Merge "Fix key event propagation in text controller" into devel/master
[platform/core/uifw/dali-toolkit.git] / automated-tests / src / dali-toolkit / utc-Dali-TextField.cpp
1 /*
2  * Copyright (c) 2022 Samsung Electronics Co., Ltd.
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  * http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  *
16  */
17
18 #include <stdlib.h>
19 #include <unistd.h>
20 #include <iostream>
21
22 #include <dali/integration-api/events/key-event-integ.h>
23 #include <dali/integration-api/events/touch-event-integ.h>
24 #include <dali/public-api/rendering/renderer.h>
25 #include <dali/devel-api/actors/actor-devel.h>
26
27 #include <dali-toolkit-test-suite-utils.h>
28 #include <dali-toolkit/dali-toolkit.h>
29 #include <dali-toolkit/devel-api/controls/text-controls/text-field-devel.h>
30 #include <dali-toolkit/devel-api/controls/text-controls/text-selection-popup.h>
31 #include <dali-toolkit/devel-api/text/rendering-backend.h>
32 #include <dali-toolkit/devel-api/text/text-enumerations-devel.h>
33 #include <dali/devel-api/adaptor-framework/key-devel.h>
34 #include <dali/devel-api/text-abstraction/font-client.h>
35 #include "test-text-geometry-utils.h"
36 #include "toolkit-clipboard.h"
37
38 using namespace Dali;
39 using namespace Toolkit;
40
41 void dali_textfield_startup(void)
42 {
43   test_return_value = TET_UNDEF;
44 }
45
46 void dali_textfield_cleanup(void)
47 {
48   test_return_value = TET_PASS;
49 }
50
51 namespace
52 {
53 const char* const PROPERTY_NAME_RENDERING_BACKEND                    = "renderingBackend";
54 const char* const PROPERTY_NAME_TEXT                                 = "text";
55 const char* const PROPERTY_NAME_PLACEHOLDER_TEXT                     = "placeholderText";
56 const char* const PROPERTY_NAME_PLACEHOLDER_TEXT_FOCUSED             = "placeholderTextFocused";
57 const char* const PROPERTY_NAME_FONT_FAMILY                          = "fontFamily";
58 const char* const PROPERTY_NAME_FONT_STYLE                           = "fontStyle";
59 const char* const PROPERTY_NAME_POINT_SIZE                           = "pointSize";
60 const char* const PROPERTY_NAME_MAX_LENGTH                           = "maxLength";
61 const char* const PROPERTY_NAME_EXCEED_POLICY                        = "exceedPolicy";
62 const char* const PROPERTY_NAME_HORIZONTAL_ALIGNMENT                 = "horizontalAlignment";
63 const char* const PROPERTY_NAME_VERTICAL_ALIGNMENT                   = "verticalAlignment";
64 const char* const PROPERTY_NAME_TEXT_COLOR                           = "textColor";
65 const char* const PROPERTY_NAME_PLACEHOLDER_TEXT_COLOR               = "placeholderTextColor";
66 const char* const PROPERTY_NAME_PRIMARY_CURSOR_COLOR                 = "primaryCursorColor";
67 const char* const PROPERTY_NAME_SECONDARY_CURSOR_COLOR               = "secondaryCursorColor";
68 const char* const PROPERTY_NAME_ENABLE_CURSOR_BLINK                  = "enableCursorBlink";
69 const char* const PROPERTY_NAME_CURSOR_BLINK_INTERVAL                = "cursorBlinkInterval";
70 const char* const PROPERTY_NAME_CURSOR_BLINK_DURATION                = "cursorBlinkDuration";
71 const char* const PROPERTY_NAME_CURSOR_WIDTH                         = "cursorWidth";
72 const char* const PROPERTY_NAME_GRAB_HANDLE_IMAGE                    = "grabHandleImage";
73 const char* const PROPERTY_NAME_GRAB_HANDLE_PRESSED_IMAGE            = "grabHandlePressedImage";
74 const char* const PROPERTY_NAME_SCROLL_THRESHOLD                     = "scrollThreshold";
75 const char* const PROPERTY_NAME_SCROLL_SPEED                         = "scrollSpeed";
76 const char* const PROPERTY_NAME_SELECTION_POPUP_STYLE                = "selectionPopupStyle";
77 const char* const PROPERTY_NAME_SELECTION_HANDLE_IMAGE_LEFT          = "selectionHandleImageLeft";
78 const char* const PROPERTY_NAME_SELECTION_HANDLE_IMAGE_RIGHT         = "selectionHandleImageRight";
79 const char* const PROPERTY_NAME_SELECTION_HANDLE_PRESSED_IMAGE_LEFT  = "selectionHandlePressedImageLeft";
80 const char* const PROPERTY_NAME_SELECTION_HANDLE_PRESSED_IMAGE_RIGHT = "selectionHandlePressedImageRight";
81 const char* const PROPERTY_NAME_SELECTION_HANDLE_MARKER_IMAGE_LEFT   = "selectionHandleMarkerImageLeft";
82 const char* const PROPERTY_NAME_SELECTION_HANDLE_MARKER_IMAGE_RIGHT  = "selectionHandleMarkerImageRight";
83 const char* const PROPERTY_NAME_SELECTION_HIGHLIGHT_COLOR            = "selectionHighlightColor";
84 const char* const PROPERTY_NAME_DECORATION_BOUNDING_BOX              = "decorationBoundingBox";
85 const char* const PROPERTY_NAME_INPUT_METHOD_SETTINGS                = "inputMethodSettings";
86 const char* const PROPERTY_NAME_INPUT_COLOR                          = "inputColor";
87 const char* const PROPERTY_NAME_ENABLE_MARKUP                        = "enableMarkup";
88 const char* const PROPERTY_NAME_INPUT_FONT_FAMILY                    = "inputFontFamily";
89 const char* const PROPERTY_NAME_INPUT_FONT_STYLE                     = "inputFontStyle";
90 const char* const PROPERTY_NAME_INPUT_POINT_SIZE                     = "inputPointSize";
91
92 const char* const PROPERTY_NAME_UNDERLINE           = "underline";
93 const char* const PROPERTY_NAME_INPUT_UNDERLINE     = "inputUnderline";
94 const char* const PROPERTY_NAME_SHADOW              = "shadow";
95 const char* const PROPERTY_NAME_INPUT_SHADOW        = "inputShadow";
96 const char* const PROPERTY_NAME_EMBOSS              = "emboss";
97 const char* const PROPERTY_NAME_INPUT_EMBOSS        = "inputEmboss";
98 const char* const PROPERTY_NAME_OUTLINE             = "outline";
99 const char* const PROPERTY_NAME_INPUT_OUTLINE       = "inputOutline";
100 const char* const PROPERTY_NAME_STRIKETHROUGH       = "strikethrough";
101 const char* const PROPERTY_NAME_INPUT_STRIKETHROUGH = "inputStrikethrough";
102
103 const char* const PROPERTY_NAME_HIDDEN_INPUT_SETTINGS           = "hiddenInputSettings";
104 const char* const PROPERTY_NAME_PIXEL_SIZE                      = "pixelSize";
105 const char* const PROPERTY_NAME_ENABLE_SELECTION                = "enableSelection";
106 const char* const PROPERTY_NAME_PLACEHOLDER                     = "placeholder";
107 const char* const PROPERTY_NAME_ELLIPSIS                        = "ellipsis";
108 const char* const PROPERTY_NAME_ENABLE_SHIFT_SELECTION          = "enableShiftSelection";
109 const char* const PROPERTY_NAME_ENABLE_GRAB_HANDLE              = "enableGrabHandle";
110 const char* const PROPERTY_NAME_MATCH_SYSTEM_LANGUAGE_DIRECTION = "matchSystemLanguageDirection";
111 const char* const PROPERTY_NAME_ENABLE_GRAB_HANDLE_POPUP        = "enableGrabHandlePopup";
112 const char* const PROPERTY_NAME_BACKGROUND                      = "textBackground";
113 const char* const PROPERTY_NAME_FONT_SIZE_SCALE                 = "fontSizeScale";
114 const char* const PROPERTY_NAME_ENABLE_FONT_SIZE_SCALE          = "enableFontSizeScale";
115 const char* const PROPERTY_NAME_GRAB_HANDLE_COLOR               = "grabHandleColor";
116 const char* const PROPERTY_NAME_INPUT_FILTER                    = "inputFilter";
117
118 const Vector4       PLACEHOLDER_TEXT_COLOR(0.8f, 0.8f, 0.8f, 0.8f);
119 const Dali::Vector4 LIGHT_BLUE(0.75f, 0.96f, 1.f, 1.f); // The text highlight color.
120
121 const float RENDER_FRAME_INTERVAL = 16.66f;
122
123 const unsigned int DEFAULT_FONT_SIZE = 1152u;
124 const std::string  DEFAULT_FONT_DIR("/resources/fonts");
125
126 const int KEY_RETURN_CODE    = 36;
127 const int KEY_A_CODE         = 38;
128 const int KEY_D_CODE         = 40;
129 const int KEY_SHIFT_MODIFIER = 257;
130
131 const std::string DEFAULT_DEVICE_NAME("hwKeyboard");
132
133 static bool                                       gSelectionChangedCallbackCalled;
134 static uint32_t                                   oldSelectionStart;
135 static uint32_t                                   oldSelectionEnd;
136 static bool                                       gSelectionClearedCallbackCalled;
137 static bool                                       gSelectionStartedCallbackCalled;
138 static bool                                       gAnchorClickedCallBackCalled;
139 static bool                                       gAnchorClickedCallBackNotCalled;
140 static bool                                       gTextChangedCallBackCalled;
141 static bool                                       gMaxCharactersCallBackCalled;
142 static bool                                       gInputFilteredAcceptedCallbackCalled;
143 static bool                                       gInputFilteredRejectedCallbackCalled;
144 static bool                                       gInputStyleChangedCallbackCalled;
145 static bool                                       gCursorPositionChangedCallbackCalled;
146 static uint32_t                                   oldCursorPos;
147 static Dali::Toolkit::TextField::InputStyle::Mask gInputStyleMask;
148
149 static void LoadBitmapResource(TestPlatformAbstraction& platform, int width, int height)
150 {
151   Integration::Bitmap*         bitmap = Integration::Bitmap::New(Integration::Bitmap::BITMAP_2D_PACKED_PIXELS, ResourcePolicy::OWNED_DISCARD);
152   Integration::ResourcePointer resource(bitmap);
153   bitmap->GetPackedPixelsProfile()->ReserveBuffer(Pixel::RGBA8888, width, height, width, height);
154 }
155
156 static void LoadMarkerImages(ToolkitTestApplication& app, TextField textField)
157 {
158   int width(40);
159   int height(40);
160   LoadBitmapResource(app.GetPlatform(), width, height);
161
162   Property::Map propertyMap;
163   propertyMap["filename"] = "image.png";
164   propertyMap["width"]    = width;
165   propertyMap["height"]   = height;
166   textField.SetProperty(Toolkit::TextField::Property::SELECTION_HANDLE_IMAGE_LEFT, propertyMap);
167   textField.SetProperty(Toolkit::TextField::Property::SELECTION_HANDLE_IMAGE_RIGHT, propertyMap);
168   textField.SetProperty(Toolkit::TextField::Property::SELECTION_HANDLE_PRESSED_IMAGE_LEFT, propertyMap);
169   textField.SetProperty(Toolkit::TextField::Property::SELECTION_HANDLE_PRESSED_IMAGE_RIGHT, propertyMap);
170   textField.SetProperty(Toolkit::TextField::Property::SELECTION_HANDLE_MARKER_IMAGE_LEFT, propertyMap);
171   textField.SetProperty(Toolkit::TextField::Property::SELECTION_HANDLE_MARKER_IMAGE_RIGHT, propertyMap);
172   textField.SetProperty(Toolkit::TextField::Property::GRAB_HANDLE_IMAGE, propertyMap);
173   textField.SetProperty(Toolkit::TextField::Property::GRAB_HANDLE_PRESSED_IMAGE, propertyMap);
174 }
175
176 /*
177  * Simulate time passed by.
178  *
179  * @note this will always process at least 1 frame (1/60 sec)
180  *
181  * @param application Test application instance
182  * @param duration Time to pass in milliseconds.
183  * @return The actual time passed in milliseconds
184  */
185 static int Wait(ToolkitTestApplication& application, int duration = 0)
186 {
187   int time = 0;
188
189   for(int i = 0; i <= (duration / RENDER_FRAME_INTERVAL); i++)
190   {
191     application.SendNotification();
192     application.Render(RENDER_FRAME_INTERVAL);
193     time += RENDER_FRAME_INTERVAL;
194   }
195
196   return time;
197 }
198
199 Dali::Integration::Point GetPointDownInside(Vector2& pos)
200 {
201   Dali::Integration::Point point;
202   point.SetState(PointState::DOWN);
203   point.SetScreenPosition(pos);
204   return point;
205 }
206
207 Dali::Integration::Point GetPointUpInside(Vector2& pos)
208 {
209   Dali::Integration::Point point;
210   point.SetState(PointState::UP);
211   point.SetScreenPosition(pos);
212   return point;
213 }
214
215 struct CallbackFunctor
216 {
217   CallbackFunctor(bool* callbackFlag)
218   : mCallbackFlag(callbackFlag)
219   {
220   }
221
222   void operator()()
223   {
224     *mCallbackFlag = true;
225   }
226   bool* mCallbackFlag;
227 };
228
229 static void TestSelectionClearedCallback(TextField control)
230 {
231   tet_infoline(" TestSelectionClearedCallback");
232
233   gSelectionClearedCallbackCalled = true;
234 }
235
236 static void TestSelectionStartedCallback(TextField control)
237 {
238   tet_infoline(" TestSelectionStartedCallback");
239
240   gSelectionStartedCallbackCalled = true;
241 }
242
243 static void TestSelectionChangedCallback(TextField control, uint32_t oldStart, uint32_t oldEnd)
244 {
245   tet_infoline(" TestSelectionChangedCallback");
246
247   gSelectionChangedCallbackCalled = true;
248   oldSelectionStart               = oldStart;
249   oldSelectionEnd                 = oldEnd;
250 }
251
252 static void TestAnchorClickedCallback(TextField control, const char* href, unsigned int hrefLength)
253 {
254   tet_infoline(" TestAnchorClickedCallback");
255
256   gAnchorClickedCallBackNotCalled = false;
257
258   if(!strcmp(href, "https://www.tizen.org") && hrefLength == strlen(href))
259   {
260     gAnchorClickedCallBackCalled = true;
261   }
262 }
263
264 static void TestCursorPositionChangedCallback(TextField control, unsigned int oldPos)
265 {
266   tet_infoline(" TestCursorPositionChangedCallback");
267
268   gCursorPositionChangedCallbackCalled = true;
269   oldCursorPos                         = oldPos;
270 }
271
272 static void TestTextChangedCallback(TextField control)
273 {
274   tet_infoline(" TestTextChangedCallback");
275
276   gTextChangedCallBackCalled = true;
277 }
278
279 static void TestMaxLengthReachedCallback(TextField control)
280 {
281   tet_infoline(" TestMaxLengthReachedCallback");
282
283   gMaxCharactersCallBackCalled = true;
284 }
285
286 static void TestInputFilteredCallback(TextField control, Toolkit::InputFilter::Property::Type type)
287 {
288   tet_infoline(" TestInputFilteredCallback");
289
290   if(type == Toolkit::InputFilter::Property::ACCEPTED)
291   {
292     gInputFilteredAcceptedCallbackCalled = true;
293   }
294   else if(type == Toolkit::InputFilter::Property::REJECTED)
295   {
296     gInputFilteredRejectedCallbackCalled = true;
297   }
298 }
299
300 static void TestInputStyleChangedCallback(TextField control, TextField::InputStyle::Mask mask)
301 {
302   tet_infoline(" TestInputStyleChangedCallback");
303
304   gInputStyleChangedCallbackCalled = true;
305   gInputStyleMask                  = mask;
306 }
307
308 // Generate a KeyEvent to send to Core.
309 Integration::KeyEvent GenerateKey(const std::string&                  keyName,
310                                   const std::string&                  logicalKey,
311                                   const std::string&                  keyString,
312                                   int                                 keyCode,
313                                   int                                 keyModifier,
314                                   unsigned long                       timeStamp,
315                                   const Integration::KeyEvent::State& keyState,
316                                   const std::string&                  compose        = "",
317                                   const std::string&                  deviceName     = DEFAULT_DEVICE_NAME,
318                                   const Device::Class::Type&          deviceClass    = Device::Class::NONE,
319                                   const Device::Subclass::Type&       deviceSubclass = Device::Subclass::NONE)
320 {
321   return Integration::KeyEvent(keyName,
322                                logicalKey,
323                                keyString,
324                                keyCode,
325                                keyModifier,
326                                timeStamp,
327                                keyState,
328                                compose,
329                                deviceName,
330                                deviceClass,
331                                deviceSubclass);
332 }
333
334 bool DaliTestCheckMaps(const Property::Map& fontStyleMapGet, const Property::Map& fontStyleMapSet)
335 {
336   if(fontStyleMapGet.Count() == fontStyleMapSet.Count())
337   {
338     for(unsigned int index = 0u; index < fontStyleMapGet.Count(); ++index)
339     {
340       const KeyValuePair& valueGet = fontStyleMapGet.GetKeyValue(index);
341
342       Property::Value* valueSet = NULL;
343       if(valueGet.first.type == Property::Key::INDEX)
344       {
345         valueSet = fontStyleMapSet.Find(valueGet.first.indexKey);
346       }
347       else
348       {
349         // Get Key is a string so searching Set Map for a string key
350         valueSet = fontStyleMapSet.Find(valueGet.first.stringKey);
351       }
352
353       if(NULL != valueSet)
354       {
355         if(valueSet->GetType() == Dali::Property::STRING && (valueGet.second.Get<std::string>() != valueSet->Get<std::string>()))
356         {
357           tet_printf("Value got : [%s], expected : [%s]", valueGet.second.Get<std::string>().c_str(), valueSet->Get<std::string>().c_str());
358           return false;
359         }
360         else if(valueSet->GetType() == Dali::Property::BOOLEAN && (valueGet.second.Get<bool>() != valueSet->Get<bool>()))
361         {
362           tet_printf("Value got : [%d], expected : [%d]", valueGet.second.Get<bool>(), valueSet->Get<bool>());
363           return false;
364         }
365         else if(valueSet->GetType() == Dali::Property::INTEGER && (valueGet.second.Get<int>() != valueSet->Get<int>()))
366         {
367           tet_printf("Value got : [%d], expected : [%d]", valueGet.second.Get<int>(), valueSet->Get<int>());
368           return false;
369         }
370         else if(valueSet->GetType() == Dali::Property::FLOAT && (valueGet.second.Get<float>() != valueSet->Get<float>()))
371         {
372           tet_printf("Value got : [%f], expected : [%f]", valueGet.second.Get<float>(), valueSet->Get<float>());
373           return false;
374         }
375         else if(valueSet->GetType() == Dali::Property::VECTOR2 && (valueGet.second.Get<Vector2>() != valueSet->Get<Vector2>()))
376         {
377           Vector2 vector2Get = valueGet.second.Get<Vector2>();
378           Vector2 vector2Set = valueSet->Get<Vector2>();
379           tet_printf("Value got : [%f, %f], expected : [%f, %f]", vector2Get.x, vector2Get.y, vector2Set.x, vector2Set.y);
380           return false;
381         }
382         else if(valueSet->GetType() == Dali::Property::VECTOR4 && (valueGet.second.Get<Vector4>() != valueSet->Get<Vector4>()))
383         {
384           Vector4 vector4Get = valueGet.second.Get<Vector4>();
385           Vector4 vector4Set = valueSet->Get<Vector4>();
386           tet_printf("Value got : [%f, %f, %f, %f], expected : [%f, %f, %f, %f]", vector4Get.r, vector4Get.g, vector4Get.b, vector4Get.a, vector4Set.r, vector4Set.g, vector4Set.b, vector4Set.a);
387           return false;
388         }
389       }
390       else
391       {
392         if(valueGet.first.type == Property::Key::INDEX)
393         {
394           tet_printf("  The key %d doesn't exist.", valueGet.first.indexKey);
395         }
396         else
397         {
398           tet_printf("  The key %s doesn't exist.", valueGet.first.stringKey.c_str());
399         }
400         return false;
401       }
402     }
403   }
404
405   return true;
406 }
407
408 } // namespace
409
410 int UtcDaliToolkitTextFieldConstructorP(void)
411 {
412   ToolkitTestApplication application;
413   tet_infoline(" UtcDaliToolkitTextFieldConstructorP");
414   TextField textField;
415   DALI_TEST_CHECK(!textField);
416   END_TEST;
417 }
418
419 int UtcDaliToolkitTextFieldNewP(void)
420 {
421   ToolkitTestApplication application;
422   tet_infoline(" UtcDaliToolkitTextFieldNewP");
423   TextField textField = TextField::New();
424   DALI_TEST_CHECK(textField);
425   END_TEST;
426 }
427
428 int UtcDaliToolkitTextFieldDownCastP(void)
429 {
430   ToolkitTestApplication application;
431   tet_infoline(" UtcDaliToolkitTextFieldDownCastP");
432   TextField  textField1 = TextField::New();
433   BaseHandle object(textField1);
434
435   TextField textField2 = TextField::DownCast(object);
436   DALI_TEST_CHECK(textField2);
437
438   TextField textField3 = DownCast<TextField>(object);
439   DALI_TEST_CHECK(textField3);
440   END_TEST;
441 }
442
443 int UtcDaliToolkitTextFieldDownCastN(void)
444 {
445   ToolkitTestApplication application;
446   tet_infoline(" UtcDaliToolkitTextFieldDownCastN");
447   BaseHandle uninitializedObject;
448   TextField  textField1 = TextField::DownCast(uninitializedObject);
449   DALI_TEST_CHECK(!textField1);
450
451   TextField textField2 = DownCast<TextField>(uninitializedObject);
452   DALI_TEST_CHECK(!textField2);
453   END_TEST;
454 }
455
456 int UtcDaliToolkitTextFieldCopyConstructorP(void)
457 {
458   ToolkitTestApplication application;
459   tet_infoline(" UtcDaliToolkitTextFieldCopyConstructorP");
460   TextField textField = TextField::New();
461   textField.SetProperty(TextField::Property::TEXT, "Test");
462
463   TextField copy(textField);
464   DALI_TEST_CHECK(copy);
465   DALI_TEST_CHECK(copy.GetProperty<std::string>(TextLabel::Property::TEXT) == textField.GetProperty<std::string>(TextLabel::Property::TEXT));
466   END_TEST;
467 }
468
469 int UtcDaliTextFieldMoveConstructor(void)
470 {
471   ToolkitTestApplication application;
472
473   TextField textField = TextField::New();
474   textField.SetProperty(TextEditor::Property::TEXT, "Test");
475   DALI_TEST_CHECK(textField.GetProperty<std::string>(TextField::Property::TEXT) == "Test");
476
477   TextField moved = std::move(textField);
478   DALI_TEST_CHECK(moved);
479   DALI_TEST_EQUALS(1, moved.GetBaseObject().ReferenceCount(), TEST_LOCATION);
480   DALI_TEST_CHECK(moved.GetProperty<std::string>(TextField::Property::TEXT) == "Test");
481   DALI_TEST_CHECK(!textField);
482
483   END_TEST;
484 }
485
486 int UtcDaliToolkitTextFieldAssignmentOperatorP(void)
487 {
488   ToolkitTestApplication application;
489   tet_infoline(" UtcDaliToolkitTextFieldAssignmentOperatorP");
490   TextField textField = TextField::New();
491   textField.SetProperty(TextField::Property::TEXT, "Test");
492
493   TextField copy = textField;
494   DALI_TEST_CHECK(copy);
495   DALI_TEST_CHECK(copy.GetProperty<std::string>(TextField::Property::TEXT) == textField.GetProperty<std::string>(TextField::Property::TEXT));
496   END_TEST;
497 }
498
499 int UtcDaliTextFieldMoveAssignment(void)
500 {
501   ToolkitTestApplication application;
502
503   TextField textField = TextField::New();
504   textField.SetProperty(TextEditor::Property::TEXT, "Test");
505   DALI_TEST_CHECK(textField.GetProperty<std::string>(TextField::Property::TEXT) == "Test");
506
507   TextField moved;
508   moved = std::move(textField);
509   DALI_TEST_CHECK(moved);
510   DALI_TEST_EQUALS(1, moved.GetBaseObject().ReferenceCount(), TEST_LOCATION);
511   DALI_TEST_CHECK(moved.GetProperty<std::string>(TextField::Property::TEXT) == "Test");
512   DALI_TEST_CHECK(!textField);
513
514   END_TEST;
515 }
516
517 int UtcDaliTextFieldNewP(void)
518 {
519   ToolkitTestApplication application;
520   tet_infoline(" UtcDaliToolkitTextFieldNewP");
521   TextField textField = TextField::New();
522   DALI_TEST_CHECK(textField);
523   END_TEST;
524 }
525
526 // Positive test case for a method
527 int UtcDaliTextFieldGetPropertyP(void)
528 {
529   ToolkitTestApplication application;
530   tet_infoline(" UtcDaliToolkitTextFieldGetPropertyP");
531   TextField field = TextField::New();
532   DALI_TEST_CHECK(field);
533
534   // Check Property Indices are correct
535   DALI_TEST_CHECK(field.GetPropertyIndex(PROPERTY_NAME_RENDERING_BACKEND) == DevelTextField::Property::RENDERING_BACKEND);
536   DALI_TEST_CHECK(field.GetPropertyIndex(PROPERTY_NAME_TEXT) == TextField::Property::TEXT);
537   DALI_TEST_CHECK(field.GetPropertyIndex(PROPERTY_NAME_PLACEHOLDER_TEXT) == TextField::Property::PLACEHOLDER_TEXT);
538   DALI_TEST_CHECK(field.GetPropertyIndex(PROPERTY_NAME_PLACEHOLDER_TEXT_FOCUSED) == TextField::Property::PLACEHOLDER_TEXT_FOCUSED);
539   DALI_TEST_CHECK(field.GetPropertyIndex(PROPERTY_NAME_FONT_FAMILY) == TextField::Property::FONT_FAMILY);
540   DALI_TEST_CHECK(field.GetPropertyIndex(PROPERTY_NAME_FONT_STYLE) == TextField::Property::FONT_STYLE);
541   DALI_TEST_CHECK(field.GetPropertyIndex(PROPERTY_NAME_POINT_SIZE) == TextField::Property::POINT_SIZE);
542   DALI_TEST_CHECK(field.GetPropertyIndex(PROPERTY_NAME_MAX_LENGTH) == TextField::Property::MAX_LENGTH);
543   DALI_TEST_CHECK(field.GetPropertyIndex(PROPERTY_NAME_EXCEED_POLICY) == TextField::Property::EXCEED_POLICY);
544   DALI_TEST_CHECK(field.GetPropertyIndex(PROPERTY_NAME_HORIZONTAL_ALIGNMENT) == TextField::Property::HORIZONTAL_ALIGNMENT);
545   DALI_TEST_CHECK(field.GetPropertyIndex(PROPERTY_NAME_VERTICAL_ALIGNMENT) == TextField::Property::VERTICAL_ALIGNMENT);
546   DALI_TEST_CHECK(field.GetPropertyIndex(PROPERTY_NAME_TEXT_COLOR) == TextField::Property::TEXT_COLOR);
547   DALI_TEST_CHECK(field.GetPropertyIndex(PROPERTY_NAME_PLACEHOLDER_TEXT_COLOR) == TextField::Property::PLACEHOLDER_TEXT_COLOR);
548   DALI_TEST_CHECK(field.GetPropertyIndex(PROPERTY_NAME_PRIMARY_CURSOR_COLOR) == TextField::Property::PRIMARY_CURSOR_COLOR);
549   DALI_TEST_CHECK(field.GetPropertyIndex(PROPERTY_NAME_SECONDARY_CURSOR_COLOR) == TextField::Property::SECONDARY_CURSOR_COLOR);
550   DALI_TEST_CHECK(field.GetPropertyIndex(PROPERTY_NAME_ENABLE_CURSOR_BLINK) == TextField::Property::ENABLE_CURSOR_BLINK);
551   DALI_TEST_CHECK(field.GetPropertyIndex(PROPERTY_NAME_CURSOR_BLINK_INTERVAL) == TextField::Property::CURSOR_BLINK_INTERVAL);
552   DALI_TEST_CHECK(field.GetPropertyIndex(PROPERTY_NAME_CURSOR_BLINK_DURATION) == TextField::Property::CURSOR_BLINK_DURATION);
553   DALI_TEST_CHECK(field.GetPropertyIndex(PROPERTY_NAME_CURSOR_WIDTH) == TextField::Property::CURSOR_WIDTH);
554   DALI_TEST_CHECK(field.GetPropertyIndex(PROPERTY_NAME_GRAB_HANDLE_IMAGE) == TextField::Property::GRAB_HANDLE_IMAGE);
555   DALI_TEST_CHECK(field.GetPropertyIndex(PROPERTY_NAME_GRAB_HANDLE_PRESSED_IMAGE) == TextField::Property::GRAB_HANDLE_PRESSED_IMAGE);
556   DALI_TEST_CHECK(field.GetPropertyIndex(PROPERTY_NAME_SCROLL_THRESHOLD) == TextField::Property::SCROLL_THRESHOLD);
557   DALI_TEST_CHECK(field.GetPropertyIndex(PROPERTY_NAME_SCROLL_SPEED) == TextField::Property::SCROLL_SPEED);
558   DALI_TEST_CHECK(field.GetPropertyIndex(PROPERTY_NAME_SELECTION_HANDLE_IMAGE_LEFT) == TextField::Property::SELECTION_HANDLE_IMAGE_LEFT);
559   DALI_TEST_CHECK(field.GetPropertyIndex(PROPERTY_NAME_SELECTION_HANDLE_IMAGE_RIGHT) == TextField::Property::SELECTION_HANDLE_IMAGE_RIGHT);
560   DALI_TEST_CHECK(field.GetPropertyIndex(PROPERTY_NAME_SELECTION_HANDLE_PRESSED_IMAGE_LEFT) == TextField::Property::SELECTION_HANDLE_PRESSED_IMAGE_LEFT);
561   DALI_TEST_CHECK(field.GetPropertyIndex(PROPERTY_NAME_SELECTION_HANDLE_PRESSED_IMAGE_RIGHT) == TextField::Property::SELECTION_HANDLE_PRESSED_IMAGE_RIGHT);
562   DALI_TEST_CHECK(field.GetPropertyIndex(PROPERTY_NAME_SELECTION_HANDLE_MARKER_IMAGE_LEFT) == TextField::Property::SELECTION_HANDLE_MARKER_IMAGE_LEFT);
563   DALI_TEST_CHECK(field.GetPropertyIndex(PROPERTY_NAME_SELECTION_HANDLE_MARKER_IMAGE_RIGHT) == TextField::Property::SELECTION_HANDLE_MARKER_IMAGE_RIGHT);
564   DALI_TEST_CHECK(field.GetPropertyIndex(PROPERTY_NAME_SELECTION_HIGHLIGHT_COLOR) == TextField::Property::SELECTION_HIGHLIGHT_COLOR);
565   DALI_TEST_CHECK(field.GetPropertyIndex(PROPERTY_NAME_DECORATION_BOUNDING_BOX) == TextField::Property::DECORATION_BOUNDING_BOX);
566   DALI_TEST_CHECK(field.GetPropertyIndex(PROPERTY_NAME_INPUT_METHOD_SETTINGS) == TextField::Property::INPUT_METHOD_SETTINGS);
567   DALI_TEST_CHECK(field.GetPropertyIndex(PROPERTY_NAME_INPUT_COLOR) == TextField::Property::INPUT_COLOR);
568   DALI_TEST_CHECK(field.GetPropertyIndex(PROPERTY_NAME_ENABLE_MARKUP) == TextField::Property::ENABLE_MARKUP);
569   DALI_TEST_CHECK(field.GetPropertyIndex(PROPERTY_NAME_INPUT_FONT_FAMILY) == TextField::Property::INPUT_FONT_FAMILY);
570   DALI_TEST_CHECK(field.GetPropertyIndex(PROPERTY_NAME_INPUT_FONT_STYLE) == TextField::Property::INPUT_FONT_STYLE);
571   DALI_TEST_CHECK(field.GetPropertyIndex(PROPERTY_NAME_INPUT_POINT_SIZE) == TextField::Property::INPUT_POINT_SIZE);
572   DALI_TEST_CHECK(field.GetPropertyIndex(PROPERTY_NAME_UNDERLINE) == TextField::Property::UNDERLINE);
573   DALI_TEST_CHECK(field.GetPropertyIndex(PROPERTY_NAME_INPUT_UNDERLINE) == TextField::Property::INPUT_UNDERLINE);
574   DALI_TEST_CHECK(field.GetPropertyIndex(PROPERTY_NAME_SHADOW) == TextField::Property::SHADOW);
575   DALI_TEST_CHECK(field.GetPropertyIndex(PROPERTY_NAME_INPUT_SHADOW) == TextField::Property::INPUT_SHADOW);
576   DALI_TEST_CHECK(field.GetPropertyIndex(PROPERTY_NAME_EMBOSS) == TextField::Property::EMBOSS);
577   DALI_TEST_CHECK(field.GetPropertyIndex(PROPERTY_NAME_INPUT_EMBOSS) == TextField::Property::INPUT_EMBOSS);
578   DALI_TEST_CHECK(field.GetPropertyIndex(PROPERTY_NAME_OUTLINE) == TextField::Property::OUTLINE);
579   DALI_TEST_CHECK(field.GetPropertyIndex(PROPERTY_NAME_INPUT_OUTLINE) == TextField::Property::INPUT_OUTLINE);
580   DALI_TEST_CHECK(field.GetPropertyIndex(PROPERTY_NAME_HIDDEN_INPUT_SETTINGS) == TextField::Property::HIDDEN_INPUT_SETTINGS);
581   DALI_TEST_CHECK(field.GetPropertyIndex(PROPERTY_NAME_PIXEL_SIZE) == TextField::Property::PIXEL_SIZE);
582   DALI_TEST_CHECK(field.GetPropertyIndex(PROPERTY_NAME_ENABLE_SELECTION) == TextField::Property::ENABLE_SELECTION);
583   DALI_TEST_CHECK(field.GetPropertyIndex(PROPERTY_NAME_PLACEHOLDER) == TextField::Property::PLACEHOLDER);
584   DALI_TEST_CHECK(field.GetPropertyIndex(PROPERTY_NAME_ELLIPSIS) == TextField::Property::ELLIPSIS);
585   DALI_TEST_CHECK(field.GetPropertyIndex(PROPERTY_NAME_FONT_SIZE_SCALE) == DevelTextField::Property::FONT_SIZE_SCALE);
586   DALI_TEST_CHECK(field.GetPropertyIndex(PROPERTY_NAME_ENABLE_FONT_SIZE_SCALE) == DevelTextField::Property::ENABLE_FONT_SIZE_SCALE);
587   DALI_TEST_CHECK(field.GetPropertyIndex(PROPERTY_NAME_ENABLE_SHIFT_SELECTION) == DevelTextField::Property::ENABLE_SHIFT_SELECTION);
588   DALI_TEST_CHECK(field.GetPropertyIndex(PROPERTY_NAME_ENABLE_GRAB_HANDLE) == DevelTextField::Property::ENABLE_GRAB_HANDLE);
589   DALI_TEST_CHECK(field.GetPropertyIndex(PROPERTY_NAME_MATCH_SYSTEM_LANGUAGE_DIRECTION) == DevelTextField::Property::MATCH_SYSTEM_LANGUAGE_DIRECTION);
590   DALI_TEST_CHECK(field.GetPropertyIndex(PROPERTY_NAME_ENABLE_GRAB_HANDLE_POPUP) == DevelTextField::Property::ENABLE_GRAB_HANDLE_POPUP);
591   DALI_TEST_CHECK(field.GetPropertyIndex(PROPERTY_NAME_BACKGROUND) == DevelTextField::Property::BACKGROUND);
592   DALI_TEST_CHECK(field.GetPropertyIndex(PROPERTY_NAME_GRAB_HANDLE_COLOR) == DevelTextField::Property::GRAB_HANDLE_COLOR);
593   DALI_TEST_CHECK(field.GetPropertyIndex(PROPERTY_NAME_INPUT_FILTER) == DevelTextField::Property::INPUT_FILTER);
594   DALI_TEST_CHECK(field.GetPropertyIndex(PROPERTY_NAME_STRIKETHROUGH) == DevelTextField::Property::STRIKETHROUGH);
595   DALI_TEST_CHECK(field.GetPropertyIndex(PROPERTY_NAME_INPUT_STRIKETHROUGH) == DevelTextField::Property::INPUT_STRIKETHROUGH);
596   DALI_TEST_CHECK(field.GetPropertyIndex(PROPERTY_NAME_SELECTION_POPUP_STYLE) == DevelTextField::Property::SELECTION_POPUP_STYLE);
597
598   END_TEST;
599 }
600
601 bool SetPropertyMapRetrieved(TextField& field, const Property::Index property, const std::string mapKey, const std::string mapValue)
602 {
603   bool          result = false;
604   Property::Map imageMap;
605   imageMap[mapKey] = mapValue;
606
607   field.SetProperty(property, imageMap);
608   Property::Value propValue = field.GetProperty(property);
609   Property::Map*  resultMap = propValue.GetMap();
610
611   if(resultMap->Find(mapKey)->Get<std::string>() == mapValue)
612   {
613     result = true;
614   }
615
616   return result;
617 }
618
619 // Positive test case for a method
620 int UtcDaliTextFieldSetPropertyP(void)
621 {
622   ToolkitTestApplication application;
623   tet_infoline(" UtcDaliToolkitTextFieldSetPropertyP");
624   TextField field = TextField::New();
625   DALI_TEST_CHECK(field);
626   application.GetScene().Add(field);
627
628   // Note - we can't check the defaults since the stylesheets are platform-specific
629
630   // Check the render backend property.
631   field.SetProperty(DevelTextField::Property::RENDERING_BACKEND, DevelText::RENDERING_SHARED_ATLAS);
632   DALI_TEST_EQUALS((DevelText::RenderingType)field.GetProperty<int>(DevelTextField::Property::RENDERING_BACKEND), DevelText::RENDERING_SHARED_ATLAS, TEST_LOCATION);
633
634   field.SetProperty(DevelTextField::Property::RENDERING_BACKEND, DevelText::RENDERING_VECTOR_BASED);
635   DALI_TEST_EQUALS((DevelText::RenderingType)field.GetProperty<int>(DevelTextField::Property::RENDERING_BACKEND), DevelText::RENDERING_VECTOR_BASED, TEST_LOCATION);
636
637   // Check text property.
638   field.SetProperty(TextField::Property::TEXT, "Setting Text");
639   DALI_TEST_EQUALS(field.GetProperty<std::string>(TextField::Property::TEXT), std::string("Setting Text"), TEST_LOCATION);
640
641   // Check placeholder text properties.
642   field.SetProperty(TextField::Property::PLACEHOLDER_TEXT, "Setting Placeholder Text");
643   DALI_TEST_EQUALS(field.GetProperty<std::string>(TextField::Property::PLACEHOLDER_TEXT), std::string("Setting Placeholder Text"), TEST_LOCATION);
644
645   field.SetProperty(TextField::Property::PLACEHOLDER_TEXT_FOCUSED, "Setting Placeholder Text Focused");
646   DALI_TEST_EQUALS(field.GetProperty<std::string>(TextField::Property::PLACEHOLDER_TEXT_FOCUSED), std::string("Setting Placeholder Text Focused"), TEST_LOCATION);
647
648   // Check font properties.
649   field.SetProperty(TextField::Property::FONT_FAMILY, "Setting font family");
650   DALI_TEST_EQUALS(field.GetProperty<std::string>(TextField::Property::FONT_FAMILY), std::string("Setting font family"), TEST_LOCATION);
651
652   Property::Map    fontStyleMapSet;
653   Property::Map    fontStyleMapGet;
654   Property::Value* slantValue = NULL;
655
656   fontStyleMapSet.Insert("weight", "bold");
657   fontStyleMapSet.Insert("width", "condensed");
658   fontStyleMapSet.Insert("slant", "italic");
659   field.SetProperty(TextField::Property::FONT_STYLE, fontStyleMapSet);
660
661   fontStyleMapGet = field.GetProperty<Property::Map>(TextField::Property::FONT_STYLE);
662   DALI_TEST_EQUALS(fontStyleMapGet.Count(), fontStyleMapSet.Count(), TEST_LOCATION);
663   DALI_TEST_EQUALS(DaliTestCheckMaps(fontStyleMapGet, fontStyleMapSet), true, TEST_LOCATION);
664
665   field.SetProperty(TextField::Property::POINT_SIZE, 10.f);
666   DALI_TEST_EQUALS(field.GetProperty<float>(TextField::Property::POINT_SIZE), 10.f, Math::MACHINE_EPSILON_1000, TEST_LOCATION);
667
668   field.SetProperty(DevelTextField::Property::FONT_SIZE_SCALE, 2.5f);
669   DALI_TEST_EQUALS(field.GetProperty<float>(DevelTextField::Property::FONT_SIZE_SCALE), 2.5f, Math::MACHINE_EPSILON_1000, TEST_LOCATION);
670   field.SetProperty(DevelTextField::Property::FONT_SIZE_SCALE, 1.0f);
671
672   field.SetProperty(DevelTextField::Property::ENABLE_FONT_SIZE_SCALE, false);
673   DALI_TEST_EQUALS(field.GetProperty<bool>(DevelTextField::Property::ENABLE_FONT_SIZE_SCALE), false, TEST_LOCATION);
674   field.SetProperty(DevelTextField::Property::ENABLE_FONT_SIZE_SCALE, true);
675
676   // Reset font style.
677   fontStyleMapSet.Clear();
678   fontStyleMapSet.Insert("weight", "normal");
679   fontStyleMapSet.Insert("slant", "oblique");
680   field.SetProperty(TextField::Property::FONT_STYLE, fontStyleMapSet);
681
682   fontStyleMapGet = field.GetProperty<Property::Map>(TextField::Property::FONT_STYLE);
683   DALI_TEST_EQUALS(fontStyleMapGet.Count(), fontStyleMapSet.Count(), TEST_LOCATION);
684   DALI_TEST_EQUALS(DaliTestCheckMaps(fontStyleMapGet, fontStyleMapSet), true, TEST_LOCATION);
685
686   fontStyleMapSet.Clear();
687   fontStyleMapSet.Insert("slant", "roman");
688   field.SetProperty(TextField::Property::FONT_STYLE, fontStyleMapSet);
689   fontStyleMapGet = field.GetProperty<Property::Map>(TextField::Property::FONT_STYLE);
690
691   // Replace 'roman' for 'normal'.
692   slantValue = fontStyleMapGet.Find("slant");
693   if(NULL != slantValue)
694   {
695     if("normal" == slantValue->Get<std::string>())
696     {
697       fontStyleMapGet["slant"] = "roman";
698     }
699   }
700   DALI_TEST_EQUALS(fontStyleMapGet.Count(), fontStyleMapSet.Count(), TEST_LOCATION);
701   DALI_TEST_EQUALS(DaliTestCheckMaps(fontStyleMapGet, fontStyleMapSet), true, TEST_LOCATION);
702
703   fontStyleMapSet.Clear();
704
705   field.SetProperty(TextField::Property::FONT_STYLE, fontStyleMapSet);
706   fontStyleMapGet = field.GetProperty<Property::Map>(TextField::Property::FONT_STYLE);
707   DALI_TEST_EQUALS(fontStyleMapGet.Count(), fontStyleMapSet.Count(), TEST_LOCATION);
708   DALI_TEST_EQUALS(DaliTestCheckMaps(fontStyleMapGet, fontStyleMapSet), true, TEST_LOCATION);
709
710   // Check that the MAX_LENGTH property can be correctly set
711   const int maxNumberOfCharacters = 20;
712   field.SetProperty(TextField::Property::MAX_LENGTH, maxNumberOfCharacters);
713   DALI_TEST_EQUALS(field.GetProperty<int>(TextField::Property::MAX_LENGTH), maxNumberOfCharacters, TEST_LOCATION);
714
715   // Check exceed policy
716   field.SetProperty(TextField::Property::EXCEED_POLICY, Dali::Toolkit::TextField::EXCEED_POLICY_CLIP);
717   DALI_TEST_EQUALS(field.GetProperty<int>(TextField::Property::EXCEED_POLICY), static_cast<int>(Dali::Toolkit::TextField::EXCEED_POLICY_CLIP), TEST_LOCATION);
718   field.SetProperty(TextField::Property::EXCEED_POLICY, Dali::Toolkit::TextField::EXCEED_POLICY_ORIGINAL);
719   DALI_TEST_EQUALS(field.GetProperty<int>(TextField::Property::EXCEED_POLICY), static_cast<int>(Dali::Toolkit::TextField::EXCEED_POLICY_ORIGINAL), TEST_LOCATION);
720
721   // Check that the Alignment properties can be correctly set
722   field.SetProperty(TextField::Property::HORIZONTAL_ALIGNMENT, "END");
723   DALI_TEST_EQUALS(field.GetProperty<std::string>(TextField::Property::HORIZONTAL_ALIGNMENT), "END", TEST_LOCATION);
724   field.SetProperty(TextField::Property::VERTICAL_ALIGNMENT, "CENTER");
725   DALI_TEST_EQUALS(field.GetProperty<std::string>(TextField::Property::VERTICAL_ALIGNMENT), "CENTER", TEST_LOCATION);
726
727   // Check text's color property
728   field.SetProperty(TextField::Property::TEXT_COLOR, Color::WHITE);
729   DALI_TEST_EQUALS(field.GetProperty<Vector4>(TextField::Property::TEXT_COLOR), Color::WHITE, TEST_LOCATION);
730
731   // Check placeholder text's color property.
732   field.SetProperty(TextField::Property::PLACEHOLDER_TEXT_COLOR, Color::RED);
733   DALI_TEST_EQUALS(field.GetProperty<Vector4>(TextField::Property::PLACEHOLDER_TEXT_COLOR), Color::RED, TEST_LOCATION);
734
735   // Check cursor properties
736   field.SetProperty(TextField::Property::PRIMARY_CURSOR_COLOR, Color::RED);
737   DALI_TEST_EQUALS(field.GetProperty<Vector4>(TextField::Property::PRIMARY_CURSOR_COLOR), Color::RED, TEST_LOCATION);
738   field.SetProperty(TextField::Property::SECONDARY_CURSOR_COLOR, Color::BLUE);
739   DALI_TEST_EQUALS(field.GetProperty<Vector4>(TextField::Property::SECONDARY_CURSOR_COLOR), Color::BLUE, TEST_LOCATION);
740
741   field.SetProperty(TextField::Property::ENABLE_CURSOR_BLINK, false);
742   DALI_TEST_EQUALS(field.GetProperty<bool>(TextField::Property::ENABLE_CURSOR_BLINK), false, TEST_LOCATION);
743   field.SetProperty(TextField::Property::CURSOR_BLINK_INTERVAL, 1.f);
744   DALI_TEST_EQUALS(field.GetProperty<float>(TextField::Property::CURSOR_BLINK_INTERVAL), 1.f, Math::MACHINE_EPSILON_1000, TEST_LOCATION);
745   field.SetProperty(TextField::Property::CURSOR_BLINK_DURATION, 10.f);
746   DALI_TEST_EQUALS(field.GetProperty<float>(TextField::Property::CURSOR_BLINK_DURATION), 10.f, Math::MACHINE_EPSILON_1000, TEST_LOCATION);
747   field.SetProperty(TextField::Property::CURSOR_WIDTH, 1);
748   DALI_TEST_EQUALS(field.GetProperty<int>(TextField::Property::CURSOR_WIDTH), 1, TEST_LOCATION);
749
750   // Check scroll properties.
751   field.SetProperty(TextField::Property::SCROLL_THRESHOLD, 1.f);
752   DALI_TEST_EQUALS(field.GetProperty<float>(TextField::Property::SCROLL_THRESHOLD), 1.f, Math::MACHINE_EPSILON_1000, TEST_LOCATION);
753   field.SetProperty(TextField::Property::SCROLL_SPEED, 100.f);
754   DALI_TEST_EQUALS(field.GetProperty<float>(TextField::Property::SCROLL_SPEED), 100.f, Math::MACHINE_EPSILON_1000, TEST_LOCATION);
755
756   // Check handle images
757   field.SetProperty(TextField::Property::GRAB_HANDLE_IMAGE, "image1");
758   DALI_TEST_EQUALS(field.GetProperty<std::string>(TextField::Property::GRAB_HANDLE_IMAGE), "image1", TEST_LOCATION);
759   field.SetProperty(TextField::Property::GRAB_HANDLE_PRESSED_IMAGE, "image2");
760   DALI_TEST_EQUALS(field.GetProperty<std::string>(TextField::Property::GRAB_HANDLE_PRESSED_IMAGE), "image2", TEST_LOCATION);
761   field.SetProperty(TextField::Property::SELECTION_HANDLE_IMAGE_LEFT, "image3");
762
763   // Check handle images
764   DALI_TEST_CHECK(SetPropertyMapRetrieved(field, TextField::Property::SELECTION_HANDLE_IMAGE_LEFT, "filename", "leftHandleImage"));
765   DALI_TEST_CHECK(SetPropertyMapRetrieved(field, TextField::Property::SELECTION_HANDLE_IMAGE_RIGHT, "filename", "rightHandleImage"));
766   DALI_TEST_CHECK(SetPropertyMapRetrieved(field, TextField::Property::SELECTION_HANDLE_PRESSED_IMAGE_LEFT, "filename", "leftHandleImagePressed"));
767   DALI_TEST_CHECK(SetPropertyMapRetrieved(field, TextField::Property::SELECTION_HANDLE_PRESSED_IMAGE_RIGHT, "filename", "rightHandleImagePressed"));
768   DALI_TEST_CHECK(SetPropertyMapRetrieved(field, TextField::Property::SELECTION_HANDLE_MARKER_IMAGE_LEFT, "filename", "leftHandleMarkerImage"));
769   DALI_TEST_CHECK(SetPropertyMapRetrieved(field, TextField::Property::SELECTION_HANDLE_MARKER_IMAGE_RIGHT, "filename", "rightHandleMarkerImage"));
770
771   // Check the selection popup style
772   const Vector2 popupMaxSize(200.0f, 300.0f);
773   const Vector2 optionDividerSize(30.0f, 5.0f);
774   const Vector4 optionDividerPadding(20.0f, 20.0f, 10.0f, 10.0f);
775   const Vector4 labelPadding(5.0f, 5.0f, 50.0f, 25.0f);
776
777   Property::Map selectionPopupStyle;
778   selectionPopupStyle.Insert(TextSelectionPopup::Property::POPUP_MAX_SIZE, popupMaxSize);
779   selectionPopupStyle.Insert(TextSelectionPopup::Property::OPTION_DIVIDER_SIZE, optionDividerSize);
780   selectionPopupStyle.Insert(TextSelectionPopup::Property::OPTION_DIVIDER_PADDING, optionDividerPadding);
781   selectionPopupStyle.Insert(TextSelectionPopup::Property::LABEL_PADDING, labelPadding);
782
783   field.SetProperty(DevelTextField::Property::SELECTION_POPUP_STYLE, selectionPopupStyle);
784
785   Property::Map selectionPopupStyleGet;
786   selectionPopupStyleGet = field.GetProperty<Property::Map>(DevelTextField::Property::SELECTION_POPUP_STYLE);
787
788   Property::Value* popupValue;
789   popupValue = selectionPopupStyleGet.Find(TextSelectionPopup::Property::POPUP_MAX_SIZE);
790   DALI_TEST_CHECK(NULL != popupValue);
791   if(popupValue)
792   {
793     Vector2 popupMaxSizeGet;
794     popupValue->Get(popupMaxSizeGet);
795     DALI_TEST_EQUALS(popupMaxSizeGet, popupMaxSize, TEST_LOCATION);
796   }
797
798   popupValue = selectionPopupStyleGet.Find(TextSelectionPopup::Property::OPTION_DIVIDER_SIZE);
799   DALI_TEST_CHECK(NULL != popupValue);
800   if(popupValue)
801   {
802     Vector2 optionDividerSizeGet;
803     popupValue->Get(optionDividerSizeGet);
804     DALI_TEST_EQUALS(optionDividerSizeGet, optionDividerSize, TEST_LOCATION);
805   }
806
807   popupValue = selectionPopupStyleGet.Find(TextSelectionPopup::Property::OPTION_DIVIDER_PADDING);
808   DALI_TEST_CHECK(NULL != popupValue);
809   if(popupValue)
810   {
811     Vector4 optionDividerPaddingGet;
812     popupValue->Get(optionDividerPaddingGet);
813     DALI_TEST_EQUALS(optionDividerPaddingGet, optionDividerPadding, TEST_LOCATION);
814   }
815
816   popupValue = selectionPopupStyleGet.Find(TextSelectionPopup::Property::LABEL_PADDING);
817   DALI_TEST_CHECK(NULL != popupValue);
818   if(popupValue)
819   {
820     Vector4 labelPaddingGet;
821     popupValue->Get(labelPaddingGet);
822     DALI_TEST_EQUALS(labelPaddingGet, labelPadding, TEST_LOCATION);
823   }
824
825   // Reset selection popup style
826   selectionPopupStyle.Clear();
827   field.SetProperty(DevelTextField::Property::SELECTION_POPUP_STYLE, selectionPopupStyle);
828
829   // Check the highlight color
830   field.SetProperty(TextField::Property::SELECTION_HIGHLIGHT_COLOR, Color::GREEN);
831   DALI_TEST_EQUALS(field.GetProperty<Vector4>(TextField::Property::SELECTION_HIGHLIGHT_COLOR), Color::GREEN, TEST_LOCATION);
832
833   // Decoration bounding box
834   field.SetProperty(TextField::Property::DECORATION_BOUNDING_BOX, Rect<int>(0, 0, 1, 1));
835   DALI_TEST_EQUALS(field.GetProperty<Rect<int> >(TextField::Property::DECORATION_BOUNDING_BOX), Rect<int>(0, 0, 1, 1), TEST_LOCATION);
836
837   // Check the input method setting
838   Property::Map                   propertyMap;
839   InputMethod::PanelLayout::Type  panelLayout    = InputMethod::PanelLayout::NUMBER;
840   InputMethod::AutoCapital::Type  autoCapital    = InputMethod::AutoCapital::WORD;
841   InputMethod::ButtonAction::Type buttonAction   = InputMethod::ButtonAction::GO;
842   int                             inputVariation = 1;
843   propertyMap["PANEL_LAYOUT"]                    = panelLayout;
844   propertyMap["AUTO_CAPITALIZE"]                 = autoCapital;
845   propertyMap["BUTTON_ACTION"]                   = buttonAction;
846   propertyMap["VARIATION"]                       = inputVariation;
847   field.SetProperty(TextField::Property::INPUT_METHOD_SETTINGS, propertyMap);
848
849   Property::Value value = field.GetProperty(TextField::Property::INPUT_METHOD_SETTINGS);
850   Property::Map   map;
851   DALI_TEST_CHECK(value.Get(map));
852
853   int layout = 0;
854   DALI_TEST_CHECK(map["PANEL_LAYOUT"].Get(layout));
855   DALI_TEST_EQUALS(static_cast<int>(panelLayout), layout, TEST_LOCATION);
856
857   int capital = 0;
858   DALI_TEST_CHECK(map["AUTO_CAPITALIZE"].Get(capital));
859   DALI_TEST_EQUALS(static_cast<int>(autoCapital), capital, TEST_LOCATION);
860
861   int action = 0;
862   DALI_TEST_CHECK(map["BUTTON_ACTION"].Get(action));
863   DALI_TEST_EQUALS(static_cast<int>(buttonAction), action, TEST_LOCATION);
864
865   int variation = 0;
866   DALI_TEST_CHECK(map["VARIATION"].Get(variation));
867   DALI_TEST_EQUALS(inputVariation, variation, TEST_LOCATION);
868
869   // Check input color property.
870   field.SetProperty(TextField::Property::INPUT_COLOR, Color::YELLOW);
871   DALI_TEST_EQUALS(field.GetProperty<Vector4>(TextField::Property::INPUT_COLOR), Color::YELLOW, TEST_LOCATION);
872
873   // Check the enable markup property.
874   DALI_TEST_CHECK(!field.GetProperty<bool>(TextField::Property::ENABLE_MARKUP));
875   field.SetProperty(TextField::Property::ENABLE_MARKUP, true);
876   DALI_TEST_CHECK(field.GetProperty<bool>(TextField::Property::ENABLE_MARKUP));
877
878   // Check input font properties.
879   field.SetProperty(TextField::Property::INPUT_FONT_FAMILY, "Setting input font family");
880   DALI_TEST_EQUALS(field.GetProperty<std::string>(TextField::Property::INPUT_FONT_FAMILY), "Setting input font family", TEST_LOCATION);
881
882   fontStyleMapSet.Clear();
883   fontStyleMapSet.Insert("weight", "bold");
884   fontStyleMapSet.Insert("width", "condensed");
885   fontStyleMapSet.Insert("slant", "italic");
886
887   field.SetProperty(TextField::Property::INPUT_FONT_STYLE, fontStyleMapSet);
888   fontStyleMapGet = field.GetProperty<Property::Map>(TextField::Property::INPUT_FONT_STYLE);
889   DALI_TEST_EQUALS(fontStyleMapGet.Count(), fontStyleMapSet.Count(), TEST_LOCATION);
890   DALI_TEST_EQUALS(DaliTestCheckMaps(fontStyleMapGet, fontStyleMapSet), true, TEST_LOCATION);
891
892   field.SetProperty(TextField::Property::INPUT_POINT_SIZE, 12.f);
893   DALI_TEST_EQUALS(field.GetProperty<float>(TextField::Property::INPUT_POINT_SIZE), 12.f, Math::MACHINE_EPSILON_1000, TEST_LOCATION);
894
895   // Reset input font style.
896   fontStyleMapSet.Clear();
897   fontStyleMapSet.Insert("weight", "normal");
898   fontStyleMapSet.Insert("slant", "oblique");
899
900   field.SetProperty(TextField::Property::INPUT_FONT_STYLE, fontStyleMapSet);
901   fontStyleMapGet = field.GetProperty<Property::Map>(TextField::Property::INPUT_FONT_STYLE);
902   DALI_TEST_EQUALS(fontStyleMapGet.Count(), fontStyleMapSet.Count(), TEST_LOCATION);
903   DALI_TEST_EQUALS(DaliTestCheckMaps(fontStyleMapGet, fontStyleMapSet), true, TEST_LOCATION);
904
905   fontStyleMapSet.Clear();
906   fontStyleMapSet.Insert("slant", "roman");
907
908   field.SetProperty(TextField::Property::INPUT_FONT_STYLE, fontStyleMapSet);
909   fontStyleMapGet = field.GetProperty<Property::Map>(TextField::Property::INPUT_FONT_STYLE);
910
911   // Replace 'roman' for 'normal'.
912   slantValue = fontStyleMapGet.Find("slant");
913   if(NULL != slantValue)
914   {
915     if("normal" == slantValue->Get<std::string>())
916     {
917       fontStyleMapGet["slant"] = "roman";
918     }
919   }
920   DALI_TEST_EQUALS(fontStyleMapGet.Count(), fontStyleMapSet.Count(), TEST_LOCATION);
921   DALI_TEST_EQUALS(DaliTestCheckMaps(fontStyleMapGet, fontStyleMapSet), true, TEST_LOCATION);
922
923   fontStyleMapSet.Clear();
924
925   field.SetProperty(TextField::Property::INPUT_FONT_STYLE, fontStyleMapSet);
926   fontStyleMapGet = field.GetProperty<Property::Map>(TextField::Property::INPUT_FONT_STYLE);
927   DALI_TEST_EQUALS(fontStyleMapGet.Count(), fontStyleMapSet.Count(), TEST_LOCATION);
928   DALI_TEST_EQUALS(DaliTestCheckMaps(fontStyleMapGet, fontStyleMapSet), true, TEST_LOCATION);
929
930   Property::Map strikethroughMapSet;
931   Property::Map strikethroughMapGet;
932
933   strikethroughMapSet.Insert("enable", true);
934   strikethroughMapSet.Insert("color", Color::RED);
935   strikethroughMapSet.Insert("height", 2.0f);
936
937   // Check the strikethrough property
938   field.SetProperty(DevelTextField::Property::STRIKETHROUGH, strikethroughMapSet);
939
940   strikethroughMapGet = field.GetProperty<Property::Map>(DevelTextField::Property::STRIKETHROUGH);
941   DALI_TEST_EQUALS(strikethroughMapGet.Count(), strikethroughMapSet.Count(), TEST_LOCATION);
942   DALI_TEST_EQUALS(DaliTestCheckMaps(strikethroughMapGet, strikethroughMapSet), true, TEST_LOCATION);
943
944   // Check the input strikethrough property
945   field.SetProperty(DevelTextField::Property::INPUT_STRIKETHROUGH, "Strikethrough input properties");
946   DALI_TEST_EQUALS(field.GetProperty<std::string>(DevelTextField::Property::INPUT_STRIKETHROUGH), std::string("Strikethrough input properties"), TEST_LOCATION);
947
948   Property::Map underlineMapSet;
949   Property::Map underlineMapGet;
950
951   underlineMapSet.Insert("enable", true);
952   underlineMapSet.Insert("color", Color::RED);
953   underlineMapSet.Insert("height", 1);
954   underlineMapSet.Insert("type", Text::Underline::SOLID);
955   underlineMapSet.Insert("dashWidth", 2);
956   underlineMapSet.Insert("dashGap", 1);
957
958   // Check the underline property
959   field.SetProperty(TextField::Property::UNDERLINE, underlineMapSet);
960
961   underlineMapGet = field.GetProperty<Property::Map>(TextField::Property::UNDERLINE);
962   DALI_TEST_EQUALS(underlineMapGet.Count(), underlineMapSet.Count(), TEST_LOCATION);
963   DALI_TEST_EQUALS(DaliTestCheckMaps(underlineMapGet, underlineMapSet), true, TEST_LOCATION);
964
965   // Render and notify
966   application.SendNotification();
967   application.Render();
968
969   underlineMapSet.Clear();
970   underlineMapGet.Clear();
971
972   underlineMapSet.Insert("enable", true);
973   underlineMapSet.Insert("color", Color::BLUE);
974   underlineMapSet.Insert("height", 1);
975   underlineMapSet.Insert("type", Text::Underline::DASHED);
976   underlineMapSet.Insert("dashWidth", 4);
977   underlineMapSet.Insert("dashGap", 2);
978
979   // Check the dashed underline property
980   field.SetProperty(TextField::Property::UNDERLINE, underlineMapSet);
981
982   underlineMapGet = field.GetProperty<Property::Map>(TextField::Property::UNDERLINE);
983   DALI_TEST_EQUALS(underlineMapGet.Count(), underlineMapSet.Count(), TEST_LOCATION);
984   DALI_TEST_EQUALS(DaliTestCheckMaps(underlineMapGet, underlineMapSet), true, TEST_LOCATION);
985
986   // Render and notify
987   application.SendNotification();
988   application.Render();
989
990   underlineMapSet.Clear();
991   underlineMapGet.Clear();
992
993   underlineMapSet.Insert("enable", true);
994   underlineMapSet.Insert("color", Color::BLUE);
995   underlineMapSet.Insert("height", 4);
996   underlineMapSet.Insert("type", Text::Underline::DOUBLE);
997   underlineMapSet.Insert("dashWidth", 4);
998   underlineMapSet.Insert("dashGap", 2);
999
1000   // Check the dashed underline property
1001   field.SetProperty(TextField::Property::UNDERLINE, underlineMapSet);
1002
1003   underlineMapGet = field.GetProperty<Property::Map>(TextField::Property::UNDERLINE);
1004   DALI_TEST_EQUALS(underlineMapGet.Count(), underlineMapSet.Count(), TEST_LOCATION);
1005   DALI_TEST_EQUALS(DaliTestCheckMaps(underlineMapGet, underlineMapSet), true, TEST_LOCATION);
1006
1007   // Render and notify
1008   application.SendNotification();
1009   application.Render();
1010
1011   underlineMapSet.Clear();
1012   underlineMapGet.Clear();
1013
1014   // Check the input underline property
1015   field.SetProperty(TextField::Property::INPUT_UNDERLINE, "Underline input properties");
1016   DALI_TEST_EQUALS(field.GetProperty<std::string>(TextField::Property::INPUT_UNDERLINE), std::string("Underline input properties"), TEST_LOCATION);
1017
1018   // Check the shadow property
1019   Property::Map shadowMapSet;
1020   Property::Map shadowMapGet;
1021
1022   shadowMapSet.Insert("color", Color::GREEN);
1023   shadowMapSet.Insert("offset", Vector2(2.0f, 2.0f));
1024   shadowMapSet.Insert("blurRadius", 3.0f);
1025
1026   field.SetProperty(TextField::Property::SHADOW, shadowMapSet);
1027
1028   shadowMapGet = field.GetProperty<Property::Map>(TextField::Property::SHADOW);
1029   DALI_TEST_EQUALS(shadowMapGet.Count(), shadowMapSet.Count(), TEST_LOCATION);
1030   DALI_TEST_EQUALS(DaliTestCheckMaps(shadowMapGet, shadowMapSet), true, TEST_LOCATION);
1031
1032   // Check the input shadow property
1033   field.SetProperty(TextField::Property::INPUT_SHADOW, "Shadow input properties");
1034   DALI_TEST_EQUALS(field.GetProperty<std::string>(TextField::Property::INPUT_SHADOW), std::string("Shadow input properties"), TEST_LOCATION);
1035
1036   // Check the emboss property
1037   field.SetProperty(TextField::Property::EMBOSS, "Emboss properties");
1038   DALI_TEST_EQUALS(field.GetProperty<std::string>(TextField::Property::EMBOSS), std::string("Emboss properties"), TEST_LOCATION);
1039
1040   // Check the input emboss property
1041   field.SetProperty(TextField::Property::INPUT_EMBOSS, "Emboss input properties");
1042   DALI_TEST_EQUALS(field.GetProperty<std::string>(TextField::Property::INPUT_EMBOSS), std::string("Emboss input properties"), TEST_LOCATION);
1043
1044   // Check the outline property
1045
1046   // Test string type first
1047   // This is purely to maintain backward compatibility, but we don't support string as the outline property type.
1048   field.SetProperty(TextField::Property::OUTLINE, "Outline properties");
1049   DALI_TEST_EQUALS(field.GetProperty<std::string>(TextField::Property::OUTLINE), std::string("Outline properties"), TEST_LOCATION);
1050
1051   // Then test the property map type
1052   Property::Map outlineMapSet;
1053   Property::Map outlineMapGet;
1054
1055   outlineMapSet["color"] = Color::RED;
1056   outlineMapSet["width"] = 2.0f;
1057
1058   field.SetProperty(TextField::Property::OUTLINE, outlineMapSet);
1059
1060   outlineMapGet = field.GetProperty<Property::Map>(TextField::Property::OUTLINE);
1061   DALI_TEST_EQUALS(outlineMapGet.Count(), outlineMapSet.Count(), TEST_LOCATION);
1062   DALI_TEST_EQUALS(DaliTestCheckMaps(outlineMapGet, outlineMapSet), true, TEST_LOCATION);
1063
1064   // Check the input outline property
1065   field.SetProperty(TextField::Property::INPUT_OUTLINE, "Outline input properties");
1066   DALI_TEST_EQUALS(field.GetProperty<std::string>(TextField::Property::INPUT_OUTLINE), std::string("Outline input properties"), TEST_LOCATION);
1067
1068   // Check the hidden input settings property
1069   Property::Map hiddenMapSet;
1070   Property::Map hiddenMapGet;
1071   hiddenMapSet[HiddenInput::Property::MODE]                         = HiddenInput::Mode::HIDE_ALL;
1072   hiddenMapSet[HiddenInput::Property::SHOW_LAST_CHARACTER_DURATION] = 2;
1073   hiddenMapSet[HiddenInput::Property::SUBSTITUTE_COUNT]             = 4;
1074   hiddenMapSet[HiddenInput::Property::SUBSTITUTE_CHARACTER]         = 0x23;
1075   field.SetProperty(TextField::Property::HIDDEN_INPUT_SETTINGS, hiddenMapSet);
1076
1077   hiddenMapGet = field.GetProperty<Property::Map>(TextField::Property::HIDDEN_INPUT_SETTINGS);
1078   DALI_TEST_EQUALS(hiddenMapSet.Count(), hiddenMapGet.Count(), TEST_LOCATION);
1079   DALI_TEST_EQUALS(DaliTestCheckMaps(hiddenMapSet, hiddenMapGet), true, TEST_LOCATION);
1080
1081   // Check the pixel size of font
1082   field.SetProperty(TextField::Property::PIXEL_SIZE, 20.f);
1083   DALI_TEST_EQUALS(field.GetProperty<float>(TextField::Property::PIXEL_SIZE), 20.f, Math::MACHINE_EPSILON_1000, TEST_LOCATION);
1084
1085   // Check the enable selection property
1086   field.SetProperty(TextField::Property::ENABLE_SELECTION, false);
1087   DALI_TEST_EQUALS(field.GetProperty<bool>(TextField::Property::ENABLE_SELECTION), false, TEST_LOCATION);
1088
1089   // Check the placeholder property with pixel size
1090   Property::Map placeholderPixelSizeMapSet;
1091   Property::Map placeholderPixelSizeMapGet;
1092   Property::Map placeholderFontstyleMap;
1093   placeholderPixelSizeMapSet["text"]        = "Setting Placeholder Text";
1094   placeholderPixelSizeMapSet["textFocused"] = "Setting Placeholder Text Focused";
1095   placeholderPixelSizeMapSet["color"]       = Color::BLUE;
1096   placeholderPixelSizeMapSet["fontFamily"]  = "Arial";
1097   placeholderPixelSizeMapSet["pixelSize"]   = 15.0f;
1098   placeholderPixelSizeMapSet["ellipsis"]    = true;
1099
1100   placeholderFontstyleMap.Insert("weight", "bold");
1101   placeholderPixelSizeMapSet["placeholderFontStyle"] = placeholderFontstyleMap;
1102   field.SetProperty(TextField::Property::PLACEHOLDER, placeholderPixelSizeMapSet);
1103
1104   placeholderPixelSizeMapGet = field.GetProperty<Property::Map>(TextField::Property::PLACEHOLDER);
1105   DALI_TEST_EQUALS(placeholderPixelSizeMapGet.Count(), placeholderPixelSizeMapSet.Count(), TEST_LOCATION);
1106
1107   tet_infoline("Test Placeholder settings set as strings is converted correctly to Property Index key and holds set value");
1108   Property::Map placeholderConversionMap;
1109   placeholderConversionMap[Text::PlaceHolder::Property::TEXT]         = placeholderPixelSizeMapSet["text"];
1110   placeholderConversionMap[Text::PlaceHolder::Property::TEXT_FOCUSED] = placeholderPixelSizeMapSet["textFocused"];
1111   placeholderConversionMap[Text::PlaceHolder::Property::COLOR]        = placeholderPixelSizeMapSet["color"];
1112   placeholderConversionMap[Text::PlaceHolder::Property::FONT_STYLE]   = placeholderPixelSizeMapSet["fontStyle"];
1113   placeholderConversionMap[Text::PlaceHolder::Property::FONT_FAMILY]  = placeholderPixelSizeMapSet["fontFamily"];
1114   placeholderConversionMap[Text::PlaceHolder::Property::PIXEL_SIZE]   = placeholderPixelSizeMapSet["pixelSize"];
1115
1116   DALI_TEST_EQUALS(DaliTestCheckMaps(placeholderPixelSizeMapGet, placeholderConversionMap), true, TEST_LOCATION);
1117
1118   // Check the placeholder property with point size
1119   Property::Map placeholderMapSet;
1120   Property::Map placeholderMapGet;
1121   placeholderMapSet["text"]        = "Setting Placeholder Text";
1122   placeholderMapSet["textFocused"] = "Setting Placeholder Text Focused";
1123   placeholderMapSet["color"]       = Color::RED;
1124   placeholderMapSet["fontFamily"]  = "Arial";
1125   placeholderMapSet["pointSize"]   = 12.0f;
1126   placeholderMapSet["ellipsis"]    = false;
1127
1128   // Check the placeholder font style property
1129   placeholderFontstyleMap.Clear();
1130
1131   placeholderFontstyleMap.Insert("weight", "bold");
1132   placeholderFontstyleMap.Insert("width", "condensed");
1133   placeholderFontstyleMap.Insert("slant", "italic");
1134   placeholderMapSet["fontStyle"] = placeholderFontstyleMap;
1135   field.SetProperty(TextField::Property::PLACEHOLDER, placeholderMapSet);
1136
1137   placeholderMapGet = field.GetProperty<Property::Map>(TextField::Property::PLACEHOLDER);
1138   DALI_TEST_EQUALS(placeholderMapGet.Count(), placeholderMapSet.Count(), TEST_LOCATION);
1139
1140   placeholderConversionMap.Clear();
1141   placeholderConversionMap[Text::PlaceHolder::Property::TEXT]         = placeholderPixelSizeMapSet["text"];
1142   placeholderConversionMap[Text::PlaceHolder::Property::TEXT_FOCUSED] = placeholderPixelSizeMapSet["textFocused"];
1143   placeholderConversionMap[Text::PlaceHolder::Property::COLOR]        = placeholderPixelSizeMapSet["color"];
1144   placeholderConversionMap[Text::PlaceHolder::Property::FONT_STYLE]   = placeholderPixelSizeMapSet["fontStyle"];
1145   placeholderConversionMap[Text::PlaceHolder::Property::FONT_FAMILY]  = placeholderPixelSizeMapSet["fontFamily"];
1146   placeholderConversionMap[Text::PlaceHolder::Property::POINT_SIZE]   = placeholderPixelSizeMapSet["pointSize"];
1147
1148   DALI_TEST_EQUALS(DaliTestCheckMaps(placeholderMapGet, placeholderConversionMap), true, TEST_LOCATION);
1149
1150   // Reset font style.
1151   placeholderFontstyleMap.Clear();
1152   placeholderFontstyleMap.Insert("weight", "normal");
1153   placeholderFontstyleMap.Insert("slant", "oblique");
1154   placeholderMapSet["fontStyle"] = placeholderFontstyleMap;
1155   field.SetProperty(TextField::Property::PLACEHOLDER, placeholderMapSet);
1156
1157   placeholderMapGet = field.GetProperty<Property::Map>(TextField::Property::PLACEHOLDER);
1158   DALI_TEST_EQUALS(placeholderMapGet.Count(), placeholderMapSet.Count(), TEST_LOCATION);
1159
1160   placeholderConversionMap[Text::PlaceHolder::Property::FONT_STYLE] = placeholderPixelSizeMapSet["fontStyle"];
1161   DALI_TEST_EQUALS(DaliTestCheckMaps(placeholderMapGet, placeholderConversionMap), true, TEST_LOCATION);
1162
1163   placeholderFontstyleMap.Clear();
1164   placeholderFontstyleMap.Insert("slant", "roman");
1165   placeholderMapSet["fontStyle"]                                    = placeholderFontstyleMap;
1166   placeholderConversionMap[Text::PlaceHolder::Property::FONT_STYLE] = placeholderPixelSizeMapSet["fontStyle"];
1167
1168   field.SetProperty(TextField::Property::PLACEHOLDER, placeholderMapSet);
1169
1170   placeholderMapGet = field.GetProperty<Property::Map>(TextField::Property::PLACEHOLDER);
1171
1172   placeholderFontstyleMap.Clear();
1173   placeholderMapSet["fontStyle"]                                    = placeholderFontstyleMap;
1174   placeholderConversionMap[Text::PlaceHolder::Property::FONT_STYLE] = placeholderPixelSizeMapSet["fontStyle"];
1175
1176   field.SetProperty(TextField::Property::PLACEHOLDER, placeholderMapSet);
1177   placeholderMapGet = field.GetProperty<Property::Map>(TextField::Property::PLACEHOLDER);
1178   DALI_TEST_EQUALS(placeholderMapGet.Count(), placeholderMapSet.Count(), TEST_LOCATION);
1179
1180   DALI_TEST_EQUALS(DaliTestCheckMaps(placeholderMapGet, placeholderConversionMap), true, TEST_LOCATION);
1181
1182   // Check the ellipsis property
1183   DALI_TEST_CHECK(!field.GetProperty<bool>(TextField::Property::ELLIPSIS));
1184   field.SetProperty(TextField::Property::ELLIPSIS, true);
1185   DALI_TEST_CHECK(field.GetProperty<bool>(TextField::Property::ELLIPSIS));
1186
1187   field.SetProperty(Actor::Property::LAYOUT_DIRECTION, LayoutDirection::RIGHT_TO_LEFT);
1188   DALI_TEST_EQUALS(field.GetProperty<int>(Actor::Property::LAYOUT_DIRECTION), static_cast<int>(LayoutDirection::RIGHT_TO_LEFT), TEST_LOCATION);
1189
1190   // Test the ENABLE_GRAB_HANDLE_POPUP property
1191   DALI_TEST_CHECK(field.GetProperty<bool>(DevelTextField::Property::ENABLE_GRAB_HANDLE_POPUP));
1192   field.SetProperty(DevelTextField::Property::ENABLE_GRAB_HANDLE_POPUP, false);
1193   DALI_TEST_CHECK(!field.GetProperty<bool>(DevelTextField::Property::ENABLE_GRAB_HANDLE_POPUP));
1194
1195   // Check the background property
1196   field.SetProperty(DevelTextField::Property::BACKGROUND, Color::RED);
1197   DALI_TEST_EQUALS(field.GetProperty<Vector4>(DevelTextField::Property::BACKGROUND), Color::RED, TEST_LOCATION);
1198
1199   //Check handle color
1200   field.SetProperty(DevelTextField::Property::GRAB_HANDLE_COLOR, Color::GREEN);
1201   DALI_TEST_EQUALS(field.GetProperty<Vector4>(DevelTextField::Property::GRAB_HANDLE_COLOR), Color::GREEN, TEST_LOCATION);
1202
1203   // Check the input filter property
1204   Property::Map inputFilterMapSet;
1205   Property::Map inputFilterMapGet;
1206   inputFilterMapSet[InputFilter::Property::ACCEPTED] = "[\\w]";
1207   inputFilterMapSet[InputFilter::Property::REJECTED] = "[\\d]";
1208
1209   field.SetProperty(DevelTextField::Property::INPUT_FILTER, inputFilterMapSet);
1210
1211   inputFilterMapGet = field.GetProperty<Property::Map>(DevelTextField::Property::INPUT_FILTER);
1212   DALI_TEST_EQUALS(inputFilterMapGet.Count(), inputFilterMapSet.Count(), TEST_LOCATION);
1213
1214   // Clear
1215   inputFilterMapSet.Clear();
1216   field.SetProperty(DevelTextField::Property::INPUT_FILTER, inputFilterMapSet);
1217
1218   application.SendNotification();
1219   application.Render();
1220
1221   END_TEST;
1222 }
1223
1224 // Positive Atlas Text Renderer test
1225 int utcDaliTextFieldAtlasRenderP(void)
1226 {
1227   ToolkitTestApplication application;
1228   tet_infoline(" UtcDaliToolkitTextFieldAtlasRenderP");
1229   StyleManager styleManager = StyleManager::Get();
1230   styleManager.ApplyDefaultTheme();
1231   TextField field = TextField::New();
1232   DALI_TEST_CHECK(field);
1233
1234   field.SetProperty(TextField::Property::HORIZONTAL_ALIGNMENT, "CENTER");
1235
1236   application.GetGlAbstraction().SetCheckFramebufferStatusResult(GL_FRAMEBUFFER_COMPLETE);
1237
1238   application.GetScene().Add(field);
1239
1240   try
1241   {
1242     // Render some text with the shared atlas backend
1243     field.SetProperty(DevelTextField::Property::RENDERING_BACKEND, DevelText::RENDERING_SHARED_ATLAS);
1244     application.SendNotification();
1245     application.Render();
1246   }
1247   catch(...)
1248   {
1249     tet_result(TET_FAIL);
1250   }
1251   END_TEST;
1252 }
1253
1254 // Positive test for the anchorClicked signal.
1255 int utcDaliTextFieldAnchorClicked01(void)
1256 {
1257   ToolkitTestApplication application;
1258   tet_infoline(" utcDaliTextFieldAnchorClicked01");
1259   TextField field = TextField::New();
1260   DALI_TEST_CHECK(field);
1261
1262   application.GetScene().Add(field);
1263
1264   // connect to the anchor clicked signal.
1265   ConnectionTracker* testTracker = new ConnectionTracker();
1266   DevelTextField::AnchorClickedSignal(field).Connect(&TestAnchorClickedCallback);
1267   bool anchorClickedSignal = false;
1268   field.ConnectSignal(testTracker, "anchorClicked", CallbackFunctor(&anchorClickedSignal));
1269
1270   gAnchorClickedCallBackCalled = false;
1271   field.SetProperty(TextField::Property::TEXT, "<a href='https://www.tizen.org'>TIZEN</a>");
1272   field.SetProperty(TextField::Property::ENABLE_MARKUP, true);
1273   field.SetProperty(Actor::Property::SIZE, Vector2(100.f, 50.f));
1274   field.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT);
1275   field.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
1276
1277   application.SendNotification();
1278   application.Render();
1279   field.SetKeyInputFocus();
1280
1281   // Create a tap event to touch the text field.
1282   TestGenerateTap(application, 5.0f, 25.0f);
1283   application.SendNotification();
1284   application.Render();
1285
1286   DALI_TEST_CHECK(gAnchorClickedCallBackCalled);
1287   DALI_TEST_CHECK(anchorClickedSignal);
1288
1289   gAnchorClickedCallBackNotCalled = true;
1290   // Tap the outside of anchor, callback should not be called.
1291   TestGenerateTap(application, 150.f, 100.f);
1292   application.SendNotification();
1293   application.Render();
1294
1295   DALI_TEST_CHECK(gAnchorClickedCallBackNotCalled);
1296
1297   END_TEST;
1298 }
1299
1300 // Positive test for the anchorClicked signal.
1301 int utcDaliTextFieldAnchorClicked02(void)
1302 {
1303   ToolkitTestApplication application;
1304   tet_infoline(" utcDaliTextFieldAnchorClicked02");
1305   TextField field = TextField::New();
1306   DALI_TEST_CHECK(field);
1307
1308   application.GetScene().Add(field);
1309
1310   // connect to the anchor clicked signal.
1311   ConnectionTracker* testTracker = new ConnectionTracker();
1312   DevelTextField::AnchorClickedSignal(field).Connect(&TestAnchorClickedCallback);
1313   bool anchorClickedSignal = false;
1314   field.ConnectSignal(testTracker, "anchorClicked", CallbackFunctor(&anchorClickedSignal));
1315
1316   gAnchorClickedCallBackCalled = false;
1317   field.SetProperty(TextField::Property::TEXT, "<a href='https://www.tizen.org'>TIZEN</a>");
1318   field.SetProperty(TextField::Property::ENABLE_MARKUP, true);
1319   field.SetProperty(Actor::Property::SIZE, Vector2(100.f, 50.f));
1320   field.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT);
1321   field.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
1322
1323   application.SendNotification();
1324   application.Render();
1325   field.SetKeyInputFocus();
1326
1327   // Avoid a crash when core load gl resources.
1328   application.GetGlAbstraction().SetCheckFramebufferStatusResult(GL_FRAMEBUFFER_COMPLETE);
1329
1330   // Create a tap event to touch the text field.
1331   TestGenerateTap(application, 30.0f, 25.0f, 100);
1332   application.SendNotification();
1333   application.Render();
1334
1335   DALI_TEST_CHECK(gAnchorClickedCallBackCalled);
1336   DALI_TEST_CHECK(anchorClickedSignal);
1337
1338   // For coverage InsertTextAnchor, RemoveTextAnchor
1339   // first index insert
1340   field.SetProperty(TextField::Property::TEXT, "<a href='https://www.tizen.org'>TIZEN</a>");
1341   field.SetProperty(DevelTextField::Property::PRIMARY_CURSOR_POSITION, 0);
1342   application.SendNotification();
1343   application.Render();
1344
1345   application.ProcessEvent(GenerateKey("D", "", "D", KEY_D_CODE, 0, 0, Integration::KeyEvent::DOWN, "D", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
1346   application.SendNotification();
1347   application.Render();
1348
1349   gAnchorClickedCallBackCalled = false;
1350   // Create a tap event to touch the text field.
1351   TestGenerateTap(application, 30.0f, 25.0f, 700);
1352   application.SendNotification();
1353   field.SetKeyInputFocus();
1354
1355   DALI_TEST_CHECK(gAnchorClickedCallBackCalled);
1356
1357   // last index insert
1358   field.SetProperty(TextField::Property::TEXT, "<a href='https://www.tizen.org'>TIZEN</a>");
1359   field.SetProperty(DevelTextField::Property::PRIMARY_CURSOR_POSITION, 5);
1360   application.SendNotification();
1361   application.Render();
1362
1363   application.ProcessEvent(GenerateKey("D", "", "D", KEY_D_CODE, 0, 0, Integration::KeyEvent::DOWN, "D", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
1364   application.SendNotification();
1365   application.Render();
1366
1367   gAnchorClickedCallBackCalled = false;
1368   // Create a tap event to touch the text field.
1369   TestGenerateTap(application, 30.0f, 25.0f, 1300);
1370   application.SendNotification();
1371   field.SetKeyInputFocus();
1372
1373   DALI_TEST_CHECK(gAnchorClickedCallBackCalled);
1374
1375   // mid index insert
1376   field.SetProperty(TextField::Property::TEXT, "<a href='https://www.tizen.org'>TIZEN</a>");
1377   field.SetProperty(DevelTextField::Property::PRIMARY_CURSOR_POSITION, 2);
1378   application.SendNotification();
1379   application.Render();
1380
1381   application.ProcessEvent(GenerateKey("D", "", "D", KEY_D_CODE, 0, 0, Integration::KeyEvent::DOWN, "D", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
1382   application.SendNotification();
1383   application.Render();
1384
1385   gAnchorClickedCallBackCalled = false;
1386   // Create a tap event to touch the text field.
1387   TestGenerateTap(application, 30.0f, 25.0f, 1900);
1388   application.SendNotification();
1389   field.SetKeyInputFocus();
1390
1391   DALI_TEST_CHECK(gAnchorClickedCallBackCalled);
1392
1393   // first index remove
1394   field.SetProperty(TextField::Property::TEXT, "<a href='https://www.tizen.org'>TIZEN</a>");
1395   field.SetProperty(DevelTextField::Property::PRIMARY_CURSOR_POSITION, 0);
1396   application.SendNotification();
1397   application.Render();
1398
1399   application.ProcessEvent(GenerateKey("", "", "", DALI_KEY_BACKSPACE, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
1400   application.ProcessEvent(GenerateKey("Delete", "", "Delete", Dali::DevelKey::DALI_KEY_DELETE, 0, 0, Integration::KeyEvent::DOWN, "Delete", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
1401   application.SendNotification();
1402   application.Render();
1403
1404   gAnchorClickedCallBackCalled = false;
1405   // Create a tap event to touch the text field.
1406   TestGenerateTap(application, 30.0f, 25.0f, 2500);
1407   application.SendNotification();
1408   field.SetKeyInputFocus();
1409
1410   DALI_TEST_CHECK(gAnchorClickedCallBackCalled);
1411
1412   // last index remove
1413   field.SetProperty(TextField::Property::TEXT, "<a href='https://www.tizen.org'>TIZEN</a>");
1414   field.SetProperty(DevelTextField::Property::PRIMARY_CURSOR_POSITION, 5);
1415   application.SendNotification();
1416   application.Render();
1417
1418   application.ProcessEvent(GenerateKey("", "", "", DALI_KEY_BACKSPACE, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
1419   application.ProcessEvent(GenerateKey("Delete", "", "Delete", Dali::DevelKey::DALI_KEY_DELETE, 0, 0, Integration::KeyEvent::DOWN, "Delete", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
1420   application.SendNotification();
1421   application.Render();
1422
1423   gAnchorClickedCallBackCalled = false;
1424   // Create a tap event to touch the text field.
1425   TestGenerateTap(application, 30.0f, 25.0f, 3100);
1426   application.SendNotification();
1427   application.Render();
1428
1429   DALI_TEST_CHECK(gAnchorClickedCallBackCalled);
1430
1431   // middle index
1432   field.SetProperty(TextField::Property::TEXT, "<a href='https://www.tizen.org'>TIZEN</a>");
1433   field.SetProperty(DevelTextField::Property::PRIMARY_CURSOR_POSITION, 2);
1434   application.SendNotification();
1435   application.Render();
1436
1437   application.ProcessEvent(GenerateKey("", "", "", DALI_KEY_BACKSPACE, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
1438   application.ProcessEvent(GenerateKey("Delete", "", "Delete", Dali::DevelKey::DALI_KEY_DELETE, 0, 0, Integration::KeyEvent::DOWN, "Delete", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
1439   application.SendNotification();
1440   application.Render();
1441
1442   gAnchorClickedCallBackCalled = false;
1443   // Create a tap event to touch the text field.
1444   TestGenerateTap(application, 30.0f, 25.0f, 3700);
1445   application.SendNotification();
1446   application.Render();
1447
1448   DALI_TEST_CHECK(gAnchorClickedCallBackCalled);
1449
1450   // 0 ~ 1 index remove
1451   field.SetProperty(TextField::Property::TEXT, "<a href='https://www.tizen.org'>TIZEN</a>");
1452   field.SetProperty(DevelTextField::Property::SELECTED_TEXT_START, 0);
1453   field.SetProperty(DevelTextField::Property::SELECTED_TEXT_END, 1);
1454   application.SendNotification();
1455   application.Render();
1456
1457   application.ProcessEvent(GenerateKey("", "", "", DALI_KEY_BACKSPACE, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
1458   application.SendNotification();
1459   application.Render();
1460
1461   gAnchorClickedCallBackCalled = false;
1462   // Create a tap event to touch the text field.
1463   TestGenerateTap(application, 30.0f, 25.0f, 4300);
1464   application.SendNotification();
1465   application.Render();
1466
1467   DALI_TEST_CHECK(gAnchorClickedCallBackCalled);
1468
1469   // 1 ~ 3 index remove
1470   field.SetProperty(TextField::Property::TEXT, "<a href='https://www.tizen.org'>TIZEN</a>");
1471   field.SetProperty(DevelTextField::Property::SELECTED_TEXT_START, 1);
1472   field.SetProperty(DevelTextField::Property::SELECTED_TEXT_END, 3);
1473   application.SendNotification();
1474   application.Render();
1475
1476   application.ProcessEvent(GenerateKey("", "", "", DALI_KEY_BACKSPACE, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
1477   application.SendNotification();
1478   application.Render();
1479
1480   gAnchorClickedCallBackCalled = false;
1481   // Create a tap event to touch the text field.
1482   TestGenerateTap(application, 30.0f, 25.0f, 4900);
1483   application.SendNotification();
1484   application.Render();
1485
1486   DALI_TEST_CHECK(gAnchorClickedCallBackCalled);
1487
1488   // 3 ~ 4 index remove
1489   field.SetProperty(TextField::Property::TEXT, "<a href='https://www.tizen.org'>TIZEN</a>");
1490   field.SetProperty(DevelTextField::Property::SELECTED_TEXT_START, 3);
1491   field.SetProperty(DevelTextField::Property::SELECTED_TEXT_END, 4);
1492   application.SendNotification();
1493   application.Render();
1494
1495   application.ProcessEvent(GenerateKey("", "", "", DALI_KEY_BACKSPACE, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
1496   application.SendNotification();
1497   application.Render();
1498
1499   gAnchorClickedCallBackCalled = false;
1500   // Create a tap event to touch the text field.
1501   TestGenerateTap(application, 30.0f, 25.0f, 5500);
1502   application.SendNotification();
1503   application.Render();
1504
1505   DALI_TEST_CHECK(gAnchorClickedCallBackCalled);
1506
1507   // Remove front of anchor
1508   field.SetProperty(TextField::Property::TEXT, "TIZEN<a href='https://www.tizen.org'>TIZEN</a>");
1509   field.SetProperty(DevelTextField::Property::PRIMARY_CURSOR_POSITION, 3);
1510   application.SendNotification();
1511   application.Render();
1512
1513   application.ProcessEvent(GenerateKey("", "", "", DALI_KEY_BACKSPACE, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
1514   application.SendNotification();
1515   application.Render();
1516
1517   // Remove whole text
1518   field.SetProperty(TextField::Property::TEXT, "<a href='https://www.tizen.org'>TIZEN</a>");
1519   DevelTextField::SelectWholeText(field);
1520   application.SendNotification();
1521   application.Render();
1522
1523   application.ProcessEvent(GenerateKey("", "", "", DALI_KEY_BACKSPACE, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
1524   application.SendNotification();
1525   application.Render();
1526
1527   // Remove all with backspace
1528   field.SetProperty(TextField::Property::TEXT, "<a href='https://www.tizen.org'>T</a>");
1529   field.SetProperty(DevelTextField::Property::PRIMARY_CURSOR_POSITION, 1);
1530   application.SendNotification();
1531   application.Render();
1532
1533   application.ProcessEvent(GenerateKey("", "", "", DALI_KEY_BACKSPACE, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
1534   application.SendNotification();
1535   application.Render();
1536
1537   // Remove all with delete
1538   field.SetProperty(TextField::Property::TEXT, "<a href='https://www.tizen.org'>T</a>");
1539   field.SetProperty(DevelTextField::Property::PRIMARY_CURSOR_POSITION, 0);
1540   application.SendNotification();
1541   application.Render();
1542
1543   application.ProcessEvent(GenerateKey("Delete", "", "Delete", Dali::DevelKey::DALI_KEY_DELETE, 0, 0, Integration::KeyEvent::DOWN, "Delete", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
1544   application.SendNotification();
1545   application.Render();
1546
1547   END_TEST;
1548 }
1549
1550 // Positive test for the textChanged signal.
1551 int utcDaliTextFieldTextChangedP(void)
1552 {
1553   ToolkitTestApplication application;
1554   tet_infoline(" utcDaliTextFieldTextChangedP");
1555   TextField field = TextField::New();
1556   DALI_TEST_CHECK(field);
1557
1558   application.GetScene().Add(field);
1559
1560   // connect to the text changed signal.
1561   ConnectionTracker* testTracker = new ConnectionTracker();
1562   field.TextChangedSignal().Connect(&TestTextChangedCallback);
1563   bool textChangedSignal = false;
1564   field.ConnectSignal(testTracker, "textChanged", CallbackFunctor(&textChangedSignal));
1565
1566   gTextChangedCallBackCalled = false;
1567   field.SetProperty(TextField::Property::TEXT, "ABC");
1568   DALI_TEST_CHECK(gTextChangedCallBackCalled);
1569   DALI_TEST_CHECK(textChangedSignal);
1570
1571   application.SendNotification();
1572   field.SetKeyInputFocus();
1573
1574   gTextChangedCallBackCalled = false;
1575   application.ProcessEvent(GenerateKey("D", "", "D", KEY_D_CODE, 0, 0, Integration::KeyEvent::DOWN, "D", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
1576   DALI_TEST_CHECK(gTextChangedCallBackCalled);
1577
1578   // Remove all text
1579   field.SetProperty(TextField::Property::TEXT, "");
1580
1581   // Pressing backspace key: TextChangedCallback should not be called when there is no text in textfield.
1582   gTextChangedCallBackCalled = false;
1583   application.ProcessEvent(GenerateKey("", "", "", DALI_KEY_BACKSPACE, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
1584   DALI_TEST_CHECK(!gTextChangedCallBackCalled);
1585
1586   // Pressing delete key: TextChangedCallback should not be called when there is no text in textfield.
1587   gTextChangedCallBackCalled = false;
1588   application.ProcessEvent(GenerateKey("", "", "", Dali::DevelKey::DALI_KEY_DELETE, 0, 0, Integration::KeyEvent::DOWN, "Delete", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
1589   DALI_TEST_CHECK(!gTextChangedCallBackCalled);
1590
1591   END_TEST;
1592 }
1593
1594 int utcDaliTextFieldTextChangedWithInputMethodContext(void)
1595 {
1596   ToolkitTestApplication application;
1597   tet_infoline(" utcDaliTextFieldTextChangedWithInputMethodContext");
1598   TextField field = TextField::New();
1599   DALI_TEST_CHECK(field);
1600
1601   application.GetScene().Add(field);
1602
1603   // connect to the text changed signal.
1604   ConnectionTracker* testTracker = new ConnectionTracker();
1605   field.TextChangedSignal().Connect(&TestTextChangedCallback);
1606   bool textChangedSignal = false;
1607   field.ConnectSignal(testTracker, "textChanged", CallbackFunctor(&textChangedSignal));
1608
1609   // get InputMethodContext
1610   std::string                   text;
1611   InputMethodContext::EventData imfEvent;
1612   InputMethodContext            inputMethodContext = DevelTextField::GetInputMethodContext(field);
1613
1614   field.SetKeyInputFocus();
1615   field.SetProperty(DevelTextField::Property::ENABLE_EDITING, true);
1616
1617   // input text
1618   gTextChangedCallBackCalled = false;
1619   imfEvent                   = InputMethodContext::EventData(InputMethodContext::PRE_EDIT, "ㅎ", 0, 1);
1620   inputMethodContext.EventReceivedSignal().Emit(inputMethodContext, imfEvent);
1621   application.SendNotification();
1622   application.Render();
1623   DALI_TEST_CHECK(gTextChangedCallBackCalled);
1624   DALI_TEST_EQUALS(field.GetProperty<std::string>(TextField::Property::TEXT), std::string("ㅎ"), TEST_LOCATION);
1625
1626   gTextChangedCallBackCalled = false;
1627   imfEvent                   = InputMethodContext::EventData(InputMethodContext::PRE_EDIT, "호", 0, 1);
1628   inputMethodContext.EventReceivedSignal().Emit(inputMethodContext, imfEvent);
1629   application.SendNotification();
1630   application.Render();
1631   DALI_TEST_CHECK(gTextChangedCallBackCalled);
1632   DALI_TEST_EQUALS(field.GetProperty<std::string>(TextField::Property::TEXT), std::string("호"), TEST_LOCATION);
1633
1634   gTextChangedCallBackCalled = false;
1635   imfEvent                   = InputMethodContext::EventData(InputMethodContext::PRE_EDIT, "혿", 0, 1);
1636   inputMethodContext.EventReceivedSignal().Emit(inputMethodContext, imfEvent);
1637   application.SendNotification();
1638   application.Render();
1639   DALI_TEST_CHECK(gTextChangedCallBackCalled);
1640   DALI_TEST_EQUALS(field.GetProperty<std::string>(TextField::Property::TEXT), std::string("혿"), TEST_LOCATION);
1641
1642   gTextChangedCallBackCalled = false;
1643   imfEvent                   = InputMethodContext::EventData(InputMethodContext::PRE_EDIT, "", 0, 1);
1644   inputMethodContext.EventReceivedSignal().Emit(inputMethodContext, imfEvent);
1645   DALI_TEST_CHECK(!gTextChangedCallBackCalled);
1646
1647   imfEvent = InputMethodContext::EventData(InputMethodContext::COMMIT, "호", 0, 1);
1648   inputMethodContext.EventReceivedSignal().Emit(inputMethodContext, imfEvent);
1649   DALI_TEST_CHECK(!gTextChangedCallBackCalled);
1650
1651   imfEvent = InputMethodContext::EventData(InputMethodContext::PRE_EDIT, "두", 1, 2);
1652   inputMethodContext.EventReceivedSignal().Emit(inputMethodContext, imfEvent);
1653   DALI_TEST_CHECK(!gTextChangedCallBackCalled);
1654
1655   application.SendNotification();
1656   application.Render();
1657   DALI_TEST_CHECK(gTextChangedCallBackCalled);
1658   DALI_TEST_EQUALS(field.GetProperty<std::string>(TextField::Property::TEXT), std::string("호두"), TEST_LOCATION);
1659
1660   END_TEST;
1661 }
1662
1663 int utcDaliTextFieldSelectionWithInputMethodContext(void)
1664 {
1665   ToolkitTestApplication application;
1666   tet_infoline(" utcDaliTextFieldSelectionWithInputMethodContext");
1667   TextField field = TextField::New();
1668   DALI_TEST_CHECK(field);
1669
1670   field.SetProperty(TextField::Property::TEXT, "Hello world");
1671
1672   application.GetScene().Add(field);
1673
1674   // connect to the selection changed signal.
1675   ConnectionTracker* testTracker = new ConnectionTracker();
1676   DevelTextField::SelectionChangedSignal(field).Connect(&TestSelectionChangedCallback);
1677   bool selectionChangedSignal = false;
1678   field.ConnectSignal(testTracker, "selectionChanged", CallbackFunctor(&selectionChangedSignal));
1679
1680   // get InputMethodContext
1681   std::string                   text;
1682   InputMethodContext::EventData imfEvent;
1683   InputMethodContext            inputMethodContext = DevelTextField::GetInputMethodContext(field);
1684
1685   field.SetKeyInputFocus();
1686   field.SetProperty(DevelTextField::Property::ENABLE_EDITING, true);
1687
1688   // input text
1689   gSelectionChangedCallbackCalled = false;
1690   imfEvent                        = InputMethodContext::EventData(InputMethodContext::SELECTION_SET, 1, 4);
1691   inputMethodContext.EventReceivedSignal().Emit(inputMethodContext, imfEvent);
1692   application.SendNotification();
1693   application.Render();
1694   DALI_TEST_CHECK(gSelectionChangedCallbackCalled);
1695
1696   DALI_TEST_EQUALS(field.GetProperty(DevelTextField::Property::SELECTED_TEXT_START).Get<int>(), 1, TEST_LOCATION);
1697   DALI_TEST_EQUALS(field.GetProperty(DevelTextField::Property::SELECTED_TEXT_END).Get<int>(), 4, TEST_LOCATION);
1698
1699   END_TEST;
1700 }
1701
1702 int utcDaliTextFieldPositionWithInputMethodContext(void)
1703 {
1704   ToolkitTestApplication application;
1705   tet_infoline(" utcDaliTextFieldPositionWithInputMethodContext");
1706   TextField field = TextField::New();
1707   DALI_TEST_CHECK(field);
1708
1709   field.SetProperty(TextField::Property::TEXT, "Hello world");
1710
1711   application.GetScene().Add(field);
1712
1713   // connect to the selection changed signal.
1714   ConnectionTracker* testTracker = new ConnectionTracker();
1715   DevelTextField::CursorPositionChangedSignal(field).Connect(&TestCursorPositionChangedCallback);
1716   bool cursorPositionChangedSignal = false;
1717   field.ConnectSignal(testTracker, "cursorPositionChanged", CallbackFunctor(&cursorPositionChangedSignal));
1718
1719   // get InputMethodContext
1720   std::string                   text;
1721   InputMethodContext::EventData imfEvent;
1722   InputMethodContext            inputMethodContext = DevelTextField::GetInputMethodContext(field);
1723
1724   field.SetKeyInputFocus();
1725   field.SetProperty(DevelTextField::Property::ENABLE_EDITING, true);
1726
1727   // input text
1728   gCursorPositionChangedCallbackCalled = false;
1729   imfEvent                             = InputMethodContext::EventData(InputMethodContext::SELECTION_SET, 2, 2);
1730   inputMethodContext.EventReceivedSignal().Emit(inputMethodContext, imfEvent);
1731   application.SendNotification();
1732   application.Render();
1733   DALI_TEST_CHECK(gCursorPositionChangedCallbackCalled);
1734
1735   DALI_TEST_EQUALS(field.GetProperty(DevelTextField::Property::PRIMARY_CURSOR_POSITION).Get<int>(), 2, TEST_LOCATION);
1736
1737   END_TEST;
1738 }
1739
1740 // Negative test for the textChanged signal.
1741 int utcDaliTextFieldTextChangedN(void)
1742 {
1743   ToolkitTestApplication application;
1744   tet_infoline(" utcDaliTextFieldTextChangedN");
1745   TextField field = TextField::New();
1746   DALI_TEST_CHECK(field);
1747
1748   application.GetScene().Add(field);
1749
1750   // connect to the text changed signal.
1751   ConnectionTracker* testTracker = new ConnectionTracker();
1752   field.TextChangedSignal().Connect(&TestTextChangedCallback);
1753   bool textChangedSignal = false;
1754   field.ConnectSignal(testTracker, "textChanged", CallbackFunctor(&textChangedSignal));
1755
1756   gTextChangedCallBackCalled = false;
1757   field.SetProperty(TextField::Property::PLACEHOLDER_TEXT, "ABC"); // Setting placeholder, not TEXT
1758   application.SendNotification();
1759   application.Render();
1760   DALI_TEST_CHECK(!gTextChangedCallBackCalled);
1761   DALI_TEST_CHECK(!textChangedSignal);
1762
1763   END_TEST;
1764 }
1765
1766 // Positive test for Max Characters reached signal.
1767 int utcDaliTextFieldMaxCharactersReachedP(void)
1768 {
1769   ToolkitTestApplication application;
1770   tet_infoline(" utcDaliTextFieldMaxCharactersReachedP");
1771   TextField field = TextField::New();
1772   DALI_TEST_CHECK(field);
1773
1774   application.GetScene().Add(field);
1775
1776   const int maxNumberOfCharacters = 1;
1777   field.SetProperty(TextField::Property::MAX_LENGTH, maxNumberOfCharacters);
1778
1779   field.SetKeyInputFocus();
1780
1781   // connect to the text changed signal.
1782   ConnectionTracker* testTracker = new ConnectionTracker();
1783   field.MaxLengthReachedSignal().Connect(&TestMaxLengthReachedCallback);
1784   bool maxLengthReachedSignal = false;
1785   field.ConnectSignal(testTracker, "maxLengthReached", CallbackFunctor(&maxLengthReachedSignal));
1786
1787   gMaxCharactersCallBackCalled = false;
1788
1789   application.ProcessEvent(GenerateKey("a", "", "a", KEY_A_CODE, 0, 0, Integration::KeyEvent::DOWN, "a", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
1790   application.ProcessEvent(GenerateKey("a", "", "a", KEY_A_CODE, 0, 0, Integration::KeyEvent::DOWN, "a", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
1791
1792   DALI_TEST_CHECK(gMaxCharactersCallBackCalled);
1793   DALI_TEST_CHECK(maxLengthReachedSignal);
1794
1795   END_TEST;
1796 }
1797
1798 // Negative test for Max Characters reached signal.
1799 int utcDaliTextFieldMaxCharactersReachedN(void)
1800 {
1801   ToolkitTestApplication application;
1802   tet_infoline(" utcDaliTextFieldMaxCharactersReachedN");
1803   TextField field = TextField::New();
1804   DALI_TEST_CHECK(field);
1805
1806   application.GetScene().Add(field);
1807
1808   const int maxNumberOfCharacters = 3;
1809   field.SetProperty(TextField::Property::MAX_LENGTH, maxNumberOfCharacters);
1810
1811   field.SetKeyInputFocus();
1812
1813   // connect to the text changed signal.
1814   ConnectionTracker* testTracker = new ConnectionTracker();
1815   field.MaxLengthReachedSignal().Connect(&TestMaxLengthReachedCallback);
1816   bool maxLengthReachedSignal = false;
1817   field.ConnectSignal(testTracker, "maxLengthReached", CallbackFunctor(&maxLengthReachedSignal));
1818
1819   gMaxCharactersCallBackCalled = false;
1820
1821   application.ProcessEvent(GenerateKey("a", "", "a", KEY_A_CODE, 0, 0, Integration::KeyEvent::DOWN, "a", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
1822   application.ProcessEvent(GenerateKey("a", "", "a", KEY_A_CODE, 0, 0, Integration::KeyEvent::DOWN, "a", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
1823
1824   DALI_TEST_CHECK(!gMaxCharactersCallBackCalled);
1825   DALI_TEST_CHECK(!maxLengthReachedSignal);
1826
1827   application.ProcessEvent(GenerateKey("Return", "", "\r", KEY_RETURN_CODE, 0, 0, Integration::KeyEvent::DOWN, "\r", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
1828
1829   DALI_TEST_CHECK(!gMaxCharactersCallBackCalled);
1830   DALI_TEST_CHECK(!maxLengthReachedSignal);
1831
1832   END_TEST;
1833 }
1834
1835 // Positive test for Input Filtered signal.
1836 int utcDaliTextFieldInputFilteredP(void)
1837 {
1838   ToolkitTestApplication application;
1839   tet_infoline(" utcDaliTextFieldInputFilteredP");
1840   TextField field = TextField::New();
1841   DALI_TEST_CHECK(field);
1842
1843   application.GetScene().Add(field);
1844
1845   Property::Map inputFilter;
1846
1847   // Only digit is accepted.
1848   inputFilter[InputFilter::Property::ACCEPTED] = "[\\d]";
1849
1850   // Set input filter to TextField.
1851   field.SetProperty(DevelTextField::Property::INPUT_FILTER, inputFilter);
1852
1853   field.SetKeyInputFocus();
1854
1855   // connect to the input filtered signal.
1856   ConnectionTracker* testTracker = new ConnectionTracker();
1857   DevelTextField::InputFilteredSignal(field).Connect(&TestInputFilteredCallback);
1858   bool inputFilteredSignal = false;
1859   field.ConnectSignal(testTracker, "inputFiltered", CallbackFunctor(&inputFilteredSignal));
1860
1861   gInputFilteredAcceptedCallbackCalled = false;
1862
1863   application.ProcessEvent(GenerateKey("a", "", "a", KEY_A_CODE, 0, 0, Integration::KeyEvent::DOWN, "a", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
1864
1865   DALI_TEST_CHECK(gInputFilteredAcceptedCallbackCalled);
1866   DALI_TEST_CHECK(inputFilteredSignal);
1867
1868   // Word is rejected.
1869   inputFilter[InputFilter::Property::ACCEPTED] = "";
1870   inputFilter[InputFilter::Property::REJECTED] = "[\\w]";
1871
1872   // Set input filter to TextField.
1873   field.SetProperty(DevelTextField::Property::INPUT_FILTER, inputFilter);
1874
1875   field.SetKeyInputFocus();
1876
1877   inputFilteredSignal                  = false;
1878   gInputFilteredRejectedCallbackCalled = false;
1879
1880   application.ProcessEvent(GenerateKey("a", "", "a", KEY_A_CODE, 0, 0, Integration::KeyEvent::DOWN, "a", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
1881
1882   DALI_TEST_CHECK(gInputFilteredAcceptedCallbackCalled);
1883   DALI_TEST_CHECK(inputFilteredSignal);
1884
1885   END_TEST;
1886 }
1887
1888 // Negative test for Input Filtered signal.
1889 int utcDaliTextFieldInputFilteredN(void)
1890 {
1891   ToolkitTestApplication application;
1892   tet_infoline(" utcDaliTextFieldInputFilteredP");
1893   TextField field = TextField::New();
1894   DALI_TEST_CHECK(field);
1895
1896   application.GetScene().Add(field);
1897
1898   Property::Map inputFilter;
1899
1900   // Only word is accepted.
1901   inputFilter[InputFilter::Property::ACCEPTED] = "[\\w]";
1902
1903   // Set input filter to TextField.
1904   field.SetProperty(DevelTextField::Property::INPUT_FILTER, inputFilter);
1905
1906   field.SetKeyInputFocus();
1907
1908   // connect to the input filtered signal.
1909   ConnectionTracker* testTracker = new ConnectionTracker();
1910   DevelTextField::InputFilteredSignal(field).Connect(&TestInputFilteredCallback);
1911   bool inputFilteredSignal = false;
1912   field.ConnectSignal(testTracker, "inputFiltered", CallbackFunctor(&inputFilteredSignal));
1913
1914   gInputFilteredAcceptedCallbackCalled = false;
1915
1916   // Key a, d should not be filtered.
1917   application.ProcessEvent(GenerateKey("a", "", "a", KEY_A_CODE, 0, 0, Integration::KeyEvent::DOWN, "a", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
1918   application.ProcessEvent(GenerateKey("a", "", "a", KEY_A_CODE, 0, 0, Integration::KeyEvent::UP, "a", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
1919   application.ProcessEvent(GenerateKey("d", "", "d", KEY_D_CODE, 0, 0, Integration::KeyEvent::DOWN, "d", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
1920   application.ProcessEvent(GenerateKey("d", "", "d", KEY_D_CODE, 0, 0, Integration::KeyEvent::UP, "d", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
1921
1922   // Backspace, Delete should not be filtered.
1923   application.ProcessEvent(GenerateKey("", "", "", DALI_KEY_BACKSPACE, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
1924   application.ProcessEvent(GenerateKey("Delete", "", "Delete", Dali::DevelKey::DALI_KEY_DELETE, 0, 0, Integration::KeyEvent::DOWN, "Delete", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
1925
1926   // Render and notify
1927   application.SendNotification();
1928   application.Render();
1929
1930   DALI_TEST_CHECK(!gInputFilteredAcceptedCallbackCalled);
1931   DALI_TEST_CHECK(!inputFilteredSignal);
1932
1933   // Digit is rejected.
1934   inputFilter[InputFilter::Property::ACCEPTED] = "";
1935   inputFilter[InputFilter::Property::REJECTED] = "[\\d]";
1936
1937   field.SetProperty(DevelTextField::Property::INPUT_FILTER, inputFilter);
1938
1939   field.SetKeyInputFocus();
1940
1941   inputFilteredSignal                  = false;
1942   gInputFilteredRejectedCallbackCalled = false;
1943
1944   // Key a, d should not be filtered.
1945   application.ProcessEvent(GenerateKey("a", "", "a", KEY_A_CODE, 0, 0, Integration::KeyEvent::DOWN, "a", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
1946   application.ProcessEvent(GenerateKey("a", "", "a", KEY_A_CODE, 0, 0, Integration::KeyEvent::UP, "a", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
1947   application.ProcessEvent(GenerateKey("d", "", "d", KEY_D_CODE, 0, 0, Integration::KeyEvent::DOWN, "d", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
1948   application.ProcessEvent(GenerateKey("d", "", "d", KEY_D_CODE, 0, 0, Integration::KeyEvent::UP, "d", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
1949
1950   // Backspace, Delete should not be filtered.
1951   application.ProcessEvent(GenerateKey("", "", "", DALI_KEY_BACKSPACE, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
1952   application.ProcessEvent(GenerateKey("Delete", "", "Delete", Dali::DevelKey::DALI_KEY_DELETE, 0, 0, Integration::KeyEvent::DOWN, "Delete", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
1953
1954   // Render and notify
1955   application.SendNotification();
1956   application.Render();
1957
1958   DALI_TEST_CHECK(!gInputFilteredAcceptedCallbackCalled);
1959   DALI_TEST_CHECK(!inputFilteredSignal);
1960
1961   END_TEST;
1962 }
1963
1964 int utcDaliTextFieldInputStyleChanged01(void)
1965 {
1966   // The text-field emits signals when the input style changes. These changes of style are
1967   // detected during the relayout process (size negotiation), i.e after the cursor has been moved. Signals
1968   // can't be emitted during the size negotiation as the callbacks may update the UI.
1969   // The text-field adds an idle callback to the adaptor to emit the signals after the size negotiation.
1970   // The ToolkitTestApplication creates an implementation of the adaptor stub and a queue of idle callbacks.
1971   ToolkitTestApplication application;
1972   tet_infoline(" utcDaliTextFieldInputStyleChanged01");
1973
1974   // Load some fonts.
1975
1976   char*             pathNamePtr = get_current_dir_name();
1977   const std::string pathName(pathNamePtr);
1978   free(pathNamePtr);
1979
1980   TextAbstraction::FontClient fontClient = TextAbstraction::FontClient::Get();
1981   fontClient.SetDpi(93u, 93u);
1982
1983   fontClient.GetFontId(pathName + DEFAULT_FONT_DIR + "/dejavu/DejaVuSerif.ttf", DEFAULT_FONT_SIZE);
1984   fontClient.GetFontId(pathName + DEFAULT_FONT_DIR + "/dejavu/DejaVuSerif-Bold.ttf", DEFAULT_FONT_SIZE);
1985
1986   TextField field = TextField::New();
1987   DALI_TEST_CHECK(field);
1988
1989   field.SetProperty(Actor::Property::SIZE, Vector2(300.f, 50.f));
1990   field.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT);
1991   field.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
1992
1993   field.SetProperty(TextField::Property::ENABLE_MARKUP, true);
1994   field.SetProperty(TextField::Property::TEXT, "<font family='DejaVuSerif' size='18'>He<color value='green'>llo</color> <font weight='bold'>world</font> demo</font>");
1995
1996   // connect to the text changed signal.
1997   ConnectionTracker* testTracker = new ConnectionTracker();
1998   field.InputStyleChangedSignal().Connect(&TestInputStyleChangedCallback);
1999   bool inputStyleChangedSignal = false;
2000   field.ConnectSignal(testTracker, "inputStyleChanged", CallbackFunctor(&inputStyleChangedSignal));
2001
2002   application.GetScene().Add(field);
2003
2004   // Render and notify
2005   application.SendNotification();
2006   application.Render();
2007
2008   // Executes the idle callbacks added by the text control on the change of input style.
2009   application.RunIdles();
2010
2011   gInputStyleChangedCallbackCalled = false;
2012   gInputStyleMask                  = TextField::InputStyle::NONE;
2013   inputStyleChangedSignal          = false;
2014
2015   // Create a tap event to touch the text field.
2016   TestGenerateTap(application, 18.0f, 25.0f);
2017
2018   // Render and notify
2019   application.SendNotification();
2020   application.Render();
2021
2022   // Executes the idle callbacks added by the text control on the change of input style.
2023   application.RunIdles();
2024
2025   DALI_TEST_CHECK(gInputStyleChangedCallbackCalled);
2026   if(gInputStyleChangedCallbackCalled)
2027   {
2028     DALI_TEST_EQUALS(static_cast<unsigned int>(gInputStyleMask), static_cast<unsigned int>(TextField::InputStyle::FONT_FAMILY | TextField::InputStyle::POINT_SIZE), TEST_LOCATION);
2029
2030     const std::string fontFamily = field.GetProperty(TextField::Property::INPUT_FONT_FAMILY).Get<std::string>();
2031     DALI_TEST_EQUALS(fontFamily, "DejaVuSerif", TEST_LOCATION);
2032
2033     const float pointSize = field.GetProperty(TextField::Property::INPUT_POINT_SIZE).Get<float>();
2034     DALI_TEST_EQUALS(pointSize, 18.f, Math::MACHINE_EPSILON_1000, TEST_LOCATION);
2035   }
2036   DALI_TEST_CHECK(inputStyleChangedSignal);
2037
2038   gInputStyleChangedCallbackCalled = false;
2039   gInputStyleMask                  = TextField::InputStyle::NONE;
2040   inputStyleChangedSignal          = false;
2041
2042   // Create a tap event to touch the text field.
2043   TestGenerateTap(application, 30.0f, 25.0f);
2044
2045   // Render and notify
2046   application.SendNotification();
2047   application.Render();
2048
2049   // Executes the idle callbacks added by the text control on the change of input style.
2050   application.RunIdles();
2051
2052   DALI_TEST_CHECK(!gInputStyleChangedCallbackCalled);
2053   DALI_TEST_CHECK(!inputStyleChangedSignal);
2054
2055   gInputStyleChangedCallbackCalled = false;
2056   gInputStyleMask                  = TextField::InputStyle::NONE;
2057   inputStyleChangedSignal          = false;
2058
2059   // Create a tap event to touch the text field.
2060   TestGenerateTap(application, 43.0f, 25.0f);
2061
2062   // Render and notify
2063   application.SendNotification();
2064   application.Render();
2065
2066   // Executes the idle callbacks added by the text control on the change of input style.
2067   application.RunIdles();
2068
2069   DALI_TEST_CHECK(gInputStyleChangedCallbackCalled);
2070   if(gInputStyleChangedCallbackCalled)
2071   {
2072     DALI_TEST_EQUALS(static_cast<unsigned int>(gInputStyleMask), static_cast<unsigned int>(TextField::InputStyle::COLOR), TEST_LOCATION);
2073
2074     const Vector4 color = field.GetProperty(TextField::Property::INPUT_COLOR).Get<Vector4>();
2075     DALI_TEST_EQUALS(color, Color::GREEN, TEST_LOCATION);
2076   }
2077   DALI_TEST_CHECK(inputStyleChangedSignal);
2078
2079   gInputStyleChangedCallbackCalled = false;
2080   gInputStyleMask                  = TextField::InputStyle::NONE;
2081   inputStyleChangedSignal          = false;
2082
2083   // Create a tap event to touch the text field.
2084   TestGenerateTap(application, 88.0f, 25.0f);
2085
2086   // Render and notify
2087   application.SendNotification();
2088   application.Render();
2089
2090   // Executes the idle callbacks added by the text control on the change of input style.
2091   application.RunIdles();
2092
2093   DALI_TEST_CHECK(gInputStyleChangedCallbackCalled);
2094   if(gInputStyleChangedCallbackCalled)
2095   {
2096     DALI_TEST_EQUALS(static_cast<unsigned int>(gInputStyleMask), static_cast<unsigned int>(TextField::InputStyle::COLOR | TextField::InputStyle::FONT_STYLE), TEST_LOCATION);
2097
2098     const Vector4 color = field.GetProperty(TextField::Property::INPUT_COLOR).Get<Vector4>();
2099     DALI_TEST_EQUALS(color, Color::BLACK, TEST_LOCATION);
2100
2101     const Property::Map fontStyleMapGet = field.GetProperty(TextField::Property::INPUT_FONT_STYLE).Get<Property::Map>();
2102
2103     Property::Map fontStyleMapSet;
2104     fontStyleMapSet.Insert("weight", "bold");
2105
2106     DALI_TEST_EQUALS(fontStyleMapGet.Count(), fontStyleMapSet.Count(), TEST_LOCATION);
2107     DALI_TEST_EQUALS(DaliTestCheckMaps(fontStyleMapGet, fontStyleMapSet), true, TEST_LOCATION);
2108   }
2109   DALI_TEST_CHECK(inputStyleChangedSignal);
2110
2111   gInputStyleChangedCallbackCalled = false;
2112   gInputStyleMask                  = TextField::InputStyle::NONE;
2113   inputStyleChangedSignal          = false;
2114
2115   // Create a tap event to touch the text field.
2116   TestGenerateTap(application, 115.0f, 25.0f);
2117
2118   // Render and notify
2119   application.SendNotification();
2120   application.Render();
2121
2122   // Executes the idle callbacks added by the text control on the change of input style.
2123   application.RunIdles();
2124
2125   DALI_TEST_CHECK(!gInputStyleChangedCallbackCalled);
2126   DALI_TEST_CHECK(!inputStyleChangedSignal);
2127
2128   gInputStyleChangedCallbackCalled = false;
2129   gInputStyleMask                  = TextField::InputStyle::NONE;
2130   inputStyleChangedSignal          = false;
2131
2132   // Create a tap event to touch the text field.
2133   TestGenerateTap(application, 164.0f, 25.0f);
2134
2135   // Render and notify
2136   application.SendNotification();
2137   application.Render();
2138
2139   // Executes the idle callbacks added by the text control on the change of input style.
2140   application.RunIdles();
2141
2142   DALI_TEST_CHECK(gInputStyleChangedCallbackCalled);
2143   if(gInputStyleChangedCallbackCalled)
2144   {
2145     DALI_TEST_EQUALS(static_cast<unsigned int>(gInputStyleMask), static_cast<unsigned int>(TextField::InputStyle::FONT_STYLE), TEST_LOCATION);
2146
2147     const std::string style = field.GetProperty(TextField::Property::INPUT_FONT_STYLE).Get<std::string>();
2148     DALI_TEST_CHECK(style.empty());
2149   }
2150   DALI_TEST_CHECK(inputStyleChangedSignal);
2151
2152   gInputStyleChangedCallbackCalled = false;
2153   gInputStyleMask                  = TextField::InputStyle::NONE;
2154   inputStyleChangedSignal          = false;
2155
2156   // Create a tap event to touch the text field.
2157   TestGenerateTap(application, 191.0f, 25.0f);
2158
2159   // Render and notify
2160   application.SendNotification();
2161   application.Render();
2162
2163   // Executes the idle callbacks added by the text control on the change of input style.
2164   application.RunIdles();
2165
2166   DALI_TEST_CHECK(!gInputStyleChangedCallbackCalled);
2167   DALI_TEST_CHECK(!inputStyleChangedSignal);
2168
2169   END_TEST;
2170 }
2171
2172 int utcDaliTextFieldInputStyleChanged02(void)
2173 {
2174   // The text-field emits signals when the input style changes. These changes of style are
2175   // detected during the relayout process (size negotiation), i.e after the cursor has been moved. Signals
2176   // can't be emitted during the size negotiation as the callbacks may update the UI.
2177   // The text-field adds an idle callback to the adaptor to emit the signals after the size negotiation.
2178   // The ToolkitTestApplication creates an implementation of the adaptor stub and a queue of idle callbacks.
2179   ToolkitTestApplication application;
2180   tet_infoline(" utcDaliTextFieldInputStyleChanged02");
2181
2182   // Load some fonts.
2183
2184   char*             pathNamePtr = get_current_dir_name();
2185   const std::string pathName(pathNamePtr);
2186   free(pathNamePtr);
2187
2188   TextAbstraction::FontClient fontClient = TextAbstraction::FontClient::Get();
2189   fontClient.SetDpi(93u, 93u);
2190
2191   fontClient.GetFontId(pathName + DEFAULT_FONT_DIR + "/dejavu/DejaVuSerif.ttf", DEFAULT_FONT_SIZE);
2192   fontClient.GetFontId(pathName + DEFAULT_FONT_DIR + "/dejavu/DejaVuSerif-Bold.ttf", DEFAULT_FONT_SIZE);
2193
2194   TextField field = TextField::New();
2195   DALI_TEST_CHECK(field);
2196
2197   field.SetProperty(Actor::Property::SIZE, Vector2(300.f, 50.f));
2198   field.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT);
2199   field.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
2200
2201   field.SetProperty(TextField::Property::ENABLE_MARKUP, true);
2202   field.SetProperty(TextField::Property::TEXT, "<font family='DejaVuSerif' size='18'>He<color value='blue'> l</color><color value='green'>lo</color> <font weight='bold'>world</font> demo</font>");
2203
2204   // connect to the text changed signal.
2205   ConnectionTracker* testTracker = new ConnectionTracker();
2206   field.InputStyleChangedSignal().Connect(&TestInputStyleChangedCallback);
2207   bool inputStyleChangedSignal = false;
2208   field.ConnectSignal(testTracker, "inputStyleChanged", CallbackFunctor(&inputStyleChangedSignal));
2209
2210   application.GetScene().Add(field);
2211
2212   // Render and notify
2213   application.SendNotification();
2214   application.Render();
2215
2216   // Executes the idle callbacks added by the text control on the change of input style.
2217   application.RunIdles();
2218
2219   gInputStyleChangedCallbackCalled = false;
2220   gInputStyleMask                  = TextField::InputStyle::NONE;
2221   inputStyleChangedSignal          = false;
2222
2223   // Create a tap event to touch the text field.
2224   TestGenerateTap(application, 53.0f, 25.0f, 100);
2225   TestGenerateTap(application, 53.0f, 25.0f, 200);
2226
2227   // Render and notify
2228   application.SendNotification();
2229   application.Render();
2230
2231   // Executes the idle callbacks added by the text control on the change of input style.
2232   application.RunIdles();
2233
2234   DALI_TEST_CHECK(gInputStyleChangedCallbackCalled);
2235   if(gInputStyleChangedCallbackCalled)
2236   {
2237     DALI_TEST_EQUALS(static_cast<unsigned int>(gInputStyleMask),
2238                      static_cast<unsigned int>(TextField::InputStyle::FONT_FAMILY |
2239                                                TextField::InputStyle::POINT_SIZE |
2240                                                TextField::InputStyle::COLOR),
2241                      TEST_LOCATION);
2242
2243     const Vector4 color = field.GetProperty(TextField::Property::INPUT_COLOR).Get<Vector4>();
2244     DALI_TEST_EQUALS(color, Color::GREEN, TEST_LOCATION);
2245
2246     const std::string fontFamily = field.GetProperty(TextField::Property::INPUT_FONT_FAMILY).Get<std::string>();
2247     DALI_TEST_EQUALS(fontFamily, "DejaVuSerif", TEST_LOCATION);
2248
2249     const float pointSize = field.GetProperty(TextField::Property::INPUT_POINT_SIZE).Get<float>();
2250     DALI_TEST_EQUALS(pointSize, 18.f, Math::MACHINE_EPSILON_1000, TEST_LOCATION);
2251   }
2252   DALI_TEST_CHECK(inputStyleChangedSignal);
2253
2254   gInputStyleChangedCallbackCalled = false;
2255   gInputStyleMask                  = TextField::InputStyle::NONE;
2256   inputStyleChangedSignal          = false;
2257
2258   application.ProcessEvent(GenerateKey("", "", "", DALI_KEY_BACKSPACE, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
2259
2260   // Render and notify
2261   application.SendNotification();
2262   application.Render();
2263
2264   // Executes the idle callbacks added by the text control on the change of input style.
2265   application.RunIdles();
2266
2267   DALI_TEST_CHECK(gInputStyleChangedCallbackCalled);
2268   if(gInputStyleChangedCallbackCalled)
2269   {
2270     DALI_TEST_EQUALS(static_cast<unsigned int>(gInputStyleMask),
2271                      static_cast<unsigned int>(TextField::InputStyle::COLOR),
2272                      TEST_LOCATION);
2273
2274     const Vector4 color = field.GetProperty(TextField::Property::INPUT_COLOR).Get<Vector4>();
2275     DALI_TEST_EQUALS(color, Color::BLUE, TEST_LOCATION);
2276   }
2277   DALI_TEST_CHECK(inputStyleChangedSignal);
2278
2279   gInputStyleChangedCallbackCalled = false;
2280   gInputStyleMask                  = TextField::InputStyle::NONE;
2281   inputStyleChangedSignal          = false;
2282
2283   application.ProcessEvent(GenerateKey("", "", "", DALI_KEY_BACKSPACE, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
2284
2285   // Render and notify
2286   application.SendNotification();
2287   application.Render();
2288
2289   // Executes the idle callbacks added by the text control on the change of input style.
2290   application.RunIdles();
2291
2292   DALI_TEST_CHECK(!gInputStyleChangedCallbackCalled);
2293   DALI_TEST_CHECK(!inputStyleChangedSignal);
2294
2295   gInputStyleChangedCallbackCalled = false;
2296   gInputStyleMask                  = TextField::InputStyle::NONE;
2297   inputStyleChangedSignal          = false;
2298
2299   application.ProcessEvent(GenerateKey("", "", "", DALI_KEY_BACKSPACE, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
2300
2301   // Render and notify
2302   application.SendNotification();
2303   application.Render();
2304
2305   // Executes the idle callbacks added by the text control on the change of input style.
2306   application.RunIdles();
2307
2308   DALI_TEST_CHECK(gInputStyleChangedCallbackCalled);
2309   if(gInputStyleChangedCallbackCalled)
2310   {
2311     DALI_TEST_EQUALS(static_cast<unsigned int>(gInputStyleMask),
2312                      static_cast<unsigned int>(TextField::InputStyle::COLOR),
2313                      TEST_LOCATION);
2314
2315     const Vector4 color = field.GetProperty(TextField::Property::INPUT_COLOR).Get<Vector4>();
2316     DALI_TEST_EQUALS(color, Color::BLACK, TEST_LOCATION);
2317   }
2318   DALI_TEST_CHECK(inputStyleChangedSignal);
2319
2320   gInputStyleChangedCallbackCalled = false;
2321   gInputStyleMask                  = TextField::InputStyle::NONE;
2322   inputStyleChangedSignal          = false;
2323
2324   field.SetProperty(TextField::Property::INPUT_COLOR, Color::YELLOW);
2325
2326   Property::Map fontStyleMapSet;
2327   fontStyleMapSet.Insert("weight", "thin");
2328   fontStyleMapSet.Insert("width", "condensed");
2329   fontStyleMapSet.Insert("slant", "italic");
2330
2331   field.SetProperty(TextField::Property::INPUT_FONT_STYLE, fontStyleMapSet);
2332   field.SetProperty(TextField::Property::INPUT_POINT_SIZE, 20.f);
2333
2334   field.SetProperty(TextField::Property::INPUT_UNDERLINE, "underline");
2335   field.SetProperty(TextField::Property::INPUT_SHADOW, "shadow");
2336   field.SetProperty(TextField::Property::INPUT_EMBOSS, "emboss");
2337   field.SetProperty(TextField::Property::INPUT_OUTLINE, "outline");
2338   field.SetProperty(DevelTextField::Property::INPUT_STRIKETHROUGH, "strikethrough");
2339
2340   // Render and notify
2341   application.SendNotification();
2342   application.Render();
2343
2344   // Executes the idle callbacks added by the text control on the change of input style.
2345   application.RunIdles();
2346
2347   DALI_TEST_CHECK(!gInputStyleChangedCallbackCalled);
2348   DALI_TEST_CHECK(!inputStyleChangedSignal);
2349
2350   // Create a tap event to touch the text field.
2351   TestGenerateTap(application, 63.0f, 25.0f, 700);
2352
2353   // Render and notify
2354   application.SendNotification();
2355   application.Render();
2356
2357   // Executes the idle callbacks added by the text control on the change of input style.
2358   application.RunIdles();
2359
2360   DALI_TEST_CHECK(gInputStyleChangedCallbackCalled);
2361   if(gInputStyleChangedCallbackCalled)
2362   {
2363     DALI_TEST_EQUALS(static_cast<unsigned int>(gInputStyleMask),
2364                      static_cast<unsigned int>(TextField::InputStyle::COLOR |
2365                                                TextField::InputStyle::POINT_SIZE |
2366                                                TextField::InputStyle::FONT_STYLE |
2367                                                TextField::InputStyle::UNDERLINE |
2368                                                TextField::InputStyle::SHADOW |
2369                                                TextField::InputStyle::EMBOSS |
2370                                                TextField::InputStyle::OUTLINE),
2371                      TEST_LOCATION);
2372
2373     const Vector4 color = field.GetProperty(TextField::Property::INPUT_COLOR).Get<Vector4>();
2374     DALI_TEST_EQUALS(color, Color::BLACK, TEST_LOCATION);
2375   }
2376   DALI_TEST_CHECK(inputStyleChangedSignal);
2377
2378   END_TEST;
2379 }
2380
2381 int utcDaliTextFieldEvent01(void)
2382 {
2383   ToolkitTestApplication application;
2384   tet_infoline(" utcDaliTextFieldEvent01");
2385
2386   // Creates a tap event. After creating a tap event the text field should
2387   // have the focus and add text with key events should be possible.
2388
2389   TextField field = TextField::New();
2390   DALI_TEST_CHECK(field);
2391
2392   application.GetScene().Add(field);
2393
2394   field.SetProperty(Actor::Property::SIZE, Vector2(300.f, 50.f));
2395   field.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT);
2396   field.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
2397
2398   // Render and notify
2399   application.SendNotification();
2400   application.Render();
2401
2402   // Avoid a crash when core load gl resources.
2403   application.GetGlAbstraction().SetCheckFramebufferStatusResult(GL_FRAMEBUFFER_COMPLETE);
2404
2405   // Render and notify
2406   application.SendNotification();
2407   application.Render();
2408
2409   // Add a key event but as the text field has not the focus it should do nothing.
2410   application.ProcessEvent(GenerateKey("a", "", "a", KEY_A_CODE, 0, 0, Integration::KeyEvent::DOWN, "a", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
2411
2412   // Render and notify
2413   application.SendNotification();
2414   application.Render();
2415
2416   DALI_TEST_EQUALS(field.GetProperty<std::string>(TextField::Property::TEXT), std::string(""), TEST_LOCATION);
2417
2418   // Create a tap event to touch the text field.
2419   TestGenerateTap(application, 150.0f, 25.0f);
2420
2421   // Render and notify
2422   application.SendNotification();
2423   application.Render();
2424
2425   // Pressing delete key should be fine even if there is no text in TextField.
2426   application.ProcessEvent(GenerateKey("Delete", "", "Delete", Dali::DevelKey::DALI_KEY_DELETE, 0, 0, Integration::KeyEvent::DOWN, "Delete", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
2427   // Render and notify
2428   application.SendNotification();
2429   application.Render();
2430
2431   // Now the text field has the focus, so it can handle the key events.
2432   application.ProcessEvent(GenerateKey("a", "", "a", KEY_A_CODE, 0, 0, Integration::KeyEvent::DOWN, "a", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
2433   application.ProcessEvent(GenerateKey("a", "", "a", KEY_A_CODE, 0, 0, Integration::KeyEvent::DOWN, "a", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
2434
2435   // Render and notify
2436   application.SendNotification();
2437   application.Render();
2438
2439   DALI_TEST_EQUALS(field.GetProperty<std::string>(TextField::Property::TEXT), std::string("aa"), TEST_LOCATION);
2440
2441   // Create a second text field and send key events to it.
2442   TextField field2 = TextField::New();
2443
2444   field2.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT);
2445   field2.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
2446   field2.SetProperty(Actor::Property::SIZE, Vector2(100.f, 100.f));
2447   field2.SetProperty(Actor::Property::POSITION, Vector2(100.0f, 100.0f));
2448
2449   application.GetScene().Add(field2);
2450
2451   // Render and notify
2452   application.SendNotification();
2453   application.Render();
2454
2455   // Create a tap event on the second text field.
2456   TestGenerateTap(application, 150.0f, 125.0f);
2457
2458   // Render and notify
2459   application.SendNotification();
2460   application.Render();
2461
2462   // The second text field has the focus. It should handle the key events.
2463   application.ProcessEvent(GenerateKey("a", "", "a", KEY_A_CODE, 0, 0, Integration::KeyEvent::DOWN, "a", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
2464   application.ProcessEvent(GenerateKey("a", "", "a", KEY_A_CODE, 0, 0, Integration::KeyEvent::DOWN, "a", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
2465
2466   // Render and notify
2467   application.SendNotification();
2468   application.Render();
2469
2470   // Check the text has been added to the second text field.
2471   DALI_TEST_EQUALS(field2.GetProperty<std::string>(TextField::Property::TEXT), std::string("aa"), TEST_LOCATION);
2472
2473   END_TEST;
2474 }
2475
2476 int utcDaliTextFieldEvent02(void)
2477 {
2478   ToolkitTestApplication application;
2479   tet_infoline(" utcDaliTextFieldEvent02");
2480
2481   // Checks if the right number of actors are created.
2482
2483   TextField field = TextField::New();
2484   field.SetProperty(TextField::Property::POINT_SIZE, 10.f);
2485   DALI_TEST_CHECK(field);
2486   LoadMarkerImages(application, field);
2487
2488   application.GetScene().Add(field);
2489
2490   field.SetProperty(Actor::Property::SIZE, Vector2(300.f, 50.f));
2491   field.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT);
2492   field.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
2493
2494   // Avoid a crash when core load gl resources.
2495   application.GetGlAbstraction().SetCheckFramebufferStatusResult(GL_FRAMEBUFFER_COMPLETE);
2496
2497   // Render and notify
2498   application.SendNotification();
2499   application.Render();
2500
2501   // Check there are the expected number of children ( stencil ).
2502   DALI_TEST_EQUALS(field.GetChildCount(), 1u, TEST_LOCATION);
2503
2504   Actor stencil = field.GetChildAt(0u);
2505   DALI_TEST_EQUALS(stencil.GetChildCount(), 0u, TEST_LOCATION);
2506
2507   // Create a tap event to touch the text field.
2508   TestGenerateTap(application, 150.0f, 25.0f, 300);
2509
2510   // Render and notify
2511   application.SendNotification();
2512   application.Render();
2513
2514   Actor layer = field.GetChildAt(2u);
2515   DALI_TEST_EQUALS(layer.GetChildCount(), 1u, TEST_LOCATION); // The cursor.
2516   DALI_TEST_EQUALS(stencil.GetChildCount(), 0u, TEST_LOCATION);
2517
2518   // Now the text field has the focus, so it can handle the key events.
2519   application.ProcessEvent(GenerateKey("a", "", "a", KEY_A_CODE, 0, 0, Integration::KeyEvent::DOWN, "a", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
2520   application.ProcessEvent(GenerateKey("a", "", "a", KEY_A_CODE, 0, 0, Integration::KeyEvent::DOWN, "a", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
2521
2522   // Render and notify
2523   application.SendNotification();
2524   application.Render();
2525
2526   // Checks the cursor and the renderer have been created.
2527   DALI_TEST_EQUALS(layer.GetChildCount(), 1u, TEST_LOCATION);   // The cursor.
2528   DALI_TEST_EQUALS(stencil.GetChildCount(), 2u, TEST_LOCATION); // The renderer, clipped cursor
2529
2530   Control cursor = Control::DownCast(layer.GetChildAt(0u));
2531   DALI_TEST_CHECK(cursor);
2532
2533   // The offscreen root actor has a container with all the actors which contain the text renderers.
2534   Actor container = stencil.GetChildAt(0u);
2535   for(unsigned int index = 0; index < container.GetChildCount(); ++index)
2536   {
2537     Renderer renderer = container.GetChildAt(index).GetRendererAt(0u);
2538     DALI_TEST_CHECK(renderer);
2539   }
2540
2541   // Move the cursor and check the position changes.
2542   Vector3 position1 = cursor.GetCurrentProperty<Vector3>(Actor::Property::POSITION);
2543   application.ProcessEvent(GenerateKey("", "", "", DALI_KEY_CURSOR_LEFT, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
2544
2545   // Render and notify
2546   application.SendNotification();
2547   application.Render();
2548
2549   Vector3 position2 = cursor.GetCurrentProperty<Vector3>(Actor::Property::POSITION);
2550   DALI_TEST_CHECK(position2.x < position1.x);
2551
2552   application.ProcessEvent(GenerateKey("", "", "", DALI_KEY_CURSOR_RIGHT, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
2553
2554   // Render and notify
2555   application.SendNotification();
2556   application.Render();
2557
2558   Vector3 position3 = cursor.GetCurrentProperty<Vector3>(Actor::Property::POSITION);
2559   DALI_TEST_EQUALS(position1, position3, TEST_LOCATION); // Should be in the same position1.
2560
2561   // Move the cursor to the first position.
2562   application.ProcessEvent(GenerateKey("", "", "", DALI_KEY_CURSOR_LEFT, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
2563   application.ProcessEvent(GenerateKey("", "", "", DALI_KEY_CURSOR_LEFT, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
2564
2565   // Render and notify
2566   application.SendNotification();
2567   application.Render();
2568
2569   Vector3 position4 = cursor.GetCurrentProperty<Vector3>(Actor::Property::POSITION);
2570
2571   // Send some taps and check the cursor positions.
2572
2573   // Try to tap at the beginning.
2574   TestGenerateTap(application, 1.0f, 25.0f, 900);
2575
2576   // Render and notify
2577   application.SendNotification();
2578   application.Render();
2579
2580   // Cursor position should be the same than position1.
2581   Vector3 position5 = cursor.GetCurrentProperty<Vector3>(Actor::Property::POSITION);
2582
2583   DALI_TEST_EQUALS(position4, position5, TEST_LOCATION); // Should be in the same position2.
2584
2585   // Tap away from the start position.
2586   TestGenerateTap(application, 16.0f, 25.0f, 1500);
2587
2588   // Render and notify
2589   application.SendNotification();
2590   application.Render();
2591
2592   Vector3 position6 = cursor.GetCurrentProperty<Vector3>(Actor::Property::POSITION);
2593
2594   DALI_TEST_CHECK(position6.x > position5.x);
2595
2596   // Remove all the text.
2597   application.ProcessEvent(GenerateKey("", "", "", DALI_KEY_BACKSPACE, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
2598   application.ProcessEvent(GenerateKey("", "", "", DALI_KEY_BACKSPACE, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
2599   field.SetProperty(TextField::Property::TEXT, "");
2600
2601   // Render and notify
2602   application.SendNotification();
2603   application.Render();
2604
2605   // Cursor position should be the same than position2.
2606   Vector3 position7 = cursor.GetCurrentProperty<Vector3>(Actor::Property::POSITION);
2607
2608   DALI_TEST_EQUALS(position4, position7, TEST_LOCATION); // Should be in the same position2.
2609
2610   // Should not be a renderer, there is only a clipped cursor.
2611   DALI_TEST_EQUALS(stencil.GetChildCount(), 1u, TEST_LOCATION);
2612
2613   // Chanege exceed policy (EXCEED_POLICY_ORIGINAL doesn't use stencil )
2614   field.SetProperty(TextField::Property::TEXT, "This is a long text for the size of the text-field.");
2615   field.SetProperty(TextField::Property::EXCEED_POLICY, Dali::Toolkit::TextField::EXCEED_POLICY_ORIGINAL);
2616
2617   application.SendNotification();
2618   application.Render();
2619
2620   // There are renderer and decorator layer
2621   DALI_TEST_EQUALS(field.GetChildCount(), 2u, TEST_LOCATION);
2622
2623   END_TEST;
2624 }
2625
2626 int utcDaliTextFieldEvent03(void)
2627 {
2628   ToolkitTestApplication application;
2629   tet_infoline(" utcDaliTextFieldEvent03");
2630
2631   // Checks if the highlight actor is created.
2632
2633   TextField field = TextField::New();
2634   DALI_TEST_CHECK(field);
2635
2636   application.GetScene().Add(field);
2637
2638   field.SetProperty(TextField::Property::TEXT, "This is a long text for the size of the text-field.");
2639   field.SetProperty(TextField::Property::POINT_SIZE, 10.f);
2640   field.SetProperty(Actor::Property::SIZE, Vector2(30.f, 50.f));
2641   field.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT);
2642   field.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
2643
2644   // Avoid a crash when core load gl resources.
2645   application.GetGlAbstraction().SetCheckFramebufferStatusResult(GL_FRAMEBUFFER_COMPLETE);
2646   LoadMarkerImages(application, field);
2647
2648   // Render and notify
2649   application.SendNotification();
2650   application.Render();
2651
2652   // Tap first to get the focus.
2653   TestGenerateTap(application, 3.0f, 25.0f);
2654
2655   // Render and notify
2656   application.SendNotification();
2657   application.Render();
2658
2659   // Double tap to select a word.
2660   TestGenerateTap(application, 3.0f, 25.0f);
2661
2662   // Render and notify
2663   application.SendNotification();
2664   application.Render();
2665
2666   // The offscreen root actor should have two actors: the renderer and the highlight actor.
2667   Actor stencil = field.GetChildAt(0u);
2668
2669   // The highlight actor is drawn first, so is the first actor in the list
2670   Renderer highlight = stencil.GetChildAt(0u).GetRendererAt(0u);
2671   DALI_TEST_CHECK(highlight);
2672
2673   // The offscreen root actor has a container with all the actors which contain the text renderers.
2674   Actor container = stencil.GetChildAt(1u);
2675   for(unsigned int index = 0; index < container.GetChildCount(); ++index)
2676   {
2677     Renderer renderer = container.GetChildAt(index).GetRendererAt(0u);
2678     DALI_TEST_CHECK(renderer);
2679   }
2680
2681   END_TEST;
2682 }
2683
2684 int utcDaliTextFieldEvent04(void)
2685 {
2686   ToolkitTestApplication application;
2687   tet_infoline(" utcDaliTextFieldEvent04");
2688
2689   // Checks if the highlight actor is created.
2690
2691   TextField field = TextField::New();
2692   DALI_TEST_CHECK(field);
2693   application.GetScene().Add(field);
2694   LoadMarkerImages(application, field);
2695   // Render and notify
2696   application.SendNotification();
2697   application.Render();
2698
2699   field.SetProperty(TextField::Property::TEXT, "This is a long text for the size of the text-field.");
2700   field.SetProperty(TextField::Property::POINT_SIZE, 10.f);
2701   field.SetProperty(Actor::Property::SIZE, Vector2(300.f, 50.f));
2702   field.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT);
2703   field.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
2704
2705   // Avoid a crash when core load gl resources.
2706   application.GetGlAbstraction().SetCheckFramebufferStatusResult(GL_FRAMEBUFFER_COMPLETE);
2707   // Render and notify
2708   application.SendNotification();
2709   application.Render();
2710
2711   // Create a tap event to touch the text field.
2712   TestGenerateTap(application, 150.0f, 25.0f);
2713   // Render and notify
2714   application.SendNotification();
2715   application.Render();
2716
2717   // Tap first to get the focus.
2718   TestGenerateTap(application, 1.0f, 25.0f);
2719
2720   // Render and notify
2721   application.SendNotification();
2722   application.Render();
2723
2724   // Double tap to select a word.
2725   TestGenerateTap(application, 1.0f, 25.0f);
2726
2727   // Render and notify
2728   application.SendNotification();
2729   application.Render();
2730
2731   // Tap grab handle
2732   TestGenerateTap(application, 0.0f, 40.0f);
2733   END_TEST;
2734 }
2735
2736 int utcDaliTextFieldEvent05(void)
2737 {
2738   ToolkitTestApplication application;
2739   tet_infoline(" utcDaliTextFieldEvent05");
2740
2741   // Checks dragging of cursor/grab handle
2742
2743   TextField field = TextField::New();
2744   DALI_TEST_CHECK(field);
2745   application.GetScene().Add(field);
2746   LoadMarkerImages(application, field);
2747   // Render and notify
2748   application.SendNotification();
2749   application.Render();
2750
2751   field.SetProperty(TextField::Property::TEXT, "This is a long text for the size of the text-field.");
2752   field.SetProperty(TextField::Property::POINT_SIZE, 10.f);
2753   field.SetProperty(Actor::Property::SIZE, Vector2(300.f, 50.f));
2754   field.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT);
2755   field.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
2756
2757   // Avoid a crash when core load gl resources.
2758   application.GetGlAbstraction().SetCheckFramebufferStatusResult(GL_FRAMEBUFFER_COMPLETE);
2759   // Render and notify
2760   application.SendNotification();
2761   application.Render();
2762
2763   // Create a tap event to touch the text field.
2764   TestGenerateTap(application, 150.0f, 25.0f);
2765   // Render and notify
2766   application.SendNotification();
2767   application.Render();
2768
2769   // Tap first to get the focus.
2770   TestGenerateTap(application, 1.0f, 25.0f);
2771
2772   // Render and notify
2773   application.SendNotification();
2774   application.Render();
2775
2776   // Double tap to select a word.
2777   TestGenerateTap(application, 1.0f, 25.0f);
2778
2779   // Render and notify
2780   application.SendNotification();
2781   application.Render();
2782
2783   Actor stencil = field.GetChildAt(1u);
2784   END_TEST;
2785 }
2786
2787 int utcDaliTextFieldEvent06(void)
2788 {
2789   ToolkitTestApplication application;
2790   tet_infoline(" utcDaliTextFieldEvent06");
2791
2792   // Checks Longpress when in edit mode
2793
2794   TextField field = TextField::New();
2795   DALI_TEST_CHECK(field);
2796   application.GetScene().Add(field);
2797   LoadMarkerImages(application, field);
2798   // Render and notify
2799   application.SendNotification();
2800   application.Render();
2801
2802   field.SetProperty(TextField::Property::TEXT, "Thisisalongtextforthesizeofthetextfield.");
2803   field.SetProperty(TextField::Property::POINT_SIZE, 10.f);
2804   field.SetProperty(Actor::Property::SIZE, Vector2(300.f, 50.f));
2805   field.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT);
2806   field.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
2807
2808   // Avoid a crash when core load gl resources.
2809   application.GetGlAbstraction().SetCheckFramebufferStatusResult(GL_FRAMEBUFFER_COMPLETE);
2810   // Render and notify
2811   application.SendNotification();
2812   application.Render();
2813
2814   // Create a tap event to touch the text field.
2815   TestGenerateTap(application, 150.0f, 25.0f);
2816   // Render and notify
2817   application.SendNotification();
2818   application.Render();
2819
2820   // Tap first to get the focus.
2821   TestGenerateTap(application, 1.0f, 25.0f);
2822
2823   // Render and notify
2824   application.SendNotification();
2825   application.Render();
2826
2827   // Long Press
2828   TestGenerateLongPress(application, 1.0f, 25.0f);
2829
2830   // Render and notify
2831   application.SendNotification();
2832   application.Render();
2833
2834   END_TEST;
2835 }
2836
2837 int utcDaliTextFieldEvent07(void)
2838 {
2839   ToolkitTestApplication application;
2840   tet_infoline(" utcDaliTextFieldEvent07");
2841
2842   // Checks Longpress to start edit mode
2843
2844   TextField field = TextField::New();
2845   DALI_TEST_CHECK(field);
2846   application.GetScene().Add(field);
2847   LoadMarkerImages(application, field);
2848   // Render and notify
2849   application.SendNotification();
2850   application.Render();
2851
2852   field.SetProperty(TextField::Property::TEXT, "Thisisalongtextforthesizeofthetextfield.");
2853   field.SetProperty(TextField::Property::POINT_SIZE, 10.f);
2854   field.SetProperty(Actor::Property::SIZE, Vector2(300.f, 50.f));
2855   field.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT);
2856   field.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
2857   Property::Map propertyMap;
2858   propertyMap["PANEL_LAYOUT"] = InputMethod::PanelLayout::PASSWORD;
2859   field.SetProperty(TextField::Property::INPUT_METHOD_SETTINGS, propertyMap);
2860
2861   // Avoid a crash when core load gl resources.
2862   application.GetGlAbstraction().SetCheckFramebufferStatusResult(GL_FRAMEBUFFER_COMPLETE);
2863   // Render and notify
2864   application.SendNotification();
2865   application.Render();
2866
2867   // Long Press
2868   TestGenerateLongPress(application, 1.0f, 25.0f);
2869
2870   // Render and notify
2871   application.SendNotification();
2872   application.Render();
2873
2874   END_TEST;
2875 }
2876
2877 int utcDaliTextFieldEvent08(void)
2878 {
2879   ToolkitTestApplication application;
2880   tet_infoline(" utcDaliTextFieldEvent08");
2881
2882   Dali::Clipboard clipboard = Clipboard::Get();
2883   clipboard.SetItem("testTextFieldEvent");
2884
2885   // Checks Longpress when only place holder text
2886
2887   TextField field = TextField::New();
2888   DALI_TEST_CHECK(field);
2889   application.GetScene().Add(field);
2890   LoadMarkerImages(application, field);
2891   // Render and notify
2892   application.SendNotification();
2893   application.Render();
2894
2895   field.SetProperty(TextField::Property::PLACEHOLDER_TEXT, "Setting Placeholder Text");
2896   field.SetProperty(TextField::Property::POINT_SIZE, 10.f);
2897   field.SetProperty(Actor::Property::SIZE, Vector2(300.f, 50.f));
2898   field.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT);
2899   field.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
2900
2901   // Avoid a crash when core load gl resources.
2902   application.GetGlAbstraction().SetCheckFramebufferStatusResult(GL_FRAMEBUFFER_COMPLETE);
2903   // Render and notify
2904   application.SendNotification();
2905   application.Render();
2906
2907   // Long Press
2908   TestGenerateLongPress(application, 1.0f, 25.0f, 20);
2909
2910   // Render and notify
2911   application.SendNotification();
2912   application.Render();
2913
2914   Wait(application, 500);
2915
2916   TestEndLongPress(application, 1.0f, 25.0f, 520);
2917
2918   // Long Press
2919   TestGenerateLongPress(application, 1.0f, 25.0f, 600);
2920
2921   // Render and notify
2922   application.Render();
2923
2924   Wait(application, 500);
2925
2926   Integration::Scene stage = application.GetScene();
2927   Layer              layer = stage.GetRootLayer();
2928   Actor              actor = layer.FindChildByName("optionPaste");
2929
2930   if(actor)
2931   {
2932     Vector3 worldPosition = actor.GetCurrentProperty<Vector3>(Actor::Property::WORLD_POSITION);
2933     Vector2 halfStageSize = stage.GetSize() / 2.0f;
2934     Vector2 position(worldPosition.x + halfStageSize.width, worldPosition.y + halfStageSize.height);
2935
2936     Dali::Integration::TouchEvent event;
2937     event = Dali::Integration::TouchEvent();
2938     event.AddPoint(GetPointDownInside(position));
2939     application.ProcessEvent(event);
2940
2941     event = Dali::Integration::TouchEvent();
2942     event.AddPoint(GetPointUpInside(position));
2943     application.ProcessEvent(event);
2944   }
2945   DALI_TEST_EQUALS(field.GetProperty<std::string>(TextEditor::Property::TEXT), std::string("testTextFieldEvent"), TEST_LOCATION);
2946
2947   END_TEST;
2948 }
2949
2950 int utcDaliTextFieldEvent09(void)
2951 {
2952   ToolkitTestApplication application;
2953   tet_infoline(" utcDaliTextFieldEvent09");
2954
2955   TextField field = TextField::New();
2956   DALI_TEST_CHECK(field);
2957   application.GetScene().Add(field);
2958   LoadMarkerImages(application, field);
2959   // Render and notify
2960   application.SendNotification();
2961   application.Render();
2962
2963   field.SetProperty(TextField::Property::TEXT, "Hello");
2964   field.SetProperty(TextField::Property::POINT_SIZE, 10.f);
2965   field.SetProperty(Actor::Property::SIZE, Vector2(300.f, 50.f));
2966   field.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT);
2967   field.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
2968
2969   // Avoid a crash when core load gl resources.
2970   application.GetGlAbstraction().SetCheckFramebufferStatusResult(GL_FRAMEBUFFER_COMPLETE);
2971
2972   // Create a tap event to touch the text field.
2973   TestGenerateTap(application, 150.0f, 25.0f);
2974   application.SendNotification();
2975   application.Render();
2976
2977   Property::Map map;
2978   map[HiddenInput::Property::MODE] = HiddenInput::Mode::HIDE_NONE;
2979   field.SetProperty(TextField::Property::HIDDEN_INPUT_SETTINGS, map);
2980   application.ProcessEvent(GenerateKey("d", "", "d", 0, 0, 0, Integration::KeyEvent::DOWN, "d", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
2981   application.SendNotification();
2982   application.Render();
2983
2984   map[HiddenInput::Property::MODE]                 = HiddenInput::Mode::HIDE_ALL;
2985   map[HiddenInput::Property::SUBSTITUTE_CHARACTER] = 0x23;
2986   field.SetProperty(TextField::Property::HIDDEN_INPUT_SETTINGS, map);
2987   application.ProcessEvent(GenerateKey("d", "", "d", 0, 0, 0, Integration::KeyEvent::DOWN, "d", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
2988   application.SendNotification();
2989   application.Render();
2990
2991   map[HiddenInput::Property::MODE]             = HiddenInput::Mode::HIDE_COUNT;
2992   map[HiddenInput::Property::SUBSTITUTE_COUNT] = 2;
2993   field.SetProperty(TextField::Property::HIDDEN_INPUT_SETTINGS, map);
2994   for(unsigned int index = 0u; index < 5u; ++index)
2995   {
2996     application.ProcessEvent(GenerateKey("d", "", "d", 0, 0, 0, Integration::KeyEvent::DOWN, "d", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
2997     application.SendNotification();
2998     application.Render();
2999   }
3000
3001   map[HiddenInput::Property::MODE]             = HiddenInput::Mode::SHOW_COUNT;
3002   map[HiddenInput::Property::SUBSTITUTE_COUNT] = 2;
3003   field.SetProperty(TextField::Property::HIDDEN_INPUT_SETTINGS, map);
3004   for(unsigned int index = 0u; index < 5u; ++index)
3005   {
3006     application.ProcessEvent(GenerateKey("d", "", "d", 0, 0, 0, Integration::KeyEvent::DOWN, "d", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
3007     application.SendNotification();
3008     application.Render();
3009   }
3010
3011   map[HiddenInput::Property::MODE]                         = HiddenInput::Mode::SHOW_LAST_CHARACTER;
3012   map[HiddenInput::Property::SHOW_LAST_CHARACTER_DURATION] = 0;
3013   field.SetProperty(TextField::Property::HIDDEN_INPUT_SETTINGS, map);
3014   application.ProcessEvent(GenerateKey("", "", "", DALI_KEY_BACKSPACE, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
3015   application.SendNotification();
3016   application.Render();
3017   application.ProcessEvent(GenerateKey("d", "", "d", 0, 0, 0, Integration::KeyEvent::DOWN, "d", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
3018   application.SendNotification();
3019   application.Render();
3020
3021   map[HiddenInput::Property::SHOW_LAST_CHARACTER_DURATION] = 100;
3022   field.SetProperty(TextField::Property::HIDDEN_INPUT_SETTINGS, map);
3023   application.ProcessEvent(GenerateKey("d", "", "d", 0, 0, 0, Integration::KeyEvent::DOWN, "d", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
3024   application.SendNotification();
3025   application.Render();
3026
3027   Property::Map mapGet;
3028   mapGet = field.GetProperty<Property::Map>(TextField::Property::HIDDEN_INPUT_SETTINGS);
3029   DALI_TEST_EQUALS(map.Count(), mapGet.Count(), TEST_LOCATION);
3030   DALI_TEST_EQUALS(DaliTestCheckMaps(map, mapGet), true, TEST_LOCATION);
3031   END_TEST;
3032 }
3033
3034 int utcDaliTextFieldStyleWhilstSelected(void)
3035 {
3036   ToolkitTestApplication application;
3037   tet_infoline(" utcDaliTextFieldStyleWhilstSelected");
3038
3039   // Change font and styles whilst text is selected whilst word selected
3040
3041   TextField field = TextField::New();
3042   DALI_TEST_CHECK(field);
3043   application.GetScene().Add(field);
3044   LoadMarkerImages(application, field);
3045   // Render and notify
3046   application.SendNotification();
3047   application.Render();
3048
3049   field.SetProperty(TextField::Property::TEXT, "This is a long text for the size of the text-field.");
3050   field.SetProperty(TextField::Property::POINT_SIZE, 10.f);
3051   field.SetProperty(Actor::Property::SIZE, Vector2(300.f, 50.f));
3052   field.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT);
3053   field.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
3054
3055   // Avoid a crash when core load gl resources.
3056   application.GetGlAbstraction().SetCheckFramebufferStatusResult(GL_FRAMEBUFFER_COMPLETE);
3057   // Render and notify
3058   application.SendNotification();
3059   application.Render();
3060
3061   // Create a tap event to touch the text field.
3062   TestGenerateTap(application, 150.0f, 25.0f);
3063   // Render and notify
3064   application.SendNotification();
3065   application.Render();
3066
3067   // Tap first to get the focus.
3068   TestGenerateTap(application, 1.0f, 25.0f);
3069
3070   // Render and notify
3071   application.SendNotification();
3072   application.Render();
3073
3074   // Double tap to select a word.
3075   TestGenerateTap(application, 1.0f, 25.0f);