Merge "Extending Style - Adding Strikethrough" 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 #include <dali-toolkit/devel-api/text/text-enumerations-devel.h>
34 #include "test-text-geometry-utils.h"
35
36 using namespace Dali;
37 using namespace Toolkit;
38
39 void dali_textfield_startup(void)
40 {
41   test_return_value = TET_UNDEF;
42 }
43
44 void dali_textfield_cleanup(void)
45 {
46   test_return_value = TET_PASS;
47 }
48
49 namespace
50 {
51
52 const char* const PROPERTY_NAME_RENDERING_BACKEND                    = "renderingBackend";
53 const char* const PROPERTY_NAME_TEXT                                 = "text";
54 const char* const PROPERTY_NAME_PLACEHOLDER_TEXT                     = "placeholderText";
55 const char* const PROPERTY_NAME_PLACEHOLDER_TEXT_FOCUSED             = "placeholderTextFocused";
56 const char* const PROPERTY_NAME_FONT_FAMILY                          = "fontFamily";
57 const char* const PROPERTY_NAME_FONT_STYLE                           = "fontStyle";
58 const char* const PROPERTY_NAME_POINT_SIZE                           = "pointSize";
59 const char* const PROPERTY_NAME_MAX_LENGTH                           = "maxLength";
60 const char* const PROPERTY_NAME_EXCEED_POLICY                        = "exceedPolicy";
61 const char* const PROPERTY_NAME_HORIZONTAL_ALIGNMENT                 = "horizontalAlignment";
62 const char* const PROPERTY_NAME_VERTICAL_ALIGNMENT                   = "verticalAlignment";
63 const char* const PROPERTY_NAME_TEXT_COLOR                           = "textColor";
64 const char* const PROPERTY_NAME_PLACEHOLDER_TEXT_COLOR               = "placeholderTextColor";
65 const char* const PROPERTY_NAME_PRIMARY_CURSOR_COLOR                 = "primaryCursorColor";
66 const char* const PROPERTY_NAME_SECONDARY_CURSOR_COLOR               = "secondaryCursorColor";
67 const char* const PROPERTY_NAME_ENABLE_CURSOR_BLINK                  = "enableCursorBlink";
68 const char* const PROPERTY_NAME_CURSOR_BLINK_INTERVAL                = "cursorBlinkInterval";
69 const char* const PROPERTY_NAME_CURSOR_BLINK_DURATION                = "cursorBlinkDuration";
70 const char* const PROPERTY_NAME_CURSOR_WIDTH                         = "cursorWidth";
71 const char* const PROPERTY_NAME_GRAB_HANDLE_IMAGE                    = "grabHandleImage";
72 const char* const PROPERTY_NAME_GRAB_HANDLE_PRESSED_IMAGE            = "grabHandlePressedImage";
73 const char* const PROPERTY_NAME_SCROLL_THRESHOLD                     = "scrollThreshold";
74 const char* const PROPERTY_NAME_SCROLL_SPEED                         = "scrollSpeed";
75 const char* const PROPERTY_NAME_SELECTION_HANDLE_IMAGE_LEFT          = "selectionHandleImageLeft";
76 const char* const PROPERTY_NAME_SELECTION_HANDLE_IMAGE_RIGHT         = "selectionHandleImageRight";
77 const char* const PROPERTY_NAME_SELECTION_HANDLE_PRESSED_IMAGE_LEFT  = "selectionHandlePressedImageLeft";
78 const char* const PROPERTY_NAME_SELECTION_HANDLE_PRESSED_IMAGE_RIGHT = "selectionHandlePressedImageRight";
79 const char* const PROPERTY_NAME_SELECTION_HANDLE_MARKER_IMAGE_LEFT   = "selectionHandleMarkerImageLeft";
80 const char* const PROPERTY_NAME_SELECTION_HANDLE_MARKER_IMAGE_RIGHT  = "selectionHandleMarkerImageRight";
81 const char* const PROPERTY_NAME_SELECTION_HIGHLIGHT_COLOR            = "selectionHighlightColor";
82 const char* const PROPERTY_NAME_DECORATION_BOUNDING_BOX              = "decorationBoundingBox";
83 const char* const PROPERTY_NAME_INPUT_METHOD_SETTINGS                = "inputMethodSettings";
84 const char* const PROPERTY_NAME_INPUT_COLOR                          = "inputColor";
85 const char* const PROPERTY_NAME_ENABLE_MARKUP                        = "enableMarkup";
86 const char* const PROPERTY_NAME_INPUT_FONT_FAMILY                    = "inputFontFamily";
87 const char* const PROPERTY_NAME_INPUT_FONT_STYLE                     = "inputFontStyle";
88 const char* const PROPERTY_NAME_INPUT_POINT_SIZE                     = "inputPointSize";
89
90 const char* const PROPERTY_NAME_UNDERLINE                            = "underline";
91 const char* const PROPERTY_NAME_INPUT_UNDERLINE                      = "inputUnderline";
92 const char* const PROPERTY_NAME_SHADOW                               = "shadow";
93 const char* const PROPERTY_NAME_INPUT_SHADOW                         = "inputShadow";
94 const char* const PROPERTY_NAME_EMBOSS                               = "emboss";
95 const char* const PROPERTY_NAME_INPUT_EMBOSS                         = "inputEmboss";
96 const char* const PROPERTY_NAME_OUTLINE                              = "outline";
97 const char* const PROPERTY_NAME_INPUT_OUTLINE                        = "inputOutline";
98 const char* const PROPERTY_NAME_STRIKETHROUGH                        = "strikethrough";
99 const char* const PROPERTY_NAME_INPUT_STRIKETHROUGH                  = "inputStrikethrough";
100
101 const char* const PROPERTY_NAME_HIDDEN_INPUT_SETTINGS                = "hiddenInputSettings";
102 const char* const PROPERTY_NAME_PIXEL_SIZE                           = "pixelSize";
103 const char* const PROPERTY_NAME_ENABLE_SELECTION                     = "enableSelection";
104 const char* const PROPERTY_NAME_PLACEHOLDER                          = "placeholder";
105 const char* const PROPERTY_NAME_ELLIPSIS                             = "ellipsis";
106 const char* const PROPERTY_NAME_ENABLE_SHIFT_SELECTION               = "enableShiftSelection";
107 const char* const PROPERTY_NAME_ENABLE_GRAB_HANDLE                   = "enableGrabHandle";
108 const char* const PROPERTY_NAME_MATCH_SYSTEM_LANGUAGE_DIRECTION      = "matchSystemLanguageDirection";
109 const char* const PROPERTY_NAME_ENABLE_GRAB_HANDLE_POPUP             = "enableGrabHandlePopup";
110 const char* const PROPERTY_NAME_BACKGROUND                           = "textBackground";
111 const char* const PROPERTY_NAME_FONT_SIZE_SCALE                      = "fontSizeScale";
112 const char* const PROPERTY_NAME_ENABLE_FONT_SIZE_SCALE               = "enableFontSizeScale";
113 const char* const PROPERTY_NAME_GRAB_HANDLE_COLOR                    = "grabHandleColor";
114 const char* const PROPERTY_NAME_INPUT_FILTER                         = "inputFilter";
115
116 const Vector4 PLACEHOLDER_TEXT_COLOR( 0.8f, 0.8f, 0.8f, 0.8f );
117 const Dali::Vector4 LIGHT_BLUE( 0.75f, 0.96f, 1.f, 1.f ); // The text highlight color.
118
119 const float RENDER_FRAME_INTERVAL = 16.66f;
120
121 const unsigned int DEFAULT_FONT_SIZE = 1152u;
122 const std::string DEFAULT_FONT_DIR( "/resources/fonts" );
123
124 const int KEY_RETURN_CODE = 36;
125 const int KEY_A_CODE = 38;
126 const int KEY_D_CODE = 40;
127 const int KEY_SHIFT_MODIFIER = 257;
128
129 const std::string DEFAULT_DEVICE_NAME("hwKeyboard");
130
131 static bool gSelectionChangedCallbackCalled;
132 static uint32_t oldSelectionStart;
133 static uint32_t oldSelectionEnd;
134 static bool gSelectionClearedCallbackCalled;
135 static bool gAnchorClickedCallBackCalled;
136 static bool gAnchorClickedCallBackNotCalled;
137 static bool gTextChangedCallBackCalled;
138 static bool gMaxCharactersCallBackCalled;
139 static bool gInputFilteredAcceptedCallbackCalled;
140 static bool gInputFilteredRejectedCallbackCalled;
141 static bool gInputStyleChangedCallbackCalled;
142 static bool gCursorPositionChangedCallbackCalled;
143 static uint32_t oldCursorPos;
144 static Dali::Toolkit::TextField::InputStyle::Mask gInputStyleMask;
145
146 static void LoadBitmapResource(TestPlatformAbstraction& platform, int width, int height)
147 {
148   Integration::Bitmap* bitmap = Integration::Bitmap::New( Integration::Bitmap::BITMAP_2D_PACKED_PIXELS, ResourcePolicy::OWNED_DISCARD );
149   Integration::ResourcePointer resource(bitmap);
150   bitmap->GetPackedPixelsProfile()->ReserveBuffer(Pixel::RGBA8888, width, height, width, height);
151 }
152
153 static void LoadMarkerImages(ToolkitTestApplication& app, TextField textField)
154 {
155   int width(40);
156   int height(40);
157   LoadBitmapResource( app.GetPlatform(), width, height );
158
159   Property::Map propertyMap;
160   propertyMap["filename"] = "image.png";
161   propertyMap["width"] = width;
162   propertyMap["height"] = height;
163   textField.SetProperty( Toolkit::TextField::Property::SELECTION_HANDLE_IMAGE_LEFT, propertyMap );
164   textField.SetProperty( Toolkit::TextField::Property::SELECTION_HANDLE_IMAGE_RIGHT, propertyMap );
165   textField.SetProperty( Toolkit::TextField::Property::SELECTION_HANDLE_PRESSED_IMAGE_LEFT, propertyMap );
166   textField.SetProperty( Toolkit::TextField::Property::SELECTION_HANDLE_PRESSED_IMAGE_RIGHT, propertyMap );
167   textField.SetProperty( Toolkit::TextField::Property::SELECTION_HANDLE_MARKER_IMAGE_LEFT, propertyMap );
168   textField.SetProperty( Toolkit::TextField::Property::SELECTION_HANDLE_MARKER_IMAGE_RIGHT, propertyMap );
169   textField.SetProperty( Toolkit::TextField::Property::GRAB_HANDLE_IMAGE, propertyMap );
170   textField.SetProperty( Toolkit::TextField::Property::GRAB_HANDLE_PRESSED_IMAGE, propertyMap );
171 }
172
173 /*
174  * Simulate time passed by.
175  *
176  * @note this will always process at least 1 frame (1/60 sec)
177  *
178  * @param application Test application instance
179  * @param duration Time to pass in milliseconds.
180  * @return The actual time passed in milliseconds
181  */
182 static int Wait(ToolkitTestApplication& application, int duration = 0)
183 {
184   int time = 0;
185
186   for(int i = 0; i <= ( duration / RENDER_FRAME_INTERVAL); i++)
187   {
188     application.SendNotification();
189     application.Render(RENDER_FRAME_INTERVAL);
190     time += RENDER_FRAME_INTERVAL;
191   }
192
193   return time;
194 }
195
196 Dali::Integration::Point GetPointDownInside( Vector2& pos )
197 {
198   Dali::Integration::Point point;
199   point.SetState( PointState::DOWN );
200   point.SetScreenPosition( pos );
201   return point;
202 }
203
204 Dali::Integration::Point GetPointUpInside( Vector2& pos )
205 {
206   Dali::Integration::Point point;
207   point.SetState( PointState::UP );
208   point.SetScreenPosition( pos );
209   return point;
210 }
211
212 struct CallbackFunctor
213 {
214   CallbackFunctor(bool* callbackFlag)
215   : mCallbackFlag( callbackFlag )
216   {
217   }
218
219   void operator()()
220   {
221     *mCallbackFlag = true;
222   }
223   bool* mCallbackFlag;
224 };
225
226 static void TestSelectionClearedCallback(TextField control)
227 {
228   tet_infoline(" TestSelectionClearedCallback");
229
230   gSelectionClearedCallbackCalled = true;
231 }
232
233 static void TestSelectionChangedCallback(TextField control, uint32_t oldStart, uint32_t oldEnd)
234 {
235   tet_infoline(" TestSelectionChangedCallback");
236
237   gSelectionChangedCallbackCalled = true;
238   oldSelectionStart = oldStart;
239   oldSelectionEnd   = oldEnd;
240 }
241
242 static void TestAnchorClickedCallback(TextField control, const char* href, unsigned int hrefLength)
243 {
244   tet_infoline(" TestAnchorClickedCallback");
245
246   gAnchorClickedCallBackNotCalled = false;
247
248   if (!strcmp(href, "https://www.tizen.org") && hrefLength == strlen(href))
249   {
250     gAnchorClickedCallBackCalled = true;
251   }
252 }
253
254 static void TestCursorPositionChangedCallback( TextField control, unsigned int oldPos )
255 {
256   tet_infoline(" TestCursorPositionChangedCallback");
257
258   gCursorPositionChangedCallbackCalled = true;
259   oldCursorPos = oldPos;
260 }
261
262 static void TestTextChangedCallback( TextField control )
263 {
264   tet_infoline(" TestTextChangedCallback");
265
266   gTextChangedCallBackCalled = true;
267 }
268
269 static void TestMaxLengthReachedCallback( TextField control )
270 {
271   tet_infoline(" TestMaxLengthReachedCallback");
272
273   gMaxCharactersCallBackCalled = true;
274 }
275
276 static void TestInputFilteredCallback(TextField control, Toolkit::InputFilter::Property::Type type)
277 {
278   tet_infoline(" TestInputFilteredCallback");
279
280   if(type == Toolkit::InputFilter::Property::ACCEPTED)
281   {
282     gInputFilteredAcceptedCallbackCalled = true;
283   }
284   else if(type == Toolkit::InputFilter::Property::REJECTED)
285   {
286     gInputFilteredRejectedCallbackCalled = true;
287   }
288 }
289
290 static void TestInputStyleChangedCallback( TextField control, TextField::InputStyle::Mask mask )
291 {
292   tet_infoline(" TestInputStyleChangedCallback");
293
294   gInputStyleChangedCallbackCalled = true;
295   gInputStyleMask = mask;
296 }
297
298 // Generate a KeyEvent to send to Core.
299 Integration::KeyEvent GenerateKey( const std::string& keyName,
300                                    const std::string& logicalKey,
301                                    const std::string& keyString,
302                                    int keyCode,
303                                    int keyModifier,
304                                    unsigned long timeStamp,
305                                    const Integration::KeyEvent::State& keyState,
306                                    const std::string& compose = "",
307                                    const std::string& deviceName = DEFAULT_DEVICE_NAME,
308                                    const Device::Class::Type& deviceClass = Device::Class::NONE,
309                                    const Device::Subclass::Type& deviceSubclass = Device::Subclass::NONE )
310 {
311   return Integration::KeyEvent( keyName,
312                                 logicalKey,
313                                 keyString,
314                                 keyCode,
315                                 keyModifier,
316                                 timeStamp,
317                                 keyState,
318                                 compose,
319                                 deviceName,
320                                 deviceClass,
321                                 deviceSubclass );
322 }
323
324 bool DaliTestCheckMaps( const Property::Map& fontStyleMapGet, const Property::Map& fontStyleMapSet )
325 {
326   if( fontStyleMapGet.Count() == fontStyleMapSet.Count() )
327   {
328     for( unsigned int index = 0u; index < fontStyleMapGet.Count(); ++index )
329     {
330       const KeyValuePair& valueGet = fontStyleMapGet.GetKeyValue( index );
331
332       Property::Value* valueSet = NULL;
333       if ( valueGet.first.type == Property::Key::INDEX )
334       {
335         valueSet = fontStyleMapSet.Find( valueGet.first.indexKey );
336       }
337       else
338       {
339         // Get Key is a string so searching Set Map for a string key
340         valueSet = fontStyleMapSet.Find( valueGet.first.stringKey );
341       }
342
343       if( NULL != valueSet )
344       {
345         if( valueSet->GetType() == Dali::Property::STRING && ( valueGet.second.Get<std::string>() != valueSet->Get<std::string>() ) )
346         {
347           tet_printf( "Value got : [%s], expected : [%s]", valueGet.second.Get<std::string>().c_str(), valueSet->Get<std::string>().c_str() );
348           return false;
349         }
350         else if( valueSet->GetType() == Dali::Property::BOOLEAN && ( valueGet.second.Get<bool>() != valueSet->Get<bool>() ) )
351         {
352           tet_printf( "Value got : [%d], expected : [%d]", valueGet.second.Get<bool>(), valueSet->Get<bool>() );
353           return false;
354         }
355         else if( valueSet->GetType() == Dali::Property::INTEGER && ( valueGet.second.Get<int>() != valueSet->Get<int>() ) )
356         {
357           tet_printf( "Value got : [%d], expected : [%d]", valueGet.second.Get<int>(), valueSet->Get<int>() );
358           return false;
359         }
360         else if( valueSet->GetType() == Dali::Property::FLOAT && ( valueGet.second.Get<float>() != valueSet->Get<float>() ) )
361         {
362           tet_printf( "Value got : [%f], expected : [%f]", valueGet.second.Get<float>(), valueSet->Get<float>() );
363           return false;
364         }
365         else if( valueSet->GetType() == Dali::Property::VECTOR2 && ( valueGet.second.Get<Vector2>() != valueSet->Get<Vector2>() ) )
366         {
367           Vector2 vector2Get = valueGet.second.Get<Vector2>();
368           Vector2 vector2Set = valueSet->Get<Vector2>();
369           tet_printf( "Value got : [%f, %f], expected : [%f, %f]", vector2Get.x, vector2Get.y, vector2Set.x, vector2Set.y );
370           return false;
371         }
372         else if( valueSet->GetType() == Dali::Property::VECTOR4 && ( valueGet.second.Get<Vector4>() != valueSet->Get<Vector4>() ) )
373         {
374           Vector4 vector4Get = valueGet.second.Get<Vector4>();
375           Vector4 vector4Set = valueSet->Get<Vector4>();
376           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 );
377           return false;
378         }
379       }
380       else
381       {
382         if ( valueGet.first.type == Property::Key::INDEX )
383         {
384           tet_printf( "  The key %d doesn't exist.", valueGet.first.indexKey );
385         }
386         else
387         {
388           tet_printf( "  The key %s doesn't exist.", valueGet.first.stringKey.c_str() );
389         }
390         return false;
391       }
392     }
393   }
394
395   return true;
396 }
397
398 } // namespace
399
400 int UtcDaliToolkitTextFieldConstructorP(void)
401 {
402   ToolkitTestApplication application;
403   tet_infoline(" UtcDaliToolkitTextFieldConstructorP");
404   TextField textField;
405   DALI_TEST_CHECK( !textField );
406   END_TEST;
407 }
408
409 int UtcDaliToolkitTextFieldNewP(void)
410 {
411   ToolkitTestApplication application;
412   tet_infoline(" UtcDaliToolkitTextFieldNewP");
413   TextField textField = TextField::New();
414   DALI_TEST_CHECK( textField );
415   END_TEST;
416 }
417
418 int UtcDaliToolkitTextFieldDownCastP(void)
419 {
420   ToolkitTestApplication application;
421   tet_infoline(" UtcDaliToolkitTextFieldDownCastP");
422   TextField textField1 = TextField::New();
423   BaseHandle object( textField1 );
424
425   TextField textField2 = TextField::DownCast( object );
426   DALI_TEST_CHECK( textField2 );
427
428   TextField textField3 = DownCast< TextField >( object );
429   DALI_TEST_CHECK( textField3 );
430   END_TEST;
431 }
432
433 int UtcDaliToolkitTextFieldDownCastN(void)
434 {
435   ToolkitTestApplication application;
436   tet_infoline(" UtcDaliToolkitTextFieldDownCastN");
437   BaseHandle uninitializedObject;
438   TextField textField1 = TextField::DownCast( uninitializedObject );
439   DALI_TEST_CHECK( !textField1 );
440
441   TextField textField2 = DownCast< TextField >( uninitializedObject );
442   DALI_TEST_CHECK( !textField2 );
443   END_TEST;
444 }
445
446 int UtcDaliToolkitTextFieldCopyConstructorP(void)
447 {
448   ToolkitTestApplication application;
449   tet_infoline(" UtcDaliToolkitTextFieldCopyConstructorP");
450   TextField textField = TextField::New();
451   textField.SetProperty( TextField::Property::TEXT, "Test" );
452
453   TextField copy( textField );
454   DALI_TEST_CHECK( copy );
455   DALI_TEST_CHECK( copy.GetProperty<std::string>( TextLabel::Property::TEXT ) == textField.GetProperty<std::string>( TextLabel::Property::TEXT ) );
456   END_TEST;
457 }
458
459 int UtcDaliTextFieldMoveConstructor(void)
460 {
461   ToolkitTestApplication application;
462
463   TextField textField = TextField::New();
464   textField.SetProperty( TextEditor::Property::TEXT, "Test" );
465   DALI_TEST_CHECK( textField.GetProperty<std::string>( TextField::Property::TEXT ) == "Test" );
466
467   TextField moved = std::move( textField );
468   DALI_TEST_CHECK( moved );
469   DALI_TEST_EQUALS( 1, moved.GetBaseObject().ReferenceCount(), TEST_LOCATION );
470   DALI_TEST_CHECK( moved.GetProperty<std::string>( TextField::Property::TEXT ) == "Test" );
471   DALI_TEST_CHECK( !textField );
472
473   END_TEST;
474 }
475
476 int UtcDaliToolkitTextFieldAssignmentOperatorP(void)
477 {
478   ToolkitTestApplication application;
479   tet_infoline(" UtcDaliToolkitTextFieldAssignmentOperatorP");
480   TextField textField = TextField::New();
481   textField.SetProperty( TextField::Property::TEXT, "Test" );
482
483   TextField copy = textField;
484   DALI_TEST_CHECK( copy );
485   DALI_TEST_CHECK( copy.GetProperty<std::string>( TextField::Property::TEXT ) == textField.GetProperty<std::string>( TextField::Property::TEXT ) );
486   END_TEST;
487 }
488
489 int UtcDaliTextFieldMoveAssignment(void)
490 {
491   ToolkitTestApplication application;
492
493   TextField textField = TextField::New();
494   textField.SetProperty( TextEditor::Property::TEXT, "Test" );
495   DALI_TEST_CHECK( textField.GetProperty<std::string>( TextField::Property::TEXT ) == "Test" );
496
497   TextField moved;
498   moved = std::move( textField );
499   DALI_TEST_CHECK( moved );
500   DALI_TEST_EQUALS( 1, moved.GetBaseObject().ReferenceCount(), TEST_LOCATION );
501   DALI_TEST_CHECK( moved.GetProperty<std::string>( TextField::Property::TEXT ) == "Test" );
502   DALI_TEST_CHECK( !textField );
503
504   END_TEST;
505 }
506
507 int UtcDaliTextFieldNewP(void)
508 {
509   ToolkitTestApplication application;
510   tet_infoline(" UtcDaliToolkitTextFieldNewP");
511   TextField textField = TextField::New();
512   DALI_TEST_CHECK( textField );
513   END_TEST;
514 }
515
516 // Positive test case for a method
517 int UtcDaliTextFieldGetPropertyP(void)
518 {
519   ToolkitTestApplication application;
520   tet_infoline(" UtcDaliToolkitTextFieldGetPropertyP");
521   TextField field = TextField::New();
522   DALI_TEST_CHECK( field );
523
524   // Check Property Indices are correct
525   DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_RENDERING_BACKEND ) == DevelTextField::Property::RENDERING_BACKEND );
526   DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_TEXT ) == TextField::Property::TEXT );
527   DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_PLACEHOLDER_TEXT ) == TextField::Property::PLACEHOLDER_TEXT );
528   DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_PLACEHOLDER_TEXT_FOCUSED ) == TextField::Property::PLACEHOLDER_TEXT_FOCUSED );
529   DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_FONT_FAMILY ) == TextField::Property::FONT_FAMILY );
530   DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_FONT_STYLE ) == TextField::Property::FONT_STYLE );
531   DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_POINT_SIZE ) == TextField::Property::POINT_SIZE );
532   DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_MAX_LENGTH ) == TextField::Property::MAX_LENGTH );
533   DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_EXCEED_POLICY ) == TextField::Property::EXCEED_POLICY );
534   DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_HORIZONTAL_ALIGNMENT ) == TextField::Property::HORIZONTAL_ALIGNMENT );
535   DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_VERTICAL_ALIGNMENT ) == TextField::Property::VERTICAL_ALIGNMENT );
536   DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_TEXT_COLOR ) == TextField::Property::TEXT_COLOR );
537   DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_PLACEHOLDER_TEXT_COLOR ) == TextField::Property::PLACEHOLDER_TEXT_COLOR );
538   DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_PRIMARY_CURSOR_COLOR ) == TextField::Property::PRIMARY_CURSOR_COLOR );
539   DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_SECONDARY_CURSOR_COLOR ) == TextField::Property::SECONDARY_CURSOR_COLOR );
540   DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_ENABLE_CURSOR_BLINK ) == TextField::Property::ENABLE_CURSOR_BLINK );
541   DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_CURSOR_BLINK_INTERVAL ) == TextField::Property::CURSOR_BLINK_INTERVAL );
542   DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_CURSOR_BLINK_DURATION ) == TextField::Property::CURSOR_BLINK_DURATION );
543   DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_CURSOR_WIDTH ) == TextField::Property::CURSOR_WIDTH );
544   DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_GRAB_HANDLE_IMAGE ) == TextField::Property::GRAB_HANDLE_IMAGE );
545   DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_GRAB_HANDLE_PRESSED_IMAGE ) == TextField::Property::GRAB_HANDLE_PRESSED_IMAGE );
546   DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_SCROLL_THRESHOLD ) == TextField::Property::SCROLL_THRESHOLD );
547   DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_SCROLL_SPEED ) == TextField::Property::SCROLL_SPEED );
548   DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_SELECTION_HANDLE_IMAGE_LEFT ) == TextField::Property::SELECTION_HANDLE_IMAGE_LEFT );
549   DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_SELECTION_HANDLE_IMAGE_RIGHT ) == TextField::Property::SELECTION_HANDLE_IMAGE_RIGHT );
550   DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_SELECTION_HANDLE_PRESSED_IMAGE_LEFT ) == TextField::Property::SELECTION_HANDLE_PRESSED_IMAGE_LEFT );
551   DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_SELECTION_HANDLE_PRESSED_IMAGE_RIGHT ) == TextField::Property::SELECTION_HANDLE_PRESSED_IMAGE_RIGHT );
552   DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_SELECTION_HANDLE_MARKER_IMAGE_LEFT ) == TextField::Property::SELECTION_HANDLE_MARKER_IMAGE_LEFT );
553   DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_SELECTION_HANDLE_MARKER_IMAGE_RIGHT ) == TextField::Property::SELECTION_HANDLE_MARKER_IMAGE_RIGHT );
554   DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_SELECTION_HIGHLIGHT_COLOR ) == TextField::Property::SELECTION_HIGHLIGHT_COLOR );
555   DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_DECORATION_BOUNDING_BOX ) == TextField::Property::DECORATION_BOUNDING_BOX );
556   DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_INPUT_METHOD_SETTINGS ) == TextField::Property::INPUT_METHOD_SETTINGS );
557   DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_INPUT_COLOR ) == TextField::Property::INPUT_COLOR );
558   DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_ENABLE_MARKUP ) == TextField::Property::ENABLE_MARKUP );
559   DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_INPUT_FONT_FAMILY ) == TextField::Property::INPUT_FONT_FAMILY );
560   DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_INPUT_FONT_STYLE ) == TextField::Property::INPUT_FONT_STYLE );
561   DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_INPUT_POINT_SIZE ) == TextField::Property::INPUT_POINT_SIZE );
562   DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_UNDERLINE ) == TextField::Property::UNDERLINE );
563   DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_INPUT_UNDERLINE ) == TextField::Property::INPUT_UNDERLINE );
564   DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_SHADOW ) == TextField::Property::SHADOW );
565   DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_INPUT_SHADOW ) == TextField::Property::INPUT_SHADOW );
566   DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_EMBOSS ) == TextField::Property::EMBOSS );
567   DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_INPUT_EMBOSS ) == TextField::Property::INPUT_EMBOSS );
568   DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_OUTLINE ) == TextField::Property::OUTLINE );
569   DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_INPUT_OUTLINE ) == TextField::Property::INPUT_OUTLINE );
570   DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_HIDDEN_INPUT_SETTINGS ) == TextField::Property::HIDDEN_INPUT_SETTINGS );
571   DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_PIXEL_SIZE ) == TextField::Property::PIXEL_SIZE );
572   DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_ENABLE_SELECTION ) == TextField::Property::ENABLE_SELECTION );
573   DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_PLACEHOLDER ) == TextField::Property::PLACEHOLDER );
574   DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_ELLIPSIS ) == TextField::Property::ELLIPSIS );
575   DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_FONT_SIZE_SCALE ) == DevelTextField::Property::FONT_SIZE_SCALE );
576   DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_ENABLE_FONT_SIZE_SCALE ) == DevelTextField::Property::ENABLE_FONT_SIZE_SCALE );
577   DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_ENABLE_SHIFT_SELECTION ) == DevelTextField::Property::ENABLE_SHIFT_SELECTION );
578   DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_ENABLE_GRAB_HANDLE ) == DevelTextField::Property::ENABLE_GRAB_HANDLE );
579   DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_MATCH_SYSTEM_LANGUAGE_DIRECTION ) == DevelTextField::Property::MATCH_SYSTEM_LANGUAGE_DIRECTION );
580   DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_ENABLE_GRAB_HANDLE_POPUP ) == DevelTextField::Property::ENABLE_GRAB_HANDLE_POPUP );
581   DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_BACKGROUND ) == DevelTextField::Property::BACKGROUND );
582   DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_GRAB_HANDLE_COLOR ) == DevelTextField::Property::GRAB_HANDLE_COLOR );
583   DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_INPUT_FILTER ) == DevelTextField::Property::INPUT_FILTER );
584   DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_STRIKETHROUGH ) == DevelTextField::Property::STRIKETHROUGH );
585   DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_INPUT_STRIKETHROUGH ) == DevelTextField::Property::INPUT_STRIKETHROUGH );
586
587   END_TEST;
588 }
589
590 bool SetPropertyMapRetrieved( TextField& field, const Property::Index property, const std::string mapKey, const std::string mapValue )
591 {
592   bool result = false;
593   Property::Map imageMap;
594   imageMap[mapKey] =mapValue;
595
596   field.SetProperty( property , imageMap );
597   Property::Value propValue = field.GetProperty( property );
598   Property::Map* resultMap = propValue.GetMap();
599
600   if ( resultMap->Find( mapKey )->Get< std::string>() == mapValue )
601   {
602     result = true;
603   }
604
605   return result;
606 }
607
608 // Positive test case for a method
609 int UtcDaliTextFieldSetPropertyP(void)
610 {
611   ToolkitTestApplication application;
612   tet_infoline(" UtcDaliToolkitTextFieldSetPropertyP");
613   TextField field = TextField::New();
614   DALI_TEST_CHECK( field );
615   application.GetScene().Add( field );
616
617   // Note - we can't check the defaults since the stylesheets are platform-specific
618
619   // Check the render backend property.
620   field.SetProperty( DevelTextField::Property::RENDERING_BACKEND, DevelText::RENDERING_SHARED_ATLAS );
621   DALI_TEST_EQUALS( (DevelText::RenderingType)field.GetProperty<int>( DevelTextField::Property::RENDERING_BACKEND ), DevelText::RENDERING_SHARED_ATLAS, TEST_LOCATION );
622
623   field.SetProperty( DevelTextField::Property::RENDERING_BACKEND, DevelText::RENDERING_VECTOR_BASED );
624   DALI_TEST_EQUALS( (DevelText::RenderingType)field.GetProperty<int>( DevelTextField::Property::RENDERING_BACKEND ), DevelText::RENDERING_VECTOR_BASED, TEST_LOCATION );
625
626   // Check text property.
627   field.SetProperty( TextField::Property::TEXT, "Setting Text" );
628   DALI_TEST_EQUALS( field.GetProperty<std::string>( TextField::Property::TEXT ), std::string("Setting Text"), TEST_LOCATION );
629
630   // Check placeholder text properties.
631   field.SetProperty( TextField::Property::PLACEHOLDER_TEXT, "Setting Placeholder Text" );
632   DALI_TEST_EQUALS( field.GetProperty<std::string>( TextField::Property::PLACEHOLDER_TEXT ), std::string("Setting Placeholder Text"), TEST_LOCATION );
633
634   field.SetProperty( TextField::Property::PLACEHOLDER_TEXT_FOCUSED, "Setting Placeholder Text Focused" );
635   DALI_TEST_EQUALS( field.GetProperty<std::string>( TextField::Property::PLACEHOLDER_TEXT_FOCUSED ), std::string("Setting Placeholder Text Focused"), TEST_LOCATION );
636
637   // Check font properties.
638   field.SetProperty( TextField::Property::FONT_FAMILY, "Setting font family" );
639   DALI_TEST_EQUALS( field.GetProperty<std::string>( TextField::Property::FONT_FAMILY ), std::string("Setting font family"), TEST_LOCATION );
640
641   Property::Map fontStyleMapSet;
642   Property::Map fontStyleMapGet;
643   Property::Value* slantValue = NULL;
644
645   fontStyleMapSet.Insert( "weight", "bold" );
646   fontStyleMapSet.Insert( "width", "condensed" );
647   fontStyleMapSet.Insert( "slant", "italic" );
648   field.SetProperty( TextField::Property::FONT_STYLE, fontStyleMapSet );
649
650   fontStyleMapGet = field.GetProperty<Property::Map>( TextField::Property::FONT_STYLE );
651   DALI_TEST_EQUALS( fontStyleMapGet.Count(), fontStyleMapSet.Count(), TEST_LOCATION );
652   DALI_TEST_EQUALS( DaliTestCheckMaps( fontStyleMapGet, fontStyleMapSet ), true, TEST_LOCATION );
653
654   field.SetProperty( TextField::Property::POINT_SIZE, 10.f );
655   DALI_TEST_EQUALS( field.GetProperty<float>( TextField::Property::POINT_SIZE ), 10.f, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
656
657   field.SetProperty( DevelTextField::Property::FONT_SIZE_SCALE, 2.5f );
658   DALI_TEST_EQUALS( field.GetProperty<float>( DevelTextField::Property::FONT_SIZE_SCALE ), 2.5f, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
659   field.SetProperty( DevelTextField::Property::FONT_SIZE_SCALE, 1.0f );
660
661   field.SetProperty( DevelTextField::Property::ENABLE_FONT_SIZE_SCALE, false );
662   DALI_TEST_EQUALS( field.GetProperty<bool>( DevelTextField::Property::ENABLE_FONT_SIZE_SCALE ), false, TEST_LOCATION );
663   field.SetProperty( DevelTextField::Property::ENABLE_FONT_SIZE_SCALE, true );
664
665   // Reset font style.
666   fontStyleMapSet.Clear();
667   fontStyleMapSet.Insert( "weight", "normal" );
668   fontStyleMapSet.Insert( "slant", "oblique" );
669   field.SetProperty( TextField::Property::FONT_STYLE, fontStyleMapSet );
670
671   fontStyleMapGet = field.GetProperty<Property::Map>( TextField::Property::FONT_STYLE );
672   DALI_TEST_EQUALS( fontStyleMapGet.Count(), fontStyleMapSet.Count(), TEST_LOCATION );
673   DALI_TEST_EQUALS( DaliTestCheckMaps( fontStyleMapGet, fontStyleMapSet ), true, TEST_LOCATION );
674
675   fontStyleMapSet.Clear();
676   fontStyleMapSet.Insert( "slant", "roman" );
677   field.SetProperty( TextField::Property::FONT_STYLE, fontStyleMapSet );
678   fontStyleMapGet = field.GetProperty<Property::Map>( TextField::Property::FONT_STYLE );
679
680   // Replace 'roman' for 'normal'.
681   slantValue = fontStyleMapGet.Find( "slant" );
682   if( NULL != slantValue )
683   {
684     if( "normal" == slantValue->Get<std::string>() )
685     {
686       fontStyleMapGet["slant"] = "roman";
687     }
688   }
689   DALI_TEST_EQUALS( fontStyleMapGet.Count(), fontStyleMapSet.Count(), TEST_LOCATION );
690   DALI_TEST_EQUALS( DaliTestCheckMaps( fontStyleMapGet, fontStyleMapSet ), true, TEST_LOCATION );
691
692   fontStyleMapSet.Clear();
693
694   field.SetProperty( TextField::Property::FONT_STYLE, fontStyleMapSet );
695   fontStyleMapGet = field.GetProperty<Property::Map>( TextField::Property::FONT_STYLE );
696   DALI_TEST_EQUALS( fontStyleMapGet.Count(), fontStyleMapSet.Count(), TEST_LOCATION );
697   DALI_TEST_EQUALS( DaliTestCheckMaps( fontStyleMapGet, fontStyleMapSet ), true, TEST_LOCATION );
698
699   // Check that the MAX_LENGTH property can be correctly set
700   const int maxNumberOfCharacters = 20;
701   field.SetProperty( TextField::Property::MAX_LENGTH, maxNumberOfCharacters );
702   DALI_TEST_EQUALS( field.GetProperty<int>( TextField::Property::MAX_LENGTH ), maxNumberOfCharacters, TEST_LOCATION );
703
704   // Check exceed policy
705   field.SetProperty( TextField::Property::EXCEED_POLICY, Dali::Toolkit::TextField::EXCEED_POLICY_CLIP );
706   DALI_TEST_EQUALS( field.GetProperty<int>( TextField::Property::EXCEED_POLICY ), static_cast<int>( Dali::Toolkit::TextField::EXCEED_POLICY_CLIP ), TEST_LOCATION );
707   field.SetProperty( TextField::Property::EXCEED_POLICY, Dali::Toolkit::TextField::EXCEED_POLICY_ORIGINAL );
708   DALI_TEST_EQUALS( field.GetProperty<int>( TextField::Property::EXCEED_POLICY ), static_cast<int>( Dali::Toolkit::TextField::EXCEED_POLICY_ORIGINAL ), TEST_LOCATION );
709
710   // Check that the Alignment properties can be correctly set
711   field.SetProperty( TextField::Property::HORIZONTAL_ALIGNMENT, "END" );
712   DALI_TEST_EQUALS( field.GetProperty<std::string>( TextField::Property::HORIZONTAL_ALIGNMENT ), "END", TEST_LOCATION );
713   field.SetProperty( TextField::Property::VERTICAL_ALIGNMENT, "CENTER" );
714   DALI_TEST_EQUALS( field.GetProperty<std::string>( TextField::Property::VERTICAL_ALIGNMENT ), "CENTER", TEST_LOCATION );
715
716   // Check text's color property
717   field.SetProperty( TextField::Property::TEXT_COLOR, Color::WHITE );
718   DALI_TEST_EQUALS( field.GetProperty<Vector4>( TextField::Property::TEXT_COLOR ), Color::WHITE, TEST_LOCATION );
719
720   // Check placeholder text's color property.
721   field.SetProperty( TextField::Property::PLACEHOLDER_TEXT_COLOR, Color::RED );
722   DALI_TEST_EQUALS( field.GetProperty<Vector4>( TextField::Property::PLACEHOLDER_TEXT_COLOR ), Color::RED, TEST_LOCATION );
723
724   // Check cursor properties
725   field.SetProperty( TextField::Property::PRIMARY_CURSOR_COLOR, Color::RED );
726   DALI_TEST_EQUALS( field.GetProperty<Vector4>( TextField::Property::PRIMARY_CURSOR_COLOR ), Color::RED, TEST_LOCATION );
727   field.SetProperty( TextField::Property::SECONDARY_CURSOR_COLOR, Color::BLUE );
728   DALI_TEST_EQUALS( field.GetProperty<Vector4>( TextField::Property::SECONDARY_CURSOR_COLOR ), Color::BLUE, TEST_LOCATION );
729
730   field.SetProperty( TextField::Property::ENABLE_CURSOR_BLINK, false );
731   DALI_TEST_EQUALS( field.GetProperty<bool>( TextField::Property::ENABLE_CURSOR_BLINK ), false, TEST_LOCATION );
732   field.SetProperty( TextField::Property::CURSOR_BLINK_INTERVAL, 1.f );
733   DALI_TEST_EQUALS( field.GetProperty<float>( TextField::Property::CURSOR_BLINK_INTERVAL ), 1.f, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
734   field.SetProperty( TextField::Property::CURSOR_BLINK_DURATION, 10.f );
735   DALI_TEST_EQUALS( field.GetProperty<float>( TextField::Property::CURSOR_BLINK_DURATION ), 10.f, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
736   field.SetProperty( TextField::Property::CURSOR_WIDTH, 1 );
737   DALI_TEST_EQUALS( field.GetProperty<int>( TextField::Property::CURSOR_WIDTH ), 1, TEST_LOCATION );
738
739   // Check scroll properties.
740   field.SetProperty( TextField::Property::SCROLL_THRESHOLD, 1.f );
741   DALI_TEST_EQUALS( field.GetProperty<float>( TextField::Property::SCROLL_THRESHOLD ), 1.f, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
742   field.SetProperty( TextField::Property::SCROLL_SPEED, 100.f );
743   DALI_TEST_EQUALS( field.GetProperty<float>( TextField::Property::SCROLL_SPEED ), 100.f, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
744
745   // Check handle images
746   field.SetProperty( TextField::Property::GRAB_HANDLE_IMAGE, "image1" );
747   DALI_TEST_EQUALS( field.GetProperty<std::string>( TextField::Property::GRAB_HANDLE_IMAGE ), "image1", TEST_LOCATION );
748   field.SetProperty( TextField::Property::GRAB_HANDLE_PRESSED_IMAGE, "image2" );
749   DALI_TEST_EQUALS( field.GetProperty<std::string>( TextField::Property::GRAB_HANDLE_PRESSED_IMAGE ), "image2", TEST_LOCATION );
750   field.SetProperty( TextField::Property::SELECTION_HANDLE_IMAGE_LEFT, "image3" );
751
752   // Check handle images
753   DALI_TEST_CHECK( SetPropertyMapRetrieved( field, TextField::Property::SELECTION_HANDLE_IMAGE_LEFT, "filename", "leftHandleImage" )  );
754   DALI_TEST_CHECK( SetPropertyMapRetrieved( field, TextField::Property::SELECTION_HANDLE_IMAGE_RIGHT, "filename", "rightHandleImage" )  );
755   DALI_TEST_CHECK( SetPropertyMapRetrieved( field, TextField::Property::SELECTION_HANDLE_PRESSED_IMAGE_LEFT, "filename", "leftHandleImagePressed" )  );
756   DALI_TEST_CHECK( SetPropertyMapRetrieved( field, TextField::Property::SELECTION_HANDLE_PRESSED_IMAGE_RIGHT, "filename", "rightHandleImagePressed" )  );
757   DALI_TEST_CHECK( SetPropertyMapRetrieved( field, TextField::Property::SELECTION_HANDLE_MARKER_IMAGE_LEFT, "filename", "leftHandleMarkerImage" )  );
758   DALI_TEST_CHECK( SetPropertyMapRetrieved( field, TextField::Property::SELECTION_HANDLE_MARKER_IMAGE_RIGHT, "filename", "rightHandleMarkerImage" )  );
759
760   // Check the highlight color
761   field.SetProperty( TextField::Property::SELECTION_HIGHLIGHT_COLOR, Color::GREEN );
762   DALI_TEST_EQUALS( field.GetProperty<Vector4>( TextField::Property::SELECTION_HIGHLIGHT_COLOR ), Color::GREEN, TEST_LOCATION );
763
764   // Decoration bounding box
765   field.SetProperty( TextField::Property::DECORATION_BOUNDING_BOX, Rect<int>( 0, 0, 1, 1 ) );
766   DALI_TEST_EQUALS( field.GetProperty<Rect <int > >( TextField::Property::DECORATION_BOUNDING_BOX ), Rect<int>( 0, 0, 1, 1 ), TEST_LOCATION );
767
768   // Check the input method setting
769   Property::Map propertyMap;
770   InputMethod::PanelLayout::Type panelLayout = InputMethod::PanelLayout::NUMBER;
771   InputMethod::AutoCapital::Type autoCapital = InputMethod::AutoCapital::WORD;
772   InputMethod::ButtonAction::Type buttonAction = InputMethod::ButtonAction::GO;
773   int inputVariation = 1;
774   propertyMap["PANEL_LAYOUT"] = panelLayout;
775   propertyMap["AUTO_CAPITALIZE"] = autoCapital;
776   propertyMap["BUTTON_ACTION"] = buttonAction;
777   propertyMap["VARIATION"] = inputVariation;
778   field.SetProperty( TextField::Property::INPUT_METHOD_SETTINGS, propertyMap );
779
780   Property::Value value = field.GetProperty( TextField::Property::INPUT_METHOD_SETTINGS );
781   Property::Map map;
782   DALI_TEST_CHECK( value.Get( map ) );
783
784   int layout = 0;
785   DALI_TEST_CHECK( map[ "PANEL_LAYOUT" ].Get( layout ) );
786   DALI_TEST_EQUALS( static_cast<int>(panelLayout), layout, TEST_LOCATION );
787
788   int capital = 0;
789   DALI_TEST_CHECK( map[ "AUTO_CAPITALIZE" ].Get( capital ) );
790   DALI_TEST_EQUALS( static_cast<int>(autoCapital), capital, TEST_LOCATION );
791
792   int action = 0;
793   DALI_TEST_CHECK( map[ "BUTTON_ACTION" ].Get( action ) );
794   DALI_TEST_EQUALS( static_cast<int>(buttonAction), action, TEST_LOCATION );
795
796   int variation = 0;
797   DALI_TEST_CHECK( map[ "VARIATION" ].Get( variation ) );
798   DALI_TEST_EQUALS( inputVariation, variation, TEST_LOCATION );
799
800   // Check input color property.
801   field.SetProperty( TextField::Property::INPUT_COLOR, Color::YELLOW );
802   DALI_TEST_EQUALS( field.GetProperty<Vector4>( TextField::Property::INPUT_COLOR ), Color::YELLOW, TEST_LOCATION );
803
804   // Check the enable markup property.
805   DALI_TEST_CHECK( !field.GetProperty<bool>( TextField::Property::ENABLE_MARKUP ) );
806   field.SetProperty( TextField::Property::ENABLE_MARKUP, true );
807   DALI_TEST_CHECK( field.GetProperty<bool>( TextField::Property::ENABLE_MARKUP ) );
808
809   // Check input font properties.
810   field.SetProperty( TextField::Property::INPUT_FONT_FAMILY, "Setting input font family" );
811   DALI_TEST_EQUALS( field.GetProperty<std::string>( TextField::Property::INPUT_FONT_FAMILY ), "Setting input font family", TEST_LOCATION );
812
813   fontStyleMapSet.Clear();
814   fontStyleMapSet.Insert( "weight", "bold" );
815   fontStyleMapSet.Insert( "width", "condensed" );
816   fontStyleMapSet.Insert( "slant", "italic" );
817
818   field.SetProperty( TextField::Property::INPUT_FONT_STYLE, fontStyleMapSet );
819   fontStyleMapGet = field.GetProperty<Property::Map>( TextField::Property::INPUT_FONT_STYLE );
820   DALI_TEST_EQUALS( fontStyleMapGet.Count(), fontStyleMapSet.Count(), TEST_LOCATION );
821   DALI_TEST_EQUALS( DaliTestCheckMaps( fontStyleMapGet, fontStyleMapSet ), true, TEST_LOCATION );
822
823   field.SetProperty( TextField::Property::INPUT_POINT_SIZE, 12.f );
824   DALI_TEST_EQUALS( field.GetProperty<float>( TextField::Property::INPUT_POINT_SIZE ), 12.f, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
825
826   // Reset input font style.
827   fontStyleMapSet.Clear();
828   fontStyleMapSet.Insert( "weight", "normal" );
829   fontStyleMapSet.Insert( "slant", "oblique" );
830
831   field.SetProperty( TextField::Property::INPUT_FONT_STYLE, fontStyleMapSet );
832   fontStyleMapGet = field.GetProperty<Property::Map>( TextField::Property::INPUT_FONT_STYLE );
833   DALI_TEST_EQUALS( fontStyleMapGet.Count(), fontStyleMapSet.Count(), TEST_LOCATION );
834   DALI_TEST_EQUALS( DaliTestCheckMaps( fontStyleMapGet, fontStyleMapSet ), true, TEST_LOCATION );
835
836   fontStyleMapSet.Clear();
837   fontStyleMapSet.Insert( "slant", "roman" );
838
839   field.SetProperty( TextField::Property::INPUT_FONT_STYLE, fontStyleMapSet );
840   fontStyleMapGet = field.GetProperty<Property::Map>( TextField::Property::INPUT_FONT_STYLE );
841
842   // Replace 'roman' for 'normal'.
843   slantValue = fontStyleMapGet.Find( "slant" );
844   if( NULL != slantValue )
845   {
846     if( "normal" == slantValue->Get<std::string>() )
847     {
848       fontStyleMapGet["slant"] = "roman";
849     }
850   }
851   DALI_TEST_EQUALS( fontStyleMapGet.Count(), fontStyleMapSet.Count(), TEST_LOCATION );
852   DALI_TEST_EQUALS( DaliTestCheckMaps( fontStyleMapGet, fontStyleMapSet ), true, TEST_LOCATION );
853
854   fontStyleMapSet.Clear();
855
856   field.SetProperty( TextField::Property::INPUT_FONT_STYLE, fontStyleMapSet );
857   fontStyleMapGet = field.GetProperty<Property::Map>( TextField::Property::INPUT_FONT_STYLE );
858   DALI_TEST_EQUALS( fontStyleMapGet.Count(), fontStyleMapSet.Count(), TEST_LOCATION );
859   DALI_TEST_EQUALS( DaliTestCheckMaps( fontStyleMapGet, fontStyleMapSet ), true, TEST_LOCATION );
860
861   Property::Map strikethroughMapSet;
862   Property::Map strikethroughMapGet;
863
864   strikethroughMapSet.Insert( "enable", true );
865   strikethroughMapSet.Insert( "color", Color::RED );
866   strikethroughMapSet.Insert( "height", 2.0f );
867
868   // Check the strikethrough property
869   field.SetProperty( DevelTextField::Property::STRIKETHROUGH, strikethroughMapSet );
870
871   strikethroughMapGet = field.GetProperty<Property::Map>( DevelTextField::Property::STRIKETHROUGH );
872   DALI_TEST_EQUALS( strikethroughMapGet.Count(), strikethroughMapSet.Count(), TEST_LOCATION );
873   DALI_TEST_EQUALS( DaliTestCheckMaps( strikethroughMapGet, strikethroughMapSet ), true, TEST_LOCATION );
874
875   // Check the input strikethrough property
876   field.SetProperty( DevelTextField::Property::INPUT_STRIKETHROUGH, "Strikethrough input properties" );
877   DALI_TEST_EQUALS( field.GetProperty<std::string>( DevelTextField::Property::INPUT_STRIKETHROUGH ), std::string("Strikethrough input properties"), TEST_LOCATION );
878
879   Property::Map underlineMapSet;
880   Property::Map underlineMapGet;
881
882   underlineMapSet.Insert( "enable", true );
883   underlineMapSet.Insert( "color", Color::RED );
884   underlineMapSet.Insert( "height", 1 );
885
886   // Check the underline property
887   field.SetProperty( TextField::Property::UNDERLINE, underlineMapSet );
888
889   underlineMapGet = field.GetProperty<Property::Map>( TextField::Property::UNDERLINE );
890   DALI_TEST_EQUALS( underlineMapGet.Count(), underlineMapSet.Count(), TEST_LOCATION );
891   DALI_TEST_EQUALS( DaliTestCheckMaps( underlineMapGet, underlineMapSet ), true, TEST_LOCATION );
892
893   // Check the input underline property
894   field.SetProperty( TextField::Property::INPUT_UNDERLINE, "Underline input properties" );
895   DALI_TEST_EQUALS( field.GetProperty<std::string>( TextField::Property::INPUT_UNDERLINE ), std::string("Underline input properties"), TEST_LOCATION );
896
897   // Check the shadow property
898   Property::Map shadowMapSet;
899   Property::Map shadowMapGet;
900
901   shadowMapSet.Insert( "color", Color::GREEN );
902   shadowMapSet.Insert( "offset", Vector2(2.0f, 2.0f) );
903   shadowMapSet.Insert( "blurRadius", 3.0f );
904
905   field.SetProperty( TextField::Property::SHADOW, shadowMapSet );
906
907   shadowMapGet = field.GetProperty<Property::Map>( TextField::Property::SHADOW );
908   DALI_TEST_EQUALS( shadowMapGet.Count(), shadowMapSet.Count(), TEST_LOCATION );
909   DALI_TEST_EQUALS( DaliTestCheckMaps( shadowMapGet, shadowMapSet ), true, TEST_LOCATION );
910
911   // Check the input shadow property
912   field.SetProperty( TextField::Property::INPUT_SHADOW, "Shadow input properties" );
913   DALI_TEST_EQUALS( field.GetProperty<std::string>( TextField::Property::INPUT_SHADOW ), std::string("Shadow input properties"), TEST_LOCATION );
914
915   // Check the emboss property
916   field.SetProperty( TextField::Property::EMBOSS, "Emboss properties" );
917   DALI_TEST_EQUALS( field.GetProperty<std::string>( TextField::Property::EMBOSS ), std::string("Emboss properties"), TEST_LOCATION );
918
919   // Check the input emboss property
920   field.SetProperty( TextField::Property::INPUT_EMBOSS, "Emboss input properties" );
921   DALI_TEST_EQUALS( field.GetProperty<std::string>( TextField::Property::INPUT_EMBOSS ), std::string("Emboss input properties"), TEST_LOCATION );
922
923   // Check the outline property
924
925   // Test string type first
926   // This is purely to maintain backward compatibility, but we don't support string as the outline property type.
927   field.SetProperty( TextField::Property::OUTLINE, "Outline properties" );
928   DALI_TEST_EQUALS( field.GetProperty<std::string>( TextField::Property::OUTLINE ), std::string("Outline properties"), TEST_LOCATION );
929
930   // Then test the property map type
931   Property::Map outlineMapSet;
932   Property::Map outlineMapGet;
933
934   outlineMapSet["color"] = Color::RED;
935   outlineMapSet["width"] = 2.0f;
936
937   field.SetProperty( TextField::Property::OUTLINE, outlineMapSet );
938
939   outlineMapGet = field.GetProperty<Property::Map>( TextField::Property::OUTLINE );
940   DALI_TEST_EQUALS( outlineMapGet.Count(), outlineMapSet.Count(), TEST_LOCATION );
941   DALI_TEST_EQUALS( DaliTestCheckMaps( outlineMapGet, outlineMapSet ), true, TEST_LOCATION );
942
943   // Check the input outline property
944   field.SetProperty( TextField::Property::INPUT_OUTLINE, "Outline input properties" );
945   DALI_TEST_EQUALS( field.GetProperty<std::string>( TextField::Property::INPUT_OUTLINE ), std::string("Outline input properties"), TEST_LOCATION );
946
947   // Check the hidden input settings property
948   Property::Map hiddenMapSet;
949   Property::Map hiddenMapGet;
950   hiddenMapSet[ HiddenInput::Property::MODE ] = HiddenInput::Mode::HIDE_ALL;
951   hiddenMapSet[ HiddenInput::Property::SHOW_LAST_CHARACTER_DURATION ] = 2;
952   hiddenMapSet[ HiddenInput::Property::SUBSTITUTE_COUNT ] = 4;
953   hiddenMapSet[ HiddenInput::Property::SUBSTITUTE_CHARACTER ] = 0x23;
954   field.SetProperty( TextField::Property::HIDDEN_INPUT_SETTINGS, hiddenMapSet );
955
956   hiddenMapGet = field.GetProperty<Property::Map>( TextField::Property::HIDDEN_INPUT_SETTINGS );
957   DALI_TEST_EQUALS( hiddenMapSet.Count(), hiddenMapGet.Count(), TEST_LOCATION );
958   DALI_TEST_EQUALS( DaliTestCheckMaps( hiddenMapSet, hiddenMapGet ), true, TEST_LOCATION );
959
960   // Check the pixel size of font
961   field.SetProperty( TextField::Property::PIXEL_SIZE, 20.f );
962   DALI_TEST_EQUALS( field.GetProperty<float>( TextField::Property::PIXEL_SIZE ), 20.f, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
963
964   // Check the enable selection property
965   field.SetProperty( TextField::Property::ENABLE_SELECTION, false );
966   DALI_TEST_EQUALS( field.GetProperty<bool>( TextField::Property::ENABLE_SELECTION ), false, TEST_LOCATION );
967
968   // Check the placeholder property with pixel size
969   Property::Map placeholderPixelSizeMapSet;
970   Property::Map placeholderPixelSizeMapGet;
971   Property::Map placeholderFontstyleMap;
972   placeholderPixelSizeMapSet["text"] = "Setting Placeholder Text";
973   placeholderPixelSizeMapSet["textFocused"] = "Setting Placeholder Text Focused";
974   placeholderPixelSizeMapSet["color"] = Color::BLUE;
975   placeholderPixelSizeMapSet["fontFamily"] = "Arial";
976   placeholderPixelSizeMapSet["pixelSize"] = 15.0f;
977   placeholderPixelSizeMapSet["ellipsis"] = true;
978
979   placeholderFontstyleMap.Insert( "weight", "bold" );
980   placeholderPixelSizeMapSet["placeholderFontStyle"] = placeholderFontstyleMap;
981   field.SetProperty( TextField::Property::PLACEHOLDER, placeholderPixelSizeMapSet );
982
983   placeholderPixelSizeMapGet = field.GetProperty<Property::Map>( TextField::Property::PLACEHOLDER );
984   DALI_TEST_EQUALS( placeholderPixelSizeMapGet.Count(), placeholderPixelSizeMapSet.Count(), TEST_LOCATION );
985
986   tet_infoline("Test Placeholder settings set as strings is converted correctly to Property Index key and holds set value");
987   Property::Map placeholderConversionMap;
988   placeholderConversionMap[ Text::PlaceHolder::Property::TEXT ] = placeholderPixelSizeMapSet["text"];
989   placeholderConversionMap[ Text::PlaceHolder::Property::TEXT_FOCUSED ] = placeholderPixelSizeMapSet["textFocused"] ;
990   placeholderConversionMap[ Text::PlaceHolder::Property::COLOR ] = placeholderPixelSizeMapSet["color"];
991   placeholderConversionMap[ Text::PlaceHolder::Property::FONT_STYLE ] = placeholderPixelSizeMapSet["fontStyle"];
992   placeholderConversionMap[ Text::PlaceHolder::Property::FONT_FAMILY ] = placeholderPixelSizeMapSet["fontFamily"];
993   placeholderConversionMap[ Text::PlaceHolder::Property::PIXEL_SIZE ] = placeholderPixelSizeMapSet["pixelSize"];
994
995   DALI_TEST_EQUALS( DaliTestCheckMaps( placeholderPixelSizeMapGet, placeholderConversionMap ), true, TEST_LOCATION );
996
997   // Check the placeholder property with point size
998   Property::Map placeholderMapSet;
999   Property::Map placeholderMapGet;
1000   placeholderMapSet["text"] = "Setting Placeholder Text";
1001   placeholderMapSet["textFocused"] = "Setting Placeholder Text Focused";
1002   placeholderMapSet["color"] = Color::RED;
1003   placeholderMapSet["fontFamily"] = "Arial";
1004   placeholderMapSet["pointSize"] = 12.0f;
1005   placeholderMapSet["ellipsis"] = false;
1006
1007   // Check the placeholder font style property
1008   placeholderFontstyleMap.Clear();
1009
1010   placeholderFontstyleMap.Insert( "weight", "bold" );
1011   placeholderFontstyleMap.Insert( "width", "condensed" );
1012   placeholderFontstyleMap.Insert( "slant", "italic" );
1013   placeholderMapSet["fontStyle"] = placeholderFontstyleMap;
1014   field.SetProperty( TextField::Property::PLACEHOLDER, placeholderMapSet );
1015
1016   placeholderMapGet = field.GetProperty<Property::Map>( TextField::Property::PLACEHOLDER );
1017   DALI_TEST_EQUALS( placeholderMapGet.Count(), placeholderMapSet.Count(), TEST_LOCATION );
1018
1019   placeholderConversionMap.Clear();
1020   placeholderConversionMap[ Text::PlaceHolder::Property::TEXT ] = placeholderPixelSizeMapSet["text"];
1021   placeholderConversionMap[ Text::PlaceHolder::Property::TEXT_FOCUSED ] = placeholderPixelSizeMapSet["textFocused"] ;
1022   placeholderConversionMap[ Text::PlaceHolder::Property::COLOR ] = placeholderPixelSizeMapSet["color"];
1023   placeholderConversionMap[ Text::PlaceHolder::Property::FONT_STYLE ] = placeholderPixelSizeMapSet["fontStyle"];
1024   placeholderConversionMap[ Text::PlaceHolder::Property::FONT_FAMILY ] = placeholderPixelSizeMapSet["fontFamily"];
1025   placeholderConversionMap[ Text::PlaceHolder::Property::POINT_SIZE ] = placeholderPixelSizeMapSet["pointSize"];
1026
1027   DALI_TEST_EQUALS( DaliTestCheckMaps( placeholderMapGet, placeholderConversionMap ), true, TEST_LOCATION );
1028
1029   // Reset font style.
1030   placeholderFontstyleMap.Clear();
1031   placeholderFontstyleMap.Insert( "weight", "normal" );
1032   placeholderFontstyleMap.Insert( "slant", "oblique" );
1033   placeholderMapSet["fontStyle"] = placeholderFontstyleMap;
1034   field.SetProperty( TextField::Property::PLACEHOLDER, placeholderMapSet );
1035
1036   placeholderMapGet = field.GetProperty<Property::Map>( TextField::Property::PLACEHOLDER );
1037   DALI_TEST_EQUALS( placeholderMapGet.Count(), placeholderMapSet.Count(), TEST_LOCATION );
1038
1039   placeholderConversionMap[ Text::PlaceHolder::Property::FONT_STYLE ] = placeholderPixelSizeMapSet["fontStyle"];
1040   DALI_TEST_EQUALS( DaliTestCheckMaps( placeholderMapGet, placeholderConversionMap ), true, TEST_LOCATION );
1041
1042   placeholderFontstyleMap.Clear();
1043   placeholderFontstyleMap.Insert( "slant", "roman" );
1044   placeholderMapSet["fontStyle"] = placeholderFontstyleMap;
1045   placeholderConversionMap[ Text::PlaceHolder::Property::FONT_STYLE ] = placeholderPixelSizeMapSet["fontStyle"];
1046
1047   field.SetProperty( TextField::Property::PLACEHOLDER, placeholderMapSet );
1048
1049   placeholderMapGet = field.GetProperty<Property::Map>( TextField::Property::PLACEHOLDER );
1050
1051   placeholderFontstyleMap.Clear();
1052   placeholderMapSet["fontStyle"] = placeholderFontstyleMap;
1053   placeholderConversionMap[ Text::PlaceHolder::Property::FONT_STYLE ] = placeholderPixelSizeMapSet["fontStyle"];
1054
1055   field.SetProperty( TextField::Property::PLACEHOLDER, placeholderMapSet );
1056   placeholderMapGet = field.GetProperty<Property::Map>( TextField::Property::PLACEHOLDER );
1057   DALI_TEST_EQUALS( placeholderMapGet.Count(), placeholderMapSet.Count(), TEST_LOCATION );
1058
1059   DALI_TEST_EQUALS( DaliTestCheckMaps( placeholderMapGet, placeholderConversionMap ), true, TEST_LOCATION );
1060
1061   // Check the ellipsis property
1062   DALI_TEST_CHECK( !field.GetProperty<bool>( TextField::Property::ELLIPSIS ) );
1063   field.SetProperty( TextField::Property::ELLIPSIS, true );
1064   DALI_TEST_CHECK( field.GetProperty<bool>( TextField::Property::ELLIPSIS ) );
1065
1066   field.SetProperty( Actor::Property::LAYOUT_DIRECTION, LayoutDirection::RIGHT_TO_LEFT );
1067   DALI_TEST_EQUALS( field.GetProperty<int>( Actor::Property::LAYOUT_DIRECTION ), static_cast<int>( LayoutDirection::RIGHT_TO_LEFT ), TEST_LOCATION );
1068
1069   // Test the ENABLE_GRAB_HANDLE_POPUP property
1070   DALI_TEST_CHECK( field.GetProperty<bool>( DevelTextField::Property::ENABLE_GRAB_HANDLE_POPUP ) );
1071   field.SetProperty( DevelTextField::Property::ENABLE_GRAB_HANDLE_POPUP, false );
1072   DALI_TEST_CHECK( !field.GetProperty<bool>( DevelTextField::Property::ENABLE_GRAB_HANDLE_POPUP ) );
1073
1074   // Check the background property
1075   field.SetProperty( DevelTextField::Property::BACKGROUND, Color::RED );
1076   DALI_TEST_EQUALS( field.GetProperty<Vector4>( DevelTextField::Property::BACKGROUND ), Color::RED, TEST_LOCATION );
1077
1078   //Check handle color
1079   field.SetProperty( DevelTextField::Property::GRAB_HANDLE_COLOR, Color::GREEN );
1080   DALI_TEST_EQUALS( field.GetProperty<Vector4>( DevelTextField::Property::GRAB_HANDLE_COLOR ), Color::GREEN, TEST_LOCATION );
1081
1082   // Check the input filter property
1083   Property::Map inputFilterMapSet;
1084   Property::Map inputFilterMapGet;
1085   inputFilterMapSet[InputFilter::Property::ACCEPTED] = "[\\w]";
1086   inputFilterMapSet[InputFilter::Property::REJECTED] = "[\\d]";
1087
1088   field.SetProperty(DevelTextField::Property::INPUT_FILTER, inputFilterMapSet);
1089
1090   inputFilterMapGet = field.GetProperty<Property::Map>(DevelTextField::Property::INPUT_FILTER);
1091   DALI_TEST_EQUALS(inputFilterMapGet.Count(), inputFilterMapSet.Count(), TEST_LOCATION);
1092
1093   // Clear
1094   inputFilterMapSet.Clear();
1095   field.SetProperty(DevelTextField::Property::INPUT_FILTER, inputFilterMapSet);
1096
1097   application.SendNotification();
1098   application.Render();
1099
1100   END_TEST;
1101 }
1102
1103 // Positive Atlas Text Renderer test
1104 int utcDaliTextFieldAtlasRenderP(void)
1105 {
1106   ToolkitTestApplication application;
1107   tet_infoline(" UtcDaliToolkitTextFieldAtlasRenderP");
1108   StyleManager styleManager = StyleManager::Get();
1109   styleManager.ApplyDefaultTheme();
1110   TextField field = TextField::New();
1111   DALI_TEST_CHECK( field );
1112
1113   field.SetProperty( TextField::Property::HORIZONTAL_ALIGNMENT, "CENTER" );
1114
1115   application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
1116
1117   application.GetScene().Add( field );
1118
1119   try
1120   {
1121     // Render some text with the shared atlas backend
1122     field.SetProperty( DevelTextField::Property::RENDERING_BACKEND, DevelText::RENDERING_SHARED_ATLAS );
1123     application.SendNotification();
1124     application.Render();
1125   }
1126   catch( ... )
1127   {
1128     tet_result(TET_FAIL);
1129   }
1130   END_TEST;
1131 }
1132
1133 // Positive test for the anchorClicked signal.
1134 int utcDaliTextFieldAnchorClicked01(void)
1135 {
1136   ToolkitTestApplication application;
1137   tet_infoline(" utcDaliTextFieldAnchorClicked01");
1138   TextField field = TextField::New();
1139   DALI_TEST_CHECK(field);
1140
1141   application.GetScene().Add(field);
1142
1143   // connect to the anchor clicked signal.
1144   ConnectionTracker* testTracker = new ConnectionTracker();
1145   DevelTextField::AnchorClickedSignal(field).Connect(&TestAnchorClickedCallback);
1146   bool anchorClickedSignal = false;
1147   field.ConnectSignal(testTracker, "anchorClicked", CallbackFunctor(&anchorClickedSignal));
1148
1149   gAnchorClickedCallBackCalled = false;
1150   field.SetProperty(TextField::Property::TEXT, "<a href='https://www.tizen.org'>TIZEN</a>");
1151   field.SetProperty(TextField::Property::ENABLE_MARKUP, true);
1152   field.SetProperty(Actor::Property::SIZE, Vector2(100.f, 50.f));
1153   field.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT);
1154   field.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
1155
1156   application.SendNotification();
1157   application.Render();
1158   field.SetKeyInputFocus();
1159
1160   // Create a tap event to touch the text field.
1161   TestGenerateTap(application, 5.0f, 25.0f);
1162   application.SendNotification();
1163   application.Render();
1164
1165   DALI_TEST_CHECK(gAnchorClickedCallBackCalled);
1166   DALI_TEST_CHECK(anchorClickedSignal);
1167
1168   gAnchorClickedCallBackNotCalled = true;
1169   // Tap the outside of anchor, callback should not be called.
1170   TestGenerateTap(application, 150.f, 100.f);
1171   application.SendNotification();
1172   application.Render();
1173
1174   DALI_TEST_CHECK(gAnchorClickedCallBackNotCalled);
1175
1176   END_TEST;
1177 }
1178
1179 // Positive test for the anchorClicked signal.
1180 int utcDaliTextFieldAnchorClicked02(void)
1181 {
1182   ToolkitTestApplication application;
1183   tet_infoline(" utcDaliTextFieldAnchorClicked02");
1184   TextField field = TextField::New();
1185   DALI_TEST_CHECK(field);
1186
1187   application.GetScene().Add(field);
1188
1189   // connect to the anchor clicked signal.
1190   ConnectionTracker* testTracker = new ConnectionTracker();
1191   DevelTextField::AnchorClickedSignal(field).Connect(&TestAnchorClickedCallback);
1192   bool anchorClickedSignal = false;
1193   field.ConnectSignal(testTracker, "anchorClicked", CallbackFunctor(&anchorClickedSignal));
1194
1195   gAnchorClickedCallBackCalled = false;
1196   field.SetProperty(TextField::Property::TEXT, "<a href='https://www.tizen.org'>TIZEN</a>");
1197   field.SetProperty(TextField::Property::ENABLE_MARKUP, true);
1198   field.SetProperty(Actor::Property::SIZE, Vector2(100.f, 50.f));
1199   field.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT);
1200   field.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
1201
1202   application.SendNotification();
1203   application.Render();
1204   field.SetKeyInputFocus();
1205
1206   // Avoid a crash when core load gl resources.
1207   application.GetGlAbstraction().SetCheckFramebufferStatusResult(GL_FRAMEBUFFER_COMPLETE);
1208
1209   // Create a tap event to touch the text field.
1210   TestGenerateTap(application, 30.0f, 25.0f, 100);
1211   application.SendNotification();
1212   application.Render();
1213
1214   DALI_TEST_CHECK(gAnchorClickedCallBackCalled);
1215   DALI_TEST_CHECK(anchorClickedSignal);
1216
1217
1218   // For coverage InsertTextAnchor, RemoveTextAnchor
1219   // first index insert
1220   field.SetProperty(TextField::Property::TEXT, "<a href='https://www.tizen.org'>TIZEN</a>");
1221   field.SetProperty(DevelTextField::Property::PRIMARY_CURSOR_POSITION, 0);
1222   application.SendNotification();
1223   application.Render();
1224
1225   application.ProcessEvent( GenerateKey( "D", "", "D", KEY_D_CODE, 0, 0, Integration::KeyEvent::DOWN, "D", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
1226   application.SendNotification();
1227   application.Render();
1228
1229   gAnchorClickedCallBackCalled = false;
1230   // Create a tap event to touch the text field.
1231   TestGenerateTap(application, 30.0f, 25.0f, 700);
1232   application.SendNotification();
1233   field.SetKeyInputFocus();
1234
1235   DALI_TEST_CHECK(gAnchorClickedCallBackCalled);
1236
1237   // last index insert
1238   field.SetProperty(TextField::Property::TEXT, "<a href='https://www.tizen.org'>TIZEN</a>");
1239   field.SetProperty(DevelTextField::Property::PRIMARY_CURSOR_POSITION, 5);
1240   application.SendNotification();
1241   application.Render();
1242
1243   application.ProcessEvent( GenerateKey( "D", "", "D", KEY_D_CODE, 0, 0, Integration::KeyEvent::DOWN, "D", 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, 1300);
1250   application.SendNotification();
1251   field.SetKeyInputFocus();
1252
1253   DALI_TEST_CHECK(gAnchorClickedCallBackCalled);
1254
1255   // mid index insert
1256   field.SetProperty(TextField::Property::TEXT, "<a href='https://www.tizen.org'>TIZEN</a>");
1257   field.SetProperty(DevelTextField::Property::PRIMARY_CURSOR_POSITION, 2);
1258   application.SendNotification();
1259   application.Render();
1260
1261   application.ProcessEvent( GenerateKey( "D", "", "D", KEY_D_CODE, 0, 0, Integration::KeyEvent::DOWN, "D", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
1262   application.SendNotification();
1263   application.Render();
1264
1265   gAnchorClickedCallBackCalled = false;
1266   // Create a tap event to touch the text field.
1267   TestGenerateTap(application, 30.0f, 25.0f, 1900);
1268   application.SendNotification();
1269   field.SetKeyInputFocus();
1270
1271   DALI_TEST_CHECK(gAnchorClickedCallBackCalled);
1272
1273   // first index remove
1274   field.SetProperty(TextField::Property::TEXT, "<a href='https://www.tizen.org'>TIZEN</a>");
1275   field.SetProperty(DevelTextField::Property::PRIMARY_CURSOR_POSITION, 0);
1276   application.SendNotification();
1277   application.Render();
1278
1279   application.ProcessEvent(GenerateKey("", "", "", DALI_KEY_BACKSPACE, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
1280   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));
1281   application.SendNotification();
1282   application.Render();
1283
1284   gAnchorClickedCallBackCalled = false;
1285   // Create a tap event to touch the text field.
1286   TestGenerateTap(application, 30.0f, 25.0f, 2500);
1287   application.SendNotification();
1288   field.SetKeyInputFocus();
1289
1290   DALI_TEST_CHECK(gAnchorClickedCallBackCalled);
1291
1292   // last index remove
1293   field.SetProperty(TextField::Property::TEXT, "<a href='https://www.tizen.org'>TIZEN</a>");
1294   field.SetProperty(DevelTextField::Property::PRIMARY_CURSOR_POSITION, 5);
1295   application.SendNotification();
1296   application.Render();
1297
1298   application.ProcessEvent(GenerateKey("", "", "", DALI_KEY_BACKSPACE, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
1299   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));
1300   application.SendNotification();
1301   application.Render();
1302
1303   gAnchorClickedCallBackCalled = false;
1304   // Create a tap event to touch the text field.
1305   TestGenerateTap(application, 30.0f, 25.0f, 3100);
1306   application.SendNotification();
1307   application.Render();
1308
1309   DALI_TEST_CHECK(gAnchorClickedCallBackCalled);
1310
1311   // middle index
1312   field.SetProperty(TextField::Property::TEXT, "<a href='https://www.tizen.org'>TIZEN</a>");
1313   field.SetProperty(DevelTextField::Property::PRIMARY_CURSOR_POSITION, 2);
1314   application.SendNotification();
1315   application.Render();
1316
1317   application.ProcessEvent(GenerateKey("", "", "", DALI_KEY_BACKSPACE, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
1318   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));
1319   application.SendNotification();
1320   application.Render();
1321
1322   gAnchorClickedCallBackCalled = false;
1323   // Create a tap event to touch the text field.
1324   TestGenerateTap(application, 30.0f, 25.0f, 3700);
1325   application.SendNotification();
1326   application.Render();
1327
1328   DALI_TEST_CHECK(gAnchorClickedCallBackCalled);
1329
1330   // 0 ~ 1 index remove
1331   field.SetProperty(TextField::Property::TEXT, "<a href='https://www.tizen.org'>TIZEN</a>");
1332   field.SetProperty( DevelTextField::Property::SELECTED_TEXT_START, 0);
1333   field.SetProperty( DevelTextField::Property::SELECTED_TEXT_END, 1);
1334   application.SendNotification();
1335   application.Render();
1336
1337   application.ProcessEvent(GenerateKey("", "", "", DALI_KEY_BACKSPACE, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
1338   application.SendNotification();
1339   application.Render();
1340
1341   gAnchorClickedCallBackCalled = false;
1342   // Create a tap event to touch the text field.
1343   TestGenerateTap(application, 30.0f, 25.0f, 4300);
1344   application.SendNotification();
1345   application.Render();
1346
1347   DALI_TEST_CHECK(gAnchorClickedCallBackCalled);
1348
1349   // 1 ~ 3 index remove
1350   field.SetProperty(TextField::Property::TEXT, "<a href='https://www.tizen.org'>TIZEN</a>");
1351   field.SetProperty( DevelTextField::Property::SELECTED_TEXT_START, 1);
1352   field.SetProperty( DevelTextField::Property::SELECTED_TEXT_END, 3);
1353   application.SendNotification();
1354   application.Render();
1355
1356   application.ProcessEvent(GenerateKey("", "", "", DALI_KEY_BACKSPACE, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
1357   application.SendNotification();
1358   application.Render();
1359
1360   gAnchorClickedCallBackCalled = false;
1361   // Create a tap event to touch the text field.
1362   TestGenerateTap(application, 30.0f, 25.0f, 4900);
1363   application.SendNotification();
1364   application.Render();
1365
1366   DALI_TEST_CHECK(gAnchorClickedCallBackCalled);
1367
1368   // 3 ~ 4 index remove
1369   field.SetProperty(TextField::Property::TEXT, "<a href='https://www.tizen.org'>TIZEN</a>");
1370   field.SetProperty( DevelTextField::Property::SELECTED_TEXT_START, 3);
1371   field.SetProperty( DevelTextField::Property::SELECTED_TEXT_END, 4);
1372   application.SendNotification();
1373   application.Render();
1374
1375   application.ProcessEvent(GenerateKey("", "", "", DALI_KEY_BACKSPACE, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
1376   application.SendNotification();
1377   application.Render();
1378
1379   gAnchorClickedCallBackCalled = false;
1380   // Create a tap event to touch the text field.
1381   TestGenerateTap(application, 30.0f, 25.0f, 5500);
1382   application.SendNotification();
1383   application.Render();
1384
1385   DALI_TEST_CHECK(gAnchorClickedCallBackCalled);
1386
1387   // Remove front of anchor
1388   field.SetProperty(TextField::Property::TEXT, "TIZEN<a href='https://www.tizen.org'>TIZEN</a>");
1389   field.SetProperty(DevelTextField::Property::PRIMARY_CURSOR_POSITION, 3);
1390   application.SendNotification();
1391   application.Render();
1392
1393   application.ProcessEvent(GenerateKey("", "", "", DALI_KEY_BACKSPACE, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
1394   application.SendNotification();
1395   application.Render();
1396
1397   // Remove whole text
1398   field.SetProperty(TextField::Property::TEXT, "<a href='https://www.tizen.org'>TIZEN</a>");
1399   DevelTextField::SelectWholeText(field);
1400   application.SendNotification();
1401   application.Render();
1402
1403   application.ProcessEvent(GenerateKey("", "", "", DALI_KEY_BACKSPACE, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
1404   application.SendNotification();
1405   application.Render();
1406
1407   // Remove all with backspace
1408   field.SetProperty(TextField::Property::TEXT, "<a href='https://www.tizen.org'>T</a>");
1409   field.SetProperty(DevelTextField::Property::PRIMARY_CURSOR_POSITION, 1);
1410   application.SendNotification();
1411   application.Render();
1412
1413   application.ProcessEvent(GenerateKey("", "", "", DALI_KEY_BACKSPACE, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
1414   application.SendNotification();
1415   application.Render();
1416
1417   // Remove all with delete
1418   field.SetProperty(TextField::Property::TEXT, "<a href='https://www.tizen.org'>T</a>");
1419   field.SetProperty(DevelTextField::Property::PRIMARY_CURSOR_POSITION, 0);
1420   application.SendNotification();
1421   application.Render();
1422
1423   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));
1424   application.SendNotification();
1425   application.Render();
1426
1427   END_TEST;
1428 }
1429
1430 // Positive test for the textChanged signal.
1431 int utcDaliTextFieldTextChangedP(void)
1432 {
1433   ToolkitTestApplication application;
1434   tet_infoline(" utcDaliTextFieldTextChangedP");
1435   TextField field = TextField::New();
1436   DALI_TEST_CHECK( field );
1437
1438   application.GetScene().Add( field );
1439
1440   // connect to the text changed signal.
1441   ConnectionTracker* testTracker = new ConnectionTracker();
1442   field.TextChangedSignal().Connect(&TestTextChangedCallback);
1443   bool textChangedSignal = false;
1444   field.ConnectSignal( testTracker, "textChanged",   CallbackFunctor(&textChangedSignal) );
1445
1446   gTextChangedCallBackCalled = false;
1447   field.SetProperty( TextField::Property::TEXT, "ABC" );
1448   DALI_TEST_CHECK( gTextChangedCallBackCalled );
1449   DALI_TEST_CHECK( textChangedSignal );
1450
1451   application.SendNotification();
1452   field.SetKeyInputFocus();
1453
1454   gTextChangedCallBackCalled = false;
1455   application.ProcessEvent( GenerateKey( "D", "", "D", KEY_D_CODE, 0, 0, Integration::KeyEvent::DOWN, "D", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
1456   DALI_TEST_CHECK( gTextChangedCallBackCalled );
1457
1458   // Remove all text
1459   field.SetProperty( TextField::Property::TEXT, "" );
1460
1461   // Pressing backspace key: TextChangedCallback should not be called when there is no text in textfield.
1462   gTextChangedCallBackCalled = false;
1463   application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_BACKSPACE, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
1464   DALI_TEST_CHECK( !gTextChangedCallBackCalled );
1465
1466   // Pressing delete key: TextChangedCallback should not be called when there is no text in textfield.
1467   gTextChangedCallBackCalled = false;
1468   application.ProcessEvent( GenerateKey( "", "", "", Dali::DevelKey::DALI_KEY_DELETE, 0, 0, Integration::KeyEvent::DOWN, "Delete", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
1469   DALI_TEST_CHECK( !gTextChangedCallBackCalled );
1470
1471   END_TEST;
1472 }
1473
1474 int utcDaliTextFieldTextChangedWithInputMethodContext(void)
1475 {
1476   ToolkitTestApplication application;
1477   tet_infoline(" utcDaliTextFieldTextChangedWithInputMethodContext");
1478   TextField field = TextField::New();
1479   DALI_TEST_CHECK( field );
1480
1481
1482   application.GetScene().Add( field );
1483
1484   // connect to the text changed signal.
1485   ConnectionTracker* testTracker = new ConnectionTracker();
1486   field.TextChangedSignal().Connect(&TestTextChangedCallback);
1487   bool textChangedSignal = false;
1488   field.ConnectSignal( testTracker, "textChanged",   CallbackFunctor(&textChangedSignal) );
1489
1490
1491   // get InputMethodContext
1492   std::string text;
1493   InputMethodContext::EventData imfEvent;
1494   InputMethodContext inputMethodContext = DevelTextField::GetInputMethodContext( field );
1495
1496   field.SetKeyInputFocus();
1497   field.SetProperty( DevelTextField::Property::ENABLE_EDITING, true );
1498
1499   // input text
1500   gTextChangedCallBackCalled = false;
1501   imfEvent = InputMethodContext::EventData( InputMethodContext::PRE_EDIT, "ㅎ", 0, 1 );
1502   inputMethodContext.EventReceivedSignal().Emit(inputMethodContext, imfEvent);
1503   application.SendNotification();
1504   application.Render();
1505   DALI_TEST_CHECK( gTextChangedCallBackCalled );
1506   DALI_TEST_EQUALS( field.GetProperty<std::string>( TextField::Property::TEXT ), std::string("ㅎ"), TEST_LOCATION );
1507
1508   gTextChangedCallBackCalled = false;
1509   imfEvent = InputMethodContext::EventData( InputMethodContext::PRE_EDIT, "호", 0, 1 );
1510   inputMethodContext.EventReceivedSignal().Emit(inputMethodContext, imfEvent);
1511   application.SendNotification();
1512   application.Render();
1513   DALI_TEST_CHECK( gTextChangedCallBackCalled );
1514   DALI_TEST_EQUALS( field.GetProperty<std::string>( TextField::Property::TEXT ), std::string("호"), TEST_LOCATION );
1515
1516   gTextChangedCallBackCalled = false;
1517   imfEvent = InputMethodContext::EventData( InputMethodContext::PRE_EDIT, "혿", 0, 1 );
1518   inputMethodContext.EventReceivedSignal().Emit(inputMethodContext, imfEvent);
1519   application.SendNotification();
1520   application.Render();
1521   DALI_TEST_CHECK( gTextChangedCallBackCalled );
1522   DALI_TEST_EQUALS( field.GetProperty<std::string>( TextField::Property::TEXT ), std::string("혿"), TEST_LOCATION );
1523
1524   gTextChangedCallBackCalled = false;
1525   imfEvent = InputMethodContext::EventData( InputMethodContext::PRE_EDIT, "", 0, 1 );
1526   inputMethodContext.EventReceivedSignal().Emit(inputMethodContext, imfEvent);
1527   DALI_TEST_CHECK( !gTextChangedCallBackCalled );
1528
1529   imfEvent = InputMethodContext::EventData( InputMethodContext::COMMIT, "호", 0, 1 );
1530   inputMethodContext.EventReceivedSignal().Emit(inputMethodContext, imfEvent);
1531   DALI_TEST_CHECK( !gTextChangedCallBackCalled );
1532
1533   imfEvent = InputMethodContext::EventData( InputMethodContext::PRE_EDIT, "두", 1, 2 );
1534   inputMethodContext.EventReceivedSignal().Emit(inputMethodContext, imfEvent);
1535   DALI_TEST_CHECK( !gTextChangedCallBackCalled );
1536
1537   application.SendNotification();
1538   application.Render();
1539   DALI_TEST_CHECK( gTextChangedCallBackCalled );
1540   DALI_TEST_EQUALS( field.GetProperty<std::string>( TextField::Property::TEXT ), std::string("호두"), TEST_LOCATION );
1541
1542   END_TEST;
1543 }
1544
1545
1546 // Negative test for the textChanged signal.
1547 int utcDaliTextFieldTextChangedN(void)
1548 {
1549   ToolkitTestApplication application;
1550   tet_infoline(" utcDaliTextFieldTextChangedN");
1551   TextField field = TextField::New();
1552   DALI_TEST_CHECK( field );
1553
1554   application.GetScene().Add( field );
1555
1556   // connect to the text changed signal.
1557   ConnectionTracker* testTracker = new ConnectionTracker();
1558   field.TextChangedSignal().Connect(&TestTextChangedCallback);
1559   bool textChangedSignal = false;
1560   field.ConnectSignal( testTracker, "textChanged",   CallbackFunctor(&textChangedSignal) );
1561
1562   gTextChangedCallBackCalled = false;
1563   field.SetProperty( TextField::Property::PLACEHOLDER_TEXT, "ABC" ); // Setting placeholder, not TEXT
1564   application.SendNotification();
1565   application.Render();
1566   DALI_TEST_CHECK( !gTextChangedCallBackCalled );
1567   DALI_TEST_CHECK( !textChangedSignal );
1568
1569   END_TEST;
1570 }
1571
1572 // Positive test for Max Characters reached signal.
1573 int utcDaliTextFieldMaxCharactersReachedP(void)
1574 {
1575   ToolkitTestApplication application;
1576   tet_infoline(" utcDaliTextFieldMaxCharactersReachedP");
1577   TextField field = TextField::New();
1578   DALI_TEST_CHECK( field );
1579
1580   application.GetScene().Add( field );
1581
1582   const int maxNumberOfCharacters = 1;
1583   field.SetProperty( TextField::Property::MAX_LENGTH, maxNumberOfCharacters );
1584
1585   field.SetKeyInputFocus();
1586
1587   // connect to the text changed signal.
1588   ConnectionTracker* testTracker = new ConnectionTracker();
1589   field.MaxLengthReachedSignal().Connect(&TestMaxLengthReachedCallback);
1590   bool maxLengthReachedSignal = false;
1591   field.ConnectSignal( testTracker, "maxLengthReached",   CallbackFunctor(&maxLengthReachedSignal) );
1592
1593   gMaxCharactersCallBackCalled = false;
1594
1595   application.ProcessEvent( GenerateKey( "a", "", "a", KEY_A_CODE, 0, 0, Integration::KeyEvent::DOWN, "a", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
1596   application.ProcessEvent( GenerateKey( "a", "", "a", KEY_A_CODE, 0, 0, Integration::KeyEvent::DOWN, "a", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
1597
1598   DALI_TEST_CHECK( gMaxCharactersCallBackCalled );
1599   DALI_TEST_CHECK( maxLengthReachedSignal );
1600
1601   END_TEST;
1602 }
1603
1604 // Negative test for Max Characters reached signal.
1605 int utcDaliTextFieldMaxCharactersReachedN(void)
1606 {
1607   ToolkitTestApplication application;
1608   tet_infoline(" utcDaliTextFieldMaxCharactersReachedN");
1609   TextField field = TextField::New();
1610   DALI_TEST_CHECK( field );
1611
1612   application.GetScene().Add( field );
1613
1614   const int maxNumberOfCharacters = 3;
1615   field.SetProperty( TextField::Property::MAX_LENGTH, maxNumberOfCharacters );
1616
1617   field.SetKeyInputFocus();
1618
1619   // connect to the text changed signal.
1620   ConnectionTracker* testTracker = new ConnectionTracker();
1621   field.MaxLengthReachedSignal().Connect(&TestMaxLengthReachedCallback);
1622   bool maxLengthReachedSignal = false;
1623   field.ConnectSignal( testTracker, "maxLengthReached",   CallbackFunctor(&maxLengthReachedSignal) );
1624
1625   gMaxCharactersCallBackCalled = false;
1626
1627   application.ProcessEvent( GenerateKey( "a", "", "a", KEY_A_CODE, 0, 0, Integration::KeyEvent::DOWN, "a", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
1628   application.ProcessEvent( GenerateKey( "a", "", "a", KEY_A_CODE, 0, 0, Integration::KeyEvent::DOWN, "a", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
1629
1630   DALI_TEST_CHECK( !gMaxCharactersCallBackCalled );
1631   DALI_TEST_CHECK( !maxLengthReachedSignal );
1632
1633   application.ProcessEvent( GenerateKey( "Return", "", "\r", KEY_RETURN_CODE, 0, 0, Integration::KeyEvent::DOWN, "\r", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
1634
1635   DALI_TEST_CHECK( !gMaxCharactersCallBackCalled );
1636   DALI_TEST_CHECK( !maxLengthReachedSignal );
1637
1638   END_TEST;
1639 }
1640
1641 // Positive test for Input Filtered signal.
1642 int utcDaliTextFieldInputFilteredP(void)
1643 {
1644   ToolkitTestApplication application;
1645   tet_infoline(" utcDaliTextFieldInputFilteredP");
1646   TextField field = TextField::New();
1647   DALI_TEST_CHECK(field);
1648
1649   application.GetScene().Add(field);
1650
1651   Property::Map inputFilter;
1652
1653   // Only digit is accepted.
1654   inputFilter[InputFilter::Property::ACCEPTED] = "[\\d]";
1655
1656   // Set input filter to TextField.
1657   field.SetProperty(DevelTextField::Property::INPUT_FILTER, inputFilter);
1658
1659   field.SetKeyInputFocus();
1660
1661   // connect to the input filtered signal.
1662   ConnectionTracker* testTracker = new ConnectionTracker();
1663   DevelTextField::InputFilteredSignal(field).Connect(&TestInputFilteredCallback);
1664   bool inputFilteredSignal = false;
1665   field.ConnectSignal(testTracker, "inputFiltered", CallbackFunctor(&inputFilteredSignal));
1666
1667   gInputFilteredAcceptedCallbackCalled = false;
1668
1669   application.ProcessEvent(GenerateKey( "a", "", "a", KEY_A_CODE, 0, 0, Integration::KeyEvent::DOWN, "a", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ));
1670
1671   DALI_TEST_CHECK(gInputFilteredAcceptedCallbackCalled);
1672   DALI_TEST_CHECK(inputFilteredSignal);
1673
1674   // Word is rejected.
1675   inputFilter[InputFilter::Property::ACCEPTED] = "";
1676   inputFilter[InputFilter::Property::REJECTED] = "[\\w]";
1677
1678   // Set input filter to TextField.
1679   field.SetProperty(DevelTextField::Property::INPUT_FILTER, inputFilter);
1680
1681   field.SetKeyInputFocus();
1682
1683   inputFilteredSignal = false;
1684   gInputFilteredRejectedCallbackCalled = false;
1685
1686   application.ProcessEvent(GenerateKey( "a", "", "a", KEY_A_CODE, 0, 0, Integration::KeyEvent::DOWN, "a", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
1687
1688   DALI_TEST_CHECK(gInputFilteredAcceptedCallbackCalled);
1689   DALI_TEST_CHECK(inputFilteredSignal);
1690
1691   END_TEST;
1692 }
1693
1694 // Negative test for Input Filtered signal.
1695 int utcDaliTextFieldInputFilteredN(void)
1696 {
1697   ToolkitTestApplication application;
1698   tet_infoline(" utcDaliTextFieldInputFilteredP");
1699   TextField field = TextField::New();
1700   DALI_TEST_CHECK(field);
1701
1702   application.GetScene().Add(field);
1703
1704   Property::Map inputFilter;
1705
1706   // Only word is accepted.
1707   inputFilter[InputFilter::Property::ACCEPTED] = "[\\w]";
1708
1709   // Set input filter to TextField.
1710   field.SetProperty(DevelTextField::Property::INPUT_FILTER, inputFilter);
1711
1712   field.SetKeyInputFocus();
1713
1714   // connect to the input filtered signal.
1715   ConnectionTracker* testTracker = new ConnectionTracker();
1716   DevelTextField::InputFilteredSignal(field).Connect(&TestInputFilteredCallback);
1717   bool inputFilteredSignal = false;
1718   field.ConnectSignal(testTracker, "inputFiltered", CallbackFunctor(&inputFilteredSignal));
1719
1720   gInputFilteredAcceptedCallbackCalled = false;
1721
1722   // Key a, d should not be filtered.
1723   application.ProcessEvent(GenerateKey("a", "", "a", KEY_A_CODE, 0, 0, Integration::KeyEvent::DOWN, "a", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
1724   application.ProcessEvent(GenerateKey("a", "", "a", KEY_A_CODE, 0, 0, Integration::KeyEvent::UP, "a", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
1725   application.ProcessEvent(GenerateKey("d", "", "d", KEY_D_CODE, 0, 0, Integration::KeyEvent::DOWN, "d", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
1726   application.ProcessEvent(GenerateKey("d", "", "d", KEY_D_CODE, 0, 0, Integration::KeyEvent::UP, "d", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
1727
1728   // Backspace, Delete should not be filtered.
1729   application.ProcessEvent(GenerateKey( "", "", "", DALI_KEY_BACKSPACE, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
1730   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));
1731
1732   // Render and notify
1733   application.SendNotification();
1734   application.Render();
1735
1736   DALI_TEST_CHECK(!gInputFilteredAcceptedCallbackCalled);
1737   DALI_TEST_CHECK(!inputFilteredSignal);
1738
1739   // Digit is rejected.
1740   inputFilter[InputFilter::Property::ACCEPTED] = "";
1741   inputFilter[InputFilter::Property::REJECTED] = "[\\d]";
1742
1743   field.SetProperty(DevelTextField::Property::INPUT_FILTER, inputFilter);
1744
1745   field.SetKeyInputFocus();
1746
1747   inputFilteredSignal = false;
1748   gInputFilteredRejectedCallbackCalled = false;
1749
1750   // Key a, d should not be filtered.
1751   application.ProcessEvent(GenerateKey("a", "", "a", KEY_A_CODE, 0, 0, Integration::KeyEvent::DOWN, "a", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
1752   application.ProcessEvent(GenerateKey("a", "", "a", KEY_A_CODE, 0, 0, Integration::KeyEvent::UP, "a", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
1753   application.ProcessEvent(GenerateKey("d", "", "d", KEY_D_CODE, 0, 0, Integration::KeyEvent::DOWN, "d", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
1754   application.ProcessEvent(GenerateKey("d", "", "d", KEY_D_CODE, 0, 0, Integration::KeyEvent::UP, "d", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
1755
1756   // Backspace, Delete should not be filtered.
1757   application.ProcessEvent(GenerateKey( "", "", "", DALI_KEY_BACKSPACE, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
1758   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));
1759
1760   // Render and notify
1761   application.SendNotification();
1762   application.Render();
1763
1764   DALI_TEST_CHECK(!gInputFilteredAcceptedCallbackCalled);
1765   DALI_TEST_CHECK(!inputFilteredSignal);
1766
1767   END_TEST;
1768 }
1769
1770 int utcDaliTextFieldInputStyleChanged01(void)
1771 {
1772   // The text-field emits signals when the input style changes. These changes of style are
1773   // detected during the relayout process (size negotiation), i.e after the cursor has been moved. Signals
1774   // can't be emitted during the size negotiation as the callbacks may update the UI.
1775   // The text-field adds an idle callback to the adaptor to emit the signals after the size negotiation.
1776   // The ToolkitTestApplication creates an implementation of the adaptor stub and a queue of idle callbacks.
1777   ToolkitTestApplication application;
1778   tet_infoline(" utcDaliTextFieldInputStyleChanged01");
1779
1780   // Load some fonts.
1781
1782   char* pathNamePtr = get_current_dir_name();
1783   const std::string pathName( pathNamePtr );
1784   free( pathNamePtr );
1785
1786   TextAbstraction::FontClient fontClient = TextAbstraction::FontClient::Get();
1787   fontClient.SetDpi( 93u, 93u );
1788
1789   fontClient.GetFontId( pathName + DEFAULT_FONT_DIR + "/dejavu/DejaVuSerif.ttf", DEFAULT_FONT_SIZE );
1790   fontClient.GetFontId( pathName + DEFAULT_FONT_DIR + "/dejavu/DejaVuSerif-Bold.ttf", DEFAULT_FONT_SIZE );
1791
1792   TextField field = TextField::New();
1793   DALI_TEST_CHECK( field );
1794
1795
1796   field.SetProperty( Actor::Property::SIZE, Vector2( 300.f, 50.f ) );
1797   field.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT );
1798   field.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT );
1799
1800   field.SetProperty( TextField::Property::ENABLE_MARKUP, true );
1801   field.SetProperty( TextField::Property::TEXT, "<font family='DejaVuSerif' size='18'>He<color value='green'>llo</color> <font weight='bold'>world</font> demo</font>" );
1802
1803   // connect to the text changed signal.
1804   ConnectionTracker* testTracker = new ConnectionTracker();
1805   field.InputStyleChangedSignal().Connect( &TestInputStyleChangedCallback );
1806   bool inputStyleChangedSignal = false;
1807   field.ConnectSignal( testTracker, "inputStyleChanged",   CallbackFunctor(&inputStyleChangedSignal) );
1808
1809   application.GetScene().Add( field );
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   gInputStyleChangedCallbackCalled = false;
1819   gInputStyleMask = TextField::InputStyle::NONE;
1820   inputStyleChangedSignal = false;
1821
1822   // Create a tap event to touch the text field.
1823   TestGenerateTap( application, 18.0f, 25.0f );
1824
1825   // Render and notify
1826   application.SendNotification();
1827   application.Render();
1828
1829   // Executes the idle callbacks added by the text control on the change of input style.
1830   application.RunIdles();
1831
1832   DALI_TEST_CHECK( gInputStyleChangedCallbackCalled );
1833   if( gInputStyleChangedCallbackCalled )
1834   {
1835     DALI_TEST_EQUALS( static_cast<unsigned int>( gInputStyleMask ), static_cast<unsigned int>( TextField::InputStyle::FONT_FAMILY | TextField::InputStyle::POINT_SIZE ), TEST_LOCATION );
1836
1837     const std::string fontFamily = field.GetProperty( TextField::Property::INPUT_FONT_FAMILY ).Get<std::string>();
1838     DALI_TEST_EQUALS( fontFamily, "DejaVuSerif", TEST_LOCATION );
1839
1840     const float pointSize = field.GetProperty( TextField::Property::INPUT_POINT_SIZE ).Get<float>();
1841     DALI_TEST_EQUALS( pointSize, 18.f, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
1842   }
1843   DALI_TEST_CHECK( inputStyleChangedSignal );
1844
1845   gInputStyleChangedCallbackCalled = false;
1846   gInputStyleMask = TextField::InputStyle::NONE;
1847   inputStyleChangedSignal = false;
1848
1849   // Create a tap event to touch the text field.
1850   TestGenerateTap( application, 30.0f, 25.0f );
1851
1852   // Render and notify
1853   application.SendNotification();
1854   application.Render();
1855
1856   // Executes the idle callbacks added by the text control on the change of input style.
1857   application.RunIdles();
1858
1859   DALI_TEST_CHECK( !gInputStyleChangedCallbackCalled );
1860   DALI_TEST_CHECK( !inputStyleChangedSignal );
1861
1862   gInputStyleChangedCallbackCalled = false;
1863   gInputStyleMask = TextField::InputStyle::NONE;
1864   inputStyleChangedSignal = false;
1865
1866   // Create a tap event to touch the text field.
1867   TestGenerateTap( application, 43.0f, 25.0f );
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   if( gInputStyleChangedCallbackCalled )
1878   {
1879     DALI_TEST_EQUALS( static_cast<unsigned int>( gInputStyleMask ), static_cast<unsigned int>( TextField::InputStyle::COLOR ), TEST_LOCATION );
1880
1881     const Vector4 color = field.GetProperty( TextField::Property::INPUT_COLOR ).Get<Vector4>();
1882     DALI_TEST_EQUALS( color, Color::GREEN, TEST_LOCATION );
1883   }
1884   DALI_TEST_CHECK( inputStyleChangedSignal );
1885
1886   gInputStyleChangedCallbackCalled = false;
1887   gInputStyleMask = TextField::InputStyle::NONE;
1888   inputStyleChangedSignal = false;
1889
1890   // Create a tap event to touch the text field.
1891   TestGenerateTap( application, 88.0f, 25.0f );
1892
1893   // Render and notify
1894   application.SendNotification();
1895   application.Render();
1896
1897   // Executes the idle callbacks added by the text control on the change of input style.
1898   application.RunIdles();
1899
1900   DALI_TEST_CHECK( gInputStyleChangedCallbackCalled );
1901   if( gInputStyleChangedCallbackCalled )
1902   {
1903     DALI_TEST_EQUALS( static_cast<unsigned int>( gInputStyleMask ), static_cast<unsigned int>( TextField::InputStyle::COLOR | TextField::InputStyle::FONT_STYLE ), TEST_LOCATION );
1904
1905     const Vector4 color = field.GetProperty( TextField::Property::INPUT_COLOR ).Get<Vector4>();
1906     DALI_TEST_EQUALS( color, Color::BLACK, TEST_LOCATION );
1907
1908     const Property::Map fontStyleMapGet = field.GetProperty( TextField::Property::INPUT_FONT_STYLE ).Get<Property::Map>();
1909
1910     Property::Map fontStyleMapSet;
1911     fontStyleMapSet.Insert( "weight", "bold" );
1912
1913     DALI_TEST_EQUALS( fontStyleMapGet.Count(), fontStyleMapSet.Count(), TEST_LOCATION );
1914     DALI_TEST_EQUALS( DaliTestCheckMaps( fontStyleMapGet, fontStyleMapSet ), true, TEST_LOCATION );
1915   }
1916   DALI_TEST_CHECK( inputStyleChangedSignal );
1917
1918   gInputStyleChangedCallbackCalled = false;
1919   gInputStyleMask = TextField::InputStyle::NONE;
1920   inputStyleChangedSignal = false;
1921
1922   // Create a tap event to touch the text field.
1923   TestGenerateTap( application, 115.0f, 25.0f );
1924
1925   // Render and notify
1926   application.SendNotification();
1927   application.Render();
1928
1929   // Executes the idle callbacks added by the text control on the change of input style.
1930   application.RunIdles();
1931
1932   DALI_TEST_CHECK( !gInputStyleChangedCallbackCalled );
1933   DALI_TEST_CHECK( !inputStyleChangedSignal );
1934
1935   gInputStyleChangedCallbackCalled = false;
1936   gInputStyleMask = TextField::InputStyle::NONE;
1937   inputStyleChangedSignal = false;
1938
1939   // Create a tap event to touch the text field.
1940   TestGenerateTap( application, 164.0f, 25.0f );
1941
1942   // Render and notify
1943   application.SendNotification();
1944   application.Render();
1945
1946   // Executes the idle callbacks added by the text control on the change of input style.
1947   application.RunIdles();
1948
1949   DALI_TEST_CHECK( gInputStyleChangedCallbackCalled );
1950   if( gInputStyleChangedCallbackCalled )
1951   {
1952     DALI_TEST_EQUALS( static_cast<unsigned int>( gInputStyleMask ), static_cast<unsigned int>( TextField::InputStyle::FONT_STYLE ), TEST_LOCATION );
1953
1954     const std::string style = field.GetProperty( TextField::Property::INPUT_FONT_STYLE ).Get<std::string>();
1955     DALI_TEST_CHECK( style.empty() );
1956   }
1957   DALI_TEST_CHECK( inputStyleChangedSignal );
1958
1959   gInputStyleChangedCallbackCalled = false;
1960   gInputStyleMask = TextField::InputStyle::NONE;
1961   inputStyleChangedSignal = false;
1962
1963   // Create a tap event to touch the text field.
1964   TestGenerateTap( application, 191.0f, 25.0f );
1965
1966   // Render and notify
1967   application.SendNotification();
1968   application.Render();
1969
1970   // Executes the idle callbacks added by the text control on the change of input style.
1971   application.RunIdles();
1972
1973   DALI_TEST_CHECK( !gInputStyleChangedCallbackCalled );
1974   DALI_TEST_CHECK( !inputStyleChangedSignal );
1975
1976   END_TEST;
1977 }
1978
1979 int utcDaliTextFieldInputStyleChanged02(void)
1980 {
1981   // The text-field emits signals when the input style changes. These changes of style are
1982   // detected during the relayout process (size negotiation), i.e after the cursor has been moved. Signals
1983   // can't be emitted during the size negotiation as the callbacks may update the UI.
1984   // The text-field adds an idle callback to the adaptor to emit the signals after the size negotiation.
1985   // The ToolkitTestApplication creates an implementation of the adaptor stub and a queue of idle callbacks.
1986   ToolkitTestApplication application;
1987   tet_infoline(" utcDaliTextFieldInputStyleChanged02");
1988
1989   // Load some fonts.
1990
1991   char* pathNamePtr = get_current_dir_name();
1992   const std::string pathName( pathNamePtr );
1993   free( pathNamePtr );
1994
1995   TextAbstraction::FontClient fontClient = TextAbstraction::FontClient::Get();
1996   fontClient.SetDpi( 93u, 93u );
1997
1998   fontClient.GetFontId( pathName + DEFAULT_FONT_DIR + "/dejavu/DejaVuSerif.ttf", DEFAULT_FONT_SIZE );
1999   fontClient.GetFontId( pathName + DEFAULT_FONT_DIR + "/dejavu/DejaVuSerif-Bold.ttf", DEFAULT_FONT_SIZE );
2000
2001   TextField field = TextField::New();
2002   DALI_TEST_CHECK( field );
2003
2004   field.SetProperty( Actor::Property::SIZE, Vector2( 300.f, 50.f ) );
2005   field.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT );
2006   field.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT );
2007
2008   field.SetProperty( TextField::Property::ENABLE_MARKUP, true );
2009   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>" );
2010
2011   // connect to the text changed signal.
2012   ConnectionTracker* testTracker = new ConnectionTracker();
2013   field.InputStyleChangedSignal().Connect( &TestInputStyleChangedCallback );
2014   bool inputStyleChangedSignal = false;
2015   field.ConnectSignal( testTracker, "inputStyleChanged",   CallbackFunctor(&inputStyleChangedSignal) );
2016
2017   application.GetScene().Add( field );
2018
2019   // Render and notify
2020   application.SendNotification();
2021   application.Render();
2022
2023   // Executes the idle callbacks added by the text control on the change of input style.
2024   application.RunIdles();
2025
2026   gInputStyleChangedCallbackCalled = false;
2027   gInputStyleMask = TextField::InputStyle::NONE;
2028   inputStyleChangedSignal = false;
2029
2030   // Create a tap event to touch the text field.
2031   TestGenerateTap( application, 53.0f, 25.0f, 100 );
2032   TestGenerateTap( application, 53.0f, 25.0f, 200 );
2033
2034   // Render and notify
2035   application.SendNotification();
2036   application.Render();
2037
2038   // Executes the idle callbacks added by the text control on the change of input style.
2039   application.RunIdles();
2040
2041   DALI_TEST_CHECK( gInputStyleChangedCallbackCalled );
2042   if( gInputStyleChangedCallbackCalled )
2043   {
2044     DALI_TEST_EQUALS( static_cast<unsigned int>( gInputStyleMask ),
2045                       static_cast<unsigned int>( TextField::InputStyle::FONT_FAMILY |
2046                                                  TextField::InputStyle::POINT_SIZE  |
2047                                                  TextField::InputStyle::COLOR ),
2048                       TEST_LOCATION );
2049
2050     const Vector4 color = field.GetProperty( TextField::Property::INPUT_COLOR ).Get<Vector4>();
2051     DALI_TEST_EQUALS( color, Color::GREEN, TEST_LOCATION );
2052
2053     const std::string fontFamily = field.GetProperty( TextField::Property::INPUT_FONT_FAMILY ).Get<std::string>();
2054     DALI_TEST_EQUALS( fontFamily, "DejaVuSerif", TEST_LOCATION );
2055
2056     const float pointSize = field.GetProperty( TextField::Property::INPUT_POINT_SIZE ).Get<float>();
2057     DALI_TEST_EQUALS( pointSize, 18.f, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
2058   }
2059   DALI_TEST_CHECK( inputStyleChangedSignal );
2060
2061   gInputStyleChangedCallbackCalled = false;
2062   gInputStyleMask = TextField::InputStyle::NONE;
2063   inputStyleChangedSignal = false;
2064
2065   application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_BACKSPACE, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2066
2067   // Render and notify
2068   application.SendNotification();
2069   application.Render();
2070
2071   // Executes the idle callbacks added by the text control on the change of input style.
2072   application.RunIdles();
2073
2074   DALI_TEST_CHECK( gInputStyleChangedCallbackCalled );
2075   if( gInputStyleChangedCallbackCalled )
2076   {
2077     DALI_TEST_EQUALS( static_cast<unsigned int>( gInputStyleMask ),
2078                       static_cast<unsigned int>( TextField::InputStyle::COLOR ),
2079                       TEST_LOCATION );
2080
2081     const Vector4 color = field.GetProperty( TextField::Property::INPUT_COLOR ).Get<Vector4>();
2082     DALI_TEST_EQUALS( color, Color::BLUE, TEST_LOCATION );
2083   }
2084   DALI_TEST_CHECK( inputStyleChangedSignal );
2085
2086   gInputStyleChangedCallbackCalled = false;
2087   gInputStyleMask = TextField::InputStyle::NONE;
2088   inputStyleChangedSignal = false;
2089
2090   application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_BACKSPACE, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2091
2092   // Render and notify
2093   application.SendNotification();
2094   application.Render();
2095
2096   // Executes the idle callbacks added by the text control on the change of input style.
2097   application.RunIdles();
2098
2099   DALI_TEST_CHECK( !gInputStyleChangedCallbackCalled );
2100   DALI_TEST_CHECK( !inputStyleChangedSignal );
2101
2102   gInputStyleChangedCallbackCalled = false;
2103   gInputStyleMask = TextField::InputStyle::NONE;
2104   inputStyleChangedSignal = false;
2105
2106   application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_BACKSPACE, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2107
2108   // Render and notify
2109   application.SendNotification();
2110   application.Render();
2111
2112   // Executes the idle callbacks added by the text control on the change of input style.
2113   application.RunIdles();
2114
2115   DALI_TEST_CHECK( gInputStyleChangedCallbackCalled );
2116   if( gInputStyleChangedCallbackCalled )
2117   {
2118     DALI_TEST_EQUALS( static_cast<unsigned int>( gInputStyleMask ),
2119                       static_cast<unsigned int>( TextField::InputStyle::COLOR ),
2120                       TEST_LOCATION );
2121
2122     const Vector4 color = field.GetProperty( TextField::Property::INPUT_COLOR ).Get<Vector4>();
2123     DALI_TEST_EQUALS( color, Color::BLACK, TEST_LOCATION );
2124   }
2125   DALI_TEST_CHECK( inputStyleChangedSignal );
2126
2127   gInputStyleChangedCallbackCalled = false;
2128   gInputStyleMask = TextField::InputStyle::NONE;
2129   inputStyleChangedSignal = false;
2130
2131   field.SetProperty( TextField::Property::INPUT_COLOR, Color::YELLOW );
2132
2133   Property::Map fontStyleMapSet;
2134   fontStyleMapSet.Insert( "weight", "thin" );
2135   fontStyleMapSet.Insert( "width", "condensed" );
2136   fontStyleMapSet.Insert( "slant", "italic" );
2137
2138   field.SetProperty( TextField::Property::INPUT_FONT_STYLE, fontStyleMapSet );
2139   field.SetProperty( TextField::Property::INPUT_POINT_SIZE, 20.f );
2140
2141   field.SetProperty( TextField::Property::INPUT_UNDERLINE, "underline" );
2142   field.SetProperty( TextField::Property::INPUT_SHADOW, "shadow" );
2143   field.SetProperty( TextField::Property::INPUT_EMBOSS, "emboss" );
2144   field.SetProperty( TextField::Property::INPUT_OUTLINE, "outline" );
2145   field.SetProperty( DevelTextField::Property::INPUT_STRIKETHROUGH, "strikethrough" );
2146
2147   // Render and notify
2148   application.SendNotification();
2149   application.Render();
2150
2151   // Executes the idle callbacks added by the text control on the change of input style.
2152   application.RunIdles();
2153
2154   DALI_TEST_CHECK( !gInputStyleChangedCallbackCalled );
2155   DALI_TEST_CHECK( !inputStyleChangedSignal );
2156
2157   // Create a tap event to touch the text field.
2158   TestGenerateTap( application, 63.0f, 25.0f, 700 );
2159
2160   // Render and notify
2161   application.SendNotification();
2162   application.Render();
2163
2164   // Executes the idle callbacks added by the text control on the change of input style.
2165   application.RunIdles();
2166
2167   DALI_TEST_CHECK( gInputStyleChangedCallbackCalled );
2168   if( gInputStyleChangedCallbackCalled )
2169   {
2170     DALI_TEST_EQUALS( static_cast<unsigned int>( gInputStyleMask ),
2171                       static_cast<unsigned int>( TextField::InputStyle::COLOR |
2172                                                  TextField::InputStyle::POINT_SIZE |
2173                                                  TextField::InputStyle::FONT_STYLE |
2174                                                  TextField::InputStyle::UNDERLINE |
2175                                                  TextField::InputStyle::SHADOW |
2176                                                  TextField::InputStyle::EMBOSS |
2177                                                  TextField::InputStyle::OUTLINE ),
2178                       TEST_LOCATION );
2179
2180     const Vector4 color = field.GetProperty( TextField::Property::INPUT_COLOR ).Get<Vector4>();
2181     DALI_TEST_EQUALS( color, Color::BLACK, TEST_LOCATION );
2182   }
2183   DALI_TEST_CHECK( inputStyleChangedSignal );
2184
2185   END_TEST;
2186 }
2187
2188 int utcDaliTextFieldEvent01(void)
2189 {
2190   ToolkitTestApplication application;
2191   tet_infoline(" utcDaliTextFieldEvent01");
2192
2193   // Creates a tap event. After creating a tap event the text field should
2194   // have the focus and add text with key events should be possible.
2195
2196   TextField field = TextField::New();
2197   DALI_TEST_CHECK( field );
2198
2199   application.GetScene().Add( field );
2200
2201   field.SetProperty( Actor::Property::SIZE, Vector2( 300.f, 50.f ) );
2202   field.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT );
2203   field.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT );
2204
2205   // Render and notify
2206   application.SendNotification();
2207   application.Render();
2208
2209   // Avoid a crash when core load gl resources.
2210   application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
2211
2212   // Render and notify
2213   application.SendNotification();
2214   application.Render();
2215
2216   // Add a key event but as the text field has not the focus it should do nothing.
2217   application.ProcessEvent( GenerateKey( "a", "", "a", KEY_A_CODE, 0, 0, Integration::KeyEvent::DOWN, "a", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2218
2219   // Render and notify
2220   application.SendNotification();
2221   application.Render();
2222
2223   DALI_TEST_EQUALS( field.GetProperty<std::string>( TextField::Property::TEXT ), std::string(""), TEST_LOCATION );
2224
2225   // Create a tap event to touch the text field.
2226   TestGenerateTap( application, 150.0f, 25.0f );
2227
2228   // Render and notify
2229   application.SendNotification();
2230   application.Render();
2231
2232   // Pressing delete key should be fine even if there is no text in TextField.
2233   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 ) );
2234   // Render and notify
2235   application.SendNotification();
2236   application.Render();
2237
2238   // Now the text field has the focus, so it can handle the key events.
2239   application.ProcessEvent( GenerateKey( "a", "", "a", KEY_A_CODE, 0, 0, Integration::KeyEvent::DOWN, "a", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2240   application.ProcessEvent( GenerateKey( "a", "", "a", KEY_A_CODE, 0, 0, Integration::KeyEvent::DOWN, "a", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2241
2242   // Render and notify
2243   application.SendNotification();
2244   application.Render();
2245
2246   DALI_TEST_EQUALS( field.GetProperty<std::string>( TextField::Property::TEXT ), std::string("aa"), TEST_LOCATION );
2247
2248   // Create a second text field and send key events to it.
2249   TextField field2 = TextField::New();
2250
2251   field2.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT );
2252   field2.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT );
2253   field2.SetProperty( Actor::Property::SIZE, Vector2( 100.f, 100.f ) );
2254   field2.SetProperty( Actor::Property::POSITION, Vector2( 100.0f, 100.0f ));
2255
2256   application.GetScene().Add( field2 );
2257
2258   // Render and notify
2259   application.SendNotification();
2260   application.Render();
2261
2262   // Create a tap event on the second text field.
2263   TestGenerateTap( application, 150.0f, 125.0f );
2264
2265   // Render and notify
2266   application.SendNotification();
2267   application.Render();
2268
2269   // The second text field has the focus. It should handle the key events.
2270   application.ProcessEvent( GenerateKey( "a", "", "a", KEY_A_CODE, 0, 0, Integration::KeyEvent::DOWN, "a", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2271   application.ProcessEvent( GenerateKey( "a", "", "a", KEY_A_CODE, 0, 0, Integration::KeyEvent::DOWN, "a", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2272
2273   // Render and notify
2274   application.SendNotification();
2275   application.Render();
2276
2277   // Check the text has been added to the second text field.
2278   DALI_TEST_EQUALS( field2.GetProperty<std::string>( TextField::Property::TEXT ), std::string("aa"), TEST_LOCATION );
2279
2280   END_TEST;
2281 }
2282
2283 int utcDaliTextFieldEvent02(void)
2284 {
2285   ToolkitTestApplication application;
2286   tet_infoline(" utcDaliTextFieldEvent02");
2287
2288   // Checks if the right number of actors are created.
2289
2290   TextField field = TextField::New();
2291   field.SetProperty( TextField::Property::POINT_SIZE, 10.f );
2292   DALI_TEST_CHECK( field );
2293   LoadMarkerImages(application, field);
2294
2295   application.GetScene().Add( field );
2296
2297   field.SetProperty( Actor::Property::SIZE, Vector2( 300.f, 50.f ) );
2298   field.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT );
2299   field.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT );
2300
2301   // Avoid a crash when core load gl resources.
2302   application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
2303
2304   // Render and notify
2305   application.SendNotification();
2306   application.Render();
2307
2308   // Check there are the expected number of children ( stencil ).
2309   DALI_TEST_EQUALS( field.GetChildCount(), 1u, TEST_LOCATION );
2310
2311   Actor stencil = field.GetChildAt( 0u );
2312   DALI_TEST_EQUALS( stencil.GetChildCount(), 0u, TEST_LOCATION );
2313
2314   // Create a tap event to touch the text field.
2315   TestGenerateTap( application, 150.0f, 25.0f, 300 );
2316
2317   // Render and notify
2318   application.SendNotification();
2319   application.Render();
2320
2321   Actor layer = field.GetChildAt( 1u );
2322   DALI_TEST_EQUALS( layer.GetChildCount(), 1u, TEST_LOCATION ); // The cursor.
2323   DALI_TEST_EQUALS( stencil.GetChildCount(), 0u, TEST_LOCATION );
2324
2325   // Now the text field has the focus, so it can handle the key events.
2326   application.ProcessEvent( GenerateKey( "a", "", "a", KEY_A_CODE, 0, 0, Integration::KeyEvent::DOWN, "a", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2327   application.ProcessEvent( GenerateKey( "a", "", "a", KEY_A_CODE, 0, 0, Integration::KeyEvent::DOWN, "a", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2328
2329   // Render and notify
2330   application.SendNotification();
2331   application.Render();
2332
2333   // Checks the cursor and the renderer have been created.
2334   DALI_TEST_EQUALS( layer.GetChildCount(), 1u, TEST_LOCATION ); // The cursor.
2335   DALI_TEST_EQUALS( stencil.GetChildCount(), 1u, TEST_LOCATION ); // The renderer
2336
2337   Control cursor = Control::DownCast( layer.GetChildAt( 0u ) );
2338   DALI_TEST_CHECK( cursor );
2339
2340   // The offscreen root actor has a container with all the actors which contain the text renderers.
2341   Actor container = stencil.GetChildAt( 0u );
2342   for( unsigned int index = 0; index < container.GetChildCount(); ++index )
2343   {
2344     Renderer renderer = container.GetChildAt( index ).GetRendererAt( 0u );
2345     DALI_TEST_CHECK( renderer );
2346   }
2347
2348   // Move the cursor and check the position changes.
2349   Vector3 position1 = cursor.GetCurrentProperty< Vector3 >( Actor::Property::POSITION );
2350   application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_LEFT, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2351
2352   // Render and notify
2353   application.SendNotification();
2354   application.Render();
2355
2356   Vector3 position2 = cursor.GetCurrentProperty< Vector3 >( Actor::Property::POSITION );
2357   DALI_TEST_CHECK( position2.x < position1.x );
2358
2359   application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_RIGHT, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2360
2361   // Render and notify
2362   application.SendNotification();
2363   application.Render();
2364
2365   Vector3 position3 = cursor.GetCurrentProperty< Vector3 >( Actor::Property::POSITION );
2366   DALI_TEST_EQUALS( position1, position3, TEST_LOCATION ); // Should be in the same position1.
2367
2368
2369   // Move the cursor to the first position.
2370   application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_LEFT, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2371   application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_LEFT, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2372
2373   // Render and notify
2374   application.SendNotification();
2375   application.Render();
2376
2377   Vector3 position4 = cursor.GetCurrentProperty< Vector3 >( Actor::Property::POSITION );
2378
2379   // Send some taps and check the cursor positions.
2380
2381   // Try to tap at the beginning.
2382   TestGenerateTap( application, 1.0f, 25.0f, 900 );
2383
2384   // Render and notify
2385   application.SendNotification();
2386   application.Render();
2387
2388   // Cursor position should be the same than position1.
2389   Vector3 position5 = cursor.GetCurrentProperty< Vector3 >( Actor::Property::POSITION );
2390
2391   DALI_TEST_EQUALS( position4, position5, TEST_LOCATION ); // Should be in the same position2.
2392
2393   // Tap away from the start position.
2394   TestGenerateTap( application, 16.0f, 25.0f, 1500 );
2395
2396   // Render and notify
2397   application.SendNotification();
2398   application.Render();
2399
2400   Vector3 position6 = cursor.GetCurrentProperty< Vector3 >( Actor::Property::POSITION );
2401
2402   DALI_TEST_CHECK( position6.x > position5.x );
2403
2404   // Remove all the text.
2405   application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_BACKSPACE, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2406   application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_BACKSPACE, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2407   field.SetProperty( TextField::Property::TEXT, "" );
2408
2409   // Render and notify
2410   application.SendNotification();
2411   application.Render();
2412
2413   // Cursor position should be the same than position2.
2414   Vector3 position7 = cursor.GetCurrentProperty< Vector3 >( Actor::Property::POSITION );
2415
2416   DALI_TEST_EQUALS( position4, position7, TEST_LOCATION );// Should be in the same position2.
2417
2418   // Should not be a renderer.
2419   DALI_TEST_EQUALS( stencil.GetChildCount(), 0u, TEST_LOCATION );
2420
2421   // Chanege exceed policy (EXCEED_POLICY_ORIGINAL doesn't use stencil )
2422   field.SetProperty( TextField::Property::TEXT, "This is a long text for the size of the text-field." );
2423   field.SetProperty( TextField::Property::EXCEED_POLICY, Dali::Toolkit::TextField::EXCEED_POLICY_ORIGINAL );
2424
2425   application.SendNotification();
2426   application.Render();
2427
2428   // There are renderer and decorator layer
2429   DALI_TEST_EQUALS( field.GetChildCount(), 2u, TEST_LOCATION );
2430
2431   END_TEST;
2432 }
2433
2434 int utcDaliTextFieldEvent03(void)
2435 {
2436   ToolkitTestApplication application;
2437   tet_infoline(" utcDaliTextFieldEvent03");
2438
2439   // Checks if the highlight actor is created.
2440
2441   TextField field = TextField::New();
2442   DALI_TEST_CHECK( field );
2443
2444   application.GetScene().Add( field );
2445
2446   field.SetProperty( TextField::Property::TEXT, "This is a long text for the size of the text-field." );
2447   field.SetProperty( TextField::Property::POINT_SIZE, 10.f );
2448   field.SetProperty( Actor::Property::SIZE, Vector2( 30.f, 50.f ) );
2449   field.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT );
2450   field.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT );
2451
2452   // Avoid a crash when core load gl resources.
2453   application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
2454   LoadMarkerImages(application, field);
2455
2456   // Render and notify
2457   application.SendNotification();
2458   application.Render();
2459
2460   // Tap first to get the focus.
2461   TestGenerateTap( application, 3.0f, 25.0f );
2462
2463   // Render and notify
2464   application.SendNotification();
2465   application.Render();
2466
2467   // Double tap to select a word.
2468   TestGenerateTap( application, 3.0f, 25.0f );
2469
2470   // Render and notify
2471   application.SendNotification();
2472   application.Render();
2473
2474   // The offscreen root actor should have two actors: the renderer and the highlight actor.
2475   Actor stencil = field.GetChildAt( 0u );
2476
2477   // The highlight actor is drawn first, so is the first actor in the list
2478   Renderer highlight = stencil.GetChildAt( 0u ).GetRendererAt( 0u );
2479   DALI_TEST_CHECK( highlight );
2480
2481   // The offscreen root actor has a container with all the actors which contain the text renderers.
2482   Actor container = stencil.GetChildAt( 1u );
2483   for( unsigned int index = 0; index < container.GetChildCount(); ++index )
2484   {
2485     Renderer renderer = container.GetChildAt( index ).GetRendererAt( 0u );
2486     DALI_TEST_CHECK( renderer );
2487   }
2488
2489   END_TEST;
2490 }
2491
2492 int utcDaliTextFieldEvent04(void)
2493 {
2494   ToolkitTestApplication application;
2495   tet_infoline(" utcDaliTextFieldEvent04");
2496
2497   // Checks if the highlight actor is created.
2498
2499   TextField field = TextField::New();
2500   DALI_TEST_CHECK( field );
2501   application.GetScene().Add( field );
2502   LoadMarkerImages(application, field);
2503   // Render and notify
2504   application.SendNotification();
2505   application.Render();
2506
2507   field.SetProperty( TextField::Property::TEXT, "This is a long text for the size of the text-field." );
2508   field.SetProperty( TextField::Property::POINT_SIZE, 10.f );
2509   field.SetProperty( Actor::Property::SIZE, Vector2( 300.f, 50.f ) );
2510   field.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT );
2511   field.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT );
2512
2513   // Avoid a crash when core load gl resources.
2514   application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
2515   // Render and notify
2516   application.SendNotification();
2517   application.Render();
2518
2519   // Create a tap event to touch the text field.
2520   TestGenerateTap( application, 150.0f, 25.0f );
2521   // Render and notify
2522   application.SendNotification();
2523   application.Render();
2524
2525
2526   // Tap first to get the focus.
2527   TestGenerateTap( application, 1.0f, 25.0f );
2528
2529   // Render and notify
2530   application.SendNotification();
2531   application.Render();
2532
2533   // Double tap to select a word.
2534   TestGenerateTap( application, 1.0f, 25.0f );
2535
2536   // Render and notify
2537   application.SendNotification();
2538   application.Render();
2539
2540   // Tap grab handle
2541   TestGenerateTap( application, 0.0f, 40.0f );
2542   END_TEST;
2543 }
2544
2545 int utcDaliTextFieldEvent05(void)
2546 {
2547   ToolkitTestApplication application;
2548   tet_infoline(" utcDaliTextFieldEvent05");
2549
2550   // Checks dragging of cursor/grab handle
2551
2552   TextField field = TextField::New();
2553   DALI_TEST_CHECK( field );
2554   application.GetScene().Add( field );
2555   LoadMarkerImages(application, field);
2556   // Render and notify
2557   application.SendNotification();
2558   application.Render();
2559
2560   field.SetProperty( TextField::Property::TEXT, "This is a long text for the size of the text-field." );
2561   field.SetProperty( TextField::Property::POINT_SIZE, 10.f );
2562   field.SetProperty( Actor::Property::SIZE, Vector2( 300.f, 50.f ) );
2563   field.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT );
2564   field.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT );
2565
2566   // Avoid a crash when core load gl resources.
2567   application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
2568   // Render and notify
2569   application.SendNotification();
2570   application.Render();
2571
2572   // Create a tap event to touch the text field.
2573   TestGenerateTap( application, 150.0f, 25.0f );
2574   // Render and notify
2575   application.SendNotification();
2576   application.Render();
2577
2578   // Tap first to get the focus.
2579   TestGenerateTap( application, 1.0f, 25.0f );
2580
2581   // Render and notify
2582   application.SendNotification();
2583   application.Render();
2584
2585   // Double tap to select a word.
2586   TestGenerateTap( application, 1.0f, 25.0f );
2587
2588   // Render and notify
2589   application.SendNotification();
2590   application.Render();
2591
2592   Actor stencil = field.GetChildAt( 1u );
2593   END_TEST;
2594 }
2595
2596 int utcDaliTextFieldEvent06(void)
2597 {
2598   ToolkitTestApplication application;
2599   tet_infoline(" utcDaliTextFieldEvent06");
2600
2601   // Checks Longpress when in edit mode
2602
2603   TextField field = TextField::New();
2604   DALI_TEST_CHECK( field );
2605   application.GetScene().Add( field );
2606   LoadMarkerImages(application, field);
2607   // Render and notify
2608   application.SendNotification();
2609   application.Render();
2610
2611   field.SetProperty( TextField::Property::TEXT, "Thisisalongtextforthesizeofthetextfield." );
2612   field.SetProperty( TextField::Property::POINT_SIZE, 10.f );
2613   field.SetProperty( Actor::Property::SIZE, Vector2( 300.f, 50.f ) );
2614   field.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT );
2615   field.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT );
2616
2617   // Avoid a crash when core load gl resources.
2618   application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
2619   // Render and notify
2620   application.SendNotification();
2621   application.Render();
2622
2623   // Create a tap event to touch the text field.
2624   TestGenerateTap( application, 150.0f, 25.0f );
2625   // Render and notify
2626   application.SendNotification();
2627   application.Render();
2628
2629
2630   // Tap first to get the focus.
2631   TestGenerateTap( application, 1.0f, 25.0f );
2632
2633   // Render and notify
2634   application.SendNotification();
2635   application.Render();
2636
2637   // Long Press
2638   TestGenerateLongPress(application, 1.0f, 25.0f);
2639
2640   // Render and notify
2641   application.SendNotification();
2642   application.Render();
2643
2644   END_TEST;
2645 }
2646
2647 int utcDaliTextFieldEvent07(void)
2648 {
2649   ToolkitTestApplication application;
2650   tet_infoline(" utcDaliTextFieldEvent07");
2651
2652   // Checks Longpress to start edit mode
2653
2654   TextField field = TextField::New();
2655   DALI_TEST_CHECK( field );
2656   application.GetScene().Add( field );
2657   LoadMarkerImages(application, field);
2658   // Render and notify
2659   application.SendNotification();
2660   application.Render();
2661
2662   field.SetProperty( TextField::Property::TEXT, "Thisisalongtextforthesizeofthetextfield." );
2663   field.SetProperty( TextField::Property::POINT_SIZE, 10.f );
2664   field.SetProperty( Actor::Property::SIZE, Vector2( 300.f, 50.f ) );
2665   field.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT );
2666   field.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT );
2667   Property::Map propertyMap;
2668   propertyMap["PANEL_LAYOUT"] = InputMethod::PanelLayout::PASSWORD;
2669   field.SetProperty( TextField::Property::INPUT_METHOD_SETTINGS, propertyMap );
2670
2671   // Avoid a crash when core load gl resources.
2672   application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
2673   // Render and notify
2674   application.SendNotification();
2675   application.Render();
2676
2677   // Long Press
2678   TestGenerateLongPress(application, 1.0f, 25.0f);
2679
2680   // Render and notify
2681   application.SendNotification();
2682   application.Render();
2683
2684   END_TEST;
2685 }
2686
2687 int utcDaliTextFieldEvent08(void)
2688 {
2689   ToolkitTestApplication application;
2690   tet_infoline(" utcDaliTextFieldEvent08");
2691
2692   Dali::Clipboard clipboard = Clipboard::Get();
2693   clipboard.SetItem("testTextFieldEvent");
2694
2695   // Checks Longpress when only place holder text
2696
2697   TextField field = TextField::New();
2698   DALI_TEST_CHECK( field );
2699   application.GetScene().Add( field );
2700   LoadMarkerImages(application, field);
2701   // Render and notify
2702   application.SendNotification();
2703   application.Render();
2704
2705   field.SetProperty( TextField::Property::PLACEHOLDER_TEXT, "Setting Placeholder Text" );
2706   field.SetProperty( TextField::Property::POINT_SIZE, 10.f );
2707   field.SetProperty( Actor::Property::SIZE, Vector2( 300.f, 50.f ) );
2708   field.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT );
2709   field.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT );
2710
2711   // Avoid a crash when core load gl resources.
2712   application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
2713   // Render and notify
2714   application.SendNotification();
2715   application.Render();
2716
2717   // Long Press
2718   TestGenerateLongPress( application, 1.0f, 25.0f, 20 );
2719
2720   // Render and notify
2721   application.SendNotification();
2722   application.Render();
2723
2724   Wait(application, 500);
2725
2726   TestEndLongPress( application, 1.0f, 25.0f, 520 );
2727
2728   // Long Press
2729   TestGenerateLongPress( application, 1.0f, 25.0f, 600 );
2730
2731   // Render and notify
2732   application.Render();
2733
2734   Wait(application, 500);
2735
2736   Integration::Scene stage = application.GetScene();
2737   Layer layer = stage.GetRootLayer();
2738   Actor actor = layer.FindChildByName("optionPaste");
2739
2740   if (actor)
2741   {
2742     Vector3 worldPosition = actor.GetCurrentProperty< Vector3 >( Actor::Property::WORLD_POSITION );
2743     Vector2 halfStageSize = stage.GetSize() / 2.0f;
2744     Vector2 position(worldPosition.x + halfStageSize.width, worldPosition.y + halfStageSize.height);
2745
2746     Dali::Integration::TouchEvent event;
2747     event = Dali::Integration::TouchEvent();
2748     event.AddPoint( GetPointDownInside( position ) );
2749     application.ProcessEvent( event );
2750
2751     event = Dali::Integration::TouchEvent();
2752     event.AddPoint( GetPointUpInside( position ) );
2753     application.ProcessEvent( event );
2754   }
2755   DALI_TEST_EQUALS( field.GetProperty<std::string>( TextEditor::Property::TEXT ), std::string("testTextFieldEvent"), TEST_LOCATION );
2756
2757   END_TEST;
2758 }
2759
2760 int utcDaliTextFieldEvent09(void)
2761 {
2762   ToolkitTestApplication application;
2763   tet_infoline(" utcDaliTextFieldEvent09");
2764
2765   TextField field = TextField::New();
2766   DALI_TEST_CHECK( field );
2767   application.GetScene().Add( field );
2768   LoadMarkerImages(application, field);
2769   // Render and notify
2770   application.SendNotification();
2771   application.Render();
2772
2773   field.SetProperty( TextField::Property::TEXT, "Hello" );
2774   field.SetProperty( TextField::Property::POINT_SIZE, 10.f );
2775   field.SetProperty( Actor::Property::SIZE, Vector2( 300.f, 50.f ) );
2776   field.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT );
2777   field.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT );
2778
2779   // Avoid a crash when core load gl resources.
2780   application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
2781
2782   // Create a tap event to touch the text field.
2783   TestGenerateTap( application, 150.0f, 25.0f );
2784   application.SendNotification();
2785   application.Render();
2786
2787   Property::Map map;
2788   map[ HiddenInput::Property::MODE ] = HiddenInput::Mode::HIDE_NONE;
2789   field.SetProperty( TextField::Property::HIDDEN_INPUT_SETTINGS, map );
2790   application.ProcessEvent( GenerateKey( "d", "", "d", 0, 0, 0, Integration::KeyEvent::DOWN, "d", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2791   application.SendNotification();
2792   application.Render();
2793
2794   map[ HiddenInput::Property::MODE ] = HiddenInput::Mode::HIDE_ALL;
2795   map[ HiddenInput::Property::SUBSTITUTE_CHARACTER ] = 0x23;
2796   field.SetProperty( TextField::Property::HIDDEN_INPUT_SETTINGS, map );
2797   application.ProcessEvent( GenerateKey( "d", "", "d", 0, 0, 0, Integration::KeyEvent::DOWN, "d", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2798   application.SendNotification();
2799   application.Render();
2800
2801   map[ HiddenInput::Property::MODE ] = HiddenInput::Mode::HIDE_COUNT;
2802   map[ HiddenInput::Property::SUBSTITUTE_COUNT ] = 2;
2803   field.SetProperty( TextField::Property::HIDDEN_INPUT_SETTINGS, map );
2804   for( unsigned int index = 0u; index < 5u; ++index )
2805   {
2806     application.ProcessEvent( GenerateKey( "d", "", "d", 0, 0, 0, Integration::KeyEvent::DOWN, "d", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2807     application.SendNotification();
2808     application.Render();
2809   }
2810
2811   map[ HiddenInput::Property::MODE ] = HiddenInput::Mode::SHOW_COUNT;
2812   map[ HiddenInput::Property::SUBSTITUTE_COUNT ] = 2;
2813   field.SetProperty( TextField::Property::HIDDEN_INPUT_SETTINGS, map );
2814   for( unsigned int index = 0u; index < 5u; ++index )
2815   {
2816     application.ProcessEvent( GenerateKey( "d", "", "d", 0, 0, 0, Integration::KeyEvent::DOWN, "d", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2817     application.SendNotification();
2818     application.Render();
2819   }
2820
2821   map[ HiddenInput::Property::MODE ] = HiddenInput::Mode::SHOW_LAST_CHARACTER;
2822   map[ HiddenInput::Property::SHOW_LAST_CHARACTER_DURATION ] = 0;
2823   field.SetProperty( TextField::Property::HIDDEN_INPUT_SETTINGS, map );
2824   application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_BACKSPACE, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2825   application.SendNotification();
2826   application.Render();
2827   application.ProcessEvent( GenerateKey( "d", "", "d", 0, 0, 0, Integration::KeyEvent::DOWN, "d", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2828   application.SendNotification();
2829   application.Render();
2830
2831   map[ HiddenInput::Property::SHOW_LAST_CHARACTER_DURATION ] = 100;
2832   field.SetProperty( TextField::Property::HIDDEN_INPUT_SETTINGS, map );
2833   application.ProcessEvent( GenerateKey( "d", "", "d", 0, 0, 0, Integration::KeyEvent::DOWN, "d", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2834   application.SendNotification();
2835   application.Render();
2836
2837   Property::Map mapGet;
2838   mapGet = field.GetProperty<Property::Map>( TextField::Property::HIDDEN_INPUT_SETTINGS );
2839   DALI_TEST_EQUALS( map.Count(), mapGet.Count(), TEST_LOCATION );
2840   DALI_TEST_EQUALS( DaliTestCheckMaps( map, mapGet ), true, TEST_LOCATION );
2841   END_TEST;
2842 }
2843
2844
2845 int utcDaliTextFieldStyleWhilstSelected(void)
2846 {
2847   ToolkitTestApplication application;
2848   tet_infoline(" utcDaliTextFieldStyleWhilstSelected");
2849
2850   // Change font and styles whilst text is selected whilst word selected
2851
2852   TextField field = TextField::New();
2853   DALI_TEST_CHECK( field );
2854   application.GetScene().Add( field );
2855   LoadMarkerImages(application, field);
2856   // Render and notify
2857   application.SendNotification();
2858   application.Render();
2859
2860   field.SetProperty( TextField::Property::TEXT, "This is a long text for the size of the text-field." );
2861   field.SetProperty( TextField::Property::POINT_SIZE, 10.f );
2862   field.SetProperty( Actor::Property::SIZE, Vector2( 300.f, 50.f ) );
2863   field.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT );
2864   field.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT );
2865
2866   // Avoid a crash when core load gl resources.
2867   application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
2868   // Render and notify
2869   application.SendNotification();
2870   application.Render();
2871
2872   // Create a tap event to touch the text field.
2873   TestGenerateTap( application, 150.0f, 25.0f );
2874   // Render and notify
2875   application.SendNotification();
2876   application.Render();
2877
2878
2879   // Tap first to get the focus.
2880   TestGenerateTap( application, 1.0f, 25.0f );
2881
2882   // Render and notify
2883   application.SendNotification();
2884   application.Render();
2885
2886   // Double tap to select a word.
2887   TestGenerateTap( application, 1.0f, 25.0f );
2888
2889   // Render and notify
2890   application.SendNotification();
2891   application.Render();
2892
2893   field.SetProperty( TextField::Property::INPUT_FONT_FAMILY, "Setting input font family" );
2894   DALI_TEST_EQUALS( field.GetProperty<std::string>( TextField::Property::INPUT_FONT_FAMILY ), "Setting input font family", TEST_LOCATION );
2895
2896   Property::Map fontStyleMapSet;
2897   Property::Map fontStyleMapGet;
2898
2899   fontStyleMapSet.Insert( "weight", "bold" );
2900   fontStyleMapSet.Insert( "slant", "italic" );
2901   field.SetProperty( TextField::Property::INPUT_FONT_STYLE, fontStyleMapSet );
2902
2903   fontStyleMapGet = field.GetProperty<Property::Map>( TextField::Property::INPUT_FONT_STYLE );
2904   DALI_TEST_EQUALS( fontStyleMapGet.Count(), fontStyleMapSet.Count(), TEST_LOCATION );
2905   DALI_TEST_EQUALS( DaliTestCheckMaps( fontStyleMapGet, fontStyleMapSet ), true, TEST_LOCATION );
2906
2907   fontStyleMapSet.Clear();
2908   fontStyleMapSet.Insert( "width", "expanded" );
2909   fontStyleMapSet.Insert( "slant", "italic" );
2910   field.SetProperty( TextField::Property::INPUT_FONT_STYLE, fontStyleMapSet );
2911
2912   fontStyleMapGet = field.GetProperty<Property::Map>( TextField::Property::INPUT_FONT_STYLE );
2913   DALI_TEST_EQUALS( fontStyleMapGet.Count(), fontStyleMapSet.Count(), TEST_LOCATION );
2914   DALI_TEST_EQUALS( DaliTestCheckMaps( fontStyleMapGet, fontStyleMapSet ), true, TEST_LOCATION );
2915
2916   field.SetProperty( TextField::Property::INPUT_POINT_SIZE, 12.f );
2917   DALI_TEST_EQUALS( field.GetProperty<float>( TextField::Property::INPUT_POINT_SIZE ), 12.f, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
2918
2919   field.SetProperty( TextField::Property::TEXT_COLOR, Color::RED );
2920   DALI_TEST_EQUALS( field.GetProperty<Vector4>( TextField::Property::TEXT_COLOR ), Color::RED, TEST_LOCATION );
2921
2922   fontStyleMapSet.Clear();
2923   fontStyleMapSet.Insert( "weight", "bold" );
2924   fontStyleMapSet.Insert( "slant", "italic" );
2925
2926   field.SetProperty( TextField::Property::FONT_STYLE, fontStyleMapSet );
2927
2928   fontStyleMapGet = field.GetProperty<Property::Map>( TextField::Property::FONT_STYLE );
2929   DALI_TEST_EQUALS( fontStyleMapGet.Count(), fontStyleMapSet.Count(), TEST_LOCATION );
2930   DALI_TEST_EQUALS( DaliTestCheckMaps( fontStyleMapGet, fontStyleMapSet ), true, TEST_LOCATION );
2931
2932   fontStyleMapSet.Clear();
2933   fontStyleMapSet.Insert( "width", "expanded" );
2934
2935   field.SetProperty( TextField::Property::FONT_STYLE, fontStyleMapSet );
2936
2937   fontStyleMapGet = field.GetProperty<Property::Map>( TextField::Property::FONT_STYLE );
2938   DALI_TEST_EQUALS( fontStyleMapGet.Count(), fontStyleMapSet.Count(), TEST_LOCATION );
2939   DALI_TEST_EQUALS( DaliTestCheckMaps( fontStyleMapGet, fontStyleMapSet ), true, TEST_LOCATION );
2940
2941   // Press Escape to increase coverage
2942   application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_ESCAPE, 0, 0, Integration::KeyEvent::UP, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2943   application.SendNotification();
2944   application.Render();
2945
2946   DALI_TEST_CHECK( !field.HasKeyInputFocus() );
2947
2948   END_TEST;
2949 }
2950
2951 int utcDaliTextFieldEscKeyLoseFocus(void)
2952 {
2953   ToolkitTestApplication application;
2954   tet_infoline(" utcDaliTextFieldEscKeyLoseFocus");
2955
2956   // Creates a tap event. After creating a tap event the text field should
2957   // have the focus and add text with key events should be possible.
2958
2959   TextField field = TextField::New();
2960   DALI_TEST_CHECK( field );
2961
2962   application.GetScene().Add( field );
2963
2964   field.SetProperty( Actor::Property::SIZE, Vector2( 300.f, 50.f ) );
2965   field.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT );
2966   field.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT );
2967
2968   // Avoid a crash when core load gl resources.
2969   application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
2970
2971   // Render and notify
2972   application.SendNotification();
2973   application.Render();
2974
2975   // Add a key event but as the text field has not the focus it should do nothing.
2976   application.ProcessEvent( GenerateKey( "a", "", "a", KEY_A_CODE, 0, 0, Integration::KeyEvent::DOWN, "a", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2977   application.ProcessEvent( GenerateKey( "a", "", "a", KEY_A_CODE, 0, 0, Integration::KeyEvent::UP, "a", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2978
2979   // Render and notify
2980   application.SendNotification();
2981   application.Render();
2982
2983   DALI_TEST_EQUALS( field.GetProperty<std::string>( TextField::Property::TEXT ), std::string(""), TEST_LOCATION );
2984
2985   // Create a tap event to touch the text field.
2986   TestGenerateTap( application, 150.0f, 25.0f );
2987
2988   // Render and notify
2989   application.SendNotification();
2990   application.Render();
2991
2992   // Now the text field has the focus, so it can handle the key events.
2993   application.ProcessEvent( GenerateKey( "a", "", "a", KEY_A_CODE, 0, 0, Integration::KeyEvent::DOWN, "a", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2994   application.ProcessEvent( GenerateKey( "a", "", "a", KEY_A_CODE, 0, 0, Integration::KeyEvent::UP, "a", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2995   application.ProcessEvent( GenerateKey( "d", "", "d", KEY_D_CODE, 0, 0, Integration::KeyEvent::DOWN, "d", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2996   application.ProcessEvent( GenerateKey( "d", "", "d", KEY_D_CODE, 0, 0, Integration::KeyEvent::UP, "d", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2997
2998   // Render and notify
2999   application.SendNotification();
3000   application.Render();
3001
3002   DALI_TEST_EQUALS( field.GetProperty<std::string>( TextField::Property::TEXT ), std::string("ad"), TEST_LOCATION );
3003
3004   // Generate a Esc key event. The text field should lose the focus.
3005   application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_ESCAPE, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
3006   application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_ESCAPE, 0, 0, Integration::KeyEvent::UP, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
3007
3008   // Render and notify
3009   application.SendNotification();
3010   application.Render();
3011
3012   DALI_TEST_EQUALS( false, field.HasKeyInputFocus(), TEST_LOCATION );
3013
3014   // No more text should be introduced
3015   application.ProcessEvent( GenerateKey( "a", "", "a", KEY_A_CODE, 0, 0, Integration::KeyEvent::DOWN, "a", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
3016   application.ProcessEvent( GenerateKey( "a", "", "a", KEY_A_CODE, 0, 0, Integration::KeyEvent::UP, "a", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
3017
3018   // Render and notify
3019   application.SendNotification();
3020   application.Render();
3021
3022   DALI_TEST_EQUALS( field.GetProperty<std::string>( TextField::Property::TEXT ), std::string("ad"), TEST_LOCATION );
3023
3024   END_TEST;
3025 }
3026
3027 int utcDaliTextFieldSomeSpecialKeys(void)
3028 {
3029   ToolkitTestApplication application;
3030   tet_infoline(" utcDaliTextFieldSomeSpecialKeys");
3031
3032   // Checks some special keys when the text is selected.
3033
3034   TextField field = TextField::New();
3035   DALI_TEST_CHECK( field );
3036   application.GetScene().Add( field );
3037   LoadMarkerImages(application, field);
3038   // Render and notify
3039   application.SendNotification();
3040   application.Render();
3041
3042   const std::string longText( "This is a long text for the size of the text-field." );
3043
3044   field.SetProperty( TextField::Property::TEXT, longText );
3045   field.SetProperty( TextField::Property::POINT_SIZE, 10.f );
3046   field.SetProperty( Actor::Property::SIZE, Vector2( 300.f, 50.f ) );
3047   field.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT );
3048   field.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT );
3049
3050   // Avoid a crash when core load gl resources.
3051   application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
3052   // Render and notify
3053   application.SendNotification();
3054   application.Render();
3055
3056   // Create a tap event to touch the text field.
3057   TestGenerateTap( application, 150.0f, 25.0f );
3058
3059   // Render and notify
3060   application.SendNotification();
3061   application.Render();
3062
3063   // Tap first to get the focus.
3064   TestGenerateTap( application, 1.0f, 25.0f );
3065
3066   // Render and notify
3067   application.SendNotification();
3068   application.Render();
3069
3070   // Double tap to select a word.
3071   TestGenerateTap( application, 1.0f, 25.0f );
3072
3073   // Render and notify
3074   application.SendNotification();
3075   application.Render();
3076
3077   // Generate a Esc key event. The text field should lose the focus.
3078   application.ProcessEvent( GenerateKey( "XF86PowerOff", "", "XF86PowerOff", DALI_KEY_POWER, 0, 0, Integration::KeyEvent::DOWN, "XF86PowerOff", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
3079   application.ProcessEvent( GenerateKey( "XF86PowerOff", "", "XF86PowerOff", DALI_KEY_POWER, 0, 0, Integration::KeyEvent::UP, "XF86PowerOff", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
3080
3081   // Render and notify
3082   application.SendNotification();
3083   application.Render();
3084
3085   // Generate a Esc key event. The text field should lose the focus.
3086   application.ProcessEvent( GenerateKey( "XF86Menu", "", "XF86Menu", DALI_KEY_MENU, 0, 0, Integration::KeyEvent::DOWN, "XF86Menu", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
3087   application.ProcessEvent( GenerateKey( "XF86Menu", "", "XF86Menu", DALI_KEY_MENU, 0, 0, Integration::KeyEvent::UP, "XF86Menu", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
3088
3089   // Render and notify
3090   application.SendNotification();
3091   application.Render();
3092
3093   // Generate a Esc key event. The text field should lose the focus.
3094   application.ProcessEvent( GenerateKey( "XF86Home", "", "XF86Home", DALI_KEY_HOME, 0, 0, Integration::KeyEvent::DOWN, "XF86Home", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
3095   application.ProcessEvent( GenerateKey( "XF86Home", "", "XF86Home", DALI_KEY_HOME, 0, 0, Integration::KeyEvent::UP, "XF86Home", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
3096
3097   // Render and notify
3098   application.SendNotification();
3099   application.Render();
3100
3101   // The text shouldn't be deleted.
3102   DALI_TEST_EQUALS( field.GetProperty<std::string>( TextField::Property::TEXT ), longText, TEST_LOCATION );
3103
3104   END_TEST;
3105 }
3106
3107 int utcDaliTextFieldSizeUpdate(void)
3108 {
3109   ToolkitTestApplication application;
3110   tet_infoline("utcDaliTextFieldSizeUpdate");
3111
3112   // Checks some special keys when the text is selected.
3113   TextField field = TextField::New();
3114   DALI_TEST_CHECK( field );
3115   application.GetScene().Add( field );
3116
3117   float previousHeight = 0.0f;
3118   float currentHeight = 0.0f;
3119   const float fieldWidth = 1920.0f;
3120
3121
3122   // "ㅁ" is bigger then "ኢ"
3123   field.SetProperty( Actor::Property::SIZE, Vector2( fieldWidth ,10.0f ) );
3124   field.SetResizePolicy( ResizePolicy::FIXED , Dimension::WIDTH );
3125   field.SetResizePolicy( ResizePolicy::DIMENSION_DEPENDENCY , Dimension::HEIGHT );
3126
3127   field.SetProperty( TextField::Property::TEXT, "ኢ");
3128   field.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT );
3129   field.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT );
3130
3131   field.SetProperty( Actor::Property::KEYBOARD_FOCUSABLE,true);
3132   KeyboardFocusManager::Get().SetCurrentFocusActor( field );
3133
3134   application.SendNotification();
3135   application.Render();
3136
3137   previousHeight = field.GetHeightForWidth( fieldWidth );
3138   DALI_TEST_EQUALS( previousHeight, field.GetProperty<float>( Actor::Property::SIZE_HEIGHT ) , TEST_LOCATION );
3139
3140   // Add  another script characters ( glyph height is defferent )
3141   application.ProcessEvent( GenerateKey( "ㅁ", "", "ㅁ", KEY_A_CODE, 0, 0, Integration::KeyEvent::DOWN, "ㅁ", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
3142   application.ProcessEvent( GenerateKey( "ㅁ", "", "ㅁ", KEY_A_CODE, 0, 0, Integration::KeyEvent::UP, "ㅁ", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
3143
3144   application.SendNotification();
3145   application.Render();
3146
3147   currentHeight = field.GetHeightForWidth( fieldWidth );
3148   DALI_TEST_EQUALS( currentHeight, field.GetProperty<float>( Actor::Property::SIZE_HEIGHT ), TEST_LOCATION );
3149   DALI_TEST_EQUALS( (previousHeight < currentHeight), true , TEST_LOCATION );
3150
3151   END_TEST;
3152 }
3153
3154 int utcDaliTextFieldExtremlyLargePointSize(void)
3155 {
3156   ToolkitTestApplication application;
3157   tet_infoline(" utcDaliTextFieldExtremlyLargePointSize");
3158
3159   TextField field = TextField::New();
3160
3161   field.SetProperty( TextField::Property::TEXT, "Text" );
3162   field.SetProperty( Actor::Property::SIZE, Vector2( 300.f, 50.f ) );
3163   field.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT );
3164   field.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT );
3165   application.GetScene().Add( field );
3166
3167   try
3168   {
3169     field.SetProperty( TextField::Property::POINT_SIZE, 160.0f );
3170     application.SendNotification();
3171     DALI_TEST_CHECK( field );
3172   }
3173   catch (...)
3174   {
3175     tet_result(TET_FAIL);
3176   }
3177   END_TEST;
3178 }
3179
3180 int UtcDaliTextFieldDefaultFontStylePropertyCoverage(void)
3181 {
3182   ToolkitTestApplication application;
3183   tet_infoline("UtcDaliTextFieldFontStylePorpertyCoverage");
3184   TextField field = TextField::New();
3185   DALI_TEST_CHECK( field );
3186   application.GetScene().Add( field );
3187
3188   Property::Map fontStyleMapGet;
3189
3190   fontStyleMapGet = field.GetProperty<Property::Map>( TextField::Property::FONT_STYLE );
3191
3192   Property::Value* weightValue = NULL;
3193   Property::Value* widthValue = NULL;
3194   Property::Value* slantValue = NULL;
3195   weightValue = fontStyleMapGet.Find( "weight" );
3196   widthValue = fontStyleMapGet.Find( "width" );
3197   slantValue = fontStyleMapGet.Find( "slant" );
3198   DALI_TEST_CHECK( !weightValue );
3199   DALI_TEST_CHECK( !widthValue );
3200   DALI_TEST_CHECK( !slantValue );
3201
3202   END_TEST;
3203 }
3204
3205 int UtcDaliTextFieldSettingPlaceholder(void)
3206 {
3207   ToolkitTestApplication application;
3208   tet_infoline("UtcDaliTextFieldSettingPlaceholder");
3209
3210   TextField field = TextField::New();
3211   DALI_TEST_CHECK( field );
3212   application.GetScene().Add( field );
3213
3214   // Check the placeholder property with pixel size
3215   Property::Map placeholderPixelSizeMapSet;
3216   Property::Map placeholderPixelSizeMapGet;
3217   Property::Map placeholderFontstyleMap;
3218   placeholderPixelSizeMapSet[ Text::PlaceHolder::Property::TEXT ] = "Setting Placeholder Text";
3219   placeholderPixelSizeMapSet[ Text::PlaceHolder::Property::TEXT_FOCUSED ] = "Setting Placeholder Text Focused";
3220   placeholderPixelSizeMapSet[ Text::PlaceHolder::Property::COLOR ] = Color::BLUE;
3221   placeholderPixelSizeMapSet[ Text::PlaceHolder::Property::FONT_FAMILY ] = "Arial";
3222   placeholderPixelSizeMapSet[ Text::PlaceHolder::Property::PIXEL_SIZE ] = 15.0f;
3223   placeholderPixelSizeMapSet[ Text::PlaceHolder::Property::ELLIPSIS ] = true;
3224
3225   placeholderFontstyleMap.Insert( "weight", "bold" );
3226   placeholderPixelSizeMapSet[ Text::PlaceHolder::Property::FONT_STYLE ] = placeholderFontstyleMap;
3227   field.SetProperty( TextField::Property::PLACEHOLDER, placeholderPixelSizeMapSet );
3228
3229   placeholderPixelSizeMapGet = field.GetProperty<Property::Map>( TextField::Property::PLACEHOLDER );
3230   DALI_TEST_EQUALS( placeholderPixelSizeMapGet.Count(), placeholderPixelSizeMapSet.Count(), TEST_LOCATION );
3231   DALI_TEST_EQUALS( DaliTestCheckMaps( placeholderPixelSizeMapGet, placeholderPixelSizeMapSet ), true, TEST_LOCATION );
3232
3233   // Check the placeholder property with point size
3234   Property::Map placeholderMapSet;
3235   Property::Map placeholderMapGet;
3236   placeholderMapSet[ Text::PlaceHolder::Property::TEXT ] = "Setting Placeholder Text";
3237   placeholderMapSet[ Text::PlaceHolder::Property::TEXT_FOCUSED ] = "Setting Placeholder Text Focused";
3238   placeholderMapSet[ Text::PlaceHolder::Property::COLOR ] = Color::RED;
3239   placeholderMapSet[ Text::PlaceHolder::Property::FONT_FAMILY ] = "Arial";
3240   placeholderMapSet[ Text::PlaceHolder::Property::POINT_SIZE ] = 12.0f;
3241   placeholderMapSet[ Text::PlaceHolder::Property::ELLIPSIS ] = false;
3242
3243   // Check the placeholder font style property
3244   placeholderFontstyleMap.Clear();
3245
3246   placeholderFontstyleMap.Insert( "weight", "bold" );
3247   placeholderFontstyleMap.Insert( "width", "condensed" );
3248   placeholderFontstyleMap.Insert( "slant", "italic" );
3249   placeholderMapSet[ Text::PlaceHolder::Property::FONT_STYLE ] = placeholderFontstyleMap;
3250   field.SetProperty( TextField::Property::PLACEHOLDER, placeholderMapSet );
3251
3252   placeholderMapGet = field.GetProperty<Property::Map>( TextField::Property::PLACEHOLDER );
3253   DALI_TEST_EQUALS( placeholderMapGet.Count(), placeholderMapSet.Count(), TEST_LOCATION );
3254   DALI_TEST_EQUALS( DaliTestCheckMaps( placeholderMapGet, placeholderMapSet ), true, TEST_LOCATION );
3255
3256   // Reset font style.
3257   placeholderFontstyleMap.Clear();
3258   placeholderFontstyleMap.Insert( "weight", "normal" );
3259   placeholderFontstyleMap.Insert( "slant", "oblique" );
3260   placeholderMapSet[ Text::PlaceHolder::Property::FONT_STYLE ] = placeholderFontstyleMap;
3261   field.SetProperty( TextField::Property::PLACEHOLDER, placeholderMapSet );
3262
3263   placeholderMapGet = field.GetProperty<Property::Map>( TextField::Property::PLACEHOLDER );
3264   DALI_TEST_EQUALS( placeholderMapGet.Count(), placeholderMapSet.Count(), TEST_LOCATION );
3265   DALI_TEST_EQUALS( DaliTestCheckMaps( placeholderMapGet, placeholderMapSet ), true, TEST_LOCATION );
3266
3267   placeholderFontstyleMap.Clear();
3268   placeholderFontstyleMap.Insert( "slant", "roman" );
3269   placeholderMapSet[ Text::PlaceHolder::Property::FONT_STYLE ] = placeholderFontstyleMap;
3270   field.SetProperty( TextField::Property::PLACEHOLDER, placeholderMapSet );
3271
3272   placeholderMapGet = field.GetProperty<Property::Map>( TextField::Property::PLACEHOLDER );
3273
3274   placeholderFontstyleMap.Clear();
3275   placeholderMapSet[ Text::PlaceHolder::Property::FONT_STYLE ] = placeholderFontstyleMap;
3276
3277   field.SetProperty( TextField::Property::PLACEHOLDER, placeholderMapSet );
3278   placeholderMapGet = field.GetProperty<Property::Map>( TextField::Property::PLACEHOLDER );
3279   DALI_TEST_EQUALS( placeholderMapGet.Count(), placeholderMapSet.Count(), TEST_LOCATION );
3280   DALI_TEST_EQUALS( DaliTestCheckMaps( placeholderMapGet, placeholderMapSet ), true, TEST_LOCATION );
3281
3282   END_TEST;
3283 }
3284
3285 int UtcDaliTextFieldPlaceholderCoverage(void)
3286 {
3287   ToolkitTestApplication application;
3288   tet_infoline("UtcDaliTextFieldPlaceholderCoverage");
3289
3290   // mPlaceholderFont is created only once, so create a new control for coverage.
3291   TextField fieldForCoverage = TextField::New();
3292   DALI_TEST_CHECK(fieldForCoverage);
3293   application.GetScene().Add(fieldForCoverage);
3294
3295   // for SetPlaceholderFontFamily() coverage.
3296   Property::Map fontFamilyMap;
3297   fontFamilyMap[Text::PlaceHolder::Property::FONT_FAMILY] = "Arial";
3298   fieldForCoverage.SetProperty(TextField::Property::PLACEHOLDER, fontFamilyMap);
3299
3300   // mPlaceholderFont is created only once, so create a new control for coverage.
3301   fieldForCoverage = TextField::New();
3302   DALI_TEST_CHECK(fieldForCoverage);
3303   application.GetScene().Add(fieldForCoverage);
3304
3305   // for SetPlaceholderTextFontSize coverage.
3306   Property::Map fontSizeMap;
3307   fontSizeMap[Text::PlaceHolder::Property::PIXEL_SIZE] = 15.0f;
3308   fieldForCoverage.SetProperty(TextField::Property::PLACEHOLDER, fontSizeMap);
3309
3310   // mPlaceholderFont is created only once, so create a new control for coverage.
3311   fieldForCoverage = TextField::New();
3312   DALI_TEST_CHECK(fieldForCoverage);
3313   application.GetScene().Add(fieldForCoverage);
3314
3315   // for SetPlaceholderTextFontWeight coverage.
3316   Property::Map fontStyleWeightMap;
3317   Property::Map fontStyleWeightPropertyMap;
3318   fontStyleWeightPropertyMap.Insert("weight", "bold");
3319   fontStyleWeightMap[Text::PlaceHolder::Property::FONT_STYLE] = fontStyleWeightPropertyMap;
3320   fieldForCoverage.SetProperty(TextField::Property::PLACEHOLDER, fontStyleWeightMap);
3321
3322   // mPlaceholderFont is created only once, so create a new control for coverage.
3323   fieldForCoverage = TextField::New();
3324   DALI_TEST_CHECK(fieldForCoverage);
3325   application.GetScene().Add(fieldForCoverage);
3326
3327   // for SetPlaceholderTextFontWidth coverage.
3328   Property::Map fontStyleWidthMap;
3329   Property::Map fontStyleWidthPropertyMap;
3330   fontStyleWidthPropertyMap.Insert("width", "expanded");
3331   fontStyleWidthMap[Text::PlaceHolder::Property::FONT_STYLE] = fontStyleWidthPropertyMap;
3332   fieldForCoverage.SetProperty(TextField::Property::PLACEHOLDER, fontStyleWidthMap);
3333
3334   // mPlaceholderFont is created only once, so create a new control for coverage.
3335   fieldForCoverage = TextField::New();
3336   DALI_TEST_CHECK(fieldForCoverage);
3337   application.GetScene().Add(fieldForCoverage);
3338
3339   // for SetPlaceholderTextFontSlant coverage.
3340   Property::Map fontStyleSlantMap;
3341   Property::Map fontStyleSlantPropertyMap;
3342   fontStyleSlantPropertyMap.Insert("slant", "italic");
3343   fontStyleSlantMap[Text::PlaceHolder::Property::FONT_STYLE] = fontStyleSlantPropertyMap;
3344   fieldForCoverage.SetProperty(TextField::Property::PLACEHOLDER, fontStyleSlantMap);
3345
3346   END_TEST;
3347 }
3348
3349 int UtcDaliTextFieldSetPaddingProperty(void)
3350 {
3351   ToolkitTestApplication application;
3352   tet_infoline("UtcDaliTextFieldSetPaddingProperty\n");
3353
3354   TextField field = TextField::New();
3355   DALI_TEST_CHECK( field );
3356   field.SetProperty( Actor::Property::SIZE, Vector2( 300.f, 50.f ) );
3357   field.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT );
3358   field.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT );
3359   application.GetScene().Add( field );
3360
3361   application.SendNotification();
3362   application.Render();
3363
3364   Vector3 originalSize = field.GetNaturalSize();
3365
3366   field.SetProperty( Toolkit::Control::Property::PADDING, Extents( 10, 10, 10, 10 ) );
3367
3368   application.SendNotification();
3369   application.Render();
3370
3371   DALI_TEST_EQUALS( field.GetProperty<Extents>( Toolkit::Control::Property::PADDING ), Extents( 10, 10, 10, 10 ), TEST_LOCATION );
3372
3373   Vector3 paddingAddedSize = field.GetNaturalSize();
3374
3375   DALI_TEST_EQUALS( originalSize.width + 10 + 10 , paddingAddedSize.width, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
3376
3377   DALI_TEST_EQUALS( originalSize.height + 10 + 10 , paddingAddedSize.height, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
3378
3379   END_TEST;
3380 }
3381
3382 int UtcDaliTextFieldEnableShiftSelectionProperty(void)
3383 {
3384   ToolkitTestApplication application;
3385   tet_infoline("UtcDaliTextFieldEnableShiftSelectionProperty");
3386
3387   TextField field = TextField::New();
3388   DALI_TEST_CHECK( field );
3389   field.SetProperty( Actor::Property::SIZE, Vector2( 300.f, 50.f ) );
3390   field.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT );
3391   field.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT );
3392   application.GetScene().Add( field );
3393
3394   application.SendNotification();
3395   application.Render();
3396
3397   // The default value of ENABLE_SHIFT_SELECTION is 'true'.
3398   DALI_TEST_EQUALS( field.GetProperty<bool>( DevelTextField::Property::ENABLE_SHIFT_SELECTION ), true, TEST_LOCATION );
3399
3400   // Check the enable shift selection property
3401   field.SetProperty( DevelTextField::Property::ENABLE_SHIFT_SELECTION, false );
3402   DALI_TEST_EQUALS( field.GetProperty<bool>( DevelTextField::Property::ENABLE_SHIFT_SELECTION ), false, TEST_LOCATION );
3403
3404   application.SendNotification();
3405   application.Render();
3406
3407   END_TEST;
3408 }
3409
3410 int UtcDaliTextFieldEnableGrabHandleProperty(void)
3411 {
3412   ToolkitTestApplication application;
3413   tet_infoline("UtcDaliTextFieldEnableGrabHandleProperty");
3414
3415   TextField field = TextField::New();
3416   DALI_TEST_CHECK( field );
3417   field.SetProperty( Actor::Property::SIZE, Vector2( 300.f, 50.f ) );
3418   field.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT );
3419   field.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT );
3420   application.GetScene().Add( field );
3421
3422   application.SendNotification();
3423   application.Render();
3424
3425   // The default value of ENABLE_GRAB_HANDLE is 'true'.
3426   DALI_TEST_EQUALS( field.GetProperty<bool>( DevelTextField::Property::ENABLE_GRAB_HANDLE ), true, TEST_LOCATION );
3427
3428   // Check the enable grab handle property
3429   field.SetProperty( DevelTextField::Property::ENABLE_GRAB_HANDLE, false );
3430   DALI_TEST_EQUALS( field.GetProperty<bool>( DevelTextField::Property::ENABLE_GRAB_HANDLE ), false, TEST_LOCATION );
3431
3432   application.SendNotification();
3433   application.Render();
3434
3435   END_TEST;
3436 }
3437
3438 int UtcDaliTextFieldMatchSystemLanguageDirectionProperty(void)
3439 {
3440   ToolkitTestApplication application;
3441   tet_infoline("UtcDaliTextFieldMatchSystemLanguageDirectionProperty");
3442
3443   TextField field = TextField::New();
3444   DALI_TEST_CHECK( field );
3445   field.SetProperty( Actor::Property::SIZE, Vector2( 300.f, 50.f ) );
3446   field.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT );
3447   field.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT );
3448   application.GetScene().Add( field );
3449
3450   application.SendNotification();
3451   application.Render();
3452
3453   // The default value of MATCH_SYSTEM_LANGUAGE_DIRECTION is 'true'.
3454   DALI_TEST_EQUALS( field.GetProperty<bool>( DevelTextField::Property::MATCH_SYSTEM_LANGUAGE_DIRECTION ), true, TEST_LOCATION );
3455
3456   // Check the match system language direction property
3457   field.SetProperty( DevelTextField::Property::MATCH_SYSTEM_LANGUAGE_DIRECTION, false );
3458   DALI_TEST_EQUALS( field.GetProperty<bool>( DevelTextField::Property::MATCH_SYSTEM_LANGUAGE_DIRECTION ), false, TEST_LOCATION );
3459
3460   application.SendNotification();
3461   application.Render();
3462
3463   END_TEST;
3464 }
3465
3466 int utcDaliTextFieldLayoutDirectionCoverage(void)
3467 {
3468   ToolkitTestApplication application;
3469   tet_infoline(" utcDaliTextFieldLayoutDirectionCoverage");
3470
3471   // Creates a tap event. After creating a tap event the text field should
3472   // have the focus and add text with key events should be possible.
3473   TextField field = TextField::New();
3474   DALI_TEST_CHECK( field );
3475
3476   application.GetScene().Add( field );
3477
3478   field.SetProperty( Actor::Property::SIZE, Vector2( 300.f, 50.f ) );
3479   field.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT );
3480   field.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT );
3481
3482   // Avoid a crash when core load gl resources.
3483   application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
3484
3485   // Render and notify
3486   application.SendNotification();
3487   application.Render();
3488
3489   // init direction for coverage
3490   // Set horizontal alignment END
3491   field.SetProperty( TextField::Property::HORIZONTAL_ALIGNMENT, "END");
3492
3493   // Create a tap event to touch the text field.
3494   TestGenerateTap( application, 150.0f, 25.0f );
3495
3496   // Render and notify
3497   application.SendNotification();
3498   application.Render();
3499
3500   // Set MATCH_SYSTEM_LANGUAGE_DIRECTION to true to use the layout direction.
3501   field.SetProperty( DevelTextField::Property::MATCH_SYSTEM_LANGUAGE_DIRECTION, true );
3502   field.SetProperty( Actor::Property::LAYOUT_DIRECTION, LayoutDirection::RIGHT_TO_LEFT );
3503
3504   // Set horizontal alignment BEGIN
3505   field.SetProperty( TextField::Property::HORIZONTAL_ALIGNMENT, "BEGIN");
3506
3507   // Create a tap event to touch the text field.
3508   TestGenerateTap( application, 150.0f, 25.0f );
3509
3510   // Render and notify
3511   application.SendNotification();
3512   application.Render();
3513
3514   // Set horizontal alignment CENTER
3515   field.SetProperty( TextField::Property::HORIZONTAL_ALIGNMENT, "CENTER");
3516
3517   // Create a tap event to touch the text field.
3518   TestGenerateTap( application, 150.0f, 25.0f );
3519
3520   // Render and notify
3521   application.SendNotification();
3522   application.Render();
3523
3524   // Set horizontal alignment END
3525   field.SetProperty( TextField::Property::HORIZONTAL_ALIGNMENT, "END");
3526
3527   // Create a tap event to touch the text field.
3528   TestGenerateTap( application, 150.0f, 25.0f );
3529
3530   // Render and notify
3531   application.SendNotification();
3532   application.Render();
3533
3534   // Generate a Esc key event. The text field should lose the focus.
3535   application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_ESCAPE, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
3536   application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_ESCAPE, 0, 0, Integration::KeyEvent::UP, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
3537
3538   // Render and notify
3539   application.SendNotification();
3540   application.Render();
3541
3542   DALI_TEST_EQUALS( false, field.HasKeyInputFocus(), TEST_LOCATION );
3543
3544   END_TEST;
3545 }
3546
3547 int UtcDaliTextFieldGetInputMethodContext(void)
3548 {
3549   ToolkitTestApplication application;
3550   tet_infoline("UtcDaliTextFieldGetInputMethodContext");
3551
3552   TextField field = TextField::New();
3553   DALI_TEST_CHECK( DevelTextField::GetInputMethodContext( field ) );
3554
3555   END_TEST;
3556 }
3557
3558 int UtcDaliTextFieldSelectWholeText(void)
3559 {
3560   ToolkitTestApplication application;
3561   tet_infoline(" UtcDaliTextFieldSelectWholeText ");
3562
3563   TextField textField = TextField::New();
3564
3565   application.GetScene().Add( textField );
3566
3567   textField.SetProperty( Actor::Property::SIZE, Vector2( 300.f, 50.f ) );
3568   textField.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT );
3569   textField.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT );
3570
3571   // Avoid a crash when core load gl resources.
3572   application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
3573
3574   application.SendNotification();
3575   application.Render();
3576
3577   DALI_TEST_EQUALS( 1u, textField.GetChildCount(), TEST_LOCATION );
3578
3579   DevelTextField::SelectWholeText( textField );
3580
3581   application.SendNotification();
3582   application.Render();
3583
3584   // Nothing should have been selected. The number of children is still 1
3585   DALI_TEST_EQUALS( 1u, textField.GetChildCount(), TEST_LOCATION );
3586
3587   textField.SetProperty( TextField::Property::TEXT, "Hello world" );
3588
3589   application.SendNotification();
3590   application.Render();
3591
3592   DevelTextField::SelectWholeText( textField );
3593
3594   application.SendNotification();
3595   application.Render();
3596
3597   // Even if resize, selection should remain.
3598   textField.SetProperty( Actor::Property::SIZE, Vector2( 150.f, 50.f ) );
3599
3600   application.SendNotification();
3601   application.Render();
3602
3603   // Should be 2 children, the stencil and the layer
3604   DALI_TEST_EQUALS( 2u, textField.GetChildCount(), TEST_LOCATION );
3605
3606   // The offscreen root actor should have two actors: the renderer and the highlight actor.
3607   Actor stencil = textField.GetChildAt( 0u );
3608
3609   // The highlight actor is drawn first, so is the first actor in the list
3610   Renderer highlight = stencil.GetChildAt( 0u ).GetRendererAt( 0u );
3611   DALI_TEST_CHECK( highlight );
3612
3613   END_TEST;
3614 }
3615
3616 int UtcDaliTextFieldSelectText(void)
3617 {
3618   ToolkitTestApplication application;
3619   tet_infoline(" UtcDaliTextFieldSelectText ");
3620
3621   TextField textField = TextField::New();
3622
3623   application.GetScene().Add( textField );
3624
3625   textField.SetProperty( Actor::Property::SIZE, Vector2( 300.f, 50.f ) );
3626   textField.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT );
3627   textField.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT );
3628
3629   // Avoid a crash when core load gl resources.
3630   application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
3631
3632   application.SendNotification();
3633   application.Render();
3634
3635   DevelTextField::SelectText( textField, 0, 5 );
3636
3637   application.SendNotification();
3638   application.Render();
3639
3640   // Nothing is selected
3641   std::string selectedText = textField.GetProperty( DevelTextField::Property::SELECTED_TEXT ).Get<std::string>();
3642   DALI_TEST_EQUALS( "", selectedText, TEST_LOCATION );
3643
3644   textField.SetProperty( TextField::Property::TEXT, "Hello world" );
3645
3646   application.SendNotification();
3647   application.Render();
3648
3649   // Hello is selected
3650   DevelTextField::SelectText( textField, 0, 5 );
3651
3652   application.SendNotification();
3653   application.Render();
3654
3655   selectedText = textField.GetProperty( DevelTextField::Property::SELECTED_TEXT ).Get<std::string>();
3656   DALI_TEST_EQUALS( "Hello", selectedText, TEST_LOCATION );
3657
3658   DALI_TEST_EQUALS( textField.GetProperty( DevelTextField::Property::SELECTED_TEXT_START ).Get<int>(), 0, TEST_LOCATION );
3659   DALI_TEST_EQUALS( textField.GetProperty( DevelTextField::Property::SELECTED_TEXT_END ).Get<int>(), 5, TEST_LOCATION );
3660
3661   // world is selected
3662   DevelTextField::SelectText( textField, 6, 11 );
3663
3664   application.SendNotification();
3665   application.Render();
3666
3667   selectedText = textField.GetProperty( DevelTextField::Property::SELECTED_TEXT ).Get<std::string>();
3668   DALI_TEST_EQUALS( "world", selectedText, TEST_LOCATION );
3669
3670   DALI_TEST_EQUALS( textField.GetProperty( DevelTextField::Property::SELECTED_TEXT_START ).Get<int>(), 6, TEST_LOCATION );
3671   DALI_TEST_EQUALS( textField.GetProperty( DevelTextField::Property::SELECTED_TEXT_END ).Get<int>(), 11, TEST_LOCATION );
3672
3673   END_TEST;
3674 }
3675
3676 int UtcDaliTextFieldSelectNone(void)
3677 {
3678   ToolkitTestApplication application;
3679   tet_infoline(" UtcDaliTextFieldSelectWholeText ");
3680
3681   TextField textField = TextField::New();
3682
3683   application.GetScene().Add( textField );
3684
3685   textField.SetProperty( Actor::Property::SIZE, Vector2( 300.f, 50.f ) );
3686   textField.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT );
3687   textField.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT );
3688
3689   // Avoid a crash when core load gl resources.
3690   application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
3691
3692   application.SendNotification();
3693   application.Render();
3694
3695   textField.SetProperty( TextField::Property::TEXT, "Hello world" );
3696
3697   application.SendNotification();
3698   application.Render();
3699
3700   // Nothing is selected
3701   std::string selectedText = textField.GetProperty( DevelTextField::Property::SELECTED_TEXT ).Get<std::string>();
3702   DALI_TEST_EQUALS( "", selectedText, TEST_LOCATION );
3703
3704   DevelTextField::SelectWholeText( textField );
3705
3706   application.SendNotification();
3707   application.Render();
3708
3709   // whole text is selected
3710   selectedText = textField.GetProperty( DevelTextField::Property::SELECTED_TEXT ).Get<std::string>();
3711   DALI_TEST_EQUALS( "Hello world", selectedText, TEST_LOCATION );
3712
3713   DevelTextField::SelectNone( textField );
3714
3715   application.SendNotification();
3716   application.Render();
3717
3718   // Nothing is selected
3719   selectedText = textField.GetProperty( DevelTextField::Property::SELECTED_TEXT ).Get<std::string>();
3720   DALI_TEST_EQUALS( "", selectedText, TEST_LOCATION );
3721
3722   END_TEST;
3723 }
3724
3725 int UtcDaliTextFieldSelectRange(void)
3726 {
3727   ToolkitTestApplication application;
3728   tet_infoline(" UtcDaliTextFieldSelectRange ");
3729
3730   TextField textField = TextField::New();
3731
3732   application.GetScene().Add( textField );
3733
3734   textField.SetProperty( Actor::Property::SIZE, Vector2( 300.f, 50.f ) );
3735   textField.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT );
3736   textField.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT );
3737
3738   // Avoid a crash when core load gl resources.
3739   application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
3740
3741   application.SendNotification();
3742   application.Render();
3743
3744   textField.SetProperty( TextField::Property::TEXT, "Hello world" );
3745
3746   application.SendNotification();
3747   application.Render();
3748
3749   textField.SetProperty( DevelTextField::Property::SELECTED_TEXT_START , 0);
3750   textField.SetProperty( DevelTextField::Property::SELECTED_TEXT_END , 5);
3751
3752   // Hello is selected
3753   std::string selectedText = textField.GetProperty( DevelTextField::Property::SELECTED_TEXT ).Get<std::string>();
3754   DALI_TEST_EQUALS( "Hello", selectedText, TEST_LOCATION );
3755
3756   DALI_TEST_EQUALS( textField.GetProperty( DevelTextField::Property::SELECTED_TEXT_START ).Get<int>(), 0, TEST_LOCATION );
3757   DALI_TEST_EQUALS( textField.GetProperty( DevelTextField::Property::SELECTED_TEXT_END ).Get<int>(), 5, TEST_LOCATION );
3758
3759   textField.SetProperty( DevelTextField::Property::SELECTED_TEXT_START , 6);
3760   textField.SetProperty( DevelTextField::Property::SELECTED_TEXT_END , 11);
3761
3762   // world is selected
3763   selectedText = textField.GetProperty( DevelTextField::Property::SELECTED_TEXT ).Get<std::string>();
3764   DALI_TEST_EQUALS( "world", selectedText, TEST_LOCATION );
3765
3766   DALI_TEST_EQUALS( textField.GetProperty( DevelTextField::Property::SELECTED_TEXT_START ).Get<int>(), 6, TEST_LOCATION );
3767   DALI_TEST_EQUALS( textField.GetProperty( DevelTextField::Property::SELECTED_TEXT_END ).Get<int>(), 11, TEST_LOCATION );
3768
3769   END_TEST;
3770 }
3771
3772 int UtcDaliTextFieldEnableEditing(void)
3773 {
3774   ToolkitTestApplication application;
3775   tet_infoline(" UtcDaliTextFieldEnableEditing ");
3776
3777   TextField textField = TextField::New();
3778
3779   application.GetScene().Add( textField );
3780
3781   textField.SetProperty( Actor::Property::SIZE, Vector2( 300.f, 50.f ) );
3782   textField.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT );
3783   textField.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT );
3784
3785   // Avoid a crash when core load gl resources.
3786   application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
3787
3788   application.SendNotification();
3789   application.Render();
3790
3791   textField.SetKeyInputFocus();
3792   textField.SetProperty( DevelTextField::Property::ENABLE_EDITING, false );
3793   application.ProcessEvent( GenerateKey( "D", "", "D", KEY_D_CODE, 0, 0, Integration::KeyEvent::DOWN, "D", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
3794
3795   // Render and notify
3796   application.SendNotification();
3797   application.Render();
3798
3799   DALI_TEST_EQUALS( textField.GetProperty( TextField::Property::TEXT ).Get<std::string>(), "", TEST_LOCATION );
3800   DALI_TEST_EQUALS( textField.GetProperty( DevelTextField::Property::ENABLE_EDITING ).Get<bool>(), false, TEST_LOCATION );
3801
3802
3803   textField.SetKeyInputFocus();
3804   textField.SetProperty( DevelTextField::Property::ENABLE_EDITING, true );
3805   application.ProcessEvent( GenerateKey( "D", "", "D", KEY_D_CODE, 0, 0, Integration::KeyEvent::DOWN, "D", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
3806
3807   // Render and notify
3808   application.SendNotification();
3809   application.Render();
3810
3811   DALI_TEST_EQUALS( textField.GetProperty( TextField::Property::TEXT ).Get<std::string>(), "D", TEST_LOCATION );
3812   DALI_TEST_EQUALS( textField.GetProperty( DevelTextField::Property::ENABLE_EDITING ).Get<bool>(), true, TEST_LOCATION );
3813
3814   END_TEST;
3815 }
3816
3817 int UtcDaliToolkitTextFieldFontSizeScale(void)
3818 {
3819   ToolkitTestApplication application;
3820   tet_infoline(" UtcDaliToolkitTextFieldFontSizeScale");
3821
3822   TextField textField = TextField::New();
3823   textField.SetProperty( TextField::Property::POINT_SIZE, 30.f );
3824   textField.SetProperty( TextField::Property::TEXT, "Test" );
3825   Vector3 nonScaledSize = textField.GetNaturalSize();
3826
3827   TextField textFieldScaled = TextField::New();
3828   textFieldScaled.SetProperty( TextField::Property::POINT_SIZE, 15.f );
3829   textFieldScaled.SetProperty( Toolkit::DevelTextField::Property::FONT_SIZE_SCALE, 2.f );
3830   textFieldScaled.SetProperty( TextField::Property::TEXT, "Test" );
3831   Vector3 scaledSize = textFieldScaled.GetNaturalSize();
3832
3833   DALI_TEST_EQUALS( nonScaledSize, scaledSize, TEST_LOCATION );
3834
3835   textField.SetProperty( TextField::Property::PIXEL_SIZE, 30.f );
3836   textField.SetProperty( TextField::Property::TEXT, "Test" );
3837   nonScaledSize = textField.GetNaturalSize();
3838
3839   textFieldScaled.SetProperty( TextField::Property::PIXEL_SIZE, 15.f );
3840   textFieldScaled.SetProperty( Toolkit::DevelTextField::Property::FONT_SIZE_SCALE, 2.f );
3841   textFieldScaled.SetProperty( TextField::Property::TEXT, "Test" );
3842   scaledSize = textFieldScaled.GetNaturalSize();
3843
3844   DALI_TEST_EQUALS( nonScaledSize, scaledSize, TEST_LOCATION );
3845
3846   END_TEST;
3847 }
3848
3849 int UtcDaliTextFieldPrimaryCursorPosition(void)
3850 {
3851   ToolkitTestApplication application;
3852   tet_infoline(" UtcDaliTextFieldPrimaryCursorPosition ");
3853
3854   TextField textField = TextField::New();
3855
3856   application.GetScene().Add( textField );
3857
3858   textField.SetProperty( TextField::Property::TEXT, "ABCEF");
3859   textField.SetProperty( Actor::Property::SIZE, Vector2( 300.f, 50.f ) );
3860   textField.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT );
3861   textField.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT );
3862
3863   // Avoid a crash when core load gl resources.
3864   application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
3865
3866   textField.SetProperty( DevelTextField::Property::PRIMARY_CURSOR_POSITION, 3);
3867   application.SendNotification();
3868   application.Render();
3869   textField.SetKeyInputFocus();
3870
3871   application.ProcessEvent( GenerateKey( "D", "", "D", KEY_D_CODE, 0, 0, Integration::KeyEvent::DOWN, "D", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
3872
3873   // Render and notify
3874   application.SendNotification();
3875   application.Render();
3876
3877   DALI_TEST_EQUALS( textField.GetProperty( TextField::Property::TEXT ).Get<std::string>(), "ABCDEF", TEST_LOCATION );
3878   DALI_TEST_EQUALS( textField.GetProperty( DevelTextField::Property::PRIMARY_CURSOR_POSITION ).Get<int>(), 4, TEST_LOCATION );
3879
3880   END_TEST;
3881 }
3882
3883 // test max length when set after setting long text
3884 int utcDaliTextFieldMaxCharactersReachedAfterSetText(void)
3885 {
3886   ToolkitTestApplication application;
3887   tet_infoline(" utcDaliTextFieldMaxCharactersReachedAfterSetText");
3888   TextField field = TextField::New();
3889   DALI_TEST_CHECK( field );
3890
3891   application.GetScene().Add( field );
3892
3893   field.SetProperty(TextField::Property::TEXT, "123456789");
3894
3895   const int maxNumberOfCharacters = 3;
3896   field.SetProperty( TextField::Property::MAX_LENGTH, maxNumberOfCharacters );
3897
3898   field.SetKeyInputFocus();
3899
3900   // connect to the text max lengh reached signal.
3901   ConnectionTracker* testTracker = new ConnectionTracker();
3902   bool maxLengthReachedSignal = false;
3903   field.ConnectSignal( testTracker, "maxLengthReached",   CallbackFunctor(&maxLengthReachedSignal) );
3904
3905   application.ProcessEvent( GenerateKey( "a", "", "a", KEY_A_CODE, 0, 0, Integration::KeyEvent::DOWN, "a", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
3906   application.ProcessEvent( GenerateKey( "a", "", "a", KEY_A_CODE, 0, 0, Integration::KeyEvent::DOWN, "a", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
3907
3908   DALI_TEST_CHECK( maxLengthReachedSignal );
3909
3910   DALI_TEST_EQUALS( field.GetProperty( TextField::Property::TEXT ).Get<std::string>(), "123456789", TEST_LOCATION );
3911
3912   END_TEST;
3913 }
3914
3915
3916
3917 int UtcDaliTextFieldAtlasLimitationIsEnabledForLargeFontPointSize(void)
3918 {
3919   ToolkitTestApplication application;
3920   tet_infoline(" UtcDaliTextFieldAtlasLimitationIsEnabledForLargeFontPointSize ");
3921
3922   // +2: First one to handle the equal case. Second one to handle odd to even case of GetNaturalSize
3923   const uint32_t lessThanWidth = TextAbstraction::FontClient::MAX_TEXT_ATLAS_WIDTH - TextAbstraction::FontClient::PADDING_TEXT_ATLAS_BLOCK + 2;
3924   const uint32_t lessThanHeight = TextAbstraction::FontClient::MAX_TEXT_ATLAS_HEIGHT - TextAbstraction::FontClient::PADDING_TEXT_ATLAS_BLOCK + 2;
3925
3926   // Create a text field
3927   TextField textField = TextField::New();
3928
3929   //Set size to avoid automatic eliding
3930   textField.SetProperty( Actor::Property::SIZE, Vector2(1025, 1025));
3931   //Set very large font-size using point-size
3932   textField.SetProperty( TextField::Property::POINT_SIZE, 1000) ;
3933   //Specify font-family
3934   textField.SetProperty( TextField::Property::FONT_FAMILY, "DejaVu Sans");
3935   //Set text to check if appear or not
3936   textField.SetProperty( TextField::Property::TEXT, "A");
3937
3938   application.GetScene().Add( textField );
3939
3940   application.SendNotification();
3941   application.Render();
3942   //Use GetNaturalSize to verify that size of block does not exceed Atlas size
3943   Vector3 naturalSize = textField.GetNaturalSize();
3944
3945   DALI_TEST_GREATER( lessThanWidth, static_cast<uint32_t>(naturalSize.width), TEST_LOCATION );
3946   DALI_TEST_GREATER( lessThanHeight, static_cast<uint32_t>(naturalSize.height), TEST_LOCATION );
3947
3948   END_TEST;
3949 }
3950
3951 int UtcDaliTextFieldAtlasLimitationIsEnabledPerformanceCases(void)
3952 {
3953   ToolkitTestApplication application;
3954   tet_infoline(" UtcDaliTextFieldAtlasLimitationIsEnabledPerformanceCases ");
3955
3956   // +2: First one to handle the equal case. Second one to handle odd to even case of GetNaturalSize
3957   const uint32_t lessThanWidth = TextAbstraction::FontClient::MAX_TEXT_ATLAS_WIDTH - TextAbstraction::FontClient::PADDING_TEXT_ATLAS_BLOCK + 2;
3958   const uint32_t lessThanHeight = TextAbstraction::FontClient::MAX_TEXT_ATLAS_HEIGHT - TextAbstraction::FontClient::PADDING_TEXT_ATLAS_BLOCK + 2;
3959
3960   Vector3 naturalSize; //Use GetNaturalSize to verify that size of block does not exceed Atlas size
3961   // Create a text editor
3962   TextField textField = TextField::New();
3963
3964   //Set size to avoid automatic eliding
3965   textField.SetProperty( Actor::Property::SIZE, Vector2(1025, 1025));
3966   textField.SetProperty( TextField::Property::FONT_FAMILY, "DejaVu Sans");
3967   textField.SetProperty( TextField::Property::TEXT, "A");
3968
3969   const int numberOfCases = 6;
3970   int arrayCases[numberOfCases] = {323, 326, 330, 600, 1630, 2500};
3971
3972   for (int index=0; index < numberOfCases; index++)
3973   {
3974     tet_printf(" UtcDaliTextFieldAtlasLimitationIsEnabledPerformanceCases point-size= %d \n", arrayCases[index]);
3975     textField.SetProperty( TextField::Property::POINT_SIZE, arrayCases[index]) ;
3976     application.GetScene().Add( textField );
3977     application.SendNotification();
3978     application.Render();
3979     naturalSize = textField.GetNaturalSize();
3980     DALI_TEST_GREATER( lessThanWidth, static_cast<uint32_t>(naturalSize.width), TEST_LOCATION );
3981     DALI_TEST_GREATER( lessThanHeight, static_cast<uint32_t>(naturalSize.height), TEST_LOCATION );
3982
3983   }
3984
3985   END_TEST;
3986 }
3987
3988 int UtcDaliToolkitTextFieldEllipsisPositionProperty(void)
3989 {
3990   ToolkitTestApplication application;
3991   tet_infoline(" UtcDaliToolkitTextFieldEllipsisPositionProperty ");
3992   TextField textField = TextField::New();
3993
3994   tet_infoline(" UtcDaliToolkitTextFieldEllipsisPositionProperty - Default is END");
3995   DALI_TEST_EQUALS( textField.GetProperty< int >( DevelTextField::Property::ELLIPSIS_POSITION ), static_cast< int >( Toolkit::DevelText::EllipsisPosition::END ), TEST_LOCATION );
3996
3997   tet_infoline(" UtcDaliToolkitTextFieldEllipsisPositionProperty - Change to START");
3998   textField.SetProperty(DevelTextField::Property::ELLIPSIS_POSITION, DevelText::EllipsisPosition::START);
3999   DALI_TEST_EQUALS( textField.GetProperty< int >( DevelTextField::Property::ELLIPSIS_POSITION ), static_cast< int >( Toolkit::DevelText::EllipsisPosition::START ), TEST_LOCATION );
4000
4001   tet_infoline(" UtcDaliToolkitTextFieldEllipsisPositionProperty - Change to MIDDLE");
4002   textField.SetProperty(DevelTextField::Property::ELLIPSIS_POSITION, DevelText::EllipsisPosition::MIDDLE);
4003   DALI_TEST_EQUALS( textField.GetProperty< int >( DevelTextField::Property::ELLIPSIS_POSITION ), static_cast< int >( Toolkit::DevelText::EllipsisPosition::MIDDLE ), TEST_LOCATION );
4004
4005   tet_infoline(" UtcDaliToolkitTextFieldEllipsisPositionProperty - Change to END");
4006   textField.SetProperty(DevelTextField::Property::ELLIPSIS_POSITION, DevelText::EllipsisPosition::END);
4007   DALI_TEST_EQUALS( textField.GetProperty< int >( DevelTextField::Property::ELLIPSIS_POSITION ), static_cast< int >( Toolkit::DevelText::EllipsisPosition::END ), TEST_LOCATION );
4008
4009   tet_infoline(" UtcDaliToolkitTextFieldEllipsisPositionProperty - Change to START using integer");
4010   textField.SetProperty(DevelTextField::Property::ELLIPSIS_POSITION, 1);
4011   DALI_TEST_EQUALS( textField.GetProperty< int >( DevelTextField::Property::ELLIPSIS_POSITION ), static_cast< int >( Toolkit::DevelText::EllipsisPosition::START ), TEST_LOCATION );
4012
4013   tet_infoline(" UtcDaliToolkitTextFieldEllipsisPositionProperty - Change to MIDDLE using integer");
4014   textField.SetProperty(DevelTextField::Property::ELLIPSIS_POSITION, 2);
4015   DALI_TEST_EQUALS( textField.GetProperty< int >( DevelTextField::Property::ELLIPSIS_POSITION ), static_cast< int >( Toolkit::DevelText::EllipsisPosition::MIDDLE ), TEST_LOCATION );
4016
4017   tet_infoline(" UtcDaliToolkitTextFieldEllipsisPositionProperty - Change to END using integer");
4018   textField.SetProperty(DevelTextField::Property::ELLIPSIS_POSITION, 0);
4019   DALI_TEST_EQUALS( textField.GetProperty< int >( DevelTextField::Property::ELLIPSIS_POSITION ), static_cast< int >( Toolkit::DevelText::EllipsisPosition::END ), TEST_LOCATION );
4020
4021   tet_infoline(" UtcDaliToolkitTextlabelEllipsisPositionProperty - Change to START using string - uppercase");
4022   textField.SetProperty(DevelTextField::Property::ELLIPSIS_POSITION, "START");
4023   DALI_TEST_EQUALS( textField.GetProperty< int >( DevelTextField::Property::ELLIPSIS_POSITION ), static_cast< int >( Toolkit::DevelText::EllipsisPosition::START ), TEST_LOCATION );
4024
4025   tet_infoline(" UtcDaliToolkitTextlabelEllipsisPositionProperty - Change to MIDDLE using string - uppercase");
4026   textField.SetProperty(DevelTextField::Property::ELLIPSIS_POSITION, "MIDDLE");
4027   DALI_TEST_EQUALS( textField.GetProperty< int >( DevelTextField::Property::ELLIPSIS_POSITION ), static_cast< int >( Toolkit::DevelText::EllipsisPosition::MIDDLE ), TEST_LOCATION );
4028
4029   tet_infoline(" UtcDaliToolkitTextlabelEllipsisPositionProperty - Change to END using string - uppercase");
4030   textField.SetProperty(DevelTextField::Property::ELLIPSIS_POSITION, "END");
4031   DALI_TEST_EQUALS( textField.GetProperty< int >( DevelTextField::Property::ELLIPSIS_POSITION ), static_cast< int >( Toolkit::DevelText::EllipsisPosition::END ), TEST_LOCATION );
4032
4033   tet_infoline(" UtcDaliToolkitTextlabelEllipsisPositionProperty - Change to START using string - lowercase");
4034   textField.SetProperty(DevelTextField::Property::ELLIPSIS_POSITION, "start");
4035   DALI_TEST_EQUALS( textField.GetProperty< int >( DevelTextField::Property::ELLIPSIS_POSITION ), static_cast< int >( Toolkit::DevelText::EllipsisPosition::START ), TEST_LOCATION );
4036
4037   tet_infoline(" UtcDaliToolkitTextlabelEllipsisPositionProperty - Change to MIDDLE using string - lowercase");
4038   textField.SetProperty(DevelTextField::Property::ELLIPSIS_POSITION, "middle");
4039   DALI_TEST_EQUALS( textField.GetProperty< int >( DevelTextField::Property::ELLIPSIS_POSITION ), static_cast< int >( Toolkit::DevelText::EllipsisPosition::MIDDLE ), TEST_LOCATION );
4040
4041   tet_infoline(" UtcDaliToolkitTextlabelEllipsisPositionProperty - Change to END using string - lowercase");
4042   textField.SetProperty(DevelTextField::Property::ELLIPSIS_POSITION, "end");
4043   DALI_TEST_EQUALS( textField.GetProperty< int >( DevelTextField::Property::ELLIPSIS_POSITION ), static_cast< int >( Toolkit::DevelText::EllipsisPosition::END ), TEST_LOCATION );
4044
4045   END_TEST;
4046 }
4047
4048 int UtcDaliTextFieldCopyText(void)
4049 {
4050   ToolkitTestApplication application;
4051   tet_infoline(" UtcDaliTextFieldCopyText ");
4052
4053   TextField textField = TextField::New();
4054
4055   std::string selectedText = "";
4056   std::string copiedText = "";
4057
4058   application.GetScene().Add( textField );
4059
4060   textField.SetProperty( Actor::Property::SIZE, Vector2( 300.f, 50.f ) );
4061   textField.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT );
4062   textField.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT );
4063
4064   // Avoid a crash when core load gl resources.
4065   application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
4066
4067   application.SendNotification();
4068   application.Render();
4069
4070   textField.SetProperty( TextField::Property::TEXT, "Hello world" );
4071
4072   application.SendNotification();
4073   application.Render();
4074
4075   // Hello is selected
4076   DevelTextField::SelectText( textField, 0, 5 );
4077
4078   application.SendNotification();
4079   application.Render();
4080
4081   selectedText = textField.GetProperty( DevelTextField::Property::SELECTED_TEXT ).Get<std::string>();
4082   DALI_TEST_EQUALS( "Hello", selectedText, TEST_LOCATION );
4083
4084   DALI_TEST_EQUALS( textField.GetProperty( DevelTextField::Property::SELECTED_TEXT_START ).Get<int>(), 0, TEST_LOCATION );
4085   DALI_TEST_EQUALS( textField.GetProperty( DevelTextField::Property::SELECTED_TEXT_END ).Get<int>(), 5, TEST_LOCATION );
4086
4087   // Hello is copied
4088   copiedText = DevelTextField::CopyText( textField );
4089   DALI_TEST_EQUALS( "Hello", copiedText, TEST_LOCATION );
4090
4091   // world is selected
4092   DevelTextField::SelectText( textField, 6, 11 );
4093
4094   application.SendNotification();
4095   application.Render();
4096
4097   selectedText = textField.GetProperty( DevelTextField::Property::SELECTED_TEXT ).Get<std::string>();
4098   DALI_TEST_EQUALS( "world", selectedText, TEST_LOCATION );
4099
4100   DALI_TEST_EQUALS( textField.GetProperty( DevelTextField::Property::SELECTED_TEXT_START ).Get<int>(), 6, TEST_LOCATION );
4101   DALI_TEST_EQUALS( textField.GetProperty( DevelTextField::Property::SELECTED_TEXT_END ).Get<int>(), 11, TEST_LOCATION );
4102
4103   // world is copied
4104   copiedText = DevelTextField::CopyText( textField );
4105   DALI_TEST_EQUALS( "world", copiedText, TEST_LOCATION );
4106
4107   // "lo wo" is selected
4108   DevelTextField::SelectText( textField, 3, 8 );
4109
4110   application.SendNotification();
4111   application.Render();
4112
4113   selectedText = textField.GetProperty( DevelTextField::Property::SELECTED_TEXT ).Get<std::string>();
4114   DALI_TEST_EQUALS( "lo wo", selectedText, TEST_LOCATION );
4115
4116   DALI_TEST_EQUALS( textField.GetProperty( DevelTextField::Property::SELECTED_TEXT_START ).Get<int>(), 3, TEST_LOCATION );
4117   DALI_TEST_EQUALS( textField.GetProperty( DevelTextField::Property::SELECTED_TEXT_END ).Get<int>(), 8, TEST_LOCATION );
4118
4119   // "lo wo" is copied
4120   copiedText = DevelTextField::CopyText( textField );
4121   DALI_TEST_EQUALS( "lo wo", copiedText, TEST_LOCATION );
4122
4123   END_TEST;
4124 }
4125
4126 int UtcDaliTextFieldCutText(void)
4127 {
4128   ToolkitTestApplication application;
4129   tet_infoline(" UtcDaliTextFieldCutText ");
4130
4131   TextField textField = TextField::New();
4132
4133   std::string selectedText = "";
4134
4135   application.GetScene().Add( textField );
4136
4137   textField.SetProperty( Actor::Property::SIZE, Vector2( 300.f, 50.f ) );
4138   textField.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT );
4139   textField.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT );
4140
4141   // Avoid a crash when core load gl resources.
4142   application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
4143
4144   application.SendNotification();
4145   application.Render();
4146
4147   textField.SetProperty( TextField::Property::TEXT, "Hello world" );
4148
4149   application.SendNotification();
4150   application.Render();
4151
4152   // Hello is selected
4153   DevelTextField::SelectText( textField, 0, 5 );
4154
4155   application.SendNotification();
4156   application.Render();
4157
4158   selectedText = textField.GetProperty( DevelTextField::Property::SELECTED_TEXT ).Get<std::string>();
4159   DALI_TEST_EQUALS( "Hello", selectedText, TEST_LOCATION );
4160
4161   DALI_TEST_EQUALS( textField.GetProperty( DevelTextField::Property::SELECTED_TEXT_START ).Get<int>(), 0, TEST_LOCATION );
4162   DALI_TEST_EQUALS( textField.GetProperty( DevelTextField::Property::SELECTED_TEXT_END ).Get<int>(), 5, TEST_LOCATION );
4163
4164   // Hello is cut
4165   DALI_TEST_EQUALS( "Hello", DevelTextField::CutText( textField ), TEST_LOCATION );
4166
4167   DALI_TEST_EQUALS( textField.GetProperty( TextField::Property::TEXT ).Get<std::string>(), " world", TEST_LOCATION );
4168
4169   // " w" is selected
4170   DevelTextField::SelectText( textField, 0, 2 );
4171
4172   application.SendNotification();
4173   application.Render();
4174
4175   selectedText = textField.GetProperty( DevelTextField::Property::SELECTED_TEXT ).Get<std::string>();
4176   DALI_TEST_EQUALS( " w", selectedText, TEST_LOCATION );
4177
4178   DALI_TEST_EQUALS( textField.GetProperty( DevelTextField::Property::SELECTED_TEXT_START ).Get<int>(), 0, TEST_LOCATION );
4179   DALI_TEST_EQUALS( textField.GetProperty( DevelTextField::Property::SELECTED_TEXT_END ).Get<int>(), 2, TEST_LOCATION );
4180
4181   // " w" is cut
4182   DALI_TEST_EQUALS( " w", DevelTextField::CutText( textField ), TEST_LOCATION );
4183
4184   application.SendNotification();
4185   application.Render();
4186
4187   DALI_TEST_EQUALS( textField.GetProperty( TextField::Property::TEXT ).Get<std::string>(), "orld", TEST_LOCATION );
4188
4189   // Test Cut from the middle
4190
4191   // "rl" is selected
4192   DevelTextField::SelectText( textField, 1, 3 );
4193
4194   application.SendNotification();
4195   application.Render();
4196
4197   selectedText = textField.GetProperty( DevelTextField::Property::SELECTED_TEXT ).Get<std::string>();
4198   DALI_TEST_EQUALS( "rl", selectedText, TEST_LOCATION );
4199
4200   DALI_TEST_EQUALS( textField.GetProperty( DevelTextField::Property::SELECTED_TEXT_START ).Get<int>(), 1, TEST_LOCATION );
4201   DALI_TEST_EQUALS( textField.GetProperty( DevelTextField::Property::SELECTED_TEXT_END ).Get<int>(), 3, TEST_LOCATION );
4202
4203   // "rl" is cut
4204   DALI_TEST_EQUALS( "rl", DevelTextField::CutText( textField ), TEST_LOCATION );
4205
4206   application.SendNotification();
4207   application.Render();
4208
4209   DALI_TEST_EQUALS( textField.GetProperty( TextField::Property::TEXT ).Get<std::string>(), "od", TEST_LOCATION );
4210
4211   // Test Cut from the end
4212
4213   // "d" is selected
4214   DevelTextField::SelectText( textField, 1, 2 );
4215
4216   application.SendNotification();
4217   application.Render();
4218
4219   selectedText = textField.GetProperty( DevelTextField::Property::SELECTED_TEXT ).Get<std::string>();
4220   DALI_TEST_EQUALS( "d", selectedText, TEST_LOCATION );
4221
4222   DALI_TEST_EQUALS( textField.GetProperty( DevelTextField::Property::SELECTED_TEXT_START ).Get<int>(), 1, TEST_LOCATION );
4223   DALI_TEST_EQUALS( textField.GetProperty( DevelTextField::Property::SELECTED_TEXT_END ).Get<int>(), 2, TEST_LOCATION );
4224
4225   // "d" is cut
4226   DALI_TEST_EQUALS( "d", DevelTextField::CutText( textField ), TEST_LOCATION );
4227
4228   application.SendNotification();
4229   application.Render();
4230
4231   DALI_TEST_EQUALS( textField.GetProperty( TextField::Property::TEXT ).Get<std::string>(), "o", TEST_LOCATION );
4232
4233   END_TEST;
4234 }
4235
4236 int UtcDaliTextFieldPasteText(void)
4237 {
4238   ToolkitTestApplication application;
4239   tet_infoline(" UtcDaliTextFieldPasteText ");
4240
4241   TextField textField = TextField::New();
4242
4243   application.GetScene().Add( textField );
4244
4245   std::string cutText = "";
4246   std::string copiedText = "";
4247
4248   textField.SetProperty( Actor::Property::SIZE, Vector2( 300.f, 50.f ) );
4249   textField.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT );
4250   textField.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT );
4251
4252   // Avoid a crash when core load gl resources.
4253   application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
4254
4255   application.SendNotification();
4256   application.Render();
4257
4258   textField.SetProperty( TextField::Property::TEXT, "Hello World" );
4259
4260   application.SendNotification();
4261   application.Render();
4262
4263   // Tap on the text editor
4264   TestGenerateTap( application, 3.0f, 25.0f );
4265
4266   // Render and notify
4267   application.SendNotification();
4268   application.Render();
4269
4270   // Select some text in the right of the current cursor position
4271   DevelTextField::SelectText( textField, 0, 3 );
4272
4273   // Render and notify
4274   application.SendNotification();
4275   application.Render();
4276
4277   // Cut the selected text
4278   cutText = DevelTextField::CutText(textField);
4279
4280   // Render and notify
4281   application.SendNotification();
4282   application.Render();
4283
4284   DALI_TEST_EQUALS( "Hel", cutText, TEST_LOCATION );
4285   DALI_TEST_EQUALS( textField.GetProperty( TextField::Property::TEXT ).Get<std::string>(), "lo World", TEST_LOCATION );
4286
4287   DevelTextField::SelectText( textField, 0, 3 );
4288
4289   // Render and notify
4290   application.SendNotification();
4291   application.Render();
4292
4293   // Copy the selected text
4294   copiedText = DevelTextField::CopyText(textField);
4295
4296   // Render and notify
4297   application.SendNotification();
4298   application.Render();
4299
4300   DALI_TEST_EQUALS( "lo ", copiedText, TEST_LOCATION );
4301   DALI_TEST_EQUALS( "lo World", textField.GetProperty<std::string>( TextField::Property::TEXT ), TEST_LOCATION );
4302
4303   // Move the cursor to the end of the line
4304   application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_RIGHT, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
4305   application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_RIGHT, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
4306   application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_RIGHT, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
4307   application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_RIGHT, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
4308   application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_RIGHT, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
4309   application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_RIGHT, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
4310   application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_RIGHT, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
4311   application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_RIGHT, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
4312
4313   // Render and notify
4314   application.SendNotification();
4315   application.Render();
4316
4317   // Paste the selected text at the current cursor position
4318   DevelTextField::PasteText(textField);
4319
4320   // Render and notify
4321   application.SendNotification();
4322   application.Render();
4323
4324   DALI_TEST_EQUALS( textField.GetProperty( TextField::Property::TEXT ).Get<std::string>(), "lo Worldlo ", TEST_LOCATION );
4325
4326   END_TEST;
4327 }
4328 int utcDaliTextFieldCursorPositionChangedSignal(void)
4329 {
4330   ToolkitTestApplication application;
4331   tet_infoline(" utcDaliTextFieldCursorPositionChangedSignal");
4332
4333   TextField field = TextField::New();
4334   DALI_TEST_CHECK( field );
4335
4336   application.GetScene().Add( field );
4337
4338   // connect to the selection changed signal.
4339   ConnectionTracker* testTracker = new ConnectionTracker();
4340   DevelTextField::CursorPositionChangedSignal(field).Connect(&TestCursorPositionChangedCallback);
4341   bool cursorPositionChangedSignal = false;
4342   field.ConnectSignal( testTracker, "cursorPositionChanged",   CallbackFunctor(&cursorPositionChangedSignal) );
4343
4344   field.SetProperty( TextField::Property::TEXT, "Hello world Hello world" );
4345   field.SetProperty( TextField::Property::POINT_SIZE, 10.f );
4346   field.SetProperty( Actor::Property::SIZE, Vector2( 100.f, 50.f ) );
4347   field.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT );
4348   field.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT );
4349
4350   // Avoid a crash when core load gl resources.
4351   application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
4352
4353   // Render and notify
4354   application.SendNotification();
4355   application.Render();
4356
4357   field.SetKeyInputFocus();
4358
4359   // Tap on the text field
4360   TestGenerateTap( application, 3.0f, 25.0f );
4361
4362   // Render and notify
4363   application.SendNotification();
4364   application.Render();
4365
4366   DALI_TEST_CHECK(gCursorPositionChangedCallbackCalled);
4367   DALI_TEST_EQUALS(oldCursorPos, 23, TEST_LOCATION);
4368
4369   gCursorPositionChangedCallbackCalled = false;
4370
4371   // Move to left.
4372   application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_LEFT, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
4373
4374   // Render and notify
4375   application.SendNotification();
4376   application.Render();
4377
4378   DALI_TEST_CHECK(gCursorPositionChangedCallbackCalled);
4379   DALI_TEST_EQUALS(oldCursorPos, 17, TEST_LOCATION);
4380
4381   gCursorPositionChangedCallbackCalled = false;
4382
4383   // Insert D
4384   application.ProcessEvent( GenerateKey( "D", "", "D", KEY_D_CODE, 0, 0, Integration::KeyEvent::DOWN, "D", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
4385
4386   // Render and notify
4387   application.SendNotification();
4388   application.Render();
4389
4390   DALI_TEST_CHECK(gCursorPositionChangedCallbackCalled);
4391   DALI_TEST_EQUALS(oldCursorPos, 16, TEST_LOCATION);
4392
4393   gCursorPositionChangedCallbackCalled = false;
4394
4395   //delete one character
4396   application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_BACKSPACE, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
4397
4398   // Render and notify
4399   application.SendNotification();
4400   application.Render();
4401
4402   DALI_TEST_CHECK(gCursorPositionChangedCallbackCalled);
4403   DALI_TEST_EQUALS(oldCursorPos, 17, TEST_LOCATION);
4404
4405   gCursorPositionChangedCallbackCalled = false;
4406
4407   field.SetProperty( TextField::Property::TEXT, "Hello" );
4408
4409   // Render and notify
4410   application.SendNotification();
4411   application.Render();
4412
4413   DALI_TEST_CHECK(gCursorPositionChangedCallbackCalled);
4414   DALI_TEST_EQUALS(oldCursorPos, 16, TEST_LOCATION);
4415
4416   gCursorPositionChangedCallbackCalled = false;
4417
4418   field.SetProperty(DevelTextField::Property::PRIMARY_CURSOR_POSITION, 3);
4419
4420   // Render and notify
4421   application.SendNotification();
4422   application.Render();
4423
4424   DALI_TEST_CHECK(gCursorPositionChangedCallbackCalled);
4425   DALI_TEST_EQUALS(oldCursorPos, 5, TEST_LOCATION);
4426
4427   END_TEST;
4428 }
4429
4430 int utcDaliTextFieldGeometryEllipsisStart(void)
4431 {
4432   ToolkitTestApplication application;
4433   tet_infoline(" utcDaliTextFieldGeometryEllipsisStart");
4434
4435   TextField field = TextField::New();
4436   DALI_TEST_CHECK( field );
4437
4438   application.GetScene().Add( field );
4439
4440   field.SetProperty( TextField::Property::POINT_SIZE, 7.f );
4441   field.SetProperty( Actor::Property::SIZE, Vector2( 250.f, 50.f ) );
4442   field.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT );
4443   field.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT );
4444   field.SetProperty( TextField::Property::ENABLE_MARKUP, true );
4445   field.SetProperty( DevelTextField::Property::ELLIPSIS, true );
4446   field.SetProperty( DevelTextField::Property::ELLIPSIS_POSITION, DevelText::EllipsisPosition::START );
4447   field.SetProperty( TextField::Property::TEXT, "Hello World" );
4448
4449   // Avoid a crash when core load gl resources.
4450   application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
4451
4452   // Render and notify
4453   application.SendNotification();
4454   application.Render();
4455
4456   unsigned int expectedCount = 1;
4457   unsigned int startIndex = 0;
4458   unsigned int endIndex = 10;
4459
4460   Vector<Vector2> positionsList = DevelTextField::GetTextPosition(field, startIndex, endIndex);
4461   Vector<Vector2> sizeList = DevelTextField::GetTextSize(field, startIndex, endIndex);
4462
4463   DALI_TEST_EQUALS(positionsList.Size(), expectedCount, TEST_LOCATION);
4464   DALI_TEST_EQUALS(sizeList.Size(), expectedCount, TEST_LOCATION);
4465
4466   Vector<Vector2> expectedSizes;
4467   Vector<Vector2> expectedPositions;
4468
4469   expectedPositions.PushBack(Vector2(14, 0));
4470   expectedSizes.PushBack(Vector2(106, 25));
4471
4472   TestTextGeometryUtils::CheckGeometryResult(positionsList, sizeList, expectedPositions, expectedSizes);
4473
4474   END_TEST;
4475 }
4476
4477 int utcDaliTextFieldGeometryEllipsisEnd(void)
4478 {
4479   ToolkitTestApplication application;
4480   tet_infoline(" utcDaliTextFieldGeometryEllipsisEnd");
4481
4482   TextField field = TextField::New();
4483   DALI_TEST_CHECK( field );
4484
4485   application.GetScene().Add( field );
4486
4487   field.SetProperty( TextField::Property::POINT_SIZE, 7.f );
4488   field.SetProperty( Actor::Property::SIZE, Vector2( 250.f, 50.f ) );
4489   field.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT );
4490   field.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT );
4491   field.SetProperty( TextField::Property::ENABLE_MARKUP, true );
4492   field.SetProperty( DevelTextField::Property::ELLIPSIS, true );
4493   field.SetProperty( DevelTextField::Property::ELLIPSIS_POSITION, DevelText::EllipsisPosition::END );
4494   field.SetProperty( TextField::Property::TEXT, "Hello World" );
4495
4496   // Avoid a crash when core load gl resources.
4497   application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
4498
4499   // Render and notify
4500   application.SendNotification();
4501   application.Render();
4502
4503   unsigned int expectedCount = 1;
4504   unsigned int startIndex = 0;
4505   unsigned int endIndex = 10;
4506
4507   Vector<Vector2> positionsList = DevelTextField::GetTextPosition(field, startIndex, endIndex);
4508   Vector<Vector2> sizeList = DevelTextField::GetTextSize(field, startIndex, endIndex);
4509
4510   DALI_TEST_EQUALS(positionsList.Size(), expectedCount, TEST_LOCATION);
4511   DALI_TEST_EQUALS(sizeList.Size(), expectedCount, TEST_LOCATION);
4512
4513   Vector<Vector2> expectedSizes;
4514   Vector<Vector2> expectedPositions;
4515
4516   expectedPositions.PushBack(Vector2(-2, 0));
4517   expectedSizes.PushBack(Vector2(122, 25));
4518
4519   TestTextGeometryUtils::CheckGeometryResult(positionsList, sizeList, expectedPositions, expectedSizes);
4520
4521   END_TEST;
4522 }
4523
4524 int utcDaliTextFieldGeometryRTL(void)
4525 {
4526   ToolkitTestApplication application;
4527   tet_infoline(" utcDaliTextFieldGeometryRTL");
4528
4529   TextField field = TextField::New();
4530   DALI_TEST_CHECK( field );
4531
4532   application.GetScene().Add( field );
4533
4534   field.SetProperty( TextField::Property::POINT_SIZE, 7.f );
4535   field.SetProperty( Actor::Property::SIZE, Vector2( 300.f, 50.f ) );
4536   field.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT );
4537   field.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT );
4538   field.SetProperty( TextField::Property::ENABLE_MARKUP, true );
4539   field.SetProperty( TextField::Property::TEXT, "السطر الاخير" );
4540
4541   // Avoid a crash when core load gl resources.
4542   application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
4543
4544   // Render and notify
4545   application.SendNotification();
4546   application.Render();
4547
4548   unsigned int expectedCount = 1;
4549   unsigned int startIndex = 1;
4550   unsigned int endIndex = 7;
4551
4552   Vector<Vector2> positionsList = DevelTextField::GetTextPosition(field, startIndex, endIndex);
4553   Vector<Vector2> sizeList = DevelTextField::GetTextSize(field, startIndex, endIndex);
4554
4555   DALI_TEST_EQUALS(positionsList.Size(), expectedCount, TEST_LOCATION);
4556   DALI_TEST_EQUALS(sizeList.Size(), expectedCount, TEST_LOCATION);
4557
4558   Vector<Vector2> expectedSizes;
4559   Vector<Vector2> expectedPositions;
4560
4561   expectedPositions.PushBack(Vector2(38, 0));
4562   expectedSizes.PushBack(Vector2(73, 25));
4563
4564   TestTextGeometryUtils::CheckGeometryResult(positionsList, sizeList, expectedPositions, expectedSizes);
4565
4566   END_TEST;
4567 }
4568
4569 int utcDaliTextFieldGeometryGlyphMiddle(void)
4570 {
4571   ToolkitTestApplication application;
4572   tet_infoline(" utcDaliTextFieldGeometryGlyphMiddle");
4573
4574   TextField field = TextField::New();
4575   DALI_TEST_CHECK( field );
4576
4577   application.GetScene().Add( field );
4578
4579   field.SetProperty( TextField::Property::POINT_SIZE, 7.f );
4580   field.SetProperty( Actor::Property::SIZE, Vector2( 150.f, 200.f ) );
4581   field.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT );
4582   field.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT );
4583   field.SetProperty( TextField::Property::ENABLE_MARKUP, true );
4584   field.SetProperty( TextField::Property::TEXT, "لا تحتوي على لا" );
4585
4586   // Avoid a crash when core load gl resources.
4587   application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
4588
4589   // Render and notify
4590   application.SendNotification();
4591   application.Render();
4592
4593   unsigned int expectedCount = 1;
4594   unsigned int startIndex = 1;
4595   unsigned int endIndex = 13;
4596
4597   Vector<Vector2> positionsList = DevelTextField::GetTextPosition(field, startIndex, endIndex);
4598   Vector<Vector2> sizeList = DevelTextField::GetTextSize(field, startIndex, endIndex);
4599
4600   DALI_TEST_EQUALS(positionsList.Size(), expectedCount, TEST_LOCATION);
4601   DALI_TEST_EQUALS(sizeList.Size(), expectedCount, TEST_LOCATION);
4602
4603   Vector<Vector2> expectedSizes;
4604   Vector<Vector2> expectedPositions;
4605
4606   expectedPositions.PushBack(Vector2(6, 0));
4607   expectedSizes.PushBack(Vector2(124, 25));
4608
4609   TestTextGeometryUtils::CheckGeometryResult(positionsList, sizeList, expectedPositions, expectedSizes);
4610
4611   END_TEST;
4612 }
4613
4614 int utcDaliTextFieldSelectionClearedSignal(void)
4615 {
4616   ToolkitTestApplication application;
4617   tet_infoline(" utcDaliTextFieldSelectionClearedSignal");
4618
4619   TextField field = TextField::New();
4620   DALI_TEST_CHECK( field );
4621
4622   application.GetScene().Add( field );
4623
4624   // connect to the selection changed signal.
4625   ConnectionTracker* testTracker = new ConnectionTracker();
4626   DevelTextField::SelectionClearedSignal(field).Connect(&TestSelectionClearedCallback);
4627   bool selectionClearedSignal = false;
4628   field.ConnectSignal( testTracker, "selectionCleared",   CallbackFunctor(&selectionClearedSignal) );
4629
4630   field.SetProperty( TextField::Property::TEXT, "Hello\nworld\nHello world" );
4631   field.SetProperty( TextField::Property::POINT_SIZE, 10.f );
4632   field.SetProperty( Actor::Property::SIZE, Vector2( 100.f, 50.f ) );
4633   field.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT );
4634   field.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT );
4635
4636   // Avoid a crash when core load gl resources.
4637   application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
4638
4639   // Render and notify
4640   application.SendNotification();
4641   application.Render();
4642
4643   // Tap on the text editor
4644   TestGenerateTap( application, 3.0f, 25.0f );
4645
4646   // Render and notify
4647   application.SendNotification();
4648   application.Render();
4649
4650   // Move to second line of the text & Select some text in the right of the current cursor position
4651   application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_DOWN, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) ); 
4652   application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_RIGHT, KEY_SHIFT_MODIFIER, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
4653
4654   // remove selection
4655   application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_ESCAPE, 0, 0, Integration::KeyEvent::UP, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
4656
4657   // Render and notify
4658   application.SendNotification();
4659   application.Render();
4660
4661   DALI_TEST_CHECK(gSelectionClearedCallbackCalled);
4662
4663   // Render and notify
4664   application.SendNotification();
4665   application.Render();
4666
4667   // Tap on the text editor
4668   TestGenerateTap( application, 3.0f, 25.0f );
4669
4670   // Render and notify
4671   application.SendNotification();
4672   application.Render();
4673
4674   gSelectionClearedCallbackCalled = false;
4675
4676   // Move to second line of the text & select.
4677   application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_DOWN, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
4678   application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_RIGHT, KEY_SHIFT_MODIFIER, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
4679
4680   //remove selection
4681   application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_RIGHT, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
4682
4683   // Render and notify
4684   application.SendNotification();
4685   application.Render();
4686
4687   DALI_TEST_CHECK(gSelectionClearedCallbackCalled);
4688
4689   gSelectionClearedCallbackCalled = false;
4690
4691   // Render and notify
4692   application.SendNotification();
4693   application.Render();
4694
4695   // Move to second line of the text & select.
4696   application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_DOWN, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
4697   application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_RIGHT, KEY_SHIFT_MODIFIER, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
4698
4699   // replace D with selected text
4700   application.ProcessEvent( GenerateKey( "D", "", "D", KEY_D_CODE, 0, 0, Integration::KeyEvent::DOWN, "D", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
4701
4702   // Render and notify
4703   application.SendNotification();
4704   application.Render();
4705
4706   DALI_TEST_CHECK(gSelectionClearedCallbackCalled);
4707
4708   gSelectionClearedCallbackCalled = false;
4709
4710   // Render and notify
4711   application.SendNotification();
4712   application.Render();
4713
4714   DevelTextField::SelectText( field ,1, 3 );
4715
4716   // Render and notify
4717   application.SendNotification();
4718   application.Render();
4719
4720   field.SetProperty( DevelTextField::Property::PRIMARY_CURSOR_POSITION, 3);
4721
4722   // Render and notify
4723   application.SendNotification();
4724   application.Render();
4725
4726   DALI_TEST_CHECK(gSelectionClearedCallbackCalled);
4727
4728   gSelectionClearedCallbackCalled = false;
4729
4730   DevelTextField::SelectText( field ,1, 3 );
4731
4732   // Render and notify
4733   application.SendNotification();
4734   application.Render();
4735
4736   // select none
4737   DevelTextField::SelectNone(field);
4738
4739   // Render and notify
4740   application.SendNotification();
4741   application.Render();
4742
4743   DALI_TEST_CHECK(gSelectionClearedCallbackCalled);
4744
4745   END_TEST;
4746 }
4747
4748 int utcDaliTextFieldSelectionChangedSignal(void)
4749 {
4750   ToolkitTestApplication application;
4751   tet_infoline(" utcDaliTextFieldSelectionChangedSignal");
4752
4753   TextField field = TextField::New();
4754   DALI_TEST_CHECK( field );
4755
4756   application.GetScene().Add( field );
4757
4758   // connect to the selection changed signal.
4759   ConnectionTracker* testTracker = new ConnectionTracker();
4760   DevelTextField::SelectionChangedSignal(field).Connect(&TestSelectionChangedCallback);
4761   bool selectionChangedSignal = false;
4762   field.ConnectSignal( testTracker, "selectionChanged",   CallbackFunctor(&selectionChangedSignal) );
4763
4764   field.SetProperty( TextField::Property::TEXT, "Hello world Hello world" );
4765   field.SetProperty( TextField::Property::POINT_SIZE, 10.f );
4766   field.SetProperty( Actor::Property::SIZE, Vector2( 100.f, 50.f ) );
4767   field.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT );
4768   field.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT );
4769
4770   // Avoid a crash when core load gl resources.
4771   application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
4772
4773   // Render and notify
4774   application.SendNotification();
4775   application.Render();
4776
4777   // Tap on the text field
4778   TestGenerateTap( application, 3.0f, 25.0f );
4779
4780   // Render and notify
4781   application.SendNotification();
4782   application.Render();
4783
4784   // Select some text in the right of the current cursor position
4785   application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_SHIFT_LEFT, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
4786   application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_RIGHT, KEY_SHIFT_MODIFIER, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
4787
4788   // Render and notify
4789   application.SendNotification();
4790   application.Render();
4791
4792   DALI_TEST_CHECK(gSelectionChangedCallbackCalled);
4793   DALI_TEST_EQUALS(oldSelectionStart, oldSelectionEnd, TEST_LOCATION);
4794
4795   gSelectionChangedCallbackCalled = false;
4796
4797   application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_RIGHT, KEY_SHIFT_MODIFIER, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
4798
4799   // Render and notify
4800   application.SendNotification();
4801   application.Render();
4802
4803   DALI_TEST_CHECK(gSelectionChangedCallbackCalled);
4804   DALI_TEST_EQUALS(oldSelectionStart, 0, TEST_LOCATION);
4805   DALI_TEST_EQUALS(oldSelectionEnd, 1, TEST_LOCATION);
4806
4807   gSelectionChangedCallbackCalled = false;
4808
4809   application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_ESCAPE, 0, 0, Integration::KeyEvent::UP, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
4810
4811   // Render and notify
4812   application.SendNotification();
4813   application.Render();
4814
4815   DALI_TEST_CHECK(gSelectionChangedCallbackCalled);
4816   DALI_TEST_EQUALS(oldSelectionStart, 0, TEST_LOCATION);
4817   DALI_TEST_EQUALS(oldSelectionEnd, 2, TEST_LOCATION);
4818
4819   gSelectionChangedCallbackCalled = false;
4820   field.SetKeyInputFocus();
4821
4822   // Render and notify
4823   application.SendNotification();
4824   application.Render();
4825
4826   DevelTextField::SelectText( field ,0, 5 );
4827
4828   application.SendNotification();
4829   application.Render();
4830
4831   DALI_TEST_CHECK(gSelectionChangedCallbackCalled);
4832   DALI_TEST_EQUALS(oldSelectionStart, oldSelectionEnd, TEST_LOCATION);
4833
4834   gSelectionChangedCallbackCalled = false;
4835
4836   field.SetProperty( DevelTextField::Property::PRIMARY_CURSOR_POSITION, 3);
4837
4838   // Render and notify
4839   application.SendNotification();
4840   application.Render();
4841
4842   DALI_TEST_CHECK(gSelectionChangedCallbackCalled);
4843   DALI_TEST_EQUALS(oldSelectionStart, 0, TEST_LOCATION);
4844   DALI_TEST_EQUALS(oldSelectionEnd, 5, TEST_LOCATION);
4845
4846   gSelectionChangedCallbackCalled = false;
4847
4848   // select all text
4849   DevelTextField::SelectWholeText(field);
4850
4851   // Render and notify
4852   application.SendNotification();
4853   application.Render();
4854
4855   DALI_TEST_CHECK(gSelectionChangedCallbackCalled);
4856   DALI_TEST_EQUALS(oldSelectionStart, oldSelectionEnd, TEST_LOCATION);
4857
4858   gSelectionChangedCallbackCalled = false;
4859
4860   // select none
4861   DevelTextField::SelectNone(field);
4862
4863   // Render and notify
4864   application.SendNotification();
4865   application.Render();
4866
4867   DALI_TEST_CHECK(gSelectionChangedCallbackCalled);
4868   DALI_TEST_EQUALS(oldSelectionStart, 0, TEST_LOCATION);
4869   DALI_TEST_EQUALS(oldSelectionEnd, 23, TEST_LOCATION);
4870
4871   END_TEST;
4872 }
4873
4874 int UtcDaliToolkitTextFieldStrikethroughGeneration(void)
4875 {
4876   ToolkitTestApplication application;
4877   tet_infoline(" UtcDaliToolkitTextFieldStrikethroughGeneration");
4878
4879   TextField textField = TextField::New();
4880   textField.SetProperty( TextField::Property::TEXT, "Test" );
4881   textField.SetProperty( Actor::Property::SIZE, Vector2( 200.0f, 100.f ) );
4882   textField.SetProperty( TextField::Property::POINT_SIZE, 10) ;
4883   textField.SetProperty( TextField::Property::FONT_FAMILY, "DejaVu Sans");
4884
4885   application.GetScene().Add( textField );
4886   application.SendNotification();
4887   application.Render();
4888
4889   Property::Map strikethroughMapSet;
4890   Property::Map strikethroughMapGet;
4891
4892   strikethroughMapSet.Insert( "enable", true );
4893   strikethroughMapSet.Insert( "color", Color::RED );
4894   strikethroughMapSet.Insert( "height", 2.0f );
4895
4896   // Check the strikethrough property
4897   textField.SetProperty( DevelTextField::Property::STRIKETHROUGH, strikethroughMapSet );
4898   strikethroughMapGet = textField.GetProperty<Property::Map>( DevelTextField::Property::STRIKETHROUGH );
4899   textField.SetProperty( TextField::Property::TEXT, "Test1" );
4900   DALI_TEST_EQUALS( strikethroughMapGet.Count(), strikethroughMapSet.Count(), TEST_LOCATION );
4901   DALI_TEST_EQUALS( DaliTestCheckMaps( strikethroughMapGet, strikethroughMapSet ), true, TEST_LOCATION );
4902
4903   // Render and notify
4904   application.SendNotification();
4905   application.Render();
4906
4907   strikethroughMapSet.Clear();
4908   strikethroughMapGet.Clear();
4909
4910   END_TEST;
4911 }
4912
4913 int UtcDaliToolkitTextFieldInputStrikethroughGeneration(void)
4914 {
4915   ToolkitTestApplication application;
4916   tet_infoline(" UtcDaliToolkitTextFieldInputStrikethroughGeneration");
4917
4918   TextField textField = TextField::New();
4919   textField.SetProperty( TextField::Property::TEXT, "Test" );
4920   textField.SetProperty( Actor::Property::SIZE, Vector2( 200.0f, 100.f ) );
4921   textField.SetProperty( TextField::Property::POINT_SIZE, 10) ;
4922   textField.SetProperty( TextField::Property::FONT_FAMILY, "DejaVu Sans");
4923
4924   application.GetScene().Add( textField );
4925   application.SendNotification();
4926   application.Render();
4927
4928   std::string strikethroughSettings1( "{\"enable\":\"true\",\"color\":\"red\",\"height\":\"2\"}" );
4929
4930   // Check the strikethrough property
4931   textField.SetProperty( DevelTextField::Property::INPUT_STRIKETHROUGH, strikethroughSettings1 );
4932   textField.SetProperty( TextField::Property::TEXT, "Test1" );
4933   DALI_TEST_EQUALS( textField.GetProperty<std::string>( DevelTextField::Property::INPUT_STRIKETHROUGH ), strikethroughSettings1, TEST_LOCATION );
4934
4935   // Render and notify
4936   application.SendNotification();
4937   application.Render();
4938
4939   END_TEST;
4940 }