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