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