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