Merge "Apply premultiply in animated image visual" into devel/master
[platform/core/uifw/dali-toolkit.git] / automated-tests / src / dali-toolkit / utc-Dali-TextField.cpp
1 /*
2  * Copyright (c) 2022 Samsung Electronics Co., Ltd.
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  * http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  *
16  */
17
18 #include <stdlib.h>
19 #include <unistd.h>
20 #include <iostream>
21
22 #include <dali/integration-api/events/key-event-integ.h>
23 #include <dali/integration-api/events/touch-event-integ.h>
24 #include <dali/public-api/rendering/renderer.h>
25 #include <dali/devel-api/actors/actor-devel.h>
26
27 #include <dali-toolkit-test-suite-utils.h>
28 #include <dali-toolkit/dali-toolkit.h>
29 #include <dali-toolkit/devel-api/controls/text-controls/text-field-devel.h>
30 #include <dali-toolkit/devel-api/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   // Generate a Back key event. Nothing happens to the text field.
3290   application.ProcessEvent(GenerateKey("XF86Back", "", "XF86Back", DALI_KEY_BACK, 0, 0, Integration::KeyEvent::DOWN, "XF86Back", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
3291   application.ProcessEvent(GenerateKey("XF86Back", "", "XF86Back", DALI_KEY_BACK, 0, 0, Integration::KeyEvent::UP, "XF86Back", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
3292
3293   // Render and notify
3294   application.SendNotification();
3295   application.Render();
3296
3297   // The text shouldn't be deleted.
3298   DALI_TEST_EQUALS(field.GetProperty<std::string>(TextField::Property::TEXT), longText, TEST_LOCATION);
3299
3300   END_TEST;
3301 }
3302
3303 int utcDaliTextFieldSizeUpdate(void)
3304 {
3305   ToolkitTestApplication application;
3306   tet_infoline("utcDaliTextFieldSizeUpdate");
3307
3308   // Checks some special keys when the text is selected.
3309   TextField field = TextField::New();
3310   DALI_TEST_CHECK(field);
3311   application.GetScene().Add(field);
3312
3313   float       previousHeight = 0.0f;
3314   float       currentHeight  = 0.0f;
3315   const float fieldWidth     = 1920.0f;
3316
3317   // "ㅁ" is bigger then "ኢ"
3318   field.SetProperty(Actor::Property::SIZE, Vector2(fieldWidth, 10.0f));
3319   field.SetResizePolicy(ResizePolicy::FIXED, Dimension::WIDTH);
3320   field.SetResizePolicy(ResizePolicy::DIMENSION_DEPENDENCY, Dimension::HEIGHT);
3321
3322   field.SetProperty(TextField::Property::TEXT, "ኢ");
3323   field.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT);
3324   field.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
3325
3326   field.SetProperty(Actor::Property::KEYBOARD_FOCUSABLE, true);
3327   KeyboardFocusManager::Get().SetCurrentFocusActor(field);
3328
3329   application.SendNotification();
3330   application.Render();
3331
3332   previousHeight = field.GetHeightForWidth(fieldWidth);
3333   DALI_TEST_EQUALS(previousHeight, field.GetProperty<float>(Actor::Property::SIZE_HEIGHT), TEST_LOCATION);
3334
3335   // Add  another script characters ( glyph height is defferent )
3336   application.ProcessEvent(GenerateKey("ㅁ", "", "ㅁ", KEY_A_CODE, 0, 0, Integration::KeyEvent::DOWN, "ㅁ", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
3337   application.ProcessEvent(GenerateKey("ㅁ", "", "ㅁ", KEY_A_CODE, 0, 0, Integration::KeyEvent::UP, "ㅁ", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
3338
3339   application.SendNotification();
3340   application.Render();
3341
3342   currentHeight = field.GetHeightForWidth(fieldWidth);
3343   DALI_TEST_EQUALS(currentHeight, field.GetProperty<float>(Actor::Property::SIZE_HEIGHT), TEST_LOCATION);
3344   DALI_TEST_EQUALS((previousHeight < currentHeight), true, TEST_LOCATION);
3345
3346   END_TEST;
3347 }
3348
3349 int utcDaliTextFieldExtremlyLargePointSize(void)
3350 {
3351   ToolkitTestApplication application;
3352   tet_infoline(" utcDaliTextFieldExtremlyLargePointSize");
3353
3354   TextField field = TextField::New();
3355
3356   field.SetProperty(TextField::Property::TEXT, "Text");
3357   field.SetProperty(Actor::Property::SIZE, Vector2(300.f, 50.f));
3358   field.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT);
3359   field.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
3360   application.GetScene().Add(field);
3361
3362   try
3363   {
3364     field.SetProperty(TextField::Property::POINT_SIZE, 160.0f);
3365     application.SendNotification();
3366     DALI_TEST_CHECK(field);
3367   }
3368   catch(...)
3369   {
3370     tet_result(TET_FAIL);
3371   }
3372   END_TEST;
3373 }
3374
3375 int UtcDaliTextFieldDefaultFontStylePropertyCoverage(void)
3376 {
3377   ToolkitTestApplication application;
3378   tet_infoline("UtcDaliTextFieldFontStylePorpertyCoverage");
3379   TextField field = TextField::New();
3380   DALI_TEST_CHECK(field);
3381   application.GetScene().Add(field);
3382
3383   Property::Map fontStyleMapGet;
3384
3385   fontStyleMapGet = field.GetProperty<Property::Map>(TextField::Property::FONT_STYLE);
3386
3387   Property::Value* weightValue = NULL;
3388   Property::Value* widthValue  = NULL;
3389   Property::Value* slantValue  = NULL;
3390   weightValue                  = fontStyleMapGet.Find("weight");
3391   widthValue                   = fontStyleMapGet.Find("width");
3392   slantValue                   = fontStyleMapGet.Find("slant");
3393   DALI_TEST_CHECK(!weightValue);
3394   DALI_TEST_CHECK(!widthValue);
3395   DALI_TEST_CHECK(!slantValue);
3396
3397   END_TEST;
3398 }
3399
3400 int UtcDaliTextFieldSettingPlaceholder(void)
3401 {
3402   ToolkitTestApplication application;
3403   tet_infoline("UtcDaliTextFieldSettingPlaceholder");
3404
3405   TextField field = TextField::New();
3406   DALI_TEST_CHECK(field);
3407   application.GetScene().Add(field);
3408
3409   // Check the placeholder property with pixel size
3410   Property::Map placeholderPixelSizeMapSet;
3411   Property::Map placeholderPixelSizeMapGet;
3412   Property::Map placeholderFontstyleMap;
3413   placeholderPixelSizeMapSet[Text::PlaceHolder::Property::TEXT]         = "Setting Placeholder Text";
3414   placeholderPixelSizeMapSet[Text::PlaceHolder::Property::TEXT_FOCUSED] = "Setting Placeholder Text Focused";
3415   placeholderPixelSizeMapSet[Text::PlaceHolder::Property::COLOR]        = Color::BLUE;
3416   placeholderPixelSizeMapSet[Text::PlaceHolder::Property::FONT_FAMILY]  = "Arial";
3417   placeholderPixelSizeMapSet[Text::PlaceHolder::Property::PIXEL_SIZE]   = 15.0f;
3418   placeholderPixelSizeMapSet[Text::PlaceHolder::Property::ELLIPSIS]     = true;
3419
3420   placeholderFontstyleMap.Insert("weight", "bold");
3421   placeholderPixelSizeMapSet[Text::PlaceHolder::Property::FONT_STYLE] = placeholderFontstyleMap;
3422   field.SetProperty(TextField::Property::PLACEHOLDER, placeholderPixelSizeMapSet);
3423
3424   placeholderPixelSizeMapGet = field.GetProperty<Property::Map>(TextField::Property::PLACEHOLDER);
3425   DALI_TEST_EQUALS(placeholderPixelSizeMapGet.Count(), placeholderPixelSizeMapSet.Count(), TEST_LOCATION);
3426   DALI_TEST_EQUALS(DaliTestCheckMaps(placeholderPixelSizeMapGet, placeholderPixelSizeMapSet), true, TEST_LOCATION);
3427
3428   // Check the placeholder property with point size
3429   Property::Map placeholderMapSet;
3430   Property::Map placeholderMapGet;
3431   placeholderMapSet[Text::PlaceHolder::Property::TEXT]         = "Setting Placeholder Text";
3432   placeholderMapSet[Text::PlaceHolder::Property::TEXT_FOCUSED] = "Setting Placeholder Text Focused";
3433   placeholderMapSet[Text::PlaceHolder::Property::COLOR]        = Color::RED;
3434   placeholderMapSet[Text::PlaceHolder::Property::FONT_FAMILY]  = "Arial";
3435   placeholderMapSet[Text::PlaceHolder::Property::POINT_SIZE]   = 12.0f;
3436   placeholderMapSet[Text::PlaceHolder::Property::ELLIPSIS]     = false;
3437
3438   // Check the placeholder font style property
3439   placeholderFontstyleMap.Clear();
3440
3441   placeholderFontstyleMap.Insert("weight", "bold");
3442   placeholderFontstyleMap.Insert("width", "condensed");
3443   placeholderFontstyleMap.Insert("slant", "italic");
3444   placeholderMapSet[Text::PlaceHolder::Property::FONT_STYLE] = placeholderFontstyleMap;
3445   field.SetProperty(TextField::Property::PLACEHOLDER, placeholderMapSet);
3446
3447   placeholderMapGet = field.GetProperty<Property::Map>(TextField::Property::PLACEHOLDER);
3448   DALI_TEST_EQUALS(placeholderMapGet.Count(), placeholderMapSet.Count(), TEST_LOCATION);
3449   DALI_TEST_EQUALS(DaliTestCheckMaps(placeholderMapGet, placeholderMapSet), true, TEST_LOCATION);
3450
3451   // Reset font style.
3452   placeholderFontstyleMap.Clear();
3453   placeholderFontstyleMap.Insert("weight", "normal");
3454   placeholderFontstyleMap.Insert("slant", "oblique");
3455   placeholderMapSet[Text::PlaceHolder::Property::FONT_STYLE] = placeholderFontstyleMap;
3456   field.SetProperty(TextField::Property::PLACEHOLDER, placeholderMapSet);
3457
3458   placeholderMapGet = field.GetProperty<Property::Map>(TextField::Property::PLACEHOLDER);
3459   DALI_TEST_EQUALS(placeholderMapGet.Count(), placeholderMapSet.Count(), TEST_LOCATION);
3460   DALI_TEST_EQUALS(DaliTestCheckMaps(placeholderMapGet, placeholderMapSet), true, TEST_LOCATION);
3461
3462   placeholderFontstyleMap.Clear();
3463   placeholderFontstyleMap.Insert("slant", "roman");
3464   placeholderMapSet[Text::PlaceHolder::Property::FONT_STYLE] = placeholderFontstyleMap;
3465   field.SetProperty(TextField::Property::PLACEHOLDER, placeholderMapSet);
3466
3467   placeholderMapGet = field.GetProperty<Property::Map>(TextField::Property::PLACEHOLDER);
3468
3469   placeholderFontstyleMap.Clear();
3470   placeholderMapSet[Text::PlaceHolder::Property::FONT_STYLE] = placeholderFontstyleMap;
3471
3472   field.SetProperty(TextField::Property::PLACEHOLDER, placeholderMapSet);
3473   placeholderMapGet = field.GetProperty<Property::Map>(TextField::Property::PLACEHOLDER);
3474   DALI_TEST_EQUALS(placeholderMapGet.Count(), placeholderMapSet.Count(), TEST_LOCATION);
3475   DALI_TEST_EQUALS(DaliTestCheckMaps(placeholderMapGet, placeholderMapSet), true, TEST_LOCATION);
3476
3477   END_TEST;
3478 }
3479
3480 int UtcDaliTextFieldPlaceholderCoverage(void)
3481 {
3482   ToolkitTestApplication application;
3483   tet_infoline("UtcDaliTextFieldPlaceholderCoverage");
3484
3485   // mPlaceholderFont is created only once, so create a new control for coverage.
3486   TextField fieldForCoverage = TextField::New();
3487   DALI_TEST_CHECK(fieldForCoverage);
3488   application.GetScene().Add(fieldForCoverage);
3489
3490   // for SetPlaceholderFontFamily() coverage.
3491   Property::Map fontFamilyMap;
3492   fontFamilyMap[Text::PlaceHolder::Property::FONT_FAMILY] = "Arial";
3493   fieldForCoverage.SetProperty(TextField::Property::PLACEHOLDER, fontFamilyMap);
3494
3495   // mPlaceholderFont is created only once, so create a new control for coverage.
3496   fieldForCoverage = TextField::New();
3497   DALI_TEST_CHECK(fieldForCoverage);
3498   application.GetScene().Add(fieldForCoverage);
3499
3500   // for SetPlaceholderTextFontSize coverage.
3501   Property::Map fontSizeMap;
3502   fontSizeMap[Text::PlaceHolder::Property::PIXEL_SIZE] = 15.0f;
3503   fieldForCoverage.SetProperty(TextField::Property::PLACEHOLDER, fontSizeMap);
3504
3505   // mPlaceholderFont is created only once, so create a new control for coverage.
3506   fieldForCoverage = TextField::New();
3507   DALI_TEST_CHECK(fieldForCoverage);
3508   application.GetScene().Add(fieldForCoverage);
3509
3510   // for SetPlaceholderTextFontWeight coverage.
3511   Property::Map fontStyleWeightMap;
3512   Property::Map fontStyleWeightPropertyMap;
3513   fontStyleWeightPropertyMap.Insert("weight", "bold");
3514   fontStyleWeightMap[Text::PlaceHolder::Property::FONT_STYLE] = fontStyleWeightPropertyMap;
3515   fieldForCoverage.SetProperty(TextField::Property::PLACEHOLDER, fontStyleWeightMap);
3516
3517   // mPlaceholderFont is created only once, so create a new control for coverage.
3518   fieldForCoverage = TextField::New();
3519   DALI_TEST_CHECK(fieldForCoverage);
3520   application.GetScene().Add(fieldForCoverage);
3521
3522   // for SetPlaceholderTextFontWidth coverage.
3523   Property::Map fontStyleWidthMap;
3524   Property::Map fontStyleWidthPropertyMap;
3525   fontStyleWidthPropertyMap.Insert("width", "expanded");
3526   fontStyleWidthMap[Text::PlaceHolder::Property::FONT_STYLE] = fontStyleWidthPropertyMap;
3527   fieldForCoverage.SetProperty(TextField::Property::PLACEHOLDER, fontStyleWidthMap);
3528
3529   // mPlaceholderFont is created only once, so create a new control for coverage.
3530   fieldForCoverage = TextField::New();
3531   DALI_TEST_CHECK(fieldForCoverage);
3532   application.GetScene().Add(fieldForCoverage);
3533
3534   // for SetPlaceholderTextFontSlant coverage.
3535   Property::Map fontStyleSlantMap;
3536   Property::Map fontStyleSlantPropertyMap;
3537   fontStyleSlantPropertyMap.Insert("slant", "italic");
3538   fontStyleSlantMap[Text::PlaceHolder::Property::FONT_STYLE] = fontStyleSlantPropertyMap;
3539   fieldForCoverage.SetProperty(TextField::Property::PLACEHOLDER, fontStyleSlantMap);
3540
3541   END_TEST;
3542 }
3543
3544 int UtcDaliTextFieldSetPaddingProperty(void)
3545 {
3546   ToolkitTestApplication application;
3547   tet_infoline("UtcDaliTextFieldSetPaddingProperty\n");
3548
3549   TextField field = TextField::New();
3550   DALI_TEST_CHECK(field);
3551   field.SetProperty(Actor::Property::SIZE, Vector2(300.f, 50.f));
3552   field.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT);
3553   field.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
3554   application.GetScene().Add(field);
3555
3556   application.SendNotification();
3557   application.Render();
3558
3559   Vector3 originalSize = field.GetNaturalSize();
3560
3561   field.SetProperty(Toolkit::Control::Property::PADDING, Extents(10, 10, 10, 10));
3562
3563   application.SendNotification();
3564   application.Render();
3565
3566   DALI_TEST_EQUALS(field.GetProperty<Extents>(Toolkit::Control::Property::PADDING), Extents(10, 10, 10, 10), TEST_LOCATION);
3567
3568   Vector3 paddingAddedSize = field.GetNaturalSize();
3569
3570   DALI_TEST_EQUALS(originalSize.width + 10 + 10, paddingAddedSize.width, Math::MACHINE_EPSILON_1000, TEST_LOCATION);
3571
3572   DALI_TEST_EQUALS(originalSize.height + 10 + 10, paddingAddedSize.height, Math::MACHINE_EPSILON_1000, TEST_LOCATION);
3573
3574   END_TEST;
3575 }
3576
3577 int UtcDaliTextFieldEnableShiftSelectionProperty(void)
3578 {
3579   ToolkitTestApplication application;
3580   tet_infoline("UtcDaliTextFieldEnableShiftSelectionProperty");
3581
3582   TextField field = TextField::New();
3583   DALI_TEST_CHECK(field);
3584   field.SetProperty(Actor::Property::SIZE, Vector2(300.f, 50.f));
3585   field.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT);
3586   field.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
3587   application.GetScene().Add(field);
3588
3589   application.SendNotification();
3590   application.Render();
3591
3592   // The default value of ENABLE_SHIFT_SELECTION is 'true'.
3593   DALI_TEST_EQUALS(field.GetProperty<bool>(DevelTextField::Property::ENABLE_SHIFT_SELECTION), true, TEST_LOCATION);
3594
3595   // Check the enable shift selection property
3596   field.SetProperty(DevelTextField::Property::ENABLE_SHIFT_SELECTION, false);
3597   DALI_TEST_EQUALS(field.GetProperty<bool>(DevelTextField::Property::ENABLE_SHIFT_SELECTION), false, TEST_LOCATION);
3598
3599   application.SendNotification();
3600   application.Render();
3601
3602   END_TEST;
3603 }
3604
3605 int UtcDaliTextFieldEnableGrabHandleProperty(void)
3606 {
3607   ToolkitTestApplication application;
3608   tet_infoline("UtcDaliTextFieldEnableGrabHandleProperty");
3609
3610   TextField field = TextField::New();
3611   DALI_TEST_CHECK(field);
3612   field.SetProperty(Actor::Property::SIZE, Vector2(300.f, 50.f));
3613   field.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT);
3614   field.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
3615   application.GetScene().Add(field);
3616
3617   application.SendNotification();
3618   application.Render();
3619
3620   // The default value of ENABLE_GRAB_HANDLE is 'true'.
3621   DALI_TEST_EQUALS(field.GetProperty<bool>(DevelTextField::Property::ENABLE_GRAB_HANDLE), true, TEST_LOCATION);
3622
3623   // Check the enable grab handle property
3624   field.SetProperty(DevelTextField::Property::ENABLE_GRAB_HANDLE, false);
3625   DALI_TEST_EQUALS(field.GetProperty<bool>(DevelTextField::Property::ENABLE_GRAB_HANDLE), false, TEST_LOCATION);
3626
3627   application.SendNotification();
3628   application.Render();
3629
3630   END_TEST;
3631 }
3632
3633 int UtcDaliTextFieldMatchSystemLanguageDirectionProperty(void)
3634 {
3635   ToolkitTestApplication application;
3636   tet_infoline("UtcDaliTextFieldMatchSystemLanguageDirectionProperty");
3637
3638   TextField field = TextField::New();
3639   DALI_TEST_CHECK(field);
3640   field.SetProperty(Actor::Property::SIZE, Vector2(300.f, 50.f));
3641   field.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT);
3642   field.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
3643   application.GetScene().Add(field);
3644
3645   application.SendNotification();
3646   application.Render();
3647
3648   // The default value of MATCH_SYSTEM_LANGUAGE_DIRECTION is 'true'.
3649   DALI_TEST_EQUALS(field.GetProperty<bool>(DevelTextField::Property::MATCH_SYSTEM_LANGUAGE_DIRECTION), true, TEST_LOCATION);
3650
3651   // Check the match system language direction property
3652   field.SetProperty(DevelTextField::Property::MATCH_SYSTEM_LANGUAGE_DIRECTION, false);
3653   DALI_TEST_EQUALS(field.GetProperty<bool>(DevelTextField::Property::MATCH_SYSTEM_LANGUAGE_DIRECTION), false, TEST_LOCATION);
3654
3655   application.SendNotification();
3656   application.Render();
3657
3658   END_TEST;
3659 }
3660
3661 int utcDaliTextFieldLayoutDirectionCoverage(void)
3662 {
3663   ToolkitTestApplication application;
3664   tet_infoline(" utcDaliTextFieldLayoutDirectionCoverage");
3665
3666   // Creates a tap event. After creating a tap event the text field should
3667   // have the focus and add text with key events should be possible.
3668   TextField field = TextField::New();
3669   DALI_TEST_CHECK(field);
3670
3671   application.GetScene().Add(field);
3672
3673   field.SetProperty(Actor::Property::SIZE, Vector2(300.f, 50.f));
3674   field.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT);
3675   field.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
3676
3677   // Avoid a crash when core load gl resources.
3678   application.GetGlAbstraction().SetCheckFramebufferStatusResult(GL_FRAMEBUFFER_COMPLETE);
3679
3680   // Render and notify
3681   application.SendNotification();
3682   application.Render();
3683
3684   // init direction for coverage
3685   // Set horizontal alignment END
3686   field.SetProperty(TextField::Property::HORIZONTAL_ALIGNMENT, "END");
3687
3688   // Create a tap event to touch the text field.
3689   TestGenerateTap(application, 150.0f, 25.0f);
3690
3691   // Render and notify
3692   application.SendNotification();
3693   application.Render();
3694
3695   // Set MATCH_SYSTEM_LANGUAGE_DIRECTION to true to use the layout direction.
3696   field.SetProperty(DevelTextField::Property::MATCH_SYSTEM_LANGUAGE_DIRECTION, true);
3697   field.SetProperty(Actor::Property::LAYOUT_DIRECTION, LayoutDirection::RIGHT_TO_LEFT);
3698
3699   // Set horizontal alignment BEGIN
3700   field.SetProperty(TextField::Property::HORIZONTAL_ALIGNMENT, "BEGIN");
3701
3702   // Create a tap event to touch the text field.
3703   TestGenerateTap(application, 150.0f, 25.0f);
3704
3705   // Render and notify
3706   application.SendNotification();
3707   application.Render();
3708
3709   // Set horizontal alignment CENTER
3710   field.SetProperty(TextField::Property::HORIZONTAL_ALIGNMENT, "CENTER");
3711
3712   // Create a tap event to touch the text field.
3713   TestGenerateTap(application, 150.0f, 25.0f);
3714
3715   // Render and notify
3716   application.SendNotification();
3717   application.Render();
3718
3719   // Set horizontal alignment END
3720   field.SetProperty(TextField::Property::HORIZONTAL_ALIGNMENT, "END");
3721
3722   // Create a tap event to touch the text field.
3723   TestGenerateTap(application, 150.0f, 25.0f);
3724
3725   // Render and notify
3726   application.SendNotification();
3727   application.Render();
3728
3729   // Generate a Esc key event. The text field should lose the focus.
3730   application.ProcessEvent(GenerateKey("", "", "", DALI_KEY_ESCAPE, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
3731   application.ProcessEvent(GenerateKey("", "", "", DALI_KEY_ESCAPE, 0, 0, Integration::KeyEvent::UP, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
3732
3733   // Render and notify
3734   application.SendNotification();
3735   application.Render();
3736
3737   DALI_TEST_EQUALS(false, field.HasKeyInputFocus(), TEST_LOCATION);
3738
3739   END_TEST;
3740 }
3741
3742 int UtcDaliTextFieldGetInputMethodContext(void)
3743 {
3744   ToolkitTestApplication application;
3745   tet_infoline("UtcDaliTextFieldGetInputMethodContext");
3746
3747   TextField field = TextField::New();
3748   DALI_TEST_CHECK(DevelTextField::GetInputMethodContext(field));
3749
3750   END_TEST;
3751 }
3752
3753 int UtcDaliTextFieldSelectWholeText(void)
3754 {
3755   ToolkitTestApplication application;
3756   tet_infoline(" UtcDaliTextFieldSelectWholeText ");
3757
3758   TextField textField = TextField::New();
3759
3760   application.GetScene().Add(textField);
3761
3762   textField.SetProperty(Actor::Property::SIZE, Vector2(300.f, 50.f));
3763   textField.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT);
3764   textField.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
3765
3766   // Avoid a crash when core load gl resources.
3767   application.GetGlAbstraction().SetCheckFramebufferStatusResult(GL_FRAMEBUFFER_COMPLETE);
3768
3769   application.SendNotification();
3770   application.Render();
3771
3772   DALI_TEST_EQUALS(1u, textField.GetChildCount(), TEST_LOCATION);
3773
3774   DevelTextField::SelectWholeText(textField);
3775
3776   application.SendNotification();
3777   application.Render();
3778
3779   // Nothing should have been selected. The number of children is still 1
3780   DALI_TEST_EQUALS(1u, textField.GetChildCount(), TEST_LOCATION);
3781
3782   textField.SetProperty(TextField::Property::TEXT, "Hello world");
3783
3784   application.SendNotification();
3785   application.Render();
3786
3787   DevelTextField::SelectWholeText(textField);
3788
3789   application.SendNotification();
3790   application.Render();
3791
3792   // Even if resize, selection should remain.
3793   textField.SetProperty(Actor::Property::SIZE, Vector2(150.f, 50.f));
3794
3795   application.SendNotification();
3796   application.Render();
3797
3798   // Should be 2 children, the stencil and the layer
3799   DALI_TEST_EQUALS(2u, textField.GetChildCount(), TEST_LOCATION);
3800
3801   // The offscreen root actor should have two actors: the renderer and the highlight actor.
3802   Actor stencil = textField.GetChildAt(0u);
3803
3804   // The highlight actor is drawn first, so is the first actor in the list
3805   Renderer highlight = stencil.GetChildAt(0u).GetRendererAt(0u);
3806   DALI_TEST_CHECK(highlight);
3807
3808   END_TEST;
3809 }
3810
3811 int UtcDaliTextFieldSelectText(void)
3812 {
3813   ToolkitTestApplication application;
3814   tet_infoline(" UtcDaliTextFieldSelectText ");
3815
3816   TextField textField = TextField::New();
3817
3818   application.GetScene().Add(textField);
3819
3820   textField.SetProperty(Actor::Property::SIZE, Vector2(300.f, 50.f));
3821   textField.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT);
3822   textField.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
3823
3824   // Avoid a crash when core load gl resources.
3825   application.GetGlAbstraction().SetCheckFramebufferStatusResult(GL_FRAMEBUFFER_COMPLETE);
3826
3827   application.SendNotification();
3828   application.Render();
3829
3830   DevelTextField::SelectText(textField, 0, 5);
3831
3832   application.SendNotification();
3833   application.Render();
3834
3835   // Nothing is selected
3836   std::string selectedText = textField.GetProperty(DevelTextField::Property::SELECTED_TEXT).Get<std::string>();
3837   DALI_TEST_EQUALS("", selectedText, TEST_LOCATION);
3838
3839   textField.SetProperty(TextField::Property::TEXT, "Hello world");
3840
3841   application.SendNotification();
3842   application.Render();
3843
3844   // Hello is selected
3845   DevelTextField::SelectText(textField, 0, 5);
3846
3847   application.SendNotification();
3848   application.Render();
3849
3850   selectedText = textField.GetProperty(DevelTextField::Property::SELECTED_TEXT).Get<std::string>();
3851   DALI_TEST_EQUALS("Hello", selectedText, TEST_LOCATION);
3852
3853   DALI_TEST_EQUALS(textField.GetProperty(DevelTextField::Property::SELECTED_TEXT_START).Get<int>(), 0, TEST_LOCATION);
3854   DALI_TEST_EQUALS(textField.GetProperty(DevelTextField::Property::SELECTED_TEXT_END).Get<int>(), 5, TEST_LOCATION);
3855
3856   // world is selected
3857   DevelTextField::SelectText(textField, 6, 11);
3858
3859   application.SendNotification();
3860   application.Render();
3861
3862   selectedText = textField.GetProperty(DevelTextField::Property::SELECTED_TEXT).Get<std::string>();
3863   DALI_TEST_EQUALS("world", selectedText, TEST_LOCATION);
3864
3865   DALI_TEST_EQUALS(textField.GetProperty(DevelTextField::Property::SELECTED_TEXT_START).Get<int>(), 6, TEST_LOCATION);
3866   DALI_TEST_EQUALS(textField.GetProperty(DevelTextField::Property::SELECTED_TEXT_END).Get<int>(), 11, TEST_LOCATION);
3867
3868   END_TEST;
3869 }
3870
3871 int UtcDaliTextFieldSelectNone(void)
3872 {
3873   ToolkitTestApplication application;
3874   tet_infoline(" UtcDaliTextFieldSelectWholeText ");
3875
3876   TextField textField = TextField::New();
3877
3878   application.GetScene().Add(textField);
3879
3880   textField.SetProperty(Actor::Property::SIZE, Vector2(300.f, 50.f));
3881   textField.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT);
3882   textField.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
3883
3884   // Avoid a crash when core load gl resources.
3885   application.GetGlAbstraction().SetCheckFramebufferStatusResult(GL_FRAMEBUFFER_COMPLETE);
3886
3887   application.SendNotification();
3888   application.Render();
3889
3890   textField.SetProperty(TextField::Property::TEXT, "Hello world");
3891
3892   application.SendNotification();
3893   application.Render();
3894
3895   // Nothing is selected
3896   std::string selectedText = textField.GetProperty(DevelTextField::Property::SELECTED_TEXT).Get<std::string>();
3897   DALI_TEST_EQUALS("", selectedText, TEST_LOCATION);
3898
3899   DevelTextField::SelectWholeText(textField);
3900
3901   application.SendNotification();
3902   application.Render();
3903
3904   // whole text is selected
3905   selectedText = textField.GetProperty(DevelTextField::Property::SELECTED_TEXT).Get<std::string>();
3906   DALI_TEST_EQUALS("Hello world", selectedText, TEST_LOCATION);
3907
3908   DevelTextField::SelectNone(textField);
3909
3910   application.SendNotification();
3911   application.Render();
3912
3913   // Nothing is selected
3914   selectedText = textField.GetProperty(DevelTextField::Property::SELECTED_TEXT).Get<std::string>();
3915   DALI_TEST_EQUALS("", selectedText, TEST_LOCATION);
3916
3917   END_TEST;
3918 }
3919
3920 int UtcDaliTextFieldSelectRange(void)
3921 {
3922   ToolkitTestApplication application;
3923   tet_infoline(" UtcDaliTextFieldSelectRange ");
3924
3925   TextField textField = TextField::New();
3926
3927   application.GetScene().Add(textField);
3928
3929   textField.SetProperty(Actor::Property::SIZE, Vector2(300.f, 50.f));
3930   textField.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT);
3931   textField.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
3932
3933   // Avoid a crash when core load gl resources.
3934   application.GetGlAbstraction().SetCheckFramebufferStatusResult(GL_FRAMEBUFFER_COMPLETE);
3935
3936   application.SendNotification();
3937   application.Render();
3938
3939   textField.SetProperty(TextField::Property::TEXT, "Hello world");
3940
3941   application.SendNotification();
3942   application.Render();
3943
3944   textField.SetProperty(DevelTextField::Property::SELECTED_TEXT_START, 0);
3945   textField.SetProperty(DevelTextField::Property::SELECTED_TEXT_END, 5);
3946
3947   // Hello is selected
3948   std::string selectedText = textField.GetProperty(DevelTextField::Property::SELECTED_TEXT).Get<std::string>();
3949   DALI_TEST_EQUALS("Hello", selectedText, TEST_LOCATION);
3950
3951   DALI_TEST_EQUALS(textField.GetProperty(DevelTextField::Property::SELECTED_TEXT_START).Get<int>(), 0, TEST_LOCATION);
3952   DALI_TEST_EQUALS(textField.GetProperty(DevelTextField::Property::SELECTED_TEXT_END).Get<int>(), 5, TEST_LOCATION);
3953
3954   textField.SetProperty(DevelTextField::Property::SELECTED_TEXT_START, 6);
3955   textField.SetProperty(DevelTextField::Property::SELECTED_TEXT_END, 11);
3956
3957   // world is selected
3958   selectedText = textField.GetProperty(DevelTextField::Property::SELECTED_TEXT).Get<std::string>();
3959   DALI_TEST_EQUALS("world", selectedText, TEST_LOCATION);
3960
3961   DALI_TEST_EQUALS(textField.GetProperty(DevelTextField::Property::SELECTED_TEXT_START).Get<int>(), 6, TEST_LOCATION);
3962   DALI_TEST_EQUALS(textField.GetProperty(DevelTextField::Property::SELECTED_TEXT_END).Get<int>(), 11, TEST_LOCATION);
3963
3964   END_TEST;
3965 }
3966
3967 int UtcDaliTextFieldEnableEditing(void)
3968 {
3969   ToolkitTestApplication application;
3970   tet_infoline(" UtcDaliTextFieldEnableEditing ");
3971
3972   TextField textField = TextField::New();
3973
3974   application.GetScene().Add(textField);
3975
3976   textField.SetProperty(Actor::Property::SIZE, Vector2(300.f, 50.f));
3977   textField.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT);
3978   textField.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
3979
3980   // Avoid a crash when core load gl resources.
3981   application.GetGlAbstraction().SetCheckFramebufferStatusResult(GL_FRAMEBUFFER_COMPLETE);
3982
3983   application.SendNotification();
3984   application.Render();
3985
3986   textField.SetProperty(DevelActor::Property::USER_INTERACTION_ENABLED, true);
3987   DALI_TEST_EQUALS(textField.GetProperty(DevelActor::Property::USER_INTERACTION_ENABLED).Get<bool>(), true, TEST_LOCATION);
3988
3989   textField.SetKeyInputFocus();
3990   textField.SetProperty(DevelTextField::Property::ENABLE_EDITING, false);
3991   application.ProcessEvent(GenerateKey("D", "", "D", KEY_D_CODE, 0, 0, Integration::KeyEvent::DOWN, "D", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
3992
3993   // Render and notify
3994   application.SendNotification();
3995   application.Render();
3996
3997   DALI_TEST_EQUALS(textField.GetProperty(TextField::Property::TEXT).Get<std::string>(), "", TEST_LOCATION);
3998   DALI_TEST_EQUALS(textField.GetProperty(DevelTextField::Property::ENABLE_EDITING).Get<bool>(), false, TEST_LOCATION);
3999
4000   textField.SetKeyInputFocus();
4001   textField.SetProperty(DevelTextField::Property::ENABLE_EDITING, true);
4002   application.ProcessEvent(GenerateKey("D", "", "D", KEY_D_CODE, 0, 0, Integration::KeyEvent::DOWN, "D", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
4003
4004   // Render and notify
4005   application.SendNotification();
4006   application.Render();
4007
4008   DALI_TEST_EQUALS(textField.GetProperty(TextField::Property::TEXT).Get<std::string>(), "D", TEST_LOCATION);
4009   DALI_TEST_EQUALS(textField.GetProperty(DevelTextField::Property::ENABLE_EDITING).Get<bool>(), true, TEST_LOCATION);
4010
4011   // Check the user interaction enabled and for coverage
4012   DevelTextField::SelectWholeText(textField);
4013
4014   // Render and notify
4015   application.SendNotification();
4016   application.Render();
4017
4018   textField.SetKeyInputFocus();
4019   textField.SetProperty(DevelActor::Property::USER_INTERACTION_ENABLED, false);
4020   application.ProcessEvent(GenerateKey("D", "", "D", KEY_D_CODE, 0, 0, Integration::KeyEvent::DOWN, "D", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
4021
4022   // Render and notify
4023   application.SendNotification();
4024   application.Render();
4025
4026   DALI_TEST_EQUALS(textField.GetProperty(TextField::Property::TEXT).Get<std::string>(), "D", TEST_LOCATION);
4027   DALI_TEST_EQUALS(textField.GetProperty(DevelActor::Property::USER_INTERACTION_ENABLED).Get<bool>(), false, TEST_LOCATION);
4028
4029   END_TEST;
4030 }
4031
4032 int UtcDaliToolkitTextFieldFontSizeScale(void)
4033 {
4034   ToolkitTestApplication application;
4035   tet_infoline(" UtcDaliToolkitTextFieldFontSizeScale");
4036
4037   TextField textField = TextField::New();
4038   textField.SetProperty(TextField::Property::POINT_SIZE, 30.f);
4039   textField.SetProperty(TextField::Property::TEXT, "Test");
4040   Vector3 nonScaledSize = textField.GetNaturalSize();
4041
4042   TextField textFieldScaled = TextField::New();
4043   textFieldScaled.SetProperty(TextField::Property::POINT_SIZE, 15.f);
4044   textFieldScaled.SetProperty(Toolkit::DevelTextField::Property::FONT_SIZE_SCALE, 2.f);
4045   textFieldScaled.SetProperty(TextField::Property::TEXT, "Test");
4046   Vector3 scaledSize = textFieldScaled.GetNaturalSize();
4047
4048   DALI_TEST_EQUALS(nonScaledSize, scaledSize, TEST_LOCATION);
4049
4050   textField.SetProperty(TextField::Property::PIXEL_SIZE, 30.f);
4051   textField.SetProperty(TextField::Property::TEXT, "Test");
4052   nonScaledSize = textField.GetNaturalSize();
4053
4054   textFieldScaled.SetProperty(TextField::Property::PIXEL_SIZE, 15.f);
4055   textFieldScaled.SetProperty(Toolkit::DevelTextField::Property::FONT_SIZE_SCALE, 2.f);
4056   textFieldScaled.SetProperty(TextField::Property::TEXT, "Test");
4057   scaledSize = textFieldScaled.GetNaturalSize();
4058
4059   DALI_TEST_EQUALS(nonScaledSize, scaledSize, TEST_LOCATION);
4060
4061   END_TEST;
4062 }
4063
4064 int UtcDaliTextFieldPrimaryCursorPosition(void)
4065 {
4066   ToolkitTestApplication application;
4067   tet_infoline(" UtcDaliTextFieldPrimaryCursorPosition ");
4068
4069   TextField textField = TextField::New();
4070
4071   application.GetScene().Add(textField);
4072
4073   textField.SetProperty(TextField::Property::TEXT, "ABCEF");
4074   textField.SetProperty(Actor::Property::SIZE, Vector2(300.f, 50.f));
4075   textField.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT);
4076   textField.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
4077
4078   // Avoid a crash when core load gl resources.
4079   application.GetGlAbstraction().SetCheckFramebufferStatusResult(GL_FRAMEBUFFER_COMPLETE);
4080
4081   textField.SetProperty(DevelTextField::Property::PRIMARY_CURSOR_POSITION, 3);
4082   application.SendNotification();
4083   application.Render();
4084   textField.SetKeyInputFocus();
4085
4086   application.ProcessEvent(GenerateKey("D", "", "D", KEY_D_CODE, 0, 0, Integration::KeyEvent::DOWN, "D", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
4087
4088   // Render and notify
4089   application.SendNotification();
4090   application.Render();
4091
4092   DALI_TEST_EQUALS(textField.GetProperty(TextField::Property::TEXT).Get<std::string>(), "ABCDEF", TEST_LOCATION);
4093   DALI_TEST_EQUALS(textField.GetProperty(DevelTextField::Property::PRIMARY_CURSOR_POSITION).Get<int>(), 4, TEST_LOCATION);
4094
4095   END_TEST;
4096 }
4097
4098 // test max length when set after setting long text
4099 int utcDaliTextFieldMaxCharactersReachedAfterSetText(void)
4100 {
4101   ToolkitTestApplication application;
4102   tet_infoline(" utcDaliTextFieldMaxCharactersReachedAfterSetText");
4103   TextField field = TextField::New();
4104   DALI_TEST_CHECK(field);
4105
4106   application.GetScene().Add(field);
4107
4108   field.SetProperty(TextField::Property::TEXT, "123456789");
4109
4110   const int maxNumberOfCharacters = 3;
4111   field.SetProperty(TextField::Property::MAX_LENGTH, maxNumberOfCharacters);
4112
4113   field.SetKeyInputFocus();
4114
4115   // connect to the text max lengh reached signal.
4116   ConnectionTracker* testTracker            = new ConnectionTracker();
4117   bool               maxLengthReachedSignal = false;
4118   field.ConnectSignal(testTracker, "maxLengthReached", CallbackFunctor(&maxLengthReachedSignal));
4119
4120   application.ProcessEvent(GenerateKey("a", "", "a", KEY_A_CODE, 0, 0, Integration::KeyEvent::DOWN, "a", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
4121   application.ProcessEvent(GenerateKey("a", "", "a", KEY_A_CODE, 0, 0, Integration::KeyEvent::DOWN, "a", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
4122
4123   DALI_TEST_CHECK(maxLengthReachedSignal);
4124
4125   DALI_TEST_EQUALS(field.GetProperty(TextField::Property::TEXT).Get<std::string>(), "123456789", TEST_LOCATION);
4126
4127   END_TEST;
4128 }
4129
4130 int UtcDaliTextFieldAtlasLimitationIsEnabledForLargeFontPointSize(void)
4131 {
4132   ToolkitTestApplication application;
4133   tet_infoline(" UtcDaliTextFieldAtlasLimitationIsEnabledForLargeFontPointSize ");
4134
4135   // +2: First one to handle the equal case. Second one to handle odd to even case of GetNaturalSize
4136   const uint32_t lessThanWidth  = TextAbstraction::FontClient::MAX_TEXT_ATLAS_WIDTH - TextAbstraction::FontClient::PADDING_TEXT_ATLAS_BLOCK + 2;
4137   const uint32_t lessThanHeight = TextAbstraction::FontClient::MAX_TEXT_ATLAS_HEIGHT - TextAbstraction::FontClient::PADDING_TEXT_ATLAS_BLOCK + 2;
4138
4139   // Create a text field
4140   TextField textField = TextField::New();
4141
4142   //Set size to avoid automatic eliding
4143   textField.SetProperty(Actor::Property::SIZE, Vector2(1025, 1025));
4144   //Set very large font-size using point-size
4145   textField.SetProperty(TextField::Property::POINT_SIZE, 1000);
4146   //Specify font-family
4147   textField.SetProperty(TextField::Property::FONT_FAMILY, "DejaVu Sans");
4148   //Set text to check if appear or not
4149   textField.SetProperty(TextField::Property::TEXT, "A");
4150
4151   application.GetScene().Add(textField);
4152
4153   application.SendNotification();
4154   application.Render();
4155   //Use GetNaturalSize to verify that size of block does not exceed Atlas size
4156   Vector3 naturalSize = textField.GetNaturalSize();
4157
4158   DALI_TEST_GREATER(lessThanWidth, static_cast<uint32_t>(naturalSize.width), TEST_LOCATION);
4159   DALI_TEST_GREATER(lessThanHeight, static_cast<uint32_t>(naturalSize.height), TEST_LOCATION);
4160
4161   END_TEST;
4162 }
4163
4164 int UtcDaliTextFieldAtlasLimitationIsEnabledPerformanceCases(void)
4165 {
4166   ToolkitTestApplication application;
4167   tet_infoline(" UtcDaliTextFieldAtlasLimitationIsEnabledPerformanceCases ");
4168
4169   // +2: First one to handle the equal case. Second one to handle odd to even case of GetNaturalSize
4170   const uint32_t lessThanWidth  = TextAbstraction::FontClient::MAX_TEXT_ATLAS_WIDTH - TextAbstraction::FontClient::PADDING_TEXT_ATLAS_BLOCK + 2;
4171   const uint32_t lessThanHeight = TextAbstraction::FontClient::MAX_TEXT_ATLAS_HEIGHT - TextAbstraction::FontClient::PADDING_TEXT_ATLAS_BLOCK + 2;
4172
4173   Vector3 naturalSize; //Use GetNaturalSize to verify that size of block does not exceed Atlas size
4174   // Create a text editor
4175   TextField textField = TextField::New();
4176
4177   //Set size to avoid automatic eliding
4178   textField.SetProperty(Actor::Property::SIZE, Vector2(1025, 1025));
4179   textField.SetProperty(TextField::Property::FONT_FAMILY, "DejaVu Sans");
4180   textField.SetProperty(TextField::Property::TEXT, "A");
4181
4182   const int numberOfCases             = 6;
4183   int       arrayCases[numberOfCases] = {323, 326, 330, 600, 1630, 2500};
4184
4185   for(int index = 0; index < numberOfCases; index++)
4186   {
4187     tet_printf(" UtcDaliTextFieldAtlasLimitationIsEnabledPerformanceCases point-size= %d \n", arrayCases[index]);
4188     textField.SetProperty(TextField::Property::POINT_SIZE, arrayCases[index]);
4189     application.GetScene().Add(textField);
4190     application.SendNotification();
4191     application.Render();
4192     naturalSize = textField.GetNaturalSize();
4193     DALI_TEST_GREATER(lessThanWidth, static_cast<uint32_t>(naturalSize.width), TEST_LOCATION);
4194     DALI_TEST_GREATER(lessThanHeight, static_cast<uint32_t>(naturalSize.height), TEST_LOCATION);
4195   }
4196
4197   END_TEST;
4198 }
4199
4200 int UtcDaliToolkitTextFieldEllipsisPositionProperty(void)
4201 {
4202   ToolkitTestApplication application;
4203   tet_infoline(" UtcDaliToolkitTextFieldEllipsisPositionProperty ");
4204   TextField textField = TextField::New();
4205
4206   tet_infoline(" UtcDaliToolkitTextFieldEllipsisPositionProperty - Default is END");
4207   DALI_TEST_EQUALS(textField.GetProperty<int>(DevelTextField::Property::ELLIPSIS_POSITION), static_cast<int>(Toolkit::DevelText::EllipsisPosition::END), TEST_LOCATION);
4208
4209   tet_infoline(" UtcDaliToolkitTextFieldEllipsisPositionProperty - Change to START");
4210   textField.SetProperty(DevelTextField::Property::ELLIPSIS_POSITION, DevelText::EllipsisPosition::START);
4211   DALI_TEST_EQUALS(textField.GetProperty<int>(DevelTextField::Property::ELLIPSIS_POSITION), static_cast<int>(Toolkit::DevelText::EllipsisPosition::START), TEST_LOCATION);
4212
4213   tet_infoline(" UtcDaliToolkitTextFieldEllipsisPositionProperty - Change to MIDDLE");
4214   textField.SetProperty(DevelTextField::Property::ELLIPSIS_POSITION, DevelText::EllipsisPosition::MIDDLE);
4215   DALI_TEST_EQUALS(textField.GetProperty<int>(DevelTextField::Property::ELLIPSIS_POSITION), static_cast<int>(Toolkit::DevelText::EllipsisPosition::MIDDLE), TEST_LOCATION);
4216
4217   tet_infoline(" UtcDaliToolkitTextFieldEllipsisPositionProperty - Change to END");
4218   textField.SetProperty(DevelTextField::Property::ELLIPSIS_POSITION, DevelText::EllipsisPosition::END);
4219   DALI_TEST_EQUALS(textField.GetProperty<int>(DevelTextField::Property::ELLIPSIS_POSITION), static_cast<int>(Toolkit::DevelText::EllipsisPosition::END), TEST_LOCATION);
4220
4221   tet_infoline(" UtcDaliToolkitTextFieldEllipsisPositionProperty - Change to START using integer");
4222   textField.SetProperty(DevelTextField::Property::ELLIPSIS_POSITION, 1);
4223   DALI_TEST_EQUALS(textField.GetProperty<int>(DevelTextField::Property::ELLIPSIS_POSITION), static_cast<int>(Toolkit::DevelText::EllipsisPosition::START), TEST_LOCATION);
4224
4225   tet_infoline(" UtcDaliToolkitTextFieldEllipsisPositionProperty - Change to MIDDLE using integer");
4226   textField.SetProperty(DevelTextField::Property::ELLIPSIS_POSITION, 2);
4227   DALI_TEST_EQUALS(textField.GetProperty<int>(DevelTextField::Property::ELLIPSIS_POSITION), static_cast<int>(Toolkit::DevelText::EllipsisPosition::MIDDLE), TEST_LOCATION);
4228
4229   tet_infoline(" UtcDaliToolkitTextFieldEllipsisPositionProperty - Change to END using integer");
4230   textField.SetProperty(DevelTextField::Property::ELLIPSIS_POSITION, 0);
4231   DALI_TEST_EQUALS(textField.GetProperty<int>(DevelTextField::Property::ELLIPSIS_POSITION), static_cast<int>(Toolkit::DevelText::EllipsisPosition::END), TEST_LOCATION);
4232
4233   tet_infoline(" UtcDaliToolkitTextlabelEllipsisPositionProperty - Change to START using string - uppercase");
4234   textField.SetProperty(DevelTextField::Property::ELLIPSIS_POSITION, "START");
4235   DALI_TEST_EQUALS(textField.GetProperty<int>(DevelTextField::Property::ELLIPSIS_POSITION), static_cast<int>(Toolkit::DevelText::EllipsisPosition::START), TEST_LOCATION);
4236
4237   tet_infoline(" UtcDaliToolkitTextlabelEllipsisPositionProperty - Change to MIDDLE using string - uppercase");
4238   textField.SetProperty(DevelTextField::Property::ELLIPSIS_POSITION, "MIDDLE");
4239   DALI_TEST_EQUALS(textField.GetProperty<int>(DevelTextField::Property::ELLIPSIS_POSITION), static_cast<int>(Toolkit::DevelText::EllipsisPosition::MIDDLE), TEST_LOCATION);
4240
4241   tet_infoline(" UtcDaliToolkitTextlabelEllipsisPositionProperty - Change to END using string - uppercase");
4242   textField.SetProperty(DevelTextField::Property::ELLIPSIS_POSITION, "END");
4243   DALI_TEST_EQUALS(textField.GetProperty<int>(DevelTextField::Property::ELLIPSIS_POSITION), static_cast<int>(Toolkit::DevelText::EllipsisPosition::END), TEST_LOCATION);
4244
4245   tet_infoline(" UtcDaliToolkitTextlabelEllipsisPositionProperty - Change to START using string - lowercase");
4246   textField.SetProperty(DevelTextField::Property::ELLIPSIS_POSITION, "start");
4247   DALI_TEST_EQUALS(textField.GetProperty<int>(DevelTextField::Property::ELLIPSIS_POSITION), static_cast<int>(Toolkit::DevelText::EllipsisPosition::START), TEST_LOCATION);
4248
4249   tet_infoline(" UtcDaliToolkitTextlabelEllipsisPositionProperty - Change to MIDDLE using string - lowercase");
4250   textField.SetProperty(DevelTextField::Property::ELLIPSIS_POSITION, "middle");
4251   DALI_TEST_EQUALS(textField.GetProperty<int>(DevelTextField::Property::ELLIPSIS_POSITION), static_cast<int>(Toolkit::DevelText::EllipsisPosition::MIDDLE), TEST_LOCATION);
4252
4253   tet_infoline(" UtcDaliToolkitTextlabelEllipsisPositionProperty - Change to END using string - lowercase");
4254   textField.SetProperty(DevelTextField::Property::ELLIPSIS_POSITION, "end");
4255   DALI_TEST_EQUALS(textField.GetProperty<int>(DevelTextField::Property::ELLIPSIS_POSITION), static_cast<int>(Toolkit::DevelText::EllipsisPosition::END), TEST_LOCATION);
4256
4257   END_TEST;
4258 }
4259
4260 int UtcDaliTextFieldCopyText(void)
4261 {
4262   ToolkitTestApplication application;
4263   tet_infoline(" UtcDaliTextFieldCopyText ");
4264
4265   TextField textField = TextField::New();
4266
4267   std::string selectedText = "";
4268   std::string copiedText   = "";
4269
4270   application.GetScene().Add(textField);
4271
4272   textField.SetProperty(Actor::Property::SIZE, Vector2(300.f, 50.f));
4273   textField.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT);
4274   textField.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
4275
4276   // Avoid a crash when core load gl resources.
4277   application.GetGlAbstraction().SetCheckFramebufferStatusResult(GL_FRAMEBUFFER_COMPLETE);
4278
4279   application.SendNotification();
4280   application.Render();
4281
4282   textField.SetProperty(TextField::Property::TEXT, "Hello world");
4283
4284   application.SendNotification();
4285   application.Render();
4286
4287   // Hello is selected
4288   DevelTextField::SelectText(textField, 0, 5);
4289
4290   application.SendNotification();
4291   application.Render();
4292
4293   selectedText = textField.GetProperty(DevelTextField::Property::SELECTED_TEXT).Get<std::string>();
4294   DALI_TEST_EQUALS("Hello", selectedText, TEST_LOCATION);
4295
4296   DALI_TEST_EQUALS(textField.GetProperty(DevelTextField::Property::SELECTED_TEXT_START).Get<int>(), 0, TEST_LOCATION);
4297   DALI_TEST_EQUALS(textField.GetProperty(DevelTextField::Property::SELECTED_TEXT_END).Get<int>(), 5, TEST_LOCATION);
4298
4299   // Hello is copied
4300   copiedText = DevelTextField::CopyText(textField);
4301   DALI_TEST_EQUALS("Hello", copiedText, TEST_LOCATION);
4302
4303   // world is selected
4304   DevelTextField::SelectText(textField, 6, 11);
4305
4306   application.SendNotification();
4307   application.Render();
4308
4309   selectedText = textField.GetProperty(DevelTextField::Property::SELECTED_TEXT).Get<std::string>();
4310   DALI_TEST_EQUALS("world", selectedText, TEST_LOCATION);
4311
4312   DALI_TEST_EQUALS(textField.GetProperty(DevelTextField::Property::SELECTED_TEXT_START).Get<int>(), 6, TEST_LOCATION);
4313   DALI_TEST_EQUALS(textField.GetProperty(DevelTextField::Property::SELECTED_TEXT_END).Get<int>(), 11, TEST_LOCATION);
4314
4315   // world is copied
4316   copiedText = DevelTextField::CopyText(textField);
4317   DALI_TEST_EQUALS("world", copiedText, TEST_LOCATION);
4318
4319   // "lo wo" is selected
4320   DevelTextField::SelectText(textField, 3, 8);
4321
4322   application.SendNotification();
4323   application.Render();
4324
4325   selectedText = textField.GetProperty(DevelTextField::Property::SELECTED_TEXT).Get<std::string>();
4326   DALI_TEST_EQUALS("lo wo", selectedText, TEST_LOCATION);
4327
4328   DALI_TEST_EQUALS(textField.GetProperty(DevelTextField::Property::SELECTED_TEXT_START).Get<int>(), 3, TEST_LOCATION);
4329   DALI_TEST_EQUALS(textField.GetProperty(DevelTextField::Property::SELECTED_TEXT_END).Get<int>(), 8, TEST_LOCATION);
4330
4331   // "lo wo" is copied
4332   copiedText = DevelTextField::CopyText(textField);
4333   DALI_TEST_EQUALS("lo wo", copiedText, TEST_LOCATION);
4334
4335   END_TEST;
4336 }
4337
4338 int UtcDaliTextFieldCutText(void)
4339 {
4340   ToolkitTestApplication application;
4341   tet_infoline(" UtcDaliTextFieldCutText ");
4342
4343   TextField textField = TextField::New();
4344
4345   std::string selectedText = "";
4346
4347   application.GetScene().Add(textField);
4348
4349   textField.SetProperty(Actor::Property::SIZE, Vector2(300.f, 50.f));
4350   textField.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT);
4351   textField.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
4352
4353   // Avoid a crash when core load gl resources.
4354   application.GetGlAbstraction().SetCheckFramebufferStatusResult(GL_FRAMEBUFFER_COMPLETE);
4355
4356   application.SendNotification();
4357   application.Render();
4358
4359   textField.SetProperty(TextField::Property::TEXT, "Hello world");
4360
4361   application.SendNotification();
4362   application.Render();
4363
4364   // Hello is selected
4365   DevelTextField::SelectText(textField, 0, 5);
4366
4367   application.SendNotification();
4368   application.Render();
4369
4370   selectedText = textField.GetProperty(DevelTextField::Property::SELECTED_TEXT).Get<std::string>();
4371   DALI_TEST_EQUALS("Hello", selectedText, TEST_LOCATION);
4372
4373   DALI_TEST_EQUALS(textField.GetProperty(DevelTextField::Property::SELECTED_TEXT_START).Get<int>(), 0, TEST_LOCATION);
4374   DALI_TEST_EQUALS(textField.GetProperty(DevelTextField::Property::SELECTED_TEXT_END).Get<int>(), 5, TEST_LOCATION);
4375
4376   // Hello is cut
4377   DALI_TEST_EQUALS("Hello", DevelTextField::CutText(textField), TEST_LOCATION);
4378
4379   DALI_TEST_EQUALS(textField.GetProperty(TextField::Property::TEXT).Get<std::string>(), " world", TEST_LOCATION);
4380
4381   // " w" is selected
4382   DevelTextField::SelectText(textField, 0, 2);
4383
4384   application.SendNotification();
4385   application.Render();
4386
4387   selectedText = textField.GetProperty(DevelTextField::Property::SELECTED_TEXT).Get<std::string>();
4388   DALI_TEST_EQUALS(" w", selectedText, TEST_LOCATION);
4389
4390   DALI_TEST_EQUALS(textField.GetProperty(DevelTextField::Property::SELECTED_TEXT_START).Get<int>(), 0, TEST_LOCATION);
4391   DALI_TEST_EQUALS(textField.GetProperty(DevelTextField::Property::SELECTED_TEXT_END).Get<int>(), 2, TEST_LOCATION);
4392
4393   // " w" is cut
4394   DALI_TEST_EQUALS(" w", DevelTextField::CutText(textField), TEST_LOCATION);
4395
4396   application.SendNotification();
4397   application.Render();
4398
4399   DALI_TEST_EQUALS(textField.GetProperty(TextField::Property::TEXT).Get<std::string>(), "orld", TEST_LOCATION);
4400
4401   // Test Cut from the middle
4402
4403   // "rl" is selected
4404   DevelTextField::SelectText(textField, 1, 3);
4405
4406   application.SendNotification();
4407   application.Render();
4408
4409   selectedText = textField.GetProperty(DevelTextField::Property::SELECTED_TEXT).Get<std::string>();
4410   DALI_TEST_EQUALS("rl", selectedText, TEST_LOCATION);
4411
4412   DALI_TEST_EQUALS(textField.GetProperty(DevelTextField::Property::SELECTED_TEXT_START).Get<int>(), 1, TEST_LOCATION);
4413   DALI_TEST_EQUALS(textField.GetProperty(DevelTextField::Property::SELECTED_TEXT_END).Get<int>(), 3, TEST_LOCATION);
4414
4415   // "rl" is cut
4416   DALI_TEST_EQUALS("rl", DevelTextField::CutText(textField), TEST_LOCATION);
4417
4418   application.SendNotification();
4419   application.Render();
4420
4421   DALI_TEST_EQUALS(textField.GetProperty(TextField::Property::TEXT).Get<std::string>(), "od", TEST_LOCATION);
4422
4423   // Test Cut from the end
4424
4425   // "d" is selected
4426   DevelTextField::SelectText(textField, 1, 2);
4427
4428   application.SendNotification();
4429   application.Render();
4430
4431   selectedText = textField.GetProperty(DevelTextField::Property::SELECTED_TEXT).Get<std::string>();
4432   DALI_TEST_EQUALS("d", selectedText, TEST_LOCATION);
4433
4434   DALI_TEST_EQUALS(textField.GetProperty(DevelTextField::Property::SELECTED_TEXT_START).Get<int>(), 1, TEST_LOCATION);
4435   DALI_TEST_EQUALS(textField.GetProperty(DevelTextField::Property::SELECTED_TEXT_END).Get<int>(), 2, TEST_LOCATION);
4436
4437   // "d" is cut
4438   DALI_TEST_EQUALS("d", DevelTextField::CutText(textField), TEST_LOCATION);
4439
4440   application.SendNotification();
4441   application.Render();
4442
4443   DALI_TEST_EQUALS(textField.GetProperty(TextField::Property::TEXT).Get<std::string>(), "o", TEST_LOCATION);
4444
4445   END_TEST;
4446 }
4447
4448 int UtcDaliTextFieldPasteText(void)
4449 {
4450   ToolkitTestApplication application;
4451   tet_infoline(" UtcDaliTextFieldPasteText ");
4452
4453   TextField textField = TextField::New();
4454
4455   application.GetScene().Add(textField);
4456
4457   std::string cutText    = "";
4458   std::string copiedText = "";
4459
4460   textField.SetProperty(Actor::Property::SIZE, Vector2(300.f, 50.f));
4461   textField.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT);
4462   textField.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
4463
4464   // Avoid a crash when core load gl resources.
4465   application.GetGlAbstraction().SetCheckFramebufferStatusResult(GL_FRAMEBUFFER_COMPLETE);
4466
4467   application.SendNotification();
4468   application.Render();
4469
4470   textField.SetProperty(TextField::Property::TEXT, "Hello World");
4471
4472   application.SendNotification();
4473   application.Render();
4474
4475   // Tap on the text editor
4476   TestGenerateTap(application, 3.0f, 25.0f);
4477
4478   // Render and notify
4479   application.SendNotification();
4480   application.Render();
4481
4482   // Select some text in the right of the current cursor position
4483   DevelTextField::SelectText(textField, 0, 3);
4484
4485   // Render and notify
4486   application.SendNotification();
4487   application.Render();
4488
4489   // Cut the selected text
4490   cutText = DevelTextField::CutText(textField);
4491
4492   // Render and notify
4493   application.SendNotification();
4494   application.Render();
4495
4496   DALI_TEST_EQUALS("Hel", cutText, TEST_LOCATION);
4497   DALI_TEST_EQUALS(textField.GetProperty(TextField::Property::TEXT).Get<std::string>(), "lo World", TEST_LOCATION);
4498
4499   DevelTextField::SelectText(textField, 0, 3);
4500
4501   // Render and notify
4502   application.SendNotification();
4503   application.Render();
4504
4505   // Copy the selected text
4506   copiedText = DevelTextField::CopyText(textField);
4507
4508   // Render and notify
4509   application.SendNotification();
4510   application.Render();
4511
4512   DALI_TEST_EQUALS("lo ", copiedText, TEST_LOCATION);
4513   DALI_TEST_EQUALS("lo World", textField.GetProperty<std::string>(TextField::Property::TEXT), TEST_LOCATION);
4514
4515   // Move the cursor to the end of the line
4516   application.ProcessEvent(GenerateKey("", "", "", DALI_KEY_CURSOR_RIGHT, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
4517   application.ProcessEvent(GenerateKey("", "", "", DALI_KEY_CURSOR_RIGHT, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
4518   application.ProcessEvent(GenerateKey("", "", "", DALI_KEY_CURSOR_RIGHT, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
4519   application.ProcessEvent(GenerateKey("", "", "", DALI_KEY_CURSOR_RIGHT, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
4520   application.ProcessEvent(GenerateKey("", "", "", DALI_KEY_CURSOR_RIGHT, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
4521   application.ProcessEvent(GenerateKey("", "", "", DALI_KEY_CURSOR_RIGHT, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
4522   application.ProcessEvent(GenerateKey("", "", "", DALI_KEY_CURSOR_RIGHT, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
4523   application.ProcessEvent(GenerateKey("", "", "", DALI_KEY_CURSOR_RIGHT, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
4524
4525   // Render and notify
4526   application.SendNotification();
4527   application.Render();
4528
4529   // Paste the selected text at the current cursor position
4530   DevelTextField::PasteText(textField);
4531
4532   // Render and notify
4533   application.SendNotification();
4534   application.Render();
4535
4536   DALI_TEST_EQUALS(textField.GetProperty(TextField::Property::TEXT).Get<std::string>(), "lo Worldlo ", TEST_LOCATION);
4537
4538   END_TEST;
4539 }
4540
4541 int utcDaliTextFieldCursorPositionChangedSignal(void)
4542 {
4543   ToolkitTestApplication application;
4544   tet_infoline(" utcDaliTextFieldCursorPositionChangedSignal");
4545
4546   TextField field = TextField::New();
4547   DALI_TEST_CHECK(field);
4548
4549   application.GetScene().Add(field);
4550
4551   // connect to the selection changed signal.
4552   ConnectionTracker* testTracker = new ConnectionTracker();
4553   DevelTextField::CursorPositionChangedSignal(field).Connect(&TestCursorPositionChangedCallback);
4554   bool cursorPositionChangedSignal = false;
4555   field.ConnectSignal(testTracker, "cursorPositionChanged", CallbackFunctor(&cursorPositionChangedSignal));
4556
4557   field.SetProperty(TextField::Property::TEXT, "Hello world Hello world");
4558   field.SetProperty(TextField::Property::POINT_SIZE, 10.f);
4559   field.SetProperty(Actor::Property::SIZE, Vector2(100.f, 50.f));
4560   field.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT);
4561   field.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
4562
4563   // Avoid a crash when core load gl resources.
4564   application.GetGlAbstraction().SetCheckFramebufferStatusResult(GL_FRAMEBUFFER_COMPLETE);
4565
4566   // Render and notify
4567   application.SendNotification();
4568   application.Render();
4569
4570   field.SetKeyInputFocus();
4571
4572   // Tap on the text field
4573   TestGenerateTap(application, 3.0f, 25.0f);
4574
4575   // Render and notify
4576   application.SendNotification();
4577   application.Render();
4578
4579   DALI_TEST_CHECK(gCursorPositionChangedCallbackCalled);
4580   DALI_TEST_EQUALS(oldCursorPos, 23, TEST_LOCATION);
4581
4582   gCursorPositionChangedCallbackCalled = false;
4583
4584   // Move to left.
4585   application.ProcessEvent(GenerateKey("", "", "", DALI_KEY_CURSOR_LEFT, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
4586
4587   // Render and notify
4588   application.SendNotification();
4589   application.Render();
4590
4591   DALI_TEST_CHECK(gCursorPositionChangedCallbackCalled);
4592   DALI_TEST_EQUALS(oldCursorPos, 17, TEST_LOCATION);
4593
4594   gCursorPositionChangedCallbackCalled = false;
4595
4596   // Insert D
4597   application.ProcessEvent(GenerateKey("D", "", "D", KEY_D_CODE, 0, 0, Integration::KeyEvent::DOWN, "D", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
4598
4599   // Render and notify
4600   application.SendNotification();
4601   application.Render();
4602
4603   DALI_TEST_CHECK(gCursorPositionChangedCallbackCalled);
4604   DALI_TEST_EQUALS(oldCursorPos, 16, TEST_LOCATION);
4605
4606   gCursorPositionChangedCallbackCalled = false;
4607
4608   //delete one character
4609   application.ProcessEvent(GenerateKey("", "", "", DALI_KEY_BACKSPACE, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
4610
4611   // Render and notify
4612   application.SendNotification();
4613   application.Render();
4614
4615   DALI_TEST_CHECK(gCursorPositionChangedCallbackCalled);
4616   DALI_TEST_EQUALS(oldCursorPos, 17, TEST_LOCATION);
4617
4618   gCursorPositionChangedCallbackCalled = false;
4619
4620   field.SetProperty(TextField::Property::TEXT, "Hello");
4621
4622   // Render and notify
4623   application.SendNotification();
4624   application.Render();
4625
4626   DALI_TEST_CHECK(gCursorPositionChangedCallbackCalled);
4627   DALI_TEST_EQUALS(oldCursorPos, 16, TEST_LOCATION);
4628
4629   gCursorPositionChangedCallbackCalled = false;
4630
4631   field.SetProperty(DevelTextField::Property::PRIMARY_CURSOR_POSITION, 3);
4632
4633   // Render and notify
4634   application.SendNotification();
4635   application.Render();
4636
4637   DALI_TEST_CHECK(gCursorPositionChangedCallbackCalled);
4638   DALI_TEST_EQUALS(oldCursorPos, 5, TEST_LOCATION);
4639
4640   END_TEST;
4641 }
4642
4643 int utcDaliTextFieldGeometryEllipsisStart(void)
4644 {
4645   ToolkitTestApplication application;
4646   tet_infoline(" utcDaliTextFieldGeometryEllipsisStart");
4647
4648   TextField field = TextField::New();
4649   DALI_TEST_CHECK(field);
4650
4651   application.GetScene().Add(field);
4652
4653   field.SetProperty(TextField::Property::POINT_SIZE, 7.f);
4654   field.SetProperty(Actor::Property::SIZE, Vector2(250.f, 50.f));
4655   field.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT);
4656   field.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
4657   field.SetProperty(TextField::Property::ENABLE_MARKUP, true);
4658   field.SetProperty(DevelTextField::Property::ELLIPSIS, true);
4659   field.SetProperty(DevelTextField::Property::ELLIPSIS_POSITION, DevelText::EllipsisPosition::START);
4660   field.SetProperty(TextField::Property::TEXT, "Hello World");
4661
4662   // Avoid a crash when core load gl resources.
4663   application.GetGlAbstraction().SetCheckFramebufferStatusResult(GL_FRAMEBUFFER_COMPLETE);
4664
4665   // Render and notify
4666   application.SendNotification();
4667   application.Render();
4668
4669   unsigned int expectedCount = 1;
4670   unsigned int startIndex    = 0;
4671   unsigned int endIndex      = 10;
4672
4673   Vector<Vector2> positionsList = DevelTextField::GetTextPosition(field, startIndex, endIndex);
4674   Vector<Vector2> sizeList      = DevelTextField::GetTextSize(field, startIndex, endIndex);
4675
4676   DALI_TEST_EQUALS(positionsList.Size(), expectedCount, TEST_LOCATION);
4677   DALI_TEST_EQUALS(sizeList.Size(), expectedCount, TEST_LOCATION);
4678
4679   Vector<Vector2> expectedSizes;
4680   Vector<Vector2> expectedPositions;
4681
4682   expectedPositions.PushBack(Vector2(14, 0));
4683   expectedSizes.PushBack(Vector2(106, 25));
4684
4685   TestTextGeometryUtils::CheckGeometryResult(positionsList, sizeList, expectedPositions, expectedSizes);
4686
4687   END_TEST;
4688 }
4689
4690 int utcDaliTextFieldGeometryEllipsisEnd(void)
4691 {
4692   ToolkitTestApplication application;
4693   tet_infoline(" utcDaliTextFieldGeometryEllipsisEnd");
4694
4695   TextField field = TextField::New();
4696   DALI_TEST_CHECK(field);
4697
4698   application.GetScene().Add(field);
4699
4700   field.SetProperty(TextField::Property::POINT_SIZE, 7.f);
4701   field.SetProperty(Actor::Property::SIZE, Vector2(250.f, 50.f));
4702   field.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT);
4703   field.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
4704   field.SetProperty(TextField::Property::ENABLE_MARKUP, true);
4705   field.SetProperty(DevelTextField::Property::ELLIPSIS, true);
4706   field.SetProperty(DevelTextField::Property::ELLIPSIS_POSITION, DevelText::EllipsisPosition::END);
4707   field.SetProperty(TextField::Property::TEXT, "Hello World");
4708
4709   // Avoid a crash when core load gl resources.
4710   application.GetGlAbstraction().SetCheckFramebufferStatusResult(GL_FRAMEBUFFER_COMPLETE);
4711
4712   // Render and notify
4713   application.SendNotification();
4714   application.Render();
4715
4716   unsigned int expectedCount = 1;
4717   unsigned int startIndex    = 0;
4718   unsigned int endIndex      = 10;
4719
4720   Vector<Vector2> positionsList = DevelTextField::GetTextPosition(field, startIndex, endIndex);
4721   Vector<Vector2> sizeList      = DevelTextField::GetTextSize(field, startIndex, endIndex);
4722
4723   DALI_TEST_EQUALS(positionsList.Size(), expectedCount, TEST_LOCATION);
4724   DALI_TEST_EQUALS(sizeList.Size(), expectedCount, TEST_LOCATION);
4725
4726   Vector<Vector2> expectedSizes;
4727   Vector<Vector2> expectedPositions;
4728
4729   expectedPositions.PushBack(Vector2(-2, 0));
4730   expectedSizes.PushBack(Vector2(122, 25));
4731
4732   TestTextGeometryUtils::CheckGeometryResult(positionsList, sizeList, expectedPositions, expectedSizes);
4733
4734   END_TEST;
4735 }
4736
4737 int utcDaliTextFieldGeometryRTL(void)
4738 {
4739   ToolkitTestApplication application;
4740   tet_infoline(" utcDaliTextFieldGeometryRTL");
4741
4742   TextField field = TextField::New();
4743   DALI_TEST_CHECK(field);
4744
4745   application.GetScene().Add(field);
4746
4747   field.SetProperty(TextField::Property::POINT_SIZE, 7.f);
4748   field.SetProperty(Actor::Property::SIZE, Vector2(300.f, 50.f));
4749   field.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT);
4750   field.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
4751   field.SetProperty(TextField::Property::ENABLE_MARKUP, true);
4752   field.SetProperty(TextField::Property::TEXT, "السطر الاخير");
4753
4754   // Avoid a crash when core load gl resources.
4755   application.GetGlAbstraction().SetCheckFramebufferStatusResult(GL_FRAMEBUFFER_COMPLETE);
4756
4757   // Render and notify
4758   application.SendNotification();
4759   application.Render();
4760
4761   unsigned int expectedCount = 1;
4762   unsigned int startIndex    = 1;
4763   unsigned int endIndex      = 7;
4764
4765   Vector<Vector2> positionsList = DevelTextField::GetTextPosition(field, startIndex, endIndex);
4766   Vector<Vector2> sizeList      = DevelTextField::GetTextSize(field, startIndex, endIndex);
4767
4768   DALI_TEST_EQUALS(positionsList.Size(), expectedCount, TEST_LOCATION);
4769   DALI_TEST_EQUALS(sizeList.Size(), expectedCount, TEST_LOCATION);
4770
4771   Vector<Vector2> expectedSizes;
4772   Vector<Vector2> expectedPositions;
4773
4774   expectedPositions.PushBack(Vector2(38, 0));
4775   expectedSizes.PushBack(Vector2(73, 25));
4776
4777   TestTextGeometryUtils::CheckGeometryResult(positionsList, sizeList, expectedPositions, expectedSizes);
4778
4779   END_TEST;
4780 }
4781
4782 int utcDaliTextFieldGeometryGlyphMiddle(void)
4783 {
4784   ToolkitTestApplication application;
4785   tet_infoline(" utcDaliTextFieldGeometryGlyphMiddle");
4786
4787   TextField field = TextField::New();
4788   DALI_TEST_CHECK(field);
4789
4790   application.GetScene().Add(field);
4791
4792   field.SetProperty(TextField::Property::POINT_SIZE, 7.f);
4793   field.SetProperty(Actor::Property::SIZE, Vector2(150.f, 200.f));
4794   field.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT);
4795   field.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
4796   field.SetProperty(TextField::Property::ENABLE_MARKUP, true);
4797   field.SetProperty(TextField::Property::TEXT, "لا تحتوي على لا");
4798
4799   // Avoid a crash when core load gl resources.
4800   application.GetGlAbstraction().SetCheckFramebufferStatusResult(GL_FRAMEBUFFER_COMPLETE);
4801
4802   // Render and notify
4803   application.SendNotification();
4804   application.Render();
4805
4806   unsigned int expectedCount = 1;
4807   unsigned int startIndex    = 1;
4808   unsigned int endIndex      = 13;
4809
4810   Vector<Vector2> positionsList = DevelTextField::GetTextPosition(field, startIndex, endIndex);
4811   Vector<Vector2> sizeList      = DevelTextField::GetTextSize(field, startIndex, endIndex);
4812
4813   DALI_TEST_EQUALS(positionsList.Size(), expectedCount, TEST_LOCATION);
4814   DALI_TEST_EQUALS(sizeList.Size(), expectedCount, TEST_LOCATION);
4815
4816   Vector<Vector2> expectedSizes;
4817   Vector<Vector2> expectedPositions;
4818
4819   expectedPositions.PushBack(Vector2(6, 0));
4820   expectedSizes.PushBack(Vector2(124, 25));
4821
4822   TestTextGeometryUtils::CheckGeometryResult(positionsList, sizeList, expectedPositions, expectedSizes);
4823
4824   END_TEST;
4825 }
4826
4827 int utcDaliTextFieldSelectionClearedSignal(void)
4828 {
4829   ToolkitTestApplication application;
4830   tet_infoline(" utcDaliTextFieldSelectionClearedSignal");
4831
4832   TextField field = TextField::New();
4833   DALI_TEST_CHECK(field);
4834
4835   application.GetScene().Add(field);
4836
4837   // connect to the selection changed signal.
4838   ConnectionTracker* testTracker = new ConnectionTracker();
4839   DevelTextField::SelectionClearedSignal(field).Connect(&TestSelectionClearedCallback);
4840   bool selectionClearedSignal = false;
4841   field.ConnectSignal(testTracker, "selectionCleared", CallbackFunctor(&selectionClearedSignal));
4842
4843   field.SetProperty(TextField::Property::TEXT, "Hello\nworld\nHello world");
4844   field.SetProperty(TextField::Property::POINT_SIZE, 10.f);
4845   field.SetProperty(Actor::Property::SIZE, Vector2(100.f, 50.f));
4846   field.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT);
4847   field.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
4848
4849   // Avoid a crash when core load gl resources.
4850   application.GetGlAbstraction().SetCheckFramebufferStatusResult(GL_FRAMEBUFFER_COMPLETE);
4851
4852   // Render and notify
4853   application.SendNotification();
4854   application.Render();
4855
4856   // Tap on the text editor
4857   TestGenerateTap(application, 3.0f, 25.0f);
4858
4859   // Render and notify
4860   application.SendNotification();
4861   application.Render();
4862
4863   // Move to second line of the text & Select some text in the right of the current cursor position
4864   application.ProcessEvent(GenerateKey("", "", "", DALI_KEY_CURSOR_DOWN, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
4865   application.ProcessEvent(GenerateKey("", "", "", DALI_KEY_CURSOR_RIGHT, KEY_SHIFT_MODIFIER, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
4866
4867   // remove selection
4868   application.ProcessEvent(GenerateKey("", "", "", DALI_KEY_ESCAPE, 0, 0, Integration::KeyEvent::UP, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
4869
4870   // Render and notify
4871   application.SendNotification();
4872   application.Render();
4873
4874   DALI_TEST_CHECK(gSelectionClearedCallbackCalled);
4875
4876   // Render and notify
4877   application.SendNotification();
4878   application.Render();
4879
4880   // Tap on the text editor
4881   TestGenerateTap(application, 3.0f, 25.0f);
4882
4883   // Render and notify
4884   application.SendNotification();
4885   application.Render();
4886
4887   gSelectionClearedCallbackCalled = false;
4888
4889   // Move to second line of the text & select.
4890   application.ProcessEvent(GenerateKey("", "", "", DALI_KEY_CURSOR_DOWN, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
4891   application.ProcessEvent(GenerateKey("", "", "", DALI_KEY_CURSOR_RIGHT, KEY_SHIFT_MODIFIER, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
4892
4893   //remove selection
4894   application.ProcessEvent(GenerateKey("", "", "", DALI_KEY_CURSOR_RIGHT, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
4895
4896   // Render and notify
4897   application.SendNotification();
4898   application.Render();
4899
4900   DALI_TEST_CHECK(gSelectionClearedCallbackCalled);
4901
4902   gSelectionClearedCallbackCalled = false;
4903
4904   // Render and notify
4905   application.SendNotification();
4906   application.Render();
4907
4908   // Move to second line of the text & select.
4909   application.ProcessEvent(GenerateKey("", "", "", DALI_KEY_CURSOR_DOWN, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
4910   application.ProcessEvent(GenerateKey("", "", "", DALI_KEY_CURSOR_RIGHT, KEY_SHIFT_MODIFIER, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
4911
4912   // replace D with selected text
4913   application.ProcessEvent(GenerateKey("D", "", "D", KEY_D_CODE, 0, 0, Integration::KeyEvent::DOWN, "D", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
4914
4915   // Render and notify
4916   application.SendNotification();
4917   application.Render();
4918
4919   DALI_TEST_CHECK(gSelectionClearedCallbackCalled);
4920
4921   gSelectionClearedCallbackCalled = false;
4922
4923   // Render and notify
4924   application.SendNotification();
4925   application.Render();
4926
4927   DevelTextField::SelectText(field, 1, 3);
4928
4929   // Render and notify
4930   application.SendNotification();
4931   application.Render();
4932
4933   field.SetProperty(DevelTextField::Property::PRIMARY_CURSOR_POSITION, 3);
4934
4935   // Render and notify
4936   application.SendNotification();
4937   application.Render();
4938
4939   DALI_TEST_CHECK(gSelectionClearedCallbackCalled);
4940
4941   gSelectionClearedCallbackCalled = false;
4942
4943   DevelTextField::SelectText(field, 1, 3);
4944
4945   // Render and notify
4946   application.SendNotification();
4947   application.Render();
4948
4949   // select none
4950   DevelTextField::SelectNone(field);
4951
4952   // Render and notify
4953   application.SendNotification();
4954   application.Render();
4955
4956   DALI_TEST_CHECK(gSelectionClearedCallbackCalled);
4957
4958   END_TEST;
4959 }
4960
4961 int utcDaliTextFieldSelectionStartedSignal(void)
4962 {
4963   ToolkitTestApplication application;
4964   tet_infoline(" utcDaliTextFieldSelectionStartedSignal");
4965
4966   TextField field = TextField::New();
4967   DALI_TEST_CHECK(field);
4968
4969   application.GetScene().Add(field);
4970
4971   // connect to the selection changed signal.
4972   ConnectionTracker* testTracker = new ConnectionTracker();
4973   DevelTextField::SelectionStartedSignal(field).Connect(&TestSelectionStartedCallback);
4974   bool selectionStartedSignal = false;
4975   field.ConnectSignal(testTracker, "selectionStarted", CallbackFunctor(&selectionStartedSignal));
4976
4977   field.SetProperty(TextField::Property::TEXT, "Hello\nworld\nHello world");
4978   field.SetProperty(TextField::Property::POINT_SIZE, 10.f);
4979   field.SetProperty(Actor::Property::SIZE, Vector2(100.f, 50.f));
4980   field.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT);
4981   field.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
4982
4983   // Avoid a crash when core load gl resources.
4984   application.GetGlAbstraction().SetCheckFramebufferStatusResult(GL_FRAMEBUFFER_COMPLETE);
4985
4986   // Render and notify
4987   application.SendNotification();
4988   application.Render();
4989
4990   // Tap on the text field
4991   TestGenerateTap(application, 3.0f, 25.0f);
4992
4993   // Render and notify
4994   application.SendNotification();
4995   application.Render();
4996
4997   // Move to second line of the text & Select some text in the right of the current cursor position
4998   application.ProcessEvent(GenerateKey("", "", "", DALI_KEY_CURSOR_DOWN, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
4999   application.ProcessEvent(GenerateKey("", "", "", DALI_KEY_CURSOR_RIGHT, KEY_SHIFT_MODIFIER, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
5000
5001   // Render and notify
5002   application.SendNotification();
5003   application.Render();
5004
5005   DALI_TEST_CHECK(gSelectionStartedCallbackCalled);
5006
5007   // remove selection
5008   application.ProcessEvent(GenerateKey("", "", "", DALI_KEY_ESCAPE, 0, 0, Integration::KeyEvent::UP, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
5009
5010   // Render and notify
5011   application.SendNotification();
5012   application.Render();
5013
5014   gSelectionStartedCallbackCalled = false;
5015
5016   DevelTextField::SelectText(field, 1, 3);
5017
5018   // Render and notify
5019   application.SendNotification();
5020   application.Render();
5021
5022   DALI_TEST_CHECK(gSelectionStartedCallbackCalled);
5023
5024   END_TEST;
5025 }
5026
5027 int utcDaliTextFieldSelectionChangedSignal(void)
5028 {
5029   ToolkitTestApplication application;
5030   tet_infoline(" utcDaliTextFieldSelectionChangedSignal");
5031
5032   TextField field = TextField::New();
5033   DALI_TEST_CHECK(field);
5034
5035   application.GetScene().Add(field);
5036
5037   // connect to the selection changed signal.
5038   ConnectionTracker* testTracker = new ConnectionTracker();
5039   DevelTextField::SelectionChangedSignal(field).Connect(&TestSelectionChangedCallback);
5040   bool selectionChangedSignal = false;
5041   field.ConnectSignal(testTracker, "selectionChanged", CallbackFunctor(&selectionChangedSignal));
5042
5043   field.SetProperty(TextField::Property::TEXT, "Hello world Hello world");
5044   field.SetProperty(TextField::Property::POINT_SIZE, 10.f);
5045   field.SetProperty(Actor::Property::SIZE, Vector2(100.f, 50.f));
5046   field.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT);
5047   field.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
5048
5049   // Avoid a crash when core load gl resources.
5050   application.GetGlAbstraction().SetCheckFramebufferStatusResult(GL_FRAMEBUFFER_COMPLETE);
5051
5052   // Render and notify
5053   application.SendNotification();
5054   application.Render();
5055
5056   // Tap on the text field
5057   TestGenerateTap(application, 3.0f, 25.0f);
5058
5059   // Render and notify
5060   application.SendNotification();
5061   application.Render();
5062
5063   // Select some text in the right of the current cursor position
5064   application.ProcessEvent(GenerateKey("", "", "", DALI_KEY_SHIFT_LEFT, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
5065   application.ProcessEvent(GenerateKey("", "", "", DALI_KEY_CURSOR_RIGHT, KEY_SHIFT_MODIFIER, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
5066
5067   // Render and notify
5068   application.SendNotification();
5069   application.Render();
5070
5071   DALI_TEST_CHECK(gSelectionChangedCallbackCalled);
5072   DALI_TEST_EQUALS(oldSelectionStart, oldSelectionEnd, TEST_LOCATION);
5073
5074   gSelectionChangedCallbackCalled = false;
5075
5076   application.ProcessEvent(GenerateKey("", "", "", DALI_KEY_CURSOR_RIGHT, KEY_SHIFT_MODIFIER, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
5077
5078   // Render and notify
5079   application.SendNotification();
5080   application.Render();
5081
5082   DALI_TEST_CHECK(gSelectionChangedCallbackCalled);
5083   DALI_TEST_EQUALS(oldSelectionStart, 0, TEST_LOCATION);
5084   DALI_TEST_EQUALS(oldSelectionEnd, 1, TEST_LOCATION);
5085
5086   gSelectionChangedCallbackCalled = false;
5087
5088   application.ProcessEvent(GenerateKey("", "", "", DALI_KEY_ESCAPE, 0, 0, Integration::KeyEvent::UP, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
5089
5090   // Render and notify
5091   application.SendNotification();
5092   application.Render();
5093
5094   DALI_TEST_CHECK(gSelectionChangedCallbackCalled);
5095   DALI_TEST_EQUALS(oldSelectionStart, 0, TEST_LOCATION);
5096   DALI_TEST_EQUALS(oldSelectionEnd, 2, TEST_LOCATION);
5097
5098   gSelectionChangedCallbackCalled = false;
5099   field.SetKeyInputFocus();
5100
5101   // Render and notify
5102   application.SendNotification();
5103   application.Render();
5104
5105   DevelTextField::SelectText(field, 0, 5);
5106
5107   application.SendNotification();
5108   application.Render();
5109
5110   DALI_TEST_CHECK(gSelectionChangedCallbackCalled);
5111   DALI_TEST_EQUALS(oldSelectionStart, oldSelectionEnd, TEST_LOCATION);
5112
5113   gSelectionChangedCallbackCalled = false;
5114
5115   field.SetProperty(DevelTextField::Property::PRIMARY_CURSOR_POSITION, 3);
5116
5117   // Render and notify
5118   application.SendNotification();
5119   application.Render();
5120
5121   DALI_TEST_CHECK(gSelectionChangedCallbackCalled);
5122   DALI_TEST_EQUALS(oldSelectionStart, 0, TEST_LOCATION);
5123   DALI_TEST_EQUALS(oldSelectionEnd, 5, TEST_LOCATION);
5124
5125   gSelectionChangedCallbackCalled = false;
5126
5127   // select all text
5128   DevelTextField::SelectWholeText(field);
5129
5130   // Render and notify
5131   application.SendNotification();
5132   application.Render();
5133
5134   DALI_TEST_CHECK(gSelectionChangedCallbackCalled);
5135   DALI_TEST_EQUALS(oldSelectionStart, oldSelectionEnd, TEST_LOCATION);
5136
5137   gSelectionChangedCallbackCalled = false;
5138
5139   // select none
5140   DevelTextField::SelectNone(field);
5141
5142   // Render and notify
5143   application.SendNotification();
5144   application.Render();
5145
5146   DALI_TEST_CHECK(gSelectionChangedCallbackCalled);
5147   DALI_TEST_EQUALS(oldSelectionStart, 0, TEST_LOCATION);
5148   DALI_TEST_EQUALS(oldSelectionEnd, 23, TEST_LOCATION);
5149
5150   END_TEST;
5151 }
5152
5153 int UtcDaliToolkitTextFieldStrikethroughGeneration(void)
5154 {
5155   ToolkitTestApplication application;
5156   tet_infoline(" UtcDaliToolkitTextFieldStrikethroughGeneration");
5157
5158   TextField textField = TextField::New();
5159   textField.SetProperty(TextField::Property::TEXT, "Test");
5160   textField.SetProperty(Actor::Property::SIZE, Vector2(200.0f, 100.f));
5161   textField.SetProperty(TextField::Property::POINT_SIZE, 10);
5162   textField.SetProperty(TextField::Property::FONT_FAMILY, "DejaVu Sans");
5163
5164   application.GetScene().Add(textField);
5165   application.SendNotification();
5166   application.Render();
5167
5168   Property::Map strikethroughMapSet;
5169   Property::Map strikethroughMapGet;
5170
5171   strikethroughMapSet.Insert("enable", true);
5172   strikethroughMapSet.Insert("color", Color::RED);
5173   strikethroughMapSet.Insert("height", 2.0f);
5174
5175   // Check the strikethrough property
5176   textField.SetProperty(DevelTextField::Property::STRIKETHROUGH, strikethroughMapSet);
5177   strikethroughMapGet = textField.GetProperty<Property::Map>(DevelTextField::Property::STRIKETHROUGH);
5178   textField.SetProperty(TextField::Property::TEXT, "Test1");
5179   DALI_TEST_EQUALS(strikethroughMapGet.Count(), strikethroughMapSet.Count(), TEST_LOCATION);
5180   DALI_TEST_EQUALS(DaliTestCheckMaps(strikethroughMapGet, strikethroughMapSet), true, TEST_LOCATION);
5181
5182   // Render and notify
5183   application.SendNotification();
5184   application.Render();
5185
5186   strikethroughMapSet.Clear();
5187   strikethroughMapGet.Clear();
5188
5189   END_TEST;
5190 }
5191
5192 int UtcDaliToolkitTextFieldInputStrikethroughGeneration(void)
5193 {
5194   ToolkitTestApplication application;
5195   tet_infoline(" UtcDaliToolkitTextFieldInputStrikethroughGeneration");
5196
5197   TextField textField = TextField::New();
5198   textField.SetProperty(TextField::Property::TEXT, "Test");
5199   textField.SetProperty(Actor::Property::SIZE, Vector2(200.0f, 100.f));
5200   textField.SetProperty(TextField::Property::POINT_SIZE, 10);
5201   textField.SetProperty(TextField::Property::FONT_FAMILY, "DejaVu Sans");
5202
5203   application.GetScene().Add(textField);
5204   application.SendNotification();
5205   application.Render();
5206
5207   std::string strikethroughSettings1("{\"enable\":\"true\",\"color\":\"red\",\"height\":\"2\"}");
5208
5209   // Check the strikethrough property
5210   textField.SetProperty(DevelTextField::Property::INPUT_STRIKETHROUGH, strikethroughSettings1);
5211   textField.SetProperty(TextField::Property::TEXT, "Test1");
5212   DALI_TEST_EQUALS(textField.GetProperty<std::string>(DevelTextField::Property::INPUT_STRIKETHROUGH), strikethroughSettings1, TEST_LOCATION);
5213
5214   // Render and notify
5215   application.SendNotification();
5216   application.Render();
5217
5218   END_TEST;
5219 }
5220
5221 int UtcDaliToolkitTextFieldUnderlineTypesGeneration1(void)
5222 {
5223   ToolkitTestApplication application;
5224   tet_infoline(" UtcDaliToolkitTextFieldUnderlineTypesGeneration1");
5225   TextField field = TextField::New();
5226   field.SetProperty(TextField::Property::TEXT, "Test");
5227   field.SetProperty(Actor::Property::SIZE, Vector2(200.0f, 100.f));
5228   field.SetProperty(TextField::Property::POINT_SIZE, 10);
5229   field.SetProperty(TextField::Property::FONT_FAMILY, "DejaVu Sans");
5230
5231   application.GetScene().Add(field);
5232   application.SendNotification();
5233   application.Render();
5234
5235   Property::Map underlineMapSet;
5236   Property::Map underlineMapGet;
5237
5238   underlineMapSet.Insert("enable", true);
5239   underlineMapSet.Insert("color", Color::RED);
5240   underlineMapSet.Insert("height", 1);
5241   underlineMapSet.Insert("type", Text::Underline::SOLID);
5242   underlineMapSet.Insert("dashWidth", 2);
5243   underlineMapSet.Insert("dashGap", 1);
5244
5245   // Check the underline property
5246   field.SetProperty(TextField::Property::UNDERLINE, underlineMapSet);
5247
5248   underlineMapGet = field.GetProperty<Property::Map>(TextField::Property::UNDERLINE);
5249   DALI_TEST_EQUALS(underlineMapGet.Count(), underlineMapSet.Count(), TEST_LOCATION);
5250   DALI_TEST_EQUALS(DaliTestCheckMaps(underlineMapGet, underlineMapSet), true, TEST_LOCATION);
5251
5252   // Render and notify
5253   application.SendNotification();
5254   application.Render();
5255
5256   underlineMapSet.Clear();
5257   underlineMapGet.Clear();
5258
5259   underlineMapSet.Insert("enable", true);
5260   underlineMapSet.Insert("color", Color::BLUE);
5261   underlineMapSet.Insert("height", 1);
5262   underlineMapSet.Insert("type", Text::Underline::DASHED);
5263   underlineMapSet.Insert("dashWidth", 4);
5264   underlineMapSet.Insert("dashGap", 2);
5265
5266   // Check the dashed underline property
5267   field.SetProperty(TextField::Property::UNDERLINE, underlineMapSet);
5268
5269   underlineMapGet = field.GetProperty<Property::Map>(TextField::Property::UNDERLINE);
5270   DALI_TEST_EQUALS(underlineMapGet.Count(), underlineMapSet.Count(), TEST_LOCATION);
5271   DALI_TEST_EQUALS(DaliTestCheckMaps(underlineMapGet, underlineMapSet), true, TEST_LOCATION);
5272
5273   // Render and notify
5274   application.SendNotification();
5275   application.Render();
5276
5277   underlineMapSet.Clear();
5278   underlineMapGet.Clear();
5279
5280   underlineMapSet.Insert("enable", true);
5281   underlineMapSet.Insert("color", Color::BLUE);
5282   underlineMapSet.Insert("height", 1);
5283   underlineMapSet.Insert("type", Text::Underline::DOUBLE);
5284   underlineMapSet.Insert("dashWidth", 4);
5285   underlineMapSet.Insert("dashGap", 2);
5286
5287   // Check the dashed underline property
5288   field.SetProperty(TextField::Property::UNDERLINE, underlineMapSet);
5289
5290   underlineMapGet = field.GetProperty<Property::Map>(TextField::Property::UNDERLINE);
5291   DALI_TEST_EQUALS(underlineMapGet.Count(), underlineMapSet.Count(), TEST_LOCATION);
5292   DALI_TEST_EQUALS(DaliTestCheckMaps(underlineMapGet, underlineMapSet), true, TEST_LOCATION);
5293
5294   // Render and notify
5295   application.SendNotification();
5296   application.Render();
5297
5298   underlineMapSet.Clear();
5299   underlineMapGet.Clear();
5300
5301   END_TEST;
5302 }
5303
5304 int UtcDaliToolkitTextFieldUnderlineTypesGeneration2(void)
5305 {
5306   ToolkitTestApplication application;
5307   tet_infoline(" UtcDaliToolkitTextFieldUnderlineTypesGeneration2");
5308
5309   TextField field1 = TextField::New();
5310   field1.SetProperty(TextField::Property::TEXT, "Test");
5311   field1.SetProperty(Actor::Property::SIZE, Vector2(200.0f, 100.f));
5312   field1.SetProperty(TextField::Property::POINT_SIZE, 10);
5313   field1.SetProperty(TextField::Property::FONT_FAMILY, "DejaVu Sans");
5314
5315   Property::Map underlineMapSet1;
5316   Property::Map underlineMapGet1;
5317
5318   underlineMapSet1.Insert("enable", true);
5319   underlineMapSet1.Insert("color", Color::RED);
5320   underlineMapSet1.Insert("height", 1);
5321   underlineMapSet1.Insert("type", Text::Underline::SOLID);
5322   underlineMapSet1.Insert("dashWidth", 2);
5323   underlineMapSet1.Insert("dashGap", 1);
5324
5325   // Check the underline property
5326   field1.SetProperty(TextField::Property::UNDERLINE, underlineMapSet1);
5327
5328   underlineMapGet1 = field1.GetProperty<Property::Map>(TextField::Property::UNDERLINE);
5329   DALI_TEST_EQUALS(underlineMapGet1.Count(), underlineMapSet1.Count(), TEST_LOCATION);
5330   DALI_TEST_EQUALS(DaliTestCheckMaps(underlineMapGet1, underlineMapSet1), true, TEST_LOCATION);
5331
5332   application.GetScene().Add(field1);
5333   application.SendNotification();
5334   application.Render();
5335
5336   TextField field2 = TextField::New();
5337   field2.SetProperty(TextField::Property::TEXT, "Test");
5338   field2.SetProperty(Actor::Property::SIZE, Vector2(200.0f, 100.f));
5339   field2.SetProperty(TextField::Property::POINT_SIZE, 10);
5340   field2.SetProperty(TextField::Property::FONT_FAMILY, "DejaVu Sans");
5341
5342   Property::Map underlineMapSet2;
5343   Property::Map underlineMapGet2;
5344
5345   underlineMapSet2.Insert("enable", true);
5346   underlineMapSet2.Insert("color", Color::BLUE);
5347   underlineMapSet2.Insert("height", 1);
5348   underlineMapSet2.Insert("type", Text::Underline::DASHED);
5349   underlineMapSet2.Insert("dashWidth", 4);
5350   underlineMapSet2.Insert("dashGap", 2);
5351
5352   // Check the dashed underline property
5353   field2.SetProperty(TextField::Property::UNDERLINE, underlineMapSet2);
5354
5355   underlineMapGet2 = field2.GetProperty<Property::Map>(TextField::Property::UNDERLINE);
5356   DALI_TEST_EQUALS(underlineMapGet2.Count(), underlineMapSet2.Count(), TEST_LOCATION);
5357   DALI_TEST_EQUALS(DaliTestCheckMaps(underlineMapGet2, underlineMapSet2), true, TEST_LOCATION);
5358
5359   application.GetScene().Add(field2);
5360   application.SendNotification();
5361   application.Render();
5362
5363   TextField field3 = TextField::New();
5364   field3.SetProperty(TextField::Property::TEXT, "Test");
5365   field3.SetProperty(Actor::Property::SIZE, Vector2(200.0f, 100.f));
5366   field3.SetProperty(TextField::Property::POINT_SIZE, 10);
5367   field3.SetProperty(TextField::Property::FONT_FAMILY, "DejaVu Sans");
5368
5369   Property::Map underlineMapSet3;
5370   Property::Map underlineMapGet3;
5371
5372   underlineMapSet3.Insert("enable", true);
5373   underlineMapSet3.Insert("color", Color::BLUE);
5374   underlineMapSet3.Insert("height", 1);
5375   underlineMapSet3.Insert("type", Text::Underline::DOUBLE);
5376   underlineMapSet3.Insert("dashWidth", 4);
5377   underlineMapSet3.Insert("dashGap", 2);
5378
5379   // Check the dashed underline property
5380   field3.SetProperty(TextField::Property::UNDERLINE, underlineMapSet3);
5381
5382   underlineMapGet3 = field3.GetProperty<Property::Map>(TextField::Property::UNDERLINE);
5383   DALI_TEST_EQUALS(underlineMapGet3.Count(), underlineMapSet3.Count(), TEST_LOCATION);
5384   DALI_TEST_EQUALS(DaliTestCheckMaps(underlineMapGet3, underlineMapSet3), true, TEST_LOCATION);
5385
5386   application.GetScene().Add(field3);
5387
5388   application.SendNotification();
5389   application.Render();
5390
5391   END_TEST;
5392 }
5393
5394 int UtcDaliTextFieldCharacterSpacing(void)
5395 {
5396   ToolkitTestApplication application;
5397   tet_infoline(" UtcDaliTextFieldCharacterSpacing ");
5398
5399   TextField textField = TextField::New();
5400
5401   textField.SetProperty(Actor::Property::SIZE, Vector2(150.0f, 300.f));
5402
5403   application.GetScene().Add(textField);
5404   application.SendNotification();
5405   application.Render();
5406
5407   textField.SetProperty(TextField::Property::TEXT, "Hi Experiment");
5408   textField.SetProperty(DevelTextField::Property::CHARACTER_SPACING, 10.f);
5409   DALI_TEST_EQUALS(textField.GetProperty<float>(DevelTextField::Property::CHARACTER_SPACING), 10.f, Math::MACHINE_EPSILON_1000, TEST_LOCATION);
5410
5411   application.SendNotification();
5412   application.Render();
5413
5414   END_TEST;
5415 }
5416
5417 int UtcDaliToolkitTextFieldUnderlineTypesGeneration3(void)
5418 {
5419   ToolkitTestApplication application;
5420   tet_infoline(" UtcDaliToolkitTextFieldUnderlineTypesGeneration3");
5421
5422   TextField field1 = TextField::New();
5423   field1.SetProperty(TextField::Property::TEXT, "Test1");
5424   field1.SetProperty(Actor::Property::SIZE, Vector2(200.0f, 100.f));
5425   field1.SetProperty(TextField::Property::POINT_SIZE, 10);
5426   field1.SetProperty(TextField::Property::FONT_FAMILY, "DejaVu Sans");
5427
5428   Property::Map underlineMapSet1;
5429   Property::Map underlineMapGet1;
5430
5431   underlineMapSet1.Insert("enable", true);
5432   underlineMapSet1.Insert("color", Color::RED);
5433   underlineMapSet1.Insert("height", 1);
5434   underlineMapSet1.Insert("type", Text::Underline::SOLID);
5435   underlineMapSet1.Insert("dashWidth", 2);
5436   underlineMapSet1.Insert("dashGap", 1);
5437
5438   // Check the underline property
5439   field1.SetProperty(TextField::Property::UNDERLINE, underlineMapSet1);
5440   //field1.SetProperty( TextField::Property::TEXT, "Test2" );
5441
5442   underlineMapGet1 = field1.GetProperty<Property::Map>(TextField::Property::UNDERLINE);
5443   DALI_TEST_EQUALS(underlineMapGet1.Count(), underlineMapSet1.Count(), TEST_LOCATION);
5444   DALI_TEST_EQUALS(DaliTestCheckMaps(underlineMapGet1, underlineMapSet1), true, TEST_LOCATION);
5445
5446   application.GetScene().Add(field1);
5447   application.SendNotification();
5448   application.Render();
5449
5450   END_TEST;
5451 }
5452
5453 int UtcDaliToolkitTextfieldParagraphTag(void)
5454 {
5455   ToolkitTestApplication application;
5456   tet_infoline(" UtcDaliToolkitTextfieldParagraphTag");
5457   TextField fieldNewlineSeparator = TextField::New();
5458   TextField fieldParagraphTag     = TextField::New();
5459   DALI_TEST_CHECK(fieldNewlineSeparator);
5460   DALI_TEST_CHECK(fieldParagraphTag);
5461
5462   application.GetScene().Add(fieldNewlineSeparator);
5463   application.GetScene().Add(fieldParagraphTag);
5464
5465   //Same utterance uses new-line to split paragraphs should give similar results for paragraph tag.
5466   fieldNewlineSeparator.SetProperty(TextField::Property::ENABLE_MARKUP, true);
5467   fieldNewlineSeparator.SetProperty(Actor::Property::SIZE, Vector2(100.f, 50.f));
5468   fieldNewlineSeparator.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT);
5469   fieldNewlineSeparator.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
5470   fieldNewlineSeparator.SetProperty(TextField::Property::TEXT, "test paragraph tag \ntest paragraph tag \ntest paragraph tag ");
5471
5472   fieldParagraphTag.SetProperty(TextField::Property::ENABLE_MARKUP, true);
5473   fieldParagraphTag.SetProperty(Actor::Property::SIZE, Vector2(100.f, 50.f));
5474   fieldParagraphTag.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT);
5475   fieldParagraphTag.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
5476   fieldParagraphTag.SetProperty(TextField::Property::TEXT, "test paragraph tag <p>test paragraph tag </p>test paragraph tag ");
5477
5478   application.SendNotification();
5479   application.Render();
5480
5481   Vector3 textNaturalSizeNewlineSeparator = fieldNewlineSeparator.GetNaturalSize();
5482   Vector3 textNaturalSizeParagraphTag     = fieldParagraphTag.GetNaturalSize();
5483
5484   DALI_TEST_EQUALS(textNaturalSizeNewlineSeparator, textNaturalSizeParagraphTag, TEST_LOCATION);
5485
5486   application.SendNotification();
5487   application.Render();
5488
5489   END_TEST;
5490 }
5491
5492 //Handle Emoji clustering for cursor handling
5493 int utcDaliTextFieldClusteredEmojiDeletionBackSpaceKey(void)
5494 {
5495   ToolkitTestApplication application;
5496   tet_infoline(" utcDaliTextFieldClusteredEmojiDeletionBackSpaceKey ");
5497   TextField textField = TextField::New();
5498   DALI_TEST_CHECK(textField);
5499
5500   application.GetScene().Add(textField);
5501
5502   // Avoid a crash when core load gl resources.
5503   application.GetGlAbstraction().SetCheckFramebufferStatusResult(GL_FRAMEBUFFER_COMPLETE);
5504
5505   textField.SetProperty(TextField::Property::TEXT, "ABC&#x1F468;&#x200D;&#x1F469;&#x200D;&#x1F467;&#x200D;&#x1F466;XY");
5506   textField.SetProperty(Dali::Toolkit::TextField::Property::ENABLE_MARKUP, true);
5507
5508   // Render and notify
5509   application.SendNotification();
5510   application.Render();
5511
5512   // Set currsor
5513   textField.SetProperty(DevelTextField::Property::PRIMARY_CURSOR_POSITION, 10);
5514   application.SendNotification();
5515   application.Render();
5516
5517   // Set focus and remove Emoji
5518   textField.SetKeyInputFocus();
5519   application.ProcessEvent(GenerateKey("", "", "", DALI_KEY_BACKSPACE, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
5520
5521   //Check the changed text and cursor position
5522   DALI_TEST_EQUALS(textField.GetProperty(TextField::Property::TEXT).Get<std::string>(), "ABCXY", TEST_LOCATION);
5523   DALI_TEST_EQUALS(textField.GetProperty(DevelTextField::Property::PRIMARY_CURSOR_POSITION).Get<int>(), 3, TEST_LOCATION);
5524
5525   // Render and notify
5526   application.SendNotification();
5527   application.Render();
5528
5529   END_TEST;
5530 }
5531
5532 int utcDaliTextFieldClusteredEmojiDeletionDeleteKey(void)
5533 {
5534   ToolkitTestApplication application;
5535   tet_infoline(" utcDaliTextFieldClusteredEmojiDeletionDeleteKey ");
5536   TextField textField = TextField::New();
5537   DALI_TEST_CHECK(textField);
5538
5539   application.GetScene().Add(textField);
5540
5541   // Avoid a crash when core load gl resources.
5542   application.GetGlAbstraction().SetCheckFramebufferStatusResult(GL_FRAMEBUFFER_COMPLETE);
5543
5544   textField.SetProperty(TextField::Property::TEXT, "ABC&#x1F468;&#x200D;&#x1F469;&#x200D;&#x1F467;&#x200D;&#x1F466;XY");
5545   textField.SetProperty(Dali::Toolkit::TextField::Property::ENABLE_MARKUP, true);
5546
5547   // Render and notify
5548   application.SendNotification();
5549   application.Render();
5550
5551   // Set currsor
5552   textField.SetProperty(DevelTextField::Property::PRIMARY_CURSOR_POSITION, 3);
5553   application.SendNotification();
5554   application.Render();
5555
5556   // Set focus and remove Emoji
5557   textField.SetKeyInputFocus();
5558   application.ProcessEvent(GenerateKey("", "", "", Dali::DevelKey::DALI_KEY_DELETE, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
5559
5560   //Check the changed text and cursor position
5561   DALI_TEST_EQUALS(textField.GetProperty(TextField::Property::TEXT).Get<std::string>(), "ABCXY", TEST_LOCATION);
5562   DALI_TEST_EQUALS(textField.GetProperty(DevelTextField::Property::PRIMARY_CURSOR_POSITION).Get<int>(), 3, TEST_LOCATION);
5563
5564   // Render and notify
5565   application.SendNotification();
5566   application.Render();
5567
5568   END_TEST;
5569 }