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