Merge "Extending Text Styles - Adding Dashed/Double Underline" into devel/master
[platform/core/uifw/dali-toolkit.git] / automated-tests / src / dali-toolkit / utc-Dali-TextField.cpp
1 /*
2  * Copyright (c) 2021 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