Merge "Add OPTION_DIVIDER_PADDING property to TextSelectionPopup" 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   DALI_TEST_CHECK( gTextChangedCallBackCalled );
1044   DALI_TEST_CHECK( textChangedSignal );
1045
1046   application.SendNotification();
1047   field.SetKeyInputFocus();
1048
1049   gTextChangedCallBackCalled = false;
1050   application.ProcessEvent( GenerateKey( "D", "", "D", KEY_D_CODE, 0, 0, Integration::KeyEvent::DOWN, "D", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
1051   DALI_TEST_CHECK( gTextChangedCallBackCalled );
1052
1053   // Remove all text
1054   field.SetProperty( TextField::Property::TEXT, "" );
1055
1056   // Pressing backspace key: TextChangedCallback should not be called when there is no text in textfield.
1057   gTextChangedCallBackCalled = false;
1058   application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_BACKSPACE, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
1059   DALI_TEST_CHECK( !gTextChangedCallBackCalled );
1060
1061   // Pressing delete key: TextChangedCallback should not be called when there is no text in textfield.
1062   gTextChangedCallBackCalled = false;
1063   application.ProcessEvent( GenerateKey( "", "", "", Dali::DevelKey::DALI_KEY_DELETE, 0, 0, Integration::KeyEvent::DOWN, "Delete", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
1064   DALI_TEST_CHECK( !gTextChangedCallBackCalled );
1065
1066   END_TEST;
1067 }
1068
1069 int utcDaliTextFieldTextChangedWithInputMethodContext(void)
1070 {
1071   ToolkitTestApplication application;
1072   tet_infoline(" utcDaliTextFieldTextChangedWithInputMethodContext");
1073   TextField field = TextField::New();
1074   DALI_TEST_CHECK( field );
1075
1076
1077   application.GetScene().Add( field );
1078
1079   // connect to the text changed signal.
1080   ConnectionTracker* testTracker = new ConnectionTracker();
1081   field.TextChangedSignal().Connect(&TestTextChangedCallback);
1082   bool textChangedSignal = false;
1083   field.ConnectSignal( testTracker, "textChanged",   CallbackFunctor(&textChangedSignal) );
1084
1085
1086   // get InputMethodContext
1087   std::string text;
1088   InputMethodContext::EventData imfEvent;
1089   InputMethodContext inputMethodContext = DevelTextField::GetInputMethodContext( field );
1090
1091   field.SetKeyInputFocus();
1092   field.SetProperty( DevelTextField::Property::ENABLE_EDITING, true );
1093
1094   // input text
1095   gTextChangedCallBackCalled = false;
1096   imfEvent = InputMethodContext::EventData( InputMethodContext::PRE_EDIT, "ㅎ", 0, 1 );
1097   inputMethodContext.EventReceivedSignal().Emit(inputMethodContext, imfEvent);
1098   application.SendNotification();
1099   application.Render();
1100   DALI_TEST_CHECK( gTextChangedCallBackCalled );
1101   DALI_TEST_EQUALS( field.GetProperty<std::string>( TextField::Property::TEXT ), std::string("ㅎ"), TEST_LOCATION );
1102
1103   gTextChangedCallBackCalled = false;
1104   imfEvent = InputMethodContext::EventData( InputMethodContext::PRE_EDIT, "호", 0, 1 );
1105   inputMethodContext.EventReceivedSignal().Emit(inputMethodContext, imfEvent);
1106   application.SendNotification();
1107   application.Render();
1108   DALI_TEST_CHECK( gTextChangedCallBackCalled );
1109   DALI_TEST_EQUALS( field.GetProperty<std::string>( TextField::Property::TEXT ), std::string("호"), TEST_LOCATION );
1110
1111   gTextChangedCallBackCalled = false;
1112   imfEvent = InputMethodContext::EventData( InputMethodContext::PRE_EDIT, "혿", 0, 1 );
1113   inputMethodContext.EventReceivedSignal().Emit(inputMethodContext, imfEvent);
1114   application.SendNotification();
1115   application.Render();
1116   DALI_TEST_CHECK( gTextChangedCallBackCalled );
1117   DALI_TEST_EQUALS( field.GetProperty<std::string>( TextField::Property::TEXT ), std::string("혿"), TEST_LOCATION );
1118
1119   gTextChangedCallBackCalled = false;
1120   imfEvent = InputMethodContext::EventData( InputMethodContext::PRE_EDIT, "", 0, 1 );
1121   inputMethodContext.EventReceivedSignal().Emit(inputMethodContext, imfEvent);
1122   DALI_TEST_CHECK( !gTextChangedCallBackCalled );
1123
1124   imfEvent = InputMethodContext::EventData( InputMethodContext::COMMIT, "호", 0, 1 );
1125   inputMethodContext.EventReceivedSignal().Emit(inputMethodContext, imfEvent);
1126   DALI_TEST_CHECK( !gTextChangedCallBackCalled );
1127
1128   imfEvent = InputMethodContext::EventData( InputMethodContext::PRE_EDIT, "두", 1, 2 );
1129   inputMethodContext.EventReceivedSignal().Emit(inputMethodContext, imfEvent);
1130   DALI_TEST_CHECK( !gTextChangedCallBackCalled );
1131
1132   application.SendNotification();
1133   application.Render();
1134   DALI_TEST_CHECK( gTextChangedCallBackCalled );
1135   DALI_TEST_EQUALS( field.GetProperty<std::string>( TextField::Property::TEXT ), std::string("호두"), TEST_LOCATION );
1136
1137   END_TEST;
1138 }
1139
1140
1141 // Negative test for the textChanged signal.
1142 int utcDaliTextFieldTextChangedN(void)
1143 {
1144   ToolkitTestApplication application;
1145   tet_infoline(" utcDaliTextFieldTextChangedN");
1146   TextField field = TextField::New();
1147   DALI_TEST_CHECK( field );
1148
1149   application.GetScene().Add( field );
1150
1151   // connect to the text changed signal.
1152   ConnectionTracker* testTracker = new ConnectionTracker();
1153   field.TextChangedSignal().Connect(&TestTextChangedCallback);
1154   bool textChangedSignal = false;
1155   field.ConnectSignal( testTracker, "textChanged",   CallbackFunctor(&textChangedSignal) );
1156
1157   gTextChangedCallBackCalled = false;
1158   field.SetProperty( TextField::Property::PLACEHOLDER_TEXT, "ABC" ); // Setting placeholder, not TEXT
1159   application.SendNotification();
1160   application.Render();
1161   DALI_TEST_CHECK( !gTextChangedCallBackCalled );
1162   DALI_TEST_CHECK( !textChangedSignal );
1163
1164   END_TEST;
1165 }
1166
1167 // Positive test for Max Characters reached signal.
1168 int utcDaliTextFieldMaxCharactersReachedP(void)
1169 {
1170   ToolkitTestApplication application;
1171   tet_infoline(" utcDaliTextFieldMaxCharactersReachedP");
1172   TextField field = TextField::New();
1173   DALI_TEST_CHECK( field );
1174
1175   application.GetScene().Add( field );
1176
1177   const int maxNumberOfCharacters = 1;
1178   field.SetProperty( TextField::Property::MAX_LENGTH, maxNumberOfCharacters );
1179
1180   field.SetKeyInputFocus();
1181
1182   // connect to the text changed signal.
1183   ConnectionTracker* testTracker = new ConnectionTracker();
1184   field.MaxLengthReachedSignal().Connect(&TestMaxLengthReachedCallback);
1185   bool maxLengthReachedSignal = false;
1186   field.ConnectSignal( testTracker, "maxLengthReached",   CallbackFunctor(&maxLengthReachedSignal) );
1187
1188   gMaxCharactersCallBackCalled = false;
1189
1190   application.ProcessEvent( GenerateKey( "a", "", "a", KEY_A_CODE, 0, 0, Integration::KeyEvent::DOWN, "a", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
1191   application.ProcessEvent( GenerateKey( "a", "", "a", KEY_A_CODE, 0, 0, Integration::KeyEvent::DOWN, "a", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
1192
1193   DALI_TEST_CHECK( gMaxCharactersCallBackCalled );
1194   DALI_TEST_CHECK( maxLengthReachedSignal );
1195
1196   END_TEST;
1197 }
1198
1199 // Negative test for Max Characters reached signal.
1200 int utcDaliTextFieldMaxCharactersReachedN(void)
1201 {
1202   ToolkitTestApplication application;
1203   tet_infoline(" utcDaliTextFieldMaxCharactersReachedN");
1204   TextField field = TextField::New();
1205   DALI_TEST_CHECK( field );
1206
1207   application.GetScene().Add( field );
1208
1209   const int maxNumberOfCharacters = 3;
1210   field.SetProperty( TextField::Property::MAX_LENGTH, maxNumberOfCharacters );
1211
1212   field.SetKeyInputFocus();
1213
1214   // connect to the text changed signal.
1215   ConnectionTracker* testTracker = new ConnectionTracker();
1216   field.MaxLengthReachedSignal().Connect(&TestMaxLengthReachedCallback);
1217   bool maxLengthReachedSignal = false;
1218   field.ConnectSignal( testTracker, "maxLengthReached",   CallbackFunctor(&maxLengthReachedSignal) );
1219
1220   gMaxCharactersCallBackCalled = false;
1221
1222   application.ProcessEvent( GenerateKey( "a", "", "a", KEY_A_CODE, 0, 0, Integration::KeyEvent::DOWN, "a", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
1223   application.ProcessEvent( GenerateKey( "a", "", "a", KEY_A_CODE, 0, 0, Integration::KeyEvent::DOWN, "a", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
1224
1225   DALI_TEST_CHECK( !gMaxCharactersCallBackCalled );
1226   DALI_TEST_CHECK( !maxLengthReachedSignal );
1227
1228   application.ProcessEvent( GenerateKey( "Return", "", "\r", KEY_RETURN_CODE, 0, 0, Integration::KeyEvent::DOWN, "\r", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
1229
1230   DALI_TEST_CHECK( !gMaxCharactersCallBackCalled );
1231   DALI_TEST_CHECK( !maxLengthReachedSignal );
1232
1233   END_TEST;
1234 }
1235
1236 int utcDaliTextFieldInputStyleChanged01(void)
1237 {
1238   // The text-field emits signals when the input style changes. These changes of style are
1239   // detected during the relayout process (size negotiation), i.e after the cursor has been moved. Signals
1240   // can't be emitted during the size negotiation as the callbacks may update the UI.
1241   // The text-field adds an idle callback to the adaptor to emit the signals after the size negotiation.
1242   // The ToolkitTestApplication creates an implementation of the adaptor stub and a queue of idle callbacks.
1243   ToolkitTestApplication application;
1244   tet_infoline(" utcDaliTextFieldInputStyleChanged01");
1245
1246   // Load some fonts.
1247
1248   char* pathNamePtr = get_current_dir_name();
1249   const std::string pathName( pathNamePtr );
1250   free( pathNamePtr );
1251
1252   TextAbstraction::FontClient fontClient = TextAbstraction::FontClient::Get();
1253   fontClient.SetDpi( 93u, 93u );
1254
1255   fontClient.GetFontId( pathName + DEFAULT_FONT_DIR + "/dejavu/DejaVuSerif.ttf", DEFAULT_FONT_SIZE );
1256   fontClient.GetFontId( pathName + DEFAULT_FONT_DIR + "/dejavu/DejaVuSerif-Bold.ttf", DEFAULT_FONT_SIZE );
1257
1258   TextField field = TextField::New();
1259   DALI_TEST_CHECK( field );
1260
1261
1262   field.SetProperty( Actor::Property::SIZE, Vector2( 300.f, 50.f ) );
1263   field.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT );
1264   field.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT );
1265
1266   field.SetProperty( TextField::Property::ENABLE_MARKUP, true );
1267   field.SetProperty( TextField::Property::TEXT, "<font family='DejaVuSerif' size='18'>He<color value='green'>llo</color> <font weight='bold'>world</font> demo</font>" );
1268
1269   // connect to the text changed signal.
1270   ConnectionTracker* testTracker = new ConnectionTracker();
1271   field.InputStyleChangedSignal().Connect( &TestInputStyleChangedCallback );
1272   bool inputStyleChangedSignal = false;
1273   field.ConnectSignal( testTracker, "inputStyleChanged",   CallbackFunctor(&inputStyleChangedSignal) );
1274
1275   application.GetScene().Add( field );
1276
1277   // Render and notify
1278   application.SendNotification();
1279   application.Render();
1280
1281   // Executes the idle callbacks added by the text control on the change of input style.
1282   application.RunIdles();
1283
1284   gInputStyleChangedCallbackCalled = false;
1285   gInputStyleMask = TextField::InputStyle::NONE;
1286   inputStyleChangedSignal = false;
1287
1288   // Create a tap event to touch the text field.
1289   TestGenerateTap( application, 18.0f, 25.0f );
1290
1291   // Render and notify
1292   application.SendNotification();
1293   application.Render();
1294
1295   // Executes the idle callbacks added by the text control on the change of input style.
1296   application.RunIdles();
1297
1298   DALI_TEST_CHECK( gInputStyleChangedCallbackCalled );
1299   if( gInputStyleChangedCallbackCalled )
1300   {
1301     DALI_TEST_EQUALS( static_cast<unsigned int>( gInputStyleMask ), static_cast<unsigned int>( TextField::InputStyle::FONT_FAMILY | TextField::InputStyle::POINT_SIZE ), TEST_LOCATION );
1302
1303     const std::string fontFamily = field.GetProperty( TextField::Property::INPUT_FONT_FAMILY ).Get<std::string>();
1304     DALI_TEST_EQUALS( fontFamily, "DejaVuSerif", TEST_LOCATION );
1305
1306     const float pointSize = field.GetProperty( TextField::Property::INPUT_POINT_SIZE ).Get<float>();
1307     DALI_TEST_EQUALS( pointSize, 18.f, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
1308   }
1309   DALI_TEST_CHECK( inputStyleChangedSignal );
1310
1311   gInputStyleChangedCallbackCalled = false;
1312   gInputStyleMask = TextField::InputStyle::NONE;
1313   inputStyleChangedSignal = false;
1314
1315   // Create a tap event to touch the text field.
1316   TestGenerateTap( application, 30.0f, 25.0f );
1317
1318   // Render and notify
1319   application.SendNotification();
1320   application.Render();
1321
1322   // Executes the idle callbacks added by the text control on the change of input style.
1323   application.RunIdles();
1324
1325   DALI_TEST_CHECK( !gInputStyleChangedCallbackCalled );
1326   DALI_TEST_CHECK( !inputStyleChangedSignal );
1327
1328   gInputStyleChangedCallbackCalled = false;
1329   gInputStyleMask = TextField::InputStyle::NONE;
1330   inputStyleChangedSignal = false;
1331
1332   // Create a tap event to touch the text field.
1333   TestGenerateTap( application, 43.0f, 25.0f );
1334
1335   // Render and notify
1336   application.SendNotification();
1337   application.Render();
1338
1339   // Executes the idle callbacks added by the text control on the change of input style.
1340   application.RunIdles();
1341
1342   DALI_TEST_CHECK( gInputStyleChangedCallbackCalled );
1343   if( gInputStyleChangedCallbackCalled )
1344   {
1345     DALI_TEST_EQUALS( static_cast<unsigned int>( gInputStyleMask ), static_cast<unsigned int>( TextField::InputStyle::COLOR ), TEST_LOCATION );
1346
1347     const Vector4 color = field.GetProperty( TextField::Property::INPUT_COLOR ).Get<Vector4>();
1348     DALI_TEST_EQUALS( color, Color::GREEN, TEST_LOCATION );
1349   }
1350   DALI_TEST_CHECK( inputStyleChangedSignal );
1351
1352   gInputStyleChangedCallbackCalled = false;
1353   gInputStyleMask = TextField::InputStyle::NONE;
1354   inputStyleChangedSignal = false;
1355
1356   // Create a tap event to touch the text field.
1357   TestGenerateTap( application, 88.0f, 25.0f );
1358
1359   // Render and notify
1360   application.SendNotification();
1361   application.Render();
1362
1363   // Executes the idle callbacks added by the text control on the change of input style.
1364   application.RunIdles();
1365
1366   DALI_TEST_CHECK( gInputStyleChangedCallbackCalled );
1367   if( gInputStyleChangedCallbackCalled )
1368   {
1369     DALI_TEST_EQUALS( static_cast<unsigned int>( gInputStyleMask ), static_cast<unsigned int>( TextField::InputStyle::COLOR | TextField::InputStyle::FONT_STYLE ), TEST_LOCATION );
1370
1371     const Vector4 color = field.GetProperty( TextField::Property::INPUT_COLOR ).Get<Vector4>();
1372     DALI_TEST_EQUALS( color, Color::BLACK, TEST_LOCATION );
1373
1374     const Property::Map fontStyleMapGet = field.GetProperty( TextField::Property::INPUT_FONT_STYLE ).Get<Property::Map>();
1375
1376     Property::Map fontStyleMapSet;
1377     fontStyleMapSet.Insert( "weight", "bold" );
1378
1379     DALI_TEST_EQUALS( fontStyleMapGet.Count(), fontStyleMapSet.Count(), TEST_LOCATION );
1380     DALI_TEST_EQUALS( DaliTestCheckMaps( fontStyleMapGet, fontStyleMapSet ), true, TEST_LOCATION );
1381   }
1382   DALI_TEST_CHECK( inputStyleChangedSignal );
1383
1384   gInputStyleChangedCallbackCalled = false;
1385   gInputStyleMask = TextField::InputStyle::NONE;
1386   inputStyleChangedSignal = false;
1387
1388   // Create a tap event to touch the text field.
1389   TestGenerateTap( application, 115.0f, 25.0f );
1390
1391   // Render and notify
1392   application.SendNotification();
1393   application.Render();
1394
1395   // Executes the idle callbacks added by the text control on the change of input style.
1396   application.RunIdles();
1397
1398   DALI_TEST_CHECK( !gInputStyleChangedCallbackCalled );
1399   DALI_TEST_CHECK( !inputStyleChangedSignal );
1400
1401   gInputStyleChangedCallbackCalled = false;
1402   gInputStyleMask = TextField::InputStyle::NONE;
1403   inputStyleChangedSignal = false;
1404
1405   // Create a tap event to touch the text field.
1406   TestGenerateTap( application, 164.0f, 25.0f );
1407
1408   // Render and notify
1409   application.SendNotification();
1410   application.Render();
1411
1412   // Executes the idle callbacks added by the text control on the change of input style.
1413   application.RunIdles();
1414
1415   DALI_TEST_CHECK( gInputStyleChangedCallbackCalled );
1416   if( gInputStyleChangedCallbackCalled )
1417   {
1418     DALI_TEST_EQUALS( static_cast<unsigned int>( gInputStyleMask ), static_cast<unsigned int>( TextField::InputStyle::FONT_STYLE ), TEST_LOCATION );
1419
1420     const std::string style = field.GetProperty( TextField::Property::INPUT_FONT_STYLE ).Get<std::string>();
1421     DALI_TEST_CHECK( style.empty() );
1422   }
1423   DALI_TEST_CHECK( inputStyleChangedSignal );
1424
1425   gInputStyleChangedCallbackCalled = false;
1426   gInputStyleMask = TextField::InputStyle::NONE;
1427   inputStyleChangedSignal = false;
1428
1429   // Create a tap event to touch the text field.
1430   TestGenerateTap( application, 191.0f, 25.0f );
1431
1432   // Render and notify
1433   application.SendNotification();
1434   application.Render();
1435
1436   // Executes the idle callbacks added by the text control on the change of input style.
1437   application.RunIdles();
1438
1439   DALI_TEST_CHECK( !gInputStyleChangedCallbackCalled );
1440   DALI_TEST_CHECK( !inputStyleChangedSignal );
1441
1442   END_TEST;
1443 }
1444
1445 int utcDaliTextFieldInputStyleChanged02(void)
1446 {
1447   // The text-field emits signals when the input style changes. These changes of style are
1448   // detected during the relayout process (size negotiation), i.e after the cursor has been moved. Signals
1449   // can't be emitted during the size negotiation as the callbacks may update the UI.
1450   // The text-field adds an idle callback to the adaptor to emit the signals after the size negotiation.
1451   // The ToolkitTestApplication creates an implementation of the adaptor stub and a queue of idle callbacks.
1452   ToolkitTestApplication application;
1453   tet_infoline(" utcDaliTextFieldInputStyleChanged02");
1454
1455   // Load some fonts.
1456
1457   char* pathNamePtr = get_current_dir_name();
1458   const std::string pathName( pathNamePtr );
1459   free( pathNamePtr );
1460
1461   TextAbstraction::FontClient fontClient = TextAbstraction::FontClient::Get();
1462   fontClient.SetDpi( 93u, 93u );
1463
1464   fontClient.GetFontId( pathName + DEFAULT_FONT_DIR + "/dejavu/DejaVuSerif.ttf", DEFAULT_FONT_SIZE );
1465   fontClient.GetFontId( pathName + DEFAULT_FONT_DIR + "/dejavu/DejaVuSerif-Bold.ttf", DEFAULT_FONT_SIZE );
1466
1467   TextField field = TextField::New();
1468   DALI_TEST_CHECK( field );
1469
1470   field.SetProperty( Actor::Property::SIZE, Vector2( 300.f, 50.f ) );
1471   field.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT );
1472   field.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT );
1473
1474   field.SetProperty( TextField::Property::ENABLE_MARKUP, true );
1475   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>" );
1476
1477   // connect to the text changed signal.
1478   ConnectionTracker* testTracker = new ConnectionTracker();
1479   field.InputStyleChangedSignal().Connect( &TestInputStyleChangedCallback );
1480   bool inputStyleChangedSignal = false;
1481   field.ConnectSignal( testTracker, "inputStyleChanged",   CallbackFunctor(&inputStyleChangedSignal) );
1482
1483   application.GetScene().Add( field );
1484
1485   // Render and notify
1486   application.SendNotification();
1487   application.Render();
1488
1489   // Executes the idle callbacks added by the text control on the change of input style.
1490   application.RunIdles();
1491
1492   gInputStyleChangedCallbackCalled = false;
1493   gInputStyleMask = TextField::InputStyle::NONE;
1494   inputStyleChangedSignal = false;
1495
1496   // Create a tap event to touch the text field.
1497   TestGenerateTap( application, 53.0f, 25.0f, 100 );
1498   TestGenerateTap( application, 53.0f, 25.0f, 200 );
1499
1500   // Render and notify
1501   application.SendNotification();
1502   application.Render();
1503
1504   // Executes the idle callbacks added by the text control on the change of input style.
1505   application.RunIdles();
1506
1507   DALI_TEST_CHECK( gInputStyleChangedCallbackCalled );
1508   if( gInputStyleChangedCallbackCalled )
1509   {
1510     DALI_TEST_EQUALS( static_cast<unsigned int>( gInputStyleMask ),
1511                       static_cast<unsigned int>( TextField::InputStyle::FONT_FAMILY |
1512                                                  TextField::InputStyle::POINT_SIZE  |
1513                                                  TextField::InputStyle::COLOR ),
1514                       TEST_LOCATION );
1515
1516     const Vector4 color = field.GetProperty( TextField::Property::INPUT_COLOR ).Get<Vector4>();
1517     DALI_TEST_EQUALS( color, Color::GREEN, TEST_LOCATION );
1518
1519     const std::string fontFamily = field.GetProperty( TextField::Property::INPUT_FONT_FAMILY ).Get<std::string>();
1520     DALI_TEST_EQUALS( fontFamily, "DejaVuSerif", TEST_LOCATION );
1521
1522     const float pointSize = field.GetProperty( TextField::Property::INPUT_POINT_SIZE ).Get<float>();
1523     DALI_TEST_EQUALS( pointSize, 18.f, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
1524   }
1525   DALI_TEST_CHECK( inputStyleChangedSignal );
1526
1527   gInputStyleChangedCallbackCalled = false;
1528   gInputStyleMask = TextField::InputStyle::NONE;
1529   inputStyleChangedSignal = false;
1530
1531   application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_BACKSPACE, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
1532
1533   // Render and notify
1534   application.SendNotification();
1535   application.Render();
1536
1537   // Executes the idle callbacks added by the text control on the change of input style.
1538   application.RunIdles();
1539
1540   DALI_TEST_CHECK( gInputStyleChangedCallbackCalled );
1541   if( gInputStyleChangedCallbackCalled )
1542   {
1543     DALI_TEST_EQUALS( static_cast<unsigned int>( gInputStyleMask ),
1544                       static_cast<unsigned int>( TextField::InputStyle::COLOR ),
1545                       TEST_LOCATION );
1546
1547     const Vector4 color = field.GetProperty( TextField::Property::INPUT_COLOR ).Get<Vector4>();
1548     DALI_TEST_EQUALS( color, Color::BLUE, TEST_LOCATION );
1549   }
1550   DALI_TEST_CHECK( inputStyleChangedSignal );
1551
1552   gInputStyleChangedCallbackCalled = false;
1553   gInputStyleMask = TextField::InputStyle::NONE;
1554   inputStyleChangedSignal = false;
1555
1556   application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_BACKSPACE, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
1557
1558   // Render and notify
1559   application.SendNotification();
1560   application.Render();
1561
1562   // Executes the idle callbacks added by the text control on the change of input style.
1563   application.RunIdles();
1564
1565   DALI_TEST_CHECK( !gInputStyleChangedCallbackCalled );
1566   DALI_TEST_CHECK( !inputStyleChangedSignal );
1567
1568   gInputStyleChangedCallbackCalled = false;
1569   gInputStyleMask = TextField::InputStyle::NONE;
1570   inputStyleChangedSignal = false;
1571
1572   application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_BACKSPACE, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
1573
1574   // Render and notify
1575   application.SendNotification();
1576   application.Render();
1577
1578   // Executes the idle callbacks added by the text control on the change of input style.
1579   application.RunIdles();
1580
1581   DALI_TEST_CHECK( gInputStyleChangedCallbackCalled );
1582   if( gInputStyleChangedCallbackCalled )
1583   {
1584     DALI_TEST_EQUALS( static_cast<unsigned int>( gInputStyleMask ),
1585                       static_cast<unsigned int>( TextField::InputStyle::COLOR ),
1586                       TEST_LOCATION );
1587
1588     const Vector4 color = field.GetProperty( TextField::Property::INPUT_COLOR ).Get<Vector4>();
1589     DALI_TEST_EQUALS( color, Color::BLACK, TEST_LOCATION );
1590   }
1591   DALI_TEST_CHECK( inputStyleChangedSignal );
1592
1593   gInputStyleChangedCallbackCalled = false;
1594   gInputStyleMask = TextField::InputStyle::NONE;
1595   inputStyleChangedSignal = false;
1596
1597   field.SetProperty( TextField::Property::INPUT_COLOR, Color::YELLOW );
1598
1599   Property::Map fontStyleMapSet;
1600   fontStyleMapSet.Insert( "weight", "thin" );
1601   fontStyleMapSet.Insert( "width", "condensed" );
1602   fontStyleMapSet.Insert( "slant", "italic" );
1603
1604   field.SetProperty( TextField::Property::INPUT_FONT_STYLE, fontStyleMapSet );
1605   field.SetProperty( TextField::Property::INPUT_POINT_SIZE, 20.f );
1606
1607   field.SetProperty( TextField::Property::INPUT_UNDERLINE, "underline" );
1608   field.SetProperty( TextField::Property::INPUT_SHADOW, "shadow" );
1609   field.SetProperty( TextField::Property::INPUT_EMBOSS, "emboss" );
1610   field.SetProperty( TextField::Property::INPUT_OUTLINE, "outline" );
1611
1612   // Render and notify
1613   application.SendNotification();
1614   application.Render();
1615
1616   // Executes the idle callbacks added by the text control on the change of input style.
1617   application.RunIdles();
1618
1619   DALI_TEST_CHECK( !gInputStyleChangedCallbackCalled );
1620   DALI_TEST_CHECK( !inputStyleChangedSignal );
1621
1622   // Create a tap event to touch the text field.
1623   TestGenerateTap( application, 63.0f, 25.0f, 300 );
1624
1625   // Render and notify
1626   application.SendNotification();
1627   application.Render();
1628
1629   // Executes the idle callbacks added by the text control on the change of input style.
1630   application.RunIdles();
1631
1632   DALI_TEST_CHECK( gInputStyleChangedCallbackCalled );
1633   if( gInputStyleChangedCallbackCalled )
1634   {
1635     DALI_TEST_EQUALS( static_cast<unsigned int>( gInputStyleMask ),
1636                       static_cast<unsigned int>( TextField::InputStyle::COLOR |
1637                                                  TextField::InputStyle::POINT_SIZE |
1638                                                  TextField::InputStyle::FONT_STYLE |
1639                                                  TextField::InputStyle::UNDERLINE |
1640                                                  TextField::InputStyle::SHADOW |
1641                                                  TextField::InputStyle::EMBOSS |
1642                                                  TextField::InputStyle::OUTLINE ),
1643                       TEST_LOCATION );
1644
1645     const Vector4 color = field.GetProperty( TextField::Property::INPUT_COLOR ).Get<Vector4>();
1646     DALI_TEST_EQUALS( color, Color::BLACK, TEST_LOCATION );
1647   }
1648   DALI_TEST_CHECK( inputStyleChangedSignal );
1649
1650   END_TEST;
1651 }
1652
1653 int utcDaliTextFieldEvent01(void)
1654 {
1655   ToolkitTestApplication application;
1656   tet_infoline(" utcDaliTextFieldEvent01");
1657
1658   // Creates a tap event. After creating a tap event the text field should
1659   // have the focus and add text with key events should be possible.
1660
1661   TextField field = TextField::New();
1662   DALI_TEST_CHECK( field );
1663
1664   application.GetScene().Add( field );
1665
1666   field.SetProperty( Actor::Property::SIZE, Vector2( 300.f, 50.f ) );
1667   field.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT );
1668   field.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT );
1669
1670   // Render and notify
1671   application.SendNotification();
1672   application.Render();
1673
1674   // Avoid a crash when core load gl resources.
1675   application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
1676
1677   // Render and notify
1678   application.SendNotification();
1679   application.Render();
1680
1681   // Add a key event but as the text field has not the focus it should do nothing.
1682   application.ProcessEvent( GenerateKey( "a", "", "a", KEY_A_CODE, 0, 0, Integration::KeyEvent::DOWN, "a", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
1683
1684   // Render and notify
1685   application.SendNotification();
1686   application.Render();
1687
1688   DALI_TEST_EQUALS( field.GetProperty<std::string>( TextField::Property::TEXT ), std::string(""), TEST_LOCATION );
1689
1690   // Create a tap event to touch the text field.
1691   TestGenerateTap( application, 150.0f, 25.0f );
1692
1693   // Render and notify
1694   application.SendNotification();
1695   application.Render();
1696
1697   // Pressing delete key should be fine even if there is no text in TextField.
1698   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 ) );
1699   // Render and notify
1700   application.SendNotification();
1701   application.Render();
1702
1703   // Now the text field has the focus, so it can handle the key events.
1704   application.ProcessEvent( GenerateKey( "a", "", "a", KEY_A_CODE, 0, 0, Integration::KeyEvent::DOWN, "a", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
1705   application.ProcessEvent( GenerateKey( "a", "", "a", KEY_A_CODE, 0, 0, Integration::KeyEvent::DOWN, "a", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
1706
1707   // Render and notify
1708   application.SendNotification();
1709   application.Render();
1710
1711   DALI_TEST_EQUALS( field.GetProperty<std::string>( TextField::Property::TEXT ), std::string("aa"), TEST_LOCATION );
1712
1713   // Create a second text field and send key events to it.
1714   TextField field2 = TextField::New();
1715
1716   field2.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT );
1717   field2.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT );
1718   field2.SetProperty( Actor::Property::SIZE, Vector2( 100.f, 100.f ) );
1719   field2.SetProperty( Actor::Property::POSITION, Vector2( 100.0f, 100.0f ));
1720
1721   application.GetScene().Add( field2 );
1722
1723   // Render and notify
1724   application.SendNotification();
1725   application.Render();
1726
1727   // Create a tap event on the second text field.
1728   TestGenerateTap( application, 150.0f, 125.0f );
1729
1730   // Render and notify
1731   application.SendNotification();
1732   application.Render();
1733
1734   // The second text field has the focus. It should handle the key events.
1735   application.ProcessEvent( GenerateKey( "a", "", "a", KEY_A_CODE, 0, 0, Integration::KeyEvent::DOWN, "a", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
1736   application.ProcessEvent( GenerateKey( "a", "", "a", KEY_A_CODE, 0, 0, Integration::KeyEvent::DOWN, "a", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
1737
1738   // Render and notify
1739   application.SendNotification();
1740   application.Render();
1741
1742   // Check the text has been added to the second text field.
1743   DALI_TEST_EQUALS( field2.GetProperty<std::string>( TextField::Property::TEXT ), std::string("aa"), TEST_LOCATION );
1744
1745   END_TEST;
1746 }
1747
1748 int utcDaliTextFieldEvent02(void)
1749 {
1750   ToolkitTestApplication application;
1751   tet_infoline(" utcDaliTextFieldEvent02");
1752
1753   // Checks if the right number of actors are created.
1754
1755   TextField field = TextField::New();
1756   field.SetProperty( TextField::Property::POINT_SIZE, 10.f );
1757   DALI_TEST_CHECK( field );
1758   LoadMarkerImages(application, field);
1759
1760   application.GetScene().Add( field );
1761
1762   field.SetProperty( Actor::Property::SIZE, Vector2( 300.f, 50.f ) );
1763   field.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT );
1764   field.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT );
1765
1766   // Avoid a crash when core load gl resources.
1767   application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
1768
1769   // Render and notify
1770   application.SendNotification();
1771   application.Render();
1772
1773   // Check there are the expected number of children ( stencil ).
1774   DALI_TEST_EQUALS( field.GetChildCount(), 1u, TEST_LOCATION );
1775
1776   Actor stencil = field.GetChildAt( 0u );
1777   DALI_TEST_EQUALS( stencil.GetChildCount(), 0u, TEST_LOCATION );
1778
1779   // Create a tap event to touch the text field.
1780   TestGenerateTap( application, 150.0f, 25.0f, 300 );
1781
1782   // Render and notify
1783   application.SendNotification();
1784   application.Render();
1785
1786   Actor layer = field.GetChildAt( 1u );
1787   DALI_TEST_EQUALS( layer.GetChildCount(), 1u, TEST_LOCATION ); // The cursor.
1788   DALI_TEST_EQUALS( stencil.GetChildCount(), 0u, TEST_LOCATION );
1789
1790   // Now the text field has the focus, so it can handle the key events.
1791   application.ProcessEvent( GenerateKey( "a", "", "a", KEY_A_CODE, 0, 0, Integration::KeyEvent::DOWN, "a", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
1792   application.ProcessEvent( GenerateKey( "a", "", "a", KEY_A_CODE, 0, 0, Integration::KeyEvent::DOWN, "a", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
1793
1794   // Render and notify
1795   application.SendNotification();
1796   application.Render();
1797
1798   // Checks the cursor and the renderer have been created.
1799   DALI_TEST_EQUALS( layer.GetChildCount(), 1u, TEST_LOCATION ); // The cursor.
1800   DALI_TEST_EQUALS( stencil.GetChildCount(), 1u, TEST_LOCATION ); // The renderer
1801
1802   Control cursor = Control::DownCast( layer.GetChildAt( 0u ) );
1803   DALI_TEST_CHECK( cursor );
1804
1805   // The offscreen root actor has a container with all the actors which contain the text renderers.
1806   Actor container = stencil.GetChildAt( 0u );
1807   for( unsigned int index = 0; index < container.GetChildCount(); ++index )
1808   {
1809     Renderer renderer = container.GetChildAt( index ).GetRendererAt( 0u );
1810     DALI_TEST_CHECK( renderer );
1811   }
1812
1813   // Move the cursor and check the position changes.
1814   Vector3 position1 = cursor.GetCurrentProperty< Vector3 >( Actor::Property::POSITION );
1815   application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_LEFT, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
1816
1817   // Render and notify
1818   application.SendNotification();
1819   application.Render();
1820
1821   Vector3 position2 = cursor.GetCurrentProperty< Vector3 >( Actor::Property::POSITION );
1822   DALI_TEST_CHECK( position2.x < position1.x );
1823
1824   application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_RIGHT, 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 position3 = cursor.GetCurrentProperty< Vector3 >( Actor::Property::POSITION );
1831   DALI_TEST_EQUALS( position1, position3, TEST_LOCATION ); // Should be in the same position1.
1832
1833
1834   // Move the cursor to the first position.
1835   application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_LEFT, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
1836   application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_LEFT, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
1837
1838   // Render and notify
1839   application.SendNotification();
1840   application.Render();
1841
1842   Vector3 position4 = cursor.GetCurrentProperty< Vector3 >( Actor::Property::POSITION );
1843
1844   // Send some taps and check the cursor positions.
1845
1846   // Try to tap at the beginning.
1847   TestGenerateTap( application, 1.0f, 25.0f, 900 );
1848
1849   // Render and notify
1850   application.SendNotification();
1851   application.Render();
1852
1853   // Cursor position should be the same than position1.
1854   Vector3 position5 = cursor.GetCurrentProperty< Vector3 >( Actor::Property::POSITION );
1855
1856   DALI_TEST_EQUALS( position4, position5, TEST_LOCATION ); // Should be in the same position2.
1857
1858   // Tap away from the start position.
1859   TestGenerateTap( application, 16.0f, 25.0f, 1500 );
1860
1861   // Render and notify
1862   application.SendNotification();
1863   application.Render();
1864
1865   Vector3 position6 = cursor.GetCurrentProperty< Vector3 >( Actor::Property::POSITION );
1866
1867   DALI_TEST_CHECK( position6.x > position5.x );
1868
1869   // Remove all the text.
1870   application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_BACKSPACE, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
1871   application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_BACKSPACE, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
1872   field.SetProperty( TextField::Property::TEXT, "" );
1873
1874   // Render and notify
1875   application.SendNotification();
1876   application.Render();
1877
1878   // Cursor position should be the same than position2.
1879   Vector3 position7 = cursor.GetCurrentProperty< Vector3 >( Actor::Property::POSITION );
1880
1881   DALI_TEST_EQUALS( position4, position7, TEST_LOCATION );// Should be in the same position2.
1882
1883   // Should not be a renderer.
1884   DALI_TEST_EQUALS( stencil.GetChildCount(), 0u, TEST_LOCATION );
1885
1886   // Chanege exceed policy (EXCEED_POLICY_ORIGINAL doesn't use stencil )
1887   field.SetProperty( TextField::Property::TEXT, "This is a long text for the size of the text-field." );
1888   field.SetProperty( TextField::Property::EXCEED_POLICY, Dali::Toolkit::TextField::EXCEED_POLICY_ORIGINAL );
1889
1890   application.SendNotification();
1891   application.Render();
1892
1893   // There are renderer and decorator layer
1894   DALI_TEST_EQUALS( field.GetChildCount(), 2u, TEST_LOCATION );
1895
1896   END_TEST;
1897 }
1898
1899 int utcDaliTextFieldEvent03(void)
1900 {
1901   ToolkitTestApplication application;
1902   tet_infoline(" utcDaliTextFieldEvent03");
1903
1904   // Checks if the highlight actor is created.
1905
1906   TextField field = TextField::New();
1907   DALI_TEST_CHECK( field );
1908
1909   application.GetScene().Add( field );
1910
1911   field.SetProperty( TextField::Property::TEXT, "This is a long text for the size of the text-field." );
1912   field.SetProperty( TextField::Property::POINT_SIZE, 10.f );
1913   field.SetProperty( Actor::Property::SIZE, Vector2( 30.f, 50.f ) );
1914   field.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT );
1915   field.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT );
1916
1917   // Avoid a crash when core load gl resources.
1918   application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
1919   LoadMarkerImages(application, field);
1920
1921   // Render and notify
1922   application.SendNotification();
1923   application.Render();
1924
1925   // Tap first to get the focus.
1926   TestGenerateTap( application, 3.0f, 25.0f );
1927
1928   // Render and notify
1929   application.SendNotification();
1930   application.Render();
1931
1932   // Double tap to select a word.
1933   TestGenerateTap( application, 3.0f, 25.0f );
1934
1935   // Render and notify
1936   application.SendNotification();
1937   application.Render();
1938
1939   // The offscreen root actor should have two actors: the renderer and the highlight actor.
1940   Actor stencil = field.GetChildAt( 0u );
1941
1942   // The highlight actor is drawn first, so is the first actor in the list
1943   Renderer highlight = stencil.GetChildAt( 0u ).GetRendererAt( 0u );
1944   DALI_TEST_CHECK( highlight );
1945
1946   // The offscreen root actor has a container with all the actors which contain the text renderers.
1947   Actor container = stencil.GetChildAt( 1u );
1948   for( unsigned int index = 0; index < container.GetChildCount(); ++index )
1949   {
1950     Renderer renderer = container.GetChildAt( index ).GetRendererAt( 0u );
1951     DALI_TEST_CHECK( renderer );
1952   }
1953
1954   END_TEST;
1955 }
1956
1957 int utcDaliTextFieldEvent04(void)
1958 {
1959   ToolkitTestApplication application;
1960   tet_infoline(" utcDaliTextFieldEvent04");
1961
1962   // Checks if the highlight actor is created.
1963
1964   TextField field = TextField::New();
1965   DALI_TEST_CHECK( field );
1966   application.GetScene().Add( field );
1967   LoadMarkerImages(application, field);
1968   // Render and notify
1969   application.SendNotification();
1970   application.Render();
1971
1972   field.SetProperty( TextField::Property::TEXT, "This is a long text for the size of the text-field." );
1973   field.SetProperty( TextField::Property::POINT_SIZE, 10.f );
1974   field.SetProperty( Actor::Property::SIZE, Vector2( 300.f, 50.f ) );
1975   field.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT );
1976   field.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT );
1977
1978   // Avoid a crash when core load gl resources.
1979   application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
1980   // Render and notify
1981   application.SendNotification();
1982   application.Render();
1983
1984   // Create a tap event to touch the text field.
1985   TestGenerateTap( application, 150.0f, 25.0f );
1986   // Render and notify
1987   application.SendNotification();
1988   application.Render();
1989
1990
1991   // Tap first to get the focus.
1992   TestGenerateTap( application, 1.0f, 25.0f );
1993
1994   // Render and notify
1995   application.SendNotification();
1996   application.Render();
1997
1998   // Double tap to select a word.
1999   TestGenerateTap( application, 1.0f, 25.0f );
2000
2001   // Render and notify
2002   application.SendNotification();
2003   application.Render();
2004
2005   // Tap grab handle
2006   TestGenerateTap( application, 0.0f, 40.0f );
2007   END_TEST;
2008 }
2009
2010 int utcDaliTextFieldEvent05(void)
2011 {
2012   ToolkitTestApplication application;
2013   tet_infoline(" utcDaliTextFieldEvent05");
2014
2015   // Checks dragging of cursor/grab handle
2016
2017   TextField field = TextField::New();
2018   DALI_TEST_CHECK( field );
2019   application.GetScene().Add( field );
2020   LoadMarkerImages(application, field);
2021   // Render and notify
2022   application.SendNotification();
2023   application.Render();
2024
2025   field.SetProperty( TextField::Property::TEXT, "This is a long text for the size of the text-field." );
2026   field.SetProperty( TextField::Property::POINT_SIZE, 10.f );
2027   field.SetProperty( Actor::Property::SIZE, Vector2( 300.f, 50.f ) );
2028   field.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT );
2029   field.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT );
2030
2031   // Avoid a crash when core load gl resources.
2032   application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
2033   // Render and notify
2034   application.SendNotification();
2035   application.Render();
2036
2037   // Create a tap event to touch the text field.
2038   TestGenerateTap( application, 150.0f, 25.0f );
2039   // Render and notify
2040   application.SendNotification();
2041   application.Render();
2042
2043   // Tap first to get the focus.
2044   TestGenerateTap( application, 1.0f, 25.0f );
2045
2046   // Render and notify
2047   application.SendNotification();
2048   application.Render();
2049
2050   // Double tap to select a word.
2051   TestGenerateTap( application, 1.0f, 25.0f );
2052
2053   // Render and notify
2054   application.SendNotification();
2055   application.Render();
2056
2057   Actor stencil = field.GetChildAt( 1u );
2058   END_TEST;
2059 }
2060
2061 int utcDaliTextFieldEvent06(void)
2062 {
2063   ToolkitTestApplication application;
2064   tet_infoline(" utcDaliTextFieldEvent06");
2065
2066   // Checks Longpress when in edit mode
2067
2068   TextField field = TextField::New();
2069   DALI_TEST_CHECK( field );
2070   application.GetScene().Add( field );
2071   LoadMarkerImages(application, field);
2072   // Render and notify
2073   application.SendNotification();
2074   application.Render();
2075
2076   field.SetProperty( TextField::Property::TEXT, "Thisisalongtextforthesizeofthetextfield." );
2077   field.SetProperty( TextField::Property::POINT_SIZE, 10.f );
2078   field.SetProperty( Actor::Property::SIZE, Vector2( 300.f, 50.f ) );
2079   field.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT );
2080   field.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT );
2081
2082   // Avoid a crash when core load gl resources.
2083   application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
2084   // Render and notify
2085   application.SendNotification();
2086   application.Render();
2087
2088   // Create a tap event to touch the text field.
2089   TestGenerateTap( application, 150.0f, 25.0f );
2090   // Render and notify
2091   application.SendNotification();
2092   application.Render();
2093
2094
2095   // Tap first to get the focus.
2096   TestGenerateTap( application, 1.0f, 25.0f );
2097
2098   // Render and notify
2099   application.SendNotification();
2100   application.Render();
2101
2102   // Long Press
2103   TestGenerateLongPress(application, 1.0f, 25.0f);
2104
2105   // Render and notify
2106   application.SendNotification();
2107   application.Render();
2108
2109   END_TEST;
2110 }
2111
2112 int utcDaliTextFieldEvent07(void)
2113 {
2114   ToolkitTestApplication application;
2115   tet_infoline(" utcDaliTextFieldEvent07");
2116
2117   // Checks Longpress to start edit mode
2118
2119   TextField field = TextField::New();
2120   DALI_TEST_CHECK( field );
2121   application.GetScene().Add( field );
2122   LoadMarkerImages(application, field);
2123   // Render and notify
2124   application.SendNotification();
2125   application.Render();
2126
2127   field.SetProperty( TextField::Property::TEXT, "Thisisalongtextforthesizeofthetextfield." );
2128   field.SetProperty( TextField::Property::POINT_SIZE, 10.f );
2129   field.SetProperty( Actor::Property::SIZE, Vector2( 300.f, 50.f ) );
2130   field.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT );
2131   field.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT );
2132   Property::Map propertyMap;
2133   propertyMap["PANEL_LAYOUT"] = InputMethod::PanelLayout::PASSWORD;
2134   field.SetProperty( TextField::Property::INPUT_METHOD_SETTINGS, propertyMap );
2135
2136   // Avoid a crash when core load gl resources.
2137   application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
2138   // Render and notify
2139   application.SendNotification();
2140   application.Render();
2141
2142   // Long Press
2143   TestGenerateLongPress(application, 1.0f, 25.0f);
2144
2145   // Render and notify
2146   application.SendNotification();
2147   application.Render();
2148
2149   END_TEST;
2150 }
2151
2152 int utcDaliTextFieldEvent08(void)
2153 {
2154   ToolkitTestApplication application;
2155   tet_infoline(" utcDaliTextFieldEvent08");
2156
2157   Dali::Clipboard clipboard = Clipboard::Get();
2158   clipboard.SetItem("testTextFieldEvent");
2159
2160   // Checks Longpress when only place holder text
2161
2162   TextField field = TextField::New();
2163   DALI_TEST_CHECK( field );
2164   application.GetScene().Add( field );
2165   LoadMarkerImages(application, field);
2166   // Render and notify
2167   application.SendNotification();
2168   application.Render();
2169
2170   field.SetProperty( TextField::Property::PLACEHOLDER_TEXT, "Setting Placeholder Text" );
2171   field.SetProperty( TextField::Property::POINT_SIZE, 10.f );
2172   field.SetProperty( Actor::Property::SIZE, Vector2( 300.f, 50.f ) );
2173   field.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT );
2174   field.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT );
2175
2176   // Avoid a crash when core load gl resources.
2177   application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
2178   // Render and notify
2179   application.SendNotification();
2180   application.Render();
2181
2182   // Long Press
2183   TestGenerateLongPress( application, 1.0f, 25.0f, 20 );
2184
2185   // Render and notify
2186   application.SendNotification();
2187   application.Render();
2188
2189   Wait(application, 500);
2190
2191   TestEndLongPress( application, 1.0f, 25.0f, 520 );
2192
2193   // Long Press
2194   TestGenerateLongPress( application, 1.0f, 25.0f, 600 );
2195
2196   // Render and notify
2197   application.Render();
2198
2199   Wait(application, 500);
2200
2201   Integration::Scene stage = application.GetScene();
2202   Layer layer = stage.GetRootLayer();
2203   Actor actor = layer.FindChildByName("optionPaste");
2204
2205   if (actor)
2206   {
2207     Vector3 worldPosition = actor.GetCurrentProperty< Vector3 >( Actor::Property::WORLD_POSITION );
2208     Vector2 halfStageSize = stage.GetSize() / 2.0f;
2209     Vector2 position(worldPosition.x + halfStageSize.width, worldPosition.y + halfStageSize.height);
2210
2211     Dali::Integration::TouchEvent event;
2212     event = Dali::Integration::TouchEvent();
2213     event.AddPoint( GetPointDownInside( position ) );
2214     application.ProcessEvent( event );
2215
2216     event = Dali::Integration::TouchEvent();
2217     event.AddPoint( GetPointUpInside( position ) );
2218     application.ProcessEvent( event );
2219   }
2220   DALI_TEST_EQUALS( field.GetProperty<std::string>( TextEditor::Property::TEXT ), std::string("testTextFieldEvent"), TEST_LOCATION );
2221
2222   END_TEST;
2223 }
2224
2225 int utcDaliTextFieldEvent09(void)
2226 {
2227   ToolkitTestApplication application;
2228   tet_infoline(" utcDaliTextFieldEvent09");
2229
2230   TextField field = TextField::New();
2231   DALI_TEST_CHECK( field );
2232   application.GetScene().Add( field );
2233   LoadMarkerImages(application, field);
2234   // Render and notify
2235   application.SendNotification();
2236   application.Render();
2237
2238   field.SetProperty( TextField::Property::TEXT, "Hello" );
2239   field.SetProperty( TextField::Property::POINT_SIZE, 10.f );
2240   field.SetProperty( Actor::Property::SIZE, Vector2( 300.f, 50.f ) );
2241   field.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT );
2242   field.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT );
2243
2244   // Avoid a crash when core load gl resources.
2245   application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
2246
2247   // Create a tap event to touch the text field.
2248   TestGenerateTap( application, 150.0f, 25.0f );
2249   application.SendNotification();
2250   application.Render();
2251
2252   Property::Map map;
2253   map[ HiddenInput::Property::MODE ] = HiddenInput::Mode::HIDE_NONE;
2254   field.SetProperty( TextField::Property::HIDDEN_INPUT_SETTINGS, map );
2255   application.ProcessEvent( GenerateKey( "d", "", "d", 0, 0, 0, Integration::KeyEvent::DOWN, "d", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2256   application.SendNotification();
2257   application.Render();
2258
2259   map[ HiddenInput::Property::MODE ] = HiddenInput::Mode::HIDE_ALL;
2260   map[ HiddenInput::Property::SUBSTITUTE_CHARACTER ] = 0x23;
2261   field.SetProperty( TextField::Property::HIDDEN_INPUT_SETTINGS, map );
2262   application.ProcessEvent( GenerateKey( "d", "", "d", 0, 0, 0, Integration::KeyEvent::DOWN, "d", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2263   application.SendNotification();
2264   application.Render();
2265
2266   map[ HiddenInput::Property::MODE ] = HiddenInput::Mode::HIDE_COUNT;
2267   map[ HiddenInput::Property::SUBSTITUTE_COUNT ] = 2;
2268   field.SetProperty( TextField::Property::HIDDEN_INPUT_SETTINGS, map );
2269   for( unsigned int index = 0u; index < 5u; ++index )
2270   {
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
2276   map[ HiddenInput::Property::MODE ] = HiddenInput::Mode::SHOW_COUNT;
2277   map[ HiddenInput::Property::SUBSTITUTE_COUNT ] = 2;
2278   field.SetProperty( TextField::Property::HIDDEN_INPUT_SETTINGS, map );
2279   for( unsigned int index = 0u; index < 5u; ++index )
2280   {
2281     application.ProcessEvent( GenerateKey( "d", "", "d", 0, 0, 0, Integration::KeyEvent::DOWN, "d", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2282     application.SendNotification();
2283     application.Render();
2284   }
2285
2286   map[ HiddenInput::Property::MODE ] = HiddenInput::Mode::SHOW_LAST_CHARACTER;
2287   map[ HiddenInput::Property::SHOW_LAST_CHARACTER_DURATION ] = 0;
2288   field.SetProperty( TextField::Property::HIDDEN_INPUT_SETTINGS, map );
2289   application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_BACKSPACE, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2290   application.SendNotification();
2291   application.Render();
2292   application.ProcessEvent( GenerateKey( "d", "", "d", 0, 0, 0, Integration::KeyEvent::DOWN, "d", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2293   application.SendNotification();
2294   application.Render();
2295
2296   map[ HiddenInput::Property::SHOW_LAST_CHARACTER_DURATION ] = 100;
2297   field.SetProperty( TextField::Property::HIDDEN_INPUT_SETTINGS, map );
2298   application.ProcessEvent( GenerateKey( "d", "", "d", 0, 0, 0, Integration::KeyEvent::DOWN, "d", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2299   application.SendNotification();
2300   application.Render();
2301
2302   Property::Map mapGet;
2303   mapGet = field.GetProperty<Property::Map>( TextField::Property::HIDDEN_INPUT_SETTINGS );
2304   DALI_TEST_EQUALS( map.Count(), mapGet.Count(), TEST_LOCATION );
2305   DALI_TEST_EQUALS( DaliTestCheckMaps( map, mapGet ), true, TEST_LOCATION );
2306   END_TEST;
2307 }
2308
2309
2310 int utcDaliTextFieldStyleWhilstSelected(void)
2311 {
2312   ToolkitTestApplication application;
2313   tet_infoline(" utcDaliTextFieldStyleWhilstSelected");
2314
2315   // Change font and styles whilst text is selected whilst word selected
2316
2317   TextField field = TextField::New();
2318   DALI_TEST_CHECK( field );
2319   application.GetScene().Add( field );
2320   LoadMarkerImages(application, field);
2321   // Render and notify
2322   application.SendNotification();
2323   application.Render();
2324
2325   field.SetProperty( TextField::Property::TEXT, "This is a long text for the size of the text-field." );
2326   field.SetProperty( TextField::Property::POINT_SIZE, 10.f );
2327   field.SetProperty( Actor::Property::SIZE, Vector2( 300.f, 50.f ) );
2328   field.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT );
2329   field.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT );
2330
2331   // Avoid a crash when core load gl resources.
2332   application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
2333   // Render and notify
2334   application.SendNotification();
2335   application.Render();
2336
2337   // Create a tap event to touch the text field.
2338   TestGenerateTap( application, 150.0f, 25.0f );
2339   // Render and notify
2340   application.SendNotification();
2341   application.Render();
2342
2343
2344   // Tap first to get the focus.
2345   TestGenerateTap( application, 1.0f, 25.0f );
2346
2347   // Render and notify
2348   application.SendNotification();
2349   application.Render();
2350
2351   // Double tap to select a word.
2352   TestGenerateTap( application, 1.0f, 25.0f );
2353
2354   // Render and notify
2355   application.SendNotification();
2356   application.Render();
2357
2358   field.SetProperty( TextField::Property::INPUT_FONT_FAMILY, "Setting input font family" );
2359   DALI_TEST_EQUALS( field.GetProperty<std::string>( TextField::Property::INPUT_FONT_FAMILY ), "Setting input font family", TEST_LOCATION );
2360
2361   Property::Map fontStyleMapSet;
2362   Property::Map fontStyleMapGet;
2363
2364   fontStyleMapSet.Insert( "weight", "bold" );
2365   fontStyleMapSet.Insert( "slant", "italic" );
2366   field.SetProperty( TextField::Property::INPUT_FONT_STYLE, fontStyleMapSet );
2367
2368   fontStyleMapGet = field.GetProperty<Property::Map>( TextField::Property::INPUT_FONT_STYLE );
2369   DALI_TEST_EQUALS( fontStyleMapGet.Count(), fontStyleMapSet.Count(), TEST_LOCATION );
2370   DALI_TEST_EQUALS( DaliTestCheckMaps( fontStyleMapGet, fontStyleMapSet ), true, TEST_LOCATION );
2371
2372   fontStyleMapSet.Clear();
2373   fontStyleMapSet.Insert( "width", "expanded" );
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   field.SetProperty( TextField::Property::INPUT_POINT_SIZE, 12.f );
2382   DALI_TEST_EQUALS( field.GetProperty<float>( TextField::Property::INPUT_POINT_SIZE ), 12.f, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
2383
2384   field.SetProperty( TextField::Property::TEXT_COLOR, Color::RED );
2385   DALI_TEST_EQUALS( field.GetProperty<Vector4>( TextField::Property::TEXT_COLOR ), Color::RED, TEST_LOCATION );
2386
2387   fontStyleMapSet.Clear();
2388   fontStyleMapSet.Insert( "weight", "bold" );
2389   fontStyleMapSet.Insert( "slant", "italic" );
2390
2391   field.SetProperty( TextField::Property::FONT_STYLE, fontStyleMapSet );
2392
2393   fontStyleMapGet = field.GetProperty<Property::Map>( TextField::Property::FONT_STYLE );
2394   DALI_TEST_EQUALS( fontStyleMapGet.Count(), fontStyleMapSet.Count(), TEST_LOCATION );
2395   DALI_TEST_EQUALS( DaliTestCheckMaps( fontStyleMapGet, fontStyleMapSet ), true, TEST_LOCATION );
2396
2397   fontStyleMapSet.Clear();
2398   fontStyleMapSet.Insert( "width", "expanded" );
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   // Press Escape to increase coverage
2407   application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_ESCAPE, 0, 0, Integration::KeyEvent::UP, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2408   application.SendNotification();
2409   application.Render();
2410
2411   DALI_TEST_CHECK( !field.HasKeyInputFocus() );
2412
2413   END_TEST;
2414 }
2415
2416 int utcDaliTextFieldEscKeyLoseFocus(void)
2417 {
2418   ToolkitTestApplication application;
2419   tet_infoline(" utcDaliTextFieldEscKeyLoseFocus");
2420
2421   // Creates a tap event. After creating a tap event the text field should
2422   // have the focus and add text with key events should be possible.
2423
2424   TextField field = TextField::New();
2425   DALI_TEST_CHECK( field );
2426
2427   application.GetScene().Add( field );
2428
2429   field.SetProperty( Actor::Property::SIZE, Vector2( 300.f, 50.f ) );
2430   field.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT );
2431   field.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT );
2432
2433   // Avoid a crash when core load gl resources.
2434   application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
2435
2436   // Render and notify
2437   application.SendNotification();
2438   application.Render();
2439
2440   // Add a key event but as the text field has not the focus it should do nothing.
2441   application.ProcessEvent( GenerateKey( "a", "", "a", KEY_A_CODE, 0, 0, Integration::KeyEvent::DOWN, "a", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2442   application.ProcessEvent( GenerateKey( "a", "", "a", KEY_A_CODE, 0, 0, Integration::KeyEvent::UP, "a", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2443
2444   // Render and notify
2445   application.SendNotification();
2446   application.Render();
2447
2448   DALI_TEST_EQUALS( field.GetProperty<std::string>( TextField::Property::TEXT ), std::string(""), TEST_LOCATION );
2449
2450   // Create a tap event to touch the text field.
2451   TestGenerateTap( application, 150.0f, 25.0f );
2452
2453   // Render and notify
2454   application.SendNotification();
2455   application.Render();
2456
2457   // Now the text field has the focus, so it can handle the key events.
2458   application.ProcessEvent( GenerateKey( "a", "", "a", KEY_A_CODE, 0, 0, Integration::KeyEvent::DOWN, "a", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2459   application.ProcessEvent( GenerateKey( "a", "", "a", KEY_A_CODE, 0, 0, Integration::KeyEvent::UP, "a", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2460   application.ProcessEvent( GenerateKey( "d", "", "d", KEY_D_CODE, 0, 0, Integration::KeyEvent::DOWN, "d", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2461   application.ProcessEvent( GenerateKey( "d", "", "d", KEY_D_CODE, 0, 0, Integration::KeyEvent::UP, "d", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2462
2463   // Render and notify
2464   application.SendNotification();
2465   application.Render();
2466
2467   DALI_TEST_EQUALS( field.GetProperty<std::string>( TextField::Property::TEXT ), std::string("ad"), TEST_LOCATION );
2468
2469   // Generate a Esc key event. The text field should lose the focus.
2470   application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_ESCAPE, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2471   application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_ESCAPE, 0, 0, Integration::KeyEvent::UP, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2472
2473   // Render and notify
2474   application.SendNotification();
2475   application.Render();
2476
2477   DALI_TEST_EQUALS( false, field.HasKeyInputFocus(), TEST_LOCATION );
2478
2479   // No more text should be introduced
2480   application.ProcessEvent( GenerateKey( "a", "", "a", KEY_A_CODE, 0, 0, Integration::KeyEvent::DOWN, "a", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2481   application.ProcessEvent( GenerateKey( "a", "", "a", KEY_A_CODE, 0, 0, Integration::KeyEvent::UP, "a", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2482
2483   // Render and notify
2484   application.SendNotification();
2485   application.Render();
2486
2487   DALI_TEST_EQUALS( field.GetProperty<std::string>( TextField::Property::TEXT ), std::string("ad"), TEST_LOCATION );
2488
2489   END_TEST;
2490 }
2491
2492 int utcDaliTextFieldSomeSpecialKeys(void)
2493 {
2494   ToolkitTestApplication application;
2495   tet_infoline(" utcDaliTextFieldSomeSpecialKeys");
2496
2497   // Checks some special keys when the text is selected.
2498
2499   TextField field = TextField::New();
2500   DALI_TEST_CHECK( field );
2501   application.GetScene().Add( field );
2502   LoadMarkerImages(application, field);
2503   // Render and notify
2504   application.SendNotification();
2505   application.Render();
2506
2507   const std::string longText( "This is a long text for the size of the text-field." );
2508
2509   field.SetProperty( TextField::Property::TEXT, longText );
2510   field.SetProperty( TextField::Property::POINT_SIZE, 10.f );
2511   field.SetProperty( Actor::Property::SIZE, Vector2( 300.f, 50.f ) );
2512   field.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT );
2513   field.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT );
2514
2515   // Avoid a crash when core load gl resources.
2516   application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
2517   // Render and notify
2518   application.SendNotification();
2519   application.Render();
2520
2521   // Create a tap event to touch the text field.
2522   TestGenerateTap( application, 150.0f, 25.0f );
2523
2524   // Render and notify
2525   application.SendNotification();
2526   application.Render();
2527
2528   // Tap first to get the focus.
2529   TestGenerateTap( application, 1.0f, 25.0f );
2530
2531   // Render and notify
2532   application.SendNotification();
2533   application.Render();
2534
2535   // Double tap to select a word.
2536   TestGenerateTap( application, 1.0f, 25.0f );
2537
2538   // Render and notify
2539   application.SendNotification();
2540   application.Render();
2541
2542   // Generate a Esc key event. The text field should lose the focus.
2543   application.ProcessEvent( GenerateKey( "XF86PowerOff", "", "XF86PowerOff", DALI_KEY_POWER, 0, 0, Integration::KeyEvent::DOWN, "XF86PowerOff", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2544   application.ProcessEvent( GenerateKey( "XF86PowerOff", "", "XF86PowerOff", DALI_KEY_POWER, 0, 0, Integration::KeyEvent::UP, "XF86PowerOff", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2545
2546   // Render and notify
2547   application.SendNotification();
2548   application.Render();
2549
2550   // Generate a Esc key event. The text field should lose the focus.
2551   application.ProcessEvent( GenerateKey( "XF86Menu", "", "XF86Menu", DALI_KEY_MENU, 0, 0, Integration::KeyEvent::DOWN, "XF86Menu", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2552   application.ProcessEvent( GenerateKey( "XF86Menu", "", "XF86Menu", DALI_KEY_MENU, 0, 0, Integration::KeyEvent::UP, "XF86Menu", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2553
2554   // Render and notify
2555   application.SendNotification();
2556   application.Render();
2557
2558   // Generate a Esc key event. The text field should lose the focus.
2559   application.ProcessEvent( GenerateKey( "XF86Home", "", "XF86Home", DALI_KEY_HOME, 0, 0, Integration::KeyEvent::DOWN, "XF86Home", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2560   application.ProcessEvent( GenerateKey( "XF86Home", "", "XF86Home", DALI_KEY_HOME, 0, 0, Integration::KeyEvent::UP, "XF86Home", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2561
2562   // Render and notify
2563   application.SendNotification();
2564   application.Render();
2565
2566   // The text shouldn't be deleted.
2567   DALI_TEST_EQUALS( field.GetProperty<std::string>( TextField::Property::TEXT ), longText, TEST_LOCATION );
2568
2569   END_TEST;
2570 }
2571
2572 int utcDaliTextFieldSizeUpdate(void)
2573 {
2574   ToolkitTestApplication application;
2575   tet_infoline("utcDaliTextFieldSizeUpdate");
2576
2577   // Checks some special keys when the text is selected.
2578   TextField field = TextField::New();
2579   DALI_TEST_CHECK( field );
2580   application.GetScene().Add( field );
2581
2582   float previousHeight = 0.0f;
2583   float currentHeight = 0.0f;
2584   const float fieldWidth = 1920.0f;
2585
2586
2587   // "ㅁ" is bigger then "ኢ"
2588   field.SetProperty( Actor::Property::SIZE, Vector2( fieldWidth ,10.0f ) );
2589   field.SetResizePolicy( ResizePolicy::FIXED , Dimension::WIDTH );
2590   field.SetResizePolicy( ResizePolicy::DIMENSION_DEPENDENCY , Dimension::HEIGHT );
2591
2592   field.SetProperty( TextField::Property::TEXT, "ኢ");
2593   field.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT );
2594   field.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT );
2595
2596   field.SetProperty( Actor::Property::KEYBOARD_FOCUSABLE,true);
2597   KeyboardFocusManager::Get().SetCurrentFocusActor( field );
2598
2599   application.SendNotification();
2600   application.Render();
2601
2602   previousHeight = field.GetHeightForWidth( fieldWidth );
2603   DALI_TEST_EQUALS( previousHeight, field.GetProperty<float>( Actor::Property::SIZE_HEIGHT ) , TEST_LOCATION );
2604
2605   // Add  another script characters ( glyph height is defferent )
2606   application.ProcessEvent( GenerateKey( "ㅁ", "", "ㅁ", KEY_A_CODE, 0, 0, Integration::KeyEvent::DOWN, "ㅁ", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2607   application.ProcessEvent( GenerateKey( "ㅁ", "", "ㅁ", KEY_A_CODE, 0, 0, Integration::KeyEvent::UP, "ㅁ", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2608
2609   application.SendNotification();
2610   application.Render();
2611
2612   currentHeight = field.GetHeightForWidth( fieldWidth );
2613   DALI_TEST_EQUALS( currentHeight, field.GetProperty<float>( Actor::Property::SIZE_HEIGHT ), TEST_LOCATION );
2614   DALI_TEST_EQUALS( (previousHeight < currentHeight), true , TEST_LOCATION );
2615
2616   END_TEST;
2617 }
2618
2619 int utcDaliTextFieldExtremlyLargePointSize(void)
2620 {
2621   ToolkitTestApplication application;
2622   tet_infoline(" utcDaliTextFieldExtremlyLargePointSize");
2623
2624   TextField field = TextField::New();
2625
2626   field.SetProperty( TextField::Property::TEXT, "Text" );
2627   field.SetProperty( Actor::Property::SIZE, Vector2( 300.f, 50.f ) );
2628   field.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT );
2629   field.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT );
2630   application.GetScene().Add( field );
2631
2632   try
2633   {
2634     field.SetProperty( TextField::Property::POINT_SIZE, 160.0f );
2635     application.SendNotification();
2636     DALI_TEST_CHECK( field );
2637   }
2638   catch (...)
2639   {
2640     tet_result(TET_FAIL);
2641   }
2642   END_TEST;
2643 }
2644
2645 int UtcDaliTextFieldDefaultFontStylePropertyCoverage(void)
2646 {
2647   ToolkitTestApplication application;
2648   tet_infoline("UtcDaliTextFieldFontStylePorpertyCoverage");
2649   TextField field = TextField::New();
2650   DALI_TEST_CHECK( field );
2651   application.GetScene().Add( field );
2652
2653   Property::Map fontStyleMapGet;
2654
2655   fontStyleMapGet = field.GetProperty<Property::Map>( TextField::Property::FONT_STYLE );
2656
2657   Property::Value* weightValue = NULL;
2658   Property::Value* widthValue = NULL;
2659   Property::Value* slantValue = NULL;
2660   weightValue = fontStyleMapGet.Find( "weight" );
2661   widthValue = fontStyleMapGet.Find( "width" );
2662   slantValue = fontStyleMapGet.Find( "slant" );
2663   DALI_TEST_CHECK( !weightValue );
2664   DALI_TEST_CHECK( !widthValue );
2665   DALI_TEST_CHECK( !slantValue );
2666
2667   END_TEST;
2668 }
2669
2670 int UtcDaliTextFieldSettingPlaceholder(void)
2671 {
2672   ToolkitTestApplication application;
2673   tet_infoline("UtcDaliTextFieldSettingPlaceholder");
2674
2675   TextField field = TextField::New();
2676   DALI_TEST_CHECK( field );
2677   application.GetScene().Add( field );
2678
2679   // Check the placeholder property with pixel size
2680   Property::Map placeholderPixelSizeMapSet;
2681   Property::Map placeholderPixelSizeMapGet;
2682   Property::Map placeholderFontstyleMap;
2683   placeholderPixelSizeMapSet[ Text::PlaceHolder::Property::TEXT ] = "Setting Placeholder Text";
2684   placeholderPixelSizeMapSet[ Text::PlaceHolder::Property::TEXT_FOCUSED ] = "Setting Placeholder Text Focused";
2685   placeholderPixelSizeMapSet[ Text::PlaceHolder::Property::COLOR ] = Color::BLUE;
2686   placeholderPixelSizeMapSet[ Text::PlaceHolder::Property::FONT_FAMILY ] = "Arial";
2687   placeholderPixelSizeMapSet[ Text::PlaceHolder::Property::PIXEL_SIZE ] = 15.0f;
2688   placeholderPixelSizeMapSet[ Text::PlaceHolder::Property::ELLIPSIS ] = true;
2689
2690   placeholderFontstyleMap.Insert( "weight", "bold" );
2691   placeholderPixelSizeMapSet[ Text::PlaceHolder::Property::FONT_STYLE ] = placeholderFontstyleMap;
2692   field.SetProperty( TextField::Property::PLACEHOLDER, placeholderPixelSizeMapSet );
2693
2694   placeholderPixelSizeMapGet = field.GetProperty<Property::Map>( TextField::Property::PLACEHOLDER );
2695   DALI_TEST_EQUALS( placeholderPixelSizeMapGet.Count(), placeholderPixelSizeMapSet.Count(), TEST_LOCATION );
2696   DALI_TEST_EQUALS( DaliTestCheckMaps( placeholderPixelSizeMapGet, placeholderPixelSizeMapSet ), true, TEST_LOCATION );
2697
2698   // Check the placeholder property with point size
2699   Property::Map placeholderMapSet;
2700   Property::Map placeholderMapGet;
2701   placeholderMapSet[ Text::PlaceHolder::Property::TEXT ] = "Setting Placeholder Text";
2702   placeholderMapSet[ Text::PlaceHolder::Property::TEXT_FOCUSED ] = "Setting Placeholder Text Focused";
2703   placeholderMapSet[ Text::PlaceHolder::Property::COLOR ] = Color::RED;
2704   placeholderMapSet[ Text::PlaceHolder::Property::FONT_FAMILY ] = "Arial";
2705   placeholderMapSet[ Text::PlaceHolder::Property::POINT_SIZE ] = 12.0f;
2706   placeholderMapSet[ Text::PlaceHolder::Property::ELLIPSIS ] = false;
2707
2708   // Check the placeholder font style property
2709   placeholderFontstyleMap.Clear();
2710
2711   placeholderFontstyleMap.Insert( "weight", "bold" );
2712   placeholderFontstyleMap.Insert( "width", "condensed" );
2713   placeholderFontstyleMap.Insert( "slant", "italic" );
2714   placeholderMapSet[ Text::PlaceHolder::Property::FONT_STYLE ] = placeholderFontstyleMap;
2715   field.SetProperty( TextField::Property::PLACEHOLDER, placeholderMapSet );
2716
2717   placeholderMapGet = field.GetProperty<Property::Map>( TextField::Property::PLACEHOLDER );
2718   DALI_TEST_EQUALS( placeholderMapGet.Count(), placeholderMapSet.Count(), TEST_LOCATION );
2719   DALI_TEST_EQUALS( DaliTestCheckMaps( placeholderMapGet, placeholderMapSet ), true, TEST_LOCATION );
2720
2721   // Reset font style.
2722   placeholderFontstyleMap.Clear();
2723   placeholderFontstyleMap.Insert( "weight", "normal" );
2724   placeholderFontstyleMap.Insert( "slant", "oblique" );
2725   placeholderMapSet[ Text::PlaceHolder::Property::FONT_STYLE ] = placeholderFontstyleMap;
2726   field.SetProperty( TextField::Property::PLACEHOLDER, placeholderMapSet );
2727
2728   placeholderMapGet = field.GetProperty<Property::Map>( TextField::Property::PLACEHOLDER );
2729   DALI_TEST_EQUALS( placeholderMapGet.Count(), placeholderMapSet.Count(), TEST_LOCATION );
2730   DALI_TEST_EQUALS( DaliTestCheckMaps( placeholderMapGet, placeholderMapSet ), true, TEST_LOCATION );
2731
2732   placeholderFontstyleMap.Clear();
2733   placeholderFontstyleMap.Insert( "slant", "roman" );
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
2739   placeholderFontstyleMap.Clear();
2740   placeholderMapSet[ Text::PlaceHolder::Property::FONT_STYLE ] = placeholderFontstyleMap;
2741
2742   field.SetProperty( TextField::Property::PLACEHOLDER, placeholderMapSet );
2743   placeholderMapGet = field.GetProperty<Property::Map>( TextField::Property::PLACEHOLDER );
2744   DALI_TEST_EQUALS( placeholderMapGet.Count(), placeholderMapSet.Count(), TEST_LOCATION );
2745   DALI_TEST_EQUALS( DaliTestCheckMaps( placeholderMapGet, placeholderMapSet ), true, TEST_LOCATION );
2746
2747   END_TEST;
2748 }
2749
2750 int UtcDaliTextFieldSetPaddingProperty(void)
2751 {
2752   ToolkitTestApplication application;
2753   tet_infoline("UtcDaliTextFieldSetPaddingProperty\n");
2754
2755   TextField field = TextField::New();
2756   DALI_TEST_CHECK( field );
2757   field.SetProperty( Actor::Property::SIZE, Vector2( 300.f, 50.f ) );
2758   field.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT );
2759   field.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT );
2760   application.GetScene().Add( field );
2761
2762   application.SendNotification();
2763   application.Render();
2764
2765   Vector3 originalSize = field.GetNaturalSize();
2766
2767   field.SetProperty( Toolkit::Control::Property::PADDING, Extents( 10, 10, 10, 10 ) );
2768
2769   application.SendNotification();
2770   application.Render();
2771
2772   DALI_TEST_EQUALS( field.GetProperty<Extents>( Toolkit::Control::Property::PADDING ), Extents( 10, 10, 10, 10 ), TEST_LOCATION );
2773
2774   Vector3 paddingAddedSize = field.GetNaturalSize();
2775
2776   DALI_TEST_EQUALS( originalSize.width + 10 + 10 , paddingAddedSize.width, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
2777
2778   DALI_TEST_EQUALS( originalSize.height + 10 + 10 , paddingAddedSize.height, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
2779
2780   END_TEST;
2781 }
2782
2783 int UtcDaliTextFieldEnableShiftSelectionProperty(void)
2784 {
2785   ToolkitTestApplication application;
2786   tet_infoline("UtcDaliTextFieldEnableShiftSelectionProperty");
2787
2788   TextField field = TextField::New();
2789   DALI_TEST_CHECK( field );
2790   field.SetProperty( Actor::Property::SIZE, Vector2( 300.f, 50.f ) );
2791   field.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT );
2792   field.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT );
2793   application.GetScene().Add( field );
2794
2795   application.SendNotification();
2796   application.Render();
2797
2798   // The default value of ENABLE_SHIFT_SELECTION is 'true'.
2799   DALI_TEST_EQUALS( field.GetProperty<bool>( DevelTextField::Property::ENABLE_SHIFT_SELECTION ), true, TEST_LOCATION );
2800
2801   // Check the enable shift selection property
2802   field.SetProperty( DevelTextField::Property::ENABLE_SHIFT_SELECTION, false );
2803   DALI_TEST_EQUALS( field.GetProperty<bool>( DevelTextField::Property::ENABLE_SHIFT_SELECTION ), false, TEST_LOCATION );
2804
2805   application.SendNotification();
2806   application.Render();
2807
2808   END_TEST;
2809 }
2810
2811 int UtcDaliTextFieldEnableGrabHandleProperty(void)
2812 {
2813   ToolkitTestApplication application;
2814   tet_infoline("UtcDaliTextFieldEnableGrabHandleProperty");
2815
2816   TextField field = TextField::New();
2817   DALI_TEST_CHECK( field );
2818   field.SetProperty( Actor::Property::SIZE, Vector2( 300.f, 50.f ) );
2819   field.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT );
2820   field.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT );
2821   application.GetScene().Add( field );
2822
2823   application.SendNotification();
2824   application.Render();
2825
2826   // The default value of ENABLE_GRAB_HANDLE is 'true'.
2827   DALI_TEST_EQUALS( field.GetProperty<bool>( DevelTextField::Property::ENABLE_GRAB_HANDLE ), true, TEST_LOCATION );
2828
2829   // Check the enable grab handle property
2830   field.SetProperty( DevelTextField::Property::ENABLE_GRAB_HANDLE, false );
2831   DALI_TEST_EQUALS( field.GetProperty<bool>( DevelTextField::Property::ENABLE_GRAB_HANDLE ), false, TEST_LOCATION );
2832
2833   application.SendNotification();
2834   application.Render();
2835
2836   END_TEST;
2837 }
2838
2839 int UtcDaliTextFieldMatchSystemLanguageDirectionProperty(void)
2840 {
2841   ToolkitTestApplication application;
2842   tet_infoline("UtcDaliTextFieldMatchSystemLanguageDirectionProperty");
2843
2844   TextField field = TextField::New();
2845   DALI_TEST_CHECK( field );
2846   field.SetProperty( Actor::Property::SIZE, Vector2( 300.f, 50.f ) );
2847   field.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT );
2848   field.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT );
2849   application.GetScene().Add( field );
2850
2851   application.SendNotification();
2852   application.Render();
2853
2854   // The default value of MATCH_SYSTEM_LANGUAGE_DIRECTION is 'false'.
2855   DALI_TEST_EQUALS( field.GetProperty<bool>( DevelTextField::Property::MATCH_SYSTEM_LANGUAGE_DIRECTION ), false, TEST_LOCATION );
2856
2857   // Check the match system language direction property
2858   field.SetProperty( DevelTextField::Property::MATCH_SYSTEM_LANGUAGE_DIRECTION, true );
2859   DALI_TEST_EQUALS( field.GetProperty<bool>( DevelTextField::Property::MATCH_SYSTEM_LANGUAGE_DIRECTION ), true, TEST_LOCATION );
2860
2861   application.SendNotification();
2862   application.Render();
2863
2864   END_TEST;
2865 }
2866
2867 int utcDaliTextFieldLayoutDirectionCoverage(void)
2868 {
2869   ToolkitTestApplication application;
2870   tet_infoline(" utcDaliTextFieldLayoutDirectionCoverage");
2871
2872   // Creates a tap event. After creating a tap event the text field should
2873   // have the focus and add text with key events should be possible.
2874   TextField field = TextField::New();
2875   DALI_TEST_CHECK( field );
2876
2877   application.GetScene().Add( field );
2878
2879   field.SetProperty( Actor::Property::SIZE, Vector2( 300.f, 50.f ) );
2880   field.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT );
2881   field.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT );
2882
2883   // Avoid a crash when core load gl resources.
2884   application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
2885
2886   // Render and notify
2887   application.SendNotification();
2888   application.Render();
2889
2890   // init direction for coverage
2891   // Set horizontal alignment END
2892   field.SetProperty( TextField::Property::HORIZONTAL_ALIGNMENT, "END");
2893
2894   // Create a tap event to touch the text field.
2895   TestGenerateTap( application, 150.0f, 25.0f );
2896
2897   // Render and notify
2898   application.SendNotification();
2899   application.Render();
2900
2901   // Set MATCH_SYSTEM_LANGUAGE_DIRECTION to true to use the layout direction.
2902   field.SetProperty( DevelTextField::Property::MATCH_SYSTEM_LANGUAGE_DIRECTION, true );
2903   field.SetProperty( Actor::Property::LAYOUT_DIRECTION, LayoutDirection::RIGHT_TO_LEFT );
2904
2905   // Set horizontal alignment BEGIN
2906   field.SetProperty( TextField::Property::HORIZONTAL_ALIGNMENT, "BEGIN");
2907
2908   // Create a tap event to touch the text field.
2909   TestGenerateTap( application, 150.0f, 25.0f );
2910
2911   // Render and notify
2912   application.SendNotification();
2913   application.Render();
2914
2915   // Set horizontal alignment CENTER
2916   field.SetProperty( TextField::Property::HORIZONTAL_ALIGNMENT, "CENTER");
2917
2918   // Create a tap event to touch the text field.
2919   TestGenerateTap( application, 150.0f, 25.0f );
2920
2921   // Render and notify
2922   application.SendNotification();
2923   application.Render();
2924
2925   // Set horizontal alignment END
2926   field.SetProperty( TextField::Property::HORIZONTAL_ALIGNMENT, "END");
2927
2928   // Create a tap event to touch the text field.
2929   TestGenerateTap( application, 150.0f, 25.0f );
2930
2931   // Render and notify
2932   application.SendNotification();
2933   application.Render();
2934
2935   // Generate a Esc key event. The text field should lose the focus.
2936   application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_ESCAPE, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2937   application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_ESCAPE, 0, 0, Integration::KeyEvent::UP, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2938
2939   // Render and notify
2940   application.SendNotification();
2941   application.Render();
2942
2943   DALI_TEST_EQUALS( false, field.HasKeyInputFocus(), TEST_LOCATION );
2944
2945   END_TEST;
2946 }
2947
2948 int UtcDaliTextFieldGetInputMethodContext(void)
2949 {
2950   ToolkitTestApplication application;
2951   tet_infoline("UtcDaliTextFieldGetInputMethodContext");
2952
2953   TextField field = TextField::New();
2954   DALI_TEST_CHECK( DevelTextField::GetInputMethodContext( field ) );
2955
2956   END_TEST;
2957 }
2958
2959 int UtcDaliTextFieldSelectWholeText(void)
2960 {
2961   ToolkitTestApplication application;
2962   tet_infoline(" UtcDaliTextFieldSelectWholeText ");
2963
2964   TextField textField = TextField::New();
2965
2966   application.GetScene().Add( textField );
2967
2968   textField.SetProperty( Actor::Property::SIZE, Vector2( 300.f, 50.f ) );
2969   textField.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT );
2970   textField.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT );
2971
2972   // Avoid a crash when core load gl resources.
2973   application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
2974
2975   application.SendNotification();
2976   application.Render();
2977
2978   DALI_TEST_EQUALS( 1u, textField.GetChildCount(), TEST_LOCATION );
2979
2980   DevelTextField::SelectWholeText( textField );
2981
2982   application.SendNotification();
2983   application.Render();
2984
2985   // Nothing should have been selected. The number of children is still 1
2986   DALI_TEST_EQUALS( 1u, textField.GetChildCount(), TEST_LOCATION );
2987
2988   textField.SetProperty( TextField::Property::TEXT, "Hello world" );
2989
2990   application.SendNotification();
2991   application.Render();
2992
2993   DevelTextField::SelectWholeText( textField );
2994
2995   application.SendNotification();
2996   application.Render();
2997
2998   // Should be 2 children, the stencil and the layer
2999   DALI_TEST_EQUALS( 2u, textField.GetChildCount(), TEST_LOCATION );
3000
3001   // The offscreen root actor should have two actors: the renderer and the highlight actor.
3002   Actor stencil = textField.GetChildAt( 0u );
3003
3004   // The highlight actor is drawn first, so is the first actor in the list
3005   Renderer highlight = stencil.GetChildAt( 0u ).GetRendererAt( 0u );
3006   DALI_TEST_CHECK( highlight );
3007
3008   END_TEST;
3009 }
3010
3011 int UtcDaliTextFieldSelectNone(void)
3012 {
3013   ToolkitTestApplication application;
3014   tet_infoline(" UtcDaliTextFieldSelectWholeText ");
3015
3016   TextField textField = TextField::New();
3017
3018   application.GetScene().Add( textField );
3019
3020   textField.SetProperty( Actor::Property::SIZE, Vector2( 300.f, 50.f ) );
3021   textField.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT );
3022   textField.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT );
3023
3024   // Avoid a crash when core load gl resources.
3025   application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
3026
3027   application.SendNotification();
3028   application.Render();
3029
3030   textField.SetProperty( TextField::Property::TEXT, "Hello world" );
3031
3032   application.SendNotification();
3033   application.Render();
3034
3035   // Nothing is selected
3036   std::string selectedText = textField.GetProperty( DevelTextField::Property::SELECTED_TEXT ).Get<std::string>();
3037   DALI_TEST_EQUALS( "", selectedText, TEST_LOCATION );
3038
3039   DevelTextField::SelectWholeText( textField );
3040
3041   application.SendNotification();
3042   application.Render();
3043
3044   // whole text is selected
3045   selectedText = textField.GetProperty( DevelTextField::Property::SELECTED_TEXT ).Get<std::string>();
3046   DALI_TEST_EQUALS( "Hello world", selectedText, TEST_LOCATION );
3047
3048   DevelTextField::SelectNone( textField );
3049
3050   application.SendNotification();
3051   application.Render();
3052
3053   // Nothing is selected
3054   selectedText = textField.GetProperty( DevelTextField::Property::SELECTED_TEXT ).Get<std::string>();
3055   DALI_TEST_EQUALS( "", selectedText, TEST_LOCATION );
3056
3057   END_TEST;
3058 }
3059
3060 int UtcDaliTextFieldSelectRange(void)
3061 {
3062   ToolkitTestApplication application;
3063   tet_infoline(" UtcDaliTextFieldSelectRange ");
3064
3065   TextField textField = TextField::New();
3066
3067   application.GetScene().Add( textField );
3068
3069   textField.SetProperty( Actor::Property::SIZE, Vector2( 300.f, 50.f ) );
3070   textField.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT );
3071   textField.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT );
3072
3073   // Avoid a crash when core load gl resources.
3074   application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
3075
3076   application.SendNotification();
3077   application.Render();
3078
3079   textField.SetProperty( TextField::Property::TEXT, "Hello world" );
3080
3081   application.SendNotification();
3082   application.Render();
3083
3084   textField.SetProperty( DevelTextField::Property::SELECTED_TEXT_START , 0);
3085   textField.SetProperty( DevelTextField::Property::SELECTED_TEXT_END , 5);
3086
3087   // Hello is selected
3088   std::string selectedText = textField.GetProperty( DevelTextField::Property::SELECTED_TEXT ).Get<std::string>();
3089   DALI_TEST_EQUALS( "Hello", selectedText, TEST_LOCATION );
3090
3091   DALI_TEST_EQUALS( textField.GetProperty( DevelTextField::Property::SELECTED_TEXT_START ).Get<int>(), 0, TEST_LOCATION );
3092   DALI_TEST_EQUALS( textField.GetProperty( DevelTextField::Property::SELECTED_TEXT_END ).Get<int>(), 5, TEST_LOCATION );
3093
3094   textField.SetProperty( DevelTextField::Property::SELECTED_TEXT_START , 6);
3095   textField.SetProperty( DevelTextField::Property::SELECTED_TEXT_END , 11);
3096
3097   // world is selected
3098   selectedText = textField.GetProperty( DevelTextField::Property::SELECTED_TEXT ).Get<std::string>();
3099   DALI_TEST_EQUALS( "world", selectedText, TEST_LOCATION );
3100
3101   DALI_TEST_EQUALS( textField.GetProperty( DevelTextField::Property::SELECTED_TEXT_START ).Get<int>(), 6, TEST_LOCATION );
3102   DALI_TEST_EQUALS( textField.GetProperty( DevelTextField::Property::SELECTED_TEXT_END ).Get<int>(), 11, TEST_LOCATION );
3103
3104   END_TEST;
3105 }
3106
3107 int UtcDaliTextFieldEnableEditing(void)
3108 {
3109   ToolkitTestApplication application;
3110   tet_infoline(" UtcDaliTextFieldEnableEditing ");
3111
3112   TextField textField = TextField::New();
3113
3114   application.GetScene().Add( textField );
3115
3116   textField.SetProperty( Actor::Property::SIZE, Vector2( 300.f, 50.f ) );
3117   textField.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT );
3118   textField.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT );
3119
3120   // Avoid a crash when core load gl resources.
3121   application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
3122
3123   application.SendNotification();
3124   application.Render();
3125
3126   textField.SetKeyInputFocus();
3127   textField.SetProperty( DevelTextField::Property::ENABLE_EDITING, false );
3128   application.ProcessEvent( GenerateKey( "D", "", "D", KEY_D_CODE, 0, 0, Integration::KeyEvent::DOWN, "D", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
3129
3130   // Render and notify
3131   application.SendNotification();
3132   application.Render();
3133
3134   DALI_TEST_EQUALS( textField.GetProperty( TextField::Property::TEXT ).Get<std::string>(), "", TEST_LOCATION );
3135   DALI_TEST_EQUALS( textField.GetProperty( DevelTextField::Property::ENABLE_EDITING ).Get<bool>(), false, TEST_LOCATION );
3136
3137
3138   textField.SetKeyInputFocus();
3139   textField.SetProperty( DevelTextField::Property::ENABLE_EDITING, true );
3140   application.ProcessEvent( GenerateKey( "D", "", "D", KEY_D_CODE, 0, 0, Integration::KeyEvent::DOWN, "D", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
3141
3142   // Render and notify
3143   application.SendNotification();
3144   application.Render();
3145
3146   DALI_TEST_EQUALS( textField.GetProperty( TextField::Property::TEXT ).Get<std::string>(), "D", TEST_LOCATION );
3147   DALI_TEST_EQUALS( textField.GetProperty( DevelTextField::Property::ENABLE_EDITING ).Get<bool>(), true, TEST_LOCATION );
3148
3149   END_TEST;
3150 }
3151
3152 int UtcDaliToolkitTextFieldFontSizeScale(void)
3153 {
3154   ToolkitTestApplication application;
3155   tet_infoline(" UtcDaliToolkitTextFieldFontSizeScale");
3156
3157   TextField textField = TextField::New();
3158   textField.SetProperty( TextField::Property::POINT_SIZE, 30.f );
3159   textField.SetProperty( TextField::Property::TEXT, "Test" );
3160   Vector3 nonScaledSize = textField.GetNaturalSize();
3161
3162   TextField textFieldScaled = TextField::New();
3163   textFieldScaled.SetProperty( TextField::Property::POINT_SIZE, 15.f );
3164   textFieldScaled.SetProperty( Toolkit::DevelTextField::Property::FONT_SIZE_SCALE, 2.f );
3165   textFieldScaled.SetProperty( TextField::Property::TEXT, "Test" );
3166   Vector3 scaledSize = textFieldScaled.GetNaturalSize();
3167
3168   DALI_TEST_EQUALS( nonScaledSize, scaledSize, TEST_LOCATION );
3169
3170   textField.SetProperty( TextField::Property::PIXEL_SIZE, 30.f );
3171   textField.SetProperty( TextField::Property::TEXT, "Test" );
3172   nonScaledSize = textField.GetNaturalSize();
3173
3174   textFieldScaled.SetProperty( TextField::Property::PIXEL_SIZE, 15.f );
3175   textFieldScaled.SetProperty( Toolkit::DevelTextField::Property::FONT_SIZE_SCALE, 2.f );
3176   textFieldScaled.SetProperty( TextField::Property::TEXT, "Test" );
3177   scaledSize = textFieldScaled.GetNaturalSize();
3178
3179   DALI_TEST_EQUALS( nonScaledSize, scaledSize, TEST_LOCATION );
3180
3181   END_TEST;
3182 }
3183
3184 int UtcDaliTextFieldPrimaryCursorPosition(void)
3185 {
3186   ToolkitTestApplication application;
3187   tet_infoline(" UtcDaliTextFieldPrimaryCursorPosition ");
3188
3189   TextField textField = TextField::New();
3190
3191   application.GetScene().Add( textField );
3192
3193   textField.SetProperty( TextField::Property::TEXT, "ABCEF");
3194   textField.SetProperty( Actor::Property::SIZE, Vector2( 300.f, 50.f ) );
3195   textField.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT );
3196   textField.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT );
3197
3198   // Avoid a crash when core load gl resources.
3199   application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
3200
3201   textField.SetProperty( DevelTextField::Property::PRIMARY_CURSOR_POSITION, 3);
3202   application.SendNotification();
3203   application.Render();
3204
3205   application.ProcessEvent( GenerateKey( "D", "", "D", KEY_D_CODE, 0, 0, Integration::KeyEvent::DOWN, "D", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
3206
3207   // Render and notify
3208   application.SendNotification();
3209   application.Render();
3210
3211   DALI_TEST_EQUALS( textField.GetProperty( TextField::Property::TEXT ).Get<std::string>(), "ABCDEF", TEST_LOCATION );
3212   DALI_TEST_EQUALS( textField.GetProperty( DevelTextField::Property::PRIMARY_CURSOR_POSITION ).Get<int>(), 4, TEST_LOCATION );
3213
3214   END_TEST;
3215 }