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