[dali_2.1.23] Merge branch 'devel/master'
[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 int utcDaliTextFieldSelectionWithInputMethodContext(void)
1603 {
1604   ToolkitTestApplication application;
1605   tet_infoline(" utcDaliTextFieldSelectionWithInputMethodContext");
1606   TextField field = TextField::New();
1607   DALI_TEST_CHECK(field);
1608
1609   field.SetProperty(TextField::Property::TEXT, "Hello world");
1610
1611   application.GetScene().Add(field);
1612
1613   // connect to the selection changed signal.
1614   ConnectionTracker* testTracker = new ConnectionTracker();
1615   DevelTextField::SelectionChangedSignal(field).Connect(&TestSelectionChangedCallback);
1616   bool selectionChangedSignal = false;
1617   field.ConnectSignal(testTracker, "selectionChanged", CallbackFunctor(&selectionChangedSignal));
1618
1619   // get InputMethodContext
1620   std::string                   text;
1621   InputMethodContext::EventData imfEvent;
1622   InputMethodContext            inputMethodContext = DevelTextField::GetInputMethodContext(field);
1623
1624   field.SetKeyInputFocus();
1625   field.SetProperty(DevelTextField::Property::ENABLE_EDITING, true);
1626
1627   // input text
1628   gSelectionChangedCallbackCalled = false;
1629   imfEvent                        = InputMethodContext::EventData(InputMethodContext::SELECTION_SET, 1, 4);
1630   inputMethodContext.EventReceivedSignal().Emit(inputMethodContext, imfEvent);
1631   application.SendNotification();
1632   application.Render();
1633   DALI_TEST_CHECK(gSelectionChangedCallbackCalled);
1634
1635   DALI_TEST_EQUALS(field.GetProperty(DevelTextField::Property::SELECTED_TEXT_START).Get<int>(), 1, TEST_LOCATION);
1636   DALI_TEST_EQUALS(field.GetProperty(DevelTextField::Property::SELECTED_TEXT_END).Get<int>(), 4, TEST_LOCATION);
1637
1638   END_TEST;
1639 }
1640
1641 int utcDaliTextFieldPositionWithInputMethodContext(void)
1642 {
1643   ToolkitTestApplication application;
1644   tet_infoline(" utcDaliTextFieldPositionWithInputMethodContext");
1645   TextField field = TextField::New();
1646   DALI_TEST_CHECK(field);
1647
1648   field.SetProperty(TextField::Property::TEXT, "Hello world");
1649
1650   application.GetScene().Add(field);
1651
1652   // connect to the selection changed signal.
1653   ConnectionTracker* testTracker = new ConnectionTracker();
1654   DevelTextField::CursorPositionChangedSignal(field).Connect(&TestCursorPositionChangedCallback);
1655   bool cursorPositionChangedSignal = false;
1656   field.ConnectSignal(testTracker, "cursorPositionChanged", CallbackFunctor(&cursorPositionChangedSignal));
1657
1658   // get InputMethodContext
1659   std::string                   text;
1660   InputMethodContext::EventData imfEvent;
1661   InputMethodContext            inputMethodContext = DevelTextField::GetInputMethodContext(field);
1662
1663   field.SetKeyInputFocus();
1664   field.SetProperty(DevelTextField::Property::ENABLE_EDITING, true);
1665
1666   // input text
1667   gCursorPositionChangedCallbackCalled = false;
1668   imfEvent                             = InputMethodContext::EventData(InputMethodContext::SELECTION_SET, 2, 2);
1669   inputMethodContext.EventReceivedSignal().Emit(inputMethodContext, imfEvent);
1670   application.SendNotification();
1671   application.Render();
1672   DALI_TEST_CHECK(gCursorPositionChangedCallbackCalled);
1673
1674   DALI_TEST_EQUALS(field.GetProperty(DevelTextField::Property::PRIMARY_CURSOR_POSITION).Get<int>(), 2, TEST_LOCATION);
1675
1676   END_TEST;
1677 }
1678
1679 // Negative test for the textChanged signal.
1680 int utcDaliTextFieldTextChangedN(void)
1681 {
1682   ToolkitTestApplication application;
1683   tet_infoline(" utcDaliTextFieldTextChangedN");
1684   TextField field = TextField::New();
1685   DALI_TEST_CHECK(field);
1686
1687   application.GetScene().Add(field);
1688
1689   // connect to the text changed signal.
1690   ConnectionTracker* testTracker = new ConnectionTracker();
1691   field.TextChangedSignal().Connect(&TestTextChangedCallback);
1692   bool textChangedSignal = false;
1693   field.ConnectSignal(testTracker, "textChanged", CallbackFunctor(&textChangedSignal));
1694
1695   gTextChangedCallBackCalled = false;
1696   field.SetProperty(TextField::Property::PLACEHOLDER_TEXT, "ABC"); // Setting placeholder, not TEXT
1697   application.SendNotification();
1698   application.Render();
1699   DALI_TEST_CHECK(!gTextChangedCallBackCalled);
1700   DALI_TEST_CHECK(!textChangedSignal);
1701
1702   END_TEST;
1703 }
1704
1705 // Positive test for Max Characters reached signal.
1706 int utcDaliTextFieldMaxCharactersReachedP(void)
1707 {
1708   ToolkitTestApplication application;
1709   tet_infoline(" utcDaliTextFieldMaxCharactersReachedP");
1710   TextField field = TextField::New();
1711   DALI_TEST_CHECK(field);
1712
1713   application.GetScene().Add(field);
1714
1715   const int maxNumberOfCharacters = 1;
1716   field.SetProperty(TextField::Property::MAX_LENGTH, maxNumberOfCharacters);
1717
1718   field.SetKeyInputFocus();
1719
1720   // connect to the text changed signal.
1721   ConnectionTracker* testTracker = new ConnectionTracker();
1722   field.MaxLengthReachedSignal().Connect(&TestMaxLengthReachedCallback);
1723   bool maxLengthReachedSignal = false;
1724   field.ConnectSignal(testTracker, "maxLengthReached", CallbackFunctor(&maxLengthReachedSignal));
1725
1726   gMaxCharactersCallBackCalled = false;
1727
1728   application.ProcessEvent(GenerateKey("a", "", "a", KEY_A_CODE, 0, 0, Integration::KeyEvent::DOWN, "a", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
1729   application.ProcessEvent(GenerateKey("a", "", "a", KEY_A_CODE, 0, 0, Integration::KeyEvent::DOWN, "a", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
1730
1731   DALI_TEST_CHECK(gMaxCharactersCallBackCalled);
1732   DALI_TEST_CHECK(maxLengthReachedSignal);
1733
1734   END_TEST;
1735 }
1736
1737 // Negative test for Max Characters reached signal.
1738 int utcDaliTextFieldMaxCharactersReachedN(void)
1739 {
1740   ToolkitTestApplication application;
1741   tet_infoline(" utcDaliTextFieldMaxCharactersReachedN");
1742   TextField field = TextField::New();
1743   DALI_TEST_CHECK(field);
1744
1745   application.GetScene().Add(field);
1746
1747   const int maxNumberOfCharacters = 3;
1748   field.SetProperty(TextField::Property::MAX_LENGTH, maxNumberOfCharacters);
1749
1750   field.SetKeyInputFocus();
1751
1752   // connect to the text changed signal.
1753   ConnectionTracker* testTracker = new ConnectionTracker();
1754   field.MaxLengthReachedSignal().Connect(&TestMaxLengthReachedCallback);
1755   bool maxLengthReachedSignal = false;
1756   field.ConnectSignal(testTracker, "maxLengthReached", CallbackFunctor(&maxLengthReachedSignal));
1757
1758   gMaxCharactersCallBackCalled = false;
1759
1760   application.ProcessEvent(GenerateKey("a", "", "a", KEY_A_CODE, 0, 0, Integration::KeyEvent::DOWN, "a", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
1761   application.ProcessEvent(GenerateKey("a", "", "a", KEY_A_CODE, 0, 0, Integration::KeyEvent::DOWN, "a", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
1762
1763   DALI_TEST_CHECK(!gMaxCharactersCallBackCalled);
1764   DALI_TEST_CHECK(!maxLengthReachedSignal);
1765
1766   application.ProcessEvent(GenerateKey("Return", "", "\r", KEY_RETURN_CODE, 0, 0, Integration::KeyEvent::DOWN, "\r", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
1767
1768   DALI_TEST_CHECK(!gMaxCharactersCallBackCalled);
1769   DALI_TEST_CHECK(!maxLengthReachedSignal);
1770
1771   END_TEST;
1772 }
1773
1774 // Positive test for Input Filtered signal.
1775 int utcDaliTextFieldInputFilteredP(void)
1776 {
1777   ToolkitTestApplication application;
1778   tet_infoline(" utcDaliTextFieldInputFilteredP");
1779   TextField field = TextField::New();
1780   DALI_TEST_CHECK(field);
1781
1782   application.GetScene().Add(field);
1783
1784   Property::Map inputFilter;
1785
1786   // Only digit is accepted.
1787   inputFilter[InputFilter::Property::ACCEPTED] = "[\\d]";
1788
1789   // Set input filter to TextField.
1790   field.SetProperty(DevelTextField::Property::INPUT_FILTER, inputFilter);
1791
1792   field.SetKeyInputFocus();
1793
1794   // connect to the input filtered signal.
1795   ConnectionTracker* testTracker = new ConnectionTracker();
1796   DevelTextField::InputFilteredSignal(field).Connect(&TestInputFilteredCallback);
1797   bool inputFilteredSignal = false;
1798   field.ConnectSignal(testTracker, "inputFiltered", CallbackFunctor(&inputFilteredSignal));
1799
1800   gInputFilteredAcceptedCallbackCalled = false;
1801
1802   application.ProcessEvent(GenerateKey("a", "", "a", KEY_A_CODE, 0, 0, Integration::KeyEvent::DOWN, "a", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
1803
1804   DALI_TEST_CHECK(gInputFilteredAcceptedCallbackCalled);
1805   DALI_TEST_CHECK(inputFilteredSignal);
1806
1807   // Word is rejected.
1808   inputFilter[InputFilter::Property::ACCEPTED] = "";
1809   inputFilter[InputFilter::Property::REJECTED] = "[\\w]";
1810
1811   // Set input filter to TextField.
1812   field.SetProperty(DevelTextField::Property::INPUT_FILTER, inputFilter);
1813
1814   field.SetKeyInputFocus();
1815
1816   inputFilteredSignal                  = false;
1817   gInputFilteredRejectedCallbackCalled = false;
1818
1819   application.ProcessEvent(GenerateKey("a", "", "a", KEY_A_CODE, 0, 0, Integration::KeyEvent::DOWN, "a", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
1820
1821   DALI_TEST_CHECK(gInputFilteredAcceptedCallbackCalled);
1822   DALI_TEST_CHECK(inputFilteredSignal);
1823
1824   END_TEST;
1825 }
1826
1827 // Negative test for Input Filtered signal.
1828 int utcDaliTextFieldInputFilteredN(void)
1829 {
1830   ToolkitTestApplication application;
1831   tet_infoline(" utcDaliTextFieldInputFilteredP");
1832   TextField field = TextField::New();
1833   DALI_TEST_CHECK(field);
1834
1835   application.GetScene().Add(field);
1836
1837   Property::Map inputFilter;
1838
1839   // Only word is accepted.
1840   inputFilter[InputFilter::Property::ACCEPTED] = "[\\w]";
1841
1842   // Set input filter to TextField.
1843   field.SetProperty(DevelTextField::Property::INPUT_FILTER, inputFilter);
1844
1845   field.SetKeyInputFocus();
1846
1847   // connect to the input filtered signal.
1848   ConnectionTracker* testTracker = new ConnectionTracker();
1849   DevelTextField::InputFilteredSignal(field).Connect(&TestInputFilteredCallback);
1850   bool inputFilteredSignal = false;
1851   field.ConnectSignal(testTracker, "inputFiltered", CallbackFunctor(&inputFilteredSignal));
1852
1853   gInputFilteredAcceptedCallbackCalled = false;
1854
1855   // Key a, d should not be filtered.
1856   application.ProcessEvent(GenerateKey("a", "", "a", KEY_A_CODE, 0, 0, Integration::KeyEvent::DOWN, "a", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
1857   application.ProcessEvent(GenerateKey("a", "", "a", KEY_A_CODE, 0, 0, Integration::KeyEvent::UP, "a", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
1858   application.ProcessEvent(GenerateKey("d", "", "d", KEY_D_CODE, 0, 0, Integration::KeyEvent::DOWN, "d", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
1859   application.ProcessEvent(GenerateKey("d", "", "d", KEY_D_CODE, 0, 0, Integration::KeyEvent::UP, "d", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
1860
1861   // Backspace, Delete should not be filtered.
1862   application.ProcessEvent(GenerateKey("", "", "", DALI_KEY_BACKSPACE, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
1863   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));
1864
1865   // Render and notify
1866   application.SendNotification();
1867   application.Render();
1868
1869   DALI_TEST_CHECK(!gInputFilteredAcceptedCallbackCalled);
1870   DALI_TEST_CHECK(!inputFilteredSignal);
1871
1872   // Digit is rejected.
1873   inputFilter[InputFilter::Property::ACCEPTED] = "";
1874   inputFilter[InputFilter::Property::REJECTED] = "[\\d]";
1875
1876   field.SetProperty(DevelTextField::Property::INPUT_FILTER, inputFilter);
1877
1878   field.SetKeyInputFocus();
1879
1880   inputFilteredSignal                  = false;
1881   gInputFilteredRejectedCallbackCalled = false;
1882
1883   // Key a, d should not be filtered.
1884   application.ProcessEvent(GenerateKey("a", "", "a", KEY_A_CODE, 0, 0, Integration::KeyEvent::DOWN, "a", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
1885   application.ProcessEvent(GenerateKey("a", "", "a", KEY_A_CODE, 0, 0, Integration::KeyEvent::UP, "a", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
1886   application.ProcessEvent(GenerateKey("d", "", "d", KEY_D_CODE, 0, 0, Integration::KeyEvent::DOWN, "d", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
1887   application.ProcessEvent(GenerateKey("d", "", "d", KEY_D_CODE, 0, 0, Integration::KeyEvent::UP, "d", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
1888
1889   // Backspace, Delete should not be filtered.
1890   application.ProcessEvent(GenerateKey("", "", "", DALI_KEY_BACKSPACE, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
1891   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));
1892
1893   // Render and notify
1894   application.SendNotification();
1895   application.Render();
1896
1897   DALI_TEST_CHECK(!gInputFilteredAcceptedCallbackCalled);
1898   DALI_TEST_CHECK(!inputFilteredSignal);
1899
1900   END_TEST;
1901 }
1902
1903 int utcDaliTextFieldInputStyleChanged01(void)
1904 {
1905   // The text-field emits signals when the input style changes. These changes of style are
1906   // detected during the relayout process (size negotiation), i.e after the cursor has been moved. Signals
1907   // can't be emitted during the size negotiation as the callbacks may update the UI.
1908   // The text-field adds an idle callback to the adaptor to emit the signals after the size negotiation.
1909   // The ToolkitTestApplication creates an implementation of the adaptor stub and a queue of idle callbacks.
1910   ToolkitTestApplication application;
1911   tet_infoline(" utcDaliTextFieldInputStyleChanged01");
1912
1913   // Load some fonts.
1914
1915   char*             pathNamePtr = get_current_dir_name();
1916   const std::string pathName(pathNamePtr);
1917   free(pathNamePtr);
1918
1919   TextAbstraction::FontClient fontClient = TextAbstraction::FontClient::Get();
1920   fontClient.SetDpi(93u, 93u);
1921
1922   fontClient.GetFontId(pathName + DEFAULT_FONT_DIR + "/dejavu/DejaVuSerif.ttf", DEFAULT_FONT_SIZE);
1923   fontClient.GetFontId(pathName + DEFAULT_FONT_DIR + "/dejavu/DejaVuSerif-Bold.ttf", DEFAULT_FONT_SIZE);
1924
1925   TextField field = TextField::New();
1926   DALI_TEST_CHECK(field);
1927
1928   field.SetProperty(Actor::Property::SIZE, Vector2(300.f, 50.f));
1929   field.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT);
1930   field.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
1931
1932   field.SetProperty(TextField::Property::ENABLE_MARKUP, true);
1933   field.SetProperty(TextField::Property::TEXT, "<font family='DejaVuSerif' size='18'>He<color value='green'>llo</color> <font weight='bold'>world</font> demo</font>");
1934
1935   // connect to the text changed signal.
1936   ConnectionTracker* testTracker = new ConnectionTracker();
1937   field.InputStyleChangedSignal().Connect(&TestInputStyleChangedCallback);
1938   bool inputStyleChangedSignal = false;
1939   field.ConnectSignal(testTracker, "inputStyleChanged", CallbackFunctor(&inputStyleChangedSignal));
1940
1941   application.GetScene().Add(field);
1942
1943   // Render and notify
1944   application.SendNotification();
1945   application.Render();
1946
1947   // Executes the idle callbacks added by the text control on the change of input style.
1948   application.RunIdles();
1949
1950   gInputStyleChangedCallbackCalled = false;
1951   gInputStyleMask                  = TextField::InputStyle::NONE;
1952   inputStyleChangedSignal          = false;
1953
1954   // Create a tap event to touch the text field.
1955   TestGenerateTap(application, 18.0f, 25.0f);
1956
1957   // Render and notify
1958   application.SendNotification();
1959   application.Render();
1960
1961   // Executes the idle callbacks added by the text control on the change of input style.
1962   application.RunIdles();
1963
1964   DALI_TEST_CHECK(gInputStyleChangedCallbackCalled);
1965   if(gInputStyleChangedCallbackCalled)
1966   {
1967     DALI_TEST_EQUALS(static_cast<unsigned int>(gInputStyleMask), static_cast<unsigned int>(TextField::InputStyle::FONT_FAMILY | TextField::InputStyle::POINT_SIZE), TEST_LOCATION);
1968
1969     const std::string fontFamily = field.GetProperty(TextField::Property::INPUT_FONT_FAMILY).Get<std::string>();
1970     DALI_TEST_EQUALS(fontFamily, "DejaVuSerif", TEST_LOCATION);
1971
1972     const float pointSize = field.GetProperty(TextField::Property::INPUT_POINT_SIZE).Get<float>();
1973     DALI_TEST_EQUALS(pointSize, 18.f, Math::MACHINE_EPSILON_1000, TEST_LOCATION);
1974   }
1975   DALI_TEST_CHECK(inputStyleChangedSignal);
1976
1977   gInputStyleChangedCallbackCalled = false;
1978   gInputStyleMask                  = TextField::InputStyle::NONE;
1979   inputStyleChangedSignal          = false;
1980
1981   // Create a tap event to touch the text field.
1982   TestGenerateTap(application, 30.0f, 25.0f);
1983
1984   // Render and notify
1985   application.SendNotification();
1986   application.Render();
1987
1988   // Executes the idle callbacks added by the text control on the change of input style.
1989   application.RunIdles();
1990
1991   DALI_TEST_CHECK(!gInputStyleChangedCallbackCalled);
1992   DALI_TEST_CHECK(!inputStyleChangedSignal);
1993
1994   gInputStyleChangedCallbackCalled = false;
1995   gInputStyleMask                  = TextField::InputStyle::NONE;
1996   inputStyleChangedSignal          = false;
1997
1998   // Create a tap event to touch the text field.
1999   TestGenerateTap(application, 43.0f, 25.0f);
2000
2001   // Render and notify
2002   application.SendNotification();
2003   application.Render();
2004
2005   // Executes the idle callbacks added by the text control on the change of input style.
2006   application.RunIdles();
2007
2008   DALI_TEST_CHECK(gInputStyleChangedCallbackCalled);
2009   if(gInputStyleChangedCallbackCalled)
2010   {
2011     DALI_TEST_EQUALS(static_cast<unsigned int>(gInputStyleMask), static_cast<unsigned int>(TextField::InputStyle::COLOR), TEST_LOCATION);
2012
2013     const Vector4 color = field.GetProperty(TextField::Property::INPUT_COLOR).Get<Vector4>();
2014     DALI_TEST_EQUALS(color, Color::GREEN, TEST_LOCATION);
2015   }
2016   DALI_TEST_CHECK(inputStyleChangedSignal);
2017
2018   gInputStyleChangedCallbackCalled = false;
2019   gInputStyleMask                  = TextField::InputStyle::NONE;
2020   inputStyleChangedSignal          = false;
2021
2022   // Create a tap event to touch the text field.
2023   TestGenerateTap(application, 88.0f, 25.0f);
2024
2025   // Render and notify
2026   application.SendNotification();
2027   application.Render();
2028
2029   // Executes the idle callbacks added by the text control on the change of input style.
2030   application.RunIdles();
2031
2032   DALI_TEST_CHECK(gInputStyleChangedCallbackCalled);
2033   if(gInputStyleChangedCallbackCalled)
2034   {
2035     DALI_TEST_EQUALS(static_cast<unsigned int>(gInputStyleMask), static_cast<unsigned int>(TextField::InputStyle::COLOR | TextField::InputStyle::FONT_STYLE), TEST_LOCATION);
2036
2037     const Vector4 color = field.GetProperty(TextField::Property::INPUT_COLOR).Get<Vector4>();
2038     DALI_TEST_EQUALS(color, Color::BLACK, TEST_LOCATION);
2039
2040     const Property::Map fontStyleMapGet = field.GetProperty(TextField::Property::INPUT_FONT_STYLE).Get<Property::Map>();
2041
2042     Property::Map fontStyleMapSet;
2043     fontStyleMapSet.Insert("weight", "bold");
2044
2045     DALI_TEST_EQUALS(fontStyleMapGet.Count(), fontStyleMapSet.Count(), TEST_LOCATION);
2046     DALI_TEST_EQUALS(DaliTestCheckMaps(fontStyleMapGet, fontStyleMapSet), true, TEST_LOCATION);
2047   }
2048   DALI_TEST_CHECK(inputStyleChangedSignal);
2049
2050   gInputStyleChangedCallbackCalled = false;
2051   gInputStyleMask                  = TextField::InputStyle::NONE;
2052   inputStyleChangedSignal          = false;
2053
2054   // Create a tap event to touch the text field.
2055   TestGenerateTap(application, 115.0f, 25.0f);
2056
2057   // Render and notify
2058   application.SendNotification();
2059   application.Render();
2060
2061   // Executes the idle callbacks added by the text control on the change of input style.
2062   application.RunIdles();
2063
2064   DALI_TEST_CHECK(!gInputStyleChangedCallbackCalled);
2065   DALI_TEST_CHECK(!inputStyleChangedSignal);
2066
2067   gInputStyleChangedCallbackCalled = false;
2068   gInputStyleMask                  = TextField::InputStyle::NONE;
2069   inputStyleChangedSignal          = false;
2070
2071   // Create a tap event to touch the text field.
2072   TestGenerateTap(application, 164.0f, 25.0f);
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   DALI_TEST_CHECK(gInputStyleChangedCallbackCalled);
2082   if(gInputStyleChangedCallbackCalled)
2083   {
2084     DALI_TEST_EQUALS(static_cast<unsigned int>(gInputStyleMask), static_cast<unsigned int>(TextField::InputStyle::FONT_STYLE), TEST_LOCATION);
2085
2086     const std::string style = field.GetProperty(TextField::Property::INPUT_FONT_STYLE).Get<std::string>();
2087     DALI_TEST_CHECK(style.empty());
2088   }
2089   DALI_TEST_CHECK(inputStyleChangedSignal);
2090
2091   gInputStyleChangedCallbackCalled = false;
2092   gInputStyleMask                  = TextField::InputStyle::NONE;
2093   inputStyleChangedSignal          = false;
2094
2095   // Create a tap event to touch the text field.
2096   TestGenerateTap(application, 191.0f, 25.0f);
2097
2098   // Render and notify
2099   application.SendNotification();
2100   application.Render();
2101
2102   // Executes the idle callbacks added by the text control on the change of input style.
2103   application.RunIdles();
2104
2105   DALI_TEST_CHECK(!gInputStyleChangedCallbackCalled);
2106   DALI_TEST_CHECK(!inputStyleChangedSignal);
2107
2108   END_TEST;
2109 }
2110
2111 int utcDaliTextFieldInputStyleChanged02(void)
2112 {
2113   // The text-field emits signals when the input style changes. These changes of style are
2114   // detected during the relayout process (size negotiation), i.e after the cursor has been moved. Signals
2115   // can't be emitted during the size negotiation as the callbacks may update the UI.
2116   // The text-field adds an idle callback to the adaptor to emit the signals after the size negotiation.
2117   // The ToolkitTestApplication creates an implementation of the adaptor stub and a queue of idle callbacks.
2118   ToolkitTestApplication application;
2119   tet_infoline(" utcDaliTextFieldInputStyleChanged02");
2120
2121   // Load some fonts.
2122
2123   char*             pathNamePtr = get_current_dir_name();
2124   const std::string pathName(pathNamePtr);
2125   free(pathNamePtr);
2126
2127   TextAbstraction::FontClient fontClient = TextAbstraction::FontClient::Get();
2128   fontClient.SetDpi(93u, 93u);
2129
2130   fontClient.GetFontId(pathName + DEFAULT_FONT_DIR + "/dejavu/DejaVuSerif.ttf", DEFAULT_FONT_SIZE);
2131   fontClient.GetFontId(pathName + DEFAULT_FONT_DIR + "/dejavu/DejaVuSerif-Bold.ttf", DEFAULT_FONT_SIZE);
2132
2133   TextField field = TextField::New();
2134   DALI_TEST_CHECK(field);
2135
2136   field.SetProperty(Actor::Property::SIZE, Vector2(300.f, 50.f));
2137   field.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT);
2138   field.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
2139
2140   field.SetProperty(TextField::Property::ENABLE_MARKUP, true);
2141   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>");
2142
2143   // connect to the text changed signal.
2144   ConnectionTracker* testTracker = new ConnectionTracker();
2145   field.InputStyleChangedSignal().Connect(&TestInputStyleChangedCallback);
2146   bool inputStyleChangedSignal = false;
2147   field.ConnectSignal(testTracker, "inputStyleChanged", CallbackFunctor(&inputStyleChangedSignal));
2148
2149   application.GetScene().Add(field);
2150
2151   // Render and notify
2152   application.SendNotification();
2153   application.Render();
2154
2155   // Executes the idle callbacks added by the text control on the change of input style.
2156   application.RunIdles();
2157
2158   gInputStyleChangedCallbackCalled = false;
2159   gInputStyleMask                  = TextField::InputStyle::NONE;
2160   inputStyleChangedSignal          = false;
2161
2162   // Create a tap event to touch the text field.
2163   TestGenerateTap(application, 53.0f, 25.0f, 100);
2164   TestGenerateTap(application, 53.0f, 25.0f, 200);
2165
2166   // Render and notify
2167   application.SendNotification();
2168   application.Render();
2169
2170   // Executes the idle callbacks added by the text control on the change of input style.
2171   application.RunIdles();
2172
2173   DALI_TEST_CHECK(gInputStyleChangedCallbackCalled);
2174   if(gInputStyleChangedCallbackCalled)
2175   {
2176     DALI_TEST_EQUALS(static_cast<unsigned int>(gInputStyleMask),
2177                      static_cast<unsigned int>(TextField::InputStyle::FONT_FAMILY |
2178                                                TextField::InputStyle::POINT_SIZE |
2179                                                TextField::InputStyle::COLOR),
2180                      TEST_LOCATION);
2181
2182     const Vector4 color = field.GetProperty(TextField::Property::INPUT_COLOR).Get<Vector4>();
2183     DALI_TEST_EQUALS(color, Color::GREEN, TEST_LOCATION);
2184
2185     const std::string fontFamily = field.GetProperty(TextField::Property::INPUT_FONT_FAMILY).Get<std::string>();
2186     DALI_TEST_EQUALS(fontFamily, "DejaVuSerif", TEST_LOCATION);
2187
2188     const float pointSize = field.GetProperty(TextField::Property::INPUT_POINT_SIZE).Get<float>();
2189     DALI_TEST_EQUALS(pointSize, 18.f, Math::MACHINE_EPSILON_1000, TEST_LOCATION);
2190   }
2191   DALI_TEST_CHECK(inputStyleChangedSignal);
2192
2193   gInputStyleChangedCallbackCalled = false;
2194   gInputStyleMask                  = TextField::InputStyle::NONE;
2195   inputStyleChangedSignal          = false;
2196
2197   application.ProcessEvent(GenerateKey("", "", "", DALI_KEY_BACKSPACE, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
2198
2199   // Render and notify
2200   application.SendNotification();
2201   application.Render();
2202
2203   // Executes the idle callbacks added by the text control on the change of input style.
2204   application.RunIdles();
2205
2206   DALI_TEST_CHECK(gInputStyleChangedCallbackCalled);
2207   if(gInputStyleChangedCallbackCalled)
2208   {
2209     DALI_TEST_EQUALS(static_cast<unsigned int>(gInputStyleMask),
2210                      static_cast<unsigned int>(TextField::InputStyle::COLOR),
2211                      TEST_LOCATION);
2212
2213     const Vector4 color = field.GetProperty(TextField::Property::INPUT_COLOR).Get<Vector4>();
2214     DALI_TEST_EQUALS(color, Color::BLUE, TEST_LOCATION);
2215   }
2216   DALI_TEST_CHECK(inputStyleChangedSignal);
2217
2218   gInputStyleChangedCallbackCalled = false;
2219   gInputStyleMask                  = TextField::InputStyle::NONE;
2220   inputStyleChangedSignal          = false;
2221
2222   application.ProcessEvent(GenerateKey("", "", "", DALI_KEY_BACKSPACE, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
2223
2224   // Render and notify
2225   application.SendNotification();
2226   application.Render();
2227
2228   // Executes the idle callbacks added by the text control on the change of input style.
2229   application.RunIdles();
2230
2231   DALI_TEST_CHECK(!gInputStyleChangedCallbackCalled);
2232   DALI_TEST_CHECK(!inputStyleChangedSignal);
2233
2234   gInputStyleChangedCallbackCalled = false;
2235   gInputStyleMask                  = TextField::InputStyle::NONE;
2236   inputStyleChangedSignal          = false;
2237
2238   application.ProcessEvent(GenerateKey("", "", "", DALI_KEY_BACKSPACE, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
2239
2240   // Render and notify
2241   application.SendNotification();
2242   application.Render();
2243
2244   // Executes the idle callbacks added by the text control on the change of input style.
2245   application.RunIdles();
2246
2247   DALI_TEST_CHECK(gInputStyleChangedCallbackCalled);
2248   if(gInputStyleChangedCallbackCalled)
2249   {
2250     DALI_TEST_EQUALS(static_cast<unsigned int>(gInputStyleMask),
2251                      static_cast<unsigned int>(TextField::InputStyle::COLOR),
2252                      TEST_LOCATION);
2253
2254     const Vector4 color = field.GetProperty(TextField::Property::INPUT_COLOR).Get<Vector4>();
2255     DALI_TEST_EQUALS(color, Color::BLACK, TEST_LOCATION);
2256   }
2257   DALI_TEST_CHECK(inputStyleChangedSignal);
2258
2259   gInputStyleChangedCallbackCalled = false;
2260   gInputStyleMask                  = TextField::InputStyle::NONE;
2261   inputStyleChangedSignal          = false;
2262
2263   field.SetProperty(TextField::Property::INPUT_COLOR, Color::YELLOW);
2264
2265   Property::Map fontStyleMapSet;
2266   fontStyleMapSet.Insert("weight", "thin");
2267   fontStyleMapSet.Insert("width", "condensed");
2268   fontStyleMapSet.Insert("slant", "italic");
2269
2270   field.SetProperty(TextField::Property::INPUT_FONT_STYLE, fontStyleMapSet);
2271   field.SetProperty(TextField::Property::INPUT_POINT_SIZE, 20.f);
2272
2273   field.SetProperty(TextField::Property::INPUT_UNDERLINE, "underline");
2274   field.SetProperty(TextField::Property::INPUT_SHADOW, "shadow");
2275   field.SetProperty(TextField::Property::INPUT_EMBOSS, "emboss");
2276   field.SetProperty(TextField::Property::INPUT_OUTLINE, "outline");
2277   field.SetProperty(DevelTextField::Property::INPUT_STRIKETHROUGH, "strikethrough");
2278
2279   // Render and notify
2280   application.SendNotification();
2281   application.Render();
2282
2283   // Executes the idle callbacks added by the text control on the change of input style.
2284   application.RunIdles();
2285
2286   DALI_TEST_CHECK(!gInputStyleChangedCallbackCalled);
2287   DALI_TEST_CHECK(!inputStyleChangedSignal);
2288
2289   // Create a tap event to touch the text field.
2290   TestGenerateTap(application, 63.0f, 25.0f, 700);
2291
2292   // Render and notify
2293   application.SendNotification();
2294   application.Render();
2295
2296   // Executes the idle callbacks added by the text control on the change of input style.
2297   application.RunIdles();
2298
2299   DALI_TEST_CHECK(gInputStyleChangedCallbackCalled);
2300   if(gInputStyleChangedCallbackCalled)
2301   {
2302     DALI_TEST_EQUALS(static_cast<unsigned int>(gInputStyleMask),
2303                      static_cast<unsigned int>(TextField::InputStyle::COLOR |
2304                                                TextField::InputStyle::POINT_SIZE |
2305                                                TextField::InputStyle::FONT_STYLE |
2306                                                TextField::InputStyle::UNDERLINE |
2307                                                TextField::InputStyle::SHADOW |
2308                                                TextField::InputStyle::EMBOSS |
2309                                                TextField::InputStyle::OUTLINE),
2310                      TEST_LOCATION);
2311
2312     const Vector4 color = field.GetProperty(TextField::Property::INPUT_COLOR).Get<Vector4>();
2313     DALI_TEST_EQUALS(color, Color::BLACK, TEST_LOCATION);
2314   }
2315   DALI_TEST_CHECK(inputStyleChangedSignal);
2316
2317   END_TEST;
2318 }
2319
2320 int utcDaliTextFieldEvent01(void)
2321 {
2322   ToolkitTestApplication application;
2323   tet_infoline(" utcDaliTextFieldEvent01");
2324
2325   // Creates a tap event. After creating a tap event the text field should
2326   // have the focus and add text with key events should be possible.
2327
2328   TextField field = TextField::New();
2329   DALI_TEST_CHECK(field);
2330
2331   application.GetScene().Add(field);
2332
2333   field.SetProperty(Actor::Property::SIZE, Vector2(300.f, 50.f));
2334   field.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT);
2335   field.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
2336
2337   // Render and notify
2338   application.SendNotification();
2339   application.Render();
2340
2341   // Avoid a crash when core load gl resources.
2342   application.GetGlAbstraction().SetCheckFramebufferStatusResult(GL_FRAMEBUFFER_COMPLETE);
2343
2344   // Render and notify
2345   application.SendNotification();
2346   application.Render();
2347
2348   // Add a key event but as the text field has not the focus it should do nothing.
2349   application.ProcessEvent(GenerateKey("a", "", "a", KEY_A_CODE, 0, 0, Integration::KeyEvent::DOWN, "a", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
2350
2351   // Render and notify
2352   application.SendNotification();
2353   application.Render();
2354
2355   DALI_TEST_EQUALS(field.GetProperty<std::string>(TextField::Property::TEXT), std::string(""), TEST_LOCATION);
2356
2357   // Create a tap event to touch the text field.
2358   TestGenerateTap(application, 150.0f, 25.0f);
2359
2360   // Render and notify
2361   application.SendNotification();
2362   application.Render();
2363
2364   // Pressing delete key should be fine even if there is no text in TextField.
2365   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));
2366   // Render and notify
2367   application.SendNotification();
2368   application.Render();
2369
2370   // Now the text field has the focus, so it can handle the key events.
2371   application.ProcessEvent(GenerateKey("a", "", "a", KEY_A_CODE, 0, 0, Integration::KeyEvent::DOWN, "a", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
2372   application.ProcessEvent(GenerateKey("a", "", "a", KEY_A_CODE, 0, 0, Integration::KeyEvent::DOWN, "a", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
2373
2374   // Render and notify
2375   application.SendNotification();
2376   application.Render();
2377
2378   DALI_TEST_EQUALS(field.GetProperty<std::string>(TextField::Property::TEXT), std::string("aa"), TEST_LOCATION);
2379
2380   // Create a second text field and send key events to it.
2381   TextField field2 = TextField::New();
2382
2383   field2.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT);
2384   field2.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
2385   field2.SetProperty(Actor::Property::SIZE, Vector2(100.f, 100.f));
2386   field2.SetProperty(Actor::Property::POSITION, Vector2(100.0f, 100.0f));
2387
2388   application.GetScene().Add(field2);
2389
2390   // Render and notify
2391   application.SendNotification();
2392   application.Render();
2393
2394   // Create a tap event on the second text field.
2395   TestGenerateTap(application, 150.0f, 125.0f);
2396
2397   // Render and notify
2398   application.SendNotification();
2399   application.Render();
2400
2401   // The second text field has the focus. It should handle the key events.
2402   application.ProcessEvent(GenerateKey("a", "", "a", KEY_A_CODE, 0, 0, Integration::KeyEvent::DOWN, "a", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
2403   application.ProcessEvent(GenerateKey("a", "", "a", KEY_A_CODE, 0, 0, Integration::KeyEvent::DOWN, "a", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
2404
2405   // Render and notify
2406   application.SendNotification();
2407   application.Render();
2408
2409   // Check the text has been added to the second text field.
2410   DALI_TEST_EQUALS(field2.GetProperty<std::string>(TextField::Property::TEXT), std::string("aa"), TEST_LOCATION);
2411
2412   END_TEST;
2413 }
2414
2415 int utcDaliTextFieldEvent02(void)
2416 {
2417   ToolkitTestApplication application;
2418   tet_infoline(" utcDaliTextFieldEvent02");
2419
2420   // Checks if the right number of actors are created.
2421
2422   TextField field = TextField::New();
2423   field.SetProperty(TextField::Property::POINT_SIZE, 10.f);
2424   DALI_TEST_CHECK(field);
2425   LoadMarkerImages(application, field);
2426
2427   application.GetScene().Add(field);
2428
2429   field.SetProperty(Actor::Property::SIZE, Vector2(300.f, 50.f));
2430   field.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT);
2431   field.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
2432
2433   // Avoid a crash when core load gl resources.
2434   application.GetGlAbstraction().SetCheckFramebufferStatusResult(GL_FRAMEBUFFER_COMPLETE);
2435
2436   // Render and notify
2437   application.SendNotification();
2438   application.Render();
2439
2440   // Check there are the expected number of children ( stencil ).
2441   DALI_TEST_EQUALS(field.GetChildCount(), 1u, TEST_LOCATION);
2442
2443   Actor stencil = field.GetChildAt(0u);
2444   DALI_TEST_EQUALS(stencil.GetChildCount(), 0u, TEST_LOCATION);
2445
2446   // Create a tap event to touch the text field.
2447   TestGenerateTap(application, 150.0f, 25.0f, 300);
2448
2449   // Render and notify
2450   application.SendNotification();
2451   application.Render();
2452
2453   Actor layer = field.GetChildAt(2u);
2454   DALI_TEST_EQUALS(layer.GetChildCount(), 1u, TEST_LOCATION); // The cursor.
2455   DALI_TEST_EQUALS(stencil.GetChildCount(), 0u, TEST_LOCATION);
2456
2457   // Now the text field has the focus, so it can handle the key events.
2458   application.ProcessEvent(GenerateKey("a", "", "a", KEY_A_CODE, 0, 0, Integration::KeyEvent::DOWN, "a", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
2459   application.ProcessEvent(GenerateKey("a", "", "a", KEY_A_CODE, 0, 0, Integration::KeyEvent::DOWN, "a", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
2460
2461   // Render and notify
2462   application.SendNotification();
2463   application.Render();
2464
2465   // Checks the cursor and the renderer have been created.
2466   DALI_TEST_EQUALS(layer.GetChildCount(), 1u, TEST_LOCATION);   // The cursor.
2467   DALI_TEST_EQUALS(stencil.GetChildCount(), 2u, TEST_LOCATION); // The renderer, clipped cursor
2468
2469   Control cursor = Control::DownCast(layer.GetChildAt(0u));
2470   DALI_TEST_CHECK(cursor);
2471
2472   // The offscreen root actor has a container with all the actors which contain the text renderers.
2473   Actor container = stencil.GetChildAt(0u);
2474   for(unsigned int index = 0; index < container.GetChildCount(); ++index)
2475   {
2476     Renderer renderer = container.GetChildAt(index).GetRendererAt(0u);
2477     DALI_TEST_CHECK(renderer);
2478   }
2479
2480   // Move the cursor and check the position changes.
2481   Vector3 position1 = cursor.GetCurrentProperty<Vector3>(Actor::Property::POSITION);
2482   application.ProcessEvent(GenerateKey("", "", "", DALI_KEY_CURSOR_LEFT, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
2483
2484   // Render and notify
2485   application.SendNotification();
2486   application.Render();
2487
2488   Vector3 position2 = cursor.GetCurrentProperty<Vector3>(Actor::Property::POSITION);
2489   DALI_TEST_CHECK(position2.x < position1.x);
2490
2491   application.ProcessEvent(GenerateKey("", "", "", DALI_KEY_CURSOR_RIGHT, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
2492
2493   // Render and notify
2494   application.SendNotification();
2495   application.Render();
2496
2497   Vector3 position3 = cursor.GetCurrentProperty<Vector3>(Actor::Property::POSITION);
2498   DALI_TEST_EQUALS(position1, position3, TEST_LOCATION); // Should be in the same position1.
2499
2500   // Move the cursor to the first position.
2501   application.ProcessEvent(GenerateKey("", "", "", DALI_KEY_CURSOR_LEFT, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
2502   application.ProcessEvent(GenerateKey("", "", "", DALI_KEY_CURSOR_LEFT, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
2503
2504   // Render and notify
2505   application.SendNotification();
2506   application.Render();
2507
2508   Vector3 position4 = cursor.GetCurrentProperty<Vector3>(Actor::Property::POSITION);
2509
2510   // Send some taps and check the cursor positions.
2511
2512   // Try to tap at the beginning.
2513   TestGenerateTap(application, 1.0f, 25.0f, 900);
2514
2515   // Render and notify
2516   application.SendNotification();
2517   application.Render();
2518
2519   // Cursor position should be the same than position1.
2520   Vector3 position5 = cursor.GetCurrentProperty<Vector3>(Actor::Property::POSITION);
2521
2522   DALI_TEST_EQUALS(position4, position5, TEST_LOCATION); // Should be in the same position2.
2523
2524   // Tap away from the start position.
2525   TestGenerateTap(application, 16.0f, 25.0f, 1500);
2526
2527   // Render and notify
2528   application.SendNotification();
2529   application.Render();
2530
2531   Vector3 position6 = cursor.GetCurrentProperty<Vector3>(Actor::Property::POSITION);
2532
2533   DALI_TEST_CHECK(position6.x > position5.x);
2534
2535   // Remove all the text.
2536   application.ProcessEvent(GenerateKey("", "", "", DALI_KEY_BACKSPACE, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
2537   application.ProcessEvent(GenerateKey("", "", "", DALI_KEY_BACKSPACE, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
2538   field.SetProperty(TextField::Property::TEXT, "");
2539
2540   // Render and notify
2541   application.SendNotification();
2542   application.Render();
2543
2544   // Cursor position should be the same than position2.
2545   Vector3 position7 = cursor.GetCurrentProperty<Vector3>(Actor::Property::POSITION);
2546
2547   DALI_TEST_EQUALS(position4, position7, TEST_LOCATION); // Should be in the same position2.
2548
2549   // Should not be a renderer, there is only a clipped cursor.
2550   DALI_TEST_EQUALS(stencil.GetChildCount(), 1u, TEST_LOCATION);
2551
2552   // Chanege exceed policy (EXCEED_POLICY_ORIGINAL doesn't use stencil )
2553   field.SetProperty(TextField::Property::TEXT, "This is a long text for the size of the text-field.");
2554   field.SetProperty(TextField::Property::EXCEED_POLICY, Dali::Toolkit::TextField::EXCEED_POLICY_ORIGINAL);
2555
2556   application.SendNotification();
2557   application.Render();
2558
2559   // There are renderer and decorator layer
2560   DALI_TEST_EQUALS(field.GetChildCount(), 2u, TEST_LOCATION);
2561
2562   END_TEST;
2563 }
2564
2565 int utcDaliTextFieldEvent03(void)
2566 {
2567   ToolkitTestApplication application;
2568   tet_infoline(" utcDaliTextFieldEvent03");
2569
2570   // Checks if the highlight actor is created.
2571
2572   TextField field = TextField::New();
2573   DALI_TEST_CHECK(field);
2574
2575   application.GetScene().Add(field);
2576
2577   field.SetProperty(TextField::Property::TEXT, "This is a long text for the size of the text-field.");
2578   field.SetProperty(TextField::Property::POINT_SIZE, 10.f);
2579   field.SetProperty(Actor::Property::SIZE, Vector2(30.f, 50.f));
2580   field.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT);
2581   field.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
2582
2583   // Avoid a crash when core load gl resources.
2584   application.GetGlAbstraction().SetCheckFramebufferStatusResult(GL_FRAMEBUFFER_COMPLETE);
2585   LoadMarkerImages(application, field);
2586
2587   // Render and notify
2588   application.SendNotification();
2589   application.Render();
2590
2591   // Tap first to get the focus.
2592   TestGenerateTap(application, 3.0f, 25.0f);
2593
2594   // Render and notify
2595   application.SendNotification();
2596   application.Render();
2597
2598   // Double tap to select a word.
2599   TestGenerateTap(application, 3.0f, 25.0f);
2600
2601   // Render and notify
2602   application.SendNotification();
2603   application.Render();
2604
2605   // The offscreen root actor should have two actors: the renderer and the highlight actor.
2606   Actor stencil = field.GetChildAt(0u);
2607
2608   // The highlight actor is drawn first, so is the first actor in the list
2609   Renderer highlight = stencil.GetChildAt(0u).GetRendererAt(0u);
2610   DALI_TEST_CHECK(highlight);
2611
2612   // The offscreen root actor has a container with all the actors which contain the text renderers.
2613   Actor container = stencil.GetChildAt(1u);
2614   for(unsigned int index = 0; index < container.GetChildCount(); ++index)
2615   {
2616     Renderer renderer = container.GetChildAt(index).GetRendererAt(0u);
2617     DALI_TEST_CHECK(renderer);
2618   }
2619
2620   END_TEST;
2621 }
2622
2623 int utcDaliTextFieldEvent04(void)
2624 {
2625   ToolkitTestApplication application;
2626   tet_infoline(" utcDaliTextFieldEvent04");
2627
2628   // Checks if the highlight actor is created.
2629
2630   TextField field = TextField::New();
2631   DALI_TEST_CHECK(field);
2632   application.GetScene().Add(field);
2633   LoadMarkerImages(application, field);
2634   // Render and notify
2635   application.SendNotification();
2636   application.Render();
2637
2638   field.SetProperty(TextField::Property::TEXT, "This is a long text for the size of the text-field.");
2639   field.SetProperty(TextField::Property::POINT_SIZE, 10.f);
2640   field.SetProperty(Actor::Property::SIZE, Vector2(300.f, 50.f));
2641   field.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT);
2642   field.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
2643
2644   // Avoid a crash when core load gl resources.
2645   application.GetGlAbstraction().SetCheckFramebufferStatusResult(GL_FRAMEBUFFER_COMPLETE);
2646   // Render and notify
2647   application.SendNotification();
2648   application.Render();
2649
2650   // Create a tap event to touch the text field.
2651   TestGenerateTap(application, 150.0f, 25.0f);
2652   // Render and notify
2653   application.SendNotification();
2654   application.Render();
2655
2656   // Tap first to get the focus.
2657   TestGenerateTap(application, 1.0f, 25.0f);
2658
2659   // Render and notify
2660   application.SendNotification();
2661   application.Render();
2662
2663   // Double tap to select a word.
2664   TestGenerateTap(application, 1.0f, 25.0f);
2665
2666   // Render and notify
2667   application.SendNotification();
2668   application.Render();
2669
2670   // Tap grab handle
2671   TestGenerateTap(application, 0.0f, 40.0f);
2672   END_TEST;
2673 }
2674
2675 int utcDaliTextFieldEvent05(void)
2676 {
2677   ToolkitTestApplication application;
2678   tet_infoline(" utcDaliTextFieldEvent05");
2679
2680   // Checks dragging of cursor/grab handle
2681
2682   TextField field = TextField::New();
2683   DALI_TEST_CHECK(field);
2684   application.GetScene().Add(field);
2685   LoadMarkerImages(application, field);
2686   // Render and notify
2687   application.SendNotification();
2688   application.Render();
2689
2690   field.SetProperty(TextField::Property::TEXT, "This is a long text for the size of the text-field.");
2691   field.SetProperty(TextField::Property::POINT_SIZE, 10.f);
2692   field.SetProperty(Actor::Property::SIZE, Vector2(300.f, 50.f));
2693   field.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT);
2694   field.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
2695
2696   // Avoid a crash when core load gl resources.
2697   application.GetGlAbstraction().SetCheckFramebufferStatusResult(GL_FRAMEBUFFER_COMPLETE);
2698   // Render and notify
2699   application.SendNotification();
2700   application.Render();
2701
2702   // Create a tap event to touch the text field.
2703   TestGenerateTap(application, 150.0f, 25.0f);
2704   // Render and notify
2705   application.SendNotification();
2706   application.Render();
2707
2708   // Tap first to get the focus.
2709   TestGenerateTap(application, 1.0f, 25.0f);
2710
2711   // Render and notify
2712   application.SendNotification();
2713   application.Render();
2714
2715   // Double tap to select a word.
2716   TestGenerateTap(application, 1.0f, 25.0f);
2717
2718   // Render and notify
2719   application.SendNotification();
2720   application.Render();
2721
2722   Actor stencil = field.GetChildAt(1u);
2723   END_TEST;
2724 }
2725
2726 int utcDaliTextFieldEvent06(void)
2727 {
2728   ToolkitTestApplication application;
2729   tet_infoline(" utcDaliTextFieldEvent06");
2730
2731   // Checks Longpress when in edit mode
2732
2733   TextField field = TextField::New();
2734   DALI_TEST_CHECK(field);
2735   application.GetScene().Add(field);
2736   LoadMarkerImages(application, field);
2737   // Render and notify
2738   application.SendNotification();
2739   application.Render();
2740
2741   field.SetProperty(TextField::Property::TEXT, "Thisisalongtextforthesizeofthetextfield.");
2742   field.SetProperty(TextField::Property::POINT_SIZE, 10.f);
2743   field.SetProperty(Actor::Property::SIZE, Vector2(300.f, 50.f));
2744   field.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT);
2745   field.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
2746
2747   // Avoid a crash when core load gl resources.
2748   application.GetGlAbstraction().SetCheckFramebufferStatusResult(GL_FRAMEBUFFER_COMPLETE);
2749   // Render and notify
2750   application.SendNotification();
2751   application.Render();
2752
2753   // Create a tap event to touch the text field.
2754   TestGenerateTap(application, 150.0f, 25.0f);
2755   // Render and notify
2756   application.SendNotification();
2757   application.Render();
2758
2759   // Tap first to get the focus.
2760   TestGenerateTap(application, 1.0f, 25.0f);
2761
2762   // Render and notify
2763   application.SendNotification();
2764   application.Render();
2765
2766   // Long Press
2767   TestGenerateLongPress(application, 1.0f, 25.0f);
2768
2769   // Render and notify
2770   application.SendNotification();
2771   application.Render();
2772
2773   END_TEST;
2774 }
2775
2776 int utcDaliTextFieldEvent07(void)
2777 {
2778   ToolkitTestApplication application;
2779   tet_infoline(" utcDaliTextFieldEvent07");
2780
2781   // Checks Longpress to start edit mode
2782
2783   TextField field = TextField::New();
2784   DALI_TEST_CHECK(field);
2785   application.GetScene().Add(field);
2786   LoadMarkerImages(application, field);
2787   // Render and notify
2788   application.SendNotification();
2789   application.Render();
2790
2791   field.SetProperty(TextField::Property::TEXT, "Thisisalongtextforthesizeofthetextfield.");
2792   field.SetProperty(TextField::Property::POINT_SIZE, 10.f);
2793   field.SetProperty(Actor::Property::SIZE, Vector2(300.f, 50.f));
2794   field.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT);
2795   field.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
2796   Property::Map propertyMap;
2797   propertyMap["PANEL_LAYOUT"] = InputMethod::PanelLayout::PASSWORD;
2798   field.SetProperty(TextField::Property::INPUT_METHOD_SETTINGS, propertyMap);
2799
2800   // Avoid a crash when core load gl resources.
2801   application.GetGlAbstraction().SetCheckFramebufferStatusResult(GL_FRAMEBUFFER_COMPLETE);
2802   // Render and notify
2803   application.SendNotification();
2804   application.Render();
2805
2806   // Long Press
2807   TestGenerateLongPress(application, 1.0f, 25.0f);
2808
2809   // Render and notify
2810   application.SendNotification();
2811   application.Render();
2812
2813   END_TEST;
2814 }
2815
2816 int utcDaliTextFieldEvent08(void)
2817 {
2818   ToolkitTestApplication application;
2819   tet_infoline(" utcDaliTextFieldEvent08");
2820
2821   Dali::Clipboard clipboard = Clipboard::Get();
2822   clipboard.SetItem("testTextFieldEvent");
2823
2824   // Checks Longpress when only place holder text
2825
2826   TextField field = TextField::New();
2827   DALI_TEST_CHECK(field);
2828   application.GetScene().Add(field);
2829   LoadMarkerImages(application, field);
2830   // Render and notify
2831   application.SendNotification();
2832   application.Render();
2833
2834   field.SetProperty(TextField::Property::PLACEHOLDER_TEXT, "Setting Placeholder Text");
2835   field.SetProperty(TextField::Property::POINT_SIZE, 10.f);
2836   field.SetProperty(Actor::Property::SIZE, Vector2(300.f, 50.f));
2837   field.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT);
2838   field.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
2839
2840   // Avoid a crash when core load gl resources.
2841   application.GetGlAbstraction().SetCheckFramebufferStatusResult(GL_FRAMEBUFFER_COMPLETE);
2842   // Render and notify
2843   application.SendNotification();
2844   application.Render();
2845
2846   // Long Press
2847   TestGenerateLongPress(application, 1.0f, 25.0f, 20);
2848
2849   // Render and notify
2850   application.SendNotification();
2851   application.Render();
2852
2853   Wait(application, 500);
2854
2855   TestEndLongPress(application, 1.0f, 25.0f, 520);
2856
2857   // Long Press
2858   TestGenerateLongPress(application, 1.0f, 25.0f, 600);
2859
2860   // Render and notify
2861   application.Render();
2862
2863   Wait(application, 500);
2864
2865   Integration::Scene stage = application.GetScene();
2866   Layer              layer = stage.GetRootLayer();
2867   Actor              actor = layer.FindChildByName("optionPaste");
2868
2869   if(actor)
2870   {
2871     Vector3 worldPosition = actor.GetCurrentProperty<Vector3>(Actor::Property::WORLD_POSITION);
2872     Vector2 halfStageSize = stage.GetSize() / 2.0f;
2873     Vector2 position(worldPosition.x + halfStageSize.width, worldPosition.y + halfStageSize.height);
2874
2875     Dali::Integration::TouchEvent event;
2876     event = Dali::Integration::TouchEvent();
2877     event.AddPoint(GetPointDownInside(position));
2878     application.ProcessEvent(event);
2879
2880     event = Dali::Integration::TouchEvent();
2881     event.AddPoint(GetPointUpInside(position));
2882     application.ProcessEvent(event);
2883   }
2884   DALI_TEST_EQUALS(field.GetProperty<std::string>(TextEditor::Property::TEXT), std::string("testTextFieldEvent"), TEST_LOCATION);
2885
2886   END_TEST;
2887 }
2888
2889 int utcDaliTextFieldEvent09(void)
2890 {
2891   ToolkitTestApplication application;
2892   tet_infoline(" utcDaliTextFieldEvent09");
2893
2894   TextField field = TextField::New();
2895   DALI_TEST_CHECK(field);
2896   application.GetScene().Add(field);
2897   LoadMarkerImages(application, field);
2898   // Render and notify
2899   application.SendNotification();
2900   application.Render();
2901
2902   field.SetProperty(TextField::Property::TEXT, "Hello");
2903   field.SetProperty(TextField::Property::POINT_SIZE, 10.f);
2904   field.SetProperty(Actor::Property::SIZE, Vector2(300.f, 50.f));
2905   field.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT);
2906   field.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
2907
2908   // Avoid a crash when core load gl resources.
2909   application.GetGlAbstraction().SetCheckFramebufferStatusResult(GL_FRAMEBUFFER_COMPLETE);
2910
2911   // Create a tap event to touch the text field.
2912   TestGenerateTap(application, 150.0f, 25.0f);
2913   application.SendNotification();
2914   application.Render();
2915
2916   Property::Map map;
2917   map[HiddenInput::Property::MODE] = HiddenInput::Mode::HIDE_NONE;
2918   field.SetProperty(TextField::Property::HIDDEN_INPUT_SETTINGS, map);
2919   application.ProcessEvent(GenerateKey("d", "", "d", 0, 0, 0, Integration::KeyEvent::DOWN, "d", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
2920   application.SendNotification();
2921   application.Render();
2922
2923   map[HiddenInput::Property::MODE]                 = HiddenInput::Mode::HIDE_ALL;
2924   map[HiddenInput::Property::SUBSTITUTE_CHARACTER] = 0x23;
2925   field.SetProperty(TextField::Property::HIDDEN_INPUT_SETTINGS, map);
2926   application.ProcessEvent(GenerateKey("d", "", "d", 0, 0, 0, Integration::KeyEvent::DOWN, "d", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
2927   application.SendNotification();
2928   application.Render();
2929
2930   map[HiddenInput::Property::MODE]             = HiddenInput::Mode::HIDE_COUNT;
2931   map[HiddenInput::Property::SUBSTITUTE_COUNT] = 2;
2932   field.SetProperty(TextField::Property::HIDDEN_INPUT_SETTINGS, map);
2933   for(unsigned int index = 0u; index < 5u; ++index)
2934   {
2935     application.ProcessEvent(GenerateKey("d", "", "d", 0, 0, 0, Integration::KeyEvent::DOWN, "d", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
2936     application.SendNotification();
2937     application.Render();
2938   }
2939
2940   map[HiddenInput::Property::MODE]             = HiddenInput::Mode::SHOW_COUNT;
2941   map[HiddenInput::Property::SUBSTITUTE_COUNT] = 2;
2942   field.SetProperty(TextField::Property::HIDDEN_INPUT_SETTINGS, map);
2943   for(unsigned int index = 0u; index < 5u; ++index)
2944   {
2945     application.ProcessEvent(GenerateKey("d", "", "d", 0, 0, 0, Integration::KeyEvent::DOWN, "d", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
2946     application.SendNotification();
2947     application.Render();
2948   }
2949
2950   map[HiddenInput::Property::MODE]                         = HiddenInput::Mode::SHOW_LAST_CHARACTER;
2951   map[HiddenInput::Property::SHOW_LAST_CHARACTER_DURATION] = 0;
2952   field.SetProperty(TextField::Property::HIDDEN_INPUT_SETTINGS, map);
2953   application.ProcessEvent(GenerateKey("", "", "", DALI_KEY_BACKSPACE, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
2954   application.SendNotification();
2955   application.Render();
2956   application.ProcessEvent(GenerateKey("d", "", "d", 0, 0, 0, Integration::KeyEvent::DOWN, "d", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
2957   application.SendNotification();
2958   application.Render();
2959
2960   map[HiddenInput::Property::SHOW_LAST_CHARACTER_DURATION] = 100;
2961   field.SetProperty(TextField::Property::HIDDEN_INPUT_SETTINGS, map);
2962   application.ProcessEvent(GenerateKey("d", "", "d", 0, 0, 0, Integration::KeyEvent::DOWN, "d", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
2963   application.SendNotification();
2964   application.Render();
2965
2966   Property::Map mapGet;
2967   mapGet = field.GetProperty<Property::Map>(TextField::Property::HIDDEN_INPUT_SETTINGS);
2968   DALI_TEST_EQUALS(map.Count(), mapGet.Count(), TEST_LOCATION);
2969   DALI_TEST_EQUALS(DaliTestCheckMaps(map, mapGet), true, TEST_LOCATION);
2970   END_TEST;
2971 }
2972
2973 int utcDaliTextFieldStyleWhilstSelected(void)
2974 {
2975   ToolkitTestApplication application;
2976   tet_infoline(" utcDaliTextFieldStyleWhilstSelected");
2977
2978   // Change font and styles whilst text is selected whilst word selected
2979
2980   TextField field = TextField::New();
2981   DALI_TEST_CHECK(field);
2982   application.GetScene().Add(field);
2983   LoadMarkerImages(application, field);
2984   // Render and notify
2985   application.SendNotification();
2986   application.Render();
2987
2988   field.SetProperty(TextField::Property::TEXT, "This is a long text for the size of the text-field.");
2989   field.SetProperty(TextField::Property::POINT_SIZE, 10.f);
2990   field.SetProperty(Actor::Property::SIZE, Vector2(300.f, 50.f));
2991   field.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT);
2992   field.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
2993
2994   // Avoid a crash when core load gl resources.
2995   application.GetGlAbstraction().SetCheckFramebufferStatusResult(GL_FRAMEBUFFER_COMPLETE);
2996   // Render and notify
2997   application.SendNotification();
2998   application.Render();
2999
3000   // Create a tap event to touch the text field.
3001   TestGenerateTap(application, 150.0f, 25.0f);
3002   // Render and notify
3003   application.SendNotification();
3004   application.Render();
3005
3006   // Tap first to get the focus.
3007   TestGenerateTap(application, 1.0f, 25.0f);
3008
3009   // Render and notify
3010   application.SendNotification();
3011   application.Render();
3012
3013   // Double tap to select a word.
3014   TestGenerateTap(application, 1.0f, 25.0f);
3015
3016   // Render and notify
3017   application.SendNotification();
3018   application.Render();
3019
3020   field.SetProperty(TextField::Property::INPUT_FONT_FAMILY, "Setting input font family");
3021   DALI_TEST_EQUALS(field.GetProperty<std::string>(TextField::Property::INPUT_FONT_FAMILY), "Setting input font family", TEST_LOCATION);
3022
3023   Property::Map fontStyleMapSet;
3024   Property::Map fontStyleMapGet;
3025
3026   fontStyleMapSet.Insert("weight", "bold");
3027   fontStyleMapSet.Insert("slant", "italic");
3028   field.SetProperty(TextField::Property::INPUT_FONT_STYLE, fontStyleMapSet);
3029
3030   fontStyleMapGet = field.GetProperty<Property::Map>(TextField::Property::INPUT_FONT_STYLE);
3031   DALI_TEST_EQUALS(fontStyleMapGet.Count(), fontStyleMapSet.Count(), TEST_LOCATION);
3032   DALI_TEST_EQUALS(DaliTestCheckMaps(fontStyleMapGet, fontStyleMapSet), true, TEST_LOCATION);
3033
3034   fontStyleMapSet.Clear();
3035   fontStyleMapSet.Insert("width", "expanded");
3036   fontStyleMapSet.Insert("slant", "italic");
3037   field.SetProperty(TextField::Property::INPUT_FONT_STYLE, fontStyleMapSet);
3038
3039   fontStyleMapGet = field.GetProperty<Property::Map>(TextField::Property::INPUT_FONT_STYLE);
3040   DALI_TEST_EQUALS(fontStyleMapGet.Count(), fontStyleMapSet.Count(), TEST_LOCATION);
3041   DALI_TEST_EQUALS(DaliTestCheckMaps(fontStyleMapGet, fontStyleMapSet), true, TEST_LOCATION);
3042
3043   field.SetProperty(TextField::Property::INPUT_POINT_SIZE, 12.f);
3044   DALI_TEST_EQUALS(field.GetProperty<float>(TextField::Property::INPUT_POINT_SIZE), 12.f, Math::MACHINE_EPSILON_1000, TEST_LOCATION);
3045
3046   field.SetProperty(TextField::Property::TEXT_COLOR, Color::RED);
3047   DALI_TEST_EQUALS(field.GetProperty<Vector4>(TextField::Property::TEXT_COLOR), Color::RED, TEST_LOCATION);
3048
3049   fontStyleMapSet.Clear();
3050   fontStyleMapSet.Insert("weight", "bold");
3051   fontStyleMapSet.Insert("slant", "italic");
3052
3053   field.SetProperty(TextField::Property::FONT_STYLE, fontStyleMapSet);
3054
3055   fontStyleMapGet = field.GetProperty<Property::Map>(TextField::Property::FONT_STYLE);
3056   DALI_TEST_EQUALS(fontStyleMapGet.Count(), fontStyleMapSet.Count(), TEST_LOCATION);
3057   DALI_TEST_EQUALS(DaliTestCheckMaps(fontStyleMapGet, fontStyleMapSet), true, TEST_LOCATION);
3058
3059   fontStyleMapSet.Clear();
3060   fontStyleMapSet.Insert("width", "expanded");
3061
3062   field.SetProperty(TextField::Property::FONT_STYLE, fontStyleMapSet);
3063
3064   fontStyleMapGet = field.GetProperty<Property::Map>(TextField::Property::FONT_STYLE);
3065   DALI_TEST_EQUALS(fontStyleMapGet.Count(), fontStyleMapSet.Count(), TEST_LOCATION);
3066   DALI_TEST_EQUALS(DaliTestCheckMaps(fontStyleMapGet, fontStyleMapSet), true, TEST_LOCATION);
3067
3068   // Press Escape to increase coverage
3069   application.ProcessEvent(GenerateKey("", "", "", DALI_KEY_ESCAPE, 0, 0, Integration::KeyEvent::UP, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
3070   application.SendNotification();
3071   application.Render();
3072
3073   DALI_TEST_CHECK(!field.HasKeyInputFocus());
3074
3075   END_TEST;
3076 }
3077
3078 int utcDaliTextFieldEscKeyLoseFocus(void)
3079 {
3080   ToolkitTestApplication application;
3081   tet_infoline(" utcDaliTextFieldEscKeyLoseFocus");
3082
3083   // Creates a tap event. After creating a tap event the text field should
3084   // have the focus and add text with key events should be possible.
3085
3086   TextField field = TextField::New();
3087   DALI_TEST_CHECK(field);
3088
3089   application.GetScene().Add(field);
3090
3091   field.SetProperty(Actor::Property::SIZE, Vector2(300.f, 50.f));
3092   field.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT);
3093   field.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
3094
3095   // Avoid a crash when core load gl resources.
3096   application.GetGlAbstraction().SetCheckFramebufferStatusResult(GL_FRAMEBUFFER_COMPLETE);
3097
3098   // Render and notify
3099   application.SendNotification();
3100   application.Render();
3101
3102   // Add a key event but as the text field has not the focus it should do nothing.
3103   application.ProcessEvent(GenerateKey("a", "", "a", KEY_A_CODE, 0, 0, Integration::KeyEvent::DOWN, "a", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
3104   application.ProcessEvent(GenerateKey("a", "", "a", KEY_A_CODE, 0, 0, Integration::KeyEvent::UP, "a", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
3105
3106   // Render and notify
3107   application.SendNotification();
3108   application.Render();
3109
3110   DALI_TEST_EQUALS(field.GetProperty<std::string>(TextField::Property::TEXT), std::string(""), TEST_LOCATION);
3111
3112   // Create a tap event to touch the text field.
3113   TestGenerateTap(application, 150.0f, 25.0f);
3114
3115   // Render and notify
3116   application.SendNotification();
3117   application.Render();
3118
3119   // Now the text field has the focus, so it can handle the key events.
3120   application.ProcessEvent(GenerateKey("a", "", "a", KEY_A_CODE, 0, 0, Integration::KeyEvent::DOWN, "a", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
3121   application.ProcessEvent(GenerateKey("a", "", "a", KEY_A_CODE, 0, 0, Integration::KeyEvent::UP, "a", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
3122   application.ProcessEvent(GenerateKey("d", "", "d", KEY_D_CODE, 0, 0, Integration::KeyEvent::DOWN, "d", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
3123   application.ProcessEvent(GenerateKey("d", "", "d", KEY_D_CODE, 0, 0, Integration::KeyEvent::UP, "d", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
3124
3125   // Render and notify
3126   application.SendNotification();
3127   application.Render();
3128
3129   DALI_TEST_EQUALS(field.GetProperty<std::string>(TextField::Property::TEXT), std::string("ad"), TEST_LOCATION);
3130
3131   // Generate a Esc key event. The text field should lose the focus.
3132   application.ProcessEvent(GenerateKey("", "", "", DALI_KEY_ESCAPE, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
3133   application.ProcessEvent(GenerateKey("", "", "", DALI_KEY_ESCAPE, 0, 0, Integration::KeyEvent::UP, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
3134
3135   // Render and notify
3136   application.SendNotification();
3137   application.Render();
3138
3139   DALI_TEST_EQUALS(false, field.HasKeyInputFocus(), TEST_LOCATION);
3140
3141   // No more text should be introduced
3142   application.ProcessEvent(GenerateKey("a", "", "a", KEY_A_CODE, 0, 0, Integration::KeyEvent::DOWN, "a", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
3143   application.ProcessEvent(GenerateKey("a", "", "a", KEY_A_CODE, 0, 0, Integration::KeyEvent::UP, "a", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
3144
3145   // Render and notify
3146   application.SendNotification();
3147   application.Render();
3148
3149   DALI_TEST_EQUALS(field.GetProperty<std::string>(TextField::Property::TEXT), std::string("ad"), TEST_LOCATION);
3150
3151   END_TEST;
3152 }
3153
3154 int utcDaliTextFieldSomeSpecialKeys(void)
3155 {
3156   ToolkitTestApplication application;
3157   tet_infoline(" utcDaliTextFieldSomeSpecialKeys");
3158
3159   // Checks some special keys when the text is selected.
3160
3161   TextField field = TextField::New();
3162   DALI_TEST_CHECK(field);
3163   application.GetScene().Add(field);
3164   LoadMarkerImages(application, field);
3165   // Render and notify
3166   application.SendNotification();
3167   application.Render();
3168
3169   const std::string longText("This is a long text for the size of the text-field.");
3170
3171   field.SetProperty(TextField::Property::TEXT, longText);
3172   field.SetProperty(TextField::Property::POINT_SIZE, 10.f);
3173   field.SetProperty(Actor::Property::SIZE, Vector2(300.f, 50.f));
3174   field.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT);
3175   field.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
3176
3177   // Avoid a crash when core load gl resources.
3178   application.GetGlAbstraction().SetCheckFramebufferStatusResult(GL_FRAMEBUFFER_COMPLETE);
3179   // Render and notify
3180   application.SendNotification();
3181   application.Render();
3182
3183   // Create a tap event to touch the text field.
3184   TestGenerateTap(application, 150.0f, 25.0f);
3185
3186   // Render and notify
3187   application.SendNotification();
3188   application.Render();
3189
3190   // Tap first to get the focus.
3191   TestGenerateTap(application, 1.0f, 25.0f);
3192
3193   // Render and notify
3194   application.SendNotification();
3195   application.Render();
3196
3197   // Double tap to select a word.
3198   TestGenerateTap(application, 1.0f, 25.0f);
3199
3200   // Render and notify
3201   application.SendNotification();
3202   application.Render();
3203
3204   // Generate a Esc key event. The text field should lose the focus.
3205   application.ProcessEvent(GenerateKey("XF86PowerOff", "", "XF86PowerOff", DALI_KEY_POWER, 0, 0, Integration::KeyEvent::DOWN, "XF86PowerOff", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
3206   application.ProcessEvent(GenerateKey("XF86PowerOff", "", "XF86PowerOff", DALI_KEY_POWER, 0, 0, Integration::KeyEvent::UP, "XF86PowerOff", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
3207
3208   // Render and notify
3209   application.SendNotification();
3210   application.Render();
3211
3212   // Generate a Esc key event. The text field should lose the focus.
3213   application.ProcessEvent(GenerateKey("XF86Menu", "", "XF86Menu", DALI_KEY_MENU, 0, 0, Integration::KeyEvent::DOWN, "XF86Menu", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
3214   application.ProcessEvent(GenerateKey("XF86Menu", "", "XF86Menu", DALI_KEY_MENU, 0, 0, Integration::KeyEvent::UP, "XF86Menu", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
3215
3216   // Render and notify
3217   application.SendNotification();
3218   application.Render();
3219
3220   // Generate a Esc key event. The text field should lose the focus.
3221   application.ProcessEvent(GenerateKey("XF86Home", "", "XF86Home", DALI_KEY_HOME, 0, 0, Integration::KeyEvent::DOWN, "XF86Home", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
3222   application.ProcessEvent(GenerateKey("XF86Home", "", "XF86Home", DALI_KEY_HOME, 0, 0, Integration::KeyEvent::UP, "XF86Home", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
3223
3224   // Render and notify
3225   application.SendNotification();
3226   application.Render();
3227
3228   // The text shouldn't be deleted.
3229   DALI_TEST_EQUALS(field.GetProperty<std::string>(TextField::Property::TEXT), longText, TEST_LOCATION);
3230
3231   END_TEST;
3232 }
3233
3234 int utcDaliTextFieldSizeUpdate(void)
3235 {
3236   ToolkitTestApplication application;
3237   tet_infoline("utcDaliTextFieldSizeUpdate");
3238
3239   // Checks some special keys when the text is selected.
3240   TextField field = TextField::New();
3241   DALI_TEST_CHECK(field);
3242   application.GetScene().Add(field);
3243
3244   float       previousHeight = 0.0f;
3245   float       currentHeight  = 0.0f;
3246   const float fieldWidth     = 1920.0f;
3247
3248   // "ㅁ" is bigger then "ኢ"
3249   field.SetProperty(Actor::Property::SIZE, Vector2(fieldWidth, 10.0f));
3250   field.SetResizePolicy(ResizePolicy::FIXED, Dimension::WIDTH);
3251   field.SetResizePolicy(ResizePolicy::DIMENSION_DEPENDENCY, Dimension::HEIGHT);
3252
3253   field.SetProperty(TextField::Property::TEXT, "ኢ");
3254   field.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT);
3255   field.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
3256
3257   field.SetProperty(Actor::Property::KEYBOARD_FOCUSABLE, true);
3258   KeyboardFocusManager::Get().SetCurrentFocusActor(field);
3259
3260   application.SendNotification();
3261   application.Render();
3262
3263   previousHeight = field.GetHeightForWidth(fieldWidth);
3264   DALI_TEST_EQUALS(previousHeight, field.GetProperty<float>(Actor::Property::SIZE_HEIGHT), TEST_LOCATION);
3265
3266   // Add  another script characters ( glyph height is defferent )
3267   application.ProcessEvent(GenerateKey("ㅁ", "", "ㅁ", KEY_A_CODE, 0, 0, Integration::KeyEvent::DOWN, "ㅁ", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
3268   application.ProcessEvent(GenerateKey("ㅁ", "", "ㅁ", KEY_A_CODE, 0, 0, Integration::KeyEvent::UP, "ㅁ", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
3269
3270   application.SendNotification();
3271   application.Render();
3272
3273   currentHeight = field.GetHeightForWidth(fieldWidth);
3274   DALI_TEST_EQUALS(currentHeight, field.GetProperty<float>(Actor::Property::SIZE_HEIGHT), TEST_LOCATION);
3275   DALI_TEST_EQUALS((previousHeight < currentHeight), true, TEST_LOCATION);
3276
3277   END_TEST;
3278 }
3279
3280 int utcDaliTextFieldExtremlyLargePointSize(void)
3281 {
3282   ToolkitTestApplication application;
3283   tet_infoline(" utcDaliTextFieldExtremlyLargePointSize");
3284
3285   TextField field = TextField::New();
3286
3287   field.SetProperty(TextField::Property::TEXT, "Text");
3288   field.SetProperty(Actor::Property::SIZE, Vector2(300.f, 50.f));
3289   field.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT);
3290   field.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
3291   application.GetScene().Add(field);
3292
3293   try
3294   {
3295     field.SetProperty(TextField::Property::POINT_SIZE, 160.0f);
3296     application.SendNotification();
3297     DALI_TEST_CHECK(field);
3298   }
3299   catch(...)
3300   {
3301     tet_result(TET_FAIL);
3302   }
3303   END_TEST;
3304 }
3305
3306 int UtcDaliTextFieldDefaultFontStylePropertyCoverage(void)
3307 {
3308   ToolkitTestApplication application;
3309   tet_infoline("UtcDaliTextFieldFontStylePorpertyCoverage");
3310   TextField field = TextField::New();
3311   DALI_TEST_CHECK(field);
3312   application.GetScene().Add(field);
3313
3314   Property::Map fontStyleMapGet;
3315
3316   fontStyleMapGet = field.GetProperty<Property::Map>(TextField::Property::FONT_STYLE);
3317
3318   Property::Value* weightValue = NULL;
3319   Property::Value* widthValue  = NULL;
3320   Property::Value* slantValue  = NULL;
3321   weightValue                  = fontStyleMapGet.Find("weight");
3322   widthValue                   = fontStyleMapGet.Find("width");
3323   slantValue                   = fontStyleMapGet.Find("slant");
3324   DALI_TEST_CHECK(!weightValue);
3325   DALI_TEST_CHECK(!widthValue);
3326   DALI_TEST_CHECK(!slantValue);
3327
3328   END_TEST;
3329 }
3330
3331 int UtcDaliTextFieldSettingPlaceholder(void)
3332 {
3333   ToolkitTestApplication application;
3334   tet_infoline("UtcDaliTextFieldSettingPlaceholder");
3335
3336   TextField field = TextField::New();
3337   DALI_TEST_CHECK(field);
3338   application.GetScene().Add(field);
3339
3340   // Check the placeholder property with pixel size
3341   Property::Map placeholderPixelSizeMapSet;
3342   Property::Map placeholderPixelSizeMapGet;
3343   Property::Map placeholderFontstyleMap;
3344   placeholderPixelSizeMapSet[Text::PlaceHolder::Property::TEXT]         = "Setting Placeholder Text";
3345   placeholderPixelSizeMapSet[Text::PlaceHolder::Property::TEXT_FOCUSED] = "Setting Placeholder Text Focused";
3346   placeholderPixelSizeMapSet[Text::PlaceHolder::Property::COLOR]        = Color::BLUE;
3347   placeholderPixelSizeMapSet[Text::PlaceHolder::Property::FONT_FAMILY]  = "Arial";
3348   placeholderPixelSizeMapSet[Text::PlaceHolder::Property::PIXEL_SIZE]   = 15.0f;
3349   placeholderPixelSizeMapSet[Text::PlaceHolder::Property::ELLIPSIS]     = true;
3350
3351   placeholderFontstyleMap.Insert("weight", "bold");
3352   placeholderPixelSizeMapSet[Text::PlaceHolder::Property::FONT_STYLE] = placeholderFontstyleMap;
3353   field.SetProperty(TextField::Property::PLACEHOLDER, placeholderPixelSizeMapSet);
3354
3355   placeholderPixelSizeMapGet = field.GetProperty<Property::Map>(TextField::Property::PLACEHOLDER);
3356   DALI_TEST_EQUALS(placeholderPixelSizeMapGet.Count(), placeholderPixelSizeMapSet.Count(), TEST_LOCATION);
3357   DALI_TEST_EQUALS(DaliTestCheckMaps(placeholderPixelSizeMapGet, placeholderPixelSizeMapSet), true, TEST_LOCATION);
3358
3359   // Check the placeholder property with point size
3360   Property::Map placeholderMapSet;
3361   Property::Map placeholderMapGet;
3362   placeholderMapSet[Text::PlaceHolder::Property::TEXT]         = "Setting Placeholder Text";
3363   placeholderMapSet[Text::PlaceHolder::Property::TEXT_FOCUSED] = "Setting Placeholder Text Focused";
3364   placeholderMapSet[Text::PlaceHolder::Property::COLOR]        = Color::RED;
3365   placeholderMapSet[Text::PlaceHolder::Property::FONT_FAMILY]  = "Arial";
3366   placeholderMapSet[Text::PlaceHolder::Property::POINT_SIZE]   = 12.0f;
3367   placeholderMapSet[Text::PlaceHolder::Property::ELLIPSIS]     = false;
3368
3369   // Check the placeholder font style property
3370   placeholderFontstyleMap.Clear();
3371
3372   placeholderFontstyleMap.Insert("weight", "bold");
3373   placeholderFontstyleMap.Insert("width", "condensed");
3374   placeholderFontstyleMap.Insert("slant", "italic");
3375   placeholderMapSet[Text::PlaceHolder::Property::FONT_STYLE] = placeholderFontstyleMap;
3376   field.SetProperty(TextField::Property::PLACEHOLDER, placeholderMapSet);
3377
3378   placeholderMapGet = field.GetProperty<Property::Map>(TextField::Property::PLACEHOLDER);
3379   DALI_TEST_EQUALS(placeholderMapGet.Count(), placeholderMapSet.Count(), TEST_LOCATION);
3380   DALI_TEST_EQUALS(DaliTestCheckMaps(placeholderMapGet, placeholderMapSet), true, TEST_LOCATION);
3381
3382   // Reset font style.
3383   placeholderFontstyleMap.Clear();
3384   placeholderFontstyleMap.Insert("weight", "normal");
3385   placeholderFontstyleMap.Insert("slant", "oblique");
3386   placeholderMapSet[Text::PlaceHolder::Property::FONT_STYLE] = placeholderFontstyleMap;
3387   field.SetProperty(TextField::Property::PLACEHOLDER, placeholderMapSet);
3388
3389   placeholderMapGet = field.GetProperty<Property::Map>(TextField::Property::PLACEHOLDER);
3390   DALI_TEST_EQUALS(placeholderMapGet.Count(), placeholderMapSet.Count(), TEST_LOCATION);
3391   DALI_TEST_EQUALS(DaliTestCheckMaps(placeholderMapGet, placeholderMapSet), true, TEST_LOCATION);
3392
3393   placeholderFontstyleMap.Clear();
3394   placeholderFontstyleMap.Insert("slant", "roman");
3395   placeholderMapSet[Text::PlaceHolder::Property::FONT_STYLE] = placeholderFontstyleMap;
3396   field.SetProperty(TextField::Property::PLACEHOLDER, placeholderMapSet);
3397
3398   placeholderMapGet = field.GetProperty<Property::Map>(TextField::Property::PLACEHOLDER);
3399
3400   placeholderFontstyleMap.Clear();
3401   placeholderMapSet[Text::PlaceHolder::Property::FONT_STYLE] = placeholderFontstyleMap;
3402
3403   field.SetProperty(TextField::Property::PLACEHOLDER, placeholderMapSet);
3404   placeholderMapGet = field.GetProperty<Property::Map>(TextField::Property::PLACEHOLDER);
3405   DALI_TEST_EQUALS(placeholderMapGet.Count(), placeholderMapSet.Count(), TEST_LOCATION);
3406   DALI_TEST_EQUALS(DaliTestCheckMaps(placeholderMapGet, placeholderMapSet), true, TEST_LOCATION);
3407
3408   END_TEST;
3409 }
3410
3411 int UtcDaliTextFieldPlaceholderCoverage(void)
3412 {
3413   ToolkitTestApplication application;
3414   tet_infoline("UtcDaliTextFieldPlaceholderCoverage");
3415
3416   // mPlaceholderFont is created only once, so create a new control for coverage.
3417   TextField fieldForCoverage = TextField::New();
3418   DALI_TEST_CHECK(fieldForCoverage);
3419   application.GetScene().Add(fieldForCoverage);
3420
3421   // for SetPlaceholderFontFamily() coverage.
3422   Property::Map fontFamilyMap;
3423   fontFamilyMap[Text::PlaceHolder::Property::FONT_FAMILY] = "Arial";
3424   fieldForCoverage.SetProperty(TextField::Property::PLACEHOLDER, fontFamilyMap);
3425
3426   // mPlaceholderFont is created only once, so create a new control for coverage.
3427   fieldForCoverage = TextField::New();
3428   DALI_TEST_CHECK(fieldForCoverage);
3429   application.GetScene().Add(fieldForCoverage);
3430
3431   // for SetPlaceholderTextFontSize coverage.
3432   Property::Map fontSizeMap;
3433   fontSizeMap[Text::PlaceHolder::Property::PIXEL_SIZE] = 15.0f;
3434   fieldForCoverage.SetProperty(TextField::Property::PLACEHOLDER, fontSizeMap);
3435
3436   // mPlaceholderFont is created only once, so create a new control for coverage.
3437   fieldForCoverage = TextField::New();
3438   DALI_TEST_CHECK(fieldForCoverage);
3439   application.GetScene().Add(fieldForCoverage);
3440
3441   // for SetPlaceholderTextFontWeight coverage.
3442   Property::Map fontStyleWeightMap;
3443   Property::Map fontStyleWeightPropertyMap;
3444   fontStyleWeightPropertyMap.Insert("weight", "bold");
3445   fontStyleWeightMap[Text::PlaceHolder::Property::FONT_STYLE] = fontStyleWeightPropertyMap;
3446   fieldForCoverage.SetProperty(TextField::Property::PLACEHOLDER, fontStyleWeightMap);
3447
3448   // mPlaceholderFont is created only once, so create a new control for coverage.
3449   fieldForCoverage = TextField::New();
3450   DALI_TEST_CHECK(fieldForCoverage);
3451   application.GetScene().Add(fieldForCoverage);
3452
3453   // for SetPlaceholderTextFontWidth coverage.
3454   Property::Map fontStyleWidthMap;
3455   Property::Map fontStyleWidthPropertyMap;
3456   fontStyleWidthPropertyMap.Insert("width", "expanded");
3457   fontStyleWidthMap[Text::PlaceHolder::Property::FONT_STYLE] = fontStyleWidthPropertyMap;
3458   fieldForCoverage.SetProperty(TextField::Property::PLACEHOLDER, fontStyleWidthMap);
3459
3460   // mPlaceholderFont is created only once, so create a new control for coverage.
3461   fieldForCoverage = TextField::New();
3462   DALI_TEST_CHECK(fieldForCoverage);
3463   application.GetScene().Add(fieldForCoverage);
3464
3465   // for SetPlaceholderTextFontSlant coverage.
3466   Property::Map fontStyleSlantMap;
3467   Property::Map fontStyleSlantPropertyMap;
3468   fontStyleSlantPropertyMap.Insert("slant", "italic");
3469   fontStyleSlantMap[Text::PlaceHolder::Property::FONT_STYLE] = fontStyleSlantPropertyMap;
3470   fieldForCoverage.SetProperty(TextField::Property::PLACEHOLDER, fontStyleSlantMap);
3471
3472   END_TEST;
3473 }
3474
3475 int UtcDaliTextFieldSetPaddingProperty(void)
3476 {
3477   ToolkitTestApplication application;
3478   tet_infoline("UtcDaliTextFieldSetPaddingProperty\n");
3479
3480   TextField field = TextField::New();
3481   DALI_TEST_CHECK(field);
3482   field.SetProperty(Actor::Property::SIZE, Vector2(300.f, 50.f));
3483   field.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT);
3484   field.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
3485   application.GetScene().Add(field);
3486
3487   application.SendNotification();
3488   application.Render();
3489
3490   Vector3 originalSize = field.GetNaturalSize();
3491
3492   field.SetProperty(Toolkit::Control::Property::PADDING, Extents(10, 10, 10, 10));
3493
3494   application.SendNotification();
3495   application.Render();
3496
3497   DALI_TEST_EQUALS(field.GetProperty<Extents>(Toolkit::Control::Property::PADDING), Extents(10, 10, 10, 10), TEST_LOCATION);
3498
3499   Vector3 paddingAddedSize = field.GetNaturalSize();
3500
3501   DALI_TEST_EQUALS(originalSize.width + 10 + 10, paddingAddedSize.width, Math::MACHINE_EPSILON_1000, TEST_LOCATION);
3502
3503   DALI_TEST_EQUALS(originalSize.height + 10 + 10, paddingAddedSize.height, Math::MACHINE_EPSILON_1000, TEST_LOCATION);
3504
3505   END_TEST;
3506 }
3507
3508 int UtcDaliTextFieldEnableShiftSelectionProperty(void)
3509 {
3510   ToolkitTestApplication application;
3511   tet_infoline("UtcDaliTextFieldEnableShiftSelectionProperty");
3512
3513   TextField field = TextField::New();
3514   DALI_TEST_CHECK(field);
3515   field.SetProperty(Actor::Property::SIZE, Vector2(300.f, 50.f));
3516   field.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT);
3517   field.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
3518   application.GetScene().Add(field);
3519
3520   application.SendNotification();
3521   application.Render();
3522
3523   // The default value of ENABLE_SHIFT_SELECTION is 'true'.
3524   DALI_TEST_EQUALS(field.GetProperty<bool>(DevelTextField::Property::ENABLE_SHIFT_SELECTION), true, TEST_LOCATION);
3525
3526   // Check the enable shift selection property
3527   field.SetProperty(DevelTextField::Property::ENABLE_SHIFT_SELECTION, false);
3528   DALI_TEST_EQUALS(field.GetProperty<bool>(DevelTextField::Property::ENABLE_SHIFT_SELECTION), false, TEST_LOCATION);
3529
3530   application.SendNotification();
3531   application.Render();
3532
3533   END_TEST;
3534 }
3535
3536 int UtcDaliTextFieldEnableGrabHandleProperty(void)
3537 {
3538   ToolkitTestApplication application;
3539   tet_infoline("UtcDaliTextFieldEnableGrabHandleProperty");
3540
3541   TextField field = TextField::New();
3542   DALI_TEST_CHECK(field);
3543   field.SetProperty(Actor::Property::SIZE, Vector2(300.f, 50.f));
3544   field.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT);
3545   field.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
3546   application.GetScene().Add(field);
3547
3548   application.SendNotification();
3549   application.Render();
3550
3551   // The default value of ENABLE_GRAB_HANDLE is 'true'.
3552   DALI_TEST_EQUALS(field.GetProperty<bool>(DevelTextField::Property::ENABLE_GRAB_HANDLE), true, TEST_LOCATION);
3553
3554   // Check the enable grab handle property
3555   field.SetProperty(DevelTextField::Property::ENABLE_GRAB_HANDLE, false);
3556   DALI_TEST_EQUALS(field.GetProperty<bool>(DevelTextField::Property::ENABLE_GRAB_HANDLE), false, TEST_LOCATION);
3557
3558   application.SendNotification();
3559   application.Render();
3560
3561   END_TEST;
3562 }
3563
3564 int UtcDaliTextFieldMatchSystemLanguageDirectionProperty(void)
3565 {
3566   ToolkitTestApplication application;
3567   tet_infoline("UtcDaliTextFieldMatchSystemLanguageDirectionProperty");
3568
3569   TextField field = TextField::New();
3570   DALI_TEST_CHECK(field);
3571   field.SetProperty(Actor::Property::SIZE, Vector2(300.f, 50.f));
3572   field.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT);
3573   field.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
3574   application.GetScene().Add(field);
3575
3576   application.SendNotification();
3577   application.Render();
3578
3579   // The default value of MATCH_SYSTEM_LANGUAGE_DIRECTION is 'true'.
3580   DALI_TEST_EQUALS(field.GetProperty<bool>(DevelTextField::Property::MATCH_SYSTEM_LANGUAGE_DIRECTION), true, TEST_LOCATION);
3581
3582   // Check the match system language direction property
3583   field.SetProperty(DevelTextField::Property::MATCH_SYSTEM_LANGUAGE_DIRECTION, false);
3584   DALI_TEST_EQUALS(field.GetProperty<bool>(DevelTextField::Property::MATCH_SYSTEM_LANGUAGE_DIRECTION), false, TEST_LOCATION);
3585
3586   application.SendNotification();
3587   application.Render();
3588
3589   END_TEST;
3590 }
3591
3592 int utcDaliTextFieldLayoutDirectionCoverage(void)
3593 {
3594   ToolkitTestApplication application;
3595   tet_infoline(" utcDaliTextFieldLayoutDirectionCoverage");
3596
3597   // Creates a tap event. After creating a tap event the text field should
3598   // have the focus and add text with key events should be possible.
3599   TextField field = TextField::New();
3600   DALI_TEST_CHECK(field);
3601
3602   application.GetScene().Add(field);
3603
3604   field.SetProperty(Actor::Property::SIZE, Vector2(300.f, 50.f));
3605   field.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT);
3606   field.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
3607
3608   // Avoid a crash when core load gl resources.
3609   application.GetGlAbstraction().SetCheckFramebufferStatusResult(GL_FRAMEBUFFER_COMPLETE);
3610
3611   // Render and notify
3612   application.SendNotification();
3613   application.Render();
3614
3615   // init direction for coverage
3616   // Set horizontal alignment END
3617   field.SetProperty(TextField::Property::HORIZONTAL_ALIGNMENT, "END");
3618
3619   // Create a tap event to touch the text field.
3620   TestGenerateTap(application, 150.0f, 25.0f);
3621
3622   // Render and notify
3623   application.SendNotification();
3624   application.Render();
3625
3626   // Set MATCH_SYSTEM_LANGUAGE_DIRECTION to true to use the layout direction.
3627   field.SetProperty(DevelTextField::Property::MATCH_SYSTEM_LANGUAGE_DIRECTION, true);
3628   field.SetProperty(Actor::Property::LAYOUT_DIRECTION, LayoutDirection::RIGHT_TO_LEFT);
3629
3630   // Set horizontal alignment BEGIN
3631   field.SetProperty(TextField::Property::HORIZONTAL_ALIGNMENT, "BEGIN");
3632
3633   // Create a tap event to touch the text field.
3634   TestGenerateTap(application, 150.0f, 25.0f);
3635
3636   // Render and notify
3637   application.SendNotification();
3638   application.Render();
3639
3640   // Set horizontal alignment CENTER
3641   field.SetProperty(TextField::Property::HORIZONTAL_ALIGNMENT, "CENTER");
3642
3643   // Create a tap event to touch the text field.
3644   TestGenerateTap(application, 150.0f, 25.0f);
3645
3646   // Render and notify
3647   application.SendNotification();
3648   application.Render();
3649
3650   // Set horizontal alignment END
3651   field.SetProperty(TextField::Property::HORIZONTAL_ALIGNMENT, "END");
3652
3653   // Create a tap event to touch the text field.
3654   TestGenerateTap(application, 150.0f, 25.0f);
3655
3656   // Render and notify
3657   application.SendNotification();
3658   application.Render();
3659
3660   // Generate a Esc key event. The text field should lose the focus.
3661   application.ProcessEvent(GenerateKey("", "", "", DALI_KEY_ESCAPE, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
3662   application.ProcessEvent(GenerateKey("", "", "", DALI_KEY_ESCAPE, 0, 0, Integration::KeyEvent::UP, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
3663
3664   // Render and notify
3665   application.SendNotification();
3666   application.Render();
3667
3668   DALI_TEST_EQUALS(false, field.HasKeyInputFocus(), TEST_LOCATION);
3669
3670   END_TEST;
3671 }
3672
3673 int UtcDaliTextFieldGetInputMethodContext(void)
3674 {
3675   ToolkitTestApplication application;
3676   tet_infoline("UtcDaliTextFieldGetInputMethodContext");
3677
3678   TextField field = TextField::New();
3679   DALI_TEST_CHECK(DevelTextField::GetInputMethodContext(field));
3680
3681   END_TEST;
3682 }
3683
3684 int UtcDaliTextFieldSelectWholeText(void)
3685 {
3686   ToolkitTestApplication application;
3687   tet_infoline(" UtcDaliTextFieldSelectWholeText ");
3688
3689   TextField textField = TextField::New();
3690
3691   application.GetScene().Add(textField);
3692
3693   textField.SetProperty(Actor::Property::SIZE, Vector2(300.f, 50.f));
3694   textField.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT);
3695   textField.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
3696
3697   // Avoid a crash when core load gl resources.
3698   application.GetGlAbstraction().SetCheckFramebufferStatusResult(GL_FRAMEBUFFER_COMPLETE);
3699
3700   application.SendNotification();
3701   application.Render();
3702
3703   DALI_TEST_EQUALS(1u, textField.GetChildCount(), TEST_LOCATION);
3704
3705   DevelTextField::SelectWholeText(textField);
3706
3707   application.SendNotification();
3708   application.Render();
3709
3710   // Nothing should have been selected. The number of children is still 1
3711   DALI_TEST_EQUALS(1u, textField.GetChildCount(), TEST_LOCATION);
3712
3713   textField.SetProperty(TextField::Property::TEXT, "Hello world");
3714
3715   application.SendNotification();
3716   application.Render();
3717
3718   DevelTextField::SelectWholeText(textField);
3719
3720   application.SendNotification();
3721   application.Render();
3722
3723   // Even if resize, selection should remain.
3724   textField.SetProperty(Actor::Property::SIZE, Vector2(150.f, 50.f));
3725
3726   application.SendNotification();
3727   application.Render();
3728
3729   // Should be 2 children, the stencil and the layer
3730   DALI_TEST_EQUALS(2u, textField.GetChildCount(), TEST_LOCATION);
3731
3732   // The offscreen root actor should have two actors: the renderer and the highlight actor.
3733   Actor stencil = textField.GetChildAt(0u);
3734
3735   // The highlight actor is drawn first, so is the first actor in the list
3736   Renderer highlight = stencil.GetChildAt(0u).GetRendererAt(0u);
3737   DALI_TEST_CHECK(highlight);
3738
3739   END_TEST;
3740 }
3741
3742 int UtcDaliTextFieldSelectText(void)
3743 {
3744   ToolkitTestApplication application;
3745   tet_infoline(" UtcDaliTextFieldSelectText ");
3746
3747   TextField textField = TextField::New();
3748
3749   application.GetScene().Add(textField);
3750
3751   textField.SetProperty(Actor::Property::SIZE, Vector2(300.f, 50.f));
3752   textField.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT);
3753   textField.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
3754
3755   // Avoid a crash when core load gl resources.
3756   application.GetGlAbstraction().SetCheckFramebufferStatusResult(GL_FRAMEBUFFER_COMPLETE);
3757
3758   application.SendNotification();
3759   application.Render();
3760
3761   DevelTextField::SelectText(textField, 0, 5);
3762
3763   application.SendNotification();
3764   application.Render();
3765
3766   // Nothing is selected
3767   std::string selectedText = textField.GetProperty(DevelTextField::Property::SELECTED_TEXT).Get<std::string>();
3768   DALI_TEST_EQUALS("", selectedText, TEST_LOCATION);
3769
3770   textField.SetProperty(TextField::Property::TEXT, "Hello world");
3771
3772   application.SendNotification();
3773   application.Render();
3774
3775   // Hello is selected
3776   DevelTextField::SelectText(textField, 0, 5);
3777
3778   application.SendNotification();
3779   application.Render();
3780
3781   selectedText = textField.GetProperty(DevelTextField::Property::SELECTED_TEXT).Get<std::string>();
3782   DALI_TEST_EQUALS("Hello", selectedText, TEST_LOCATION);
3783
3784   DALI_TEST_EQUALS(textField.GetProperty(DevelTextField::Property::SELECTED_TEXT_START).Get<int>(), 0, TEST_LOCATION);
3785   DALI_TEST_EQUALS(textField.GetProperty(DevelTextField::Property::SELECTED_TEXT_END).Get<int>(), 5, TEST_LOCATION);
3786
3787   // world is selected
3788   DevelTextField::SelectText(textField, 6, 11);
3789
3790   application.SendNotification();
3791   application.Render();
3792
3793   selectedText = textField.GetProperty(DevelTextField::Property::SELECTED_TEXT).Get<std::string>();
3794   DALI_TEST_EQUALS("world", selectedText, TEST_LOCATION);
3795
3796   DALI_TEST_EQUALS(textField.GetProperty(DevelTextField::Property::SELECTED_TEXT_START).Get<int>(), 6, TEST_LOCATION);
3797   DALI_TEST_EQUALS(textField.GetProperty(DevelTextField::Property::SELECTED_TEXT_END).Get<int>(), 11, TEST_LOCATION);
3798
3799   END_TEST;
3800 }
3801
3802 int UtcDaliTextFieldSelectNone(void)
3803 {
3804   ToolkitTestApplication application;
3805   tet_infoline(" UtcDaliTextFieldSelectWholeText ");
3806
3807   TextField textField = TextField::New();
3808
3809   application.GetScene().Add(textField);
3810
3811   textField.SetProperty(Actor::Property::SIZE, Vector2(300.f, 50.f));
3812   textField.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT);
3813   textField.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
3814
3815   // Avoid a crash when core load gl resources.
3816   application.GetGlAbstraction().SetCheckFramebufferStatusResult(GL_FRAMEBUFFER_COMPLETE);
3817
3818   application.SendNotification();
3819   application.Render();
3820
3821   textField.SetProperty(TextField::Property::TEXT, "Hello world");
3822
3823   application.SendNotification();
3824   application.Render();
3825
3826   // Nothing is selected
3827   std::string selectedText = textField.GetProperty(DevelTextField::Property::SELECTED_TEXT).Get<std::string>();
3828   DALI_TEST_EQUALS("", selectedText, TEST_LOCATION);
3829
3830   DevelTextField::SelectWholeText(textField);
3831
3832   application.SendNotification();
3833   application.Render();
3834
3835   // whole text is selected
3836   selectedText = textField.GetProperty(DevelTextField::Property::SELECTED_TEXT).Get<std::string>();
3837   DALI_TEST_EQUALS("Hello world", selectedText, TEST_LOCATION);
3838
3839   DevelTextField::SelectNone(textField);
3840
3841   application.SendNotification();
3842   application.Render();
3843
3844   // Nothing is selected
3845   selectedText = textField.GetProperty(DevelTextField::Property::SELECTED_TEXT).Get<std::string>();
3846   DALI_TEST_EQUALS("", selectedText, TEST_LOCATION);
3847
3848   END_TEST;
3849 }
3850
3851 int UtcDaliTextFieldSelectRange(void)
3852 {
3853   ToolkitTestApplication application;
3854   tet_infoline(" UtcDaliTextFieldSelectRange ");
3855
3856   TextField textField = TextField::New();
3857
3858   application.GetScene().Add(textField);
3859
3860   textField.SetProperty(Actor::Property::SIZE, Vector2(300.f, 50.f));
3861   textField.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT);
3862   textField.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
3863
3864   // Avoid a crash when core load gl resources.
3865   application.GetGlAbstraction().SetCheckFramebufferStatusResult(GL_FRAMEBUFFER_COMPLETE);
3866
3867   application.SendNotification();
3868   application.Render();
3869
3870   textField.SetProperty(TextField::Property::TEXT, "Hello world");
3871
3872   application.SendNotification();
3873   application.Render();
3874
3875   textField.SetProperty(DevelTextField::Property::SELECTED_TEXT_START, 0);
3876   textField.SetProperty(DevelTextField::Property::SELECTED_TEXT_END, 5);
3877
3878   // Hello is selected
3879   std::string selectedText = textField.GetProperty(DevelTextField::Property::SELECTED_TEXT).Get<std::string>();
3880   DALI_TEST_EQUALS("Hello", selectedText, TEST_LOCATION);
3881
3882   DALI_TEST_EQUALS(textField.GetProperty(DevelTextField::Property::SELECTED_TEXT_START).Get<int>(), 0, TEST_LOCATION);
3883   DALI_TEST_EQUALS(textField.GetProperty(DevelTextField::Property::SELECTED_TEXT_END).Get<int>(), 5, TEST_LOCATION);
3884
3885   textField.SetProperty(DevelTextField::Property::SELECTED_TEXT_START, 6);
3886   textField.SetProperty(DevelTextField::Property::SELECTED_TEXT_END, 11);
3887
3888   // world is selected
3889   selectedText = textField.GetProperty(DevelTextField::Property::SELECTED_TEXT).Get<std::string>();
3890   DALI_TEST_EQUALS("world", selectedText, TEST_LOCATION);
3891
3892   DALI_TEST_EQUALS(textField.GetProperty(DevelTextField::Property::SELECTED_TEXT_START).Get<int>(), 6, TEST_LOCATION);
3893   DALI_TEST_EQUALS(textField.GetProperty(DevelTextField::Property::SELECTED_TEXT_END).Get<int>(), 11, TEST_LOCATION);
3894
3895   END_TEST;
3896 }
3897
3898 int UtcDaliTextFieldEnableEditing(void)
3899 {
3900   ToolkitTestApplication application;
3901   tet_infoline(" UtcDaliTextFieldEnableEditing ");
3902
3903   TextField textField = TextField::New();
3904
3905   application.GetScene().Add(textField);
3906
3907   textField.SetProperty(Actor::Property::SIZE, Vector2(300.f, 50.f));
3908   textField.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT);
3909   textField.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
3910
3911   // Avoid a crash when core load gl resources.
3912   application.GetGlAbstraction().SetCheckFramebufferStatusResult(GL_FRAMEBUFFER_COMPLETE);
3913
3914   application.SendNotification();
3915   application.Render();
3916
3917   textField.SetProperty(DevelActor::Property::USER_INTERACTION_ENABLED, true);
3918   DALI_TEST_EQUALS(textField.GetProperty(DevelActor::Property::USER_INTERACTION_ENABLED).Get<bool>(), true, TEST_LOCATION);
3919
3920   textField.SetKeyInputFocus();
3921   textField.SetProperty(DevelTextField::Property::ENABLE_EDITING, false);
3922   application.ProcessEvent(GenerateKey("D", "", "D", KEY_D_CODE, 0, 0, Integration::KeyEvent::DOWN, "D", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
3923
3924   // Render and notify
3925   application.SendNotification();
3926   application.Render();
3927
3928   DALI_TEST_EQUALS(textField.GetProperty(TextField::Property::TEXT).Get<std::string>(), "", TEST_LOCATION);
3929   DALI_TEST_EQUALS(textField.GetProperty(DevelTextField::Property::ENABLE_EDITING).Get<bool>(), false, TEST_LOCATION);
3930
3931   textField.SetKeyInputFocus();
3932   textField.SetProperty(DevelTextField::Property::ENABLE_EDITING, true);
3933   application.ProcessEvent(GenerateKey("D", "", "D", KEY_D_CODE, 0, 0, Integration::KeyEvent::DOWN, "D", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
3934
3935   // Render and notify
3936   application.SendNotification();
3937   application.Render();
3938
3939   DALI_TEST_EQUALS(textField.GetProperty(TextField::Property::TEXT).Get<std::string>(), "D", TEST_LOCATION);
3940   DALI_TEST_EQUALS(textField.GetProperty(DevelTextField::Property::ENABLE_EDITING).Get<bool>(), true, TEST_LOCATION);
3941
3942   // Check the user interaction enabled and for coverage
3943   DevelTextField::SelectWholeText(textField);
3944
3945   // Render and notify
3946   application.SendNotification();
3947   application.Render();
3948
3949   textField.SetKeyInputFocus();
3950   textField.SetProperty(DevelActor::Property::USER_INTERACTION_ENABLED, false);
3951   application.ProcessEvent(GenerateKey("D", "", "D", KEY_D_CODE, 0, 0, Integration::KeyEvent::DOWN, "D", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
3952
3953   // Render and notify
3954   application.SendNotification();
3955   application.Render();
3956
3957   DALI_TEST_EQUALS(textField.GetProperty(TextField::Property::TEXT).Get<std::string>(), "D", TEST_LOCATION);
3958   DALI_TEST_EQUALS(textField.GetProperty(DevelActor::Property::USER_INTERACTION_ENABLED).Get<bool>(), false, TEST_LOCATION);
3959
3960   END_TEST;
3961 }
3962
3963 int UtcDaliToolkitTextFieldFontSizeScale(void)
3964 {
3965   ToolkitTestApplication application;
3966   tet_infoline(" UtcDaliToolkitTextFieldFontSizeScale");
3967
3968   TextField textField = TextField::New();
3969   textField.SetProperty(TextField::Property::POINT_SIZE, 30.f);
3970   textField.SetProperty(TextField::Property::TEXT, "Test");
3971   Vector3 nonScaledSize = textField.GetNaturalSize();
3972
3973   TextField textFieldScaled = TextField::New();
3974   textFieldScaled.SetProperty(TextField::Property::POINT_SIZE, 15.f);
3975   textFieldScaled.SetProperty(Toolkit::DevelTextField::Property::FONT_SIZE_SCALE, 2.f);
3976   textFieldScaled.SetProperty(TextField::Property::TEXT, "Test");
3977   Vector3 scaledSize = textFieldScaled.GetNaturalSize();
3978
3979   DALI_TEST_EQUALS(nonScaledSize, scaledSize, TEST_LOCATION);
3980
3981   textField.SetProperty(TextField::Property::PIXEL_SIZE, 30.f);
3982   textField.SetProperty(TextField::Property::TEXT, "Test");
3983   nonScaledSize = textField.GetNaturalSize();
3984
3985   textFieldScaled.SetProperty(TextField::Property::PIXEL_SIZE, 15.f);
3986   textFieldScaled.SetProperty(Toolkit::DevelTextField::Property::FONT_SIZE_SCALE, 2.f);
3987   textFieldScaled.SetProperty(TextField::Property::TEXT, "Test");
3988   scaledSize = textFieldScaled.GetNaturalSize();
3989
3990   DALI_TEST_EQUALS(nonScaledSize, scaledSize, TEST_LOCATION);
3991
3992   END_TEST;
3993 }
3994
3995 int UtcDaliTextFieldPrimaryCursorPosition(void)
3996 {
3997   ToolkitTestApplication application;
3998   tet_infoline(" UtcDaliTextFieldPrimaryCursorPosition ");
3999
4000   TextField textField = TextField::New();
4001
4002   application.GetScene().Add(textField);
4003
4004   textField.SetProperty(TextField::Property::TEXT, "ABCEF");
4005   textField.SetProperty(Actor::Property::SIZE, Vector2(300.f, 50.f));
4006   textField.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT);
4007   textField.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
4008
4009   // Avoid a crash when core load gl resources.
4010   application.GetGlAbstraction().SetCheckFramebufferStatusResult(GL_FRAMEBUFFER_COMPLETE);
4011
4012   textField.SetProperty(DevelTextField::Property::PRIMARY_CURSOR_POSITION, 3);
4013   application.SendNotification();
4014   application.Render();
4015   textField.SetKeyInputFocus();
4016
4017   application.ProcessEvent(GenerateKey("D", "", "D", KEY_D_CODE, 0, 0, Integration::KeyEvent::DOWN, "D", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
4018
4019   // Render and notify
4020   application.SendNotification();
4021   application.Render();
4022
4023   DALI_TEST_EQUALS(textField.GetProperty(TextField::Property::TEXT).Get<std::string>(), "ABCDEF", TEST_LOCATION);
4024   DALI_TEST_EQUALS(textField.GetProperty(DevelTextField::Property::PRIMARY_CURSOR_POSITION).Get<int>(), 4, TEST_LOCATION);
4025
4026   END_TEST;
4027 }
4028
4029 // test max length when set after setting long text
4030 int utcDaliTextFieldMaxCharactersReachedAfterSetText(void)
4031 {
4032   ToolkitTestApplication application;
4033   tet_infoline(" utcDaliTextFieldMaxCharactersReachedAfterSetText");
4034   TextField field = TextField::New();
4035   DALI_TEST_CHECK(field);
4036
4037   application.GetScene().Add(field);
4038
4039   field.SetProperty(TextField::Property::TEXT, "123456789");
4040
4041   const int maxNumberOfCharacters = 3;
4042   field.SetProperty(TextField::Property::MAX_LENGTH, maxNumberOfCharacters);
4043
4044   field.SetKeyInputFocus();
4045
4046   // connect to the text max lengh reached signal.
4047   ConnectionTracker* testTracker            = new ConnectionTracker();
4048   bool               maxLengthReachedSignal = false;
4049   field.ConnectSignal(testTracker, "maxLengthReached", CallbackFunctor(&maxLengthReachedSignal));
4050
4051   application.ProcessEvent(GenerateKey("a", "", "a", KEY_A_CODE, 0, 0, Integration::KeyEvent::DOWN, "a", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
4052   application.ProcessEvent(GenerateKey("a", "", "a", KEY_A_CODE, 0, 0, Integration::KeyEvent::DOWN, "a", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
4053
4054   DALI_TEST_CHECK(maxLengthReachedSignal);
4055
4056   DALI_TEST_EQUALS(field.GetProperty(TextField::Property::TEXT).Get<std::string>(), "123456789", TEST_LOCATION);
4057
4058   END_TEST;
4059 }
4060
4061 int UtcDaliTextFieldAtlasLimitationIsEnabledForLargeFontPointSize(void)
4062 {
4063   ToolkitTestApplication application;
4064   tet_infoline(" UtcDaliTextFieldAtlasLimitationIsEnabledForLargeFontPointSize ");
4065
4066   // +2: First one to handle the equal case. Second one to handle odd to even case of GetNaturalSize
4067   const uint32_t lessThanWidth  = TextAbstraction::FontClient::MAX_TEXT_ATLAS_WIDTH - TextAbstraction::FontClient::PADDING_TEXT_ATLAS_BLOCK + 2;
4068   const uint32_t lessThanHeight = TextAbstraction::FontClient::MAX_TEXT_ATLAS_HEIGHT - TextAbstraction::FontClient::PADDING_TEXT_ATLAS_BLOCK + 2;
4069
4070   // Create a text field
4071   TextField textField = TextField::New();
4072
4073   //Set size to avoid automatic eliding
4074   textField.SetProperty(Actor::Property::SIZE, Vector2(1025, 1025));
4075   //Set very large font-size using point-size
4076   textField.SetProperty(TextField::Property::POINT_SIZE, 1000);
4077   //Specify font-family
4078   textField.SetProperty(TextField::Property::FONT_FAMILY, "DejaVu Sans");
4079   //Set text to check if appear or not
4080   textField.SetProperty(TextField::Property::TEXT, "A");
4081
4082   application.GetScene().Add(textField);
4083
4084   application.SendNotification();
4085   application.Render();
4086   //Use GetNaturalSize to verify that size of block does not exceed Atlas size
4087   Vector3 naturalSize = textField.GetNaturalSize();
4088
4089   DALI_TEST_GREATER(lessThanWidth, static_cast<uint32_t>(naturalSize.width), TEST_LOCATION);
4090   DALI_TEST_GREATER(lessThanHeight, static_cast<uint32_t>(naturalSize.height), TEST_LOCATION);
4091
4092   END_TEST;
4093 }
4094
4095 int UtcDaliTextFieldAtlasLimitationIsEnabledPerformanceCases(void)
4096 {
4097   ToolkitTestApplication application;
4098   tet_infoline(" UtcDaliTextFieldAtlasLimitationIsEnabledPerformanceCases ");
4099
4100   // +2: First one to handle the equal case. Second one to handle odd to even case of GetNaturalSize
4101   const uint32_t lessThanWidth  = TextAbstraction::FontClient::MAX_TEXT_ATLAS_WIDTH - TextAbstraction::FontClient::PADDING_TEXT_ATLAS_BLOCK + 2;
4102   const uint32_t lessThanHeight = TextAbstraction::FontClient::MAX_TEXT_ATLAS_HEIGHT - TextAbstraction::FontClient::PADDING_TEXT_ATLAS_BLOCK + 2;
4103
4104   Vector3 naturalSize; //Use GetNaturalSize to verify that size of block does not exceed Atlas size
4105   // Create a text editor
4106   TextField textField = TextField::New();
4107
4108   //Set size to avoid automatic eliding
4109   textField.SetProperty(Actor::Property::SIZE, Vector2(1025, 1025));
4110   textField.SetProperty(TextField::Property::FONT_FAMILY, "DejaVu Sans");
4111   textField.SetProperty(TextField::Property::TEXT, "A");
4112
4113   const int numberOfCases             = 6;
4114   int       arrayCases[numberOfCases] = {323, 326, 330, 600, 1630, 2500};
4115
4116   for(int index = 0; index < numberOfCases; index++)
4117   {
4118     tet_printf(" UtcDaliTextFieldAtlasLimitationIsEnabledPerformanceCases point-size= %d \n", arrayCases[index]);
4119     textField.SetProperty(TextField::Property::POINT_SIZE, arrayCases[index]);
4120     application.GetScene().Add(textField);
4121     application.SendNotification();
4122     application.Render();
4123     naturalSize = textField.GetNaturalSize();
4124     DALI_TEST_GREATER(lessThanWidth, static_cast<uint32_t>(naturalSize.width), TEST_LOCATION);
4125     DALI_TEST_GREATER(lessThanHeight, static_cast<uint32_t>(naturalSize.height), TEST_LOCATION);
4126   }
4127
4128   END_TEST;
4129 }
4130
4131 int UtcDaliToolkitTextFieldEllipsisPositionProperty(void)
4132 {
4133   ToolkitTestApplication application;
4134   tet_infoline(" UtcDaliToolkitTextFieldEllipsisPositionProperty ");
4135   TextField textField = TextField::New();
4136
4137   tet_infoline(" UtcDaliToolkitTextFieldEllipsisPositionProperty - Default is END");
4138   DALI_TEST_EQUALS(textField.GetProperty<int>(DevelTextField::Property::ELLIPSIS_POSITION), static_cast<int>(Toolkit::DevelText::EllipsisPosition::END), TEST_LOCATION);
4139
4140   tet_infoline(" UtcDaliToolkitTextFieldEllipsisPositionProperty - Change to START");
4141   textField.SetProperty(DevelTextField::Property::ELLIPSIS_POSITION, DevelText::EllipsisPosition::START);
4142   DALI_TEST_EQUALS(textField.GetProperty<int>(DevelTextField::Property::ELLIPSIS_POSITION), static_cast<int>(Toolkit::DevelText::EllipsisPosition::START), TEST_LOCATION);
4143
4144   tet_infoline(" UtcDaliToolkitTextFieldEllipsisPositionProperty - Change to MIDDLE");
4145   textField.SetProperty(DevelTextField::Property::ELLIPSIS_POSITION, DevelText::EllipsisPosition::MIDDLE);
4146   DALI_TEST_EQUALS(textField.GetProperty<int>(DevelTextField::Property::ELLIPSIS_POSITION), static_cast<int>(Toolkit::DevelText::EllipsisPosition::MIDDLE), TEST_LOCATION);
4147
4148   tet_infoline(" UtcDaliToolkitTextFieldEllipsisPositionProperty - Change to END");
4149   textField.SetProperty(DevelTextField::Property::ELLIPSIS_POSITION, DevelText::EllipsisPosition::END);
4150   DALI_TEST_EQUALS(textField.GetProperty<int>(DevelTextField::Property::ELLIPSIS_POSITION), static_cast<int>(Toolkit::DevelText::EllipsisPosition::END), TEST_LOCATION);
4151
4152   tet_infoline(" UtcDaliToolkitTextFieldEllipsisPositionProperty - Change to START using integer");
4153   textField.SetProperty(DevelTextField::Property::ELLIPSIS_POSITION, 1);
4154   DALI_TEST_EQUALS(textField.GetProperty<int>(DevelTextField::Property::ELLIPSIS_POSITION), static_cast<int>(Toolkit::DevelText::EllipsisPosition::START), TEST_LOCATION);
4155
4156   tet_infoline(" UtcDaliToolkitTextFieldEllipsisPositionProperty - Change to MIDDLE using integer");
4157   textField.SetProperty(DevelTextField::Property::ELLIPSIS_POSITION, 2);
4158   DALI_TEST_EQUALS(textField.GetProperty<int>(DevelTextField::Property::ELLIPSIS_POSITION), static_cast<int>(Toolkit::DevelText::EllipsisPosition::MIDDLE), TEST_LOCATION);
4159
4160   tet_infoline(" UtcDaliToolkitTextFieldEllipsisPositionProperty - Change to END using integer");
4161   textField.SetProperty(DevelTextField::Property::ELLIPSIS_POSITION, 0);
4162   DALI_TEST_EQUALS(textField.GetProperty<int>(DevelTextField::Property::ELLIPSIS_POSITION), static_cast<int>(Toolkit::DevelText::EllipsisPosition::END), TEST_LOCATION);
4163
4164   tet_infoline(" UtcDaliToolkitTextlabelEllipsisPositionProperty - Change to START using string - uppercase");
4165   textField.SetProperty(DevelTextField::Property::ELLIPSIS_POSITION, "START");
4166   DALI_TEST_EQUALS(textField.GetProperty<int>(DevelTextField::Property::ELLIPSIS_POSITION), static_cast<int>(Toolkit::DevelText::EllipsisPosition::START), TEST_LOCATION);
4167
4168   tet_infoline(" UtcDaliToolkitTextlabelEllipsisPositionProperty - Change to MIDDLE using string - uppercase");
4169   textField.SetProperty(DevelTextField::Property::ELLIPSIS_POSITION, "MIDDLE");
4170   DALI_TEST_EQUALS(textField.GetProperty<int>(DevelTextField::Property::ELLIPSIS_POSITION), static_cast<int>(Toolkit::DevelText::EllipsisPosition::MIDDLE), TEST_LOCATION);
4171
4172   tet_infoline(" UtcDaliToolkitTextlabelEllipsisPositionProperty - Change to END using string - uppercase");
4173   textField.SetProperty(DevelTextField::Property::ELLIPSIS_POSITION, "END");
4174   DALI_TEST_EQUALS(textField.GetProperty<int>(DevelTextField::Property::ELLIPSIS_POSITION), static_cast<int>(Toolkit::DevelText::EllipsisPosition::END), TEST_LOCATION);
4175
4176   tet_infoline(" UtcDaliToolkitTextlabelEllipsisPositionProperty - Change to START using string - lowercase");
4177   textField.SetProperty(DevelTextField::Property::ELLIPSIS_POSITION, "start");
4178   DALI_TEST_EQUALS(textField.GetProperty<int>(DevelTextField::Property::ELLIPSIS_POSITION), static_cast<int>(Toolkit::DevelText::EllipsisPosition::START), TEST_LOCATION);
4179
4180   tet_infoline(" UtcDaliToolkitTextlabelEllipsisPositionProperty - Change to MIDDLE using string - lowercase");
4181   textField.SetProperty(DevelTextField::Property::ELLIPSIS_POSITION, "middle");
4182   DALI_TEST_EQUALS(textField.GetProperty<int>(DevelTextField::Property::ELLIPSIS_POSITION), static_cast<int>(Toolkit::DevelText::EllipsisPosition::MIDDLE), TEST_LOCATION);
4183
4184   tet_infoline(" UtcDaliToolkitTextlabelEllipsisPositionProperty - Change to END using string - lowercase");
4185   textField.SetProperty(DevelTextField::Property::ELLIPSIS_POSITION, "end");
4186   DALI_TEST_EQUALS(textField.GetProperty<int>(DevelTextField::Property::ELLIPSIS_POSITION), static_cast<int>(Toolkit::DevelText::EllipsisPosition::END), TEST_LOCATION);
4187
4188   END_TEST;
4189 }
4190
4191 int UtcDaliTextFieldCopyText(void)
4192 {
4193   ToolkitTestApplication application;
4194   tet_infoline(" UtcDaliTextFieldCopyText ");
4195
4196   TextField textField = TextField::New();
4197
4198   std::string selectedText = "";
4199   std::string copiedText   = "";
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 copied
4231   copiedText = DevelTextField::CopyText(textField);
4232   DALI_TEST_EQUALS("Hello", copiedText, TEST_LOCATION);
4233
4234   // world is selected
4235   DevelTextField::SelectText(textField, 6, 11);
4236
4237   application.SendNotification();
4238   application.Render();
4239
4240   selectedText = textField.GetProperty(DevelTextField::Property::SELECTED_TEXT).Get<std::string>();
4241   DALI_TEST_EQUALS("world", selectedText, TEST_LOCATION);
4242
4243   DALI_TEST_EQUALS(textField.GetProperty(DevelTextField::Property::SELECTED_TEXT_START).Get<int>(), 6, TEST_LOCATION);
4244   DALI_TEST_EQUALS(textField.GetProperty(DevelTextField::Property::SELECTED_TEXT_END).Get<int>(), 11, TEST_LOCATION);
4245
4246   // world is copied
4247   copiedText = DevelTextField::CopyText(textField);
4248   DALI_TEST_EQUALS("world", copiedText, TEST_LOCATION);
4249
4250   // "lo wo" is selected
4251   DevelTextField::SelectText(textField, 3, 8);
4252
4253   application.SendNotification();
4254   application.Render();
4255
4256   selectedText = textField.GetProperty(DevelTextField::Property::SELECTED_TEXT).Get<std::string>();
4257   DALI_TEST_EQUALS("lo wo", selectedText, TEST_LOCATION);
4258
4259   DALI_TEST_EQUALS(textField.GetProperty(DevelTextField::Property::SELECTED_TEXT_START).Get<int>(), 3, TEST_LOCATION);
4260   DALI_TEST_EQUALS(textField.GetProperty(DevelTextField::Property::SELECTED_TEXT_END).Get<int>(), 8, TEST_LOCATION);
4261
4262   // "lo wo" is copied
4263   copiedText = DevelTextField::CopyText(textField);
4264   DALI_TEST_EQUALS("lo wo", copiedText, TEST_LOCATION);
4265
4266   END_TEST;
4267 }
4268
4269 int UtcDaliTextFieldCutText(void)
4270 {
4271   ToolkitTestApplication application;
4272   tet_infoline(" UtcDaliTextFieldCutText ");
4273
4274   TextField textField = TextField::New();
4275
4276   std::string selectedText = "";
4277
4278   application.GetScene().Add(textField);
4279
4280   textField.SetProperty(Actor::Property::SIZE, Vector2(300.f, 50.f));
4281   textField.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT);
4282   textField.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
4283
4284   // Avoid a crash when core load gl resources.
4285   application.GetGlAbstraction().SetCheckFramebufferStatusResult(GL_FRAMEBUFFER_COMPLETE);
4286
4287   application.SendNotification();
4288   application.Render();
4289
4290   textField.SetProperty(TextField::Property::TEXT, "Hello world");
4291
4292   application.SendNotification();
4293   application.Render();
4294
4295   // Hello is selected
4296   DevelTextField::SelectText(textField, 0, 5);
4297
4298   application.SendNotification();
4299   application.Render();
4300
4301   selectedText = textField.GetProperty(DevelTextField::Property::SELECTED_TEXT).Get<std::string>();
4302   DALI_TEST_EQUALS("Hello", selectedText, TEST_LOCATION);
4303
4304   DALI_TEST_EQUALS(textField.GetProperty(DevelTextField::Property::SELECTED_TEXT_START).Get<int>(), 0, TEST_LOCATION);
4305   DALI_TEST_EQUALS(textField.GetProperty(DevelTextField::Property::SELECTED_TEXT_END).Get<int>(), 5, TEST_LOCATION);
4306
4307   // Hello is cut
4308   DALI_TEST_EQUALS("Hello", DevelTextField::CutText(textField), TEST_LOCATION);
4309
4310   DALI_TEST_EQUALS(textField.GetProperty(TextField::Property::TEXT).Get<std::string>(), " world", TEST_LOCATION);
4311
4312   // " w" is selected
4313   DevelTextField::SelectText(textField, 0, 2);
4314
4315   application.SendNotification();
4316   application.Render();
4317
4318   selectedText = textField.GetProperty(DevelTextField::Property::SELECTED_TEXT).Get<std::string>();
4319   DALI_TEST_EQUALS(" w", selectedText, TEST_LOCATION);
4320
4321   DALI_TEST_EQUALS(textField.GetProperty(DevelTextField::Property::SELECTED_TEXT_START).Get<int>(), 0, TEST_LOCATION);
4322   DALI_TEST_EQUALS(textField.GetProperty(DevelTextField::Property::SELECTED_TEXT_END).Get<int>(), 2, TEST_LOCATION);
4323
4324   // " w" is cut
4325   DALI_TEST_EQUALS(" w", DevelTextField::CutText(textField), TEST_LOCATION);
4326
4327   application.SendNotification();
4328   application.Render();
4329
4330   DALI_TEST_EQUALS(textField.GetProperty(TextField::Property::TEXT).Get<std::string>(), "orld", TEST_LOCATION);
4331
4332   // Test Cut from the middle
4333
4334   // "rl" is selected
4335   DevelTextField::SelectText(textField, 1, 3);
4336
4337   application.SendNotification();
4338   application.Render();
4339
4340   selectedText = textField.GetProperty(DevelTextField::Property::SELECTED_TEXT).Get<std::string>();
4341   DALI_TEST_EQUALS("rl", selectedText, TEST_LOCATION);
4342
4343   DALI_TEST_EQUALS(textField.GetProperty(DevelTextField::Property::SELECTED_TEXT_START).Get<int>(), 1, TEST_LOCATION);
4344   DALI_TEST_EQUALS(textField.GetProperty(DevelTextField::Property::SELECTED_TEXT_END).Get<int>(), 3, TEST_LOCATION);
4345
4346   // "rl" is cut
4347   DALI_TEST_EQUALS("rl", DevelTextField::CutText(textField), TEST_LOCATION);
4348
4349   application.SendNotification();
4350   application.Render();
4351
4352   DALI_TEST_EQUALS(textField.GetProperty(TextField::Property::TEXT).Get<std::string>(), "od", TEST_LOCATION);
4353
4354   // Test Cut from the end
4355
4356   // "d" is selected
4357   DevelTextField::SelectText(textField, 1, 2);
4358
4359   application.SendNotification();
4360   application.Render();
4361
4362   selectedText = textField.GetProperty(DevelTextField::Property::SELECTED_TEXT).Get<std::string>();
4363   DALI_TEST_EQUALS("d", selectedText, TEST_LOCATION);
4364
4365   DALI_TEST_EQUALS(textField.GetProperty(DevelTextField::Property::SELECTED_TEXT_START).Get<int>(), 1, TEST_LOCATION);
4366   DALI_TEST_EQUALS(textField.GetProperty(DevelTextField::Property::SELECTED_TEXT_END).Get<int>(), 2, TEST_LOCATION);
4367
4368   // "d" is cut
4369   DALI_TEST_EQUALS("d", DevelTextField::CutText(textField), TEST_LOCATION);
4370
4371   application.SendNotification();
4372   application.Render();
4373
4374   DALI_TEST_EQUALS(textField.GetProperty(TextField::Property::TEXT).Get<std::string>(), "o", TEST_LOCATION);
4375
4376   END_TEST;
4377 }
4378
4379 int UtcDaliTextFieldPasteText(void)
4380 {
4381   ToolkitTestApplication application;
4382   tet_infoline(" UtcDaliTextFieldPasteText ");
4383
4384   TextField textField = TextField::New();
4385
4386   application.GetScene().Add(textField);
4387
4388   std::string cutText    = "";
4389   std::string copiedText = "";
4390
4391   textField.SetProperty(Actor::Property::SIZE, Vector2(300.f, 50.f));
4392   textField.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT);
4393   textField.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
4394
4395   // Avoid a crash when core load gl resources.
4396   application.GetGlAbstraction().SetCheckFramebufferStatusResult(GL_FRAMEBUFFER_COMPLETE);
4397
4398   application.SendNotification();
4399   application.Render();
4400
4401   textField.SetProperty(TextField::Property::TEXT, "Hello World");
4402
4403   application.SendNotification();
4404   application.Render();
4405
4406   // Tap on the text editor
4407   TestGenerateTap(application, 3.0f, 25.0f);
4408
4409   // Render and notify
4410   application.SendNotification();
4411   application.Render();
4412
4413   // Select some text in the right of the current cursor position
4414   DevelTextField::SelectText(textField, 0, 3);
4415
4416   // Render and notify
4417   application.SendNotification();
4418   application.Render();
4419
4420   // Cut the selected text
4421   cutText = DevelTextField::CutText(textField);
4422
4423   // Render and notify
4424   application.SendNotification();
4425   application.Render();
4426
4427   DALI_TEST_EQUALS("Hel", cutText, TEST_LOCATION);
4428   DALI_TEST_EQUALS(textField.GetProperty(TextField::Property::TEXT).Get<std::string>(), "lo World", TEST_LOCATION);
4429
4430   DevelTextField::SelectText(textField, 0, 3);
4431
4432   // Render and notify
4433   application.SendNotification();
4434   application.Render();
4435
4436   // Copy the selected text
4437   copiedText = DevelTextField::CopyText(textField);
4438
4439   // Render and notify
4440   application.SendNotification();
4441   application.Render();
4442
4443   DALI_TEST_EQUALS("lo ", copiedText, TEST_LOCATION);
4444   DALI_TEST_EQUALS("lo World", textField.GetProperty<std::string>(TextField::Property::TEXT), TEST_LOCATION);
4445
4446   // Move the cursor to the end of the line
4447   application.ProcessEvent(GenerateKey("", "", "", DALI_KEY_CURSOR_RIGHT, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
4448   application.ProcessEvent(GenerateKey("", "", "", DALI_KEY_CURSOR_RIGHT, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
4449   application.ProcessEvent(GenerateKey("", "", "", DALI_KEY_CURSOR_RIGHT, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
4450   application.ProcessEvent(GenerateKey("", "", "", DALI_KEY_CURSOR_RIGHT, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
4451   application.ProcessEvent(GenerateKey("", "", "", DALI_KEY_CURSOR_RIGHT, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
4452   application.ProcessEvent(GenerateKey("", "", "", DALI_KEY_CURSOR_RIGHT, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
4453   application.ProcessEvent(GenerateKey("", "", "", DALI_KEY_CURSOR_RIGHT, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
4454   application.ProcessEvent(GenerateKey("", "", "", DALI_KEY_CURSOR_RIGHT, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
4455
4456   // Render and notify
4457   application.SendNotification();
4458   application.Render();
4459
4460   // Paste the selected text at the current cursor position
4461   DevelTextField::PasteText(textField);
4462
4463   // Render and notify
4464   application.SendNotification();
4465   application.Render();
4466
4467   DALI_TEST_EQUALS(textField.GetProperty(TextField::Property::TEXT).Get<std::string>(), "lo Worldlo ", TEST_LOCATION);
4468
4469   END_TEST;
4470 }
4471
4472 int utcDaliTextFieldCursorPositionChangedSignal(void)
4473 {
4474   ToolkitTestApplication application;
4475   tet_infoline(" utcDaliTextFieldCursorPositionChangedSignal");
4476
4477   TextField field = TextField::New();
4478   DALI_TEST_CHECK(field);
4479
4480   application.GetScene().Add(field);
4481
4482   // connect to the selection changed signal.
4483   ConnectionTracker* testTracker = new ConnectionTracker();
4484   DevelTextField::CursorPositionChangedSignal(field).Connect(&TestCursorPositionChangedCallback);
4485   bool cursorPositionChangedSignal = false;
4486   field.ConnectSignal(testTracker, "cursorPositionChanged", CallbackFunctor(&cursorPositionChangedSignal));
4487
4488   field.SetProperty(TextField::Property::TEXT, "Hello world Hello world");
4489   field.SetProperty(TextField::Property::POINT_SIZE, 10.f);
4490   field.SetProperty(Actor::Property::SIZE, Vector2(100.f, 50.f));
4491   field.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT);
4492   field.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
4493
4494   // Avoid a crash when core load gl resources.
4495   application.GetGlAbstraction().SetCheckFramebufferStatusResult(GL_FRAMEBUFFER_COMPLETE);
4496
4497   // Render and notify
4498   application.SendNotification();
4499   application.Render();
4500
4501   field.SetKeyInputFocus();
4502
4503   // Tap on the text field
4504   TestGenerateTap(application, 3.0f, 25.0f);
4505
4506   // Render and notify
4507   application.SendNotification();
4508   application.Render();
4509
4510   DALI_TEST_CHECK(gCursorPositionChangedCallbackCalled);
4511   DALI_TEST_EQUALS(oldCursorPos, 23, TEST_LOCATION);
4512
4513   gCursorPositionChangedCallbackCalled = false;
4514
4515   // Move to left.
4516   application.ProcessEvent(GenerateKey("", "", "", DALI_KEY_CURSOR_LEFT, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
4517
4518   // Render and notify
4519   application.SendNotification();
4520   application.Render();
4521
4522   DALI_TEST_CHECK(gCursorPositionChangedCallbackCalled);
4523   DALI_TEST_EQUALS(oldCursorPos, 17, TEST_LOCATION);
4524
4525   gCursorPositionChangedCallbackCalled = false;
4526
4527   // Insert D
4528   application.ProcessEvent(GenerateKey("D", "", "D", KEY_D_CODE, 0, 0, Integration::KeyEvent::DOWN, "D", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
4529
4530   // Render and notify
4531   application.SendNotification();
4532   application.Render();
4533
4534   DALI_TEST_CHECK(gCursorPositionChangedCallbackCalled);
4535   DALI_TEST_EQUALS(oldCursorPos, 16, TEST_LOCATION);
4536
4537   gCursorPositionChangedCallbackCalled = false;
4538
4539   //delete one character
4540   application.ProcessEvent(GenerateKey("", "", "", DALI_KEY_BACKSPACE, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
4541
4542   // Render and notify
4543   application.SendNotification();
4544   application.Render();
4545
4546   DALI_TEST_CHECK(gCursorPositionChangedCallbackCalled);
4547   DALI_TEST_EQUALS(oldCursorPos, 17, TEST_LOCATION);
4548
4549   gCursorPositionChangedCallbackCalled = false;
4550
4551   field.SetProperty(TextField::Property::TEXT, "Hello");
4552
4553   // Render and notify
4554   application.SendNotification();
4555   application.Render();
4556
4557   DALI_TEST_CHECK(gCursorPositionChangedCallbackCalled);
4558   DALI_TEST_EQUALS(oldCursorPos, 16, TEST_LOCATION);
4559
4560   gCursorPositionChangedCallbackCalled = false;
4561
4562   field.SetProperty(DevelTextField::Property::PRIMARY_CURSOR_POSITION, 3);
4563
4564   // Render and notify
4565   application.SendNotification();
4566   application.Render();
4567
4568   DALI_TEST_CHECK(gCursorPositionChangedCallbackCalled);
4569   DALI_TEST_EQUALS(oldCursorPos, 5, TEST_LOCATION);
4570
4571   END_TEST;
4572 }
4573
4574 int utcDaliTextFieldGeometryEllipsisStart(void)
4575 {
4576   ToolkitTestApplication application;
4577   tet_infoline(" utcDaliTextFieldGeometryEllipsisStart");
4578
4579   TextField field = TextField::New();
4580   DALI_TEST_CHECK(field);
4581
4582   application.GetScene().Add(field);
4583
4584   field.SetProperty(TextField::Property::POINT_SIZE, 7.f);
4585   field.SetProperty(Actor::Property::SIZE, Vector2(250.f, 50.f));
4586   field.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT);
4587   field.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
4588   field.SetProperty(TextField::Property::ENABLE_MARKUP, true);
4589   field.SetProperty(DevelTextField::Property::ELLIPSIS, true);
4590   field.SetProperty(DevelTextField::Property::ELLIPSIS_POSITION, DevelText::EllipsisPosition::START);
4591   field.SetProperty(TextField::Property::TEXT, "Hello World");
4592
4593   // Avoid a crash when core load gl resources.
4594   application.GetGlAbstraction().SetCheckFramebufferStatusResult(GL_FRAMEBUFFER_COMPLETE);
4595
4596   // Render and notify
4597   application.SendNotification();
4598   application.Render();
4599
4600   unsigned int expectedCount = 1;
4601   unsigned int startIndex    = 0;
4602   unsigned int endIndex      = 10;
4603
4604   Vector<Vector2> positionsList = DevelTextField::GetTextPosition(field, startIndex, endIndex);
4605   Vector<Vector2> sizeList      = DevelTextField::GetTextSize(field, startIndex, endIndex);
4606
4607   DALI_TEST_EQUALS(positionsList.Size(), expectedCount, TEST_LOCATION);
4608   DALI_TEST_EQUALS(sizeList.Size(), expectedCount, TEST_LOCATION);
4609
4610   Vector<Vector2> expectedSizes;
4611   Vector<Vector2> expectedPositions;
4612
4613   expectedPositions.PushBack(Vector2(14, 0));
4614   expectedSizes.PushBack(Vector2(106, 25));
4615
4616   TestTextGeometryUtils::CheckGeometryResult(positionsList, sizeList, expectedPositions, expectedSizes);
4617
4618   END_TEST;
4619 }
4620
4621 int utcDaliTextFieldGeometryEllipsisEnd(void)
4622 {
4623   ToolkitTestApplication application;
4624   tet_infoline(" utcDaliTextFieldGeometryEllipsisEnd");
4625
4626   TextField field = TextField::New();
4627   DALI_TEST_CHECK(field);
4628
4629   application.GetScene().Add(field);
4630
4631   field.SetProperty(TextField::Property::POINT_SIZE, 7.f);
4632   field.SetProperty(Actor::Property::SIZE, Vector2(250.f, 50.f));
4633   field.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT);
4634   field.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
4635   field.SetProperty(TextField::Property::ENABLE_MARKUP, true);
4636   field.SetProperty(DevelTextField::Property::ELLIPSIS, true);
4637   field.SetProperty(DevelTextField::Property::ELLIPSIS_POSITION, DevelText::EllipsisPosition::END);
4638   field.SetProperty(TextField::Property::TEXT, "Hello World");
4639
4640   // Avoid a crash when core load gl resources.
4641   application.GetGlAbstraction().SetCheckFramebufferStatusResult(GL_FRAMEBUFFER_COMPLETE);
4642
4643   // Render and notify
4644   application.SendNotification();
4645   application.Render();
4646
4647   unsigned int expectedCount = 1;
4648   unsigned int startIndex    = 0;
4649   unsigned int endIndex      = 10;
4650
4651   Vector<Vector2> positionsList = DevelTextField::GetTextPosition(field, startIndex, endIndex);
4652   Vector<Vector2> sizeList      = DevelTextField::GetTextSize(field, startIndex, endIndex);
4653
4654   DALI_TEST_EQUALS(positionsList.Size(), expectedCount, TEST_LOCATION);
4655   DALI_TEST_EQUALS(sizeList.Size(), expectedCount, TEST_LOCATION);
4656
4657   Vector<Vector2> expectedSizes;
4658   Vector<Vector2> expectedPositions;
4659
4660   expectedPositions.PushBack(Vector2(-2, 0));
4661   expectedSizes.PushBack(Vector2(122, 25));
4662
4663   TestTextGeometryUtils::CheckGeometryResult(positionsList, sizeList, expectedPositions, expectedSizes);
4664
4665   END_TEST;
4666 }
4667
4668 int utcDaliTextFieldGeometryRTL(void)
4669 {
4670   ToolkitTestApplication application;
4671   tet_infoline(" utcDaliTextFieldGeometryRTL");
4672
4673   TextField field = TextField::New();
4674   DALI_TEST_CHECK(field);
4675
4676   application.GetScene().Add(field);
4677
4678   field.SetProperty(TextField::Property::POINT_SIZE, 7.f);
4679   field.SetProperty(Actor::Property::SIZE, Vector2(300.f, 50.f));
4680   field.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT);
4681   field.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
4682   field.SetProperty(TextField::Property::ENABLE_MARKUP, true);
4683   field.SetProperty(TextField::Property::TEXT, "السطر الاخير");
4684
4685   // Avoid a crash when core load gl resources.
4686   application.GetGlAbstraction().SetCheckFramebufferStatusResult(GL_FRAMEBUFFER_COMPLETE);
4687
4688   // Render and notify
4689   application.SendNotification();
4690   application.Render();
4691
4692   unsigned int expectedCount = 1;
4693   unsigned int startIndex    = 1;
4694   unsigned int endIndex      = 7;
4695
4696   Vector<Vector2> positionsList = DevelTextField::GetTextPosition(field, startIndex, endIndex);
4697   Vector<Vector2> sizeList      = DevelTextField::GetTextSize(field, startIndex, endIndex);
4698
4699   DALI_TEST_EQUALS(positionsList.Size(), expectedCount, TEST_LOCATION);
4700   DALI_TEST_EQUALS(sizeList.Size(), expectedCount, TEST_LOCATION);
4701
4702   Vector<Vector2> expectedSizes;
4703   Vector<Vector2> expectedPositions;
4704
4705   expectedPositions.PushBack(Vector2(38, 0));
4706   expectedSizes.PushBack(Vector2(73, 25));
4707
4708   TestTextGeometryUtils::CheckGeometryResult(positionsList, sizeList, expectedPositions, expectedSizes);
4709
4710   END_TEST;
4711 }
4712
4713 int utcDaliTextFieldGeometryGlyphMiddle(void)
4714 {
4715   ToolkitTestApplication application;
4716   tet_infoline(" utcDaliTextFieldGeometryGlyphMiddle");
4717
4718   TextField field = TextField::New();
4719   DALI_TEST_CHECK(field);
4720
4721   application.GetScene().Add(field);
4722
4723   field.SetProperty(TextField::Property::POINT_SIZE, 7.f);
4724   field.SetProperty(Actor::Property::SIZE, Vector2(150.f, 200.f));
4725   field.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT);
4726   field.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
4727   field.SetProperty(TextField::Property::ENABLE_MARKUP, true);
4728   field.SetProperty(TextField::Property::TEXT, "لا تحتوي على لا");
4729
4730   // Avoid a crash when core load gl resources.
4731   application.GetGlAbstraction().SetCheckFramebufferStatusResult(GL_FRAMEBUFFER_COMPLETE);
4732
4733   // Render and notify
4734   application.SendNotification();
4735   application.Render();
4736
4737   unsigned int expectedCount = 1;
4738   unsigned int startIndex    = 1;
4739   unsigned int endIndex      = 13;
4740
4741   Vector<Vector2> positionsList = DevelTextField::GetTextPosition(field, startIndex, endIndex);
4742   Vector<Vector2> sizeList      = DevelTextField::GetTextSize(field, startIndex, endIndex);
4743
4744   DALI_TEST_EQUALS(positionsList.Size(), expectedCount, TEST_LOCATION);
4745   DALI_TEST_EQUALS(sizeList.Size(), expectedCount, TEST_LOCATION);
4746
4747   Vector<Vector2> expectedSizes;
4748   Vector<Vector2> expectedPositions;
4749
4750   expectedPositions.PushBack(Vector2(6, 0));
4751   expectedSizes.PushBack(Vector2(124, 25));
4752
4753   TestTextGeometryUtils::CheckGeometryResult(positionsList, sizeList, expectedPositions, expectedSizes);
4754
4755   END_TEST;
4756 }
4757
4758 int utcDaliTextFieldSelectionClearedSignal(void)
4759 {
4760   ToolkitTestApplication application;
4761   tet_infoline(" utcDaliTextFieldSelectionClearedSignal");
4762
4763   TextField field = TextField::New();
4764   DALI_TEST_CHECK(field);
4765
4766   application.GetScene().Add(field);
4767
4768   // connect to the selection changed signal.
4769   ConnectionTracker* testTracker = new ConnectionTracker();
4770   DevelTextField::SelectionClearedSignal(field).Connect(&TestSelectionClearedCallback);
4771   bool selectionClearedSignal = false;
4772   field.ConnectSignal(testTracker, "selectionCleared", CallbackFunctor(&selectionClearedSignal));
4773
4774   field.SetProperty(TextField::Property::TEXT, "Hello\nworld\nHello world");
4775   field.SetProperty(TextField::Property::POINT_SIZE, 10.f);
4776   field.SetProperty(Actor::Property::SIZE, Vector2(100.f, 50.f));
4777   field.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT);
4778   field.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
4779
4780   // Avoid a crash when core load gl resources.
4781   application.GetGlAbstraction().SetCheckFramebufferStatusResult(GL_FRAMEBUFFER_COMPLETE);
4782
4783   // Render and notify
4784   application.SendNotification();
4785   application.Render();
4786
4787   // Tap on the text editor
4788   TestGenerateTap(application, 3.0f, 25.0f);
4789
4790   // Render and notify
4791   application.SendNotification();
4792   application.Render();
4793
4794   // Move to second line of the text & Select some text in the right of the current cursor position
4795   application.ProcessEvent(GenerateKey("", "", "", DALI_KEY_CURSOR_DOWN, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
4796   application.ProcessEvent(GenerateKey("", "", "", DALI_KEY_CURSOR_RIGHT, KEY_SHIFT_MODIFIER, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
4797
4798   // remove selection
4799   application.ProcessEvent(GenerateKey("", "", "", DALI_KEY_ESCAPE, 0, 0, Integration::KeyEvent::UP, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
4800
4801   // Render and notify
4802   application.SendNotification();
4803   application.Render();
4804
4805   DALI_TEST_CHECK(gSelectionClearedCallbackCalled);
4806
4807   // Render and notify
4808   application.SendNotification();
4809   application.Render();
4810
4811   // Tap on the text editor
4812   TestGenerateTap(application, 3.0f, 25.0f);
4813
4814   // Render and notify
4815   application.SendNotification();
4816   application.Render();
4817
4818   gSelectionClearedCallbackCalled = false;
4819
4820   // Move to second line of the text & select.
4821   application.ProcessEvent(GenerateKey("", "", "", DALI_KEY_CURSOR_DOWN, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
4822   application.ProcessEvent(GenerateKey("", "", "", DALI_KEY_CURSOR_RIGHT, KEY_SHIFT_MODIFIER, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
4823
4824   //remove selection
4825   application.ProcessEvent(GenerateKey("", "", "", DALI_KEY_CURSOR_RIGHT, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
4826
4827   // Render and notify
4828   application.SendNotification();
4829   application.Render();
4830
4831   DALI_TEST_CHECK(gSelectionClearedCallbackCalled);
4832
4833   gSelectionClearedCallbackCalled = false;
4834
4835   // Render and notify
4836   application.SendNotification();
4837   application.Render();
4838
4839   // Move to second line of the text & select.
4840   application.ProcessEvent(GenerateKey("", "", "", DALI_KEY_CURSOR_DOWN, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
4841   application.ProcessEvent(GenerateKey("", "", "", DALI_KEY_CURSOR_RIGHT, KEY_SHIFT_MODIFIER, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
4842
4843   // replace D with selected text
4844   application.ProcessEvent(GenerateKey("D", "", "D", KEY_D_CODE, 0, 0, Integration::KeyEvent::DOWN, "D", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
4845
4846   // Render and notify
4847   application.SendNotification();
4848   application.Render();
4849
4850   DALI_TEST_CHECK(gSelectionClearedCallbackCalled);
4851
4852   gSelectionClearedCallbackCalled = false;
4853
4854   // Render and notify
4855   application.SendNotification();
4856   application.Render();
4857
4858   DevelTextField::SelectText(field, 1, 3);
4859
4860   // Render and notify
4861   application.SendNotification();
4862   application.Render();
4863
4864   field.SetProperty(DevelTextField::Property::PRIMARY_CURSOR_POSITION, 3);
4865
4866   // Render and notify
4867   application.SendNotification();
4868   application.Render();
4869
4870   DALI_TEST_CHECK(gSelectionClearedCallbackCalled);
4871
4872   gSelectionClearedCallbackCalled = false;
4873
4874   DevelTextField::SelectText(field, 1, 3);
4875
4876   // Render and notify
4877   application.SendNotification();
4878   application.Render();
4879
4880   // select none
4881   DevelTextField::SelectNone(field);
4882
4883   // Render and notify
4884   application.SendNotification();
4885   application.Render();
4886
4887   DALI_TEST_CHECK(gSelectionClearedCallbackCalled);
4888
4889   END_TEST;
4890 }
4891
4892 int utcDaliTextFieldSelectionStartedSignal(void)
4893 {
4894   ToolkitTestApplication application;
4895   tet_infoline(" utcDaliTextFieldSelectionStartedSignal");
4896
4897   TextField field = TextField::New();
4898   DALI_TEST_CHECK(field);
4899
4900   application.GetScene().Add(field);
4901
4902   // connect to the selection changed signal.
4903   ConnectionTracker* testTracker = new ConnectionTracker();
4904   DevelTextField::SelectionStartedSignal(field).Connect(&TestSelectionStartedCallback);
4905   bool selectionStartedSignal = false;
4906   field.ConnectSignal(testTracker, "selectionStarted", CallbackFunctor(&selectionStartedSignal));
4907
4908   field.SetProperty(TextField::Property::TEXT, "Hello\nworld\nHello world");
4909   field.SetProperty(TextField::Property::POINT_SIZE, 10.f);
4910   field.SetProperty(Actor::Property::SIZE, Vector2(100.f, 50.f));
4911   field.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT);
4912   field.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
4913
4914   // Avoid a crash when core load gl resources.
4915   application.GetGlAbstraction().SetCheckFramebufferStatusResult(GL_FRAMEBUFFER_COMPLETE);
4916
4917   // Render and notify
4918   application.SendNotification();
4919   application.Render();
4920
4921   // Tap on the text field
4922   TestGenerateTap(application, 3.0f, 25.0f);
4923
4924   // Render and notify
4925   application.SendNotification();
4926   application.Render();
4927
4928   // Move to second line of the text & Select some text in the right of the current cursor position
4929   application.ProcessEvent(GenerateKey("", "", "", DALI_KEY_CURSOR_DOWN, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
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(gSelectionStartedCallbackCalled);
4937
4938   // remove selection
4939   application.ProcessEvent(GenerateKey("", "", "", DALI_KEY_ESCAPE, 0, 0, Integration::KeyEvent::UP, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
4940
4941   // Render and notify
4942   application.SendNotification();
4943   application.Render();
4944
4945   gSelectionStartedCallbackCalled = false;
4946
4947   DevelTextField::SelectText(field, 1, 3);
4948
4949   // Render and notify
4950   application.SendNotification();
4951   application.Render();
4952
4953   DALI_TEST_CHECK(gSelectionStartedCallbackCalled);
4954
4955   END_TEST;
4956 }
4957
4958 int utcDaliTextFieldSelectionChangedSignal(void)
4959 {
4960   ToolkitTestApplication application;
4961   tet_infoline(" utcDaliTextFieldSelectionChangedSignal");
4962
4963   TextField field = TextField::New();
4964   DALI_TEST_CHECK(field);
4965
4966   application.GetScene().Add(field);
4967
4968   // connect to the selection changed signal.
4969   ConnectionTracker* testTracker = new ConnectionTracker();
4970   DevelTextField::SelectionChangedSignal(field).Connect(&TestSelectionChangedCallback);
4971   bool selectionChangedSignal = false;
4972   field.ConnectSignal(testTracker, "selectionChanged", CallbackFunctor(&selectionChangedSignal));
4973
4974   field.SetProperty(TextField::Property::TEXT, "Hello world Hello world");
4975   field.SetProperty(TextField::Property::POINT_SIZE, 10.f);
4976   field.SetProperty(Actor::Property::SIZE, Vector2(100.f, 50.f));
4977   field.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT);
4978   field.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
4979
4980   // Avoid a crash when core load gl resources.
4981   application.GetGlAbstraction().SetCheckFramebufferStatusResult(GL_FRAMEBUFFER_COMPLETE);
4982
4983   // Render and notify
4984   application.SendNotification();
4985   application.Render();
4986
4987   // Tap on the text field
4988   TestGenerateTap(application, 3.0f, 25.0f);
4989
4990   // Render and notify
4991   application.SendNotification();
4992   application.Render();
4993
4994   // Select some text in the right of the current cursor position
4995   application.ProcessEvent(GenerateKey("", "", "", DALI_KEY_SHIFT_LEFT, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
4996   application.ProcessEvent(GenerateKey("", "", "", DALI_KEY_CURSOR_RIGHT, KEY_SHIFT_MODIFIER, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
4997
4998   // Render and notify
4999   application.SendNotification();
5000   application.Render();
5001
5002   DALI_TEST_CHECK(gSelectionChangedCallbackCalled);
5003   DALI_TEST_EQUALS(oldSelectionStart, oldSelectionEnd, TEST_LOCATION);
5004
5005   gSelectionChangedCallbackCalled = false;
5006
5007   application.ProcessEvent(GenerateKey("", "", "", DALI_KEY_CURSOR_RIGHT, KEY_SHIFT_MODIFIER, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
5008
5009   // Render and notify
5010   application.SendNotification();
5011   application.Render();
5012
5013   DALI_TEST_CHECK(gSelectionChangedCallbackCalled);
5014   DALI_TEST_EQUALS(oldSelectionStart, 0, TEST_LOCATION);
5015   DALI_TEST_EQUALS(oldSelectionEnd, 1, TEST_LOCATION);
5016
5017   gSelectionChangedCallbackCalled = false;
5018
5019   application.ProcessEvent(GenerateKey("", "", "", DALI_KEY_ESCAPE, 0, 0, Integration::KeyEvent::UP, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
5020
5021   // Render and notify
5022   application.SendNotification();
5023   application.Render();
5024
5025   DALI_TEST_CHECK(gSelectionChangedCallbackCalled);
5026   DALI_TEST_EQUALS(oldSelectionStart, 0, TEST_LOCATION);
5027   DALI_TEST_EQUALS(oldSelectionEnd, 2, TEST_LOCATION);
5028
5029   gSelectionChangedCallbackCalled = false;
5030   field.SetKeyInputFocus();
5031
5032   // Render and notify
5033   application.SendNotification();
5034   application.Render();
5035
5036   DevelTextField::SelectText(field, 0, 5);
5037
5038   application.SendNotification();
5039   application.Render();
5040
5041   DALI_TEST_CHECK(gSelectionChangedCallbackCalled);
5042   DALI_TEST_EQUALS(oldSelectionStart, oldSelectionEnd, TEST_LOCATION);
5043
5044   gSelectionChangedCallbackCalled = false;
5045
5046   field.SetProperty(DevelTextField::Property::PRIMARY_CURSOR_POSITION, 3);
5047
5048   // Render and notify
5049   application.SendNotification();
5050   application.Render();
5051
5052   DALI_TEST_CHECK(gSelectionChangedCallbackCalled);
5053   DALI_TEST_EQUALS(oldSelectionStart, 0, TEST_LOCATION);
5054   DALI_TEST_EQUALS(oldSelectionEnd, 5, TEST_LOCATION);
5055
5056   gSelectionChangedCallbackCalled = false;
5057
5058   // select all text
5059   DevelTextField::SelectWholeText(field);
5060
5061   // Render and notify
5062   application.SendNotification();
5063   application.Render();
5064
5065   DALI_TEST_CHECK(gSelectionChangedCallbackCalled);
5066   DALI_TEST_EQUALS(oldSelectionStart, oldSelectionEnd, TEST_LOCATION);
5067
5068   gSelectionChangedCallbackCalled = false;
5069
5070   // select none
5071   DevelTextField::SelectNone(field);
5072
5073   // Render and notify
5074   application.SendNotification();
5075   application.Render();
5076
5077   DALI_TEST_CHECK(gSelectionChangedCallbackCalled);
5078   DALI_TEST_EQUALS(oldSelectionStart, 0, TEST_LOCATION);
5079   DALI_TEST_EQUALS(oldSelectionEnd, 23, TEST_LOCATION);
5080
5081   END_TEST;
5082 }
5083
5084 int UtcDaliToolkitTextFieldStrikethroughGeneration(void)
5085 {
5086   ToolkitTestApplication application;
5087   tet_infoline(" UtcDaliToolkitTextFieldStrikethroughGeneration");
5088
5089   TextField textField = TextField::New();
5090   textField.SetProperty(TextField::Property::TEXT, "Test");
5091   textField.SetProperty(Actor::Property::SIZE, Vector2(200.0f, 100.f));
5092   textField.SetProperty(TextField::Property::POINT_SIZE, 10);
5093   textField.SetProperty(TextField::Property::FONT_FAMILY, "DejaVu Sans");
5094
5095   application.GetScene().Add(textField);
5096   application.SendNotification();
5097   application.Render();
5098
5099   Property::Map strikethroughMapSet;
5100   Property::Map strikethroughMapGet;
5101
5102   strikethroughMapSet.Insert("enable", true);
5103   strikethroughMapSet.Insert("color", Color::RED);
5104   strikethroughMapSet.Insert("height", 2.0f);
5105
5106   // Check the strikethrough property
5107   textField.SetProperty(DevelTextField::Property::STRIKETHROUGH, strikethroughMapSet);
5108   strikethroughMapGet = textField.GetProperty<Property::Map>(DevelTextField::Property::STRIKETHROUGH);
5109   textField.SetProperty(TextField::Property::TEXT, "Test1");
5110   DALI_TEST_EQUALS(strikethroughMapGet.Count(), strikethroughMapSet.Count(), TEST_LOCATION);
5111   DALI_TEST_EQUALS(DaliTestCheckMaps(strikethroughMapGet, strikethroughMapSet), true, TEST_LOCATION);
5112
5113   // Render and notify
5114   application.SendNotification();
5115   application.Render();
5116
5117   strikethroughMapSet.Clear();
5118   strikethroughMapGet.Clear();
5119
5120   END_TEST;
5121 }
5122
5123 int UtcDaliToolkitTextFieldInputStrikethroughGeneration(void)
5124 {
5125   ToolkitTestApplication application;
5126   tet_infoline(" UtcDaliToolkitTextFieldInputStrikethroughGeneration");
5127
5128   TextField textField = TextField::New();
5129   textField.SetProperty(TextField::Property::TEXT, "Test");
5130   textField.SetProperty(Actor::Property::SIZE, Vector2(200.0f, 100.f));
5131   textField.SetProperty(TextField::Property::POINT_SIZE, 10);
5132   textField.SetProperty(TextField::Property::FONT_FAMILY, "DejaVu Sans");
5133
5134   application.GetScene().Add(textField);
5135   application.SendNotification();
5136   application.Render();
5137
5138   std::string strikethroughSettings1("{\"enable\":\"true\",\"color\":\"red\",\"height\":\"2\"}");
5139
5140   // Check the strikethrough property
5141   textField.SetProperty(DevelTextField::Property::INPUT_STRIKETHROUGH, strikethroughSettings1);
5142   textField.SetProperty(TextField::Property::TEXT, "Test1");
5143   DALI_TEST_EQUALS(textField.GetProperty<std::string>(DevelTextField::Property::INPUT_STRIKETHROUGH), strikethroughSettings1, TEST_LOCATION);
5144
5145   // Render and notify
5146   application.SendNotification();
5147   application.Render();
5148
5149   END_TEST;
5150 }
5151
5152 int UtcDaliToolkitTextFieldUnderlineTypesGeneration1(void)
5153 {
5154   ToolkitTestApplication application;
5155   tet_infoline(" UtcDaliToolkitTextFieldUnderlineTypesGeneration1");
5156   TextField field = TextField::New();
5157   field.SetProperty(TextField::Property::TEXT, "Test");
5158   field.SetProperty(Actor::Property::SIZE, Vector2(200.0f, 100.f));
5159   field.SetProperty(TextField::Property::POINT_SIZE, 10);
5160   field.SetProperty(TextField::Property::FONT_FAMILY, "DejaVu Sans");
5161
5162   application.GetScene().Add(field);
5163   application.SendNotification();
5164   application.Render();
5165
5166   Property::Map underlineMapSet;
5167   Property::Map underlineMapGet;
5168
5169   underlineMapSet.Insert("enable", true);
5170   underlineMapSet.Insert("color", Color::RED);
5171   underlineMapSet.Insert("height", 1);
5172   underlineMapSet.Insert("type", Text::Underline::SOLID);
5173   underlineMapSet.Insert("dashWidth", 2);
5174   underlineMapSet.Insert("dashGap", 1);
5175
5176   // Check the underline property
5177   field.SetProperty(TextField::Property::UNDERLINE, underlineMapSet);
5178
5179   underlineMapGet = field.GetProperty<Property::Map>(TextField::Property::UNDERLINE);
5180   DALI_TEST_EQUALS(underlineMapGet.Count(), underlineMapSet.Count(), TEST_LOCATION);
5181   DALI_TEST_EQUALS(DaliTestCheckMaps(underlineMapGet, underlineMapSet), true, TEST_LOCATION);
5182
5183   // Render and notify
5184   application.SendNotification();
5185   application.Render();
5186
5187   underlineMapSet.Clear();
5188   underlineMapGet.Clear();
5189
5190   underlineMapSet.Insert("enable", true);
5191   underlineMapSet.Insert("color", Color::BLUE);
5192   underlineMapSet.Insert("height", 1);
5193   underlineMapSet.Insert("type", Text::Underline::DASHED);
5194   underlineMapSet.Insert("dashWidth", 4);
5195   underlineMapSet.Insert("dashGap", 2);
5196
5197   // Check the dashed underline property
5198   field.SetProperty(TextField::Property::UNDERLINE, underlineMapSet);
5199
5200   underlineMapGet = field.GetProperty<Property::Map>(TextField::Property::UNDERLINE);
5201   DALI_TEST_EQUALS(underlineMapGet.Count(), underlineMapSet.Count(), TEST_LOCATION);
5202   DALI_TEST_EQUALS(DaliTestCheckMaps(underlineMapGet, underlineMapSet), true, TEST_LOCATION);
5203
5204   // Render and notify
5205   application.SendNotification();
5206   application.Render();
5207
5208   underlineMapSet.Clear();
5209   underlineMapGet.Clear();
5210
5211   underlineMapSet.Insert("enable", true);
5212   underlineMapSet.Insert("color", Color::BLUE);
5213   underlineMapSet.Insert("height", 1);
5214   underlineMapSet.Insert("type", Text::Underline::DOUBLE);
5215   underlineMapSet.Insert("dashWidth", 4);
5216   underlineMapSet.Insert("dashGap", 2);
5217
5218   // Check the dashed underline property
5219   field.SetProperty(TextField::Property::UNDERLINE, underlineMapSet);
5220
5221   underlineMapGet = field.GetProperty<Property::Map>(TextField::Property::UNDERLINE);
5222   DALI_TEST_EQUALS(underlineMapGet.Count(), underlineMapSet.Count(), TEST_LOCATION);
5223   DALI_TEST_EQUALS(DaliTestCheckMaps(underlineMapGet, underlineMapSet), true, TEST_LOCATION);
5224
5225   // Render and notify
5226   application.SendNotification();
5227   application.Render();
5228
5229   underlineMapSet.Clear();
5230   underlineMapGet.Clear();
5231
5232   END_TEST;
5233 }
5234
5235 int UtcDaliToolkitTextFieldUnderlineTypesGeneration2(void)
5236 {
5237   ToolkitTestApplication application;
5238   tet_infoline(" UtcDaliToolkitTextFieldUnderlineTypesGeneration2");
5239
5240   TextField field1 = TextField::New();
5241   field1.SetProperty(TextField::Property::TEXT, "Test");
5242   field1.SetProperty(Actor::Property::SIZE, Vector2(200.0f, 100.f));
5243   field1.SetProperty(TextField::Property::POINT_SIZE, 10);
5244   field1.SetProperty(TextField::Property::FONT_FAMILY, "DejaVu Sans");
5245
5246   Property::Map underlineMapSet1;
5247   Property::Map underlineMapGet1;
5248
5249   underlineMapSet1.Insert("enable", true);
5250   underlineMapSet1.Insert("color", Color::RED);
5251   underlineMapSet1.Insert("height", 1);
5252   underlineMapSet1.Insert("type", Text::Underline::SOLID);
5253   underlineMapSet1.Insert("dashWidth", 2);
5254   underlineMapSet1.Insert("dashGap", 1);
5255
5256   // Check the underline property
5257   field1.SetProperty(TextField::Property::UNDERLINE, underlineMapSet1);
5258
5259   underlineMapGet1 = field1.GetProperty<Property::Map>(TextField::Property::UNDERLINE);
5260   DALI_TEST_EQUALS(underlineMapGet1.Count(), underlineMapSet1.Count(), TEST_LOCATION);
5261   DALI_TEST_EQUALS(DaliTestCheckMaps(underlineMapGet1, underlineMapSet1), true, TEST_LOCATION);
5262
5263   application.GetScene().Add(field1);
5264   application.SendNotification();
5265   application.Render();
5266
5267   TextField field2 = TextField::New();
5268   field2.SetProperty(TextField::Property::TEXT, "Test");
5269   field2.SetProperty(Actor::Property::SIZE, Vector2(200.0f, 100.f));
5270   field2.SetProperty(TextField::Property::POINT_SIZE, 10);
5271   field2.SetProperty(TextField::Property::FONT_FAMILY, "DejaVu Sans");
5272
5273   Property::Map underlineMapSet2;
5274   Property::Map underlineMapGet2;
5275
5276   underlineMapSet2.Insert("enable", true);
5277   underlineMapSet2.Insert("color", Color::BLUE);
5278   underlineMapSet2.Insert("height", 1);
5279   underlineMapSet2.Insert("type", Text::Underline::DASHED);
5280   underlineMapSet2.Insert("dashWidth", 4);
5281   underlineMapSet2.Insert("dashGap", 2);
5282
5283   // Check the dashed underline property
5284   field2.SetProperty(TextField::Property::UNDERLINE, underlineMapSet2);
5285
5286   underlineMapGet2 = field2.GetProperty<Property::Map>(TextField::Property::UNDERLINE);
5287   DALI_TEST_EQUALS(underlineMapGet2.Count(), underlineMapSet2.Count(), TEST_LOCATION);
5288   DALI_TEST_EQUALS(DaliTestCheckMaps(underlineMapGet2, underlineMapSet2), true, TEST_LOCATION);
5289
5290   application.GetScene().Add(field2);
5291   application.SendNotification();
5292   application.Render();
5293
5294   TextField field3 = TextField::New();
5295   field3.SetProperty(TextField::Property::TEXT, "Test");
5296   field3.SetProperty(Actor::Property::SIZE, Vector2(200.0f, 100.f));
5297   field3.SetProperty(TextField::Property::POINT_SIZE, 10);
5298   field3.SetProperty(TextField::Property::FONT_FAMILY, "DejaVu Sans");
5299
5300   Property::Map underlineMapSet3;
5301   Property::Map underlineMapGet3;
5302
5303   underlineMapSet3.Insert("enable", true);
5304   underlineMapSet3.Insert("color", Color::BLUE);
5305   underlineMapSet3.Insert("height", 1);
5306   underlineMapSet3.Insert("type", Text::Underline::DOUBLE);
5307   underlineMapSet3.Insert("dashWidth", 4);
5308   underlineMapSet3.Insert("dashGap", 2);
5309
5310   // Check the dashed underline property
5311   field3.SetProperty(TextField::Property::UNDERLINE, underlineMapSet3);
5312
5313   underlineMapGet3 = field3.GetProperty<Property::Map>(TextField::Property::UNDERLINE);
5314   DALI_TEST_EQUALS(underlineMapGet3.Count(), underlineMapSet3.Count(), TEST_LOCATION);
5315   DALI_TEST_EQUALS(DaliTestCheckMaps(underlineMapGet3, underlineMapSet3), true, TEST_LOCATION);
5316
5317   application.GetScene().Add(field3);
5318
5319   application.SendNotification();
5320   application.Render();
5321
5322   END_TEST;
5323 }
5324
5325 int UtcDaliTextFieldCharacterSpacing(void)
5326 {
5327   ToolkitTestApplication application;
5328   tet_infoline(" UtcDaliTextFieldCharacterSpacing ");
5329
5330   TextField textField = TextField::New();
5331
5332   textField.SetProperty(Actor::Property::SIZE, Vector2(150.0f, 300.f));
5333
5334   application.GetScene().Add(textField);
5335   application.SendNotification();
5336   application.Render();
5337
5338   textField.SetProperty(TextField::Property::TEXT, "Hi Experiment");
5339   textField.SetProperty(DevelTextField::Property::CHARACTER_SPACING, 10.f);
5340   DALI_TEST_EQUALS(textField.GetProperty<float>(DevelTextField::Property::CHARACTER_SPACING), 10.f, Math::MACHINE_EPSILON_1000, TEST_LOCATION);
5341
5342   application.SendNotification();
5343   application.Render();
5344
5345   END_TEST;
5346 }
5347
5348 int UtcDaliToolkitTextFieldUnderlineTypesGeneration3(void)
5349 {
5350   ToolkitTestApplication application;
5351   tet_infoline(" UtcDaliToolkitTextFieldUnderlineTypesGeneration3");
5352
5353   TextField field1 = TextField::New();
5354   field1.SetProperty(TextField::Property::TEXT, "Test1");
5355   field1.SetProperty(Actor::Property::SIZE, Vector2(200.0f, 100.f));
5356   field1.SetProperty(TextField::Property::POINT_SIZE, 10);
5357   field1.SetProperty(TextField::Property::FONT_FAMILY, "DejaVu Sans");
5358
5359   Property::Map underlineMapSet1;
5360   Property::Map underlineMapGet1;
5361
5362   underlineMapSet1.Insert("enable", true);
5363   underlineMapSet1.Insert("color", Color::RED);
5364   underlineMapSet1.Insert("height", 1);
5365   underlineMapSet1.Insert("type", Text::Underline::SOLID);
5366   underlineMapSet1.Insert("dashWidth", 2);
5367   underlineMapSet1.Insert("dashGap", 1);
5368
5369   // Check the underline property
5370   field1.SetProperty(TextField::Property::UNDERLINE, underlineMapSet1);
5371   //field1.SetProperty( TextField::Property::TEXT, "Test2" );
5372
5373   underlineMapGet1 = field1.GetProperty<Property::Map>(TextField::Property::UNDERLINE);
5374   DALI_TEST_EQUALS(underlineMapGet1.Count(), underlineMapSet1.Count(), TEST_LOCATION);
5375   DALI_TEST_EQUALS(DaliTestCheckMaps(underlineMapGet1, underlineMapSet1), true, TEST_LOCATION);
5376
5377   application.GetScene().Add(field1);
5378   application.SendNotification();
5379   application.Render();
5380
5381   END_TEST;
5382 }
5383
5384 int UtcDaliToolkitTextfieldParagraphTag(void)
5385 {
5386   ToolkitTestApplication application;
5387   tet_infoline(" UtcDaliToolkitTextfieldParagraphTag");
5388   TextField fieldNewlineSeparator = TextField::New();
5389   TextField fieldParagraphTag     = TextField::New();
5390   DALI_TEST_CHECK(fieldNewlineSeparator);
5391   DALI_TEST_CHECK(fieldParagraphTag);
5392
5393   application.GetScene().Add(fieldNewlineSeparator);
5394   application.GetScene().Add(fieldParagraphTag);
5395
5396   //Same utterance uses new-line to split paragraphs should give similar results for paragraph tag.
5397   fieldNewlineSeparator.SetProperty(TextField::Property::ENABLE_MARKUP, true);
5398   fieldNewlineSeparator.SetProperty(Actor::Property::SIZE, Vector2(100.f, 50.f));
5399   fieldNewlineSeparator.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT);
5400   fieldNewlineSeparator.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
5401   fieldNewlineSeparator.SetProperty(TextField::Property::TEXT, "test paragraph tag \ntest paragraph tag \ntest paragraph tag ");
5402
5403   fieldParagraphTag.SetProperty(TextField::Property::ENABLE_MARKUP, true);
5404   fieldParagraphTag.SetProperty(Actor::Property::SIZE, Vector2(100.f, 50.f));
5405   fieldParagraphTag.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT);
5406   fieldParagraphTag.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
5407   fieldParagraphTag.SetProperty(TextField::Property::TEXT, "test paragraph tag <p>test paragraph tag </p>test paragraph tag ");
5408
5409   application.SendNotification();
5410   application.Render();
5411
5412   Vector3 textNaturalSizeNewlineSeparator = fieldNewlineSeparator.GetNaturalSize();
5413   Vector3 textNaturalSizeParagraphTag     = fieldParagraphTag.GetNaturalSize();
5414
5415   DALI_TEST_EQUALS(textNaturalSizeNewlineSeparator, textNaturalSizeParagraphTag, TEST_LOCATION);
5416
5417   application.SendNotification();
5418   application.Render();
5419
5420   END_TEST;
5421 }
5422
5423 //Handle Emoji clustering for cursor handling
5424 int utcDaliTextFieldClusteredEmojiDeletionBackSpaceKey(void)
5425 {
5426   ToolkitTestApplication application;
5427   tet_infoline(" utcDaliTextFieldClusteredEmojiDeletionBackSpaceKey ");
5428   TextField textField = TextField::New();
5429   DALI_TEST_CHECK(textField);
5430
5431   application.GetScene().Add(textField);
5432
5433   // Avoid a crash when core load gl resources.
5434   application.GetGlAbstraction().SetCheckFramebufferStatusResult(GL_FRAMEBUFFER_COMPLETE);
5435
5436   textField.SetProperty(TextField::Property::TEXT, "ABC&#x1F468;&#x200D;&#x1F469;&#x200D;&#x1F467;&#x200D;&#x1F466;XY");
5437   textField.SetProperty(Dali::Toolkit::TextField::Property::ENABLE_MARKUP, true);
5438
5439   // Render and notify
5440   application.SendNotification();
5441   application.Render();
5442
5443   // Set currsor
5444   textField.SetProperty(DevelTextField::Property::PRIMARY_CURSOR_POSITION, 10);
5445   application.SendNotification();
5446   application.Render();
5447
5448   // Set focus and remove Emoji
5449   textField.SetKeyInputFocus();
5450   application.ProcessEvent(GenerateKey("", "", "", DALI_KEY_BACKSPACE, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
5451
5452   //Check the changed text and cursor position
5453   DALI_TEST_EQUALS(textField.GetProperty(TextField::Property::TEXT).Get<std::string>(), "ABCXY", TEST_LOCATION);
5454   DALI_TEST_EQUALS(textField.GetProperty(DevelTextField::Property::PRIMARY_CURSOR_POSITION).Get<int>(), 3, TEST_LOCATION);
5455
5456   // Render and notify
5457   application.SendNotification();
5458   application.Render();
5459
5460   END_TEST;
5461 }
5462
5463 int utcDaliTextFieldClusteredEmojiDeletionDeleteKey(void)
5464 {
5465   ToolkitTestApplication application;
5466   tet_infoline(" utcDaliTextFieldClusteredEmojiDeletionDeleteKey ");
5467   TextField textField = TextField::New();
5468   DALI_TEST_CHECK(textField);
5469
5470   application.GetScene().Add(textField);
5471
5472   // Avoid a crash when core load gl resources.
5473   application.GetGlAbstraction().SetCheckFramebufferStatusResult(GL_FRAMEBUFFER_COMPLETE);
5474
5475   textField.SetProperty(TextField::Property::TEXT, "ABC&#x1F468;&#x200D;&#x1F469;&#x200D;&#x1F467;&#x200D;&#x1F466;XY");
5476   textField.SetProperty(Dali::Toolkit::TextField::Property::ENABLE_MARKUP, true);
5477
5478   // Render and notify
5479   application.SendNotification();
5480   application.Render();
5481
5482   // Set currsor
5483   textField.SetProperty(DevelTextField::Property::PRIMARY_CURSOR_POSITION, 3);
5484   application.SendNotification();
5485   application.Render();
5486
5487   // Set focus and remove Emoji
5488   textField.SetKeyInputFocus();
5489   application.ProcessEvent(GenerateKey("", "", "", Dali::DevelKey::DALI_KEY_DELETE, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
5490
5491   //Check the changed text and cursor position
5492   DALI_TEST_EQUALS(textField.GetProperty(TextField::Property::TEXT).Get<std::string>(), "ABCXY", TEST_LOCATION);
5493   DALI_TEST_EQUALS(textField.GetProperty(DevelTextField::Property::PRIMARY_CURSOR_POSITION).Get<int>(), 3, TEST_LOCATION);
5494
5495   // Render and notify
5496   application.SendNotification();
5497   application.Render();
5498
5499   END_TEST;
5500 }