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