Make we use valid geometry if broken image was n-patch and reloaded
[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   END_TEST;
3031 }
3032
3033 int utcDaliTextFieldEvent05(void)
3034 {
3035   ToolkitTestApplication application;
3036   tet_infoline(" utcDaliTextFieldEvent05");
3037
3038   // Checks dragging of cursor/grab handle
3039
3040   TextField field = TextField::New();
3041   DALI_TEST_CHECK(field);
3042   application.GetScene().Add(field);
3043   LoadMarkerImages(application, field);
3044   // Render and notify
3045   application.SendNotification();
3046   application.Render();
3047
3048   field.SetProperty(TextField::Property::TEXT, "This is a long text for the size of the text-field.");
3049   field.SetProperty(TextField::Property::POINT_SIZE, 10.f);
3050   field.SetProperty(Actor::Property::SIZE, Vector2(300.f, 50.f));
3051   field.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT);
3052   field.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
3053
3054   // Avoid a crash when core load gl resources.
3055   application.GetGlAbstraction().SetCheckFramebufferStatusResult(GL_FRAMEBUFFER_COMPLETE);
3056   // Render and notify
3057   application.SendNotification();
3058   application.Render();
3059
3060   // Create a tap event to touch the text field.
3061   TestGenerateTap(application, 150.0f, 25.0f);
3062   // Render and notify
3063   application.SendNotification();
3064   application.Render();
3065
3066   // Tap first to get the focus.
3067   TestGenerateTap(application, 1.0f, 25.0f);
3068
3069   // Render and notify
3070   application.SendNotification();
3071   application.Render();
3072
3073   // Double tap to select a word.
3074   TestGenerateTap(application, 1.0f, 25.0f);
3075
3076   // Render and notify
3077   application.SendNotification();
3078   application.Render();
3079
3080   Actor stencil = field.GetChildAt(1u);
3081   END_TEST;
3082 }
3083
3084 int utcDaliTextFieldEvent06(void)
3085 {
3086   ToolkitTestApplication application;
3087   tet_infoline(" utcDaliTextFieldEvent06");
3088
3089   // Checks Longpress when in edit mode
3090
3091   TextField field = TextField::New();
3092   DALI_TEST_CHECK(field);
3093   application.GetScene().Add(field);
3094   LoadMarkerImages(application, field);
3095   // Render and notify
3096   application.SendNotification();
3097   application.Render();
3098
3099   field.SetProperty(TextField::Property::TEXT, "Thisisalongtextforthesizeofthetextfield.");
3100   field.SetProperty(TextField::Property::POINT_SIZE, 10.f);
3101   field.SetProperty(Actor::Property::SIZE, Vector2(300.f, 50.f));
3102   field.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT);
3103   field.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
3104
3105   // Avoid a crash when core load gl resources.
3106   application.GetGlAbstraction().SetCheckFramebufferStatusResult(GL_FRAMEBUFFER_COMPLETE);
3107   // Render and notify
3108   application.SendNotification();
3109   application.Render();
3110
3111   // Create a tap event to touch the text field.
3112   TestGenerateTap(application, 150.0f, 25.0f);
3113   // Render and notify
3114   application.SendNotification();
3115   application.Render();
3116
3117   // Tap first to get the focus.
3118   TestGenerateTap(application, 1.0f, 25.0f);
3119
3120   // Render and notify
3121   application.SendNotification();
3122   application.Render();
3123
3124   // Long Press
3125   TestGenerateLongPress(application, 1.0f, 25.0f);
3126
3127   // Render and notify
3128   application.SendNotification();
3129   application.Render();
3130
3131   END_TEST;
3132 }
3133
3134 int utcDaliTextFieldEvent07(void)
3135 {
3136   ToolkitTestApplication application;
3137   tet_infoline(" utcDaliTextFieldEvent07");
3138
3139   // Checks Longpress to start edit mode
3140
3141   TextField field = TextField::New();
3142   DALI_TEST_CHECK(field);
3143   application.GetScene().Add(field);
3144   LoadMarkerImages(application, field);
3145   // Render and notify
3146   application.SendNotification();
3147   application.Render();
3148
3149   field.SetProperty(TextField::Property::TEXT, "Thisisalongtextforthesizeofthetextfield.");
3150   field.SetProperty(TextField::Property::POINT_SIZE, 10.f);
3151   field.SetProperty(Actor::Property::SIZE, Vector2(300.f, 50.f));
3152   field.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT);
3153   field.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
3154   Property::Map propertyMap;
3155   propertyMap["PANEL_LAYOUT"] = InputMethod::PanelLayout::PASSWORD;
3156   field.SetProperty(TextField::Property::INPUT_METHOD_SETTINGS, propertyMap);
3157
3158   // Avoid a crash when core load gl resources.
3159   application.GetGlAbstraction().SetCheckFramebufferStatusResult(GL_FRAMEBUFFER_COMPLETE);
3160   // Render and notify
3161   application.SendNotification();
3162   application.Render();
3163
3164   // Long Press
3165   TestGenerateLongPress(application, 1.0f, 25.0f);
3166
3167   // Render and notify
3168   application.SendNotification();
3169   application.Render();
3170
3171   END_TEST;
3172 }
3173
3174 int utcDaliTextFieldEvent08(void)
3175 {
3176   ToolkitTestApplication application;
3177   tet_infoline(" utcDaliTextFieldEvent08");
3178
3179   Dali::Clipboard           clipboard = Clipboard::Get();
3180   Dali::Clipboard::ClipData data("text/plain;charset=utf-8", "testTextFieldEvent");
3181   clipboard.SetData(data);
3182
3183   // Checks Longpress when only place holder text
3184
3185   TextField field = TextField::New();
3186   DALI_TEST_CHECK(field);
3187   application.GetScene().Add(field);
3188   LoadMarkerImages(application, field);
3189   // Render and notify
3190   application.SendNotification();
3191   application.Render();
3192
3193   field.SetProperty(TextField::Property::PLACEHOLDER_TEXT, "Setting Placeholder Text");
3194   field.SetProperty(TextField::Property::POINT_SIZE, 10.f);
3195   field.SetProperty(Actor::Property::SIZE, Vector2(300.f, 50.f));
3196   field.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT);
3197   field.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
3198
3199   // Avoid a crash when core load gl resources.
3200   application.GetGlAbstraction().SetCheckFramebufferStatusResult(GL_FRAMEBUFFER_COMPLETE);
3201   // Render and notify
3202   application.SendNotification();
3203   application.Render();
3204
3205   // Long Press
3206   TestGenerateLongPress(application, 1.0f, 25.0f, 20);
3207
3208   // Render and notify
3209   application.SendNotification();
3210   application.Render();
3211
3212   Wait(application, 500);
3213
3214   TestEndLongPress(application, 1.0f, 25.0f, 520);
3215
3216   // Long Press
3217   TestGenerateLongPress(application, 1.0f, 25.0f, 600);
3218
3219   // Render and notify
3220   application.Render();
3221
3222   Wait(application, 500);
3223
3224   Integration::Scene stage = application.GetScene();
3225   Layer              layer = stage.GetRootLayer();
3226   Actor              actor = layer.FindChildByName("optionPaste");
3227
3228   if(actor)
3229   {
3230     Vector3 worldPosition = actor.GetCurrentProperty<Vector3>(Actor::Property::WORLD_POSITION);
3231     Vector2 halfStageSize = stage.GetSize() / 2.0f;
3232     Vector2 position(worldPosition.x + halfStageSize.width, worldPosition.y + halfStageSize.height);
3233
3234     Dali::Integration::TouchEvent event;
3235     event = Dali::Integration::TouchEvent();
3236     event.AddPoint(GetPointDownInside(position));
3237     application.ProcessEvent(event);
3238
3239     event = Dali::Integration::TouchEvent();
3240     event.AddPoint(GetPointUpInside(position));
3241     application.ProcessEvent(event);
3242   }
3243   DALI_TEST_EQUALS(field.GetProperty<std::string>(TextEditor::Property::TEXT), std::string("testTextFieldEvent"), TEST_LOCATION);
3244
3245   END_TEST;
3246 }
3247
3248 int utcDaliTextFieldEvent09(void)
3249 {
3250   ToolkitTestApplication application;
3251   tet_infoline(" utcDaliTextFieldEvent09");
3252
3253   TextField field = TextField::New();
3254   DALI_TEST_CHECK(field);
3255   application.GetScene().Add(field);
3256   LoadMarkerImages(application, field);
3257   // Render and notify
3258   application.SendNotification();
3259   application.Render();
3260
3261   field.SetProperty(TextField::Property::TEXT, "Hello");
3262   field.SetProperty(TextField::Property::PLACEHOLDER_TEXT, "Placeholder text");
3263   field.SetProperty(TextField::Property::POINT_SIZE, 10.f);
3264   field.SetProperty(Actor::Property::SIZE, Vector2(300.f, 50.f));
3265   field.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT);
3266   field.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
3267
3268   // Avoid a crash when core load gl resources.
3269   application.GetGlAbstraction().SetCheckFramebufferStatusResult(GL_FRAMEBUFFER_COMPLETE);
3270
3271   // Create a tap event to touch the text field.
3272   TestGenerateTap(application, 150.0f, 25.0f);
3273   application.SendNotification();
3274   application.Render();
3275
3276   Property::Map map;
3277   map[HiddenInput::Property::MODE] = HiddenInput::Mode::HIDE_NONE;
3278   field.SetProperty(TextField::Property::HIDDEN_INPUT_SETTINGS, map);
3279   application.ProcessEvent(GenerateKey("d", "", "d", 0, 0, 0, Integration::KeyEvent::DOWN, "d", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
3280   application.SendNotification();
3281   application.Render();
3282   for(unsigned int index = 0u; index < 6u; ++index)
3283   {
3284     application.ProcessEvent(GenerateKey("", "", "", DALI_KEY_BACKSPACE, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
3285     application.SendNotification();
3286     application.Render();
3287   }
3288
3289   map[HiddenInput::Property::MODE]                 = HiddenInput::Mode::HIDE_ALL;
3290   map[HiddenInput::Property::SUBSTITUTE_CHARACTER] = 0x23;
3291   field.SetProperty(TextField::Property::HIDDEN_INPUT_SETTINGS, map);
3292   application.ProcessEvent(GenerateKey("d", "", "d", 0, 0, 0, Integration::KeyEvent::DOWN, "d", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
3293   application.SendNotification();
3294   application.Render();
3295
3296   map[HiddenInput::Property::MODE]             = HiddenInput::Mode::HIDE_COUNT;
3297   map[HiddenInput::Property::SUBSTITUTE_COUNT] = 2;
3298   field.SetProperty(TextField::Property::HIDDEN_INPUT_SETTINGS, map);
3299   for(unsigned int index = 0u; index < 5u; ++index)
3300   {
3301     application.ProcessEvent(GenerateKey("d", "", "d", 0, 0, 0, Integration::KeyEvent::DOWN, "d", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
3302     application.SendNotification();
3303     application.Render();
3304   }
3305
3306   map[HiddenInput::Property::MODE]             = HiddenInput::Mode::SHOW_COUNT;
3307   map[HiddenInput::Property::SUBSTITUTE_COUNT] = 2;
3308   field.SetProperty(TextField::Property::HIDDEN_INPUT_SETTINGS, map);
3309   for(unsigned int index = 0u; index < 5u; ++index)
3310   {
3311     application.ProcessEvent(GenerateKey("d", "", "d", 0, 0, 0, Integration::KeyEvent::DOWN, "d", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
3312     application.SendNotification();
3313     application.Render();
3314   }
3315
3316   map[HiddenInput::Property::MODE]                         = HiddenInput::Mode::SHOW_LAST_CHARACTER;
3317   map[HiddenInput::Property::SHOW_LAST_CHARACTER_DURATION] = 0;
3318   field.SetProperty(TextField::Property::HIDDEN_INPUT_SETTINGS, map);
3319   application.ProcessEvent(GenerateKey("", "", "", DALI_KEY_BACKSPACE, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
3320   application.SendNotification();
3321   application.Render();
3322   application.ProcessEvent(GenerateKey("d", "", "d", 0, 0, 0, Integration::KeyEvent::DOWN, "d", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
3323   application.SendNotification();
3324   application.Render();
3325
3326   map[HiddenInput::Property::SHOW_LAST_CHARACTER_DURATION] = 100;
3327   field.SetProperty(TextField::Property::HIDDEN_INPUT_SETTINGS, map);
3328   application.ProcessEvent(GenerateKey("d", "", "d", 0, 0, 0, Integration::KeyEvent::DOWN, "d", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
3329   application.SendNotification();
3330   application.Render();
3331
3332   Property::Map mapGet;
3333   mapGet = field.GetProperty<Property::Map>(TextField::Property::HIDDEN_INPUT_SETTINGS);
3334   DALI_TEST_EQUALS(map.Count(), mapGet.Count(), TEST_LOCATION);
3335   DALI_TEST_EQUALS(DaliTestCheckMaps(map, mapGet), true, TEST_LOCATION);
3336   END_TEST;
3337 }
3338
3339 int utcDaliTextFieldStyleWhilstSelected(void)
3340 {
3341   ToolkitTestApplication application;
3342   tet_infoline(" utcDaliTextFieldStyleWhilstSelected");
3343
3344   // Change font and styles whilst text is selected whilst word selected
3345
3346   TextField field = TextField::New();
3347   DALI_TEST_CHECK(field);
3348   application.GetScene().Add(field);
3349   LoadMarkerImages(application, field);
3350   // Render and notify
3351   application.SendNotification();
3352   application.Render();
3353
3354   field.SetProperty(TextField::Property::TEXT, "This is a long text for the size of the text-field.");
3355   field.SetProperty(TextField::Property::POINT_SIZE, 10.f);
3356   field.SetProperty(Actor::Property::SIZE, Vector2(300.f, 50.f));
3357   field.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT);
3358   field.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
3359
3360   // Avoid a crash when core load gl resources.
3361   application.GetGlAbstraction().SetCheckFramebufferStatusResult(GL_FRAMEBUFFER_COMPLETE);
3362   // Render and notify
3363   application.SendNotification();
3364   application.Render();
3365
3366   // Create a tap event to touch the text field.
3367   TestGenerateTap(application, 150.0f, 25.0f);
3368   // Render and notify
3369   application.SendNotification();
3370   application.Render();
3371
3372   // Tap first to get the focus.
3373   TestGenerateTap(application, 1.0f, 25.0f);
3374
3375   // Render and notify
3376   application.SendNotification();
3377   application.Render();
3378
3379   // Double tap to select a word.
3380   TestGenerateTap(application, 1.0f, 25.0f);
3381
3382   // Render and notify
3383   application.SendNotification();
3384   application.Render();
3385
3386   field.SetProperty(TextField::Property::INPUT_FONT_FAMILY, "Setting input font family");
3387   DALI_TEST_EQUALS(field.GetProperty<std::string>(TextField::Property::INPUT_FONT_FAMILY), "Setting input font family", TEST_LOCATION);
3388
3389   Property::Map fontStyleMapSet;
3390   Property::Map fontStyleMapGet;
3391
3392   fontStyleMapSet.Insert("weight", "bold");
3393   fontStyleMapSet.Insert("slant", "italic");
3394   field.SetProperty(TextField::Property::INPUT_FONT_STYLE, fontStyleMapSet);
3395
3396   fontStyleMapGet = field.GetProperty<Property::Map>(TextField::Property::INPUT_FONT_STYLE);
3397   DALI_TEST_EQUALS(fontStyleMapGet.Count(), fontStyleMapSet.Count(), TEST_LOCATION);
3398   DALI_TEST_EQUALS(DaliTestCheckMaps(fontStyleMapGet, fontStyleMapSet), true, TEST_LOCATION);
3399
3400   fontStyleMapSet.Clear();
3401   fontStyleMapSet.Insert("width", "expanded");
3402   fontStyleMapSet.Insert("slant", "italic");
3403   field.SetProperty(TextField::Property::INPUT_FONT_STYLE, fontStyleMapSet);
3404
3405   fontStyleMapGet = field.GetProperty<Property::Map>(TextField::Property::INPUT_FONT_STYLE);
3406   DALI_TEST_EQUALS(fontStyleMapGet.Count(), fontStyleMapSet.Count(), TEST_LOCATION);
3407   DALI_TEST_EQUALS(DaliTestCheckMaps(fontStyleMapGet, fontStyleMapSet), true, TEST_LOCATION);
3408
3409   field.SetProperty(TextField::Property::INPUT_POINT_SIZE, 12.f);
3410   DALI_TEST_EQUALS(field.GetProperty<float>(TextField::Property::INPUT_POINT_SIZE), 12.f, Math::MACHINE_EPSILON_1000, TEST_LOCATION);
3411
3412   field.SetProperty(TextField::Property::TEXT_COLOR, Color::RED);
3413   DALI_TEST_EQUALS(field.GetProperty<Vector4>(TextField::Property::TEXT_COLOR), Color::RED, TEST_LOCATION);
3414
3415   fontStyleMapSet.Clear();
3416   fontStyleMapSet.Insert("weight", "bold");
3417   fontStyleMapSet.Insert("slant", "italic");
3418
3419   field.SetProperty(TextField::Property::FONT_STYLE, fontStyleMapSet);
3420
3421   fontStyleMapGet = field.GetProperty<Property::Map>(TextField::Property::FONT_STYLE);
3422   DALI_TEST_EQUALS(fontStyleMapGet.Count(), fontStyleMapSet.Count(), TEST_LOCATION);
3423   DALI_TEST_EQUALS(DaliTestCheckMaps(fontStyleMapGet, fontStyleMapSet), true, TEST_LOCATION);
3424
3425   fontStyleMapSet.Clear();
3426   fontStyleMapSet.Insert("width", "expanded");
3427
3428   field.SetProperty(TextField::Property::FONT_STYLE, fontStyleMapSet);
3429
3430   fontStyleMapGet = field.GetProperty<Property::Map>(TextField::Property::FONT_STYLE);
3431   DALI_TEST_EQUALS(fontStyleMapGet.Count(), fontStyleMapSet.Count(), TEST_LOCATION);
3432   DALI_TEST_EQUALS(DaliTestCheckMaps(fontStyleMapGet, fontStyleMapSet), true, TEST_LOCATION);
3433
3434   // Press Escape to increase coverage
3435   application.ProcessEvent(GenerateKey("", "", "", DALI_KEY_ESCAPE, 0, 0, Integration::KeyEvent::UP, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
3436   application.SendNotification();
3437   application.Render();
3438
3439   DALI_TEST_CHECK(!field.HasKeyInputFocus());
3440
3441   END_TEST;
3442 }
3443
3444 int utcDaliTextFieldEscKeyLoseFocus(void)
3445 {
3446   ToolkitTestApplication application;
3447   tet_infoline(" utcDaliTextFieldEscKeyLoseFocus");
3448
3449   // Creates a tap event. After creating a tap event the text field should
3450   // have the focus and add text with key events should be possible.
3451
3452   TextField field = TextField::New();
3453   DALI_TEST_CHECK(field);
3454
3455   application.GetScene().Add(field);
3456
3457   field.SetProperty(Actor::Property::SIZE, Vector2(300.f, 50.f));
3458   field.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT);
3459   field.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
3460
3461   // Avoid a crash when core load gl resources.
3462   application.GetGlAbstraction().SetCheckFramebufferStatusResult(GL_FRAMEBUFFER_COMPLETE);
3463
3464   // Render and notify
3465   application.SendNotification();
3466   application.Render();
3467
3468   // Add a key event but as the text field has not the focus it should do nothing.
3469   application.ProcessEvent(GenerateKey("a", "", "a", KEY_A_CODE, 0, 0, Integration::KeyEvent::DOWN, "a", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
3470   application.ProcessEvent(GenerateKey("a", "", "a", KEY_A_CODE, 0, 0, Integration::KeyEvent::UP, "a", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
3471
3472   // Render and notify
3473   application.SendNotification();
3474   application.Render();
3475
3476   DALI_TEST_EQUALS(field.GetProperty<std::string>(TextField::Property::TEXT), std::string(""), TEST_LOCATION);
3477
3478   // Create a tap event to touch the text field.
3479   TestGenerateTap(application, 150.0f, 25.0f);
3480
3481   // Render and notify
3482   application.SendNotification();
3483   application.Render();
3484
3485   // Now the text field has the focus, so it can handle the key events.
3486   application.ProcessEvent(GenerateKey("a", "", "a", KEY_A_CODE, 0, 0, Integration::KeyEvent::DOWN, "a", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
3487   application.ProcessEvent(GenerateKey("a", "", "a", KEY_A_CODE, 0, 0, Integration::KeyEvent::UP, "a", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
3488   application.ProcessEvent(GenerateKey("d", "", "d", KEY_D_CODE, 0, 0, Integration::KeyEvent::DOWN, "d", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
3489   application.ProcessEvent(GenerateKey("d", "", "d", KEY_D_CODE, 0, 0, Integration::KeyEvent::UP, "d", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
3490
3491   // Render and notify
3492   application.SendNotification();
3493   application.Render();
3494
3495   DALI_TEST_EQUALS(field.GetProperty<std::string>(TextField::Property::TEXT), std::string("ad"), TEST_LOCATION);
3496
3497   // Generate a Esc key event. The text field should lose the focus.
3498   application.ProcessEvent(GenerateKey("", "", "", DALI_KEY_ESCAPE, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
3499   application.ProcessEvent(GenerateKey("", "", "", DALI_KEY_ESCAPE, 0, 0, Integration::KeyEvent::UP, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
3500
3501   // Render and notify
3502   application.SendNotification();
3503   application.Render();
3504
3505   DALI_TEST_EQUALS(false, field.HasKeyInputFocus(), TEST_LOCATION);
3506
3507   // No more text should be introduced
3508   application.ProcessEvent(GenerateKey("a", "", "a", KEY_A_CODE, 0, 0, Integration::KeyEvent::DOWN, "a", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
3509   application.ProcessEvent(GenerateKey("a", "", "a", KEY_A_CODE, 0, 0, Integration::KeyEvent::UP, "a", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
3510
3511   // Render and notify
3512   application.SendNotification();
3513   application.Render();
3514
3515   DALI_TEST_EQUALS(field.GetProperty<std::string>(TextField::Property::TEXT), std::string("ad"), TEST_LOCATION);
3516
3517   END_TEST;
3518 }
3519
3520 int utcDaliTextFieldSomeSpecialKeys(void)
3521 {
3522   ToolkitTestApplication application;
3523   tet_infoline(" utcDaliTextFieldSomeSpecialKeys");
3524
3525   // Checks some special keys when the text is selected.
3526
3527   TextField field = TextField::New();
3528   DALI_TEST_CHECK(field);
3529   application.GetScene().Add(field);
3530   LoadMarkerImages(application, field);
3531   // Render and notify
3532   application.SendNotification();
3533   application.Render();
3534
3535   const std::string longText("This is a long text for the size of the text-field.");
3536
3537   field.SetProperty(TextField::Property::TEXT, longText);
3538   field.SetProperty(TextField::Property::POINT_SIZE, 10.f);
3539   field.SetProperty(Actor::Property::SIZE, Vector2(300.f, 50.f));
3540   field.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT);
3541   field.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
3542
3543   // Avoid a crash when core load gl resources.
3544   application.GetGlAbstraction().SetCheckFramebufferStatusResult(GL_FRAMEBUFFER_COMPLETE);
3545   // Render and notify
3546   application.SendNotification();
3547   application.Render();
3548
3549   // Create a tap event to touch the text field.
3550   TestGenerateTap(application, 150.0f, 25.0f);
3551
3552   // Render and notify
3553   application.SendNotification();
3554   application.Render();
3555
3556   // Tap first to get the focus.
3557   TestGenerateTap(application, 1.0f, 25.0f);
3558
3559   // Render and notify
3560   application.SendNotification();
3561   application.Render();
3562
3563   // Double tap to select a word.
3564   TestGenerateTap(application, 1.0f, 25.0f);
3565
3566   // Render and notify
3567   application.SendNotification();
3568   application.Render();
3569
3570   // Generate a Esc key event. The text field should lose the focus.
3571   application.ProcessEvent(GenerateKey("XF86PowerOff", "", "XF86PowerOff", DALI_KEY_POWER, 0, 0, Integration::KeyEvent::DOWN, "XF86PowerOff", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
3572   application.ProcessEvent(GenerateKey("XF86PowerOff", "", "XF86PowerOff", DALI_KEY_POWER, 0, 0, Integration::KeyEvent::UP, "XF86PowerOff", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
3573
3574   // Render and notify
3575   application.SendNotification();
3576   application.Render();
3577
3578   // Generate a Esc key event. The text field should lose the focus.
3579   application.ProcessEvent(GenerateKey("XF86Menu", "", "XF86Menu", DALI_KEY_MENU, 0, 0, Integration::KeyEvent::DOWN, "XF86Menu", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
3580   application.ProcessEvent(GenerateKey("XF86Menu", "", "XF86Menu", DALI_KEY_MENU, 0, 0, Integration::KeyEvent::UP, "XF86Menu", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
3581
3582   // Render and notify
3583   application.SendNotification();
3584   application.Render();
3585
3586   // Generate a Esc key event. The text field should lose the focus.
3587   application.ProcessEvent(GenerateKey("XF86Home", "", "XF86Home", DALI_KEY_HOME, 0, 0, Integration::KeyEvent::DOWN, "XF86Home", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
3588   application.ProcessEvent(GenerateKey("XF86Home", "", "XF86Home", DALI_KEY_HOME, 0, 0, Integration::KeyEvent::UP, "XF86Home", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
3589
3590   // Render and notify
3591   application.SendNotification();
3592   application.Render();
3593
3594   // Generate a Back key event. Nothing happens to the text field.
3595   application.ProcessEvent(GenerateKey("XF86Back", "", "XF86Back", DALI_KEY_BACK, 0, 0, Integration::KeyEvent::DOWN, "XF86Back", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
3596   application.ProcessEvent(GenerateKey("XF86Back", "", "XF86Back", DALI_KEY_BACK, 0, 0, Integration::KeyEvent::UP, "XF86Back", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
3597
3598   // Render and notify
3599   application.SendNotification();
3600   application.Render();
3601
3602   // The text shouldn't be deleted.
3603   DALI_TEST_EQUALS(field.GetProperty<std::string>(TextField::Property::TEXT), longText, TEST_LOCATION);
3604
3605   END_TEST;
3606 }
3607
3608 int utcDaliTextFieldSizeUpdate(void)
3609 {
3610   ToolkitTestApplication application;
3611   tet_infoline("utcDaliTextFieldSizeUpdate");
3612
3613   // Checks some special keys when the text is selected.
3614   TextField field = TextField::New();
3615   DALI_TEST_CHECK(field);
3616   application.GetScene().Add(field);
3617
3618   float       previousHeight = 0.0f;
3619   float       currentHeight  = 0.0f;
3620   const float fieldWidth     = 1920.0f;
3621
3622   // "ㅁ" is bigger then "ኢ"
3623   field.SetProperty(Actor::Property::SIZE, Vector2(fieldWidth, 10.0f));
3624   field.SetResizePolicy(ResizePolicy::FIXED, Dimension::WIDTH);
3625   field.SetResizePolicy(ResizePolicy::DIMENSION_DEPENDENCY, Dimension::HEIGHT);
3626
3627   field.SetProperty(TextField::Property::TEXT, "ኢ");
3628   field.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT);
3629   field.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
3630
3631   field.SetProperty(Actor::Property::KEYBOARD_FOCUSABLE, true);
3632   KeyboardFocusManager::Get().SetCurrentFocusActor(field);
3633
3634   application.SendNotification();
3635   application.Render();
3636
3637   previousHeight = field.GetHeightForWidth(fieldWidth);
3638   DALI_TEST_EQUALS(previousHeight, field.GetProperty<float>(Actor::Property::SIZE_HEIGHT), TEST_LOCATION);
3639
3640   // Add  another script characters ( glyph height is defferent )
3641   application.ProcessEvent(GenerateKey("ㅁ", "", "ㅁ", KEY_A_CODE, 0, 0, Integration::KeyEvent::DOWN, "ㅁ", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
3642   application.ProcessEvent(GenerateKey("ㅁ", "", "ㅁ", KEY_A_CODE, 0, 0, Integration::KeyEvent::UP, "ㅁ", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
3643
3644   application.SendNotification();
3645   application.Render();
3646
3647   currentHeight = field.GetHeightForWidth(fieldWidth);
3648   DALI_TEST_EQUALS(currentHeight, field.GetProperty<float>(Actor::Property::SIZE_HEIGHT), TEST_LOCATION);
3649   DALI_TEST_EQUALS((previousHeight < currentHeight), true, TEST_LOCATION);
3650
3651   END_TEST;
3652 }
3653
3654 int utcDaliTextFieldExtremlyLargePointSize(void)
3655 {
3656   ToolkitTestApplication application;
3657   tet_infoline(" utcDaliTextFieldExtremlyLargePointSize");
3658
3659   TextField field = TextField::New();
3660
3661   field.SetProperty(TextField::Property::TEXT, "Text");
3662   field.SetProperty(Actor::Property::SIZE, Vector2(300.f, 50.f));
3663   field.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT);
3664   field.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
3665   application.GetScene().Add(field);
3666
3667   try
3668   {
3669     field.SetProperty(TextField::Property::POINT_SIZE, 160.0f);
3670     application.SendNotification();
3671     DALI_TEST_CHECK(field);
3672   }
3673   catch(...)
3674   {
3675     tet_result(TET_FAIL);
3676   }
3677   END_TEST;
3678 }
3679
3680 int UtcDaliTextFieldDefaultFontStylePropertyCoverage(void)
3681 {
3682   ToolkitTestApplication application;
3683   tet_infoline("UtcDaliTextFieldFontStylePorpertyCoverage");
3684   TextField field = TextField::New();
3685   DALI_TEST_CHECK(field);
3686   application.GetScene().Add(field);
3687
3688   Property::Map fontStyleMapGet;
3689
3690   fontStyleMapGet = field.GetProperty<Property::Map>(TextField::Property::FONT_STYLE);
3691
3692   Property::Value* weightValue = NULL;
3693   Property::Value* widthValue  = NULL;
3694   Property::Value* slantValue  = NULL;
3695   weightValue                  = fontStyleMapGet.Find("weight");
3696   widthValue                   = fontStyleMapGet.Find("width");
3697   slantValue                   = fontStyleMapGet.Find("slant");
3698   DALI_TEST_CHECK(!weightValue);
3699   DALI_TEST_CHECK(!widthValue);
3700   DALI_TEST_CHECK(!slantValue);
3701
3702   END_TEST;
3703 }
3704
3705 int UtcDaliTextFieldSettingPlaceholder(void)
3706 {
3707   ToolkitTestApplication application;
3708   tet_infoline("UtcDaliTextFieldSettingPlaceholder");
3709
3710   TextField field = TextField::New();
3711   DALI_TEST_CHECK(field);
3712   application.GetScene().Add(field);
3713
3714   // Check the placeholder property with pixel size
3715   Property::Map placeholderPixelSizeMapSet;
3716   Property::Map placeholderPixelSizeMapGet;
3717   Property::Map placeholderFontstyleMap;
3718   placeholderPixelSizeMapSet[Text::PlaceHolder::Property::TEXT]         = "Setting Placeholder Text";
3719   placeholderPixelSizeMapSet[Text::PlaceHolder::Property::TEXT_FOCUSED] = "Setting Placeholder Text Focused";
3720   placeholderPixelSizeMapSet[Text::PlaceHolder::Property::COLOR]        = Color::BLUE;
3721   placeholderPixelSizeMapSet[Text::PlaceHolder::Property::FONT_FAMILY]  = "Arial";
3722   placeholderPixelSizeMapSet[Text::PlaceHolder::Property::PIXEL_SIZE]   = 15.0f;
3723   placeholderPixelSizeMapSet[Text::PlaceHolder::Property::ELLIPSIS]     = true;
3724
3725   placeholderFontstyleMap.Insert("weight", "bold");
3726   placeholderPixelSizeMapSet[Text::PlaceHolder::Property::FONT_STYLE] = placeholderFontstyleMap;
3727   field.SetProperty(TextField::Property::PLACEHOLDER, placeholderPixelSizeMapSet);
3728
3729   placeholderPixelSizeMapGet = field.GetProperty<Property::Map>(TextField::Property::PLACEHOLDER);
3730   DALI_TEST_EQUALS(placeholderPixelSizeMapGet.Count(), placeholderPixelSizeMapSet.Count(), TEST_LOCATION);
3731   DALI_TEST_EQUALS(DaliTestCheckMaps(placeholderPixelSizeMapGet, placeholderPixelSizeMapSet), true, TEST_LOCATION);
3732
3733   // Check the placeholder property with point size
3734   Property::Map placeholderMapSet;
3735   Property::Map placeholderMapGet;
3736   placeholderMapSet[Text::PlaceHolder::Property::TEXT]         = "Setting Placeholder Text";
3737   placeholderMapSet[Text::PlaceHolder::Property::TEXT_FOCUSED] = "Setting Placeholder Text Focused";
3738   placeholderMapSet[Text::PlaceHolder::Property::COLOR]        = Color::RED;
3739   placeholderMapSet[Text::PlaceHolder::Property::FONT_FAMILY]  = "Arial";
3740   placeholderMapSet[Text::PlaceHolder::Property::POINT_SIZE]   = 12.0f;
3741   placeholderMapSet[Text::PlaceHolder::Property::ELLIPSIS]     = false;
3742
3743   // Check the placeholder font style property
3744   placeholderFontstyleMap.Clear();
3745
3746   placeholderFontstyleMap.Insert("weight", "bold");
3747   placeholderFontstyleMap.Insert("width", "condensed");
3748   placeholderFontstyleMap.Insert("slant", "italic");
3749   placeholderMapSet[Text::PlaceHolder::Property::FONT_STYLE] = placeholderFontstyleMap;
3750   field.SetProperty(TextField::Property::PLACEHOLDER, placeholderMapSet);
3751
3752   placeholderMapGet = field.GetProperty<Property::Map>(TextField::Property::PLACEHOLDER);
3753   DALI_TEST_EQUALS(placeholderMapGet.Count(), placeholderMapSet.Count(), TEST_LOCATION);
3754   DALI_TEST_EQUALS(DaliTestCheckMaps(placeholderMapGet, placeholderMapSet), true, TEST_LOCATION);
3755
3756   // Reset font style.
3757   placeholderFontstyleMap.Clear();
3758   placeholderFontstyleMap.Insert("weight", "normal");
3759   placeholderFontstyleMap.Insert("slant", "oblique");
3760   placeholderMapSet[Text::PlaceHolder::Property::FONT_STYLE] = placeholderFontstyleMap;
3761   field.SetProperty(TextField::Property::PLACEHOLDER, placeholderMapSet);
3762
3763   placeholderMapGet = field.GetProperty<Property::Map>(TextField::Property::PLACEHOLDER);
3764   DALI_TEST_EQUALS(placeholderMapGet.Count(), placeholderMapSet.Count(), TEST_LOCATION);
3765   DALI_TEST_EQUALS(DaliTestCheckMaps(placeholderMapGet, placeholderMapSet), true, TEST_LOCATION);
3766
3767   placeholderFontstyleMap.Clear();
3768   placeholderFontstyleMap.Insert("slant", "roman");
3769   placeholderMapSet[Text::PlaceHolder::Property::FONT_STYLE] = placeholderFontstyleMap;
3770   field.SetProperty(TextField::Property::PLACEHOLDER, placeholderMapSet);
3771
3772   placeholderMapGet = field.GetProperty<Property::Map>(TextField::Property::PLACEHOLDER);
3773
3774   placeholderFontstyleMap.Clear();
3775   placeholderMapSet[Text::PlaceHolder::Property::FONT_STYLE] = placeholderFontstyleMap;
3776
3777   field.SetProperty(TextField::Property::PLACEHOLDER, placeholderMapSet);
3778   placeholderMapGet = field.GetProperty<Property::Map>(TextField::Property::PLACEHOLDER);
3779   DALI_TEST_EQUALS(placeholderMapGet.Count(), placeholderMapSet.Count(), TEST_LOCATION);
3780   DALI_TEST_EQUALS(DaliTestCheckMaps(placeholderMapGet, placeholderMapSet), true, TEST_LOCATION);
3781
3782   END_TEST;
3783 }
3784
3785 int UtcDaliTextFieldPlaceholderCoverage(void)
3786 {
3787   ToolkitTestApplication application;
3788   tet_infoline("UtcDaliTextFieldPlaceholderCoverage");
3789
3790   // mPlaceholderFont is created only once, so create a new control for coverage.
3791   TextField fieldForCoverage = TextField::New();
3792   DALI_TEST_CHECK(fieldForCoverage);
3793   application.GetScene().Add(fieldForCoverage);
3794
3795   // for SetPlaceholderFontFamily() coverage.
3796   Property::Map fontFamilyMap;
3797   fontFamilyMap[Text::PlaceHolder::Property::FONT_FAMILY] = "Arial";
3798   fieldForCoverage.SetProperty(TextField::Property::PLACEHOLDER, fontFamilyMap);
3799
3800   // mPlaceholderFont is created only once, so create a new control for coverage.
3801   fieldForCoverage = TextField::New();
3802   DALI_TEST_CHECK(fieldForCoverage);
3803   application.GetScene().Add(fieldForCoverage);
3804
3805   // for SetPlaceholderTextFontSize coverage.
3806   Property::Map fontSizeMap;
3807   fontSizeMap[Text::PlaceHolder::Property::PIXEL_SIZE] = 15.0f;
3808   fieldForCoverage.SetProperty(TextField::Property::PLACEHOLDER, fontSizeMap);
3809
3810   // mPlaceholderFont is created only once, so create a new control for coverage.
3811   fieldForCoverage = TextField::New();
3812   DALI_TEST_CHECK(fieldForCoverage);
3813   application.GetScene().Add(fieldForCoverage);
3814
3815   // for SetPlaceholderTextFontWeight coverage.
3816   Property::Map fontStyleWeightMap;
3817   Property::Map fontStyleWeightPropertyMap;
3818   fontStyleWeightPropertyMap.Insert("weight", "bold");
3819   fontStyleWeightMap[Text::PlaceHolder::Property::FONT_STYLE] = fontStyleWeightPropertyMap;
3820   fieldForCoverage.SetProperty(TextField::Property::PLACEHOLDER, fontStyleWeightMap);
3821
3822   // mPlaceholderFont is created only once, so create a new control for coverage.
3823   fieldForCoverage = TextField::New();
3824   DALI_TEST_CHECK(fieldForCoverage);
3825   application.GetScene().Add(fieldForCoverage);
3826
3827   // for SetPlaceholderTextFontWidth coverage.
3828   Property::Map fontStyleWidthMap;
3829   Property::Map fontStyleWidthPropertyMap;
3830   fontStyleWidthPropertyMap.Insert("width", "expanded");
3831   fontStyleWidthMap[Text::PlaceHolder::Property::FONT_STYLE] = fontStyleWidthPropertyMap;
3832   fieldForCoverage.SetProperty(TextField::Property::PLACEHOLDER, fontStyleWidthMap);
3833
3834   // mPlaceholderFont is created only once, so create a new control for coverage.
3835   fieldForCoverage = TextField::New();
3836   DALI_TEST_CHECK(fieldForCoverage);
3837   application.GetScene().Add(fieldForCoverage);
3838
3839   // for SetPlaceholderTextFontSlant coverage.
3840   Property::Map fontStyleSlantMap;
3841   Property::Map fontStyleSlantPropertyMap;
3842   fontStyleSlantPropertyMap.Insert("slant", "italic");
3843   fontStyleSlantMap[Text::PlaceHolder::Property::FONT_STYLE] = fontStyleSlantPropertyMap;
3844   fieldForCoverage.SetProperty(TextField::Property::PLACEHOLDER, fontStyleSlantMap);
3845
3846   END_TEST;
3847 }
3848
3849 int UtcDaliTextFieldSetPaddingProperty(void)
3850 {
3851   ToolkitTestApplication application;
3852   tet_infoline("UtcDaliTextFieldSetPaddingProperty\n");
3853
3854   TextField field = TextField::New();
3855   DALI_TEST_CHECK(field);
3856   field.SetProperty(Actor::Property::SIZE, Vector2(300.f, 50.f));
3857   field.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT);
3858   field.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
3859   application.GetScene().Add(field);
3860
3861   application.SendNotification();
3862   application.Render();
3863
3864   Vector3 originalSize = field.GetNaturalSize();
3865
3866   field.SetProperty(Toolkit::Control::Property::PADDING, Extents(10, 10, 10, 10));
3867
3868   application.SendNotification();
3869   application.Render();
3870
3871   DALI_TEST_EQUALS(field.GetProperty<Extents>(Toolkit::Control::Property::PADDING), Extents(10, 10, 10, 10), TEST_LOCATION);
3872
3873   Vector3 paddingAddedSize = field.GetNaturalSize();
3874
3875   DALI_TEST_EQUALS(originalSize.width + 10 + 10, paddingAddedSize.width, Math::MACHINE_EPSILON_1000, TEST_LOCATION);
3876
3877   DALI_TEST_EQUALS(originalSize.height + 10 + 10, paddingAddedSize.height, Math::MACHINE_EPSILON_1000, TEST_LOCATION);
3878
3879   END_TEST;
3880 }
3881
3882 int UtcDaliTextFieldEnableShiftSelectionProperty(void)
3883 {
3884   ToolkitTestApplication application;
3885   tet_infoline("UtcDaliTextFieldEnableShiftSelectionProperty");
3886
3887   TextField field = TextField::New();
3888   DALI_TEST_CHECK(field);
3889   field.SetProperty(Actor::Property::SIZE, Vector2(300.f, 50.f));
3890   field.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT);
3891   field.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
3892   application.GetScene().Add(field);
3893
3894   application.SendNotification();
3895   application.Render();
3896
3897   // The default value of ENABLE_SHIFT_SELECTION is 'true'.
3898   DALI_TEST_EQUALS(field.GetProperty<bool>(DevelTextField::Property::ENABLE_SHIFT_SELECTION), true, TEST_LOCATION);
3899
3900   // Check the enable shift selection property
3901   field.SetProperty(DevelTextField::Property::ENABLE_SHIFT_SELECTION, false);
3902   DALI_TEST_EQUALS(field.GetProperty<bool>(DevelTextField::Property::ENABLE_SHIFT_SELECTION), false, TEST_LOCATION);
3903
3904   application.SendNotification();
3905   application.Render();
3906
3907   END_TEST;
3908 }
3909
3910 int UtcDaliTextFieldEnableGrabHandleProperty(void)
3911 {
3912   ToolkitTestApplication application;
3913   tet_infoline("UtcDaliTextFieldEnableGrabHandleProperty");
3914
3915   TextField field = TextField::New();
3916   DALI_TEST_CHECK(field);
3917   field.SetProperty(Actor::Property::SIZE, Vector2(300.f, 50.f));
3918   field.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT);
3919   field.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
3920   application.GetScene().Add(field);
3921
3922   application.SendNotification();
3923   application.Render();
3924
3925   // The default value of ENABLE_GRAB_HANDLE is 'true'.
3926   DALI_TEST_EQUALS(field.GetProperty<bool>(DevelTextField::Property::ENABLE_GRAB_HANDLE), true, TEST_LOCATION);
3927
3928   // Check the enable grab handle property
3929   field.SetProperty(DevelTextField::Property::ENABLE_GRAB_HANDLE, false);
3930   DALI_TEST_EQUALS(field.GetProperty<bool>(DevelTextField::Property::ENABLE_GRAB_HANDLE), false, TEST_LOCATION);
3931
3932   application.SendNotification();
3933   application.Render();
3934
3935   END_TEST;
3936 }
3937
3938 int UtcDaliTextFieldMatchSystemLanguageDirectionProperty(void)
3939 {
3940   ToolkitTestApplication application;
3941   tet_infoline("UtcDaliTextFieldMatchSystemLanguageDirectionProperty");
3942
3943   TextField field = TextField::New();
3944   DALI_TEST_CHECK(field);
3945   field.SetProperty(Actor::Property::SIZE, Vector2(300.f, 50.f));
3946   field.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT);
3947   field.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
3948   application.GetScene().Add(field);
3949
3950   application.SendNotification();
3951   application.Render();
3952
3953   // The default value of MATCH_SYSTEM_LANGUAGE_DIRECTION is 'true'.
3954   DALI_TEST_EQUALS(field.GetProperty<bool>(DevelTextField::Property::MATCH_SYSTEM_LANGUAGE_DIRECTION), true, TEST_LOCATION);
3955
3956   // Check the match system language direction property
3957   field.SetProperty(DevelTextField::Property::MATCH_SYSTEM_LANGUAGE_DIRECTION, false);
3958   DALI_TEST_EQUALS(field.GetProperty<bool>(DevelTextField::Property::MATCH_SYSTEM_LANGUAGE_DIRECTION), false, TEST_LOCATION);
3959
3960   application.SendNotification();
3961   application.Render();
3962
3963   END_TEST;
3964 }
3965
3966 int utcDaliTextFieldLayoutDirectionCoverage(void)
3967 {
3968   ToolkitTestApplication application;
3969   tet_infoline(" utcDaliTextFieldLayoutDirectionCoverage");
3970
3971   // Creates a tap event. After creating a tap event the text field should
3972   // have the focus and add text with key events should be possible.
3973   TextField field = TextField::New();
3974   DALI_TEST_CHECK(field);
3975
3976   application.GetScene().Add(field);
3977
3978   field.SetProperty(Actor::Property::SIZE, Vector2(300.f, 50.f));
3979   field.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT);
3980   field.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
3981
3982   // Avoid a crash when core load gl resources.
3983   application.GetGlAbstraction().SetCheckFramebufferStatusResult(GL_FRAMEBUFFER_COMPLETE);
3984
3985   // Render and notify
3986   application.SendNotification();
3987   application.Render();
3988
3989   // init direction for coverage
3990   // Set horizontal alignment END
3991   field.SetProperty(TextField::Property::HORIZONTAL_ALIGNMENT, "END");
3992
3993   // Create a tap event to touch the text field.
3994   TestGenerateTap(application, 150.0f, 25.0f);
3995
3996   // Render and notify
3997   application.SendNotification();
3998   application.Render();
3999
4000   // Set MATCH_SYSTEM_LANGUAGE_DIRECTION to true to use the layout direction.
4001   field.SetProperty(DevelTextField::Property::MATCH_SYSTEM_LANGUAGE_DIRECTION, true);
4002   field.SetProperty(Actor::Property::LAYOUT_DIRECTION, LayoutDirection::RIGHT_TO_LEFT);
4003
4004   // Set horizontal alignment BEGIN
4005   field.SetProperty(TextField::Property::HORIZONTAL_ALIGNMENT, "BEGIN");
4006
4007   // Create a tap event to touch the text field.
4008   TestGenerateTap(application, 150.0f, 25.0f);
4009
4010   // Render and notify
4011   application.SendNotification();
4012   application.Render();
4013
4014   // Set horizontal alignment CENTER
4015   field.SetProperty(TextField::Property::HORIZONTAL_ALIGNMENT, "CENTER");
4016
4017   // Create a tap event to touch the text field.
4018   TestGenerateTap(application, 150.0f, 25.0f);
4019
4020   // Render and notify
4021   application.SendNotification();
4022   application.Render();
4023
4024   // Set horizontal alignment END
4025   field.SetProperty(TextField::Property::HORIZONTAL_ALIGNMENT, "END");
4026
4027   // Create a tap event to touch the text field.
4028   TestGenerateTap(application, 150.0f, 25.0f);
4029
4030   // Render and notify
4031   application.SendNotification();
4032   application.Render();
4033
4034   // Generate a Esc key event. The text field should lose the focus.
4035   application.ProcessEvent(GenerateKey("", "", "", DALI_KEY_ESCAPE, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
4036   application.ProcessEvent(GenerateKey("", "", "", DALI_KEY_ESCAPE, 0, 0, Integration::KeyEvent::UP, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
4037
4038   // Render and notify
4039   application.SendNotification();
4040   application.Render();
4041
4042   DALI_TEST_EQUALS(false, field.HasKeyInputFocus(), TEST_LOCATION);
4043
4044   END_TEST;
4045 }
4046
4047 int UtcDaliTextFieldGetInputMethodContext(void)
4048 {
4049   ToolkitTestApplication application;
4050   tet_infoline("UtcDaliTextFieldGetInputMethodContext");
4051
4052   TextField field = TextField::New();
4053   DALI_TEST_CHECK(DevelTextField::GetInputMethodContext(field));
4054
4055   END_TEST;
4056 }
4057
4058 int UtcDaliTextFieldSelectWholeText(void)
4059 {
4060   ToolkitTestApplication application;
4061   tet_infoline(" UtcDaliTextFieldSelectWholeText ");
4062
4063   TextField textField = TextField::New();
4064
4065   application.GetScene().Add(textField);
4066
4067   textField.SetProperty(Actor::Property::SIZE, Vector2(300.f, 50.f));
4068   textField.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT);
4069   textField.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
4070
4071   // Avoid a crash when core load gl resources.
4072   application.GetGlAbstraction().SetCheckFramebufferStatusResult(GL_FRAMEBUFFER_COMPLETE);
4073
4074   application.SendNotification();
4075   application.Render();
4076
4077   DALI_TEST_EQUALS(1u, textField.GetChildCount(), TEST_LOCATION);
4078
4079   DevelTextField::SelectWholeText(textField);
4080
4081   application.SendNotification();
4082   application.Render();
4083
4084   // Nothing should have been selected. The number of children is still 1
4085   DALI_TEST_EQUALS(1u, textField.GetChildCount(), TEST_LOCATION);
4086
4087   textField.SetProperty(TextField::Property::TEXT, "Hello world");
4088
4089   application.SendNotification();
4090   application.Render();
4091
4092   DevelTextField::SelectWholeText(textField);
4093
4094   application.SendNotification();
4095   application.Render();
4096
4097   // Even if resize, selection should remain.
4098   textField.SetProperty(Actor::Property::SIZE, Vector2(150.f, 50.f));
4099
4100   application.SendNotification();
4101   application.Render();
4102
4103   // Should be 2 children, the stencil and the layer
4104   DALI_TEST_EQUALS(2u, textField.GetChildCount(), TEST_LOCATION);
4105
4106   // The offscreen root actor should have two actors: the renderer and the highlight actor.
4107   Actor stencil = textField.GetChildAt(0u);
4108
4109   // The highlight actor is drawn first, so is the first actor in the list
4110   Renderer highlight = stencil.GetChildAt(0u).GetRendererAt(0u);
4111   DALI_TEST_CHECK(highlight);
4112
4113   END_TEST;
4114 }
4115
4116 int UtcDaliTextFieldSelectText(void)
4117 {
4118   ToolkitTestApplication application;
4119   tet_infoline(" UtcDaliTextFieldSelectText ");
4120
4121   TextField textField = TextField::New();
4122
4123   application.GetScene().Add(textField);
4124
4125   textField.SetProperty(Actor::Property::SIZE, Vector2(300.f, 50.f));
4126   textField.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT);
4127   textField.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
4128
4129   // Avoid a crash when core load gl resources.
4130   application.GetGlAbstraction().SetCheckFramebufferStatusResult(GL_FRAMEBUFFER_COMPLETE);
4131
4132   application.SendNotification();
4133   application.Render();
4134
4135   DevelTextField::SelectText(textField, 0, 5);
4136
4137   application.SendNotification();
4138   application.Render();
4139
4140   // Nothing is selected
4141   std::string selectedText = textField.GetProperty(DevelTextField::Property::SELECTED_TEXT).Get<std::string>();
4142   DALI_TEST_EQUALS("", selectedText, TEST_LOCATION);
4143
4144   textField.SetProperty(TextField::Property::TEXT, "Hello world");
4145
4146   application.SendNotification();
4147   application.Render();
4148
4149   // Hello is selected
4150   DevelTextField::SelectText(textField, 0, 5);
4151
4152   application.SendNotification();
4153   application.Render();
4154
4155   selectedText = textField.GetProperty(DevelTextField::Property::SELECTED_TEXT).Get<std::string>();
4156   DALI_TEST_EQUALS("Hello", selectedText, TEST_LOCATION);
4157
4158   DALI_TEST_EQUALS(textField.GetProperty(DevelTextField::Property::SELECTED_TEXT_START).Get<int>(), 0, TEST_LOCATION);
4159   DALI_TEST_EQUALS(textField.GetProperty(DevelTextField::Property::SELECTED_TEXT_END).Get<int>(), 5, TEST_LOCATION);
4160
4161   // world is selected
4162   DevelTextField::SelectText(textField, 6, 11);
4163
4164   application.SendNotification();
4165   application.Render();
4166
4167   selectedText = textField.GetProperty(DevelTextField::Property::SELECTED_TEXT).Get<std::string>();
4168   DALI_TEST_EQUALS("world", selectedText, TEST_LOCATION);
4169
4170   DALI_TEST_EQUALS(textField.GetProperty(DevelTextField::Property::SELECTED_TEXT_START).Get<int>(), 6, TEST_LOCATION);
4171   DALI_TEST_EQUALS(textField.GetProperty(DevelTextField::Property::SELECTED_TEXT_END).Get<int>(), 11, TEST_LOCATION);
4172
4173   END_TEST;
4174 }
4175
4176 int UtcDaliTextFieldSelectNone(void)
4177 {
4178   ToolkitTestApplication application;
4179   tet_infoline(" UtcDaliTextFieldSelectWholeText ");
4180
4181   TextField textField = TextField::New();
4182
4183   application.GetScene().Add(textField);
4184
4185   textField.SetProperty(Actor::Property::SIZE, Vector2(300.f, 50.f));
4186   textField.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT);
4187   textField.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
4188
4189   // Avoid a crash when core load gl resources.
4190   application.GetGlAbstraction().SetCheckFramebufferStatusResult(GL_FRAMEBUFFER_COMPLETE);
4191
4192   application.SendNotification();
4193   application.Render();
4194
4195   textField.SetProperty(TextField::Property::TEXT, "Hello world");
4196
4197   application.SendNotification();
4198   application.Render();
4199
4200   // Nothing is selected
4201   std::string selectedText = textField.GetProperty(DevelTextField::Property::SELECTED_TEXT).Get<std::string>();
4202   DALI_TEST_EQUALS("", selectedText, TEST_LOCATION);
4203
4204   DevelTextField::SelectWholeText(textField);
4205
4206   application.SendNotification();
4207   application.Render();
4208
4209   // whole text is selected
4210   selectedText = textField.GetProperty(DevelTextField::Property::SELECTED_TEXT).Get<std::string>();
4211   DALI_TEST_EQUALS("Hello world", selectedText, TEST_LOCATION);
4212
4213   DevelTextField::SelectNone(textField);
4214
4215   application.SendNotification();
4216   application.Render();
4217
4218   // Nothing is selected
4219   selectedText = textField.GetProperty(DevelTextField::Property::SELECTED_TEXT).Get<std::string>();
4220   DALI_TEST_EQUALS("", selectedText, TEST_LOCATION);
4221
4222   END_TEST;
4223 }
4224
4225 int UtcDaliTextFieldSelectRange(void)
4226 {
4227   ToolkitTestApplication application;
4228   tet_infoline(" UtcDaliTextFieldSelectRange ");
4229
4230   TextField textField = TextField::New();
4231
4232   application.GetScene().Add(textField);
4233
4234   textField.SetProperty(Actor::Property::SIZE, Vector2(300.f, 50.f));
4235   textField.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT);
4236   textField.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
4237
4238   // Avoid a crash when core load gl resources.
4239   application.GetGlAbstraction().SetCheckFramebufferStatusResult(GL_FRAMEBUFFER_COMPLETE);
4240
4241   application.SendNotification();
4242   application.Render();
4243
4244   textField.SetProperty(TextField::Property::TEXT, "Hello world");
4245
4246   application.SendNotification();
4247   application.Render();
4248
4249   textField.SetProperty(DevelTextField::Property::SELECTED_TEXT_START, 0);
4250   textField.SetProperty(DevelTextField::Property::SELECTED_TEXT_END, 5);
4251
4252   // Hello is selected
4253   std::string selectedText = textField.GetProperty(DevelTextField::Property::SELECTED_TEXT).Get<std::string>();
4254   DALI_TEST_EQUALS("Hello", selectedText, TEST_LOCATION);
4255
4256   DALI_TEST_EQUALS(textField.GetProperty(DevelTextField::Property::SELECTED_TEXT_START).Get<int>(), 0, TEST_LOCATION);
4257   DALI_TEST_EQUALS(textField.GetProperty(DevelTextField::Property::SELECTED_TEXT_END).Get<int>(), 5, TEST_LOCATION);
4258
4259   textField.SetProperty(DevelTextField::Property::SELECTED_TEXT_START, 6);
4260   textField.SetProperty(DevelTextField::Property::SELECTED_TEXT_END, 11);
4261
4262   // world is selected
4263   selectedText = textField.GetProperty(DevelTextField::Property::SELECTED_TEXT).Get<std::string>();
4264   DALI_TEST_EQUALS("world", selectedText, TEST_LOCATION);
4265
4266   DALI_TEST_EQUALS(textField.GetProperty(DevelTextField::Property::SELECTED_TEXT_START).Get<int>(), 6, TEST_LOCATION);
4267   DALI_TEST_EQUALS(textField.GetProperty(DevelTextField::Property::SELECTED_TEXT_END).Get<int>(), 11, TEST_LOCATION);
4268
4269   END_TEST;
4270 }
4271
4272 int UtcDaliTextFieldEnableEditing(void)
4273 {
4274   ToolkitTestApplication application;
4275   tet_infoline(" UtcDaliTextFieldEnableEditing ");
4276
4277   TextField textField = TextField::New();
4278
4279   application.GetScene().Add(textField);
4280
4281   textField.SetProperty(Actor::Property::SIZE, Vector2(300.f, 50.f));
4282   textField.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT);
4283   textField.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
4284
4285   // Avoid a crash when core load gl resources.
4286   application.GetGlAbstraction().SetCheckFramebufferStatusResult(GL_FRAMEBUFFER_COMPLETE);
4287
4288   application.SendNotification();
4289   application.Render();
4290
4291   textField.SetProperty(DevelActor::Property::USER_INTERACTION_ENABLED, true);
4292   DALI_TEST_EQUALS(textField.GetProperty(DevelActor::Property::USER_INTERACTION_ENABLED).Get<bool>(), true, TEST_LOCATION);
4293
4294   textField.SetKeyInputFocus();
4295   textField.SetProperty(DevelTextField::Property::ENABLE_EDITING, false);
4296   application.ProcessEvent(GenerateKey("D", "", "D", KEY_D_CODE, 0, 0, Integration::KeyEvent::DOWN, "D", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
4297
4298   // Render and notify
4299   application.SendNotification();
4300   application.Render();
4301
4302   DALI_TEST_EQUALS(textField.GetProperty(TextField::Property::TEXT).Get<std::string>(), "", TEST_LOCATION);
4303   DALI_TEST_EQUALS(textField.GetProperty(DevelTextField::Property::ENABLE_EDITING).Get<bool>(), false, TEST_LOCATION);
4304
4305   textField.SetKeyInputFocus();
4306   textField.SetProperty(DevelTextField::Property::ENABLE_EDITING, true);
4307   application.ProcessEvent(GenerateKey("D", "", "D", KEY_D_CODE, 0, 0, Integration::KeyEvent::DOWN, "D", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
4308
4309   // Render and notify
4310   application.SendNotification();
4311   application.Render();
4312
4313   DALI_TEST_EQUALS(textField.GetProperty(TextField::Property::TEXT).Get<std::string>(), "D", TEST_LOCATION);
4314   DALI_TEST_EQUALS(textField.GetProperty(DevelTextField::Property::ENABLE_EDITING).Get<bool>(), true, TEST_LOCATION);
4315
4316   // Check the user interaction enabled and for coverage
4317   DevelTextField::SelectWholeText(textField);
4318
4319   // Render and notify
4320   application.SendNotification();
4321   application.Render();
4322
4323   textField.SetKeyInputFocus();
4324   textField.SetProperty(DevelActor::Property::USER_INTERACTION_ENABLED, false);
4325   application.ProcessEvent(GenerateKey("D", "", "D", KEY_D_CODE, 0, 0, Integration::KeyEvent::DOWN, "D", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
4326
4327   // Render and notify
4328   application.SendNotification();
4329   application.Render();
4330
4331   DALI_TEST_EQUALS(textField.GetProperty(TextField::Property::TEXT).Get<std::string>(), "D", TEST_LOCATION);
4332   DALI_TEST_EQUALS(textField.GetProperty(DevelActor::Property::USER_INTERACTION_ENABLED).Get<bool>(), false, TEST_LOCATION);
4333
4334   END_TEST;
4335 }
4336
4337 int UtcDaliToolkitTextFieldFontSizeScale(void)
4338 {
4339   ToolkitTestApplication application;
4340   tet_infoline(" UtcDaliToolkitTextFieldFontSizeScale");
4341
4342   TextField textField = TextField::New();
4343   textField.SetProperty(TextField::Property::POINT_SIZE, 30.f);
4344   textField.SetProperty(TextField::Property::TEXT, "Test");
4345   Vector3 nonScaledSize = textField.GetNaturalSize();
4346
4347   TextField textFieldScaled = TextField::New();
4348   textFieldScaled.SetProperty(TextField::Property::POINT_SIZE, 15.f);
4349   textFieldScaled.SetProperty(Toolkit::DevelTextField::Property::FONT_SIZE_SCALE, 2.f);
4350   textFieldScaled.SetProperty(TextField::Property::TEXT, "Test");
4351   Vector3 scaledSize = textFieldScaled.GetNaturalSize();
4352
4353   DALI_TEST_EQUALS(nonScaledSize, scaledSize, TEST_LOCATION);
4354
4355   textField.SetProperty(TextField::Property::PIXEL_SIZE, 30.f);
4356   textField.SetProperty(TextField::Property::TEXT, "Test");
4357   nonScaledSize = textField.GetNaturalSize();
4358
4359   textFieldScaled.SetProperty(TextField::Property::PIXEL_SIZE, 15.f);
4360   textFieldScaled.SetProperty(Toolkit::DevelTextField::Property::FONT_SIZE_SCALE, 2.f);
4361   textFieldScaled.SetProperty(TextField::Property::TEXT, "Test");
4362   scaledSize = textFieldScaled.GetNaturalSize();
4363
4364   DALI_TEST_EQUALS(nonScaledSize, scaledSize, TEST_LOCATION);
4365
4366   END_TEST;
4367 }
4368
4369 int UtcDaliTextFieldPrimaryCursorPosition(void)
4370 {
4371   ToolkitTestApplication application;
4372   tet_infoline(" UtcDaliTextFieldPrimaryCursorPosition ");
4373
4374   TextField textField = TextField::New();
4375
4376   application.GetScene().Add(textField);
4377
4378   textField.SetProperty(TextField::Property::TEXT, "ABCEF");
4379   textField.SetProperty(Actor::Property::SIZE, Vector2(300.f, 50.f));
4380   textField.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT);
4381   textField.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
4382
4383   // Avoid a crash when core load gl resources.
4384   application.GetGlAbstraction().SetCheckFramebufferStatusResult(GL_FRAMEBUFFER_COMPLETE);
4385
4386   textField.SetProperty(DevelTextField::Property::PRIMARY_CURSOR_POSITION, 3);
4387   application.SendNotification();
4388   application.Render();
4389   textField.SetKeyInputFocus();
4390
4391   application.ProcessEvent(GenerateKey("D", "", "D", KEY_D_CODE, 0, 0, Integration::KeyEvent::DOWN, "D", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
4392
4393   // Render and notify
4394   application.SendNotification();
4395   application.Render();
4396
4397   DALI_TEST_EQUALS(textField.GetProperty(TextField::Property::TEXT).Get<std::string>(), "ABCDEF", TEST_LOCATION);
4398   DALI_TEST_EQUALS(textField.GetProperty(DevelTextField::Property::PRIMARY_CURSOR_POSITION).Get<int>(), 4, TEST_LOCATION);
4399
4400   END_TEST;
4401 }
4402
4403 // test max length when set after setting long text
4404 int utcDaliTextFieldMaxCharactersReachedAfterSetText(void)
4405 {
4406   ToolkitTestApplication application;
4407   tet_infoline(" utcDaliTextFieldMaxCharactersReachedAfterSetText");
4408   TextField field = TextField::New();
4409   DALI_TEST_CHECK(field);
4410
4411   application.GetScene().Add(field);
4412
4413   field.SetProperty(TextField::Property::TEXT, "123456789");
4414
4415   const int maxNumberOfCharacters = 3;
4416   field.SetProperty(TextField::Property::MAX_LENGTH, maxNumberOfCharacters);
4417
4418   field.SetKeyInputFocus();
4419
4420   // connect to the text max lengh reached signal.
4421   ConnectionTracker* testTracker            = new ConnectionTracker();
4422   bool               maxLengthReachedSignal = false;
4423   field.ConnectSignal(testTracker, "maxLengthReached", CallbackFunctor(&maxLengthReachedSignal));
4424
4425   application.ProcessEvent(GenerateKey("a", "", "a", KEY_A_CODE, 0, 0, Integration::KeyEvent::DOWN, "a", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
4426   application.ProcessEvent(GenerateKey("a", "", "a", KEY_A_CODE, 0, 0, Integration::KeyEvent::DOWN, "a", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
4427
4428   DALI_TEST_CHECK(maxLengthReachedSignal);
4429
4430   DALI_TEST_EQUALS(field.GetProperty(TextField::Property::TEXT).Get<std::string>(), "123456789", TEST_LOCATION);
4431
4432   END_TEST;
4433 }
4434
4435 int UtcDaliTextFieldAtlasLimitationIsEnabledForLargeFontPointSize(void)
4436 {
4437   ToolkitTestApplication application;
4438   tet_infoline(" UtcDaliTextFieldAtlasLimitationIsEnabledForLargeFontPointSize ");
4439
4440   // +2: First one to handle the equal case. Second one to handle odd to even case of GetNaturalSize
4441   const uint32_t lessThanWidth  = TextAbstraction::FontClient::MAX_TEXT_ATLAS_WIDTH - TextAbstraction::FontClient::PADDING_TEXT_ATLAS_BLOCK + 2;
4442   const uint32_t lessThanHeight = TextAbstraction::FontClient::MAX_TEXT_ATLAS_HEIGHT - TextAbstraction::FontClient::PADDING_TEXT_ATLAS_BLOCK + 2;
4443
4444   // Create a text field
4445   TextField textField = TextField::New();
4446
4447   //Set size to avoid automatic eliding
4448   textField.SetProperty(Actor::Property::SIZE, Vector2(1025, 1025));
4449   //Set very large font-size using point-size
4450   textField.SetProperty(TextField::Property::POINT_SIZE, 1000);
4451   //Specify font-family
4452   textField.SetProperty(TextField::Property::FONT_FAMILY, "DejaVu Sans");
4453   //Set text to check if appear or not
4454   textField.SetProperty(TextField::Property::TEXT, "A");
4455
4456   application.GetScene().Add(textField);
4457
4458   application.SendNotification();
4459   application.Render();
4460   //Use GetNaturalSize to verify that size of block does not exceed Atlas size
4461   Vector3 naturalSize = textField.GetNaturalSize();
4462
4463   DALI_TEST_GREATER(lessThanWidth, static_cast<uint32_t>(naturalSize.width), TEST_LOCATION);
4464   DALI_TEST_GREATER(lessThanHeight, static_cast<uint32_t>(naturalSize.height), TEST_LOCATION);
4465
4466   END_TEST;
4467 }
4468
4469 int UtcDaliTextFieldAtlasLimitationIsEnabledPerformanceCases(void)
4470 {
4471   ToolkitTestApplication application;
4472   tet_infoline(" UtcDaliTextFieldAtlasLimitationIsEnabledPerformanceCases ");
4473
4474   // +2: First one to handle the equal case. Second one to handle odd to even case of GetNaturalSize
4475   const uint32_t lessThanWidth  = TextAbstraction::FontClient::MAX_TEXT_ATLAS_WIDTH - TextAbstraction::FontClient::PADDING_TEXT_ATLAS_BLOCK + 2;
4476   const uint32_t lessThanHeight = TextAbstraction::FontClient::MAX_TEXT_ATLAS_HEIGHT - TextAbstraction::FontClient::PADDING_TEXT_ATLAS_BLOCK + 2;
4477
4478   Vector3 naturalSize; //Use GetNaturalSize to verify that size of block does not exceed Atlas size
4479   // Create a text editor
4480   TextField textField = TextField::New();
4481
4482   //Set size to avoid automatic eliding
4483   textField.SetProperty(Actor::Property::SIZE, Vector2(1025, 1025));
4484   textField.SetProperty(TextField::Property::FONT_FAMILY, "DejaVu Sans");
4485   textField.SetProperty(TextField::Property::TEXT, "A");
4486
4487   const int numberOfCases             = 6;
4488   int       arrayCases[numberOfCases] = {323, 326, 330, 600, 1630, 2500};
4489
4490   for(int index = 0; index < numberOfCases; index++)
4491   {
4492     tet_printf(" UtcDaliTextFieldAtlasLimitationIsEnabledPerformanceCases point-size= %d \n", arrayCases[index]);
4493     textField.SetProperty(TextField::Property::POINT_SIZE, arrayCases[index]);
4494     application.GetScene().Add(textField);
4495     application.SendNotification();
4496     application.Render();
4497     naturalSize = textField.GetNaturalSize();
4498     DALI_TEST_GREATER(lessThanWidth, static_cast<uint32_t>(naturalSize.width), TEST_LOCATION);
4499     DALI_TEST_GREATER(lessThanHeight, static_cast<uint32_t>(naturalSize.height), TEST_LOCATION);
4500   }
4501
4502   END_TEST;
4503 }
4504
4505 int UtcDaliToolkitTextFieldEllipsisPositionProperty(void)
4506 {
4507   ToolkitTestApplication application;
4508   tet_infoline(" UtcDaliToolkitTextFieldEllipsisPositionProperty ");
4509   TextField textField = TextField::New();
4510
4511   tet_infoline(" UtcDaliToolkitTextFieldEllipsisPositionProperty - Default is END");
4512   DALI_TEST_EQUALS(textField.GetProperty<int>(DevelTextField::Property::ELLIPSIS_POSITION), static_cast<int>(Toolkit::DevelText::EllipsisPosition::END), TEST_LOCATION);
4513
4514   tet_infoline(" UtcDaliToolkitTextFieldEllipsisPositionProperty - Change to START");
4515   textField.SetProperty(DevelTextField::Property::ELLIPSIS_POSITION, DevelText::EllipsisPosition::START);
4516   DALI_TEST_EQUALS(textField.GetProperty<int>(DevelTextField::Property::ELLIPSIS_POSITION), static_cast<int>(Toolkit::DevelText::EllipsisPosition::START), TEST_LOCATION);
4517
4518   tet_infoline(" UtcDaliToolkitTextFieldEllipsisPositionProperty - Change to MIDDLE");
4519   textField.SetProperty(DevelTextField::Property::ELLIPSIS_POSITION, DevelText::EllipsisPosition::MIDDLE);
4520   DALI_TEST_EQUALS(textField.GetProperty<int>(DevelTextField::Property::ELLIPSIS_POSITION), static_cast<int>(Toolkit::DevelText::EllipsisPosition::MIDDLE), TEST_LOCATION);
4521
4522   tet_infoline(" UtcDaliToolkitTextFieldEllipsisPositionProperty - Change to END");
4523   textField.SetProperty(DevelTextField::Property::ELLIPSIS_POSITION, DevelText::EllipsisPosition::END);
4524   DALI_TEST_EQUALS(textField.GetProperty<int>(DevelTextField::Property::ELLIPSIS_POSITION), static_cast<int>(Toolkit::DevelText::EllipsisPosition::END), TEST_LOCATION);
4525
4526   tet_infoline(" UtcDaliToolkitTextFieldEllipsisPositionProperty - Change to START using integer");
4527   textField.SetProperty(DevelTextField::Property::ELLIPSIS_POSITION, 1);
4528   DALI_TEST_EQUALS(textField.GetProperty<int>(DevelTextField::Property::ELLIPSIS_POSITION), static_cast<int>(Toolkit::DevelText::EllipsisPosition::START), TEST_LOCATION);
4529
4530   tet_infoline(" UtcDaliToolkitTextFieldEllipsisPositionProperty - Change to MIDDLE using integer");
4531   textField.SetProperty(DevelTextField::Property::ELLIPSIS_POSITION, 2);
4532   DALI_TEST_EQUALS(textField.GetProperty<int>(DevelTextField::Property::ELLIPSIS_POSITION), static_cast<int>(Toolkit::DevelText::EllipsisPosition::MIDDLE), TEST_LOCATION);
4533
4534   tet_infoline(" UtcDaliToolkitTextFieldEllipsisPositionProperty - Change to END using integer");
4535   textField.SetProperty(DevelTextField::Property::ELLIPSIS_POSITION, 0);
4536   DALI_TEST_EQUALS(textField.GetProperty<int>(DevelTextField::Property::ELLIPSIS_POSITION), static_cast<int>(Toolkit::DevelText::EllipsisPosition::END), TEST_LOCATION);
4537
4538   tet_infoline(" UtcDaliToolkitTextlabelEllipsisPositionProperty - Change to START using string - uppercase");
4539   textField.SetProperty(DevelTextField::Property::ELLIPSIS_POSITION, "START");
4540   DALI_TEST_EQUALS(textField.GetProperty<int>(DevelTextField::Property::ELLIPSIS_POSITION), static_cast<int>(Toolkit::DevelText::EllipsisPosition::START), TEST_LOCATION);
4541
4542   tet_infoline(" UtcDaliToolkitTextlabelEllipsisPositionProperty - Change to MIDDLE using string - uppercase");
4543   textField.SetProperty(DevelTextField::Property::ELLIPSIS_POSITION, "MIDDLE");
4544   DALI_TEST_EQUALS(textField.GetProperty<int>(DevelTextField::Property::ELLIPSIS_POSITION), static_cast<int>(Toolkit::DevelText::EllipsisPosition::MIDDLE), TEST_LOCATION);
4545
4546   tet_infoline(" UtcDaliToolkitTextlabelEllipsisPositionProperty - Change to END using string - uppercase");
4547   textField.SetProperty(DevelTextField::Property::ELLIPSIS_POSITION, "END");
4548   DALI_TEST_EQUALS(textField.GetProperty<int>(DevelTextField::Property::ELLIPSIS_POSITION), static_cast<int>(Toolkit::DevelText::EllipsisPosition::END), TEST_LOCATION);
4549
4550   tet_infoline(" UtcDaliToolkitTextlabelEllipsisPositionProperty - Change to START using string - lowercase");
4551   textField.SetProperty(DevelTextField::Property::ELLIPSIS_POSITION, "start");
4552   DALI_TEST_EQUALS(textField.GetProperty<int>(DevelTextField::Property::ELLIPSIS_POSITION), static_cast<int>(Toolkit::DevelText::EllipsisPosition::START), TEST_LOCATION);
4553
4554   tet_infoline(" UtcDaliToolkitTextlabelEllipsisPositionProperty - Change to MIDDLE using string - lowercase");
4555   textField.SetProperty(DevelTextField::Property::ELLIPSIS_POSITION, "middle");
4556   DALI_TEST_EQUALS(textField.GetProperty<int>(DevelTextField::Property::ELLIPSIS_POSITION), static_cast<int>(Toolkit::DevelText::EllipsisPosition::MIDDLE), TEST_LOCATION);
4557
4558   tet_infoline(" UtcDaliToolkitTextlabelEllipsisPositionProperty - Change to END using string - lowercase");
4559   textField.SetProperty(DevelTextField::Property::ELLIPSIS_POSITION, "end");
4560   DALI_TEST_EQUALS(textField.GetProperty<int>(DevelTextField::Property::ELLIPSIS_POSITION), static_cast<int>(Toolkit::DevelText::EllipsisPosition::END), TEST_LOCATION);
4561
4562   END_TEST;
4563 }
4564
4565 int UtcDaliTextFieldCopyText(void)
4566 {
4567   ToolkitTestApplication application;
4568   tet_infoline(" UtcDaliTextFieldCopyText ");
4569
4570   TextField textField = TextField::New();
4571
4572   std::string selectedText = "";
4573   std::string copiedText   = "";
4574
4575   application.GetScene().Add(textField);
4576
4577   textField.SetProperty(Actor::Property::SIZE, Vector2(300.f, 50.f));
4578   textField.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT);
4579   textField.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
4580
4581   // Avoid a crash when core load gl resources.
4582   application.GetGlAbstraction().SetCheckFramebufferStatusResult(GL_FRAMEBUFFER_COMPLETE);
4583
4584   application.SendNotification();
4585   application.Render();
4586
4587   textField.SetProperty(TextField::Property::TEXT, "Hello world");
4588
4589   application.SendNotification();
4590   application.Render();
4591
4592   // Hello is selected
4593   DevelTextField::SelectText(textField, 0, 5);
4594
4595   application.SendNotification();
4596   application.Render();
4597
4598   selectedText = textField.GetProperty(DevelTextField::Property::SELECTED_TEXT).Get<std::string>();
4599   DALI_TEST_EQUALS("Hello", selectedText, TEST_LOCATION);
4600
4601   DALI_TEST_EQUALS(textField.GetProperty(DevelTextField::Property::SELECTED_TEXT_START).Get<int>(), 0, TEST_LOCATION);
4602   DALI_TEST_EQUALS(textField.GetProperty(DevelTextField::Property::SELECTED_TEXT_END).Get<int>(), 5, TEST_LOCATION);
4603
4604   // Hello is copied
4605   copiedText = DevelTextField::CopyText(textField);
4606   DALI_TEST_EQUALS("Hello", copiedText, TEST_LOCATION);
4607
4608   // world is selected
4609   DevelTextField::SelectText(textField, 6, 11);
4610
4611   application.SendNotification();
4612   application.Render();
4613
4614   selectedText = textField.GetProperty(DevelTextField::Property::SELECTED_TEXT).Get<std::string>();
4615   DALI_TEST_EQUALS("world", selectedText, TEST_LOCATION);
4616
4617   DALI_TEST_EQUALS(textField.GetProperty(DevelTextField::Property::SELECTED_TEXT_START).Get<int>(), 6, TEST_LOCATION);
4618   DALI_TEST_EQUALS(textField.GetProperty(DevelTextField::Property::SELECTED_TEXT_END).Get<int>(), 11, TEST_LOCATION);
4619
4620   // world is copied
4621   copiedText = DevelTextField::CopyText(textField);
4622   DALI_TEST_EQUALS("world", copiedText, TEST_LOCATION);
4623
4624   // "lo wo" is selected
4625   DevelTextField::SelectText(textField, 3, 8);
4626
4627   application.SendNotification();
4628   application.Render();
4629
4630   selectedText = textField.GetProperty(DevelTextField::Property::SELECTED_TEXT).Get<std::string>();
4631   DALI_TEST_EQUALS("lo wo", selectedText, TEST_LOCATION);
4632
4633   DALI_TEST_EQUALS(textField.GetProperty(DevelTextField::Property::SELECTED_TEXT_START).Get<int>(), 3, TEST_LOCATION);
4634   DALI_TEST_EQUALS(textField.GetProperty(DevelTextField::Property::SELECTED_TEXT_END).Get<int>(), 8, TEST_LOCATION);
4635
4636   // "lo wo" is copied
4637   copiedText = DevelTextField::CopyText(textField);
4638   DALI_TEST_EQUALS("lo wo", copiedText, TEST_LOCATION);
4639
4640   END_TEST;
4641 }
4642
4643 int UtcDaliTextFieldCutText(void)
4644 {
4645   ToolkitTestApplication application;
4646   tet_infoline(" UtcDaliTextFieldCutText ");
4647
4648   TextField textField = TextField::New();
4649
4650   std::string selectedText = "";
4651
4652   application.GetScene().Add(textField);
4653
4654   textField.SetProperty(Actor::Property::SIZE, Vector2(300.f, 50.f));
4655   textField.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT);
4656   textField.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
4657
4658   // Avoid a crash when core load gl resources.
4659   application.GetGlAbstraction().SetCheckFramebufferStatusResult(GL_FRAMEBUFFER_COMPLETE);
4660
4661   application.SendNotification();
4662   application.Render();
4663
4664   textField.SetProperty(TextField::Property::TEXT, "Hello world");
4665
4666   application.SendNotification();
4667   application.Render();
4668
4669   // Hello is selected
4670   DevelTextField::SelectText(textField, 0, 5);
4671
4672   application.SendNotification();
4673   application.Render();
4674
4675   selectedText = textField.GetProperty(DevelTextField::Property::SELECTED_TEXT).Get<std::string>();
4676   DALI_TEST_EQUALS("Hello", selectedText, TEST_LOCATION);
4677
4678   DALI_TEST_EQUALS(textField.GetProperty(DevelTextField::Property::SELECTED_TEXT_START).Get<int>(), 0, TEST_LOCATION);
4679   DALI_TEST_EQUALS(textField.GetProperty(DevelTextField::Property::SELECTED_TEXT_END).Get<int>(), 5, TEST_LOCATION);
4680
4681   // Hello is cut
4682   DALI_TEST_EQUALS("Hello", DevelTextField::CutText(textField), TEST_LOCATION);
4683
4684   DALI_TEST_EQUALS(textField.GetProperty(TextField::Property::TEXT).Get<std::string>(), " world", TEST_LOCATION);
4685
4686   // " w" is selected
4687   DevelTextField::SelectText(textField, 0, 2);
4688
4689   application.SendNotification();
4690   application.Render();
4691
4692   selectedText = textField.GetProperty(DevelTextField::Property::SELECTED_TEXT).Get<std::string>();
4693   DALI_TEST_EQUALS(" w", selectedText, TEST_LOCATION);
4694
4695   DALI_TEST_EQUALS(textField.GetProperty(DevelTextField::Property::SELECTED_TEXT_START).Get<int>(), 0, TEST_LOCATION);
4696   DALI_TEST_EQUALS(textField.GetProperty(DevelTextField::Property::SELECTED_TEXT_END).Get<int>(), 2, TEST_LOCATION);
4697
4698   // " w" is cut
4699   DALI_TEST_EQUALS(" w", DevelTextField::CutText(textField), TEST_LOCATION);
4700
4701   application.SendNotification();
4702   application.Render();
4703
4704   DALI_TEST_EQUALS(textField.GetProperty(TextField::Property::TEXT).Get<std::string>(), "orld", TEST_LOCATION);
4705
4706   // Test Cut from the middle
4707
4708   // "rl" is selected
4709   DevelTextField::SelectText(textField, 1, 3);
4710
4711   application.SendNotification();
4712   application.Render();
4713
4714   selectedText = textField.GetProperty(DevelTextField::Property::SELECTED_TEXT).Get<std::string>();
4715   DALI_TEST_EQUALS("rl", selectedText, TEST_LOCATION);
4716
4717   DALI_TEST_EQUALS(textField.GetProperty(DevelTextField::Property::SELECTED_TEXT_START).Get<int>(), 1, TEST_LOCATION);
4718   DALI_TEST_EQUALS(textField.GetProperty(DevelTextField::Property::SELECTED_TEXT_END).Get<int>(), 3, TEST_LOCATION);
4719
4720   // "rl" is cut
4721   DALI_TEST_EQUALS("rl", DevelTextField::CutText(textField), TEST_LOCATION);
4722
4723   application.SendNotification();
4724   application.Render();
4725
4726   DALI_TEST_EQUALS(textField.GetProperty(TextField::Property::TEXT).Get<std::string>(), "od", TEST_LOCATION);
4727
4728   // Test Cut from the end
4729
4730   // "d" is selected
4731   DevelTextField::SelectText(textField, 1, 2);
4732
4733   application.SendNotification();
4734   application.Render();
4735
4736   selectedText = textField.GetProperty(DevelTextField::Property::SELECTED_TEXT).Get<std::string>();
4737   DALI_TEST_EQUALS("d", selectedText, TEST_LOCATION);
4738
4739   DALI_TEST_EQUALS(textField.GetProperty(DevelTextField::Property::SELECTED_TEXT_START).Get<int>(), 1, TEST_LOCATION);
4740   DALI_TEST_EQUALS(textField.GetProperty(DevelTextField::Property::SELECTED_TEXT_END).Get<int>(), 2, TEST_LOCATION);
4741
4742   // "d" is cut
4743   DALI_TEST_EQUALS("d", DevelTextField::CutText(textField), TEST_LOCATION);
4744
4745   application.SendNotification();
4746   application.Render();
4747
4748   DALI_TEST_EQUALS(textField.GetProperty(TextField::Property::TEXT).Get<std::string>(), "o", TEST_LOCATION);
4749
4750   END_TEST;
4751 }
4752
4753 int UtcDaliTextFieldPasteText(void)
4754 {
4755   ToolkitTestApplication application;
4756   tet_infoline(" UtcDaliTextFieldPasteText ");
4757
4758   TextField textField = TextField::New();
4759
4760   application.GetScene().Add(textField);
4761
4762   std::string cutText    = "";
4763   std::string copiedText = "";
4764
4765   textField.SetProperty(Actor::Property::SIZE, Vector2(300.f, 50.f));
4766   textField.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT);
4767   textField.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
4768
4769   // Avoid a crash when core load gl resources.
4770   application.GetGlAbstraction().SetCheckFramebufferStatusResult(GL_FRAMEBUFFER_COMPLETE);
4771
4772   application.SendNotification();
4773   application.Render();
4774
4775   textField.SetProperty(TextField::Property::TEXT, "Hello World");
4776
4777   application.SendNotification();
4778   application.Render();
4779
4780   // Tap on the text editor
4781   TestGenerateTap(application, 3.0f, 25.0f);
4782
4783   // Render and notify
4784   application.SendNotification();
4785   application.Render();
4786
4787   // Select some text in the right of the current cursor position
4788   DevelTextField::SelectText(textField, 0, 3);
4789
4790   // Render and notify
4791   application.SendNotification();
4792   application.Render();
4793
4794   // Cut the selected text
4795   cutText = DevelTextField::CutText(textField);
4796
4797   // Render and notify
4798   application.SendNotification();
4799   application.Render();
4800
4801   DALI_TEST_EQUALS("Hel", cutText, TEST_LOCATION);
4802   DALI_TEST_EQUALS(textField.GetProperty(TextField::Property::TEXT).Get<std::string>(), "lo World", TEST_LOCATION);
4803
4804   DevelTextField::SelectText(textField, 0, 3);
4805
4806   // Render and notify
4807   application.SendNotification();
4808   application.Render();
4809
4810   // Copy the selected text
4811   copiedText = DevelTextField::CopyText(textField);
4812
4813   // Render and notify
4814   application.SendNotification();
4815   application.Render();
4816
4817   DALI_TEST_EQUALS("lo ", copiedText, TEST_LOCATION);
4818   DALI_TEST_EQUALS("lo World", textField.GetProperty<std::string>(TextField::Property::TEXT), TEST_LOCATION);
4819
4820   // Move the cursor to the end of the line
4821   application.ProcessEvent(GenerateKey("", "", "", DALI_KEY_CURSOR_RIGHT, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
4822   application.ProcessEvent(GenerateKey("", "", "", DALI_KEY_CURSOR_RIGHT, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
4823   application.ProcessEvent(GenerateKey("", "", "", DALI_KEY_CURSOR_RIGHT, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
4824   application.ProcessEvent(GenerateKey("", "", "", DALI_KEY_CURSOR_RIGHT, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
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
4830   // Render and notify
4831   application.SendNotification();
4832   application.Render();
4833
4834   // Paste the selected text at the current cursor position
4835   DevelTextField::PasteText(textField);
4836
4837   // Render and notify
4838   application.SendNotification();
4839   application.Render();
4840
4841   DALI_TEST_EQUALS(textField.GetProperty(TextField::Property::TEXT).Get<std::string>(), "lo Worldlo ", TEST_LOCATION);
4842
4843   END_TEST;
4844 }
4845
4846 int utcDaliTextFieldCursorPositionChangedSignal(void)
4847 {
4848   ToolkitTestApplication application;
4849   tet_infoline(" utcDaliTextFieldCursorPositionChangedSignal");
4850
4851   TextField field = TextField::New();
4852   DALI_TEST_CHECK(field);
4853
4854   application.GetScene().Add(field);
4855
4856   // connect to the selection changed signal.
4857   ConnectionTracker* testTracker = new ConnectionTracker();
4858   DevelTextField::CursorPositionChangedSignal(field).Connect(&TestCursorPositionChangedCallback);
4859   bool cursorPositionChangedSignal = false;
4860   field.ConnectSignal(testTracker, "cursorPositionChanged", CallbackFunctor(&cursorPositionChangedSignal));
4861
4862   field.SetProperty(TextField::Property::TEXT, "Hello world Hello world");
4863   field.SetProperty(TextField::Property::POINT_SIZE, 10.f);
4864   field.SetProperty(Actor::Property::SIZE, Vector2(100.f, 50.f));
4865   field.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT);
4866   field.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
4867
4868   // Avoid a crash when core load gl resources.
4869   application.GetGlAbstraction().SetCheckFramebufferStatusResult(GL_FRAMEBUFFER_COMPLETE);
4870
4871   // Render and notify
4872   application.SendNotification();
4873   application.Render();
4874
4875   field.SetKeyInputFocus();
4876
4877   // Tap on the text field
4878   TestGenerateTap(application, 3.0f, 25.0f);
4879
4880   // Render and notify
4881   application.SendNotification();
4882   application.Render();
4883
4884   DALI_TEST_CHECK(gCursorPositionChangedCallbackCalled);
4885   DALI_TEST_EQUALS(oldCursorPos, 23, TEST_LOCATION);
4886
4887   gCursorPositionChangedCallbackCalled = false;
4888
4889   // Move to left.
4890   application.ProcessEvent(GenerateKey("", "", "", DALI_KEY_CURSOR_LEFT, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
4891
4892   // Render and notify
4893   application.SendNotification();
4894   application.Render();
4895
4896   DALI_TEST_CHECK(gCursorPositionChangedCallbackCalled);
4897   DALI_TEST_EQUALS(oldCursorPos, 17, TEST_LOCATION);
4898
4899   gCursorPositionChangedCallbackCalled = false;
4900
4901   // Insert D
4902   application.ProcessEvent(GenerateKey("D", "", "D", KEY_D_CODE, 0, 0, Integration::KeyEvent::DOWN, "D", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
4903
4904   // Render and notify
4905   application.SendNotification();
4906   application.Render();
4907
4908   DALI_TEST_CHECK(gCursorPositionChangedCallbackCalled);
4909   DALI_TEST_EQUALS(oldCursorPos, 16, TEST_LOCATION);
4910
4911   gCursorPositionChangedCallbackCalled = false;
4912
4913   //delete one character
4914   application.ProcessEvent(GenerateKey("", "", "", DALI_KEY_BACKSPACE, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
4915
4916   // Render and notify
4917   application.SendNotification();
4918   application.Render();
4919
4920   DALI_TEST_CHECK(gCursorPositionChangedCallbackCalled);
4921   DALI_TEST_EQUALS(oldCursorPos, 17, TEST_LOCATION);
4922
4923   gCursorPositionChangedCallbackCalled = false;
4924
4925   field.SetProperty(TextField::Property::TEXT, "Hello");
4926
4927   // Render and notify
4928   application.SendNotification();
4929   application.Render();
4930
4931   DALI_TEST_CHECK(gCursorPositionChangedCallbackCalled);
4932   DALI_TEST_EQUALS(oldCursorPos, 16, TEST_LOCATION);
4933
4934   gCursorPositionChangedCallbackCalled = false;
4935
4936   field.SetProperty(DevelTextField::Property::PRIMARY_CURSOR_POSITION, 3);
4937
4938   // Render and notify
4939   application.SendNotification();
4940   application.Render();
4941
4942   DALI_TEST_CHECK(gCursorPositionChangedCallbackCalled);
4943   DALI_TEST_EQUALS(oldCursorPos, 5, TEST_LOCATION);
4944
4945   END_TEST;
4946 }
4947
4948 int utcDaliTextFieldGeometryEllipsisStart(void)
4949 {
4950   ToolkitTestApplication application;
4951   tet_infoline(" utcDaliTextFieldGeometryEllipsisStart");
4952
4953   TextField field = TextField::New();
4954   DALI_TEST_CHECK(field);
4955
4956   application.GetScene().Add(field);
4957
4958   field.SetProperty(TextField::Property::POINT_SIZE, 7.f);
4959   field.SetProperty(Actor::Property::SIZE, Vector2(250.f, 50.f));
4960   field.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT);
4961   field.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
4962   field.SetProperty(TextField::Property::ENABLE_MARKUP, true);
4963   field.SetProperty(DevelTextField::Property::ELLIPSIS, true);
4964   field.SetProperty(DevelTextField::Property::ELLIPSIS_POSITION, DevelText::EllipsisPosition::START);
4965   field.SetProperty(TextField::Property::TEXT, "Hello World");
4966
4967   // Avoid a crash when core load gl resources.
4968   application.GetGlAbstraction().SetCheckFramebufferStatusResult(GL_FRAMEBUFFER_COMPLETE);
4969
4970   // Render and notify
4971   application.SendNotification();
4972   application.Render();
4973
4974   unsigned int expectedCount = 1;
4975   unsigned int startIndex    = 0;
4976   unsigned int endIndex      = 10;
4977
4978   Vector<Vector2> positionsList = DevelTextField::GetTextPosition(field, startIndex, endIndex);
4979   Vector<Vector2> sizeList      = DevelTextField::GetTextSize(field, startIndex, endIndex);
4980
4981   DALI_TEST_EQUALS(positionsList.Size(), expectedCount, TEST_LOCATION);
4982   DALI_TEST_EQUALS(sizeList.Size(), expectedCount, TEST_LOCATION);
4983
4984   Vector<Vector2> expectedSizes;
4985   Vector<Vector2> expectedPositions;
4986
4987   expectedPositions.PushBack(Vector2(14, 0));
4988   expectedSizes.PushBack(Vector2(107, 25));
4989
4990   TestTextGeometryUtils::CheckGeometryResult(positionsList, sizeList, expectedPositions, expectedSizes);
4991
4992   END_TEST;
4993 }
4994
4995 int utcDaliTextFieldGeometryEllipsisEnd(void)
4996 {
4997   ToolkitTestApplication application;
4998   tet_infoline(" utcDaliTextFieldGeometryEllipsisEnd");
4999
5000   TextField field = TextField::New();
5001   DALI_TEST_CHECK(field);
5002
5003   application.GetScene().Add(field);
5004
5005   field.SetProperty(TextField::Property::POINT_SIZE, 7.f);
5006   field.SetProperty(Actor::Property::SIZE, Vector2(250.f, 50.f));
5007   field.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT);
5008   field.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
5009   field.SetProperty(TextField::Property::ENABLE_MARKUP, true);
5010   field.SetProperty(DevelTextField::Property::ELLIPSIS, true);
5011   field.SetProperty(DevelTextField::Property::ELLIPSIS_POSITION, DevelText::EllipsisPosition::END);
5012   field.SetProperty(TextField::Property::TEXT, "Hello World");
5013
5014   // Avoid a crash when core load gl resources.
5015   application.GetGlAbstraction().SetCheckFramebufferStatusResult(GL_FRAMEBUFFER_COMPLETE);
5016
5017   // Render and notify
5018   application.SendNotification();
5019   application.Render();
5020
5021   unsigned int expectedCount = 1;
5022   unsigned int startIndex    = 0;
5023   unsigned int endIndex      = 10;
5024
5025   Vector<Vector2> positionsList = DevelTextField::GetTextPosition(field, startIndex, endIndex);
5026   Vector<Vector2> sizeList      = DevelTextField::GetTextSize(field, startIndex, endIndex);
5027
5028   DALI_TEST_EQUALS(positionsList.Size(), expectedCount, TEST_LOCATION);
5029   DALI_TEST_EQUALS(sizeList.Size(), expectedCount, TEST_LOCATION);
5030
5031   Vector<Vector2> expectedSizes;
5032   Vector<Vector2> expectedPositions;
5033
5034   expectedPositions.PushBack(Vector2(-2, 0));
5035   expectedSizes.PushBack(Vector2(123, 25));
5036
5037   TestTextGeometryUtils::CheckGeometryResult(positionsList, sizeList, expectedPositions, expectedSizes);
5038
5039   END_TEST;
5040 }
5041
5042 int utcDaliTextFieldGeometryRTL(void)
5043 {
5044   ToolkitTestApplication application;
5045   tet_infoline(" utcDaliTextFieldGeometryRTL");
5046
5047   TextField field = TextField::New();
5048   DALI_TEST_CHECK(field);
5049
5050   application.GetScene().Add(field);
5051
5052   field.SetProperty(TextField::Property::POINT_SIZE, 7.f);
5053   field.SetProperty(Actor::Property::SIZE, Vector2(300.f, 50.f));
5054   field.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT);
5055   field.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
5056   field.SetProperty(TextField::Property::ENABLE_MARKUP, true);
5057   field.SetProperty(TextField::Property::TEXT, "السطر الاخير");
5058
5059   // Avoid a crash when core load gl resources.
5060   application.GetGlAbstraction().SetCheckFramebufferStatusResult(GL_FRAMEBUFFER_COMPLETE);
5061
5062   // Render and notify
5063   application.SendNotification();
5064   application.Render();
5065
5066   unsigned int expectedCount = 1;
5067   unsigned int startIndex    = 1;
5068   unsigned int endIndex      = 7;
5069
5070   Vector<Vector2> positionsList = DevelTextField::GetTextPosition(field, startIndex, endIndex);
5071   Vector<Vector2> sizeList      = DevelTextField::GetTextSize(field, startIndex, endIndex);
5072
5073   DALI_TEST_EQUALS(positionsList.Size(), expectedCount, TEST_LOCATION);
5074   DALI_TEST_EQUALS(sizeList.Size(), expectedCount, TEST_LOCATION);
5075
5076   Vector<Vector2> expectedSizes;
5077   Vector<Vector2> expectedPositions;
5078
5079   expectedPositions.PushBack(Vector2(38, 0));
5080   expectedSizes.PushBack(Vector2(75, 25));
5081
5082   TestTextGeometryUtils::CheckGeometryResult(positionsList, sizeList, expectedPositions, expectedSizes);
5083
5084   END_TEST;
5085 }
5086
5087 int utcDaliTextFieldGeometryGlyphMiddle(void)
5088 {
5089   ToolkitTestApplication application;
5090   tet_infoline(" utcDaliTextFieldGeometryGlyphMiddle");
5091
5092   TextField field = TextField::New();
5093   DALI_TEST_CHECK(field);
5094
5095   application.GetScene().Add(field);
5096
5097   field.SetProperty(TextField::Property::POINT_SIZE, 7.f);
5098   field.SetProperty(Actor::Property::SIZE, Vector2(150.f, 200.f));
5099   field.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT);
5100   field.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
5101   field.SetProperty(TextField::Property::ENABLE_MARKUP, true);
5102   field.SetProperty(TextField::Property::TEXT, "لا تحتوي على لا");
5103
5104   // Avoid a crash when core load gl resources.
5105   application.GetGlAbstraction().SetCheckFramebufferStatusResult(GL_FRAMEBUFFER_COMPLETE);
5106
5107   // Render and notify
5108   application.SendNotification();
5109   application.Render();
5110
5111   unsigned int expectedCount = 1;
5112   unsigned int startIndex    = 1;
5113   unsigned int endIndex      = 13;
5114
5115   Vector<Vector2> positionsList = DevelTextField::GetTextPosition(field, startIndex, endIndex);
5116   Vector<Vector2> sizeList      = DevelTextField::GetTextSize(field, startIndex, endIndex);
5117
5118   DALI_TEST_EQUALS(positionsList.Size(), expectedCount, TEST_LOCATION);
5119   DALI_TEST_EQUALS(sizeList.Size(), expectedCount, TEST_LOCATION);
5120
5121   Vector<Vector2> expectedSizes;
5122   Vector<Vector2> expectedPositions;
5123
5124   expectedPositions.PushBack(Vector2(6, 0));
5125   expectedSizes.PushBack(Vector2(125, 25));
5126
5127   TestTextGeometryUtils::CheckGeometryResult(positionsList, sizeList, expectedPositions, expectedSizes);
5128
5129   END_TEST;
5130 }
5131
5132 int utcDaliTextFieldGeometryNullPtr(void)
5133 {
5134   ToolkitTestApplication application;
5135   tet_infoline("utcDaliTextFieldGeometryNullPtr");
5136
5137   TextField field = TextField::New();
5138   DALI_TEST_CHECK(field);
5139
5140   application.GetScene().Add(field);
5141
5142   field.SetProperty(TextField::Property::POINT_SIZE, 7.f);
5143   field.SetProperty(Actor::Property::SIZE, Vector2(200.f, 200.f));
5144   field.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT);
5145   field.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
5146   field.SetProperty(TextField::Property::ENABLE_MARKUP, true);
5147   field.SetProperty(TextField::Property::TEXT, "");
5148
5149   // Avoid a crash when core load gl resources.
5150   application.GetGlAbstraction().SetCheckFramebufferStatusResult(GL_FRAMEBUFFER_COMPLETE);
5151
5152   unsigned int expectedCount = 0;
5153   unsigned int startIndex    = 0;
5154   unsigned int endIndex      = 0;
5155
5156   Vector<Vector2> positionsList = DevelTextField::GetTextPosition(field, startIndex, endIndex);
5157   Vector<Vector2> sizeList      = DevelTextField::GetTextSize(field, startIndex, endIndex);
5158
5159   // Render and notify
5160   application.SendNotification();
5161   application.Render();
5162
5163   DALI_TEST_EQUALS(positionsList.Size(), expectedCount, TEST_LOCATION);
5164   DALI_TEST_EQUALS(sizeList.Size(), expectedCount, TEST_LOCATION);
5165
5166   END_TEST;
5167 }
5168
5169 int utcDaliTextFieldSelectionClearedSignal(void)
5170 {
5171   ToolkitTestApplication application;
5172   tet_infoline(" utcDaliTextFieldSelectionClearedSignal");
5173
5174   TextField field = TextField::New();
5175   DALI_TEST_CHECK(field);
5176
5177   application.GetScene().Add(field);
5178
5179   // connect to the selection changed signal.
5180   ConnectionTracker* testTracker = new ConnectionTracker();
5181   DevelTextField::SelectionClearedSignal(field).Connect(&TestSelectionClearedCallback);
5182   bool selectionClearedSignal = false;
5183   field.ConnectSignal(testTracker, "selectionCleared", CallbackFunctor(&selectionClearedSignal));
5184
5185   field.SetProperty(TextField::Property::TEXT, "Hello\nworld\nHello world");
5186   field.SetProperty(TextField::Property::POINT_SIZE, 10.f);
5187   field.SetProperty(Actor::Property::SIZE, Vector2(100.f, 50.f));
5188   field.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT);
5189   field.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
5190
5191   // Avoid a crash when core load gl resources.
5192   application.GetGlAbstraction().SetCheckFramebufferStatusResult(GL_FRAMEBUFFER_COMPLETE);
5193
5194   // Render and notify
5195   application.SendNotification();
5196   application.Render();
5197
5198   // Tap on the text editor
5199   TestGenerateTap(application, 3.0f, 25.0f);
5200
5201   // Render and notify
5202   application.SendNotification();
5203   application.Render();
5204
5205   // Move to second line of the text & Select some text in the right of the current cursor position
5206   application.ProcessEvent(GenerateKey("", "", "", DALI_KEY_CURSOR_DOWN, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
5207   application.ProcessEvent(GenerateKey("", "", "", DALI_KEY_CURSOR_RIGHT, KEY_SHIFT_MODIFIER, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
5208
5209   // remove selection
5210   application.ProcessEvent(GenerateKey("", "", "", DALI_KEY_ESCAPE, 0, 0, Integration::KeyEvent::UP, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
5211
5212   // Render and notify
5213   application.SendNotification();
5214   application.Render();
5215
5216   DALI_TEST_CHECK(gSelectionClearedCallbackCalled);
5217
5218   // Render and notify
5219   application.SendNotification();
5220   application.Render();
5221
5222   // Tap on the text editor
5223   TestGenerateTap(application, 3.0f, 25.0f);
5224
5225   // Render and notify
5226   application.SendNotification();
5227   application.Render();
5228
5229   gSelectionClearedCallbackCalled = false;
5230
5231   // Move to second line of the text & select.
5232   application.ProcessEvent(GenerateKey("", "", "", DALI_KEY_CURSOR_DOWN, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
5233   application.ProcessEvent(GenerateKey("", "", "", DALI_KEY_CURSOR_RIGHT, KEY_SHIFT_MODIFIER, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
5234
5235   //remove selection
5236   application.ProcessEvent(GenerateKey("", "", "", DALI_KEY_CURSOR_RIGHT, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
5237
5238   // Render and notify
5239   application.SendNotification();
5240   application.Render();
5241
5242   DALI_TEST_CHECK(gSelectionClearedCallbackCalled);
5243
5244   gSelectionClearedCallbackCalled = false;
5245
5246   // Render and notify
5247   application.SendNotification();
5248   application.Render();
5249
5250   // Move to second line of the text & select.
5251   application.ProcessEvent(GenerateKey("", "", "", DALI_KEY_CURSOR_DOWN, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
5252   application.ProcessEvent(GenerateKey("", "", "", DALI_KEY_CURSOR_RIGHT, KEY_SHIFT_MODIFIER, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
5253
5254   // replace D with selected text
5255   application.ProcessEvent(GenerateKey("D", "", "D", KEY_D_CODE, 0, 0, Integration::KeyEvent::DOWN, "D", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
5256
5257   // Render and notify
5258   application.SendNotification();
5259   application.Render();
5260
5261   DALI_TEST_CHECK(gSelectionClearedCallbackCalled);
5262
5263   gSelectionClearedCallbackCalled = false;
5264
5265   // Render and notify
5266   application.SendNotification();
5267   application.Render();
5268
5269   DevelTextField::SelectText(field, 1, 3);
5270
5271   // Render and notify
5272   application.SendNotification();
5273   application.Render();
5274
5275   field.SetProperty(DevelTextField::Property::PRIMARY_CURSOR_POSITION, 3);
5276
5277   // Render and notify
5278   application.SendNotification();
5279   application.Render();
5280
5281   DALI_TEST_CHECK(gSelectionClearedCallbackCalled);
5282
5283   gSelectionClearedCallbackCalled = false;
5284
5285   DevelTextField::SelectText(field, 1, 3);
5286
5287   // Render and notify
5288   application.SendNotification();
5289   application.Render();
5290
5291   // select none
5292   DevelTextField::SelectNone(field);
5293
5294   // Render and notify
5295   application.SendNotification();
5296   application.Render();
5297
5298   DALI_TEST_CHECK(gSelectionClearedCallbackCalled);
5299
5300   END_TEST;
5301 }
5302
5303 int utcDaliTextFieldSelectionStartedSignal(void)
5304 {
5305   ToolkitTestApplication application;
5306   tet_infoline(" utcDaliTextFieldSelectionStartedSignal");
5307
5308   TextField field = TextField::New();
5309   DALI_TEST_CHECK(field);
5310
5311   application.GetScene().Add(field);
5312
5313   // connect to the selection changed signal.
5314   ConnectionTracker* testTracker = new ConnectionTracker();
5315   DevelTextField::SelectionStartedSignal(field).Connect(&TestSelectionStartedCallback);
5316   bool selectionStartedSignal = false;
5317   field.ConnectSignal(testTracker, "selectionStarted", CallbackFunctor(&selectionStartedSignal));
5318
5319   field.SetProperty(TextField::Property::TEXT, "Hello\nworld\nHello world");
5320   field.SetProperty(TextField::Property::POINT_SIZE, 10.f);
5321   field.SetProperty(Actor::Property::SIZE, Vector2(100.f, 50.f));
5322   field.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT);
5323   field.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
5324
5325   // Avoid a crash when core load gl resources.
5326   application.GetGlAbstraction().SetCheckFramebufferStatusResult(GL_FRAMEBUFFER_COMPLETE);
5327
5328   // Render and notify
5329   application.SendNotification();
5330   application.Render();
5331
5332   // Tap on the text field
5333   TestGenerateTap(application, 3.0f, 25.0f);
5334
5335   // Render and notify
5336   application.SendNotification();
5337   application.Render();
5338
5339   // Move to second line of the text & Select some text in the right of the current cursor position
5340   application.ProcessEvent(GenerateKey("", "", "", DALI_KEY_CURSOR_DOWN, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
5341   application.ProcessEvent(GenerateKey("", "", "", DALI_KEY_CURSOR_RIGHT, KEY_SHIFT_MODIFIER, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
5342
5343   // Render and notify
5344   application.SendNotification();
5345   application.Render();
5346
5347   DALI_TEST_CHECK(gSelectionStartedCallbackCalled);
5348
5349   // remove selection
5350   application.ProcessEvent(GenerateKey("", "", "", DALI_KEY_ESCAPE, 0, 0, Integration::KeyEvent::UP, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
5351
5352   // Render and notify
5353   application.SendNotification();
5354   application.Render();
5355
5356   gSelectionStartedCallbackCalled = false;
5357
5358   DevelTextField::SelectText(field, 1, 3);
5359
5360   // Render and notify
5361   application.SendNotification();
5362   application.Render();
5363
5364   DALI_TEST_CHECK(gSelectionStartedCallbackCalled);
5365
5366   END_TEST;
5367 }
5368
5369 int utcDaliTextFieldSelectionChangedSignal(void)
5370 {
5371   ToolkitTestApplication application;
5372   tet_infoline(" utcDaliTextFieldSelectionChangedSignal");
5373
5374   TextField field = TextField::New();
5375   DALI_TEST_CHECK(field);
5376
5377   application.GetScene().Add(field);
5378
5379   // connect to the selection changed signal.
5380   ConnectionTracker* testTracker = new ConnectionTracker();
5381   DevelTextField::SelectionChangedSignal(field).Connect(&TestSelectionChangedCallback);
5382   bool selectionChangedSignal = false;
5383   field.ConnectSignal(testTracker, "selectionChanged", CallbackFunctor(&selectionChangedSignal));
5384
5385   field.SetProperty(TextField::Property::TEXT, "Hello world Hello world");
5386   field.SetProperty(TextField::Property::POINT_SIZE, 10.f);
5387   field.SetProperty(Actor::Property::SIZE, Vector2(100.f, 50.f));
5388   field.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT);
5389   field.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
5390
5391   // Avoid a crash when core load gl resources.
5392   application.GetGlAbstraction().SetCheckFramebufferStatusResult(GL_FRAMEBUFFER_COMPLETE);
5393
5394   // Render and notify
5395   application.SendNotification();
5396   application.Render();
5397
5398   // Tap on the text field
5399   TestGenerateTap(application, 3.0f, 25.0f);
5400
5401   // Render and notify
5402   application.SendNotification();
5403   application.Render();
5404
5405   // Select some text in the right of the current cursor position
5406   application.ProcessEvent(GenerateKey("", "", "", DALI_KEY_SHIFT_LEFT, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
5407   application.ProcessEvent(GenerateKey("", "", "", DALI_KEY_CURSOR_RIGHT, KEY_SHIFT_MODIFIER, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
5408
5409   // Render and notify
5410   application.SendNotification();
5411   application.Render();
5412
5413   DALI_TEST_CHECK(gSelectionChangedCallbackCalled);
5414   DALI_TEST_EQUALS(oldSelectionStart, oldSelectionEnd, TEST_LOCATION);
5415
5416   gSelectionChangedCallbackCalled = false;
5417
5418   application.ProcessEvent(GenerateKey("", "", "", DALI_KEY_CURSOR_RIGHT, KEY_SHIFT_MODIFIER, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
5419
5420   // Render and notify
5421   application.SendNotification();
5422   application.Render();
5423
5424   DALI_TEST_CHECK(gSelectionChangedCallbackCalled);
5425   DALI_TEST_EQUALS(oldSelectionStart, 0, TEST_LOCATION);
5426   DALI_TEST_EQUALS(oldSelectionEnd, 1, TEST_LOCATION);
5427
5428   gSelectionChangedCallbackCalled = false;
5429
5430   application.ProcessEvent(GenerateKey("", "", "", DALI_KEY_ESCAPE, 0, 0, Integration::KeyEvent::UP, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
5431
5432   // Render and notify
5433   application.SendNotification();
5434   application.Render();
5435
5436   DALI_TEST_CHECK(gSelectionChangedCallbackCalled);
5437   DALI_TEST_EQUALS(oldSelectionStart, 0, TEST_LOCATION);
5438   DALI_TEST_EQUALS(oldSelectionEnd, 2, TEST_LOCATION);
5439
5440   gSelectionChangedCallbackCalled = false;
5441   field.SetKeyInputFocus();
5442
5443   // Render and notify
5444   application.SendNotification();
5445   application.Render();
5446
5447   DevelTextField::SelectText(field, 0, 5);
5448
5449   application.SendNotification();
5450   application.Render();
5451
5452   DALI_TEST_CHECK(gSelectionChangedCallbackCalled);
5453   DALI_TEST_EQUALS(oldSelectionStart, oldSelectionEnd, TEST_LOCATION);
5454
5455   gSelectionChangedCallbackCalled = false;
5456
5457   field.SetProperty(DevelTextField::Property::PRIMARY_CURSOR_POSITION, 3);
5458
5459   // Render and notify
5460   application.SendNotification();
5461   application.Render();
5462
5463   DALI_TEST_CHECK(gSelectionChangedCallbackCalled);
5464   DALI_TEST_EQUALS(oldSelectionStart, 0, TEST_LOCATION);
5465   DALI_TEST_EQUALS(oldSelectionEnd, 5, TEST_LOCATION);
5466
5467   gSelectionChangedCallbackCalled = false;
5468
5469   // select all text
5470   DevelTextField::SelectWholeText(field);
5471
5472   // Render and notify
5473   application.SendNotification();
5474   application.Render();
5475
5476   DALI_TEST_CHECK(gSelectionChangedCallbackCalled);
5477   DALI_TEST_EQUALS(oldSelectionStart, oldSelectionEnd, TEST_LOCATION);
5478
5479   gSelectionChangedCallbackCalled = false;
5480
5481   // select none
5482   DevelTextField::SelectNone(field);
5483
5484   // Render and notify
5485   application.SendNotification();
5486   application.Render();
5487
5488   DALI_TEST_CHECK(gSelectionChangedCallbackCalled);
5489   DALI_TEST_EQUALS(oldSelectionStart, 0, TEST_LOCATION);
5490   DALI_TEST_EQUALS(oldSelectionEnd, 23, TEST_LOCATION);
5491
5492   END_TEST;
5493 }
5494
5495 int UtcDaliToolkitTextFieldStrikethroughGeneration(void)
5496 {
5497   ToolkitTestApplication application;
5498   tet_infoline(" UtcDaliToolkitTextFieldStrikethroughGeneration");
5499
5500   TextField textField = TextField::New();
5501   textField.SetProperty(TextField::Property::TEXT, "Test");
5502   textField.SetProperty(Actor::Property::SIZE, Vector2(200.0f, 100.f));
5503   textField.SetProperty(TextField::Property::POINT_SIZE, 10);
5504   textField.SetProperty(TextField::Property::FONT_FAMILY, "DejaVu Sans");
5505
5506   application.GetScene().Add(textField);
5507   application.SendNotification();
5508   application.Render();
5509
5510   Property::Map strikethroughMapSet;
5511   Property::Map strikethroughMapGet;
5512
5513   strikethroughMapSet.Insert("enable", true);
5514   strikethroughMapSet.Insert("color", Color::RED);
5515   strikethroughMapSet.Insert("height", 2.0f);
5516
5517   // Check the strikethrough property
5518   textField.SetProperty(DevelTextField::Property::STRIKETHROUGH, strikethroughMapSet);
5519   strikethroughMapGet = textField.GetProperty<Property::Map>(DevelTextField::Property::STRIKETHROUGH);
5520   textField.SetProperty(TextField::Property::TEXT, "Test1");
5521   DALI_TEST_EQUALS(strikethroughMapGet.Count(), strikethroughMapSet.Count(), TEST_LOCATION);
5522   DALI_TEST_EQUALS(DaliTestCheckMaps(strikethroughMapGet, strikethroughMapSet), true, TEST_LOCATION);
5523
5524   // Render and notify
5525   application.SendNotification();
5526   application.Render();
5527
5528   strikethroughMapSet.Clear();
5529   strikethroughMapGet.Clear();
5530
5531   END_TEST;
5532 }
5533
5534 int UtcDaliToolkitTextFieldInputStrikethroughGeneration(void)
5535 {
5536   ToolkitTestApplication application;
5537   tet_infoline(" UtcDaliToolkitTextFieldInputStrikethroughGeneration");
5538
5539   TextField textField = TextField::New();
5540   textField.SetProperty(TextField::Property::TEXT, "Test");
5541   textField.SetProperty(Actor::Property::SIZE, Vector2(200.0f, 100.f));
5542   textField.SetProperty(TextField::Property::POINT_SIZE, 10);
5543   textField.SetProperty(TextField::Property::FONT_FAMILY, "DejaVu Sans");
5544
5545   application.GetScene().Add(textField);
5546   application.SendNotification();
5547   application.Render();
5548
5549   std::string strikethroughSettings1("{\"enable\":\"true\",\"color\":\"red\",\"height\":\"2\"}");
5550
5551   // Check the strikethrough property
5552   textField.SetProperty(DevelTextField::Property::INPUT_STRIKETHROUGH, strikethroughSettings1);
5553   textField.SetProperty(TextField::Property::TEXT, "Test1");
5554   DALI_TEST_EQUALS(textField.GetProperty<std::string>(DevelTextField::Property::INPUT_STRIKETHROUGH), strikethroughSettings1, TEST_LOCATION);
5555
5556   // Render and notify
5557   application.SendNotification();
5558   application.Render();
5559
5560   END_TEST;
5561 }
5562
5563 int UtcDaliToolkitTextFieldUnderlineTypesGeneration1(void)
5564 {
5565   ToolkitTestApplication application;
5566   tet_infoline(" UtcDaliToolkitTextFieldUnderlineTypesGeneration1");
5567   TextField field = TextField::New();
5568   field.SetProperty(TextField::Property::TEXT, "Test");
5569   field.SetProperty(Actor::Property::SIZE, Vector2(200.0f, 100.f));
5570   field.SetProperty(TextField::Property::POINT_SIZE, 10);
5571   field.SetProperty(TextField::Property::FONT_FAMILY, "DejaVu Sans");
5572
5573   application.GetScene().Add(field);
5574   application.SendNotification();
5575   application.Render();
5576
5577   Property::Map underlineMapSet;
5578   Property::Map underlineMapGet;
5579
5580   underlineMapSet.Insert("enable", true);
5581   underlineMapSet.Insert("color", Color::RED);
5582   underlineMapSet.Insert("height", 1);
5583   underlineMapSet.Insert("type", Text::Underline::SOLID);
5584   underlineMapSet.Insert("dashWidth", 2);
5585   underlineMapSet.Insert("dashGap", 1);
5586
5587   // Check the underline property
5588   field.SetProperty(TextField::Property::UNDERLINE, underlineMapSet);
5589
5590   underlineMapGet = field.GetProperty<Property::Map>(TextField::Property::UNDERLINE);
5591   DALI_TEST_EQUALS(underlineMapGet.Count(), underlineMapSet.Count(), TEST_LOCATION);
5592   DALI_TEST_EQUALS(DaliTestCheckMaps(underlineMapGet, underlineMapSet), true, TEST_LOCATION);
5593
5594   // Render and notify
5595   application.SendNotification();
5596   application.Render();
5597
5598   underlineMapSet.Clear();
5599   underlineMapGet.Clear();
5600
5601   underlineMapSet.Insert("enable", true);
5602   underlineMapSet.Insert("color", Color::BLUE);
5603   underlineMapSet.Insert("height", 1);
5604   underlineMapSet.Insert("type", Text::Underline::DASHED);
5605   underlineMapSet.Insert("dashWidth", 4);
5606   underlineMapSet.Insert("dashGap", 2);
5607
5608   // Check the dashed underline property
5609   field.SetProperty(TextField::Property::UNDERLINE, underlineMapSet);
5610
5611   underlineMapGet = field.GetProperty<Property::Map>(TextField::Property::UNDERLINE);
5612   DALI_TEST_EQUALS(underlineMapGet.Count(), underlineMapSet.Count(), TEST_LOCATION);
5613   DALI_TEST_EQUALS(DaliTestCheckMaps(underlineMapGet, underlineMapSet), true, TEST_LOCATION);
5614
5615   // Render and notify
5616   application.SendNotification();
5617   application.Render();
5618
5619   underlineMapSet.Clear();
5620   underlineMapGet.Clear();
5621
5622   underlineMapSet.Insert("enable", true);
5623   underlineMapSet.Insert("color", Color::BLUE);
5624   underlineMapSet.Insert("height", 1);
5625   underlineMapSet.Insert("type", Text::Underline::DOUBLE);
5626   underlineMapSet.Insert("dashWidth", 4);
5627   underlineMapSet.Insert("dashGap", 2);
5628
5629   // Check the dashed underline property
5630   field.SetProperty(TextField::Property::UNDERLINE, underlineMapSet);
5631
5632   underlineMapGet = field.GetProperty<Property::Map>(TextField::Property::UNDERLINE);
5633   DALI_TEST_EQUALS(underlineMapGet.Count(), underlineMapSet.Count(), TEST_LOCATION);
5634   DALI_TEST_EQUALS(DaliTestCheckMaps(underlineMapGet, underlineMapSet), true, TEST_LOCATION);
5635
5636   // Render and notify
5637   application.SendNotification();
5638   application.Render();
5639
5640   underlineMapSet.Clear();
5641   underlineMapGet.Clear();
5642
5643   END_TEST;
5644 }
5645
5646 int UtcDaliToolkitTextFieldUnderlineTypesGeneration2(void)
5647 {
5648   ToolkitTestApplication application;
5649   tet_infoline(" UtcDaliToolkitTextFieldUnderlineTypesGeneration2");
5650
5651   TextField field1 = TextField::New();
5652   field1.SetProperty(TextField::Property::TEXT, "Test");
5653   field1.SetProperty(Actor::Property::SIZE, Vector2(200.0f, 100.f));
5654   field1.SetProperty(TextField::Property::POINT_SIZE, 10);
5655   field1.SetProperty(TextField::Property::FONT_FAMILY, "DejaVu Sans");
5656
5657   Property::Map underlineMapSet1;
5658   Property::Map underlineMapGet1;
5659
5660   underlineMapSet1.Insert("enable", true);
5661   underlineMapSet1.Insert("color", Color::RED);
5662   underlineMapSet1.Insert("height", 1);
5663   underlineMapSet1.Insert("type", Text::Underline::SOLID);
5664   underlineMapSet1.Insert("dashWidth", 2);
5665   underlineMapSet1.Insert("dashGap", 1);
5666
5667   // Check the underline property
5668   field1.SetProperty(TextField::Property::UNDERLINE, underlineMapSet1);
5669
5670   underlineMapGet1 = field1.GetProperty<Property::Map>(TextField::Property::UNDERLINE);
5671   DALI_TEST_EQUALS(underlineMapGet1.Count(), underlineMapSet1.Count(), TEST_LOCATION);
5672   DALI_TEST_EQUALS(DaliTestCheckMaps(underlineMapGet1, underlineMapSet1), true, TEST_LOCATION);
5673
5674   application.GetScene().Add(field1);
5675   application.SendNotification();
5676   application.Render();
5677
5678   TextField field2 = TextField::New();
5679   field2.SetProperty(TextField::Property::TEXT, "Test");
5680   field2.SetProperty(Actor::Property::SIZE, Vector2(200.0f, 100.f));
5681   field2.SetProperty(TextField::Property::POINT_SIZE, 10);
5682   field2.SetProperty(TextField::Property::FONT_FAMILY, "DejaVu Sans");
5683
5684   Property::Map underlineMapSet2;
5685   Property::Map underlineMapGet2;
5686
5687   underlineMapSet2.Insert("enable", true);
5688   underlineMapSet2.Insert("color", Color::BLUE);
5689   underlineMapSet2.Insert("height", 1);
5690   underlineMapSet2.Insert("type", Text::Underline::DASHED);
5691   underlineMapSet2.Insert("dashWidth", 4);
5692   underlineMapSet2.Insert("dashGap", 2);
5693
5694   // Check the dashed underline property
5695   field2.SetProperty(TextField::Property::UNDERLINE, underlineMapSet2);
5696
5697   underlineMapGet2 = field2.GetProperty<Property::Map>(TextField::Property::UNDERLINE);
5698   DALI_TEST_EQUALS(underlineMapGet2.Count(), underlineMapSet2.Count(), TEST_LOCATION);
5699   DALI_TEST_EQUALS(DaliTestCheckMaps(underlineMapGet2, underlineMapSet2), true, TEST_LOCATION);
5700
5701   application.GetScene().Add(field2);
5702   application.SendNotification();
5703   application.Render();
5704
5705   TextField field3 = TextField::New();
5706   field3.SetProperty(TextField::Property::TEXT, "Test");
5707   field3.SetProperty(Actor::Property::SIZE, Vector2(200.0f, 100.f));
5708   field3.SetProperty(TextField::Property::POINT_SIZE, 10);
5709   field3.SetProperty(TextField::Property::FONT_FAMILY, "DejaVu Sans");
5710
5711   Property::Map underlineMapSet3;
5712   Property::Map underlineMapGet3;
5713
5714   underlineMapSet3.Insert("enable", true);
5715   underlineMapSet3.Insert("color", Color::BLUE);
5716   underlineMapSet3.Insert("height", 1);
5717   underlineMapSet3.Insert("type", Text::Underline::DOUBLE);
5718   underlineMapSet3.Insert("dashWidth", 4);
5719   underlineMapSet3.Insert("dashGap", 2);
5720
5721   // Check the dashed underline property
5722   field3.SetProperty(TextField::Property::UNDERLINE, underlineMapSet3);
5723
5724   underlineMapGet3 = field3.GetProperty<Property::Map>(TextField::Property::UNDERLINE);
5725   DALI_TEST_EQUALS(underlineMapGet3.Count(), underlineMapSet3.Count(), TEST_LOCATION);
5726   DALI_TEST_EQUALS(DaliTestCheckMaps(underlineMapGet3, underlineMapSet3), true, TEST_LOCATION);
5727
5728   application.GetScene().Add(field3);
5729
5730   application.SendNotification();
5731   application.Render();
5732
5733   END_TEST;
5734 }
5735
5736 int UtcDaliTextFieldCharacterSpacing(void)
5737 {
5738   ToolkitTestApplication application;
5739   tet_infoline(" UtcDaliTextFieldCharacterSpacing ");
5740
5741   TextField textField = TextField::New();
5742
5743   textField.SetProperty(Actor::Property::SIZE, Vector2(150.0f, 300.f));
5744
5745   application.GetScene().Add(textField);
5746   application.SendNotification();
5747   application.Render();
5748
5749   textField.SetProperty(TextField::Property::TEXT, "Hi Experiment");
5750   textField.SetProperty(DevelTextField::Property::CHARACTER_SPACING, 10.f);
5751   DALI_TEST_EQUALS(textField.GetProperty<float>(DevelTextField::Property::CHARACTER_SPACING), 10.f, Math::MACHINE_EPSILON_1000, TEST_LOCATION);
5752
5753   application.SendNotification();
5754   application.Render();
5755
5756   END_TEST;
5757 }
5758
5759 int UtcDaliToolkitTextFieldUnderlineTypesGeneration3(void)
5760 {
5761   ToolkitTestApplication application;
5762   tet_infoline(" UtcDaliToolkitTextFieldUnderlineTypesGeneration3");
5763
5764   TextField field1 = TextField::New();
5765   field1.SetProperty(TextField::Property::TEXT, "Test1");
5766   field1.SetProperty(Actor::Property::SIZE, Vector2(200.0f, 100.f));
5767   field1.SetProperty(TextField::Property::POINT_SIZE, 10);
5768   field1.SetProperty(TextField::Property::FONT_FAMILY, "DejaVu Sans");
5769
5770   Property::Map underlineMapSet1;
5771   Property::Map underlineMapGet1;
5772
5773   underlineMapSet1.Insert("enable", true);
5774   underlineMapSet1.Insert("color", Color::RED);
5775   underlineMapSet1.Insert("height", 1);
5776   underlineMapSet1.Insert("type", Text::Underline::SOLID);
5777   underlineMapSet1.Insert("dashWidth", 2);
5778   underlineMapSet1.Insert("dashGap", 1);
5779
5780   // Check the underline property
5781   field1.SetProperty(TextField::Property::UNDERLINE, underlineMapSet1);
5782   //field1.SetProperty( TextField::Property::TEXT, "Test2" );
5783
5784   underlineMapGet1 = field1.GetProperty<Property::Map>(TextField::Property::UNDERLINE);
5785   DALI_TEST_EQUALS(underlineMapGet1.Count(), underlineMapSet1.Count(), TEST_LOCATION);
5786   DALI_TEST_EQUALS(DaliTestCheckMaps(underlineMapGet1, underlineMapSet1), true, TEST_LOCATION);
5787
5788   application.GetScene().Add(field1);
5789   application.SendNotification();
5790   application.Render();
5791
5792   END_TEST;
5793 }
5794
5795 int UtcDaliToolkitTextfieldParagraphTag(void)
5796 {
5797   ToolkitTestApplication application;
5798   tet_infoline(" UtcDaliToolkitTextfieldParagraphTag");
5799   TextField fieldNewlineSeparator = TextField::New();
5800   TextField fieldParagraphTag     = TextField::New();
5801   DALI_TEST_CHECK(fieldNewlineSeparator);
5802   DALI_TEST_CHECK(fieldParagraphTag);
5803
5804   application.GetScene().Add(fieldNewlineSeparator);
5805   application.GetScene().Add(fieldParagraphTag);
5806
5807   //Same utterance uses new-line to split paragraphs should give similar results for paragraph tag.
5808   fieldNewlineSeparator.SetProperty(TextField::Property::ENABLE_MARKUP, true);
5809   fieldNewlineSeparator.SetProperty(Actor::Property::SIZE, Vector2(100.f, 50.f));
5810   fieldNewlineSeparator.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT);
5811   fieldNewlineSeparator.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
5812   fieldNewlineSeparator.SetProperty(TextField::Property::TEXT, "test paragraph tag \ntest paragraph tag \ntest paragraph tag ");
5813
5814   fieldParagraphTag.SetProperty(TextField::Property::ENABLE_MARKUP, true);
5815   fieldParagraphTag.SetProperty(Actor::Property::SIZE, Vector2(100.f, 50.f));
5816   fieldParagraphTag.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT);
5817   fieldParagraphTag.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
5818   fieldParagraphTag.SetProperty(TextField::Property::TEXT, "test paragraph tag <p>test paragraph tag </p>test paragraph tag ");
5819
5820   application.SendNotification();
5821   application.Render();
5822
5823   Vector3 textNaturalSizeNewlineSeparator = fieldNewlineSeparator.GetNaturalSize();
5824   Vector3 textNaturalSizeParagraphTag     = fieldParagraphTag.GetNaturalSize();
5825
5826   DALI_TEST_EQUALS(textNaturalSizeNewlineSeparator, textNaturalSizeParagraphTag, TEST_LOCATION);
5827
5828   application.SendNotification();
5829   application.Render();
5830
5831   END_TEST;
5832 }
5833
5834 //Handle Emoji clustering for cursor handling
5835 int utcDaliTextFieldClusteredEmojiDeletionBackSpaceKey(void)
5836 {
5837   ToolkitTestApplication application;
5838   tet_infoline(" utcDaliTextFieldClusteredEmojiDeletionBackSpaceKey ");
5839   TextField textField = TextField::New();
5840   DALI_TEST_CHECK(textField);
5841
5842   application.GetScene().Add(textField);
5843
5844   // Avoid a crash when core load gl resources.
5845   application.GetGlAbstraction().SetCheckFramebufferStatusResult(GL_FRAMEBUFFER_COMPLETE);
5846
5847   textField.SetProperty(TextField::Property::TEXT, "ABC&#x1F468;&#x200D;&#x1F469;&#x200D;&#x1F467;&#x200D;&#x1F466;XY");
5848   textField.SetProperty(Dali::Toolkit::TextField::Property::ENABLE_MARKUP, true);
5849
5850   // Render and notify
5851   application.SendNotification();
5852   application.Render();
5853
5854   // Set currsor
5855   textField.SetProperty(DevelTextField::Property::PRIMARY_CURSOR_POSITION, 10);
5856   application.SendNotification();
5857   application.Render();
5858
5859   // Set focus and remove Emoji
5860   textField.SetKeyInputFocus();
5861   application.ProcessEvent(GenerateKey("", "", "", DALI_KEY_BACKSPACE, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
5862
5863   //Check the changed text and cursor position
5864   DALI_TEST_EQUALS(textField.GetProperty(TextField::Property::TEXT).Get<std::string>(), "ABCXY", TEST_LOCATION);
5865   DALI_TEST_EQUALS(textField.GetProperty(DevelTextField::Property::PRIMARY_CURSOR_POSITION).Get<int>(), 3, TEST_LOCATION);
5866
5867   // Render and notify
5868   application.SendNotification();
5869   application.Render();
5870
5871   END_TEST;
5872 }
5873
5874 int utcDaliTextFieldClusteredEmojiDeletionDeleteKey(void)
5875 {
5876   ToolkitTestApplication application;
5877   tet_infoline(" utcDaliTextFieldClusteredEmojiDeletionDeleteKey ");
5878   TextField textField = TextField::New();
5879   DALI_TEST_CHECK(textField);
5880
5881   application.GetScene().Add(textField);
5882
5883   // Avoid a crash when core load gl resources.
5884   application.GetGlAbstraction().SetCheckFramebufferStatusResult(GL_FRAMEBUFFER_COMPLETE);
5885
5886   textField.SetProperty(TextField::Property::TEXT, "ABC&#x1F468;&#x200D;&#x1F469;&#x200D;&#x1F467;&#x200D;&#x1F466;XY");
5887   textField.SetProperty(Dali::Toolkit::TextField::Property::ENABLE_MARKUP, true);
5888
5889   // Render and notify
5890   application.SendNotification();
5891   application.Render();
5892
5893   // Set currsor
5894   textField.SetProperty(DevelTextField::Property::PRIMARY_CURSOR_POSITION, 3);
5895   application.SendNotification();
5896   application.Render();
5897
5898   // Set focus and remove Emoji
5899   textField.SetKeyInputFocus();
5900   application.ProcessEvent(GenerateKey("", "", "", Dali::DevelKey::DALI_KEY_DELETE, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
5901
5902   //Check the changed text and cursor position
5903   DALI_TEST_EQUALS(textField.GetProperty(TextField::Property::TEXT).Get<std::string>(), "ABCXY", TEST_LOCATION);
5904   DALI_TEST_EQUALS(textField.GetProperty(DevelTextField::Property::PRIMARY_CURSOR_POSITION).Get<int>(), 3, TEST_LOCATION);
5905
5906   // Render and notify
5907   application.SendNotification();
5908   application.Render();
5909
5910   END_TEST;
5911 }
5912
5913 int utcDaliTextFieldPanGesturePropagation(void)
5914 {
5915   ToolkitTestApplication application;
5916   tet_infoline(" utcDaliTextFieldPanGesturePropagation");
5917
5918   Actor actor = Actor::New();
5919   actor.SetProperty(Actor::Property::SIZE, Vector2(100.0f, 100.0f));
5920   actor.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
5921   application.GetScene().Add(actor);
5922
5923   TextField field = TextField::New();
5924   DALI_TEST_CHECK(field);
5925
5926   field.SetProperty(TextField::Property::TEXT, "This is a long text for the size of the text-field.");
5927   field.SetProperty(TextField::Property::POINT_SIZE, 10.f);
5928
5929   field.SetProperty(Actor::Property::SIZE, Vector2(50.f, 100.f));
5930   field.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT);
5931   field.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
5932
5933   actor.Add(field);
5934
5935   // Render and notify
5936   application.SendNotification();
5937   application.Render();
5938
5939   SignalData             data;
5940   GestureReceivedFunctor functor(data);
5941
5942   PanGestureDetector detector = PanGestureDetector::New();
5943   detector.Attach(actor);
5944   detector.DetectedSignal().Connect(&application, functor);
5945
5946   // Tap first to get the focus.
5947   TestGenerateTap(application, 3.0f, 25.0f, 100);
5948
5949   // Render and notify
5950   application.SendNotification();
5951   application.Render();
5952
5953   // Pan the text field
5954   uint32_t time = 100;
5955   TestStartPan(application, Vector2(40.0f, 50.0f), Vector2(40.0f, 50.0f), time);
5956   TestMovePan(application, Vector2(10.0f, 50.0f), time);
5957   TestEndPan(application, Vector2(40.0f, 50.0f), time);
5958   application.SendNotification();
5959   application.Render();
5960
5961   // The text scrolls because there is text that is scrolling.
5962   DALI_TEST_EQUALS(false, data.functorCalled, TEST_LOCATION);
5963   data.Reset();
5964
5965   // Set the size large enough to prevent scrolling.
5966   field.SetProperty(Actor::Property::SIZE, Vector2(700.f, 100.f));
5967
5968   // Render and notify
5969   application.SendNotification();
5970   application.Render();
5971
5972   time = 200;
5973   TestStartPan(application, Vector2(40.0f, 50.0f), Vector2(40.0f, 50.0f), time);
5974   TestMovePan(application, Vector2(10.0f, 50.0f), time);
5975   TestEndPan(application, Vector2(40.0f, 50.0f), time);
5976
5977   // Because scrolling is not possible, the pan gesture is propagated.
5978   DALI_TEST_EQUALS(true, data.functorCalled, TEST_LOCATION);
5979   data.Reset();
5980
5981   END_TEST;
5982 }
5983
5984 int utcDaliTextFieldGetTextBoundingRectangle(void)
5985 {
5986   ToolkitTestApplication application;
5987   tet_infoline(" utcDaliTextFieldGeometryEllipsisMiddle");
5988
5989   TextField field = TextField::New();
5990   DALI_TEST_CHECK(field);
5991
5992   application.GetScene().Add(field);
5993
5994   field.SetProperty(TextField::Property::POINT_SIZE, 7.f);
5995   field.SetProperty(Actor::Property::SIZE, Vector2(100.f, 50.f));
5996   field.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT);
5997   field.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
5998   field.SetProperty(TextField::Property::TEXT, "Hello this is the Text Bounding Rectangle TC");
5999
6000   // Avoid a crash when core load gl resources.
6001   application.GetGlAbstraction().SetCheckFramebufferStatusResult(GL_FRAMEBUFFER_COMPLETE);
6002
6003   // Render and notify
6004   application.SendNotification();
6005   application.Render();
6006
6007   unsigned int startIndex = 0;
6008   unsigned int endIndex   = 15;
6009
6010   Rect<> textBoundingRectangle         = DevelTextField::GetTextBoundingRectangle(field, startIndex, endIndex);
6011   Rect<> expectedTextBoundingRectangle = {0, 0, 100, 25};
6012
6013   TestTextGeometryUtils::CheckRectGeometryResult(textBoundingRectangle, expectedTextBoundingRectangle);
6014
6015   END_TEST;
6016 }
6017
6018 int utcDaliTextFieldDecoratorColor(void)
6019 {
6020   ToolkitTestApplication application;
6021   tet_infoline(" utcDaliTextFieldDecoratorColor");
6022   TextField textField = TextField::New();
6023   DALI_TEST_CHECK(textField);
6024   LoadMarkerImages(application, textField);
6025   application.GetScene().Add(textField);
6026
6027   // Render and notify
6028   application.SendNotification();
6029   application.Render();
6030
6031   textField.SetProperty(TextField::Property::TEXT, "العالم Hello");
6032   textField.SetProperty(TextField::Property::POINT_SIZE, 10.f);
6033   textField.SetProperty(Actor::Property::SIZE, Vector2(300.f, 50.f));
6034   textField.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT);
6035   textField.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
6036
6037   // Avoid a crash when core load gl resources.
6038   application.GetGlAbstraction().SetCheckFramebufferStatusResult(GL_FRAMEBUFFER_COMPLETE);
6039
6040   application.SendNotification();
6041   application.Render();
6042
6043   textField.SetKeyInputFocus();
6044
6045   application.SendNotification();
6046   application.Render();
6047
6048   // Create a tap event to touch the text field.
6049   TestGenerateTap(application, 1.0f, 25.0f, 100);
6050
6051   // Render and notify
6052   application.SendNotification();
6053   application.Render();
6054
6055   // Double tap to select a word.
6056   TestGenerateTap(application, 1.0f, 25.0f, 200);
6057
6058   application.SendNotification();
6059   application.Render();
6060
6061   // At this point, the text decorator's primary/secondary cursor, grab/left/right handle and highlight actor were all created.
6062   // Check some properties for coverage.
6063   textField.SetProperty(TextField::Property::PRIMARY_CURSOR_COLOR, Color::RED);
6064   DALI_TEST_EQUALS(textField.GetProperty<Vector4>(TextField::Property::PRIMARY_CURSOR_COLOR), Color::RED, TEST_LOCATION);
6065
6066   textField.SetProperty(TextField::Property::SECONDARY_CURSOR_COLOR, Color::BLUE);
6067   DALI_TEST_EQUALS(textField.GetProperty<Vector4>(TextField::Property::SECONDARY_CURSOR_COLOR), Color::BLUE, TEST_LOCATION);
6068
6069   textField.SetProperty(DevelTextField::Property::GRAB_HANDLE_COLOR, Color::GREEN);
6070   DALI_TEST_EQUALS(textField.GetProperty<Vector4>(DevelTextField::Property::GRAB_HANDLE_COLOR), Color::GREEN, TEST_LOCATION);
6071
6072   textField.SetProperty(TextField::Property::SELECTION_HIGHLIGHT_COLOR, Color::GREEN);
6073   DALI_TEST_EQUALS(textField.GetProperty<Vector4>(TextField::Property::SELECTION_HIGHLIGHT_COLOR), Color::GREEN, TEST_LOCATION);
6074
6075   textField.SetProperty(TextField::Property::CURSOR_WIDTH, 3);
6076   DALI_TEST_EQUALS(textField.GetProperty<int>(TextField::Property::CURSOR_WIDTH), 3, TEST_LOCATION);
6077
6078   application.SendNotification();
6079   application.Render();
6080
6081   END_TEST;
6082 }