Merge "Add automated-test for grabHandleColor property" into devel/master
[platform/core/uifw/dali-toolkit.git] / automated-tests / src / dali-toolkit / utc-Dali-TextField.cpp
1 /*
2  * Copyright (c) 2021 Samsung Electronics Co., Ltd.
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  * http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  *
16  */
17
18 #include <iostream>
19 #include <stdlib.h>
20 #include <unistd.h>
21
22 #include <dali/public-api/rendering/renderer.h>
23 #include <dali/integration-api/events/key-event-integ.h>
24 #include <dali/integration-api/events/touch-event-integ.h>
25
26 #include <dali/devel-api/adaptor-framework/key-devel.h>
27 #include <dali/devel-api/text-abstraction/font-client.h>
28 #include <dali-toolkit-test-suite-utils.h>
29 #include <dali-toolkit/dali-toolkit.h>
30 #include <dali-toolkit/devel-api/controls/text-controls/text-field-devel.h>
31 #include <dali-toolkit/devel-api/text/rendering-backend.h>
32 #include "toolkit-clipboard.h"
33
34 using namespace Dali;
35 using namespace Toolkit;
36
37 void dali_textfield_startup(void)
38 {
39   test_return_value = TET_UNDEF;
40 }
41
42 void dali_textfield_cleanup(void)
43 {
44   test_return_value = TET_PASS;
45 }
46
47 namespace
48 {
49
50 const char* const PROPERTY_NAME_RENDERING_BACKEND                    = "renderingBackend";
51 const char* const PROPERTY_NAME_TEXT                                 = "text";
52 const char* const PROPERTY_NAME_PLACEHOLDER_TEXT                     = "placeholderText";
53 const char* const PROPERTY_NAME_PLACEHOLDER_TEXT_FOCUSED             = "placeholderTextFocused";
54 const char* const PROPERTY_NAME_FONT_FAMILY                          = "fontFamily";
55 const char* const PROPERTY_NAME_FONT_STYLE                           = "fontStyle";
56 const char* const PROPERTY_NAME_POINT_SIZE                           = "pointSize";
57 const char* const PROPERTY_NAME_MAX_LENGTH                           = "maxLength";
58 const char* const PROPERTY_NAME_EXCEED_POLICY                        = "exceedPolicy";
59 const char* const PROPERTY_NAME_HORIZONTAL_ALIGNMENT                 = "horizontalAlignment";
60 const char* const PROPERTY_NAME_VERTICAL_ALIGNMENT                   = "verticalAlignment";
61 const char* const PROPERTY_NAME_TEXT_COLOR                           = "textColor";
62 const char* const PROPERTY_NAME_PLACEHOLDER_TEXT_COLOR               = "placeholderTextColor";
63 const char* const PROPERTY_NAME_PRIMARY_CURSOR_COLOR                 = "primaryCursorColor";
64 const char* const PROPERTY_NAME_SECONDARY_CURSOR_COLOR               = "secondaryCursorColor";
65 const char* const PROPERTY_NAME_ENABLE_CURSOR_BLINK                  = "enableCursorBlink";
66 const char* const PROPERTY_NAME_CURSOR_BLINK_INTERVAL                = "cursorBlinkInterval";
67 const char* const PROPERTY_NAME_CURSOR_BLINK_DURATION                = "cursorBlinkDuration";
68 const char* const PROPERTY_NAME_CURSOR_WIDTH                         = "cursorWidth";
69 const char* const PROPERTY_NAME_GRAB_HANDLE_IMAGE                    = "grabHandleImage";
70 const char* const PROPERTY_NAME_GRAB_HANDLE_PRESSED_IMAGE            = "grabHandlePressedImage";
71 const char* const PROPERTY_NAME_SCROLL_THRESHOLD                     = "scrollThreshold";
72 const char* const PROPERTY_NAME_SCROLL_SPEED                         = "scrollSpeed";
73 const char* const PROPERTY_NAME_SELECTION_HANDLE_IMAGE_LEFT          = "selectionHandleImageLeft";
74 const char* const PROPERTY_NAME_SELECTION_HANDLE_IMAGE_RIGHT         = "selectionHandleImageRight";
75 const char* const PROPERTY_NAME_SELECTION_HANDLE_PRESSED_IMAGE_LEFT  = "selectionHandlePressedImageLeft";
76 const char* const PROPERTY_NAME_SELECTION_HANDLE_PRESSED_IMAGE_RIGHT = "selectionHandlePressedImageRight";
77 const char* const PROPERTY_NAME_SELECTION_HANDLE_MARKER_IMAGE_LEFT   = "selectionHandleMarkerImageLeft";
78 const char* const PROPERTY_NAME_SELECTION_HANDLE_MARKER_IMAGE_RIGHT  = "selectionHandleMarkerImageRight";
79 const char* const PROPERTY_NAME_SELECTION_HIGHLIGHT_COLOR            = "selectionHighlightColor";
80 const char* const PROPERTY_NAME_DECORATION_BOUNDING_BOX              = "decorationBoundingBox";
81 const char* const PROPERTY_NAME_INPUT_METHOD_SETTINGS                = "inputMethodSettings";
82 const char* const PROPERTY_NAME_INPUT_COLOR                          = "inputColor";
83 const char* const PROPERTY_NAME_ENABLE_MARKUP                        = "enableMarkup";
84 const char* const PROPERTY_NAME_INPUT_FONT_FAMILY                    = "inputFontFamily";
85 const char* const PROPERTY_NAME_INPUT_FONT_STYLE                     = "inputFontStyle";
86 const char* const PROPERTY_NAME_INPUT_POINT_SIZE                     = "inputPointSize";
87
88 const char* const PROPERTY_NAME_UNDERLINE                            = "underline";
89 const char* const PROPERTY_NAME_INPUT_UNDERLINE                      = "inputUnderline";
90 const char* const PROPERTY_NAME_SHADOW                               = "shadow";
91 const char* const PROPERTY_NAME_INPUT_SHADOW                         = "inputShadow";
92 const char* const PROPERTY_NAME_EMBOSS                               = "emboss";
93 const char* const PROPERTY_NAME_INPUT_EMBOSS                         = "inputEmboss";
94 const char* const PROPERTY_NAME_OUTLINE                              = "outline";
95 const char* const PROPERTY_NAME_INPUT_OUTLINE                        = "inputOutline";
96
97 const char* const PROPERTY_NAME_HIDDEN_INPUT_SETTINGS                = "hiddenInputSettings";
98 const char* const PROPERTY_NAME_PIXEL_SIZE                           = "pixelSize";
99 const char* const PROPERTY_NAME_ENABLE_SELECTION                     = "enableSelection";
100 const char* const PROPERTY_NAME_PLACEHOLDER                          = "placeholder";
101 const char* const PROPERTY_NAME_ELLIPSIS                             = "ellipsis";
102 const char* const PROPERTY_NAME_ENABLE_SHIFT_SELECTION               = "enableShiftSelection";
103 const char* const PROPERTY_NAME_ENABLE_GRAB_HANDLE                   = "enableGrabHandle";
104 const char* const PROPERTY_NAME_MATCH_SYSTEM_LANGUAGE_DIRECTION      = "matchSystemLanguageDirection";
105 const char* const PROPERTY_NAME_ENABLE_GRAB_HANDLE_POPUP             = "enableGrabHandlePopup";
106 const char* const PROPERTY_NAME_BACKGROUND                           = "textBackground";
107 const char* const PROPERTY_NAME_FONT_SIZE_SCALE                      = "fontSizeScale";
108 const char* const PROPERTY_NAME_GRAB_HANDLE_COLOR                    = "grabHandleColor";
109
110 const Vector4 PLACEHOLDER_TEXT_COLOR( 0.8f, 0.8f, 0.8f, 0.8f );
111 const Dali::Vector4 LIGHT_BLUE( 0.75f, 0.96f, 1.f, 1.f ); // The text highlight color.
112
113 const float RENDER_FRAME_INTERVAL = 16.66f;
114
115 const unsigned int DEFAULT_FONT_SIZE = 1152u;
116 const std::string DEFAULT_FONT_DIR( "/resources/fonts" );
117
118 const int KEY_RETURN_CODE = 36;
119 const int KEY_A_CODE = 38;
120 const int KEY_D_CODE = 40;
121
122 const std::string DEFAULT_DEVICE_NAME("hwKeyboard");
123
124 static bool gTextChangedCallBackCalled;
125 static bool gMaxCharactersCallBackCalled;
126 static bool gInputStyleChangedCallbackCalled;
127 static Dali::Toolkit::TextField::InputStyle::Mask gInputStyleMask;
128
129 static void LoadBitmapResource(TestPlatformAbstraction& platform, int width, int height)
130 {
131   Integration::Bitmap* bitmap = Integration::Bitmap::New( Integration::Bitmap::BITMAP_2D_PACKED_PIXELS, ResourcePolicy::OWNED_DISCARD );
132   Integration::ResourcePointer resource(bitmap);
133   bitmap->GetPackedPixelsProfile()->ReserveBuffer(Pixel::RGBA8888, width, height, width, height);
134 }
135
136 static void LoadMarkerImages(ToolkitTestApplication& app, TextField textField)
137 {
138   int width(40);
139   int height(40);
140   LoadBitmapResource( app.GetPlatform(), width, height );
141
142   Property::Map propertyMap;
143   propertyMap["filename"] = "image.png";
144   propertyMap["width"] = width;
145   propertyMap["height"] = height;
146   textField.SetProperty( Toolkit::TextField::Property::SELECTION_HANDLE_IMAGE_LEFT, propertyMap );
147   textField.SetProperty( Toolkit::TextField::Property::SELECTION_HANDLE_IMAGE_RIGHT, propertyMap );
148   textField.SetProperty( Toolkit::TextField::Property::SELECTION_HANDLE_PRESSED_IMAGE_LEFT, propertyMap );
149   textField.SetProperty( Toolkit::TextField::Property::SELECTION_HANDLE_PRESSED_IMAGE_RIGHT, propertyMap );
150   textField.SetProperty( Toolkit::TextField::Property::SELECTION_HANDLE_MARKER_IMAGE_LEFT, propertyMap );
151   textField.SetProperty( Toolkit::TextField::Property::SELECTION_HANDLE_MARKER_IMAGE_RIGHT, propertyMap );
152   textField.SetProperty( Toolkit::TextField::Property::GRAB_HANDLE_IMAGE, propertyMap );
153   textField.SetProperty( Toolkit::TextField::Property::GRAB_HANDLE_PRESSED_IMAGE, propertyMap );
154 }
155
156 /*
157  * Simulate time passed by.
158  *
159  * @note this will always process at least 1 frame (1/60 sec)
160  *
161  * @param application Test application instance
162  * @param duration Time to pass in milliseconds.
163  * @return The actual time passed in milliseconds
164  */
165 static int Wait(ToolkitTestApplication& application, int duration = 0)
166 {
167   int time = 0;
168
169   for(int i = 0; i <= ( duration / RENDER_FRAME_INTERVAL); i++)
170   {
171     application.SendNotification();
172     application.Render(RENDER_FRAME_INTERVAL);
173     time += RENDER_FRAME_INTERVAL;
174   }
175
176   return time;
177 }
178
179 Dali::Integration::Point GetPointDownInside( Vector2& pos )
180 {
181   Dali::Integration::Point point;
182   point.SetState( PointState::DOWN );
183   point.SetScreenPosition( pos );
184   return point;
185 }
186
187 Dali::Integration::Point GetPointUpInside( Vector2& pos )
188 {
189   Dali::Integration::Point point;
190   point.SetState( PointState::UP );
191   point.SetScreenPosition( pos );
192   return point;
193 }
194
195 struct CallbackFunctor
196 {
197   CallbackFunctor(bool* callbackFlag)
198   : mCallbackFlag( callbackFlag )
199   {
200   }
201
202   void operator()()
203   {
204     *mCallbackFlag = true;
205   }
206   bool* mCallbackFlag;
207 };
208
209 static void TestTextChangedCallback( TextField control )
210 {
211   tet_infoline(" TestTextChangedCallback");
212
213   gTextChangedCallBackCalled = true;
214 }
215
216 static void TestMaxLengthReachedCallback( TextField control )
217 {
218   tet_infoline(" TestMaxLengthReachedCallback");
219
220   gMaxCharactersCallBackCalled = true;
221 }
222
223 static void TestInputStyleChangedCallback( TextField control, TextField::InputStyle::Mask mask )
224 {
225   tet_infoline(" TestInputStyleChangedCallback");
226
227   gInputStyleChangedCallbackCalled = true;
228   gInputStyleMask = mask;
229 }
230
231 // Generate a KeyEvent to send to Core.
232 Integration::KeyEvent GenerateKey( const std::string& keyName,
233                                    const std::string& logicalKey,
234                                    const std::string& keyString,
235                                    int keyCode,
236                                    int keyModifier,
237                                    unsigned long timeStamp,
238                                    const Integration::KeyEvent::State& keyState,
239                                    const std::string& compose = "",
240                                    const std::string& deviceName = DEFAULT_DEVICE_NAME,
241                                    const Device::Class::Type& deviceClass = Device::Class::NONE,
242                                    const Device::Subclass::Type& deviceSubclass = Device::Subclass::NONE )
243 {
244   return Integration::KeyEvent( keyName,
245                                 logicalKey,
246                                 keyString,
247                                 keyCode,
248                                 keyModifier,
249                                 timeStamp,
250                                 keyState,
251                                 compose,
252                                 deviceName,
253                                 deviceClass,
254                                 deviceSubclass );
255 }
256
257 bool DaliTestCheckMaps( const Property::Map& fontStyleMapGet, const Property::Map& fontStyleMapSet )
258 {
259   if( fontStyleMapGet.Count() == fontStyleMapSet.Count() )
260   {
261     for( unsigned int index = 0u; index < fontStyleMapGet.Count(); ++index )
262     {
263       const KeyValuePair& valueGet = fontStyleMapGet.GetKeyValue( index );
264
265       Property::Value* valueSet = NULL;
266       if ( valueGet.first.type == Property::Key::INDEX )
267       {
268         valueSet = fontStyleMapSet.Find( valueGet.first.indexKey );
269       }
270       else
271       {
272         // Get Key is a string so searching Set Map for a string key
273         valueSet = fontStyleMapSet.Find( valueGet.first.stringKey );
274       }
275
276       if( NULL != valueSet )
277       {
278         if( valueSet->GetType() == Dali::Property::STRING && ( valueGet.second.Get<std::string>() != valueSet->Get<std::string>() ) )
279         {
280           tet_printf( "Value got : [%s], expected : [%s]", valueGet.second.Get<std::string>().c_str(), valueSet->Get<std::string>().c_str() );
281           return false;
282         }
283         else if( valueSet->GetType() == Dali::Property::BOOLEAN && ( valueGet.second.Get<bool>() != valueSet->Get<bool>() ) )
284         {
285           tet_printf( "Value got : [%d], expected : [%d]", valueGet.second.Get<bool>(), valueSet->Get<bool>() );
286           return false;
287         }
288         else if( valueSet->GetType() == Dali::Property::INTEGER && ( valueGet.second.Get<int>() != valueSet->Get<int>() ) )
289         {
290           tet_printf( "Value got : [%d], expected : [%d]", valueGet.second.Get<int>(), valueSet->Get<int>() );
291           return false;
292         }
293         else if( valueSet->GetType() == Dali::Property::FLOAT && ( valueGet.second.Get<float>() != valueSet->Get<float>() ) )
294         {
295           tet_printf( "Value got : [%f], expected : [%f]", valueGet.second.Get<float>(), valueSet->Get<float>() );
296           return false;
297         }
298         else if( valueSet->GetType() == Dali::Property::VECTOR2 && ( valueGet.second.Get<Vector2>() != valueSet->Get<Vector2>() ) )
299         {
300           Vector2 vector2Get = valueGet.second.Get<Vector2>();
301           Vector2 vector2Set = valueSet->Get<Vector2>();
302           tet_printf( "Value got : [%f, %f], expected : [%f, %f]", vector2Get.x, vector2Get.y, vector2Set.x, vector2Set.y );
303           return false;
304         }
305         else if( valueSet->GetType() == Dali::Property::VECTOR4 && ( valueGet.second.Get<Vector4>() != valueSet->Get<Vector4>() ) )
306         {
307           Vector4 vector4Get = valueGet.second.Get<Vector4>();
308           Vector4 vector4Set = valueSet->Get<Vector4>();
309           tet_printf( "Value got : [%f, %f, %f, %f], expected : [%f, %f, %f, %f]", vector4Get.r, vector4Get.g, vector4Get.b, vector4Get.a, vector4Set.r, vector4Set.g, vector4Set.b, vector4Set.a );
310           return false;
311         }
312       }
313       else
314       {
315         if ( valueGet.first.type == Property::Key::INDEX )
316         {
317           tet_printf( "  The key %d doesn't exist.", valueGet.first.indexKey );
318         }
319         else
320         {
321           tet_printf( "  The key %s doesn't exist.", valueGet.first.stringKey.c_str() );
322         }
323         return false;
324       }
325     }
326   }
327
328   return true;
329 }
330
331 } // namespace
332
333 int UtcDaliToolkitTextFieldConstructorP(void)
334 {
335   ToolkitTestApplication application;
336   tet_infoline(" UtcDaliToolkitTextFieldConstructorP");
337   TextField textField;
338   DALI_TEST_CHECK( !textField );
339   END_TEST;
340 }
341
342 int UtcDaliToolkitTextFieldNewP(void)
343 {
344   ToolkitTestApplication application;
345   tet_infoline(" UtcDaliToolkitTextFieldNewP");
346   TextField textField = TextField::New();
347   DALI_TEST_CHECK( textField );
348   END_TEST;
349 }
350
351 int UtcDaliToolkitTextFieldDownCastP(void)
352 {
353   ToolkitTestApplication application;
354   tet_infoline(" UtcDaliToolkitTextFieldDownCastP");
355   TextField textField1 = TextField::New();
356   BaseHandle object( textField1 );
357
358   TextField textField2 = TextField::DownCast( object );
359   DALI_TEST_CHECK( textField2 );
360
361   TextField textField3 = DownCast< TextField >( object );
362   DALI_TEST_CHECK( textField3 );
363   END_TEST;
364 }
365
366 int UtcDaliToolkitTextFieldDownCastN(void)
367 {
368   ToolkitTestApplication application;
369   tet_infoline(" UtcDaliToolkitTextFieldDownCastN");
370   BaseHandle uninitializedObject;
371   TextField textField1 = TextField::DownCast( uninitializedObject );
372   DALI_TEST_CHECK( !textField1 );
373
374   TextField textField2 = DownCast< TextField >( uninitializedObject );
375   DALI_TEST_CHECK( !textField2 );
376   END_TEST;
377 }
378
379 int UtcDaliToolkitTextFieldCopyConstructorP(void)
380 {
381   ToolkitTestApplication application;
382   tet_infoline(" UtcDaliToolkitTextFieldCopyConstructorP");
383   TextField textField = TextField::New();
384   textField.SetProperty( TextField::Property::TEXT, "Test" );
385
386   TextField copy( textField );
387   DALI_TEST_CHECK( copy );
388   DALI_TEST_CHECK( copy.GetProperty<std::string>( TextLabel::Property::TEXT ) == textField.GetProperty<std::string>( TextLabel::Property::TEXT ) );
389   END_TEST;
390 }
391
392 int UtcDaliTextFieldMoveConstructor(void)
393 {
394   ToolkitTestApplication application;
395
396   TextField textField = TextField::New();
397   textField.SetProperty( TextEditor::Property::TEXT, "Test" );
398   DALI_TEST_CHECK( textField.GetProperty<std::string>( TextField::Property::TEXT ) == "Test" );
399
400   TextField moved = std::move( textField );
401   DALI_TEST_CHECK( moved );
402   DALI_TEST_EQUALS( 1, moved.GetBaseObject().ReferenceCount(), TEST_LOCATION );
403   DALI_TEST_CHECK( moved.GetProperty<std::string>( TextField::Property::TEXT ) == "Test" );
404   DALI_TEST_CHECK( !textField );
405
406   END_TEST;
407 }
408
409 int UtcDaliToolkitTextFieldAssignmentOperatorP(void)
410 {
411   ToolkitTestApplication application;
412   tet_infoline(" UtcDaliToolkitTextFieldAssignmentOperatorP");
413   TextField textField = TextField::New();
414   textField.SetProperty( TextField::Property::TEXT, "Test" );
415
416   TextField copy = textField;
417   DALI_TEST_CHECK( copy );
418   DALI_TEST_CHECK( copy.GetProperty<std::string>( TextField::Property::TEXT ) == textField.GetProperty<std::string>( TextField::Property::TEXT ) );
419   END_TEST;
420 }
421
422 int UtcDaliTextFieldMoveAssignment(void)
423 {
424   ToolkitTestApplication application;
425
426   TextField textField = TextField::New();
427   textField.SetProperty( TextEditor::Property::TEXT, "Test" );
428   DALI_TEST_CHECK( textField.GetProperty<std::string>( TextField::Property::TEXT ) == "Test" );
429
430   TextField moved;
431   moved = std::move( textField );
432   DALI_TEST_CHECK( moved );
433   DALI_TEST_EQUALS( 1, moved.GetBaseObject().ReferenceCount(), TEST_LOCATION );
434   DALI_TEST_CHECK( moved.GetProperty<std::string>( TextField::Property::TEXT ) == "Test" );
435   DALI_TEST_CHECK( !textField );
436
437   END_TEST;
438 }
439
440 int UtcDaliTextFieldNewP(void)
441 {
442   ToolkitTestApplication application;
443   tet_infoline(" UtcDaliToolkitTextFieldNewP");
444   TextField textField = TextField::New();
445   DALI_TEST_CHECK( textField );
446   END_TEST;
447 }
448
449 // Positive test case for a method
450 int UtcDaliTextFieldGetPropertyP(void)
451 {
452   ToolkitTestApplication application;
453   tet_infoline(" UtcDaliToolkitTextFieldGetPropertyP");
454   TextField field = TextField::New();
455   DALI_TEST_CHECK( field );
456
457   // Check Property Indices are correct
458   DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_RENDERING_BACKEND ) == DevelTextField::Property::RENDERING_BACKEND );
459   DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_TEXT ) == TextField::Property::TEXT );
460   DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_PLACEHOLDER_TEXT ) == TextField::Property::PLACEHOLDER_TEXT );
461   DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_PLACEHOLDER_TEXT_FOCUSED ) == TextField::Property::PLACEHOLDER_TEXT_FOCUSED );
462   DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_FONT_FAMILY ) == TextField::Property::FONT_FAMILY );
463   DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_FONT_STYLE ) == TextField::Property::FONT_STYLE );
464   DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_POINT_SIZE ) == TextField::Property::POINT_SIZE );
465   DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_MAX_LENGTH ) == TextField::Property::MAX_LENGTH );
466   DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_EXCEED_POLICY ) == TextField::Property::EXCEED_POLICY );
467   DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_HORIZONTAL_ALIGNMENT ) == TextField::Property::HORIZONTAL_ALIGNMENT );
468   DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_VERTICAL_ALIGNMENT ) == TextField::Property::VERTICAL_ALIGNMENT );
469   DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_TEXT_COLOR ) == TextField::Property::TEXT_COLOR );
470   DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_PLACEHOLDER_TEXT_COLOR ) == TextField::Property::PLACEHOLDER_TEXT_COLOR );
471   DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_PRIMARY_CURSOR_COLOR ) == TextField::Property::PRIMARY_CURSOR_COLOR );
472   DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_SECONDARY_CURSOR_COLOR ) == TextField::Property::SECONDARY_CURSOR_COLOR );
473   DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_ENABLE_CURSOR_BLINK ) == TextField::Property::ENABLE_CURSOR_BLINK );
474   DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_CURSOR_BLINK_INTERVAL ) == TextField::Property::CURSOR_BLINK_INTERVAL );
475   DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_CURSOR_BLINK_DURATION ) == TextField::Property::CURSOR_BLINK_DURATION );
476   DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_CURSOR_WIDTH ) == TextField::Property::CURSOR_WIDTH );
477   DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_GRAB_HANDLE_IMAGE ) == TextField::Property::GRAB_HANDLE_IMAGE );
478   DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_GRAB_HANDLE_PRESSED_IMAGE ) == TextField::Property::GRAB_HANDLE_PRESSED_IMAGE );
479   DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_SCROLL_THRESHOLD ) == TextField::Property::SCROLL_THRESHOLD );
480   DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_SCROLL_SPEED ) == TextField::Property::SCROLL_SPEED );
481   DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_SELECTION_HANDLE_IMAGE_LEFT ) == TextField::Property::SELECTION_HANDLE_IMAGE_LEFT );
482   DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_SELECTION_HANDLE_IMAGE_RIGHT ) == TextField::Property::SELECTION_HANDLE_IMAGE_RIGHT );
483   DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_SELECTION_HANDLE_PRESSED_IMAGE_LEFT ) == TextField::Property::SELECTION_HANDLE_PRESSED_IMAGE_LEFT );
484   DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_SELECTION_HANDLE_PRESSED_IMAGE_RIGHT ) == TextField::Property::SELECTION_HANDLE_PRESSED_IMAGE_RIGHT );
485   DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_SELECTION_HANDLE_MARKER_IMAGE_LEFT ) == TextField::Property::SELECTION_HANDLE_MARKER_IMAGE_LEFT );
486   DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_SELECTION_HANDLE_MARKER_IMAGE_RIGHT ) == TextField::Property::SELECTION_HANDLE_MARKER_IMAGE_RIGHT );
487   DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_SELECTION_HIGHLIGHT_COLOR ) == TextField::Property::SELECTION_HIGHLIGHT_COLOR );
488   DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_DECORATION_BOUNDING_BOX ) == TextField::Property::DECORATION_BOUNDING_BOX );
489   DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_INPUT_METHOD_SETTINGS ) == TextField::Property::INPUT_METHOD_SETTINGS );
490   DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_INPUT_COLOR ) == TextField::Property::INPUT_COLOR );
491   DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_ENABLE_MARKUP ) == TextField::Property::ENABLE_MARKUP );
492   DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_INPUT_FONT_FAMILY ) == TextField::Property::INPUT_FONT_FAMILY );
493   DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_INPUT_FONT_STYLE ) == TextField::Property::INPUT_FONT_STYLE );
494   DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_INPUT_POINT_SIZE ) == TextField::Property::INPUT_POINT_SIZE );
495   DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_UNDERLINE ) == TextField::Property::UNDERLINE );
496   DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_INPUT_UNDERLINE ) == TextField::Property::INPUT_UNDERLINE );
497   DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_SHADOW ) == TextField::Property::SHADOW );
498   DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_INPUT_SHADOW ) == TextField::Property::INPUT_SHADOW );
499   DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_EMBOSS ) == TextField::Property::EMBOSS );
500   DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_INPUT_EMBOSS ) == TextField::Property::INPUT_EMBOSS );
501   DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_OUTLINE ) == TextField::Property::OUTLINE );
502   DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_INPUT_OUTLINE ) == TextField::Property::INPUT_OUTLINE );
503   DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_HIDDEN_INPUT_SETTINGS ) == TextField::Property::HIDDEN_INPUT_SETTINGS );
504   DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_PIXEL_SIZE ) == TextField::Property::PIXEL_SIZE );
505   DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_ENABLE_SELECTION ) == TextField::Property::ENABLE_SELECTION );
506   DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_PLACEHOLDER ) == TextField::Property::PLACEHOLDER );
507   DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_ELLIPSIS ) == TextField::Property::ELLIPSIS );
508   DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_FONT_SIZE_SCALE ) == DevelTextField::Property::FONT_SIZE_SCALE );
509   DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_ENABLE_SHIFT_SELECTION ) == DevelTextField::Property::ENABLE_SHIFT_SELECTION );
510   DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_ENABLE_GRAB_HANDLE ) == DevelTextField::Property::ENABLE_GRAB_HANDLE );
511   DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_MATCH_SYSTEM_LANGUAGE_DIRECTION ) == DevelTextField::Property::MATCH_SYSTEM_LANGUAGE_DIRECTION );
512   DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_ENABLE_GRAB_HANDLE_POPUP ) == DevelTextField::Property::ENABLE_GRAB_HANDLE_POPUP );
513   DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_BACKGROUND ) == DevelTextField::Property::BACKGROUND );
514   DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_GRAB_HANDLE_COLOR ) == DevelTextField::Property::GRAB_HANDLE_COLOR );
515
516   END_TEST;
517 }
518
519 bool SetPropertyMapRetrieved( TextField& field, const Property::Index property, const std::string mapKey, const std::string mapValue )
520 {
521   bool result = false;
522   Property::Map imageMap;
523   imageMap[mapKey] =mapValue;
524
525   field.SetProperty( property , imageMap );
526   Property::Value propValue = field.GetProperty( property );
527   Property::Map* resultMap = propValue.GetMap();
528
529   if ( resultMap->Find( mapKey )->Get< std::string>() == mapValue )
530   {
531     result = true;
532   }
533
534   return result;
535 }
536
537 // Positive test case for a method
538 int UtcDaliTextFieldSetPropertyP(void)
539 {
540   ToolkitTestApplication application;
541   tet_infoline(" UtcDaliToolkitTextFieldSetPropertyP");
542   TextField field = TextField::New();
543   DALI_TEST_CHECK( field );
544   application.GetScene().Add( field );
545
546   // Note - we can't check the defaults since the stylesheets are platform-specific
547
548   // Check the render backend property.
549   field.SetProperty( DevelTextField::Property::RENDERING_BACKEND, DevelText::RENDERING_SHARED_ATLAS );
550   DALI_TEST_EQUALS( (DevelText::RenderingType)field.GetProperty<int>( DevelTextField::Property::RENDERING_BACKEND ), DevelText::RENDERING_SHARED_ATLAS, TEST_LOCATION );
551
552   field.SetProperty( DevelTextField::Property::RENDERING_BACKEND, DevelText::RENDERING_VECTOR_BASED );
553   DALI_TEST_EQUALS( (DevelText::RenderingType)field.GetProperty<int>( DevelTextField::Property::RENDERING_BACKEND ), DevelText::RENDERING_VECTOR_BASED, TEST_LOCATION );
554
555   // Check text property.
556   field.SetProperty( TextField::Property::TEXT, "Setting Text" );
557   DALI_TEST_EQUALS( field.GetProperty<std::string>( TextField::Property::TEXT ), std::string("Setting Text"), TEST_LOCATION );
558
559   // Check placeholder text properties.
560   field.SetProperty( TextField::Property::PLACEHOLDER_TEXT, "Setting Placeholder Text" );
561   DALI_TEST_EQUALS( field.GetProperty<std::string>( TextField::Property::PLACEHOLDER_TEXT ), std::string("Setting Placeholder Text"), TEST_LOCATION );
562
563   field.SetProperty( TextField::Property::PLACEHOLDER_TEXT_FOCUSED, "Setting Placeholder Text Focused" );
564   DALI_TEST_EQUALS( field.GetProperty<std::string>( TextField::Property::PLACEHOLDER_TEXT_FOCUSED ), std::string("Setting Placeholder Text Focused"), TEST_LOCATION );
565
566   // Check font properties.
567   field.SetProperty( TextField::Property::FONT_FAMILY, "Setting font family" );
568   DALI_TEST_EQUALS( field.GetProperty<std::string>( TextField::Property::FONT_FAMILY ), std::string("Setting font family"), TEST_LOCATION );
569
570   Property::Map fontStyleMapSet;
571   Property::Map fontStyleMapGet;
572   Property::Value* slantValue = NULL;
573
574   fontStyleMapSet.Insert( "weight", "bold" );
575   fontStyleMapSet.Insert( "width", "condensed" );
576   fontStyleMapSet.Insert( "slant", "italic" );
577   field.SetProperty( TextField::Property::FONT_STYLE, fontStyleMapSet );
578
579   fontStyleMapGet = field.GetProperty<Property::Map>( TextField::Property::FONT_STYLE );
580   DALI_TEST_EQUALS( fontStyleMapGet.Count(), fontStyleMapSet.Count(), TEST_LOCATION );
581   DALI_TEST_EQUALS( DaliTestCheckMaps( fontStyleMapGet, fontStyleMapSet ), true, TEST_LOCATION );
582
583   field.SetProperty( TextField::Property::POINT_SIZE, 10.f );
584   DALI_TEST_EQUALS( field.GetProperty<float>( TextField::Property::POINT_SIZE ), 10.f, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
585
586   field.SetProperty( DevelTextField::Property::FONT_SIZE_SCALE, 2.5f );
587   DALI_TEST_EQUALS( field.GetProperty<float>( DevelTextField::Property::FONT_SIZE_SCALE ), 2.5f, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
588   field.SetProperty( DevelTextField::Property::FONT_SIZE_SCALE, 1.0f );
589
590   // Reset font style.
591   fontStyleMapSet.Clear();
592   fontStyleMapSet.Insert( "weight", "normal" );
593   fontStyleMapSet.Insert( "slant", "oblique" );
594   field.SetProperty( TextField::Property::FONT_STYLE, fontStyleMapSet );
595
596   fontStyleMapGet = field.GetProperty<Property::Map>( TextField::Property::FONT_STYLE );
597   DALI_TEST_EQUALS( fontStyleMapGet.Count(), fontStyleMapSet.Count(), TEST_LOCATION );
598   DALI_TEST_EQUALS( DaliTestCheckMaps( fontStyleMapGet, fontStyleMapSet ), true, TEST_LOCATION );
599
600   fontStyleMapSet.Clear();
601   fontStyleMapSet.Insert( "slant", "roman" );
602   field.SetProperty( TextField::Property::FONT_STYLE, fontStyleMapSet );
603   fontStyleMapGet = field.GetProperty<Property::Map>( TextField::Property::FONT_STYLE );
604
605   // Replace 'roman' for 'normal'.
606   slantValue = fontStyleMapGet.Find( "slant" );
607   if( NULL != slantValue )
608   {
609     if( "normal" == slantValue->Get<std::string>() )
610     {
611       fontStyleMapGet["slant"] = "roman";
612     }
613   }
614   DALI_TEST_EQUALS( fontStyleMapGet.Count(), fontStyleMapSet.Count(), TEST_LOCATION );
615   DALI_TEST_EQUALS( DaliTestCheckMaps( fontStyleMapGet, fontStyleMapSet ), true, TEST_LOCATION );
616
617   fontStyleMapSet.Clear();
618
619   field.SetProperty( TextField::Property::FONT_STYLE, fontStyleMapSet );
620   fontStyleMapGet = field.GetProperty<Property::Map>( TextField::Property::FONT_STYLE );
621   DALI_TEST_EQUALS( fontStyleMapGet.Count(), fontStyleMapSet.Count(), TEST_LOCATION );
622   DALI_TEST_EQUALS( DaliTestCheckMaps( fontStyleMapGet, fontStyleMapSet ), true, TEST_LOCATION );
623
624   // Check that the MAX_LENGTH property can be correctly set
625   const int maxNumberOfCharacters = 20;
626   field.SetProperty( TextField::Property::MAX_LENGTH, maxNumberOfCharacters );
627   DALI_TEST_EQUALS( field.GetProperty<int>( TextField::Property::MAX_LENGTH ), maxNumberOfCharacters, TEST_LOCATION );
628
629   // Check exceed policy
630   field.SetProperty( TextField::Property::EXCEED_POLICY, Dali::Toolkit::TextField::EXCEED_POLICY_CLIP );
631   DALI_TEST_EQUALS( field.GetProperty<int>( TextField::Property::EXCEED_POLICY ), static_cast<int>( Dali::Toolkit::TextField::EXCEED_POLICY_CLIP ), TEST_LOCATION );
632   field.SetProperty( TextField::Property::EXCEED_POLICY, Dali::Toolkit::TextField::EXCEED_POLICY_ORIGINAL );
633   DALI_TEST_EQUALS( field.GetProperty<int>( TextField::Property::EXCEED_POLICY ), static_cast<int>( Dali::Toolkit::TextField::EXCEED_POLICY_ORIGINAL ), TEST_LOCATION );
634
635   // Check that the Alignment properties can be correctly set
636   field.SetProperty( TextField::Property::HORIZONTAL_ALIGNMENT, "END" );
637   DALI_TEST_EQUALS( field.GetProperty<std::string>( TextField::Property::HORIZONTAL_ALIGNMENT ), "END", TEST_LOCATION );
638   field.SetProperty( TextField::Property::VERTICAL_ALIGNMENT, "CENTER" );
639   DALI_TEST_EQUALS( field.GetProperty<std::string>( TextField::Property::VERTICAL_ALIGNMENT ), "CENTER", TEST_LOCATION );
640
641   // Check text's color property
642   field.SetProperty( TextField::Property::TEXT_COLOR, Color::WHITE );
643   DALI_TEST_EQUALS( field.GetProperty<Vector4>( TextField::Property::TEXT_COLOR ), Color::WHITE, TEST_LOCATION );
644
645   // Check placeholder text's color property.
646   field.SetProperty( TextField::Property::PLACEHOLDER_TEXT_COLOR, Color::RED );
647   DALI_TEST_EQUALS( field.GetProperty<Vector4>( TextField::Property::PLACEHOLDER_TEXT_COLOR ), Color::RED, TEST_LOCATION );
648
649   // Check cursor properties
650   field.SetProperty( TextField::Property::PRIMARY_CURSOR_COLOR, Color::RED );
651   DALI_TEST_EQUALS( field.GetProperty<Vector4>( TextField::Property::PRIMARY_CURSOR_COLOR ), Color::RED, TEST_LOCATION );
652   field.SetProperty( TextField::Property::SECONDARY_CURSOR_COLOR, Color::BLUE );
653   DALI_TEST_EQUALS( field.GetProperty<Vector4>( TextField::Property::SECONDARY_CURSOR_COLOR ), Color::BLUE, TEST_LOCATION );
654
655   field.SetProperty( TextField::Property::ENABLE_CURSOR_BLINK, false );
656   DALI_TEST_EQUALS( field.GetProperty<bool>( TextField::Property::ENABLE_CURSOR_BLINK ), false, TEST_LOCATION );
657   field.SetProperty( TextField::Property::CURSOR_BLINK_INTERVAL, 1.f );
658   DALI_TEST_EQUALS( field.GetProperty<float>( TextField::Property::CURSOR_BLINK_INTERVAL ), 1.f, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
659   field.SetProperty( TextField::Property::CURSOR_BLINK_DURATION, 10.f );
660   DALI_TEST_EQUALS( field.GetProperty<float>( TextField::Property::CURSOR_BLINK_DURATION ), 10.f, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
661   field.SetProperty( TextField::Property::CURSOR_WIDTH, 1 );
662   DALI_TEST_EQUALS( field.GetProperty<int>( TextField::Property::CURSOR_WIDTH ), 1, TEST_LOCATION );
663
664   // Check scroll properties.
665   field.SetProperty( TextField::Property::SCROLL_THRESHOLD, 1.f );
666   DALI_TEST_EQUALS( field.GetProperty<float>( TextField::Property::SCROLL_THRESHOLD ), 1.f, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
667   field.SetProperty( TextField::Property::SCROLL_SPEED, 100.f );
668   DALI_TEST_EQUALS( field.GetProperty<float>( TextField::Property::SCROLL_SPEED ), 100.f, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
669
670   // Check handle images
671   field.SetProperty( TextField::Property::GRAB_HANDLE_IMAGE, "image1" );
672   DALI_TEST_EQUALS( field.GetProperty<std::string>( TextField::Property::GRAB_HANDLE_IMAGE ), "image1", TEST_LOCATION );
673   field.SetProperty( TextField::Property::GRAB_HANDLE_PRESSED_IMAGE, "image2" );
674   DALI_TEST_EQUALS( field.GetProperty<std::string>( TextField::Property::GRAB_HANDLE_PRESSED_IMAGE ), "image2", TEST_LOCATION );
675   field.SetProperty( TextField::Property::SELECTION_HANDLE_IMAGE_LEFT, "image3" );
676
677   // Check handle images
678   DALI_TEST_CHECK( SetPropertyMapRetrieved( field, TextField::Property::SELECTION_HANDLE_IMAGE_LEFT, "filename", "leftHandleImage" )  );
679   DALI_TEST_CHECK( SetPropertyMapRetrieved( field, TextField::Property::SELECTION_HANDLE_IMAGE_RIGHT, "filename", "rightHandleImage" )  );
680   DALI_TEST_CHECK( SetPropertyMapRetrieved( field, TextField::Property::SELECTION_HANDLE_PRESSED_IMAGE_LEFT, "filename", "leftHandleImagePressed" )  );
681   DALI_TEST_CHECK( SetPropertyMapRetrieved( field, TextField::Property::SELECTION_HANDLE_PRESSED_IMAGE_RIGHT, "filename", "rightHandleImagePressed" )  );
682   DALI_TEST_CHECK( SetPropertyMapRetrieved( field, TextField::Property::SELECTION_HANDLE_MARKER_IMAGE_LEFT, "filename", "leftHandleMarkerImage" )  );
683   DALI_TEST_CHECK( SetPropertyMapRetrieved( field, TextField::Property::SELECTION_HANDLE_MARKER_IMAGE_RIGHT, "filename", "rightHandleMarkerImage" )  );
684
685   // Check the highlight color
686   field.SetProperty( TextField::Property::SELECTION_HIGHLIGHT_COLOR, Color::GREEN );
687   DALI_TEST_EQUALS( field.GetProperty<Vector4>( TextField::Property::SELECTION_HIGHLIGHT_COLOR ), Color::GREEN, TEST_LOCATION );
688
689   // Decoration bounding box
690   field.SetProperty( TextField::Property::DECORATION_BOUNDING_BOX, Rect<int>( 0, 0, 1, 1 ) );
691   DALI_TEST_EQUALS( field.GetProperty<Rect <int > >( TextField::Property::DECORATION_BOUNDING_BOX ), Rect<int>( 0, 0, 1, 1 ), TEST_LOCATION );
692
693   // Check the input method setting
694   Property::Map propertyMap;
695   InputMethod::PanelLayout::Type panelLayout = InputMethod::PanelLayout::NUMBER;
696   InputMethod::AutoCapital::Type autoCapital = InputMethod::AutoCapital::WORD;
697   InputMethod::ButtonAction::Type buttonAction = InputMethod::ButtonAction::GO;
698   int inputVariation = 1;
699   propertyMap["PANEL_LAYOUT"] = panelLayout;
700   propertyMap["AUTO_CAPITALIZE"] = autoCapital;
701   propertyMap["BUTTON_ACTION"] = buttonAction;
702   propertyMap["VARIATION"] = inputVariation;
703   field.SetProperty( TextField::Property::INPUT_METHOD_SETTINGS, propertyMap );
704
705   Property::Value value = field.GetProperty( TextField::Property::INPUT_METHOD_SETTINGS );
706   Property::Map map;
707   DALI_TEST_CHECK( value.Get( map ) );
708
709   int layout = 0;
710   DALI_TEST_CHECK( map[ "PANEL_LAYOUT" ].Get( layout ) );
711   DALI_TEST_EQUALS( static_cast<int>(panelLayout), layout, TEST_LOCATION );
712
713   int capital = 0;
714   DALI_TEST_CHECK( map[ "AUTO_CAPITALIZE" ].Get( capital ) );
715   DALI_TEST_EQUALS( static_cast<int>(autoCapital), capital, TEST_LOCATION );
716
717   int action = 0;
718   DALI_TEST_CHECK( map[ "BUTTON_ACTION" ].Get( action ) );
719   DALI_TEST_EQUALS( static_cast<int>(buttonAction), action, TEST_LOCATION );
720
721   int variation = 0;
722   DALI_TEST_CHECK( map[ "VARIATION" ].Get( variation ) );
723   DALI_TEST_EQUALS( inputVariation, variation, TEST_LOCATION );
724
725   // Check input color property.
726   field.SetProperty( TextField::Property::INPUT_COLOR, Color::YELLOW );
727   DALI_TEST_EQUALS( field.GetProperty<Vector4>( TextField::Property::INPUT_COLOR ), Color::YELLOW, TEST_LOCATION );
728
729   // Check the enable markup property.
730   DALI_TEST_CHECK( !field.GetProperty<bool>( TextField::Property::ENABLE_MARKUP ) );
731   field.SetProperty( TextField::Property::ENABLE_MARKUP, true );
732   DALI_TEST_CHECK( field.GetProperty<bool>( TextField::Property::ENABLE_MARKUP ) );
733
734   // Check input font properties.
735   field.SetProperty( TextField::Property::INPUT_FONT_FAMILY, "Setting input font family" );
736   DALI_TEST_EQUALS( field.GetProperty<std::string>( TextField::Property::INPUT_FONT_FAMILY ), "Setting input font family", TEST_LOCATION );
737
738   fontStyleMapSet.Clear();
739   fontStyleMapSet.Insert( "weight", "bold" );
740   fontStyleMapSet.Insert( "width", "condensed" );
741   fontStyleMapSet.Insert( "slant", "italic" );
742
743   field.SetProperty( TextField::Property::INPUT_FONT_STYLE, fontStyleMapSet );
744   fontStyleMapGet = field.GetProperty<Property::Map>( TextField::Property::INPUT_FONT_STYLE );
745   DALI_TEST_EQUALS( fontStyleMapGet.Count(), fontStyleMapSet.Count(), TEST_LOCATION );
746   DALI_TEST_EQUALS( DaliTestCheckMaps( fontStyleMapGet, fontStyleMapSet ), true, TEST_LOCATION );
747
748   field.SetProperty( TextField::Property::INPUT_POINT_SIZE, 12.f );
749   DALI_TEST_EQUALS( field.GetProperty<float>( TextField::Property::INPUT_POINT_SIZE ), 12.f, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
750
751   // Reset input font style.
752   fontStyleMapSet.Clear();
753   fontStyleMapSet.Insert( "weight", "normal" );
754   fontStyleMapSet.Insert( "slant", "oblique" );
755
756   field.SetProperty( TextField::Property::INPUT_FONT_STYLE, fontStyleMapSet );
757   fontStyleMapGet = field.GetProperty<Property::Map>( TextField::Property::INPUT_FONT_STYLE );
758   DALI_TEST_EQUALS( fontStyleMapGet.Count(), fontStyleMapSet.Count(), TEST_LOCATION );
759   DALI_TEST_EQUALS( DaliTestCheckMaps( fontStyleMapGet, fontStyleMapSet ), true, TEST_LOCATION );
760
761   fontStyleMapSet.Clear();
762   fontStyleMapSet.Insert( "slant", "roman" );
763
764   field.SetProperty( TextField::Property::INPUT_FONT_STYLE, fontStyleMapSet );
765   fontStyleMapGet = field.GetProperty<Property::Map>( TextField::Property::INPUT_FONT_STYLE );
766
767   // Replace 'roman' for 'normal'.
768   slantValue = fontStyleMapGet.Find( "slant" );
769   if( NULL != slantValue )
770   {
771     if( "normal" == slantValue->Get<std::string>() )
772     {
773       fontStyleMapGet["slant"] = "roman";
774     }
775   }
776   DALI_TEST_EQUALS( fontStyleMapGet.Count(), fontStyleMapSet.Count(), TEST_LOCATION );
777   DALI_TEST_EQUALS( DaliTestCheckMaps( fontStyleMapGet, fontStyleMapSet ), true, TEST_LOCATION );
778
779   fontStyleMapSet.Clear();
780
781   field.SetProperty( TextField::Property::INPUT_FONT_STYLE, fontStyleMapSet );
782   fontStyleMapGet = field.GetProperty<Property::Map>( TextField::Property::INPUT_FONT_STYLE );
783   DALI_TEST_EQUALS( fontStyleMapGet.Count(), fontStyleMapSet.Count(), TEST_LOCATION );
784   DALI_TEST_EQUALS( DaliTestCheckMaps( fontStyleMapGet, fontStyleMapSet ), true, TEST_LOCATION );
785
786   Property::Map underlineMapSet;
787   Property::Map underlineMapGet;
788
789   underlineMapSet.Insert( "enable", true );
790   underlineMapSet.Insert( "color", Color::RED );
791   underlineMapSet.Insert( "height", 1 );
792
793   // Check the underline property
794   field.SetProperty( TextField::Property::UNDERLINE, underlineMapSet );
795
796   underlineMapGet = field.GetProperty<Property::Map>( TextField::Property::UNDERLINE );
797   DALI_TEST_EQUALS( underlineMapGet.Count(), underlineMapSet.Count(), TEST_LOCATION );
798   DALI_TEST_EQUALS( DaliTestCheckMaps( underlineMapGet, underlineMapSet ), true, TEST_LOCATION );
799
800   // Check the input underline property
801   field.SetProperty( TextField::Property::INPUT_UNDERLINE, "Underline input properties" );
802   DALI_TEST_EQUALS( field.GetProperty<std::string>( TextField::Property::INPUT_UNDERLINE ), std::string("Underline input properties"), TEST_LOCATION );
803
804   // Check the shadow property
805   Property::Map shadowMapSet;
806   Property::Map shadowMapGet;
807
808   shadowMapSet.Insert( "color", Color::GREEN );
809   shadowMapSet.Insert( "offset", Vector2(2.0f, 2.0f) );
810   shadowMapSet.Insert( "blurRadius", 3.0f );
811
812   field.SetProperty( TextField::Property::SHADOW, shadowMapSet );
813
814   shadowMapGet = field.GetProperty<Property::Map>( TextField::Property::SHADOW );
815   DALI_TEST_EQUALS( shadowMapGet.Count(), shadowMapSet.Count(), TEST_LOCATION );
816   DALI_TEST_EQUALS( DaliTestCheckMaps( shadowMapGet, shadowMapSet ), true, TEST_LOCATION );
817
818   // Check the input shadow property
819   field.SetProperty( TextField::Property::INPUT_SHADOW, "Shadow input properties" );
820   DALI_TEST_EQUALS( field.GetProperty<std::string>( TextField::Property::INPUT_SHADOW ), std::string("Shadow input properties"), TEST_LOCATION );
821
822   // Check the emboss property
823   field.SetProperty( TextField::Property::EMBOSS, "Emboss properties" );
824   DALI_TEST_EQUALS( field.GetProperty<std::string>( TextField::Property::EMBOSS ), std::string("Emboss properties"), TEST_LOCATION );
825
826   // Check the input emboss property
827   field.SetProperty( TextField::Property::INPUT_EMBOSS, "Emboss input properties" );
828   DALI_TEST_EQUALS( field.GetProperty<std::string>( TextField::Property::INPUT_EMBOSS ), std::string("Emboss input properties"), TEST_LOCATION );
829
830   // Check the outline property
831
832   // Test string type first
833   // This is purely to maintain backward compatibility, but we don't support string as the outline property type.
834   field.SetProperty( TextField::Property::OUTLINE, "Outline properties" );
835   DALI_TEST_EQUALS( field.GetProperty<std::string>( TextField::Property::OUTLINE ), std::string("Outline properties"), TEST_LOCATION );
836
837   // Then test the property map type
838   Property::Map outlineMapSet;
839   Property::Map outlineMapGet;
840
841   outlineMapSet["color"] = Color::RED;
842   outlineMapSet["width"] = 2.0f;
843
844   field.SetProperty( TextField::Property::OUTLINE, outlineMapSet );
845
846   outlineMapGet = field.GetProperty<Property::Map>( TextField::Property::OUTLINE );
847   DALI_TEST_EQUALS( outlineMapGet.Count(), outlineMapSet.Count(), TEST_LOCATION );
848   DALI_TEST_EQUALS( DaliTestCheckMaps( outlineMapGet, outlineMapSet ), true, TEST_LOCATION );
849
850   // Check the input outline property
851   field.SetProperty( TextField::Property::INPUT_OUTLINE, "Outline input properties" );
852   DALI_TEST_EQUALS( field.GetProperty<std::string>( TextField::Property::INPUT_OUTLINE ), std::string("Outline input properties"), TEST_LOCATION );
853
854   // Check the hidden input settings property
855   Property::Map hiddenMapSet;
856   Property::Map hiddenMapGet;
857   hiddenMapSet[ HiddenInput::Property::MODE ] = HiddenInput::Mode::HIDE_ALL;
858   hiddenMapSet[ HiddenInput::Property::SHOW_LAST_CHARACTER_DURATION ] = 2;
859   hiddenMapSet[ HiddenInput::Property::SUBSTITUTE_COUNT ] = 4;
860   hiddenMapSet[ HiddenInput::Property::SUBSTITUTE_CHARACTER ] = 0x23;
861   field.SetProperty( TextField::Property::HIDDEN_INPUT_SETTINGS, hiddenMapSet );
862
863   hiddenMapGet = field.GetProperty<Property::Map>( TextField::Property::HIDDEN_INPUT_SETTINGS );
864   DALI_TEST_EQUALS( hiddenMapSet.Count(), hiddenMapGet.Count(), TEST_LOCATION );
865   DALI_TEST_EQUALS( DaliTestCheckMaps( hiddenMapSet, hiddenMapGet ), true, TEST_LOCATION );
866
867   // Check the pixel size of font
868   field.SetProperty( TextField::Property::PIXEL_SIZE, 20.f );
869   DALI_TEST_EQUALS( field.GetProperty<float>( TextField::Property::PIXEL_SIZE ), 20.f, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
870
871   // Check the enable selection property
872   field.SetProperty( TextField::Property::ENABLE_SELECTION, false );
873   DALI_TEST_EQUALS( field.GetProperty<bool>( TextField::Property::ENABLE_SELECTION ), false, TEST_LOCATION );
874
875   // Check the placeholder property with pixel size
876   Property::Map placeholderPixelSizeMapSet;
877   Property::Map placeholderPixelSizeMapGet;
878   Property::Map placeholderFontstyleMap;
879   placeholderPixelSizeMapSet["text"] = "Setting Placeholder Text";
880   placeholderPixelSizeMapSet["textFocused"] = "Setting Placeholder Text Focused";
881   placeholderPixelSizeMapSet["color"] = Color::BLUE;
882   placeholderPixelSizeMapSet["fontFamily"] = "Arial";
883   placeholderPixelSizeMapSet["pixelSize"] = 15.0f;
884   placeholderPixelSizeMapSet["ellipsis"] = true;
885
886   placeholderFontstyleMap.Insert( "weight", "bold" );
887   placeholderPixelSizeMapSet["placeholderFontStyle"] = placeholderFontstyleMap;
888   field.SetProperty( TextField::Property::PLACEHOLDER, placeholderPixelSizeMapSet );
889
890   placeholderPixelSizeMapGet = field.GetProperty<Property::Map>( TextField::Property::PLACEHOLDER );
891   DALI_TEST_EQUALS( placeholderPixelSizeMapGet.Count(), placeholderPixelSizeMapSet.Count(), TEST_LOCATION );
892
893   tet_infoline("Test Placeholder settings set as strings is converted correctly to Property Index key and holds set value");
894   Property::Map placeholderConversionMap;
895   placeholderConversionMap[ Text::PlaceHolder::Property::TEXT ] = placeholderPixelSizeMapSet["text"];
896   placeholderConversionMap[ Text::PlaceHolder::Property::TEXT_FOCUSED ] = placeholderPixelSizeMapSet["textFocused"] ;
897   placeholderConversionMap[ Text::PlaceHolder::Property::COLOR ] = placeholderPixelSizeMapSet["color"];
898   placeholderConversionMap[ Text::PlaceHolder::Property::FONT_STYLE ] = placeholderPixelSizeMapSet["fontStyle"];
899   placeholderConversionMap[ Text::PlaceHolder::Property::FONT_FAMILY ] = placeholderPixelSizeMapSet["fontFamily"];
900   placeholderConversionMap[ Text::PlaceHolder::Property::PIXEL_SIZE ] = placeholderPixelSizeMapSet["pixelSize"];
901
902   DALI_TEST_EQUALS( DaliTestCheckMaps( placeholderPixelSizeMapGet, placeholderConversionMap ), true, TEST_LOCATION );
903
904   // Check the placeholder property with point size
905   Property::Map placeholderMapSet;
906   Property::Map placeholderMapGet;
907   placeholderMapSet["text"] = "Setting Placeholder Text";
908   placeholderMapSet["textFocused"] = "Setting Placeholder Text Focused";
909   placeholderMapSet["color"] = Color::RED;
910   placeholderMapSet["fontFamily"] = "Arial";
911   placeholderMapSet["pointSize"] = 12.0f;
912   placeholderMapSet["ellipsis"] = false;
913
914   // Check the placeholder font style property
915   placeholderFontstyleMap.Clear();
916
917   placeholderFontstyleMap.Insert( "weight", "bold" );
918   placeholderFontstyleMap.Insert( "width", "condensed" );
919   placeholderFontstyleMap.Insert( "slant", "italic" );
920   placeholderMapSet["fontStyle"] = placeholderFontstyleMap;
921   field.SetProperty( TextField::Property::PLACEHOLDER, placeholderMapSet );
922
923   placeholderMapGet = field.GetProperty<Property::Map>( TextField::Property::PLACEHOLDER );
924   DALI_TEST_EQUALS( placeholderMapGet.Count(), placeholderMapSet.Count(), TEST_LOCATION );
925
926   placeholderConversionMap.Clear();
927   placeholderConversionMap[ Text::PlaceHolder::Property::TEXT ] = placeholderPixelSizeMapSet["text"];
928   placeholderConversionMap[ Text::PlaceHolder::Property::TEXT_FOCUSED ] = placeholderPixelSizeMapSet["textFocused"] ;
929   placeholderConversionMap[ Text::PlaceHolder::Property::COLOR ] = placeholderPixelSizeMapSet["color"];
930   placeholderConversionMap[ Text::PlaceHolder::Property::FONT_STYLE ] = placeholderPixelSizeMapSet["fontStyle"];
931   placeholderConversionMap[ Text::PlaceHolder::Property::FONT_FAMILY ] = placeholderPixelSizeMapSet["fontFamily"];
932   placeholderConversionMap[ Text::PlaceHolder::Property::POINT_SIZE ] = placeholderPixelSizeMapSet["pointSize"];
933
934   DALI_TEST_EQUALS( DaliTestCheckMaps( placeholderMapGet, placeholderConversionMap ), true, TEST_LOCATION );
935
936   // Reset font style.
937   placeholderFontstyleMap.Clear();
938   placeholderFontstyleMap.Insert( "weight", "normal" );
939   placeholderFontstyleMap.Insert( "slant", "oblique" );
940   placeholderMapSet["fontStyle"] = placeholderFontstyleMap;
941   field.SetProperty( TextField::Property::PLACEHOLDER, placeholderMapSet );
942
943   placeholderMapGet = field.GetProperty<Property::Map>( TextField::Property::PLACEHOLDER );
944   DALI_TEST_EQUALS( placeholderMapGet.Count(), placeholderMapSet.Count(), TEST_LOCATION );
945
946   placeholderConversionMap[ Text::PlaceHolder::Property::FONT_STYLE ] = placeholderPixelSizeMapSet["fontStyle"];
947   DALI_TEST_EQUALS( DaliTestCheckMaps( placeholderMapGet, placeholderConversionMap ), true, TEST_LOCATION );
948
949   placeholderFontstyleMap.Clear();
950   placeholderFontstyleMap.Insert( "slant", "roman" );
951   placeholderMapSet["fontStyle"] = placeholderFontstyleMap;
952   placeholderConversionMap[ Text::PlaceHolder::Property::FONT_STYLE ] = placeholderPixelSizeMapSet["fontStyle"];
953
954   field.SetProperty( TextField::Property::PLACEHOLDER, placeholderMapSet );
955
956   placeholderMapGet = field.GetProperty<Property::Map>( TextField::Property::PLACEHOLDER );
957
958   placeholderFontstyleMap.Clear();
959   placeholderMapSet["fontStyle"] = placeholderFontstyleMap;
960   placeholderConversionMap[ Text::PlaceHolder::Property::FONT_STYLE ] = placeholderPixelSizeMapSet["fontStyle"];
961
962   field.SetProperty( TextField::Property::PLACEHOLDER, placeholderMapSet );
963   placeholderMapGet = field.GetProperty<Property::Map>( TextField::Property::PLACEHOLDER );
964   DALI_TEST_EQUALS( placeholderMapGet.Count(), placeholderMapSet.Count(), TEST_LOCATION );
965
966   DALI_TEST_EQUALS( DaliTestCheckMaps( placeholderMapGet, placeholderConversionMap ), true, TEST_LOCATION );
967
968   // Check the ellipsis property
969   DALI_TEST_CHECK( !field.GetProperty<bool>( TextField::Property::ELLIPSIS ) );
970   field.SetProperty( TextField::Property::ELLIPSIS, true );
971   DALI_TEST_CHECK( field.GetProperty<bool>( TextField::Property::ELLIPSIS ) );
972
973   field.SetProperty( Actor::Property::LAYOUT_DIRECTION, LayoutDirection::RIGHT_TO_LEFT );
974   DALI_TEST_EQUALS( field.GetProperty<int>( Actor::Property::LAYOUT_DIRECTION ), static_cast<int>( LayoutDirection::RIGHT_TO_LEFT ), TEST_LOCATION );
975
976   // Test the ENABLE_GRAB_HANDLE_POPUP property
977   DALI_TEST_CHECK( field.GetProperty<bool>( DevelTextField::Property::ENABLE_GRAB_HANDLE_POPUP ) );
978   field.SetProperty( DevelTextField::Property::ENABLE_GRAB_HANDLE_POPUP, false );
979   DALI_TEST_CHECK( !field.GetProperty<bool>( DevelTextField::Property::ENABLE_GRAB_HANDLE_POPUP ) );
980
981   // Check the background property
982   field.SetProperty( DevelTextField::Property::BACKGROUND, Color::RED );
983   DALI_TEST_EQUALS( field.GetProperty<Vector4>( DevelTextField::Property::BACKGROUND ), Color::RED, TEST_LOCATION );
984
985   //Check handle color
986   field.SetProperty( DevelTextField::Property::GRAB_HANDLE_COLOR, Color::GREEN );
987   DALI_TEST_EQUALS( field.GetProperty<Vector4>( DevelTextField::Property::GRAB_HANDLE_COLOR ), Color::GREEN, TEST_LOCATION );
988
989   application.SendNotification();
990   application.Render();
991
992   END_TEST;
993 }
994
995 // Positive Atlas Text Renderer test
996 int utcDaliTextFieldAtlasRenderP(void)
997 {
998   ToolkitTestApplication application;
999   tet_infoline(" UtcDaliToolkitTextFieldAtlasRenderP");
1000   StyleManager styleManager = StyleManager::Get();
1001   styleManager.ApplyDefaultTheme();
1002   TextField field = TextField::New();
1003   DALI_TEST_CHECK( field );
1004
1005   field.SetProperty( TextField::Property::HORIZONTAL_ALIGNMENT, "CENTER" );
1006
1007   application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
1008
1009   application.GetScene().Add( field );
1010
1011   try
1012   {
1013     // Render some text with the shared atlas backend
1014     field.SetProperty( DevelTextField::Property::RENDERING_BACKEND, DevelText::RENDERING_SHARED_ATLAS );
1015     application.SendNotification();
1016     application.Render();
1017   }
1018   catch( ... )
1019   {
1020     tet_result(TET_FAIL);
1021   }
1022   END_TEST;
1023 }
1024
1025 // Positive test for the textChanged signal.
1026 int utcDaliTextFieldTextChangedP(void)
1027 {
1028   ToolkitTestApplication application;
1029   tet_infoline(" utcDaliTextFieldTextChangedP");
1030   TextField field = TextField::New();
1031   DALI_TEST_CHECK( field );
1032
1033   application.GetScene().Add( field );
1034
1035   // connect to the text changed signal.
1036   ConnectionTracker* testTracker = new ConnectionTracker();
1037   field.TextChangedSignal().Connect(&TestTextChangedCallback);
1038   bool textChangedSignal = false;
1039   field.ConnectSignal( testTracker, "textChanged",   CallbackFunctor(&textChangedSignal) );
1040
1041   gTextChangedCallBackCalled = false;
1042   field.SetProperty( TextField::Property::TEXT, "ABC" );
1043   application.SendNotification();
1044   application.Render();
1045   DALI_TEST_CHECK( gTextChangedCallBackCalled );
1046   DALI_TEST_CHECK( textChangedSignal );
1047
1048   field.SetKeyInputFocus();
1049
1050   gTextChangedCallBackCalled = false;
1051   application.ProcessEvent( GenerateKey( "D", "", "D", KEY_D_CODE, 0, 0, Integration::KeyEvent::DOWN, "D", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
1052   application.SendNotification();
1053   application.Render();
1054   DALI_TEST_CHECK( gTextChangedCallBackCalled );
1055
1056   // Remove all text
1057   field.SetProperty( TextField::Property::TEXT, "" );
1058   application.SendNotification();
1059   application.Render();
1060
1061   // Pressing backspace key: TextChangedCallback should not be called when there is no text in textfield.
1062   gTextChangedCallBackCalled = false;
1063   application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_BACKSPACE, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
1064   application.SendNotification();
1065   application.Render();
1066   DALI_TEST_CHECK( !gTextChangedCallBackCalled );
1067
1068   // Pressing delete key: TextChangedCallback should not be called when there is no text in textfield.
1069   gTextChangedCallBackCalled = false;
1070   application.ProcessEvent( GenerateKey( "", "", "", Dali::DevelKey::DALI_KEY_DELETE, 0, 0, Integration::KeyEvent::DOWN, "Delete", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
1071   application.SendNotification();
1072   application.Render();
1073   DALI_TEST_CHECK( !gTextChangedCallBackCalled );
1074
1075   END_TEST;
1076 }
1077
1078 int utcDaliTextFieldTextChangedWithInputMethodContext(void)
1079 {
1080   ToolkitTestApplication application;
1081   tet_infoline(" utcDaliTextFieldTextChangedWithInputMethodContext");
1082   TextField field = TextField::New();
1083   DALI_TEST_CHECK( field );
1084
1085
1086   application.GetScene().Add( field );
1087
1088   // connect to the text changed signal.
1089   ConnectionTracker* testTracker = new ConnectionTracker();
1090   field.TextChangedSignal().Connect(&TestTextChangedCallback);
1091   bool textChangedSignal = false;
1092   field.ConnectSignal( testTracker, "textChanged",   CallbackFunctor(&textChangedSignal) );
1093
1094
1095   // get InputMethodContext
1096   std::string text;
1097   InputMethodContext::EventData imfEvent;
1098   InputMethodContext inputMethodContext = DevelTextField::GetInputMethodContext( field );
1099
1100   field.SetKeyInputFocus();
1101   field.SetProperty( DevelTextField::Property::ENABLE_EDITING, true );
1102
1103   // input text
1104   gTextChangedCallBackCalled = false;
1105   imfEvent = InputMethodContext::EventData( InputMethodContext::PRE_EDIT, "ㅎ", 0, 1 );
1106   inputMethodContext.EventReceivedSignal().Emit(inputMethodContext, imfEvent);
1107   application.SendNotification();
1108   application.Render();
1109   DALI_TEST_CHECK( gTextChangedCallBackCalled );
1110   DALI_TEST_EQUALS( field.GetProperty<std::string>( TextField::Property::TEXT ), std::string("ㅎ"), TEST_LOCATION );
1111
1112   gTextChangedCallBackCalled = false;
1113   imfEvent = InputMethodContext::EventData( InputMethodContext::PRE_EDIT, "호", 0, 1 );
1114   inputMethodContext.EventReceivedSignal().Emit(inputMethodContext, imfEvent);
1115   application.SendNotification();
1116   application.Render();
1117   DALI_TEST_CHECK( gTextChangedCallBackCalled );
1118   DALI_TEST_EQUALS( field.GetProperty<std::string>( TextField::Property::TEXT ), std::string("호"), TEST_LOCATION );
1119
1120   gTextChangedCallBackCalled = false;
1121   imfEvent = InputMethodContext::EventData( InputMethodContext::PRE_EDIT, "혿", 0, 1 );
1122   inputMethodContext.EventReceivedSignal().Emit(inputMethodContext, imfEvent);
1123   application.SendNotification();
1124   application.Render();
1125   DALI_TEST_CHECK( gTextChangedCallBackCalled );
1126   DALI_TEST_EQUALS( field.GetProperty<std::string>( TextField::Property::TEXT ), std::string("혿"), TEST_LOCATION );
1127
1128   gTextChangedCallBackCalled = false;
1129   imfEvent = InputMethodContext::EventData( InputMethodContext::PRE_EDIT, "", 0, 1 );
1130   inputMethodContext.EventReceivedSignal().Emit(inputMethodContext, imfEvent);
1131   DALI_TEST_CHECK( !gTextChangedCallBackCalled );
1132
1133   imfEvent = InputMethodContext::EventData( InputMethodContext::COMMIT, "호", 0, 1 );
1134   inputMethodContext.EventReceivedSignal().Emit(inputMethodContext, imfEvent);
1135   DALI_TEST_CHECK( !gTextChangedCallBackCalled );
1136
1137   imfEvent = InputMethodContext::EventData( InputMethodContext::PRE_EDIT, "두", 1, 2 );
1138   inputMethodContext.EventReceivedSignal().Emit(inputMethodContext, imfEvent);
1139   DALI_TEST_CHECK( !gTextChangedCallBackCalled );
1140
1141   application.SendNotification();
1142   application.Render();
1143   DALI_TEST_CHECK( gTextChangedCallBackCalled );
1144   DALI_TEST_EQUALS( field.GetProperty<std::string>( TextField::Property::TEXT ), std::string("호두"), TEST_LOCATION );
1145
1146   END_TEST;
1147 }
1148
1149
1150 // Negative test for the textChanged signal.
1151 int utcDaliTextFieldTextChangedN(void)
1152 {
1153   ToolkitTestApplication application;
1154   tet_infoline(" utcDaliTextFieldTextChangedN");
1155   TextField field = TextField::New();
1156   DALI_TEST_CHECK( field );
1157
1158   application.GetScene().Add( field );
1159
1160   // connect to the text changed signal.
1161   ConnectionTracker* testTracker = new ConnectionTracker();
1162   field.TextChangedSignal().Connect(&TestTextChangedCallback);
1163   bool textChangedSignal = false;
1164   field.ConnectSignal( testTracker, "textChanged",   CallbackFunctor(&textChangedSignal) );
1165
1166   gTextChangedCallBackCalled = false;
1167   field.SetProperty( TextField::Property::PLACEHOLDER_TEXT, "ABC" ); // Setting placeholder, not TEXT
1168   application.SendNotification();
1169   application.Render();
1170   DALI_TEST_CHECK( !gTextChangedCallBackCalled );
1171   DALI_TEST_CHECK( !textChangedSignal );
1172
1173   END_TEST;
1174 }
1175
1176 // Positive test for Max Characters reached signal.
1177 int utcDaliTextFieldMaxCharactersReachedP(void)
1178 {
1179   ToolkitTestApplication application;
1180   tet_infoline(" utcDaliTextFieldMaxCharactersReachedP");
1181   TextField field = TextField::New();
1182   DALI_TEST_CHECK( field );
1183
1184   application.GetScene().Add( field );
1185
1186   const int maxNumberOfCharacters = 1;
1187   field.SetProperty( TextField::Property::MAX_LENGTH, maxNumberOfCharacters );
1188
1189   field.SetKeyInputFocus();
1190
1191   // connect to the text changed signal.
1192   ConnectionTracker* testTracker = new ConnectionTracker();
1193   field.MaxLengthReachedSignal().Connect(&TestMaxLengthReachedCallback);
1194   bool maxLengthReachedSignal = false;
1195   field.ConnectSignal( testTracker, "maxLengthReached",   CallbackFunctor(&maxLengthReachedSignal) );
1196
1197   gMaxCharactersCallBackCalled = false;
1198
1199   application.ProcessEvent( GenerateKey( "a", "", "a", KEY_A_CODE, 0, 0, Integration::KeyEvent::DOWN, "a", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
1200   application.ProcessEvent( GenerateKey( "a", "", "a", KEY_A_CODE, 0, 0, Integration::KeyEvent::DOWN, "a", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
1201
1202   DALI_TEST_CHECK( gMaxCharactersCallBackCalled );
1203   DALI_TEST_CHECK( maxLengthReachedSignal );
1204
1205   END_TEST;
1206 }
1207
1208 // Negative test for Max Characters reached signal.
1209 int utcDaliTextFieldMaxCharactersReachedN(void)
1210 {
1211   ToolkitTestApplication application;
1212   tet_infoline(" utcDaliTextFieldMaxCharactersReachedN");
1213   TextField field = TextField::New();
1214   DALI_TEST_CHECK( field );
1215
1216   application.GetScene().Add( field );
1217
1218   const int maxNumberOfCharacters = 3;
1219   field.SetProperty( TextField::Property::MAX_LENGTH, maxNumberOfCharacters );
1220
1221   field.SetKeyInputFocus();
1222
1223   // connect to the text changed signal.
1224   ConnectionTracker* testTracker = new ConnectionTracker();
1225   field.MaxLengthReachedSignal().Connect(&TestMaxLengthReachedCallback);
1226   bool maxLengthReachedSignal = false;
1227   field.ConnectSignal( testTracker, "maxLengthReached",   CallbackFunctor(&maxLengthReachedSignal) );
1228
1229   gMaxCharactersCallBackCalled = false;
1230
1231   application.ProcessEvent( GenerateKey( "a", "", "a", KEY_A_CODE, 0, 0, Integration::KeyEvent::DOWN, "a", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
1232   application.ProcessEvent( GenerateKey( "a", "", "a", KEY_A_CODE, 0, 0, Integration::KeyEvent::DOWN, "a", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
1233
1234   DALI_TEST_CHECK( !gMaxCharactersCallBackCalled );
1235   DALI_TEST_CHECK( !maxLengthReachedSignal );
1236
1237   application.ProcessEvent( GenerateKey( "Return", "", "\r", KEY_RETURN_CODE, 0, 0, Integration::KeyEvent::DOWN, "\r", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
1238
1239   DALI_TEST_CHECK( !gMaxCharactersCallBackCalled );
1240   DALI_TEST_CHECK( !maxLengthReachedSignal );
1241
1242   END_TEST;
1243 }
1244
1245 int utcDaliTextFieldInputStyleChanged01(void)
1246 {
1247   // The text-field emits signals when the input style changes. These changes of style are
1248   // detected during the relayout process (size negotiation), i.e after the cursor has been moved. Signals
1249   // can't be emitted during the size negotiation as the callbacks may update the UI.
1250   // The text-field adds an idle callback to the adaptor to emit the signals after the size negotiation.
1251   // The ToolkitTestApplication creates an implementation of the adaptor stub and a queue of idle callbacks.
1252   ToolkitTestApplication application;
1253   tet_infoline(" utcDaliTextFieldInputStyleChanged01");
1254
1255   // Load some fonts.
1256
1257   char* pathNamePtr = get_current_dir_name();
1258   const std::string pathName( pathNamePtr );
1259   free( pathNamePtr );
1260
1261   TextAbstraction::FontClient fontClient = TextAbstraction::FontClient::Get();
1262   fontClient.SetDpi( 93u, 93u );
1263
1264   fontClient.GetFontId( pathName + DEFAULT_FONT_DIR + "/dejavu/DejaVuSerif.ttf", DEFAULT_FONT_SIZE );
1265   fontClient.GetFontId( pathName + DEFAULT_FONT_DIR + "/dejavu/DejaVuSerif-Bold.ttf", DEFAULT_FONT_SIZE );
1266
1267   TextField field = TextField::New();
1268   DALI_TEST_CHECK( field );
1269
1270
1271   field.SetProperty( Actor::Property::SIZE, Vector2( 300.f, 50.f ) );
1272   field.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT );
1273   field.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT );
1274
1275   field.SetProperty( TextField::Property::ENABLE_MARKUP, true );
1276   field.SetProperty( TextField::Property::TEXT, "<font family='DejaVuSerif' size='18'>He<color value='green'>llo</color> <font weight='bold'>world</font> demo</font>" );
1277
1278   // connect to the text changed signal.
1279   ConnectionTracker* testTracker = new ConnectionTracker();
1280   field.InputStyleChangedSignal().Connect( &TestInputStyleChangedCallback );
1281   bool inputStyleChangedSignal = false;
1282   field.ConnectSignal( testTracker, "inputStyleChanged",   CallbackFunctor(&inputStyleChangedSignal) );
1283
1284   application.GetScene().Add( field );
1285
1286   // Render and notify
1287   application.SendNotification();
1288   application.Render();
1289
1290   // Executes the idle callbacks added by the text control on the change of input style.
1291   application.RunIdles();
1292
1293   gInputStyleChangedCallbackCalled = false;
1294   gInputStyleMask = TextField::InputStyle::NONE;
1295   inputStyleChangedSignal = false;
1296
1297   // Create a tap event to touch the text field.
1298   TestGenerateTap( application, 18.0f, 25.0f );
1299
1300   // Render and notify
1301   application.SendNotification();
1302   application.Render();
1303
1304   // Executes the idle callbacks added by the text control on the change of input style.
1305   application.RunIdles();
1306
1307   DALI_TEST_CHECK( gInputStyleChangedCallbackCalled );
1308   if( gInputStyleChangedCallbackCalled )
1309   {
1310     DALI_TEST_EQUALS( static_cast<unsigned int>( gInputStyleMask ), static_cast<unsigned int>( TextField::InputStyle::FONT_FAMILY | TextField::InputStyle::POINT_SIZE ), TEST_LOCATION );
1311
1312     const std::string fontFamily = field.GetProperty( TextField::Property::INPUT_FONT_FAMILY ).Get<std::string>();
1313     DALI_TEST_EQUALS( fontFamily, "DejaVuSerif", TEST_LOCATION );
1314
1315     const float pointSize = field.GetProperty( TextField::Property::INPUT_POINT_SIZE ).Get<float>();
1316     DALI_TEST_EQUALS( pointSize, 18.f, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
1317   }
1318   DALI_TEST_CHECK( inputStyleChangedSignal );
1319
1320   gInputStyleChangedCallbackCalled = false;
1321   gInputStyleMask = TextField::InputStyle::NONE;
1322   inputStyleChangedSignal = false;
1323
1324   // Create a tap event to touch the text field.
1325   TestGenerateTap( application, 30.0f, 25.0f );
1326
1327   // Render and notify
1328   application.SendNotification();
1329   application.Render();
1330
1331   // Executes the idle callbacks added by the text control on the change of input style.
1332   application.RunIdles();
1333
1334   DALI_TEST_CHECK( !gInputStyleChangedCallbackCalled );
1335   DALI_TEST_CHECK( !inputStyleChangedSignal );
1336
1337   gInputStyleChangedCallbackCalled = false;
1338   gInputStyleMask = TextField::InputStyle::NONE;
1339   inputStyleChangedSignal = false;
1340
1341   // Create a tap event to touch the text field.
1342   TestGenerateTap( application, 43.0f, 25.0f );
1343
1344   // Render and notify
1345   application.SendNotification();
1346   application.Render();
1347
1348   // Executes the idle callbacks added by the text control on the change of input style.
1349   application.RunIdles();
1350
1351   DALI_TEST_CHECK( gInputStyleChangedCallbackCalled );
1352   if( gInputStyleChangedCallbackCalled )
1353   {
1354     DALI_TEST_EQUALS( static_cast<unsigned int>( gInputStyleMask ), static_cast<unsigned int>( TextField::InputStyle::COLOR ), TEST_LOCATION );
1355
1356     const Vector4 color = field.GetProperty( TextField::Property::INPUT_COLOR ).Get<Vector4>();
1357     DALI_TEST_EQUALS( color, Color::GREEN, TEST_LOCATION );
1358   }
1359   DALI_TEST_CHECK( inputStyleChangedSignal );
1360
1361   gInputStyleChangedCallbackCalled = false;
1362   gInputStyleMask = TextField::InputStyle::NONE;
1363   inputStyleChangedSignal = false;
1364
1365   // Create a tap event to touch the text field.
1366   TestGenerateTap( application, 88.0f, 25.0f );
1367
1368   // Render and notify
1369   application.SendNotification();
1370   application.Render();
1371
1372   // Executes the idle callbacks added by the text control on the change of input style.
1373   application.RunIdles();
1374
1375   DALI_TEST_CHECK( gInputStyleChangedCallbackCalled );
1376   if( gInputStyleChangedCallbackCalled )
1377   {
1378     DALI_TEST_EQUALS( static_cast<unsigned int>( gInputStyleMask ), static_cast<unsigned int>( TextField::InputStyle::COLOR | TextField::InputStyle::FONT_STYLE ), TEST_LOCATION );
1379
1380     const Vector4 color = field.GetProperty( TextField::Property::INPUT_COLOR ).Get<Vector4>();
1381     DALI_TEST_EQUALS( color, Color::BLACK, TEST_LOCATION );
1382
1383     const Property::Map fontStyleMapGet = field.GetProperty( TextField::Property::INPUT_FONT_STYLE ).Get<Property::Map>();
1384
1385     Property::Map fontStyleMapSet;
1386     fontStyleMapSet.Insert( "weight", "bold" );
1387
1388     DALI_TEST_EQUALS( fontStyleMapGet.Count(), fontStyleMapSet.Count(), TEST_LOCATION );
1389     DALI_TEST_EQUALS( DaliTestCheckMaps( fontStyleMapGet, fontStyleMapSet ), true, TEST_LOCATION );
1390   }
1391   DALI_TEST_CHECK( inputStyleChangedSignal );
1392
1393   gInputStyleChangedCallbackCalled = false;
1394   gInputStyleMask = TextField::InputStyle::NONE;
1395   inputStyleChangedSignal = false;
1396
1397   // Create a tap event to touch the text field.
1398   TestGenerateTap( application, 115.0f, 25.0f );
1399
1400   // Render and notify
1401   application.SendNotification();
1402   application.Render();
1403
1404   // Executes the idle callbacks added by the text control on the change of input style.
1405   application.RunIdles();
1406
1407   DALI_TEST_CHECK( !gInputStyleChangedCallbackCalled );
1408   DALI_TEST_CHECK( !inputStyleChangedSignal );
1409
1410   gInputStyleChangedCallbackCalled = false;
1411   gInputStyleMask = TextField::InputStyle::NONE;
1412   inputStyleChangedSignal = false;
1413
1414   // Create a tap event to touch the text field.
1415   TestGenerateTap( application, 164.0f, 25.0f );
1416
1417   // Render and notify
1418   application.SendNotification();
1419   application.Render();
1420
1421   // Executes the idle callbacks added by the text control on the change of input style.
1422   application.RunIdles();
1423
1424   DALI_TEST_CHECK( gInputStyleChangedCallbackCalled );
1425   if( gInputStyleChangedCallbackCalled )
1426   {
1427     DALI_TEST_EQUALS( static_cast<unsigned int>( gInputStyleMask ), static_cast<unsigned int>( TextField::InputStyle::FONT_STYLE ), TEST_LOCATION );
1428
1429     const std::string style = field.GetProperty( TextField::Property::INPUT_FONT_STYLE ).Get<std::string>();
1430     DALI_TEST_CHECK( style.empty() );
1431   }
1432   DALI_TEST_CHECK( inputStyleChangedSignal );
1433
1434   gInputStyleChangedCallbackCalled = false;
1435   gInputStyleMask = TextField::InputStyle::NONE;
1436   inputStyleChangedSignal = false;
1437
1438   // Create a tap event to touch the text field.
1439   TestGenerateTap( application, 191.0f, 25.0f );
1440
1441   // Render and notify
1442   application.SendNotification();
1443   application.Render();
1444
1445   // Executes the idle callbacks added by the text control on the change of input style.
1446   application.RunIdles();
1447
1448   DALI_TEST_CHECK( !gInputStyleChangedCallbackCalled );
1449   DALI_TEST_CHECK( !inputStyleChangedSignal );
1450
1451   END_TEST;
1452 }
1453
1454 int utcDaliTextFieldInputStyleChanged02(void)
1455 {
1456   // The text-field emits signals when the input style changes. These changes of style are
1457   // detected during the relayout process (size negotiation), i.e after the cursor has been moved. Signals
1458   // can't be emitted during the size negotiation as the callbacks may update the UI.
1459   // The text-field adds an idle callback to the adaptor to emit the signals after the size negotiation.
1460   // The ToolkitTestApplication creates an implementation of the adaptor stub and a queue of idle callbacks.
1461   ToolkitTestApplication application;
1462   tet_infoline(" utcDaliTextFieldInputStyleChanged02");
1463
1464   // Load some fonts.
1465
1466   char* pathNamePtr = get_current_dir_name();
1467   const std::string pathName( pathNamePtr );
1468   free( pathNamePtr );
1469
1470   TextAbstraction::FontClient fontClient = TextAbstraction::FontClient::Get();
1471   fontClient.SetDpi( 93u, 93u );
1472
1473   fontClient.GetFontId( pathName + DEFAULT_FONT_DIR + "/dejavu/DejaVuSerif.ttf", DEFAULT_FONT_SIZE );
1474   fontClient.GetFontId( pathName + DEFAULT_FONT_DIR + "/dejavu/DejaVuSerif-Bold.ttf", DEFAULT_FONT_SIZE );
1475
1476   TextField field = TextField::New();
1477   DALI_TEST_CHECK( field );
1478
1479   field.SetProperty( Actor::Property::SIZE, Vector2( 300.f, 50.f ) );
1480   field.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT );
1481   field.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT );
1482
1483   field.SetProperty( TextField::Property::ENABLE_MARKUP, true );
1484   field.SetProperty( TextField::Property::TEXT, "<font family='DejaVuSerif' size='18'>He<color value='blue'> l</color><color value='green'>lo</color> <font weight='bold'>world</font> demo</font>" );
1485
1486   // connect to the text changed signal.
1487   ConnectionTracker* testTracker = new ConnectionTracker();
1488   field.InputStyleChangedSignal().Connect( &TestInputStyleChangedCallback );
1489   bool inputStyleChangedSignal = false;
1490   field.ConnectSignal( testTracker, "inputStyleChanged",   CallbackFunctor(&inputStyleChangedSignal) );
1491
1492   application.GetScene().Add( field );
1493
1494   // Render and notify
1495   application.SendNotification();
1496   application.Render();
1497
1498   // Executes the idle callbacks added by the text control on the change of input style.
1499   application.RunIdles();
1500
1501   gInputStyleChangedCallbackCalled = false;
1502   gInputStyleMask = TextField::InputStyle::NONE;
1503   inputStyleChangedSignal = false;
1504
1505   // Create a tap event to touch the text field.
1506   TestGenerateTap( application, 53.0f, 25.0f, 100 );
1507   TestGenerateTap( application, 53.0f, 25.0f, 200 );
1508
1509   // Render and notify
1510   application.SendNotification();
1511   application.Render();
1512
1513   // Executes the idle callbacks added by the text control on the change of input style.
1514   application.RunIdles();
1515
1516   DALI_TEST_CHECK( gInputStyleChangedCallbackCalled );
1517   if( gInputStyleChangedCallbackCalled )
1518   {
1519     DALI_TEST_EQUALS( static_cast<unsigned int>( gInputStyleMask ),
1520                       static_cast<unsigned int>( TextField::InputStyle::FONT_FAMILY |
1521                                                  TextField::InputStyle::POINT_SIZE  |
1522                                                  TextField::InputStyle::COLOR ),
1523                       TEST_LOCATION );
1524
1525     const Vector4 color = field.GetProperty( TextField::Property::INPUT_COLOR ).Get<Vector4>();
1526     DALI_TEST_EQUALS( color, Color::GREEN, TEST_LOCATION );
1527
1528     const std::string fontFamily = field.GetProperty( TextField::Property::INPUT_FONT_FAMILY ).Get<std::string>();
1529     DALI_TEST_EQUALS( fontFamily, "DejaVuSerif", TEST_LOCATION );
1530
1531     const float pointSize = field.GetProperty( TextField::Property::INPUT_POINT_SIZE ).Get<float>();
1532     DALI_TEST_EQUALS( pointSize, 18.f, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
1533   }
1534   DALI_TEST_CHECK( inputStyleChangedSignal );
1535
1536   gInputStyleChangedCallbackCalled = false;
1537   gInputStyleMask = TextField::InputStyle::NONE;
1538   inputStyleChangedSignal = false;
1539
1540   application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_BACKSPACE, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
1541
1542   // Render and notify
1543   application.SendNotification();
1544   application.Render();
1545
1546   // Executes the idle callbacks added by the text control on the change of input style.
1547   application.RunIdles();
1548
1549   DALI_TEST_CHECK( gInputStyleChangedCallbackCalled );
1550   if( gInputStyleChangedCallbackCalled )
1551   {
1552     DALI_TEST_EQUALS( static_cast<unsigned int>( gInputStyleMask ),
1553                       static_cast<unsigned int>( TextField::InputStyle::COLOR ),
1554                       TEST_LOCATION );
1555
1556     const Vector4 color = field.GetProperty( TextField::Property::INPUT_COLOR ).Get<Vector4>();
1557     DALI_TEST_EQUALS( color, Color::BLUE, TEST_LOCATION );
1558   }
1559   DALI_TEST_CHECK( inputStyleChangedSignal );
1560
1561   gInputStyleChangedCallbackCalled = false;
1562   gInputStyleMask = TextField::InputStyle::NONE;
1563   inputStyleChangedSignal = false;
1564
1565   application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_BACKSPACE, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
1566
1567   // Render and notify
1568   application.SendNotification();
1569   application.Render();
1570
1571   // Executes the idle callbacks added by the text control on the change of input style.
1572   application.RunIdles();
1573
1574   DALI_TEST_CHECK( !gInputStyleChangedCallbackCalled );
1575   DALI_TEST_CHECK( !inputStyleChangedSignal );
1576
1577   gInputStyleChangedCallbackCalled = false;
1578   gInputStyleMask = TextField::InputStyle::NONE;
1579   inputStyleChangedSignal = false;
1580
1581   application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_BACKSPACE, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
1582
1583   // Render and notify
1584   application.SendNotification();
1585   application.Render();
1586
1587   // Executes the idle callbacks added by the text control on the change of input style.
1588   application.RunIdles();
1589
1590   DALI_TEST_CHECK( gInputStyleChangedCallbackCalled );
1591   if( gInputStyleChangedCallbackCalled )
1592   {
1593     DALI_TEST_EQUALS( static_cast<unsigned int>( gInputStyleMask ),
1594                       static_cast<unsigned int>( TextField::InputStyle::COLOR ),
1595                       TEST_LOCATION );
1596
1597     const Vector4 color = field.GetProperty( TextField::Property::INPUT_COLOR ).Get<Vector4>();
1598     DALI_TEST_EQUALS( color, Color::BLACK, TEST_LOCATION );
1599   }
1600   DALI_TEST_CHECK( inputStyleChangedSignal );
1601
1602   gInputStyleChangedCallbackCalled = false;
1603   gInputStyleMask = TextField::InputStyle::NONE;
1604   inputStyleChangedSignal = false;
1605
1606   field.SetProperty( TextField::Property::INPUT_COLOR, Color::YELLOW );
1607
1608   Property::Map fontStyleMapSet;
1609   fontStyleMapSet.Insert( "weight", "thin" );
1610   fontStyleMapSet.Insert( "width", "condensed" );
1611   fontStyleMapSet.Insert( "slant", "italic" );
1612
1613   field.SetProperty( TextField::Property::INPUT_FONT_STYLE, fontStyleMapSet );
1614   field.SetProperty( TextField::Property::INPUT_POINT_SIZE, 20.f );
1615
1616   field.SetProperty( TextField::Property::INPUT_UNDERLINE, "underline" );
1617   field.SetProperty( TextField::Property::INPUT_SHADOW, "shadow" );
1618   field.SetProperty( TextField::Property::INPUT_EMBOSS, "emboss" );
1619   field.SetProperty( TextField::Property::INPUT_OUTLINE, "outline" );
1620
1621   // Render and notify
1622   application.SendNotification();
1623   application.Render();
1624
1625   // Executes the idle callbacks added by the text control on the change of input style.
1626   application.RunIdles();
1627
1628   DALI_TEST_CHECK( !gInputStyleChangedCallbackCalled );
1629   DALI_TEST_CHECK( !inputStyleChangedSignal );
1630
1631   // Create a tap event to touch the text field.
1632   TestGenerateTap( application, 63.0f, 25.0f, 300 );
1633
1634   // Render and notify
1635   application.SendNotification();
1636   application.Render();
1637
1638   // Executes the idle callbacks added by the text control on the change of input style.
1639   application.RunIdles();
1640
1641   DALI_TEST_CHECK( gInputStyleChangedCallbackCalled );
1642   if( gInputStyleChangedCallbackCalled )
1643   {
1644     DALI_TEST_EQUALS( static_cast<unsigned int>( gInputStyleMask ),
1645                       static_cast<unsigned int>( TextField::InputStyle::COLOR |
1646                                                  TextField::InputStyle::POINT_SIZE |
1647                                                  TextField::InputStyle::FONT_STYLE |
1648                                                  TextField::InputStyle::UNDERLINE |
1649                                                  TextField::InputStyle::SHADOW |
1650                                                  TextField::InputStyle::EMBOSS |
1651                                                  TextField::InputStyle::OUTLINE ),
1652                       TEST_LOCATION );
1653
1654     const Vector4 color = field.GetProperty( TextField::Property::INPUT_COLOR ).Get<Vector4>();
1655     DALI_TEST_EQUALS( color, Color::BLACK, TEST_LOCATION );
1656   }
1657   DALI_TEST_CHECK( inputStyleChangedSignal );
1658
1659   END_TEST;
1660 }
1661
1662 int utcDaliTextFieldEvent01(void)
1663 {
1664   ToolkitTestApplication application;
1665   tet_infoline(" utcDaliTextFieldEvent01");
1666
1667   // Creates a tap event. After creating a tap event the text field should
1668   // have the focus and add text with key events should be possible.
1669
1670   TextField field = TextField::New();
1671   DALI_TEST_CHECK( field );
1672
1673   application.GetScene().Add( field );
1674
1675   field.SetProperty( Actor::Property::SIZE, Vector2( 300.f, 50.f ) );
1676   field.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT );
1677   field.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT );
1678
1679   // Render and notify
1680   application.SendNotification();
1681   application.Render();
1682
1683   // Avoid a crash when core load gl resources.
1684   application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
1685
1686   // Render and notify
1687   application.SendNotification();
1688   application.Render();
1689
1690   // Add a key event but as the text field has not the focus it should do nothing.
1691   application.ProcessEvent( GenerateKey( "a", "", "a", KEY_A_CODE, 0, 0, Integration::KeyEvent::DOWN, "a", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
1692
1693   // Render and notify
1694   application.SendNotification();
1695   application.Render();
1696
1697   DALI_TEST_EQUALS( field.GetProperty<std::string>( TextField::Property::TEXT ), std::string(""), TEST_LOCATION );
1698
1699   // Create a tap event to touch the text field.
1700   TestGenerateTap( application, 150.0f, 25.0f );
1701
1702   // Render and notify
1703   application.SendNotification();
1704   application.Render();
1705
1706   // Pressing delete key should be fine even if there is no text in TextField.
1707   application.ProcessEvent( GenerateKey( "Delete", "", "Delete", Dali::DevelKey::DALI_KEY_DELETE, 0, 0, Integration::KeyEvent::DOWN, "Delete", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
1708   // Render and notify
1709   application.SendNotification();
1710   application.Render();
1711
1712   // Now the text field has the focus, so it can handle the key events.
1713   application.ProcessEvent( GenerateKey( "a", "", "a", KEY_A_CODE, 0, 0, Integration::KeyEvent::DOWN, "a", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
1714   application.ProcessEvent( GenerateKey( "a", "", "a", KEY_A_CODE, 0, 0, Integration::KeyEvent::DOWN, "a", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
1715
1716   // Render and notify
1717   application.SendNotification();
1718   application.Render();
1719
1720   DALI_TEST_EQUALS( field.GetProperty<std::string>( TextField::Property::TEXT ), std::string("aa"), TEST_LOCATION );
1721
1722   // Create a second text field and send key events to it.
1723   TextField field2 = TextField::New();
1724
1725   field2.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT );
1726   field2.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT );
1727   field2.SetProperty( Actor::Property::SIZE, Vector2( 100.f, 100.f ) );
1728   field2.SetProperty( Actor::Property::POSITION, Vector2( 100.0f, 100.0f ));
1729
1730   application.GetScene().Add( field2 );
1731
1732   // Render and notify
1733   application.SendNotification();
1734   application.Render();
1735
1736   // Create a tap event on the second text field.
1737   TestGenerateTap( application, 150.0f, 125.0f );
1738
1739   // Render and notify
1740   application.SendNotification();
1741   application.Render();
1742
1743   // The second text field has the focus. It should handle the key events.
1744   application.ProcessEvent( GenerateKey( "a", "", "a", KEY_A_CODE, 0, 0, Integration::KeyEvent::DOWN, "a", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
1745   application.ProcessEvent( GenerateKey( "a", "", "a", KEY_A_CODE, 0, 0, Integration::KeyEvent::DOWN, "a", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
1746
1747   // Render and notify
1748   application.SendNotification();
1749   application.Render();
1750
1751   // Check the text has been added to the second text field.
1752   DALI_TEST_EQUALS( field2.GetProperty<std::string>( TextField::Property::TEXT ), std::string("aa"), TEST_LOCATION );
1753
1754   END_TEST;
1755 }
1756
1757 int utcDaliTextFieldEvent02(void)
1758 {
1759   ToolkitTestApplication application;
1760   tet_infoline(" utcDaliTextFieldEvent02");
1761
1762   // Checks if the right number of actors are created.
1763
1764   TextField field = TextField::New();
1765   field.SetProperty( TextField::Property::POINT_SIZE, 10.f );
1766   DALI_TEST_CHECK( field );
1767   LoadMarkerImages(application, field);
1768
1769   application.GetScene().Add( field );
1770
1771   field.SetProperty( Actor::Property::SIZE, Vector2( 300.f, 50.f ) );
1772   field.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT );
1773   field.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT );
1774
1775   // Avoid a crash when core load gl resources.
1776   application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
1777
1778   // Render and notify
1779   application.SendNotification();
1780   application.Render();
1781
1782   // Check there are the expected number of children ( stencil ).
1783   DALI_TEST_EQUALS( field.GetChildCount(), 1u, TEST_LOCATION );
1784
1785   Actor stencil = field.GetChildAt( 0u );
1786   DALI_TEST_EQUALS( stencil.GetChildCount(), 0u, TEST_LOCATION );
1787
1788   // Create a tap event to touch the text field.
1789   TestGenerateTap( application, 150.0f, 25.0f, 300 );
1790
1791   // Render and notify
1792   application.SendNotification();
1793   application.Render();
1794
1795   Actor layer = field.GetChildAt( 1u );
1796   DALI_TEST_EQUALS( layer.GetChildCount(), 1u, TEST_LOCATION ); // The cursor.
1797   DALI_TEST_EQUALS( stencil.GetChildCount(), 0u, TEST_LOCATION );
1798
1799   // Now the text field has the focus, so it can handle the key events.
1800   application.ProcessEvent( GenerateKey( "a", "", "a", KEY_A_CODE, 0, 0, Integration::KeyEvent::DOWN, "a", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
1801   application.ProcessEvent( GenerateKey( "a", "", "a", KEY_A_CODE, 0, 0, Integration::KeyEvent::DOWN, "a", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
1802
1803   // Render and notify
1804   application.SendNotification();
1805   application.Render();
1806
1807   // Checks the cursor and the renderer have been created.
1808   DALI_TEST_EQUALS( layer.GetChildCount(), 1u, TEST_LOCATION ); // The cursor.
1809   DALI_TEST_EQUALS( stencil.GetChildCount(), 1u, TEST_LOCATION ); // The renderer
1810
1811   Control cursor = Control::DownCast( layer.GetChildAt( 0u ) );
1812   DALI_TEST_CHECK( cursor );
1813
1814   // The offscreen root actor has a container with all the actors which contain the text renderers.
1815   Actor container = stencil.GetChildAt( 0u );
1816   for( unsigned int index = 0; index < container.GetChildCount(); ++index )
1817   {
1818     Renderer renderer = container.GetChildAt( index ).GetRendererAt( 0u );
1819     DALI_TEST_CHECK( renderer );
1820   }
1821
1822   // Move the cursor and check the position changes.
1823   Vector3 position1 = cursor.GetCurrentProperty< Vector3 >( Actor::Property::POSITION );
1824   application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_LEFT, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
1825
1826   // Render and notify
1827   application.SendNotification();
1828   application.Render();
1829
1830   Vector3 position2 = cursor.GetCurrentProperty< Vector3 >( Actor::Property::POSITION );
1831   DALI_TEST_CHECK( position2.x < position1.x );
1832
1833   application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_RIGHT, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
1834
1835   // Render and notify
1836   application.SendNotification();
1837   application.Render();
1838
1839   Vector3 position3 = cursor.GetCurrentProperty< Vector3 >( Actor::Property::POSITION );
1840   DALI_TEST_EQUALS( position1, position3, TEST_LOCATION ); // Should be in the same position1.
1841
1842
1843   // Move the cursor to the first position.
1844   application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_LEFT, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
1845   application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_LEFT, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
1846
1847   // Render and notify
1848   application.SendNotification();
1849   application.Render();
1850
1851   Vector3 position4 = cursor.GetCurrentProperty< Vector3 >( Actor::Property::POSITION );
1852
1853   // Send some taps and check the cursor positions.
1854
1855   // Try to tap at the beginning.
1856   TestGenerateTap( application, 1.0f, 25.0f, 900 );
1857
1858   // Render and notify
1859   application.SendNotification();
1860   application.Render();
1861
1862   // Cursor position should be the same than position1.
1863   Vector3 position5 = cursor.GetCurrentProperty< Vector3 >( Actor::Property::POSITION );
1864
1865   DALI_TEST_EQUALS( position4, position5, TEST_LOCATION ); // Should be in the same position2.
1866
1867   // Tap away from the start position.
1868   TestGenerateTap( application, 16.0f, 25.0f, 1500 );
1869
1870   // Render and notify
1871   application.SendNotification();
1872   application.Render();
1873
1874   Vector3 position6 = cursor.GetCurrentProperty< Vector3 >( Actor::Property::POSITION );
1875
1876   DALI_TEST_CHECK( position6.x > position5.x );
1877
1878   // Remove all the text.
1879   application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_BACKSPACE, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
1880   application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_BACKSPACE, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
1881   field.SetProperty( TextField::Property::TEXT, "" );
1882
1883   // Render and notify
1884   application.SendNotification();
1885   application.Render();
1886
1887   // Cursor position should be the same than position2.
1888   Vector3 position7 = cursor.GetCurrentProperty< Vector3 >( Actor::Property::POSITION );
1889
1890   DALI_TEST_EQUALS( position4, position7, TEST_LOCATION );// Should be in the same position2.
1891
1892   // Should not be a renderer.
1893   DALI_TEST_EQUALS( stencil.GetChildCount(), 0u, TEST_LOCATION );
1894
1895   // Chanege exceed policy (EXCEED_POLICY_ORIGINAL doesn't use stencil )
1896   field.SetProperty( TextField::Property::TEXT, "This is a long text for the size of the text-field." );
1897   field.SetProperty( TextField::Property::EXCEED_POLICY, Dali::Toolkit::TextField::EXCEED_POLICY_ORIGINAL );
1898
1899   application.SendNotification();
1900   application.Render();
1901
1902   // There are renderer and decorator layer
1903   DALI_TEST_EQUALS( field.GetChildCount(), 2u, TEST_LOCATION );
1904
1905   END_TEST;
1906 }
1907
1908 int utcDaliTextFieldEvent03(void)
1909 {
1910   ToolkitTestApplication application;
1911   tet_infoline(" utcDaliTextFieldEvent03");
1912
1913   // Checks if the highlight actor is created.
1914
1915   TextField field = TextField::New();
1916   DALI_TEST_CHECK( field );
1917
1918   application.GetScene().Add( field );
1919
1920   field.SetProperty( TextField::Property::TEXT, "This is a long text for the size of the text-field." );
1921   field.SetProperty( TextField::Property::POINT_SIZE, 10.f );
1922   field.SetProperty( Actor::Property::SIZE, Vector2( 30.f, 50.f ) );
1923   field.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT );
1924   field.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT );
1925
1926   // Avoid a crash when core load gl resources.
1927   application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
1928   LoadMarkerImages(application, field);
1929
1930   // Render and notify
1931   application.SendNotification();
1932   application.Render();
1933
1934   // Tap first to get the focus.
1935   TestGenerateTap( application, 3.0f, 25.0f );
1936
1937   // Render and notify
1938   application.SendNotification();
1939   application.Render();
1940
1941   // Double tap to select a word.
1942   TestGenerateTap( application, 3.0f, 25.0f );
1943
1944   // Render and notify
1945   application.SendNotification();
1946   application.Render();
1947
1948   // The offscreen root actor should have two actors: the renderer and the highlight actor.
1949   Actor stencil = field.GetChildAt( 0u );
1950
1951   // The highlight actor is drawn first, so is the first actor in the list
1952   Renderer highlight = stencil.GetChildAt( 0u ).GetRendererAt( 0u );
1953   DALI_TEST_CHECK( highlight );
1954
1955   // The offscreen root actor has a container with all the actors which contain the text renderers.
1956   Actor container = stencil.GetChildAt( 1u );
1957   for( unsigned int index = 0; index < container.GetChildCount(); ++index )
1958   {
1959     Renderer renderer = container.GetChildAt( index ).GetRendererAt( 0u );
1960     DALI_TEST_CHECK( renderer );
1961   }
1962
1963   END_TEST;
1964 }
1965
1966 int utcDaliTextFieldEvent04(void)
1967 {
1968   ToolkitTestApplication application;
1969   tet_infoline(" utcDaliTextFieldEvent04");
1970
1971   // Checks if the highlight actor is created.
1972
1973   TextField field = TextField::New();
1974   DALI_TEST_CHECK( field );
1975   application.GetScene().Add( field );
1976   LoadMarkerImages(application, field);
1977   // Render and notify
1978   application.SendNotification();
1979   application.Render();
1980
1981   field.SetProperty( TextField::Property::TEXT, "This is a long text for the size of the text-field." );
1982   field.SetProperty( TextField::Property::POINT_SIZE, 10.f );
1983   field.SetProperty( Actor::Property::SIZE, Vector2( 300.f, 50.f ) );
1984   field.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT );
1985   field.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT );
1986
1987   // Avoid a crash when core load gl resources.
1988   application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
1989   // Render and notify
1990   application.SendNotification();
1991   application.Render();
1992
1993   // Create a tap event to touch the text field.
1994   TestGenerateTap( application, 150.0f, 25.0f );
1995   // Render and notify
1996   application.SendNotification();
1997   application.Render();
1998
1999
2000   // Tap first to get the focus.
2001   TestGenerateTap( application, 1.0f, 25.0f );
2002
2003   // Render and notify
2004   application.SendNotification();
2005   application.Render();
2006
2007   // Double tap to select a word.
2008   TestGenerateTap( application, 1.0f, 25.0f );
2009
2010   // Render and notify
2011   application.SendNotification();
2012   application.Render();
2013
2014   // Tap grab handle
2015   TestGenerateTap( application, 0.0f, 40.0f );
2016   END_TEST;
2017 }
2018
2019 int utcDaliTextFieldEvent05(void)
2020 {
2021   ToolkitTestApplication application;
2022   tet_infoline(" utcDaliTextFieldEvent05");
2023
2024   // Checks dragging of cursor/grab handle
2025
2026   TextField field = TextField::New();
2027   DALI_TEST_CHECK( field );
2028   application.GetScene().Add( field );
2029   LoadMarkerImages(application, field);
2030   // Render and notify
2031   application.SendNotification();
2032   application.Render();
2033
2034   field.SetProperty( TextField::Property::TEXT, "This is a long text for the size of the text-field." );
2035   field.SetProperty( TextField::Property::POINT_SIZE, 10.f );
2036   field.SetProperty( Actor::Property::SIZE, Vector2( 300.f, 50.f ) );
2037   field.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT );
2038   field.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT );
2039
2040   // Avoid a crash when core load gl resources.
2041   application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
2042   // Render and notify
2043   application.SendNotification();
2044   application.Render();
2045
2046   // Create a tap event to touch the text field.
2047   TestGenerateTap( application, 150.0f, 25.0f );
2048   // Render and notify
2049   application.SendNotification();
2050   application.Render();
2051
2052   // Tap first to get the focus.
2053   TestGenerateTap( application, 1.0f, 25.0f );
2054
2055   // Render and notify
2056   application.SendNotification();
2057   application.Render();
2058
2059   // Double tap to select a word.
2060   TestGenerateTap( application, 1.0f, 25.0f );
2061
2062   // Render and notify
2063   application.SendNotification();
2064   application.Render();
2065
2066   Actor stencil = field.GetChildAt( 1u );
2067   END_TEST;
2068 }
2069
2070 int utcDaliTextFieldEvent06(void)
2071 {
2072   ToolkitTestApplication application;
2073   tet_infoline(" utcDaliTextFieldEvent06");
2074
2075   // Checks Longpress when in edit mode
2076
2077   TextField field = TextField::New();
2078   DALI_TEST_CHECK( field );
2079   application.GetScene().Add( field );
2080   LoadMarkerImages(application, field);
2081   // Render and notify
2082   application.SendNotification();
2083   application.Render();
2084
2085   field.SetProperty( TextField::Property::TEXT, "Thisisalongtextforthesizeofthetextfield." );
2086   field.SetProperty( TextField::Property::POINT_SIZE, 10.f );
2087   field.SetProperty( Actor::Property::SIZE, Vector2( 300.f, 50.f ) );
2088   field.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT );
2089   field.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT );
2090
2091   // Avoid a crash when core load gl resources.
2092   application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
2093   // Render and notify
2094   application.SendNotification();
2095   application.Render();
2096
2097   // Create a tap event to touch the text field.
2098   TestGenerateTap( application, 150.0f, 25.0f );
2099   // Render and notify
2100   application.SendNotification();
2101   application.Render();
2102
2103
2104   // Tap first to get the focus.
2105   TestGenerateTap( application, 1.0f, 25.0f );
2106
2107   // Render and notify
2108   application.SendNotification();
2109   application.Render();
2110
2111   // Long Press
2112   TestGenerateLongPress(application, 1.0f, 25.0f);
2113
2114   // Render and notify
2115   application.SendNotification();
2116   application.Render();
2117
2118   END_TEST;
2119 }
2120
2121 int utcDaliTextFieldEvent07(void)
2122 {
2123   ToolkitTestApplication application;
2124   tet_infoline(" utcDaliTextFieldEvent07");
2125
2126   // Checks Longpress to start edit mode
2127
2128   TextField field = TextField::New();
2129   DALI_TEST_CHECK( field );
2130   application.GetScene().Add( field );
2131   LoadMarkerImages(application, field);
2132   // Render and notify
2133   application.SendNotification();
2134   application.Render();
2135
2136   field.SetProperty( TextField::Property::TEXT, "Thisisalongtextforthesizeofthetextfield." );
2137   field.SetProperty( TextField::Property::POINT_SIZE, 10.f );
2138   field.SetProperty( Actor::Property::SIZE, Vector2( 300.f, 50.f ) );
2139   field.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT );
2140   field.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT );
2141   Property::Map propertyMap;
2142   propertyMap["PANEL_LAYOUT"] = InputMethod::PanelLayout::PASSWORD;
2143   field.SetProperty( TextField::Property::INPUT_METHOD_SETTINGS, propertyMap );
2144
2145   // Avoid a crash when core load gl resources.
2146   application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
2147   // Render and notify
2148   application.SendNotification();
2149   application.Render();
2150
2151   // Long Press
2152   TestGenerateLongPress(application, 1.0f, 25.0f);
2153
2154   // Render and notify
2155   application.SendNotification();
2156   application.Render();
2157
2158   END_TEST;
2159 }
2160
2161 int utcDaliTextFieldEvent08(void)
2162 {
2163   ToolkitTestApplication application;
2164   tet_infoline(" utcDaliTextFieldEvent08");
2165
2166   Dali::Clipboard clipboard = Clipboard::Get();
2167   clipboard.SetItem("testTextFieldEvent");
2168
2169   // Checks Longpress when only place holder text
2170
2171   TextField field = TextField::New();
2172   DALI_TEST_CHECK( field );
2173   application.GetScene().Add( field );
2174   LoadMarkerImages(application, field);
2175   // Render and notify
2176   application.SendNotification();
2177   application.Render();
2178
2179   field.SetProperty( TextField::Property::PLACEHOLDER_TEXT, "Setting Placeholder Text" );
2180   field.SetProperty( TextField::Property::POINT_SIZE, 10.f );
2181   field.SetProperty( Actor::Property::SIZE, Vector2( 300.f, 50.f ) );
2182   field.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT );
2183   field.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT );
2184
2185   // Avoid a crash when core load gl resources.
2186   application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
2187   // Render and notify
2188   application.SendNotification();
2189   application.Render();
2190
2191   // Long Press
2192   TestGenerateLongPress( application, 1.0f, 25.0f, 20 );
2193
2194   // Render and notify
2195   application.SendNotification();
2196   application.Render();
2197
2198   Wait(application, 500);
2199
2200   TestEndLongPress( application, 1.0f, 25.0f, 520 );
2201
2202   // Long Press
2203   TestGenerateLongPress( application, 1.0f, 25.0f, 600 );
2204
2205   // Render and notify
2206   application.Render();
2207
2208   Wait(application, 500);
2209
2210   Integration::Scene stage = application.GetScene();
2211   Layer layer = stage.GetRootLayer();
2212   Actor actor = layer.FindChildByName("optionPaste");
2213
2214   if (actor)
2215   {
2216     Vector3 worldPosition = actor.GetCurrentProperty< Vector3 >( Actor::Property::WORLD_POSITION );
2217     Vector2 halfStageSize = stage.GetSize() / 2.0f;
2218     Vector2 position(worldPosition.x + halfStageSize.width, worldPosition.y + halfStageSize.height);
2219
2220     Dali::Integration::TouchEvent event;
2221     event = Dali::Integration::TouchEvent();
2222     event.AddPoint( GetPointDownInside( position ) );
2223     application.ProcessEvent( event );
2224
2225     event = Dali::Integration::TouchEvent();
2226     event.AddPoint( GetPointUpInside( position ) );
2227     application.ProcessEvent( event );
2228   }
2229   DALI_TEST_EQUALS( field.GetProperty<std::string>( TextEditor::Property::TEXT ), std::string("testTextFieldEvent"), TEST_LOCATION );
2230
2231   END_TEST;
2232 }
2233
2234 int utcDaliTextFieldEvent09(void)
2235 {
2236   ToolkitTestApplication application;
2237   tet_infoline(" utcDaliTextFieldEvent09");
2238
2239   TextField field = TextField::New();
2240   DALI_TEST_CHECK( field );
2241   application.GetScene().Add( field );
2242   LoadMarkerImages(application, field);
2243   // Render and notify
2244   application.SendNotification();
2245   application.Render();
2246
2247   field.SetProperty( TextField::Property::TEXT, "Hello" );
2248   field.SetProperty( TextField::Property::POINT_SIZE, 10.f );
2249   field.SetProperty( Actor::Property::SIZE, Vector2( 300.f, 50.f ) );
2250   field.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT );
2251   field.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT );
2252
2253   // Avoid a crash when core load gl resources.
2254   application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
2255
2256   // Create a tap event to touch the text field.
2257   TestGenerateTap( application, 150.0f, 25.0f );
2258   application.SendNotification();
2259   application.Render();
2260
2261   Property::Map map;
2262   map[ HiddenInput::Property::MODE ] = HiddenInput::Mode::HIDE_NONE;
2263   field.SetProperty( TextField::Property::HIDDEN_INPUT_SETTINGS, map );
2264   application.ProcessEvent( GenerateKey( "d", "", "d", 0, 0, 0, Integration::KeyEvent::DOWN, "d", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2265   application.SendNotification();
2266   application.Render();
2267
2268   map[ HiddenInput::Property::MODE ] = HiddenInput::Mode::HIDE_ALL;
2269   map[ HiddenInput::Property::SUBSTITUTE_CHARACTER ] = 0x23;
2270   field.SetProperty( TextField::Property::HIDDEN_INPUT_SETTINGS, map );
2271   application.ProcessEvent( GenerateKey( "d", "", "d", 0, 0, 0, Integration::KeyEvent::DOWN, "d", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2272   application.SendNotification();
2273   application.Render();
2274
2275   map[ HiddenInput::Property::MODE ] = HiddenInput::Mode::HIDE_COUNT;
2276   map[ HiddenInput::Property::SUBSTITUTE_COUNT ] = 2;
2277   field.SetProperty( TextField::Property::HIDDEN_INPUT_SETTINGS, map );
2278   for( unsigned int index = 0u; index < 5u; ++index )
2279   {
2280     application.ProcessEvent( GenerateKey( "d", "", "d", 0, 0, 0, Integration::KeyEvent::DOWN, "d", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2281     application.SendNotification();
2282     application.Render();
2283   }
2284
2285   map[ HiddenInput::Property::MODE ] = HiddenInput::Mode::SHOW_COUNT;
2286   map[ HiddenInput::Property::SUBSTITUTE_COUNT ] = 2;
2287   field.SetProperty( TextField::Property::HIDDEN_INPUT_SETTINGS, map );
2288   for( unsigned int index = 0u; index < 5u; ++index )
2289   {
2290     application.ProcessEvent( GenerateKey( "d", "", "d", 0, 0, 0, Integration::KeyEvent::DOWN, "d", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2291     application.SendNotification();
2292     application.Render();
2293   }
2294
2295   map[ HiddenInput::Property::MODE ] = HiddenInput::Mode::SHOW_LAST_CHARACTER;
2296   map[ HiddenInput::Property::SHOW_LAST_CHARACTER_DURATION ] = 0;
2297   field.SetProperty( TextField::Property::HIDDEN_INPUT_SETTINGS, map );
2298   application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_BACKSPACE, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2299   application.SendNotification();
2300   application.Render();
2301   application.ProcessEvent( GenerateKey( "d", "", "d", 0, 0, 0, Integration::KeyEvent::DOWN, "d", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2302   application.SendNotification();
2303   application.Render();
2304
2305   map[ HiddenInput::Property::SHOW_LAST_CHARACTER_DURATION ] = 100;
2306   field.SetProperty( TextField::Property::HIDDEN_INPUT_SETTINGS, map );
2307   application.ProcessEvent( GenerateKey( "d", "", "d", 0, 0, 0, Integration::KeyEvent::DOWN, "d", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2308   application.SendNotification();
2309   application.Render();
2310
2311   Property::Map mapGet;
2312   mapGet = field.GetProperty<Property::Map>( TextField::Property::HIDDEN_INPUT_SETTINGS );
2313   DALI_TEST_EQUALS( map.Count(), mapGet.Count(), TEST_LOCATION );
2314   DALI_TEST_EQUALS( DaliTestCheckMaps( map, mapGet ), true, TEST_LOCATION );
2315   END_TEST;
2316 }
2317
2318
2319 int utcDaliTextFieldStyleWhilstSelected(void)
2320 {
2321   ToolkitTestApplication application;
2322   tet_infoline(" utcDaliTextFieldStyleWhilstSelected");
2323
2324   // Change font and styles whilst text is selected whilst word selected
2325
2326   TextField field = TextField::New();
2327   DALI_TEST_CHECK( field );
2328   application.GetScene().Add( field );
2329   LoadMarkerImages(application, field);
2330   // Render and notify
2331   application.SendNotification();
2332   application.Render();
2333
2334   field.SetProperty( TextField::Property::TEXT, "This is a long text for the size of the text-field." );
2335   field.SetProperty( TextField::Property::POINT_SIZE, 10.f );
2336   field.SetProperty( Actor::Property::SIZE, Vector2( 300.f, 50.f ) );
2337   field.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT );
2338   field.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT );
2339
2340   // Avoid a crash when core load gl resources.
2341   application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
2342   // Render and notify
2343   application.SendNotification();
2344   application.Render();
2345
2346   // Create a tap event to touch the text field.
2347   TestGenerateTap( application, 150.0f, 25.0f );
2348   // Render and notify
2349   application.SendNotification();
2350   application.Render();
2351
2352
2353   // Tap first to get the focus.
2354   TestGenerateTap( application, 1.0f, 25.0f );
2355
2356   // Render and notify
2357   application.SendNotification();
2358   application.Render();
2359
2360   // Double tap to select a word.
2361   TestGenerateTap( application, 1.0f, 25.0f );
2362
2363   // Render and notify
2364   application.SendNotification();
2365   application.Render();
2366
2367   field.SetProperty( TextField::Property::INPUT_FONT_FAMILY, "Setting input font family" );
2368   DALI_TEST_EQUALS( field.GetProperty<std::string>( TextField::Property::INPUT_FONT_FAMILY ), "Setting input font family", TEST_LOCATION );
2369
2370   Property::Map fontStyleMapSet;
2371   Property::Map fontStyleMapGet;
2372
2373   fontStyleMapSet.Insert( "weight", "bold" );
2374   fontStyleMapSet.Insert( "slant", "italic" );
2375   field.SetProperty( TextField::Property::INPUT_FONT_STYLE, fontStyleMapSet );
2376
2377   fontStyleMapGet = field.GetProperty<Property::Map>( TextField::Property::INPUT_FONT_STYLE );
2378   DALI_TEST_EQUALS( fontStyleMapGet.Count(), fontStyleMapSet.Count(), TEST_LOCATION );
2379   DALI_TEST_EQUALS( DaliTestCheckMaps( fontStyleMapGet, fontStyleMapSet ), true, TEST_LOCATION );
2380
2381   fontStyleMapSet.Clear();
2382   fontStyleMapSet.Insert( "width", "expanded" );
2383   fontStyleMapSet.Insert( "slant", "italic" );
2384   field.SetProperty( TextField::Property::INPUT_FONT_STYLE, fontStyleMapSet );
2385
2386   fontStyleMapGet = field.GetProperty<Property::Map>( TextField::Property::INPUT_FONT_STYLE );
2387   DALI_TEST_EQUALS( fontStyleMapGet.Count(), fontStyleMapSet.Count(), TEST_LOCATION );
2388   DALI_TEST_EQUALS( DaliTestCheckMaps( fontStyleMapGet, fontStyleMapSet ), true, TEST_LOCATION );
2389
2390   field.SetProperty( TextField::Property::INPUT_POINT_SIZE, 12.f );
2391   DALI_TEST_EQUALS( field.GetProperty<float>( TextField::Property::INPUT_POINT_SIZE ), 12.f, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
2392
2393   field.SetProperty( TextField::Property::TEXT_COLOR, Color::RED );
2394   DALI_TEST_EQUALS( field.GetProperty<Vector4>( TextField::Property::TEXT_COLOR ), Color::RED, TEST_LOCATION );
2395
2396   fontStyleMapSet.Clear();
2397   fontStyleMapSet.Insert( "weight", "bold" );
2398   fontStyleMapSet.Insert( "slant", "italic" );
2399
2400   field.SetProperty( TextField::Property::FONT_STYLE, fontStyleMapSet );
2401
2402   fontStyleMapGet = field.GetProperty<Property::Map>( TextField::Property::FONT_STYLE );
2403   DALI_TEST_EQUALS( fontStyleMapGet.Count(), fontStyleMapSet.Count(), TEST_LOCATION );
2404   DALI_TEST_EQUALS( DaliTestCheckMaps( fontStyleMapGet, fontStyleMapSet ), true, TEST_LOCATION );
2405
2406   fontStyleMapSet.Clear();
2407   fontStyleMapSet.Insert( "width", "expanded" );
2408
2409   field.SetProperty( TextField::Property::FONT_STYLE, fontStyleMapSet );
2410
2411   fontStyleMapGet = field.GetProperty<Property::Map>( TextField::Property::FONT_STYLE );
2412   DALI_TEST_EQUALS( fontStyleMapGet.Count(), fontStyleMapSet.Count(), TEST_LOCATION );
2413   DALI_TEST_EQUALS( DaliTestCheckMaps( fontStyleMapGet, fontStyleMapSet ), true, TEST_LOCATION );
2414
2415   // Press Escape to increase coverage
2416   application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_ESCAPE, 0, 0, Integration::KeyEvent::UP, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2417   application.SendNotification();
2418   application.Render();
2419
2420   DALI_TEST_CHECK( !field.HasKeyInputFocus() );
2421
2422   END_TEST;
2423 }
2424
2425 int utcDaliTextFieldEscKeyLoseFocus(void)
2426 {
2427   ToolkitTestApplication application;
2428   tet_infoline(" utcDaliTextFieldEscKeyLoseFocus");
2429
2430   // Creates a tap event. After creating a tap event the text field should
2431   // have the focus and add text with key events should be possible.
2432
2433   TextField field = TextField::New();
2434   DALI_TEST_CHECK( field );
2435
2436   application.GetScene().Add( field );
2437
2438   field.SetProperty( Actor::Property::SIZE, Vector2( 300.f, 50.f ) );
2439   field.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT );
2440   field.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT );
2441
2442   // Avoid a crash when core load gl resources.
2443   application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
2444
2445   // Render and notify
2446   application.SendNotification();
2447   application.Render();
2448
2449   // Add a key event but as the text field has not the focus it should do nothing.
2450   application.ProcessEvent( GenerateKey( "a", "", "a", KEY_A_CODE, 0, 0, Integration::KeyEvent::DOWN, "a", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2451   application.ProcessEvent( GenerateKey( "a", "", "a", KEY_A_CODE, 0, 0, Integration::KeyEvent::UP, "a", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2452
2453   // Render and notify
2454   application.SendNotification();
2455   application.Render();
2456
2457   DALI_TEST_EQUALS( field.GetProperty<std::string>( TextField::Property::TEXT ), std::string(""), TEST_LOCATION );
2458
2459   // Create a tap event to touch the text field.
2460   TestGenerateTap( application, 150.0f, 25.0f );
2461
2462   // Render and notify
2463   application.SendNotification();
2464   application.Render();
2465
2466   // Now the text field has the focus, so it can handle the key events.
2467   application.ProcessEvent( GenerateKey( "a", "", "a", KEY_A_CODE, 0, 0, Integration::KeyEvent::DOWN, "a", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2468   application.ProcessEvent( GenerateKey( "a", "", "a", KEY_A_CODE, 0, 0, Integration::KeyEvent::UP, "a", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2469   application.ProcessEvent( GenerateKey( "d", "", "d", KEY_D_CODE, 0, 0, Integration::KeyEvent::DOWN, "d", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2470   application.ProcessEvent( GenerateKey( "d", "", "d", KEY_D_CODE, 0, 0, Integration::KeyEvent::UP, "d", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2471
2472   // Render and notify
2473   application.SendNotification();
2474   application.Render();
2475
2476   DALI_TEST_EQUALS( field.GetProperty<std::string>( TextField::Property::TEXT ), std::string("ad"), TEST_LOCATION );
2477
2478   // Generate a Esc key event. The text field should lose the focus.
2479   application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_ESCAPE, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2480   application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_ESCAPE, 0, 0, Integration::KeyEvent::UP, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2481
2482   // Render and notify
2483   application.SendNotification();
2484   application.Render();
2485
2486   DALI_TEST_EQUALS( false, field.HasKeyInputFocus(), TEST_LOCATION );
2487
2488   // No more text should be introduced
2489   application.ProcessEvent( GenerateKey( "a", "", "a", KEY_A_CODE, 0, 0, Integration::KeyEvent::DOWN, "a", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2490   application.ProcessEvent( GenerateKey( "a", "", "a", KEY_A_CODE, 0, 0, Integration::KeyEvent::UP, "a", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2491
2492   // Render and notify
2493   application.SendNotification();
2494   application.Render();
2495
2496   DALI_TEST_EQUALS( field.GetProperty<std::string>( TextField::Property::TEXT ), std::string("ad"), TEST_LOCATION );
2497
2498   END_TEST;
2499 }
2500
2501 int utcDaliTextFieldSomeSpecialKeys(void)
2502 {
2503   ToolkitTestApplication application;
2504   tet_infoline(" utcDaliTextFieldSomeSpecialKeys");
2505
2506   // Checks some special keys when the text is selected.
2507
2508   TextField field = TextField::New();
2509   DALI_TEST_CHECK( field );
2510   application.GetScene().Add( field );
2511   LoadMarkerImages(application, field);
2512   // Render and notify
2513   application.SendNotification();
2514   application.Render();
2515
2516   const std::string longText( "This is a long text for the size of the text-field." );
2517
2518   field.SetProperty( TextField::Property::TEXT, longText );
2519   field.SetProperty( TextField::Property::POINT_SIZE, 10.f );
2520   field.SetProperty( Actor::Property::SIZE, Vector2( 300.f, 50.f ) );
2521   field.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT );
2522   field.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT );
2523
2524   // Avoid a crash when core load gl resources.
2525   application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
2526   // Render and notify
2527   application.SendNotification();
2528   application.Render();
2529
2530   // Create a tap event to touch the text field.
2531   TestGenerateTap( application, 150.0f, 25.0f );
2532
2533   // Render and notify
2534   application.SendNotification();
2535   application.Render();
2536
2537   // Tap first to get the focus.
2538   TestGenerateTap( application, 1.0f, 25.0f );
2539
2540   // Render and notify
2541   application.SendNotification();
2542   application.Render();
2543
2544   // Double tap to select a word.
2545   TestGenerateTap( application, 1.0f, 25.0f );
2546
2547   // Render and notify
2548   application.SendNotification();
2549   application.Render();
2550
2551   // Generate a Esc key event. The text field should lose the focus.
2552   application.ProcessEvent( GenerateKey( "XF86PowerOff", "", "XF86PowerOff", DALI_KEY_POWER, 0, 0, Integration::KeyEvent::DOWN, "XF86PowerOff", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2553   application.ProcessEvent( GenerateKey( "XF86PowerOff", "", "XF86PowerOff", DALI_KEY_POWER, 0, 0, Integration::KeyEvent::UP, "XF86PowerOff", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2554
2555   // Render and notify
2556   application.SendNotification();
2557   application.Render();
2558
2559   // Generate a Esc key event. The text field should lose the focus.
2560   application.ProcessEvent( GenerateKey( "XF86Menu", "", "XF86Menu", DALI_KEY_MENU, 0, 0, Integration::KeyEvent::DOWN, "XF86Menu", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2561   application.ProcessEvent( GenerateKey( "XF86Menu", "", "XF86Menu", DALI_KEY_MENU, 0, 0, Integration::KeyEvent::UP, "XF86Menu", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2562
2563   // Render and notify
2564   application.SendNotification();
2565   application.Render();
2566
2567   // Generate a Esc key event. The text field should lose the focus.
2568   application.ProcessEvent( GenerateKey( "XF86Home", "", "XF86Home", DALI_KEY_HOME, 0, 0, Integration::KeyEvent::DOWN, "XF86Home", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2569   application.ProcessEvent( GenerateKey( "XF86Home", "", "XF86Home", DALI_KEY_HOME, 0, 0, Integration::KeyEvent::UP, "XF86Home", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2570
2571   // Render and notify
2572   application.SendNotification();
2573   application.Render();
2574
2575   // The text shouldn't be deleted.
2576   DALI_TEST_EQUALS( field.GetProperty<std::string>( TextField::Property::TEXT ), longText, TEST_LOCATION );
2577
2578   END_TEST;
2579 }
2580
2581 int utcDaliTextFieldSizeUpdate(void)
2582 {
2583   ToolkitTestApplication application;
2584   tet_infoline("utcDaliTextFieldSizeUpdate");
2585
2586   // Checks some special keys when the text is selected.
2587   TextField field = TextField::New();
2588   DALI_TEST_CHECK( field );
2589   application.GetScene().Add( field );
2590
2591   float previousHeight = 0.0f;
2592   float currentHeight = 0.0f;
2593   const float fieldWidth = 1920.0f;
2594
2595
2596   // "ㅁ" is bigger then "ኢ"
2597   field.SetProperty( Actor::Property::SIZE, Vector2( fieldWidth ,10.0f ) );
2598   field.SetResizePolicy( ResizePolicy::FIXED , Dimension::WIDTH );
2599   field.SetResizePolicy( ResizePolicy::DIMENSION_DEPENDENCY , Dimension::HEIGHT );
2600
2601   field.SetProperty( TextField::Property::TEXT, "ኢ");
2602   field.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT );
2603   field.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT );
2604
2605   field.SetProperty( Actor::Property::KEYBOARD_FOCUSABLE,true);
2606   KeyboardFocusManager::Get().SetCurrentFocusActor( field );
2607
2608   application.SendNotification();
2609   application.Render();
2610
2611   previousHeight = field.GetHeightForWidth( fieldWidth );
2612   DALI_TEST_EQUALS( previousHeight, field.GetProperty<float>( Actor::Property::SIZE_HEIGHT ) , TEST_LOCATION );
2613
2614   // Add  another script characters ( glyph height is defferent )
2615   application.ProcessEvent( GenerateKey( "ㅁ", "", "ㅁ", KEY_A_CODE, 0, 0, Integration::KeyEvent::DOWN, "ㅁ", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2616   application.ProcessEvent( GenerateKey( "ㅁ", "", "ㅁ", KEY_A_CODE, 0, 0, Integration::KeyEvent::UP, "ㅁ", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2617
2618   application.SendNotification();
2619   application.Render();
2620
2621   currentHeight = field.GetHeightForWidth( fieldWidth );
2622   DALI_TEST_EQUALS( currentHeight, field.GetProperty<float>( Actor::Property::SIZE_HEIGHT ), TEST_LOCATION );
2623   DALI_TEST_EQUALS( (previousHeight < currentHeight), true , TEST_LOCATION );
2624
2625   END_TEST;
2626 }
2627
2628 int utcDaliTextFieldExtremlyLargePointSize(void)
2629 {
2630   ToolkitTestApplication application;
2631   tet_infoline(" utcDaliTextFieldExtremlyLargePointSize");
2632
2633   TextField field = TextField::New();
2634
2635   field.SetProperty( TextField::Property::TEXT, "Text" );
2636   field.SetProperty( Actor::Property::SIZE, Vector2( 300.f, 50.f ) );
2637   field.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT );
2638   field.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT );
2639   application.GetScene().Add( field );
2640
2641   try
2642   {
2643     field.SetProperty( TextField::Property::POINT_SIZE, 160.0f );
2644     application.SendNotification();
2645     DALI_TEST_CHECK( field );
2646   }
2647   catch (...)
2648   {
2649     tet_result(TET_FAIL);
2650   }
2651   END_TEST;
2652 }
2653
2654 int UtcDaliTextFieldDefaultFontStylePropertyCoverage(void)
2655 {
2656   ToolkitTestApplication application;
2657   tet_infoline("UtcDaliTextFieldFontStylePorpertyCoverage");
2658   TextField field = TextField::New();
2659   DALI_TEST_CHECK( field );
2660   application.GetScene().Add( field );
2661
2662   Property::Map fontStyleMapGet;
2663
2664   fontStyleMapGet = field.GetProperty<Property::Map>( TextField::Property::FONT_STYLE );
2665
2666   Property::Value* weightValue = NULL;
2667   Property::Value* widthValue = NULL;
2668   Property::Value* slantValue = NULL;
2669   weightValue = fontStyleMapGet.Find( "weight" );
2670   widthValue = fontStyleMapGet.Find( "width" );
2671   slantValue = fontStyleMapGet.Find( "slant" );
2672   DALI_TEST_CHECK( !weightValue );
2673   DALI_TEST_CHECK( !widthValue );
2674   DALI_TEST_CHECK( !slantValue );
2675
2676   END_TEST;
2677 }
2678
2679 int UtcDaliTextFieldSettingPlaceholder(void)
2680 {
2681   ToolkitTestApplication application;
2682   tet_infoline("UtcDaliTextFieldSettingPlaceholder");
2683
2684   TextField field = TextField::New();
2685   DALI_TEST_CHECK( field );
2686   application.GetScene().Add( field );
2687
2688   // Check the placeholder property with pixel size
2689   Property::Map placeholderPixelSizeMapSet;
2690   Property::Map placeholderPixelSizeMapGet;
2691   Property::Map placeholderFontstyleMap;
2692   placeholderPixelSizeMapSet[ Text::PlaceHolder::Property::TEXT ] = "Setting Placeholder Text";
2693   placeholderPixelSizeMapSet[ Text::PlaceHolder::Property::TEXT_FOCUSED ] = "Setting Placeholder Text Focused";
2694   placeholderPixelSizeMapSet[ Text::PlaceHolder::Property::COLOR ] = Color::BLUE;
2695   placeholderPixelSizeMapSet[ Text::PlaceHolder::Property::FONT_FAMILY ] = "Arial";
2696   placeholderPixelSizeMapSet[ Text::PlaceHolder::Property::PIXEL_SIZE ] = 15.0f;
2697   placeholderPixelSizeMapSet[ Text::PlaceHolder::Property::ELLIPSIS ] = true;
2698
2699   placeholderFontstyleMap.Insert( "weight", "bold" );
2700   placeholderPixelSizeMapSet[ Text::PlaceHolder::Property::FONT_STYLE ] = placeholderFontstyleMap;
2701   field.SetProperty( TextField::Property::PLACEHOLDER, placeholderPixelSizeMapSet );
2702
2703   placeholderPixelSizeMapGet = field.GetProperty<Property::Map>( TextField::Property::PLACEHOLDER );
2704   DALI_TEST_EQUALS( placeholderPixelSizeMapGet.Count(), placeholderPixelSizeMapSet.Count(), TEST_LOCATION );
2705   DALI_TEST_EQUALS( DaliTestCheckMaps( placeholderPixelSizeMapGet, placeholderPixelSizeMapSet ), true, TEST_LOCATION );
2706
2707   // Check the placeholder property with point size
2708   Property::Map placeholderMapSet;
2709   Property::Map placeholderMapGet;
2710   placeholderMapSet[ Text::PlaceHolder::Property::TEXT ] = "Setting Placeholder Text";
2711   placeholderMapSet[ Text::PlaceHolder::Property::TEXT_FOCUSED ] = "Setting Placeholder Text Focused";
2712   placeholderMapSet[ Text::PlaceHolder::Property::COLOR ] = Color::RED;
2713   placeholderMapSet[ Text::PlaceHolder::Property::FONT_FAMILY ] = "Arial";
2714   placeholderMapSet[ Text::PlaceHolder::Property::POINT_SIZE ] = 12.0f;
2715   placeholderMapSet[ Text::PlaceHolder::Property::ELLIPSIS ] = false;
2716
2717   // Check the placeholder font style property
2718   placeholderFontstyleMap.Clear();
2719
2720   placeholderFontstyleMap.Insert( "weight", "bold" );
2721   placeholderFontstyleMap.Insert( "width", "condensed" );
2722   placeholderFontstyleMap.Insert( "slant", "italic" );
2723   placeholderMapSet[ Text::PlaceHolder::Property::FONT_STYLE ] = placeholderFontstyleMap;
2724   field.SetProperty( TextField::Property::PLACEHOLDER, placeholderMapSet );
2725
2726   placeholderMapGet = field.GetProperty<Property::Map>( TextField::Property::PLACEHOLDER );
2727   DALI_TEST_EQUALS( placeholderMapGet.Count(), placeholderMapSet.Count(), TEST_LOCATION );
2728   DALI_TEST_EQUALS( DaliTestCheckMaps( placeholderMapGet, placeholderMapSet ), true, TEST_LOCATION );
2729
2730   // Reset font style.
2731   placeholderFontstyleMap.Clear();
2732   placeholderFontstyleMap.Insert( "weight", "normal" );
2733   placeholderFontstyleMap.Insert( "slant", "oblique" );
2734   placeholderMapSet[ Text::PlaceHolder::Property::FONT_STYLE ] = placeholderFontstyleMap;
2735   field.SetProperty( TextField::Property::PLACEHOLDER, placeholderMapSet );
2736
2737   placeholderMapGet = field.GetProperty<Property::Map>( TextField::Property::PLACEHOLDER );
2738   DALI_TEST_EQUALS( placeholderMapGet.Count(), placeholderMapSet.Count(), TEST_LOCATION );
2739   DALI_TEST_EQUALS( DaliTestCheckMaps( placeholderMapGet, placeholderMapSet ), true, TEST_LOCATION );
2740
2741   placeholderFontstyleMap.Clear();
2742   placeholderFontstyleMap.Insert( "slant", "roman" );
2743   placeholderMapSet[ Text::PlaceHolder::Property::FONT_STYLE ] = placeholderFontstyleMap;
2744   field.SetProperty( TextField::Property::PLACEHOLDER, placeholderMapSet );
2745
2746   placeholderMapGet = field.GetProperty<Property::Map>( TextField::Property::PLACEHOLDER );
2747
2748   placeholderFontstyleMap.Clear();
2749   placeholderMapSet[ Text::PlaceHolder::Property::FONT_STYLE ] = placeholderFontstyleMap;
2750
2751   field.SetProperty( TextField::Property::PLACEHOLDER, placeholderMapSet );
2752   placeholderMapGet = field.GetProperty<Property::Map>( TextField::Property::PLACEHOLDER );
2753   DALI_TEST_EQUALS( placeholderMapGet.Count(), placeholderMapSet.Count(), TEST_LOCATION );
2754   DALI_TEST_EQUALS( DaliTestCheckMaps( placeholderMapGet, placeholderMapSet ), true, TEST_LOCATION );
2755
2756   END_TEST;
2757 }
2758
2759 int UtcDaliTextFieldSetPaddingProperty(void)
2760 {
2761   ToolkitTestApplication application;
2762   tet_infoline("UtcDaliTextFieldSetPaddingProperty\n");
2763
2764   TextField field = TextField::New();
2765   DALI_TEST_CHECK( field );
2766   field.SetProperty( Actor::Property::SIZE, Vector2( 300.f, 50.f ) );
2767   field.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT );
2768   field.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT );
2769   application.GetScene().Add( field );
2770
2771   application.SendNotification();
2772   application.Render();
2773
2774   Vector3 originalSize = field.GetNaturalSize();
2775
2776   field.SetProperty( Toolkit::Control::Property::PADDING, Extents( 10, 10, 10, 10 ) );
2777
2778   application.SendNotification();
2779   application.Render();
2780
2781   DALI_TEST_EQUALS( field.GetProperty<Extents>( Toolkit::Control::Property::PADDING ), Extents( 10, 10, 10, 10 ), TEST_LOCATION );
2782
2783   Vector3 paddingAddedSize = field.GetNaturalSize();
2784
2785   DALI_TEST_EQUALS( originalSize.width + 10 + 10 , paddingAddedSize.width, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
2786
2787   DALI_TEST_EQUALS( originalSize.height + 10 + 10 , paddingAddedSize.height, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
2788
2789   END_TEST;
2790 }
2791
2792 int UtcDaliTextFieldEnableShiftSelectionProperty(void)
2793 {
2794   ToolkitTestApplication application;
2795   tet_infoline("UtcDaliTextFieldEnableShiftSelectionProperty");
2796
2797   TextField field = TextField::New();
2798   DALI_TEST_CHECK( field );
2799   field.SetProperty( Actor::Property::SIZE, Vector2( 300.f, 50.f ) );
2800   field.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT );
2801   field.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT );
2802   application.GetScene().Add( field );
2803
2804   application.SendNotification();
2805   application.Render();
2806
2807   // The default value of ENABLE_SHIFT_SELECTION is 'true'.
2808   DALI_TEST_EQUALS( field.GetProperty<bool>( DevelTextField::Property::ENABLE_SHIFT_SELECTION ), true, TEST_LOCATION );
2809
2810   // Check the enable shift selection property
2811   field.SetProperty( DevelTextField::Property::ENABLE_SHIFT_SELECTION, false );
2812   DALI_TEST_EQUALS( field.GetProperty<bool>( DevelTextField::Property::ENABLE_SHIFT_SELECTION ), false, TEST_LOCATION );
2813
2814   application.SendNotification();
2815   application.Render();
2816
2817   END_TEST;
2818 }
2819
2820 int UtcDaliTextFieldEnableGrabHandleProperty(void)
2821 {
2822   ToolkitTestApplication application;
2823   tet_infoline("UtcDaliTextFieldEnableGrabHandleProperty");
2824
2825   TextField field = TextField::New();
2826   DALI_TEST_CHECK( field );
2827   field.SetProperty( Actor::Property::SIZE, Vector2( 300.f, 50.f ) );
2828   field.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT );
2829   field.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT );
2830   application.GetScene().Add( field );
2831
2832   application.SendNotification();
2833   application.Render();
2834
2835   // The default value of ENABLE_GRAB_HANDLE is 'true'.
2836   DALI_TEST_EQUALS( field.GetProperty<bool>( DevelTextField::Property::ENABLE_GRAB_HANDLE ), true, TEST_LOCATION );
2837
2838   // Check the enable grab handle property
2839   field.SetProperty( DevelTextField::Property::ENABLE_GRAB_HANDLE, false );
2840   DALI_TEST_EQUALS( field.GetProperty<bool>( DevelTextField::Property::ENABLE_GRAB_HANDLE ), false, TEST_LOCATION );
2841
2842   application.SendNotification();
2843   application.Render();
2844
2845   END_TEST;
2846 }
2847
2848 int UtcDaliTextFieldMatchSystemLanguageDirectionProperty(void)
2849 {
2850   ToolkitTestApplication application;
2851   tet_infoline("UtcDaliTextFieldMatchSystemLanguageDirectionProperty");
2852
2853   TextField field = TextField::New();
2854   DALI_TEST_CHECK( field );
2855   field.SetProperty( Actor::Property::SIZE, Vector2( 300.f, 50.f ) );
2856   field.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT );
2857   field.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT );
2858   application.GetScene().Add( field );
2859
2860   application.SendNotification();
2861   application.Render();
2862
2863   // The default value of MATCH_SYSTEM_LANGUAGE_DIRECTION is 'false'.
2864   DALI_TEST_EQUALS( field.GetProperty<bool>( DevelTextField::Property::MATCH_SYSTEM_LANGUAGE_DIRECTION ), false, TEST_LOCATION );
2865
2866   // Check the match system language direction property
2867   field.SetProperty( DevelTextField::Property::MATCH_SYSTEM_LANGUAGE_DIRECTION, true );
2868   DALI_TEST_EQUALS( field.GetProperty<bool>( DevelTextField::Property::MATCH_SYSTEM_LANGUAGE_DIRECTION ), true, TEST_LOCATION );
2869
2870   application.SendNotification();
2871   application.Render();
2872
2873   END_TEST;
2874 }
2875
2876 int utcDaliTextFieldLayoutDirectionCoverage(void)
2877 {
2878   ToolkitTestApplication application;
2879   tet_infoline(" utcDaliTextFieldLayoutDirectionCoverage");
2880
2881   // Creates a tap event. After creating a tap event the text field should
2882   // have the focus and add text with key events should be possible.
2883   TextField field = TextField::New();
2884   DALI_TEST_CHECK( field );
2885
2886   application.GetScene().Add( field );
2887
2888   field.SetProperty( Actor::Property::SIZE, Vector2( 300.f, 50.f ) );
2889   field.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT );
2890   field.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT );
2891
2892   // Avoid a crash when core load gl resources.
2893   application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
2894
2895   // Render and notify
2896   application.SendNotification();
2897   application.Render();
2898
2899   // init direction for coverage
2900   // Set horizontal alignment END
2901   field.SetProperty( TextField::Property::HORIZONTAL_ALIGNMENT, "END");
2902
2903   // Create a tap event to touch the text field.
2904   TestGenerateTap( application, 150.0f, 25.0f );
2905
2906   // Render and notify
2907   application.SendNotification();
2908   application.Render();
2909
2910   // Set MATCH_SYSTEM_LANGUAGE_DIRECTION to true to use the layout direction.
2911   field.SetProperty( DevelTextField::Property::MATCH_SYSTEM_LANGUAGE_DIRECTION, true );
2912   field.SetProperty( Actor::Property::LAYOUT_DIRECTION, LayoutDirection::RIGHT_TO_LEFT );
2913
2914   // Set horizontal alignment BEGIN
2915   field.SetProperty( TextField::Property::HORIZONTAL_ALIGNMENT, "BEGIN");
2916
2917   // Create a tap event to touch the text field.
2918   TestGenerateTap( application, 150.0f, 25.0f );
2919
2920   // Render and notify
2921   application.SendNotification();
2922   application.Render();
2923
2924   // Set horizontal alignment CENTER
2925   field.SetProperty( TextField::Property::HORIZONTAL_ALIGNMENT, "CENTER");
2926
2927   // Create a tap event to touch the text field.
2928   TestGenerateTap( application, 150.0f, 25.0f );
2929
2930   // Render and notify
2931   application.SendNotification();
2932   application.Render();
2933
2934   // Set horizontal alignment END
2935   field.SetProperty( TextField::Property::HORIZONTAL_ALIGNMENT, "END");
2936
2937   // Create a tap event to touch the text field.
2938   TestGenerateTap( application, 150.0f, 25.0f );
2939
2940   // Render and notify
2941   application.SendNotification();
2942   application.Render();
2943
2944   // Generate a Esc key event. The text field should lose the focus.
2945   application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_ESCAPE, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2946   application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_ESCAPE, 0, 0, Integration::KeyEvent::UP, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2947
2948   // Render and notify
2949   application.SendNotification();
2950   application.Render();
2951
2952   DALI_TEST_EQUALS( false, field.HasKeyInputFocus(), TEST_LOCATION );
2953
2954   END_TEST;
2955 }
2956
2957 int UtcDaliTextFieldGetInputMethodContext(void)
2958 {
2959   ToolkitTestApplication application;
2960   tet_infoline("UtcDaliTextFieldGetInputMethodContext");
2961
2962   TextField field = TextField::New();
2963   DALI_TEST_CHECK( DevelTextField::GetInputMethodContext( field ) );
2964
2965   END_TEST;
2966 }
2967
2968 int UtcDaliTextFieldSelectWholeText(void)
2969 {
2970   ToolkitTestApplication application;
2971   tet_infoline(" UtcDaliTextFieldSelectWholeText ");
2972
2973   TextField textField = TextField::New();
2974
2975   application.GetScene().Add( textField );
2976
2977   textField.SetProperty( Actor::Property::SIZE, Vector2( 300.f, 50.f ) );
2978   textField.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT );
2979   textField.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT );
2980
2981   // Avoid a crash when core load gl resources.
2982   application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
2983
2984   application.SendNotification();
2985   application.Render();
2986
2987   DALI_TEST_EQUALS( 1u, textField.GetChildCount(), TEST_LOCATION );
2988
2989   DevelTextField::SelectWholeText( textField );
2990
2991   application.SendNotification();
2992   application.Render();
2993
2994   // Nothing should have been selected. The number of children is still 1
2995   DALI_TEST_EQUALS( 1u, textField.GetChildCount(), TEST_LOCATION );
2996
2997   textField.SetProperty( TextField::Property::TEXT, "Hello world" );
2998
2999   application.SendNotification();
3000   application.Render();
3001
3002   DevelTextField::SelectWholeText( textField );
3003
3004   application.SendNotification();
3005   application.Render();
3006
3007   // Should be 2 children, the stencil and the layer
3008   DALI_TEST_EQUALS( 2u, textField.GetChildCount(), TEST_LOCATION );
3009
3010   // The offscreen root actor should have two actors: the renderer and the highlight actor.
3011   Actor stencil = textField.GetChildAt( 0u );
3012
3013   // The highlight actor is drawn first, so is the first actor in the list
3014   Renderer highlight = stencil.GetChildAt( 0u ).GetRendererAt( 0u );
3015   DALI_TEST_CHECK( highlight );
3016
3017   END_TEST;
3018 }
3019
3020 int UtcDaliTextFieldSelectNone(void)
3021 {
3022   ToolkitTestApplication application;
3023   tet_infoline(" UtcDaliTextFieldSelectWholeText ");
3024
3025   TextField textField = TextField::New();
3026
3027   application.GetScene().Add( textField );
3028
3029   textField.SetProperty( Actor::Property::SIZE, Vector2( 300.f, 50.f ) );
3030   textField.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT );
3031   textField.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT );
3032
3033   // Avoid a crash when core load gl resources.
3034   application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
3035
3036   application.SendNotification();
3037   application.Render();
3038
3039   textField.SetProperty( TextField::Property::TEXT, "Hello world" );
3040
3041   application.SendNotification();
3042   application.Render();
3043
3044   // Nothing is selected
3045   std::string selectedText = textField.GetProperty( DevelTextField::Property::SELECTED_TEXT ).Get<std::string>();
3046   DALI_TEST_EQUALS( "", selectedText, TEST_LOCATION );
3047
3048   DevelTextField::SelectWholeText( textField );
3049
3050   application.SendNotification();
3051   application.Render();
3052
3053   // whole text is selected
3054   selectedText = textField.GetProperty( DevelTextField::Property::SELECTED_TEXT ).Get<std::string>();
3055   DALI_TEST_EQUALS( "Hello world", selectedText, TEST_LOCATION );
3056
3057   DevelTextField::SelectNone( textField );
3058
3059   application.SendNotification();
3060   application.Render();
3061
3062   // Nothing is selected
3063   selectedText = textField.GetProperty( DevelTextField::Property::SELECTED_TEXT ).Get<std::string>();
3064   DALI_TEST_EQUALS( "", selectedText, TEST_LOCATION );
3065
3066   END_TEST;
3067 }
3068
3069 int UtcDaliTextFieldSelectRange(void)
3070 {
3071   ToolkitTestApplication application;
3072   tet_infoline(" UtcDaliTextFieldSelectRange ");
3073
3074   TextField textField = TextField::New();
3075
3076   application.GetScene().Add( textField );
3077
3078   textField.SetProperty( Actor::Property::SIZE, Vector2( 300.f, 50.f ) );
3079   textField.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT );
3080   textField.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT );
3081
3082   // Avoid a crash when core load gl resources.
3083   application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
3084
3085   application.SendNotification();
3086   application.Render();
3087
3088   textField.SetProperty( TextField::Property::TEXT, "Hello world" );
3089
3090   application.SendNotification();
3091   application.Render();
3092
3093   textField.SetProperty( DevelTextField::Property::SELECTED_TEXT_START , 0);
3094   textField.SetProperty( DevelTextField::Property::SELECTED_TEXT_END , 5);
3095
3096   // Hello is selected
3097   std::string selectedText = textField.GetProperty( DevelTextField::Property::SELECTED_TEXT ).Get<std::string>();
3098   DALI_TEST_EQUALS( "Hello", selectedText, TEST_LOCATION );
3099
3100   DALI_TEST_EQUALS( textField.GetProperty( DevelTextField::Property::SELECTED_TEXT_START ).Get<int>(), 0, TEST_LOCATION );
3101   DALI_TEST_EQUALS( textField.GetProperty( DevelTextField::Property::SELECTED_TEXT_END ).Get<int>(), 5, TEST_LOCATION );
3102
3103   textField.SetProperty( DevelTextField::Property::SELECTED_TEXT_START , 6);
3104   textField.SetProperty( DevelTextField::Property::SELECTED_TEXT_END , 11);
3105
3106   // world is selected
3107   selectedText = textField.GetProperty( DevelTextField::Property::SELECTED_TEXT ).Get<std::string>();
3108   DALI_TEST_EQUALS( "world", selectedText, TEST_LOCATION );
3109
3110   DALI_TEST_EQUALS( textField.GetProperty( DevelTextField::Property::SELECTED_TEXT_START ).Get<int>(), 6, TEST_LOCATION );
3111   DALI_TEST_EQUALS( textField.GetProperty( DevelTextField::Property::SELECTED_TEXT_END ).Get<int>(), 11, TEST_LOCATION );
3112
3113   END_TEST;
3114 }
3115
3116 int UtcDaliTextFieldEnableEditing(void)
3117 {
3118   ToolkitTestApplication application;
3119   tet_infoline(" UtcDaliTextFieldEnableEditing ");
3120
3121   TextField textField = TextField::New();
3122
3123   application.GetScene().Add( textField );
3124
3125   textField.SetProperty( Actor::Property::SIZE, Vector2( 300.f, 50.f ) );
3126   textField.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT );
3127   textField.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT );
3128
3129   // Avoid a crash when core load gl resources.
3130   application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
3131
3132   application.SendNotification();
3133   application.Render();
3134
3135   textField.SetKeyInputFocus();
3136   textField.SetProperty( DevelTextField::Property::ENABLE_EDITING, false );
3137   application.ProcessEvent( GenerateKey( "D", "", "D", KEY_D_CODE, 0, 0, Integration::KeyEvent::DOWN, "D", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
3138
3139   // Render and notify
3140   application.SendNotification();
3141   application.Render();
3142
3143   DALI_TEST_EQUALS( textField.GetProperty( TextField::Property::TEXT ).Get<std::string>(), "", TEST_LOCATION );
3144   DALI_TEST_EQUALS( textField.GetProperty( DevelTextField::Property::ENABLE_EDITING ).Get<bool>(), false, TEST_LOCATION );
3145
3146
3147   textField.SetKeyInputFocus();
3148   textField.SetProperty( DevelTextField::Property::ENABLE_EDITING, true );
3149   application.ProcessEvent( GenerateKey( "D", "", "D", KEY_D_CODE, 0, 0, Integration::KeyEvent::DOWN, "D", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
3150
3151   // Render and notify
3152   application.SendNotification();
3153   application.Render();
3154
3155   DALI_TEST_EQUALS( textField.GetProperty( TextField::Property::TEXT ).Get<std::string>(), "D", TEST_LOCATION );
3156   DALI_TEST_EQUALS( textField.GetProperty( DevelTextField::Property::ENABLE_EDITING ).Get<bool>(), true, TEST_LOCATION );
3157
3158   END_TEST;
3159 }
3160
3161 int UtcDaliToolkitTextFieldFontSizeScale(void)
3162 {
3163   ToolkitTestApplication application;
3164   tet_infoline(" UtcDaliToolkitTextFieldFontSizeScale");
3165
3166   TextField textField = TextField::New();
3167   textField.SetProperty( TextField::Property::POINT_SIZE, 30.f );
3168   textField.SetProperty( TextField::Property::TEXT, "Test" );
3169   Vector3 nonScaledSize = textField.GetNaturalSize();
3170
3171   TextField textFieldScaled = TextField::New();
3172   textFieldScaled.SetProperty( TextField::Property::POINT_SIZE, 15.f );
3173   textFieldScaled.SetProperty( Toolkit::DevelTextField::Property::FONT_SIZE_SCALE, 2.f );
3174   textFieldScaled.SetProperty( TextField::Property::TEXT, "Test" );
3175   Vector3 scaledSize = textFieldScaled.GetNaturalSize();
3176
3177   DALI_TEST_EQUALS( nonScaledSize, scaledSize, TEST_LOCATION );
3178
3179   textField.SetProperty( TextField::Property::PIXEL_SIZE, 30.f );
3180   textField.SetProperty( TextField::Property::TEXT, "Test" );
3181   nonScaledSize = textField.GetNaturalSize();
3182
3183   textFieldScaled.SetProperty( TextField::Property::PIXEL_SIZE, 15.f );
3184   textFieldScaled.SetProperty( Toolkit::DevelTextField::Property::FONT_SIZE_SCALE, 2.f );
3185   textFieldScaled.SetProperty( TextField::Property::TEXT, "Test" );
3186   scaledSize = textFieldScaled.GetNaturalSize();
3187
3188   DALI_TEST_EQUALS( nonScaledSize, scaledSize, TEST_LOCATION );
3189
3190   END_TEST;
3191 }
3192
3193 int UtcDaliTextFieldPrimaryCursorPosition(void)
3194 {
3195   ToolkitTestApplication application;
3196   tet_infoline(" UtcDaliTextFieldPrimaryCursorPosition ");
3197
3198   TextField textField = TextField::New();
3199
3200   application.GetScene().Add( textField );
3201
3202   textField.SetProperty( TextField::Property::TEXT, "ABCEF");
3203   textField.SetProperty( Actor::Property::SIZE, Vector2( 300.f, 50.f ) );
3204   textField.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT );
3205   textField.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT );
3206
3207   // Avoid a crash when core load gl resources.
3208   application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
3209
3210   textField.SetProperty( DevelTextField::Property::PRIMARY_CURSOR_POSITION, 3);
3211   application.SendNotification();
3212   application.Render();
3213
3214   application.ProcessEvent( GenerateKey( "D", "", "D", KEY_D_CODE, 0, 0, Integration::KeyEvent::DOWN, "D", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
3215
3216   // Render and notify
3217   application.SendNotification();
3218   application.Render();
3219
3220   DALI_TEST_EQUALS( textField.GetProperty( TextField::Property::TEXT ).Get<std::string>(), "ABCDEF", TEST_LOCATION );
3221   DALI_TEST_EQUALS( textField.GetProperty( DevelTextField::Property::PRIMARY_CURSOR_POSITION ).Get<int>(), 4, TEST_LOCATION );
3222
3223   END_TEST;
3224 }