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