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