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