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