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