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