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