Add bvh loader in scene-loader
[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>(TextLabel::Property::TEXT) == textField.GetProperty<std::string>(TextLabel::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 // Negative test for the textChanged signal.
1792 int utcDaliTextFieldTextChangedN(void)
1793 {
1794   ToolkitTestApplication application;
1795   tet_infoline(" utcDaliTextFieldTextChangedN");
1796   TextField field = TextField::New();
1797   DALI_TEST_CHECK(field);
1798
1799   application.GetScene().Add(field);
1800
1801   // connect to the text changed signal.
1802   ConnectionTracker* testTracker = new ConnectionTracker();
1803   field.TextChangedSignal().Connect(&TestTextChangedCallback);
1804   bool textChangedSignal = false;
1805   field.ConnectSignal(testTracker, "textChanged", CallbackFunctor(&textChangedSignal));
1806
1807   gTextChangedCallBackCalled = false;
1808   field.SetProperty(TextField::Property::PLACEHOLDER_TEXT, "ABC"); // Setting placeholder, not TEXT
1809   application.SendNotification();
1810   application.Render();
1811   DALI_TEST_CHECK(!gTextChangedCallBackCalled);
1812   DALI_TEST_CHECK(!textChangedSignal);
1813
1814   END_TEST;
1815 }
1816
1817 // Positive test for Max Characters reached signal.
1818 int utcDaliTextFieldMaxCharactersReachedP(void)
1819 {
1820   ToolkitTestApplication application;
1821   tet_infoline(" utcDaliTextFieldMaxCharactersReachedP");
1822   TextField field = TextField::New();
1823   DALI_TEST_CHECK(field);
1824
1825   application.GetScene().Add(field);
1826
1827   const int maxNumberOfCharacters = 1;
1828   field.SetProperty(TextField::Property::MAX_LENGTH, maxNumberOfCharacters);
1829
1830   field.SetKeyInputFocus();
1831
1832   // connect to the text changed signal.
1833   ConnectionTracker* testTracker = new ConnectionTracker();
1834   field.MaxLengthReachedSignal().Connect(&TestMaxLengthReachedCallback);
1835   bool maxLengthReachedSignal = false;
1836   field.ConnectSignal(testTracker, "maxLengthReached", CallbackFunctor(&maxLengthReachedSignal));
1837
1838   gMaxCharactersCallBackCalled = false;
1839
1840   application.ProcessEvent(GenerateKey("a", "", "a", KEY_A_CODE, 0, 0, Integration::KeyEvent::DOWN, "a", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
1841   application.ProcessEvent(GenerateKey("a", "", "a", KEY_A_CODE, 0, 0, Integration::KeyEvent::DOWN, "a", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
1842
1843   DALI_TEST_CHECK(gMaxCharactersCallBackCalled);
1844   DALI_TEST_CHECK(maxLengthReachedSignal);
1845
1846   END_TEST;
1847 }
1848
1849 // Negative test for Max Characters reached signal.
1850 int utcDaliTextFieldMaxCharactersReachedN(void)
1851 {
1852   ToolkitTestApplication application;
1853   tet_infoline(" utcDaliTextFieldMaxCharactersReachedN");
1854   TextField field = TextField::New();
1855   DALI_TEST_CHECK(field);
1856
1857   application.GetScene().Add(field);
1858
1859   const int maxNumberOfCharacters = 3;
1860   field.SetProperty(TextField::Property::MAX_LENGTH, maxNumberOfCharacters);
1861
1862   field.SetKeyInputFocus();
1863
1864   // connect to the text changed signal.
1865   ConnectionTracker* testTracker = new ConnectionTracker();
1866   field.MaxLengthReachedSignal().Connect(&TestMaxLengthReachedCallback);
1867   bool maxLengthReachedSignal = false;
1868   field.ConnectSignal(testTracker, "maxLengthReached", CallbackFunctor(&maxLengthReachedSignal));
1869
1870   gMaxCharactersCallBackCalled = false;
1871
1872   application.ProcessEvent(GenerateKey("a", "", "a", KEY_A_CODE, 0, 0, Integration::KeyEvent::DOWN, "a", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
1873   application.ProcessEvent(GenerateKey("a", "", "a", KEY_A_CODE, 0, 0, Integration::KeyEvent::DOWN, "a", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
1874
1875   DALI_TEST_CHECK(!gMaxCharactersCallBackCalled);
1876   DALI_TEST_CHECK(!maxLengthReachedSignal);
1877
1878   application.ProcessEvent(GenerateKey("Return", "", "\r", KEY_RETURN_CODE, 0, 0, Integration::KeyEvent::DOWN, "\r", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
1879
1880   DALI_TEST_CHECK(!gMaxCharactersCallBackCalled);
1881   DALI_TEST_CHECK(!maxLengthReachedSignal);
1882
1883   END_TEST;
1884 }
1885
1886 // Positive test for Input Filtered signal.
1887 int utcDaliTextFieldInputFilteredP(void)
1888 {
1889   ToolkitTestApplication application;
1890   tet_infoline(" utcDaliTextFieldInputFilteredP");
1891   TextField field = TextField::New();
1892   DALI_TEST_CHECK(field);
1893
1894   application.GetScene().Add(field);
1895
1896   Property::Map inputFilter;
1897
1898   // Only digit is accepted.
1899   inputFilter[InputFilter::Property::ACCEPTED] = "[\\d]";
1900
1901   // Set input filter to TextField.
1902   field.SetProperty(DevelTextField::Property::INPUT_FILTER, inputFilter);
1903
1904   field.SetKeyInputFocus();
1905
1906   // connect to the input filtered signal.
1907   ConnectionTracker* testTracker = new ConnectionTracker();
1908   DevelTextField::InputFilteredSignal(field).Connect(&TestInputFilteredCallback);
1909   bool inputFilteredSignal = false;
1910   field.ConnectSignal(testTracker, "inputFiltered", CallbackFunctor(&inputFilteredSignal));
1911
1912   gInputFilteredAcceptedCallbackCalled = false;
1913
1914   application.ProcessEvent(GenerateKey("a", "", "a", KEY_A_CODE, 0, 0, Integration::KeyEvent::DOWN, "a", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
1915
1916   DALI_TEST_CHECK(gInputFilteredAcceptedCallbackCalled);
1917   DALI_TEST_CHECK(inputFilteredSignal);
1918
1919   // Word is rejected.
1920   inputFilter[InputFilter::Property::ACCEPTED] = "";
1921   inputFilter[InputFilter::Property::REJECTED] = "[\\w]";
1922
1923   // Set input filter to TextField.
1924   field.SetProperty(DevelTextField::Property::INPUT_FILTER, inputFilter);
1925
1926   field.SetKeyInputFocus();
1927
1928   inputFilteredSignal                  = false;
1929   gInputFilteredRejectedCallbackCalled = false;
1930
1931   application.ProcessEvent(GenerateKey("a", "", "a", KEY_A_CODE, 0, 0, Integration::KeyEvent::DOWN, "a", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
1932
1933   DALI_TEST_CHECK(gInputFilteredAcceptedCallbackCalled);
1934   DALI_TEST_CHECK(inputFilteredSignal);
1935
1936   END_TEST;
1937 }
1938
1939 // Negative test for Input Filtered signal.
1940 int utcDaliTextFieldInputFilteredN(void)
1941 {
1942   ToolkitTestApplication application;
1943   tet_infoline(" utcDaliTextFieldInputFilteredP");
1944   TextField field = TextField::New();
1945   DALI_TEST_CHECK(field);
1946
1947   application.GetScene().Add(field);
1948
1949   Property::Map inputFilter;
1950
1951   // Only word is accepted.
1952   inputFilter[InputFilter::Property::ACCEPTED] = "[\\w]";
1953
1954   // Set input filter to TextField.
1955   field.SetProperty(DevelTextField::Property::INPUT_FILTER, inputFilter);
1956
1957   field.SetKeyInputFocus();
1958
1959   // connect to the input filtered signal.
1960   ConnectionTracker* testTracker = new ConnectionTracker();
1961   DevelTextField::InputFilteredSignal(field).Connect(&TestInputFilteredCallback);
1962   bool inputFilteredSignal = false;
1963   field.ConnectSignal(testTracker, "inputFiltered", CallbackFunctor(&inputFilteredSignal));
1964
1965   gInputFilteredAcceptedCallbackCalled = false;
1966
1967   // Key a, d should not be filtered.
1968   application.ProcessEvent(GenerateKey("a", "", "a", KEY_A_CODE, 0, 0, Integration::KeyEvent::DOWN, "a", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
1969   application.ProcessEvent(GenerateKey("a", "", "a", KEY_A_CODE, 0, 0, Integration::KeyEvent::UP, "a", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
1970   application.ProcessEvent(GenerateKey("d", "", "d", KEY_D_CODE, 0, 0, Integration::KeyEvent::DOWN, "d", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
1971   application.ProcessEvent(GenerateKey("d", "", "d", KEY_D_CODE, 0, 0, Integration::KeyEvent::UP, "d", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
1972
1973   // Backspace, Delete should not be filtered.
1974   application.ProcessEvent(GenerateKey("", "", "", DALI_KEY_BACKSPACE, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
1975   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));
1976
1977   // Render and notify
1978   application.SendNotification();
1979   application.Render();
1980
1981   DALI_TEST_CHECK(!gInputFilteredAcceptedCallbackCalled);
1982   DALI_TEST_CHECK(!inputFilteredSignal);
1983
1984   // Digit is rejected.
1985   inputFilter[InputFilter::Property::ACCEPTED] = "";
1986   inputFilter[InputFilter::Property::REJECTED] = "[\\d]";
1987
1988   field.SetProperty(DevelTextField::Property::INPUT_FILTER, inputFilter);
1989
1990   field.SetKeyInputFocus();
1991
1992   inputFilteredSignal                  = false;
1993   gInputFilteredRejectedCallbackCalled = false;
1994
1995   // Key a, d should not be filtered.
1996   application.ProcessEvent(GenerateKey("a", "", "a", KEY_A_CODE, 0, 0, Integration::KeyEvent::DOWN, "a", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
1997   application.ProcessEvent(GenerateKey("a", "", "a", KEY_A_CODE, 0, 0, Integration::KeyEvent::UP, "a", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
1998   application.ProcessEvent(GenerateKey("d", "", "d", KEY_D_CODE, 0, 0, Integration::KeyEvent::DOWN, "d", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
1999   application.ProcessEvent(GenerateKey("d", "", "d", KEY_D_CODE, 0, 0, Integration::KeyEvent::UP, "d", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
2000
2001   // Backspace, Delete should not be filtered.
2002   application.ProcessEvent(GenerateKey("", "", "", DALI_KEY_BACKSPACE, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
2003   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));
2004
2005   // Render and notify
2006   application.SendNotification();
2007   application.Render();
2008
2009   DALI_TEST_CHECK(!gInputFilteredAcceptedCallbackCalled);
2010   DALI_TEST_CHECK(!inputFilteredSignal);
2011
2012   END_TEST;
2013 }
2014
2015 int utcDaliTextFieldInputStyleChanged01(void)
2016 {
2017   // The text-field emits signals when the input style changes. These changes of style are
2018   // detected during the relayout process (size negotiation), i.e after the cursor has been moved. Signals
2019   // can't be emitted during the size negotiation as the callbacks may update the UI.
2020   // The text-field adds an idle callback to the adaptor to emit the signals after the size negotiation.
2021   // The ToolkitTestApplication creates an implementation of the adaptor stub and a queue of idle callbacks.
2022   ToolkitTestApplication application;
2023   tet_infoline(" utcDaliTextFieldInputStyleChanged01");
2024
2025   // Load some fonts.
2026
2027   char*             pathNamePtr = get_current_dir_name();
2028   const std::string pathName(pathNamePtr);
2029   free(pathNamePtr);
2030
2031   TextAbstraction::FontClient fontClient = TextAbstraction::FontClient::Get();
2032   fontClient.SetDpi(93u, 93u);
2033
2034   fontClient.GetFontId(pathName + DEFAULT_FONT_DIR + "/dejavu/DejaVuSerif.ttf", DEFAULT_FONT_SIZE);
2035   fontClient.GetFontId(pathName + DEFAULT_FONT_DIR + "/dejavu/DejaVuSerif-Bold.ttf", DEFAULT_FONT_SIZE);
2036
2037   TextField field = TextField::New();
2038   DALI_TEST_CHECK(field);
2039
2040   field.SetProperty(Actor::Property::SIZE, Vector2(300.f, 50.f));
2041   field.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT);
2042   field.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
2043
2044   field.SetProperty(TextField::Property::ENABLE_MARKUP, true);
2045   field.SetProperty(TextField::Property::TEXT, "<font family='DejaVuSerif' size='18'>He<color value='green'>llo</color> <font weight='bold'>world</font> demo</font>");
2046
2047   // connect to the text changed signal.
2048   ConnectionTracker* testTracker = new ConnectionTracker();
2049   field.InputStyleChangedSignal().Connect(&TestInputStyleChangedCallback);
2050   bool inputStyleChangedSignal = false;
2051   field.ConnectSignal(testTracker, "inputStyleChanged", CallbackFunctor(&inputStyleChangedSignal));
2052
2053   application.GetScene().Add(field);
2054
2055   // Render and notify
2056   application.SendNotification();
2057   application.Render();
2058
2059   // Executes the idle callbacks added by the text control on the change of input style.
2060   application.RunIdles();
2061
2062   gInputStyleChangedCallbackCalled = false;
2063   gInputStyleMask                  = TextField::InputStyle::NONE;
2064   inputStyleChangedSignal          = false;
2065
2066   // Create a tap event to touch the text field.
2067   TestGenerateTap(application, 18.0f, 25.0f);
2068
2069   // Render and notify
2070   application.SendNotification();
2071   application.Render();
2072
2073   // Executes the idle callbacks added by the text control on the change of input style.
2074   application.RunIdles();
2075
2076   DALI_TEST_CHECK(gInputStyleChangedCallbackCalled);
2077   if(gInputStyleChangedCallbackCalled)
2078   {
2079     DALI_TEST_EQUALS(static_cast<unsigned int>(gInputStyleMask), static_cast<unsigned int>(TextField::InputStyle::FONT_FAMILY | TextField::InputStyle::POINT_SIZE), TEST_LOCATION);
2080
2081     const std::string fontFamily = field.GetProperty(TextField::Property::INPUT_FONT_FAMILY).Get<std::string>();
2082     DALI_TEST_EQUALS(fontFamily, "DejaVuSerif", TEST_LOCATION);
2083
2084     const float pointSize = field.GetProperty(TextField::Property::INPUT_POINT_SIZE).Get<float>();
2085     DALI_TEST_EQUALS(pointSize, 18.f, Math::MACHINE_EPSILON_1000, TEST_LOCATION);
2086   }
2087   DALI_TEST_CHECK(inputStyleChangedSignal);
2088
2089   gInputStyleChangedCallbackCalled = false;
2090   gInputStyleMask                  = TextField::InputStyle::NONE;
2091   inputStyleChangedSignal          = false;
2092
2093   // Create a tap event to touch the text field.
2094   TestGenerateTap(application, 30.0f, 25.0f);
2095
2096   // Render and notify
2097   application.SendNotification();
2098   application.Render();
2099
2100   // Executes the idle callbacks added by the text control on the change of input style.
2101   application.RunIdles();
2102
2103   DALI_TEST_CHECK(!gInputStyleChangedCallbackCalled);
2104   DALI_TEST_CHECK(!inputStyleChangedSignal);
2105
2106   gInputStyleChangedCallbackCalled = false;
2107   gInputStyleMask                  = TextField::InputStyle::NONE;
2108   inputStyleChangedSignal          = false;
2109
2110   // Create a tap event to touch the text field.
2111   TestGenerateTap(application, 43.0f, 25.0f);
2112
2113   // Render and notify
2114   application.SendNotification();
2115   application.Render();
2116
2117   // Executes the idle callbacks added by the text control on the change of input style.
2118   application.RunIdles();
2119
2120   DALI_TEST_CHECK(gInputStyleChangedCallbackCalled);
2121   if(gInputStyleChangedCallbackCalled)
2122   {
2123     DALI_TEST_EQUALS(static_cast<unsigned int>(gInputStyleMask), static_cast<unsigned int>(TextField::InputStyle::COLOR), TEST_LOCATION);
2124
2125     const Vector4 color = field.GetProperty(TextField::Property::INPUT_COLOR).Get<Vector4>();
2126     DALI_TEST_EQUALS(color, Color::GREEN, TEST_LOCATION);
2127   }
2128   DALI_TEST_CHECK(inputStyleChangedSignal);
2129
2130   gInputStyleChangedCallbackCalled = false;
2131   gInputStyleMask                  = TextField::InputStyle::NONE;
2132   inputStyleChangedSignal          = false;
2133
2134   // Create a tap event to touch the text field.
2135   TestGenerateTap(application, 88.0f, 25.0f);
2136
2137   // Render and notify
2138   application.SendNotification();
2139   application.Render();
2140
2141   // Executes the idle callbacks added by the text control on the change of input style.
2142   application.RunIdles();
2143
2144   DALI_TEST_CHECK(gInputStyleChangedCallbackCalled);
2145   if(gInputStyleChangedCallbackCalled)
2146   {
2147     DALI_TEST_EQUALS(static_cast<unsigned int>(gInputStyleMask), static_cast<unsigned int>(TextField::InputStyle::COLOR | TextField::InputStyle::FONT_STYLE), TEST_LOCATION);
2148
2149     const Vector4 color = field.GetProperty(TextField::Property::INPUT_COLOR).Get<Vector4>();
2150     DALI_TEST_EQUALS(color, Color::BLACK, TEST_LOCATION);
2151
2152     const Property::Map fontStyleMapGet = field.GetProperty(TextField::Property::INPUT_FONT_STYLE).Get<Property::Map>();
2153
2154     Property::Map fontStyleMapSet;
2155     fontStyleMapSet.Insert("weight", "bold");
2156
2157     DALI_TEST_EQUALS(fontStyleMapGet.Count(), fontStyleMapSet.Count(), TEST_LOCATION);
2158     DALI_TEST_EQUALS(DaliTestCheckMaps(fontStyleMapGet, fontStyleMapSet), true, TEST_LOCATION);
2159   }
2160   DALI_TEST_CHECK(inputStyleChangedSignal);
2161
2162   gInputStyleChangedCallbackCalled = false;
2163   gInputStyleMask                  = TextField::InputStyle::NONE;
2164   inputStyleChangedSignal          = false;
2165
2166   // Create a tap event to touch the text field.
2167   TestGenerateTap(application, 115.0f, 25.0f);
2168
2169   // Render and notify
2170   application.SendNotification();
2171   application.Render();
2172
2173   // Executes the idle callbacks added by the text control on the change of input style.
2174   application.RunIdles();
2175
2176   DALI_TEST_CHECK(!gInputStyleChangedCallbackCalled);
2177   DALI_TEST_CHECK(!inputStyleChangedSignal);
2178
2179   gInputStyleChangedCallbackCalled = false;
2180   gInputStyleMask                  = TextField::InputStyle::NONE;
2181   inputStyleChangedSignal          = false;
2182
2183   // Create a tap event to touch the text field.
2184   TestGenerateTap(application, 164.0f, 25.0f);
2185
2186   // Render and notify
2187   application.SendNotification();
2188   application.Render();
2189
2190   // Executes the idle callbacks added by the text control on the change of input style.
2191   application.RunIdles();
2192
2193   DALI_TEST_CHECK(gInputStyleChangedCallbackCalled);
2194   if(gInputStyleChangedCallbackCalled)
2195   {
2196     DALI_TEST_EQUALS(static_cast<unsigned int>(gInputStyleMask), static_cast<unsigned int>(TextField::InputStyle::FONT_STYLE), TEST_LOCATION);
2197
2198     const std::string style = field.GetProperty(TextField::Property::INPUT_FONT_STYLE).Get<std::string>();
2199     DALI_TEST_CHECK(style.empty());
2200   }
2201   DALI_TEST_CHECK(inputStyleChangedSignal);
2202
2203   gInputStyleChangedCallbackCalled = false;
2204   gInputStyleMask                  = TextField::InputStyle::NONE;
2205   inputStyleChangedSignal          = false;
2206
2207   // Create a tap event to touch the text field.
2208   TestGenerateTap(application, 191.0f, 25.0f);
2209
2210   // Render and notify
2211   application.SendNotification();
2212   application.Render();
2213
2214   // Executes the idle callbacks added by the text control on the change of input style.
2215   application.RunIdles();
2216
2217   DALI_TEST_CHECK(!gInputStyleChangedCallbackCalled);
2218   DALI_TEST_CHECK(!inputStyleChangedSignal);
2219
2220   END_TEST;
2221 }
2222
2223 int utcDaliTextFieldInputStyleChanged02(void)
2224 {
2225   // The text-field emits signals when the input style changes. These changes of style are
2226   // detected during the relayout process (size negotiation), i.e after the cursor has been moved. Signals
2227   // can't be emitted during the size negotiation as the callbacks may update the UI.
2228   // The text-field adds an idle callback to the adaptor to emit the signals after the size negotiation.
2229   // The ToolkitTestApplication creates an implementation of the adaptor stub and a queue of idle callbacks.
2230   ToolkitTestApplication application;
2231   tet_infoline(" utcDaliTextFieldInputStyleChanged02");
2232
2233   // Load some fonts.
2234
2235   char*             pathNamePtr = get_current_dir_name();
2236   const std::string pathName(pathNamePtr);
2237   free(pathNamePtr);
2238
2239   TextAbstraction::FontClient fontClient = TextAbstraction::FontClient::Get();
2240   fontClient.SetDpi(93u, 93u);
2241
2242   fontClient.GetFontId(pathName + DEFAULT_FONT_DIR + "/dejavu/DejaVuSerif.ttf", DEFAULT_FONT_SIZE);
2243   fontClient.GetFontId(pathName + DEFAULT_FONT_DIR + "/dejavu/DejaVuSerif-Bold.ttf", DEFAULT_FONT_SIZE);
2244
2245   TextField field = TextField::New();
2246   DALI_TEST_CHECK(field);
2247
2248   field.SetProperty(Actor::Property::SIZE, Vector2(300.f, 50.f));
2249   field.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT);
2250   field.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
2251
2252   field.SetProperty(TextField::Property::ENABLE_MARKUP, true);
2253   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>");
2254
2255   // connect to the text changed signal.
2256   ConnectionTracker* testTracker = new ConnectionTracker();
2257   field.InputStyleChangedSignal().Connect(&TestInputStyleChangedCallback);
2258   bool inputStyleChangedSignal = false;
2259   field.ConnectSignal(testTracker, "inputStyleChanged", CallbackFunctor(&inputStyleChangedSignal));
2260
2261   application.GetScene().Add(field);
2262
2263   // Render and notify
2264   application.SendNotification();
2265   application.Render();
2266
2267   // Executes the idle callbacks added by the text control on the change of input style.
2268   application.RunIdles();
2269
2270   gInputStyleChangedCallbackCalled = false;
2271   gInputStyleMask                  = TextField::InputStyle::NONE;
2272   inputStyleChangedSignal          = false;
2273
2274   // Create a tap event to touch the text field.
2275   TestGenerateTap(application, 53.0f, 25.0f, 100);
2276   TestGenerateTap(application, 53.0f, 25.0f, 200);
2277
2278   // Render and notify
2279   application.SendNotification();
2280   application.Render();
2281
2282   // Executes the idle callbacks added by the text control on the change of input style.
2283   application.RunIdles();
2284
2285   DALI_TEST_CHECK(gInputStyleChangedCallbackCalled);
2286   if(gInputStyleChangedCallbackCalled)
2287   {
2288     DALI_TEST_EQUALS(static_cast<unsigned int>(gInputStyleMask),
2289                      static_cast<unsigned int>(TextField::InputStyle::FONT_FAMILY |
2290                                                TextField::InputStyle::POINT_SIZE |
2291                                                TextField::InputStyle::COLOR),
2292                      TEST_LOCATION);
2293
2294     const Vector4 color = field.GetProperty(TextField::Property::INPUT_COLOR).Get<Vector4>();
2295     DALI_TEST_EQUALS(color, Color::GREEN, TEST_LOCATION);
2296
2297     const std::string fontFamily = field.GetProperty(TextField::Property::INPUT_FONT_FAMILY).Get<std::string>();
2298     DALI_TEST_EQUALS(fontFamily, "DejaVuSerif", TEST_LOCATION);
2299
2300     const float pointSize = field.GetProperty(TextField::Property::INPUT_POINT_SIZE).Get<float>();
2301     DALI_TEST_EQUALS(pointSize, 18.f, Math::MACHINE_EPSILON_1000, TEST_LOCATION);
2302   }
2303   DALI_TEST_CHECK(inputStyleChangedSignal);
2304
2305   gInputStyleChangedCallbackCalled = false;
2306   gInputStyleMask                  = TextField::InputStyle::NONE;
2307   inputStyleChangedSignal          = false;
2308
2309   application.ProcessEvent(GenerateKey("", "", "", DALI_KEY_BACKSPACE, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
2310
2311   // Render and notify
2312   application.SendNotification();
2313   application.Render();
2314
2315   // Executes the idle callbacks added by the text control on the change of input style.
2316   application.RunIdles();
2317
2318   DALI_TEST_CHECK(gInputStyleChangedCallbackCalled);
2319   if(gInputStyleChangedCallbackCalled)
2320   {
2321     DALI_TEST_EQUALS(static_cast<unsigned int>(gInputStyleMask),
2322                      static_cast<unsigned int>(TextField::InputStyle::COLOR),
2323                      TEST_LOCATION);
2324
2325     const Vector4 color = field.GetProperty(TextField::Property::INPUT_COLOR).Get<Vector4>();
2326     DALI_TEST_EQUALS(color, Color::BLUE, TEST_LOCATION);
2327   }
2328   DALI_TEST_CHECK(inputStyleChangedSignal);
2329
2330   gInputStyleChangedCallbackCalled = false;
2331   gInputStyleMask                  = TextField::InputStyle::NONE;
2332   inputStyleChangedSignal          = false;
2333
2334   application.ProcessEvent(GenerateKey("", "", "", DALI_KEY_BACKSPACE, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
2335
2336   // Render and notify
2337   application.SendNotification();
2338   application.Render();
2339
2340   // Executes the idle callbacks added by the text control on the change of input style.
2341   application.RunIdles();
2342
2343   DALI_TEST_CHECK(!gInputStyleChangedCallbackCalled);
2344   DALI_TEST_CHECK(!inputStyleChangedSignal);
2345
2346   gInputStyleChangedCallbackCalled = false;
2347   gInputStyleMask                  = TextField::InputStyle::NONE;
2348   inputStyleChangedSignal          = false;
2349
2350   application.ProcessEvent(GenerateKey("", "", "", DALI_KEY_BACKSPACE, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
2351
2352   // Render and notify
2353   application.SendNotification();
2354   application.Render();
2355
2356   // Executes the idle callbacks added by the text control on the change of input style.
2357   application.RunIdles();
2358
2359   DALI_TEST_CHECK(gInputStyleChangedCallbackCalled);
2360   if(gInputStyleChangedCallbackCalled)
2361   {
2362     DALI_TEST_EQUALS(static_cast<unsigned int>(gInputStyleMask),
2363                      static_cast<unsigned int>(TextField::InputStyle::COLOR),
2364                      TEST_LOCATION);
2365
2366     const Vector4 color = field.GetProperty(TextField::Property::INPUT_COLOR).Get<Vector4>();
2367     DALI_TEST_EQUALS(color, Color::BLACK, TEST_LOCATION);
2368   }
2369   DALI_TEST_CHECK(inputStyleChangedSignal);
2370
2371   gInputStyleChangedCallbackCalled = false;
2372   gInputStyleMask                  = TextField::InputStyle::NONE;
2373   inputStyleChangedSignal          = false;
2374
2375   field.SetProperty(TextField::Property::INPUT_COLOR, Color::YELLOW);
2376
2377   Property::Map fontStyleMapSet;
2378   fontStyleMapSet.Insert("weight", "thin");
2379   fontStyleMapSet.Insert("width", "condensed");
2380   fontStyleMapSet.Insert("slant", "italic");
2381
2382   field.SetProperty(TextField::Property::INPUT_FONT_STYLE, fontStyleMapSet);
2383   field.SetProperty(TextField::Property::INPUT_POINT_SIZE, 20.f);
2384
2385   field.SetProperty(TextField::Property::INPUT_UNDERLINE, "underline");
2386   field.SetProperty(TextField::Property::INPUT_SHADOW, "shadow");
2387   field.SetProperty(TextField::Property::INPUT_EMBOSS, "emboss");
2388   field.SetProperty(TextField::Property::INPUT_OUTLINE, "outline");
2389   field.SetProperty(DevelTextField::Property::INPUT_STRIKETHROUGH, "strikethrough");
2390
2391   // Render and notify
2392   application.SendNotification();
2393   application.Render();
2394
2395   // Executes the idle callbacks added by the text control on the change of input style.
2396   application.RunIdles();
2397
2398   DALI_TEST_CHECK(!gInputStyleChangedCallbackCalled);
2399   DALI_TEST_CHECK(!inputStyleChangedSignal);
2400
2401   // Create a tap event to touch the text field.
2402   TestGenerateTap(application, 63.0f, 25.0f, 700);
2403
2404   // Render and notify
2405   application.SendNotification();
2406   application.Render();
2407
2408   // Executes the idle callbacks added by the text control on the change of input style.
2409   application.RunIdles();
2410
2411   DALI_TEST_CHECK(gInputStyleChangedCallbackCalled);
2412   if(gInputStyleChangedCallbackCalled)
2413   {
2414     DALI_TEST_EQUALS(static_cast<unsigned int>(gInputStyleMask),
2415                      static_cast<unsigned int>(TextField::InputStyle::COLOR |
2416                                                TextField::InputStyle::POINT_SIZE |
2417                                                TextField::InputStyle::FONT_STYLE |
2418                                                TextField::InputStyle::UNDERLINE |
2419                                                TextField::InputStyle::SHADOW |
2420                                                TextField::InputStyle::EMBOSS |
2421                                                TextField::InputStyle::OUTLINE),
2422                      TEST_LOCATION);
2423
2424     const Vector4 color = field.GetProperty(TextField::Property::INPUT_COLOR).Get<Vector4>();
2425     DALI_TEST_EQUALS(color, Color::BLACK, TEST_LOCATION);
2426   }
2427   DALI_TEST_CHECK(inputStyleChangedSignal);
2428
2429   END_TEST;
2430 }
2431
2432 int utcDaliTextFieldEvent01(void)
2433 {
2434   ToolkitTestApplication application;
2435   tet_infoline(" utcDaliTextFieldEvent01");
2436
2437   // Creates a tap event. After creating a tap event the text field should
2438   // have the focus and add text with key events should be possible.
2439
2440   TextField field = TextField::New();
2441   DALI_TEST_CHECK(field);
2442
2443   application.GetScene().Add(field);
2444
2445   field.SetProperty(Actor::Property::SIZE, Vector2(300.f, 50.f));
2446   field.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT);
2447   field.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
2448
2449   // Render and notify
2450   application.SendNotification();
2451   application.Render();
2452
2453   // Avoid a crash when core load gl resources.
2454   application.GetGlAbstraction().SetCheckFramebufferStatusResult(GL_FRAMEBUFFER_COMPLETE);
2455
2456   // Render and notify
2457   application.SendNotification();
2458   application.Render();
2459
2460   // Add a key event but as the text field has not the focus it should do nothing.
2461   application.ProcessEvent(GenerateKey("a", "", "a", KEY_A_CODE, 0, 0, Integration::KeyEvent::DOWN, "a", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
2462
2463   // Render and notify
2464   application.SendNotification();
2465   application.Render();
2466
2467   DALI_TEST_EQUALS(field.GetProperty<std::string>(TextField::Property::TEXT), std::string(""), TEST_LOCATION);
2468
2469   // Create a tap event to touch the text field.
2470   TestGenerateTap(application, 150.0f, 25.0f);
2471
2472   // Render and notify
2473   application.SendNotification();
2474   application.Render();
2475
2476   // Pressing delete key should be fine even if there is no text in TextField.
2477   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));
2478   // Render and notify
2479   application.SendNotification();
2480   application.Render();
2481
2482   // Now the text field has the focus, so it can handle the key events.
2483   application.ProcessEvent(GenerateKey("a", "", "a", KEY_A_CODE, 0, 0, Integration::KeyEvent::DOWN, "a", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
2484   application.ProcessEvent(GenerateKey("a", "", "a", KEY_A_CODE, 0, 0, Integration::KeyEvent::DOWN, "a", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
2485
2486   // Render and notify
2487   application.SendNotification();
2488   application.Render();
2489
2490   DALI_TEST_EQUALS(field.GetProperty<std::string>(TextField::Property::TEXT), std::string("aa"), TEST_LOCATION);
2491
2492   // Create a second text field and send key events to it.
2493   TextField field2 = TextField::New();
2494
2495   field2.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT);
2496   field2.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
2497   field2.SetProperty(Actor::Property::SIZE, Vector2(100.f, 100.f));
2498   field2.SetProperty(Actor::Property::POSITION, Vector2(100.0f, 100.0f));
2499
2500   application.GetScene().Add(field2);
2501
2502   // Render and notify
2503   application.SendNotification();
2504   application.Render();
2505
2506   // Create a tap event on the second text field.
2507   TestGenerateTap(application, 150.0f, 125.0f);
2508
2509   // Render and notify
2510   application.SendNotification();
2511   application.Render();
2512
2513   // The second text field has the focus. It should handle the key events.
2514   application.ProcessEvent(GenerateKey("a", "", "a", KEY_A_CODE, 0, 0, Integration::KeyEvent::DOWN, "a", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
2515   application.ProcessEvent(GenerateKey("a", "", "a", KEY_A_CODE, 0, 0, Integration::KeyEvent::DOWN, "a", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
2516
2517   // Render and notify
2518   application.SendNotification();
2519   application.Render();
2520
2521   // Check the text has been added to the second text field.
2522   DALI_TEST_EQUALS(field2.GetProperty<std::string>(TextField::Property::TEXT), std::string("aa"), TEST_LOCATION);
2523
2524   END_TEST;
2525 }
2526
2527 int utcDaliTextFieldEvent02(void)
2528 {
2529   ToolkitTestApplication application;
2530   tet_infoline(" utcDaliTextFieldEvent02");
2531
2532   // Checks if the right number of actors are created.
2533
2534   TextField field = TextField::New();
2535   field.SetProperty(TextField::Property::POINT_SIZE, 10.f);
2536   DALI_TEST_CHECK(field);
2537   LoadMarkerImages(application, field);
2538
2539   application.GetScene().Add(field);
2540
2541   field.SetProperty(Actor::Property::SIZE, Vector2(300.f, 50.f));
2542   field.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT);
2543   field.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
2544
2545   // Avoid a crash when core load gl resources.
2546   application.GetGlAbstraction().SetCheckFramebufferStatusResult(GL_FRAMEBUFFER_COMPLETE);
2547
2548   // Render and notify
2549   application.SendNotification();
2550   application.Render();
2551
2552   // Check there are the expected number of children ( stencil ).
2553   DALI_TEST_EQUALS(field.GetChildCount(), 1u, TEST_LOCATION);
2554
2555   Actor stencil = field.GetChildAt(0u);
2556   DALI_TEST_EQUALS(stencil.GetChildCount(), 0u, TEST_LOCATION);
2557
2558   // Create a tap event to touch the text field.
2559   TestGenerateTap(application, 150.0f, 25.0f, 300);
2560
2561   // Render and notify
2562   application.SendNotification();
2563   application.Render();
2564
2565   Actor layer = field.GetChildAt(2u);
2566   DALI_TEST_EQUALS(layer.GetChildCount(), 1u, TEST_LOCATION); // The cursor.
2567   DALI_TEST_EQUALS(stencil.GetChildCount(), 0u, TEST_LOCATION);
2568
2569   // Now the text field has the focus, so it can handle the key events.
2570   application.ProcessEvent(GenerateKey("a", "", "a", KEY_A_CODE, 0, 0, Integration::KeyEvent::DOWN, "a", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
2571   application.ProcessEvent(GenerateKey("a", "", "a", KEY_A_CODE, 0, 0, Integration::KeyEvent::DOWN, "a", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
2572
2573   // Render and notify
2574   application.SendNotification();
2575   application.Render();
2576
2577   // Checks the cursor and the renderer have been created.
2578   DALI_TEST_EQUALS(layer.GetChildCount(), 1u, TEST_LOCATION);   // The cursor.
2579   DALI_TEST_EQUALS(stencil.GetChildCount(), 2u, TEST_LOCATION); // The renderer, clipped cursor
2580
2581   Control cursor = Control::DownCast(layer.GetChildAt(0u));
2582   DALI_TEST_CHECK(cursor);
2583
2584   // The offscreen root actor has a container with all the actors which contain the text renderers.
2585   Actor container = stencil.GetChildAt(0u);
2586   for(unsigned int index = 0; index < container.GetChildCount(); ++index)
2587   {
2588     Renderer renderer = container.GetChildAt(index).GetRendererAt(0u);
2589     DALI_TEST_CHECK(renderer);
2590   }
2591
2592   // Move the cursor and check the position changes.
2593   Vector3 position1 = cursor.GetCurrentProperty<Vector3>(Actor::Property::POSITION);
2594   application.ProcessEvent(GenerateKey("", "", "", DALI_KEY_CURSOR_LEFT, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
2595
2596   // Render and notify
2597   application.SendNotification();
2598   application.Render();
2599
2600   Vector3 position2 = cursor.GetCurrentProperty<Vector3>(Actor::Property::POSITION);
2601   DALI_TEST_CHECK(position2.x < position1.x);
2602
2603   application.ProcessEvent(GenerateKey("", "", "", DALI_KEY_CURSOR_RIGHT, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
2604
2605   // Render and notify
2606   application.SendNotification();
2607   application.Render();
2608
2609   Vector3 position3 = cursor.GetCurrentProperty<Vector3>(Actor::Property::POSITION);
2610   DALI_TEST_EQUALS(position1, position3, TEST_LOCATION); // Should be in the same position1.
2611
2612   // Move the cursor to the first position.
2613   application.ProcessEvent(GenerateKey("", "", "", DALI_KEY_CURSOR_LEFT, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
2614   application.ProcessEvent(GenerateKey("", "", "", DALI_KEY_CURSOR_LEFT, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
2615
2616   // Render and notify
2617   application.SendNotification();
2618   application.Render();
2619
2620   Vector3 position4 = cursor.GetCurrentProperty<Vector3>(Actor::Property::POSITION);
2621
2622   // Send some taps and check the cursor positions.
2623
2624   // Try to tap at the beginning.
2625   TestGenerateTap(application, 1.0f, 25.0f, 900);
2626
2627   // Render and notify
2628   application.SendNotification();
2629   application.Render();
2630
2631   // Cursor position should be the same than position1.
2632   Vector3 position5 = cursor.GetCurrentProperty<Vector3>(Actor::Property::POSITION);
2633
2634   DALI_TEST_EQUALS(position4, position5, TEST_LOCATION); // Should be in the same position2.
2635
2636   // Tap away from the start position.
2637   TestGenerateTap(application, 16.0f, 25.0f, 1500);
2638
2639   // Render and notify
2640   application.SendNotification();
2641   application.Render();
2642
2643   Vector3 position6 = cursor.GetCurrentProperty<Vector3>(Actor::Property::POSITION);
2644
2645   DALI_TEST_CHECK(position6.x > position5.x);
2646
2647   // Remove all the text.
2648   application.ProcessEvent(GenerateKey("", "", "", DALI_KEY_BACKSPACE, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
2649   application.ProcessEvent(GenerateKey("", "", "", DALI_KEY_BACKSPACE, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
2650   field.SetProperty(TextField::Property::TEXT, "");
2651
2652   // Render and notify
2653   application.SendNotification();
2654   application.Render();
2655
2656   // Cursor position should be the same than position2.
2657   Vector3 position7 = cursor.GetCurrentProperty<Vector3>(Actor::Property::POSITION);
2658
2659   DALI_TEST_EQUALS(position4, position7, TEST_LOCATION); // Should be in the same position2.
2660
2661   // Should not be a renderer, there is only a clipped cursor.
2662   DALI_TEST_EQUALS(stencil.GetChildCount(), 1u, TEST_LOCATION);
2663
2664   // Chanege exceed policy (EXCEED_POLICY_ORIGINAL doesn't use stencil )
2665   field.SetProperty(TextField::Property::TEXT, "This is a long text for the size of the text-field.");
2666   field.SetProperty(TextField::Property::EXCEED_POLICY, Dali::Toolkit::TextField::EXCEED_POLICY_ORIGINAL);
2667
2668   application.SendNotification();
2669   application.Render();
2670
2671   // There are renderer and decorator layer
2672   DALI_TEST_EQUALS(field.GetChildCount(), 2u, TEST_LOCATION);
2673
2674   END_TEST;
2675 }
2676
2677 int utcDaliTextFieldEvent03(void)
2678 {
2679   ToolkitTestApplication application;
2680   tet_infoline(" utcDaliTextFieldEvent03");
2681
2682   // Checks if the highlight actor is created.
2683
2684   TextField field = TextField::New();
2685   DALI_TEST_CHECK(field);
2686
2687   application.GetScene().Add(field);
2688
2689   field.SetProperty(TextField::Property::TEXT, "This is a long text for the size of the text-field.");
2690   field.SetProperty(TextField::Property::POINT_SIZE, 10.f);
2691   field.SetProperty(Actor::Property::SIZE, Vector2(30.f, 50.f));
2692   field.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT);
2693   field.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
2694
2695   // Avoid a crash when core load gl resources.
2696   application.GetGlAbstraction().SetCheckFramebufferStatusResult(GL_FRAMEBUFFER_COMPLETE);
2697   LoadMarkerImages(application, field);
2698
2699   // Render and notify
2700   application.SendNotification();
2701   application.Render();
2702
2703   // Tap first to get the focus.
2704   TestGenerateTap(application, 3.0f, 25.0f);
2705
2706   // Render and notify
2707   application.SendNotification();
2708   application.Render();
2709
2710   // Double tap to select a word.
2711   TestGenerateTap(application, 3.0f, 25.0f);
2712
2713   // Render and notify
2714   application.SendNotification();
2715   application.Render();
2716
2717   // The offscreen root actor should have two actors: the renderer and the highlight actor.
2718   Actor stencil = field.GetChildAt(0u);
2719
2720   // The highlight actor is drawn first, so is the first actor in the list
2721   Renderer highlight = stencil.GetChildAt(0u).GetRendererAt(0u);
2722   DALI_TEST_CHECK(highlight);
2723
2724   // The offscreen root actor has a container with all the actors which contain the text renderers.
2725   Actor container = stencil.GetChildAt(1u);
2726   for(unsigned int index = 0; index < container.GetChildCount(); ++index)
2727   {
2728     Renderer renderer = container.GetChildAt(index).GetRendererAt(0u);
2729     DALI_TEST_CHECK(renderer);
2730   }
2731
2732   END_TEST;
2733 }
2734
2735 int utcDaliTextFieldEvent04(void)
2736 {
2737   ToolkitTestApplication application;
2738   tet_infoline(" utcDaliTextFieldEvent04");
2739
2740   // Checks if the highlight actor is created.
2741
2742   TextField field = TextField::New();
2743   DALI_TEST_CHECK(field);
2744   application.GetScene().Add(field);
2745   LoadMarkerImages(application, field);
2746   // Render and notify
2747   application.SendNotification();
2748   application.Render();
2749
2750   field.SetProperty(TextField::Property::TEXT, "This is a long text for the size of the text-field.");
2751   field.SetProperty(TextField::Property::POINT_SIZE, 10.f);
2752   field.SetProperty(Actor::Property::SIZE, Vector2(300.f, 50.f));
2753   field.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT);
2754   field.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
2755
2756   // Avoid a crash when core load gl resources.
2757   application.GetGlAbstraction().SetCheckFramebufferStatusResult(GL_FRAMEBUFFER_COMPLETE);
2758   // Render and notify
2759   application.SendNotification();
2760   application.Render();
2761
2762   // Create a tap event to touch the text field.
2763   TestGenerateTap(application, 150.0f, 25.0f);
2764   // Render and notify
2765   application.SendNotification();
2766   application.Render();
2767
2768   // Tap first to get the focus.
2769   TestGenerateTap(application, 1.0f, 25.0f);
2770
2771   // Render and notify
2772   application.SendNotification();
2773   application.Render();
2774
2775   // Double tap to select a word.
2776   TestGenerateTap(application, 1.0f, 25.0f);
2777
2778   // Render and notify
2779   application.SendNotification();
2780   application.Render();
2781
2782   // Tap grab handle
2783   TestGenerateTap(application, 0.0f, 40.0f);
2784   END_TEST;
2785 }
2786
2787 int utcDaliTextFieldEvent05(void)
2788 {
2789   ToolkitTestApplication application;
2790   tet_infoline(" utcDaliTextFieldEvent05");
2791
2792   // Checks dragging of cursor/grab handle
2793
2794   TextField field = TextField::New();
2795   DALI_TEST_CHECK(field);
2796   application.GetScene().Add(field);
2797   LoadMarkerImages(application, field);
2798   // Render and notify
2799   application.SendNotification();
2800   application.Render();
2801
2802   field.SetProperty(TextField::Property::TEXT, "This is a long text for the size of the text-field.");
2803   field.SetProperty(TextField::Property::POINT_SIZE, 10.f);
2804   field.SetProperty(Actor::Property::SIZE, Vector2(300.f, 50.f));
2805   field.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT);
2806   field.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
2807
2808   // Avoid a crash when core load gl resources.
2809   application.GetGlAbstraction().SetCheckFramebufferStatusResult(GL_FRAMEBUFFER_COMPLETE);
2810   // Render and notify
2811   application.SendNotification();
2812   application.Render();
2813
2814   // Create a tap event to touch the text field.
2815   TestGenerateTap(application, 150.0f, 25.0f);
2816   // Render and notify
2817   application.SendNotification();
2818   application.Render();
2819
2820   // Tap first to get the focus.
2821   TestGenerateTap(application, 1.0f, 25.0f);
2822
2823   // Render and notify
2824   application.SendNotification();
2825   application.Render();
2826
2827   // Double tap to select a word.
2828   TestGenerateTap(application, 1.0f, 25.0f);
2829
2830   // Render and notify
2831   application.SendNotification();
2832   application.Render();
2833
2834   Actor stencil = field.GetChildAt(1u);
2835   END_TEST;
2836 }
2837
2838 int utcDaliTextFieldEvent06(void)
2839 {
2840   ToolkitTestApplication application;
2841   tet_infoline(" utcDaliTextFieldEvent06");
2842
2843   // Checks Longpress when in edit mode
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, "Thisisalongtextforthesizeofthetextfield.");
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   // Long Press
2879   TestGenerateLongPress(application, 1.0f, 25.0f);
2880
2881   // Render and notify
2882   application.SendNotification();
2883   application.Render();
2884
2885   END_TEST;
2886 }
2887
2888 int utcDaliTextFieldEvent07(void)
2889 {
2890   ToolkitTestApplication application;
2891   tet_infoline(" utcDaliTextFieldEvent07");
2892
2893   // Checks Longpress to start edit mode
2894
2895   TextField field = TextField::New();
2896   DALI_TEST_CHECK(field);
2897   application.GetScene().Add(field);
2898   LoadMarkerImages(application, field);
2899   // Render and notify
2900   application.SendNotification();
2901   application.Render();
2902
2903   field.SetProperty(TextField::Property::TEXT, "Thisisalongtextforthesizeofthetextfield.");
2904   field.SetProperty(TextField::Property::POINT_SIZE, 10.f);
2905   field.SetProperty(Actor::Property::SIZE, Vector2(300.f, 50.f));
2906   field.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT);
2907   field.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
2908   Property::Map propertyMap;
2909   propertyMap["PANEL_LAYOUT"] = InputMethod::PanelLayout::PASSWORD;
2910   field.SetProperty(TextField::Property::INPUT_METHOD_SETTINGS, propertyMap);
2911
2912   // Avoid a crash when core load gl resources.
2913   application.GetGlAbstraction().SetCheckFramebufferStatusResult(GL_FRAMEBUFFER_COMPLETE);
2914   // Render and notify
2915   application.SendNotification();
2916   application.Render();
2917
2918   // Long Press
2919   TestGenerateLongPress(application, 1.0f, 25.0f);
2920
2921   // Render and notify
2922   application.SendNotification();
2923   application.Render();
2924
2925   END_TEST;
2926 }
2927
2928 int utcDaliTextFieldEvent08(void)
2929 {
2930   ToolkitTestApplication application;
2931   tet_infoline(" utcDaliTextFieldEvent08");
2932
2933   Dali::Clipboard clipboard = Clipboard::Get();
2934   clipboard.SetItem("testTextFieldEvent");
2935
2936   // Checks Longpress when only place holder text
2937
2938   TextField field = TextField::New();
2939   DALI_TEST_CHECK(field);
2940   application.GetScene().Add(field);
2941   LoadMarkerImages(application, field);
2942   // Render and notify
2943   application.SendNotification();
2944   application.Render();
2945
2946   field.SetProperty(TextField::Property::PLACEHOLDER_TEXT, "Setting Placeholder Text");
2947   field.SetProperty(TextField::Property::POINT_SIZE, 10.f);
2948   field.SetProperty(Actor::Property::SIZE, Vector2(300.f, 50.f));
2949   field.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT);
2950   field.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
2951
2952   // Avoid a crash when core load gl resources.
2953   application.GetGlAbstraction().SetCheckFramebufferStatusResult(GL_FRAMEBUFFER_COMPLETE);
2954   // Render and notify
2955   application.SendNotification();
2956   application.Render();
2957
2958   // Long Press
2959   TestGenerateLongPress(application, 1.0f, 25.0f, 20);
2960
2961   // Render and notify
2962   application.SendNotification();
2963   application.Render();
2964
2965   Wait(application, 500);
2966
2967   TestEndLongPress(application, 1.0f, 25.0f, 520);
2968
2969   // Long Press
2970   TestGenerateLongPress(application, 1.0f, 25.0f, 600);
2971
2972   // Render and notify
2973   application.Render();
2974
2975   Wait(application, 500);
2976
2977   Integration::Scene stage = application.GetScene();
2978   Layer              layer = stage.GetRootLayer();
2979   Actor              actor = layer.FindChildByName("optionPaste");
2980
2981   if(actor)
2982   {
2983     Vector3 worldPosition = actor.GetCurrentProperty<Vector3>(Actor::Property::WORLD_POSITION);
2984     Vector2 halfStageSize = stage.GetSize() / 2.0f;
2985     Vector2 position(worldPosition.x + halfStageSize.width, worldPosition.y + halfStageSize.height);
2986
2987     Dali::Integration::TouchEvent event;
2988     event = Dali::Integration::TouchEvent();
2989     event.AddPoint(GetPointDownInside(position));
2990     application.ProcessEvent(event);
2991
2992     event = Dali::Integration::TouchEvent();
2993     event.AddPoint(GetPointUpInside(position));
2994     application.ProcessEvent(event);
2995   }
2996   DALI_TEST_EQUALS(field.GetProperty<std::string>(TextEditor::Property::TEXT), std::string("testTextFieldEvent"), TEST_LOCATION);
2997
2998   END_TEST;
2999 }
3000
3001 int utcDaliTextFieldEvent09(void)
3002 {
3003   ToolkitTestApplication application;
3004   tet_infoline(" utcDaliTextFieldEvent09");
3005
3006   TextField field = TextField::New();
3007   DALI_TEST_CHECK(field);
3008   application.GetScene().Add(field);
3009   LoadMarkerImages(application, field);
3010   // Render and notify
3011   application.SendNotification();
3012   application.Render();
3013
3014   field.SetProperty(TextField::Property::TEXT, "Hello");
3015   field.SetProperty(TextField::Property::POINT_SIZE, 10.f);
3016   field.SetProperty(Actor::Property::SIZE, Vector2(300.f, 50.f));
3017   field.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT);
3018   field.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
3019
3020   // Avoid a crash when core load gl resources.
3021   application.GetGlAbstraction().SetCheckFramebufferStatusResult(GL_FRAMEBUFFER_COMPLETE);
3022
3023   // Create a tap event to touch the text field.
3024   TestGenerateTap(application, 150.0f, 25.0f);
3025   application.SendNotification();
3026   application.Render();
3027
3028   Property::Map map;
3029   map[HiddenInput::Property::MODE] = HiddenInput::Mode::HIDE_NONE;
3030   field.SetProperty(TextField::Property::HIDDEN_INPUT_SETTINGS, map);
3031   application.ProcessEvent(GenerateKey("d", "", "d", 0, 0, 0, Integration::KeyEvent::DOWN, "d", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
3032   application.SendNotification();
3033   application.Render();
3034
3035   map[HiddenInput::Property::MODE]                 = HiddenInput::Mode::HIDE_ALL;
3036   map[HiddenInput::Property::SUBSTITUTE_CHARACTER] = 0x23;
3037   field.SetProperty(TextField::Property::HIDDEN_INPUT_SETTINGS, map);
3038   application.ProcessEvent(GenerateKey("d", "", "d", 0, 0, 0, Integration::KeyEvent::DOWN, "d", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
3039   application.SendNotification();
3040   application.Render();
3041
3042   map[HiddenInput::Property::MODE]             = HiddenInput::Mode::HIDE_COUNT;
3043   map[HiddenInput::Property::SUBSTITUTE_COUNT] = 2;
3044   field.SetProperty(TextField::Property::HIDDEN_INPUT_SETTINGS, map);
3045   for(unsigned int index = 0u; index < 5u; ++index)
3046   {
3047     application.ProcessEvent(GenerateKey("d", "", "d", 0, 0, 0, Integration::KeyEvent::DOWN, "d", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
3048     application.SendNotification();
3049     application.Render();
3050   }
3051
3052   map[HiddenInput::Property::MODE]             = HiddenInput::Mode::SHOW_COUNT;
3053   map[HiddenInput::Property::SUBSTITUTE_COUNT] = 2;
3054   field.SetProperty(TextField::Property::HIDDEN_INPUT_SETTINGS, map);
3055   for(unsigned int index = 0u; index < 5u; ++index)
3056   {
3057     application.ProcessEvent(GenerateKey("d", "", "d", 0, 0, 0, Integration::KeyEvent::DOWN, "d", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
3058     application.SendNotification();
3059     application.Render();
3060   }
3061
3062   map[HiddenInput::Property::MODE]                         = HiddenInput::Mode::SHOW_LAST_CHARACTER;
3063   map[HiddenInput::Property::SHOW_LAST_CHARACTER_DURATION] = 0;
3064   field.SetProperty(TextField::Property::HIDDEN_INPUT_SETTINGS, map);
3065   application.ProcessEvent(GenerateKey("", "", "", DALI_KEY_BACKSPACE, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
3066   application.SendNotification();
3067   application.Render();
3068   application.ProcessEvent(GenerateKey("d", "", "d", 0, 0, 0, Integration::KeyEvent::DOWN, "d", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
3069   application.SendNotification();
3070   application.Render();
3071
3072   map[HiddenInput::Property::SHOW_LAST_CHARACTER_DURATION] = 100;
3073   field.SetProperty(TextField::Property::HIDDEN_INPUT_SETTINGS, map);
3074   application.ProcessEvent(GenerateKey("d", "", "d", 0, 0, 0, Integration::KeyEvent::DOWN, "d", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
3075   application.SendNotification();
3076   application.Render();
3077
3078   Property::Map mapGet;
3079   mapGet = field.GetProperty<Property::Map>(TextField::Property::HIDDEN_INPUT_SETTINGS);
3080   DALI_TEST_EQUALS(map.Count(), mapGet.Count(), TEST_LOCATION);
3081   DALI_TEST_EQUALS(DaliTestCheckMaps(map, mapGet), true, TEST_LOCATION);
3082   END_TEST;
3083 }
3084
3085 int utcDaliTextFieldStyleWhilstSelected(void)
3086 {
3087   ToolkitTestApplication application;
3088   tet_infoline(" utcDaliTextFieldStyleWhilstSelected");
3089
3090   // Change font and styles whilst text is selected whilst word selected
3091
3092   TextField field = TextField::New();
3093   DALI_TEST_CHECK(field);
3094   application.GetScene().Add(field);
3095   LoadMarkerImages(application, field);
3096   // Render and notify
3097   application.SendNotification();
3098   application.Render();
3099
3100   field.SetProperty(TextField::Property::TEXT, "This is a long text for the size of the text-field.");
3101   field.SetProperty(TextField::Property::POINT_SIZE, 10.f);
3102   field.SetProperty(Actor::Property::SIZE, Vector2(300.f, 50.f));
3103   field.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT);
3104   field.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
3105
3106   // Avoid a crash when core load gl resources.
3107   application.GetGlAbstraction().SetCheckFramebufferStatusResult(GL_FRAMEBUFFER_COMPLETE);
3108   // Render and notify
3109   application.SendNotification();
3110   application.Render();
3111
3112   // Create a tap event to touch the text field.
3113   TestGenerateTap(application, 150.0f, 25.0f);
3114   // Render and notify
3115   application.SendNotification();
3116   application.Render();
3117
3118   // Tap first to get the focus.
3119   TestGenerateTap(application, 1.0f, 25.0f);
3120
3121   // Render and notify
3122   application.SendNotification();
3123   application.Render();
3124
3125   // Double tap to select a word.
3126   TestGenerateTap(application, 1.0f, 25.0f);
3127
3128   // Render and notify
3129   application.SendNotification();
3130   application.Render();
3131
3132   field.SetProperty(TextField::Property::INPUT_FONT_FAMILY, "Setting input font family");
3133   DALI_TEST_EQUALS(field.GetProperty<std::string>(TextField::Property::INPUT_FONT_FAMILY), "Setting input font family", TEST_LOCATION);
3134
3135   Property::Map fontStyleMapSet;
3136   Property::Map fontStyleMapGet;
3137
3138   fontStyleMapSet.Insert("weight", "bold");
3139   fontStyleMapSet.Insert("slant", "italic");
3140   field.SetProperty(TextField::Property::INPUT_FONT_STYLE, fontStyleMapSet);
3141
3142   fontStyleMapGet = field.GetProperty<Property::Map>(TextField::Property::INPUT_FONT_STYLE);
3143   DALI_TEST_EQUALS(fontStyleMapGet.Count(), fontStyleMapSet.Count(), TEST_LOCATION);
3144   DALI_TEST_EQUALS(DaliTestCheckMaps(fontStyleMapGet, fontStyleMapSet), true, TEST_LOCATION);
3145
3146   fontStyleMapSet.Clear();
3147   fontStyleMapSet.Insert("width", "expanded");
3148   fontStyleMapSet.Insert("slant", "italic");
3149   field.SetProperty(TextField::Property::INPUT_FONT_STYLE, fontStyleMapSet);
3150
3151   fontStyleMapGet = field.GetProperty<Property::Map>(TextField::Property::INPUT_FONT_STYLE);
3152   DALI_TEST_EQUALS(fontStyleMapGet.Count(), fontStyleMapSet.Count(), TEST_LOCATION);
3153   DALI_TEST_EQUALS(DaliTestCheckMaps(fontStyleMapGet, fontStyleMapSet), true, TEST_LOCATION);
3154
3155   field.SetProperty(TextField::Property::INPUT_POINT_SIZE, 12.f);
3156   DALI_TEST_EQUALS(field.GetProperty<float>(TextField::Property::INPUT_POINT_SIZE), 12.f, Math::MACHINE_EPSILON_1000, TEST_LOCATION);
3157
3158   field.SetProperty(TextField::Property::TEXT_COLOR, Color::RED);
3159   DALI_TEST_EQUALS(field.GetProperty<Vector4>(TextField::Property::TEXT_COLOR), Color::RED, TEST_LOCATION);
3160
3161   fontStyleMapSet.Clear();
3162   fontStyleMapSet.Insert("weight", "bold");
3163   fontStyleMapSet.Insert("slant", "italic");
3164
3165   field.SetProperty(TextField::Property::FONT_STYLE, fontStyleMapSet);
3166
3167   fontStyleMapGet = field.GetProperty<Property::Map>(TextField::Property::FONT_STYLE);
3168   DALI_TEST_EQUALS(fontStyleMapGet.Count(), fontStyleMapSet.Count(), TEST_LOCATION);
3169   DALI_TEST_EQUALS(DaliTestCheckMaps(fontStyleMapGet, fontStyleMapSet), true, TEST_LOCATION);
3170
3171   fontStyleMapSet.Clear();
3172   fontStyleMapSet.Insert("width", "expanded");
3173
3174   field.SetProperty(TextField::Property::FONT_STYLE, fontStyleMapSet);
3175
3176   fontStyleMapGet = field.GetProperty<Property::Map>(TextField::Property::FONT_STYLE);
3177   DALI_TEST_EQUALS(fontStyleMapGet.Count(), fontStyleMapSet.Count(), TEST_LOCATION);
3178   DALI_TEST_EQUALS(DaliTestCheckMaps(fontStyleMapGet, fontStyleMapSet), true, TEST_LOCATION);
3179
3180   // Press Escape to increase coverage
3181   application.ProcessEvent(GenerateKey("", "", "", DALI_KEY_ESCAPE, 0, 0, Integration::KeyEvent::UP, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
3182   application.SendNotification();
3183   application.Render();
3184
3185   DALI_TEST_CHECK(!field.HasKeyInputFocus());
3186
3187   END_TEST;
3188 }
3189
3190 int utcDaliTextFieldEscKeyLoseFocus(void)
3191 {
3192   ToolkitTestApplication application;
3193   tet_infoline(" utcDaliTextFieldEscKeyLoseFocus");
3194
3195   // Creates a tap event. After creating a tap event the text field should
3196   // have the focus and add text with key events should be possible.
3197
3198   TextField field = TextField::New();
3199   DALI_TEST_CHECK(field);
3200
3201   application.GetScene().Add(field);
3202
3203   field.SetProperty(Actor::Property::SIZE, Vector2(300.f, 50.f));
3204   field.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT);
3205   field.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
3206
3207   // Avoid a crash when core load gl resources.
3208   application.GetGlAbstraction().SetCheckFramebufferStatusResult(GL_FRAMEBUFFER_COMPLETE);
3209
3210   // Render and notify
3211   application.SendNotification();
3212   application.Render();
3213
3214   // Add a key event but as the text field has not the focus it should do nothing.
3215   application.ProcessEvent(GenerateKey("a", "", "a", KEY_A_CODE, 0, 0, Integration::KeyEvent::DOWN, "a", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
3216   application.ProcessEvent(GenerateKey("a", "", "a", KEY_A_CODE, 0, 0, Integration::KeyEvent::UP, "a", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
3217
3218   // Render and notify
3219   application.SendNotification();
3220   application.Render();
3221
3222   DALI_TEST_EQUALS(field.GetProperty<std::string>(TextField::Property::TEXT), std::string(""), TEST_LOCATION);
3223
3224   // Create a tap event to touch the text field.
3225   TestGenerateTap(application, 150.0f, 25.0f);
3226
3227   // Render and notify
3228   application.SendNotification();
3229   application.Render();
3230
3231   // Now the text field has the focus, so it can handle the key events.
3232   application.ProcessEvent(GenerateKey("a", "", "a", KEY_A_CODE, 0, 0, Integration::KeyEvent::DOWN, "a", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
3233   application.ProcessEvent(GenerateKey("a", "", "a", KEY_A_CODE, 0, 0, Integration::KeyEvent::UP, "a", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
3234   application.ProcessEvent(GenerateKey("d", "", "d", KEY_D_CODE, 0, 0, Integration::KeyEvent::DOWN, "d", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
3235   application.ProcessEvent(GenerateKey("d", "", "d", KEY_D_CODE, 0, 0, Integration::KeyEvent::UP, "d", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
3236
3237   // Render and notify
3238   application.SendNotification();
3239   application.Render();
3240
3241   DALI_TEST_EQUALS(field.GetProperty<std::string>(TextField::Property::TEXT), std::string("ad"), TEST_LOCATION);
3242
3243   // Generate a Esc key event. The text field should lose the focus.
3244   application.ProcessEvent(GenerateKey("", "", "", DALI_KEY_ESCAPE, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
3245   application.ProcessEvent(GenerateKey("", "", "", DALI_KEY_ESCAPE, 0, 0, Integration::KeyEvent::UP, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
3246
3247   // Render and notify
3248   application.SendNotification();
3249   application.Render();
3250
3251   DALI_TEST_EQUALS(false, field.HasKeyInputFocus(), TEST_LOCATION);
3252
3253   // No more text should be introduced
3254   application.ProcessEvent(GenerateKey("a", "", "a", KEY_A_CODE, 0, 0, Integration::KeyEvent::DOWN, "a", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
3255   application.ProcessEvent(GenerateKey("a", "", "a", KEY_A_CODE, 0, 0, Integration::KeyEvent::UP, "a", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
3256
3257   // Render and notify
3258   application.SendNotification();
3259   application.Render();
3260
3261   DALI_TEST_EQUALS(field.GetProperty<std::string>(TextField::Property::TEXT), std::string("ad"), TEST_LOCATION);
3262
3263   END_TEST;
3264 }
3265
3266 int utcDaliTextFieldSomeSpecialKeys(void)
3267 {
3268   ToolkitTestApplication application;
3269   tet_infoline(" utcDaliTextFieldSomeSpecialKeys");
3270
3271   // Checks some special keys when the text is selected.
3272
3273   TextField field = TextField::New();
3274   DALI_TEST_CHECK(field);
3275   application.GetScene().Add(field);
3276   LoadMarkerImages(application, field);
3277   // Render and notify
3278   application.SendNotification();
3279   application.Render();
3280
3281   const std::string longText("This is a long text for the size of the text-field.");
3282
3283   field.SetProperty(TextField::Property::TEXT, longText);
3284   field.SetProperty(TextField::Property::POINT_SIZE, 10.f);
3285   field.SetProperty(Actor::Property::SIZE, Vector2(300.f, 50.f));
3286   field.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT);
3287   field.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
3288
3289   // Avoid a crash when core load gl resources.
3290   application.GetGlAbstraction().SetCheckFramebufferStatusResult(GL_FRAMEBUFFER_COMPLETE);
3291   // Render and notify
3292   application.SendNotification();
3293   application.Render();
3294
3295   // Create a tap event to touch the text field.
3296   TestGenerateTap(application, 150.0f, 25.0f);
3297
3298   // Render and notify
3299   application.SendNotification();
3300   application.Render();
3301
3302   // Tap first to get the focus.
3303   TestGenerateTap(application, 1.0f, 25.0f);
3304
3305   // Render and notify
3306   application.SendNotification();
3307   application.Render();
3308
3309   // Double tap to select a word.
3310   TestGenerateTap(application, 1.0f, 25.0f);
3311
3312   // Render and notify
3313   application.SendNotification();
3314   application.Render();
3315
3316   // Generate a Esc key event. The text field should lose the focus.
3317   application.ProcessEvent(GenerateKey("XF86PowerOff", "", "XF86PowerOff", DALI_KEY_POWER, 0, 0, Integration::KeyEvent::DOWN, "XF86PowerOff", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
3318   application.ProcessEvent(GenerateKey("XF86PowerOff", "", "XF86PowerOff", DALI_KEY_POWER, 0, 0, Integration::KeyEvent::UP, "XF86PowerOff", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
3319
3320   // Render and notify
3321   application.SendNotification();
3322   application.Render();
3323
3324   // Generate a Esc key event. The text field should lose the focus.
3325   application.ProcessEvent(GenerateKey("XF86Menu", "", "XF86Menu", DALI_KEY_MENU, 0, 0, Integration::KeyEvent::DOWN, "XF86Menu", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
3326   application.ProcessEvent(GenerateKey("XF86Menu", "", "XF86Menu", DALI_KEY_MENU, 0, 0, Integration::KeyEvent::UP, "XF86Menu", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
3327
3328   // Render and notify
3329   application.SendNotification();
3330   application.Render();
3331
3332   // Generate a Esc key event. The text field should lose the focus.
3333   application.ProcessEvent(GenerateKey("XF86Home", "", "XF86Home", DALI_KEY_HOME, 0, 0, Integration::KeyEvent::DOWN, "XF86Home", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
3334   application.ProcessEvent(GenerateKey("XF86Home", "", "XF86Home", DALI_KEY_HOME, 0, 0, Integration::KeyEvent::UP, "XF86Home", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
3335
3336   // Render and notify
3337   application.SendNotification();
3338   application.Render();
3339
3340   // Generate a Back key event. Nothing happens to the text field.
3341   application.ProcessEvent(GenerateKey("XF86Back", "", "XF86Back", DALI_KEY_BACK, 0, 0, Integration::KeyEvent::DOWN, "XF86Back", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
3342   application.ProcessEvent(GenerateKey("XF86Back", "", "XF86Back", DALI_KEY_BACK, 0, 0, Integration::KeyEvent::UP, "XF86Back", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
3343
3344   // Render and notify
3345   application.SendNotification();
3346   application.Render();
3347
3348   // The text shouldn't be deleted.
3349   DALI_TEST_EQUALS(field.GetProperty<std::string>(TextField::Property::TEXT), longText, TEST_LOCATION);
3350
3351   END_TEST;
3352 }
3353
3354 int utcDaliTextFieldSizeUpdate(void)
3355 {
3356   ToolkitTestApplication application;
3357   tet_infoline("utcDaliTextFieldSizeUpdate");
3358
3359   // Checks some special keys when the text is selected.
3360   TextField field = TextField::New();
3361   DALI_TEST_CHECK(field);
3362   application.GetScene().Add(field);
3363
3364   float       previousHeight = 0.0f;
3365   float       currentHeight  = 0.0f;
3366   const float fieldWidth     = 1920.0f;
3367
3368   // "ㅁ" is bigger then "ኢ"
3369   field.SetProperty(Actor::Property::SIZE, Vector2(fieldWidth, 10.0f));
3370   field.SetResizePolicy(ResizePolicy::FIXED, Dimension::WIDTH);
3371   field.SetResizePolicy(ResizePolicy::DIMENSION_DEPENDENCY, Dimension::HEIGHT);
3372
3373   field.SetProperty(TextField::Property::TEXT, "ኢ");
3374   field.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT);
3375   field.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
3376
3377   field.SetProperty(Actor::Property::KEYBOARD_FOCUSABLE, true);
3378   KeyboardFocusManager::Get().SetCurrentFocusActor(field);
3379
3380   application.SendNotification();
3381   application.Render();
3382
3383   previousHeight = field.GetHeightForWidth(fieldWidth);
3384   DALI_TEST_EQUALS(previousHeight, field.GetProperty<float>(Actor::Property::SIZE_HEIGHT), TEST_LOCATION);
3385
3386   // Add  another script characters ( glyph height is defferent )
3387   application.ProcessEvent(GenerateKey("ㅁ", "", "ㅁ", KEY_A_CODE, 0, 0, Integration::KeyEvent::DOWN, "ㅁ", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
3388   application.ProcessEvent(GenerateKey("ㅁ", "", "ㅁ", KEY_A_CODE, 0, 0, Integration::KeyEvent::UP, "ㅁ", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
3389
3390   application.SendNotification();
3391   application.Render();
3392
3393   currentHeight = field.GetHeightForWidth(fieldWidth);
3394   DALI_TEST_EQUALS(currentHeight, field.GetProperty<float>(Actor::Property::SIZE_HEIGHT), TEST_LOCATION);
3395   DALI_TEST_EQUALS((previousHeight < currentHeight), true, TEST_LOCATION);
3396
3397   END_TEST;
3398 }
3399
3400 int utcDaliTextFieldExtremlyLargePointSize(void)
3401 {
3402   ToolkitTestApplication application;
3403   tet_infoline(" utcDaliTextFieldExtremlyLargePointSize");
3404
3405   TextField field = TextField::New();
3406
3407   field.SetProperty(TextField::Property::TEXT, "Text");
3408   field.SetProperty(Actor::Property::SIZE, Vector2(300.f, 50.f));
3409   field.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT);
3410   field.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
3411   application.GetScene().Add(field);
3412
3413   try
3414   {
3415     field.SetProperty(TextField::Property::POINT_SIZE, 160.0f);
3416     application.SendNotification();
3417     DALI_TEST_CHECK(field);
3418   }
3419   catch(...)
3420   {
3421     tet_result(TET_FAIL);
3422   }
3423   END_TEST;
3424 }
3425
3426 int UtcDaliTextFieldDefaultFontStylePropertyCoverage(void)
3427 {
3428   ToolkitTestApplication application;
3429   tet_infoline("UtcDaliTextFieldFontStylePorpertyCoverage");
3430   TextField field = TextField::New();
3431   DALI_TEST_CHECK(field);
3432   application.GetScene().Add(field);
3433
3434   Property::Map fontStyleMapGet;
3435
3436   fontStyleMapGet = field.GetProperty<Property::Map>(TextField::Property::FONT_STYLE);
3437
3438   Property::Value* weightValue = NULL;
3439   Property::Value* widthValue  = NULL;
3440   Property::Value* slantValue  = NULL;
3441   weightValue                  = fontStyleMapGet.Find("weight");
3442   widthValue                   = fontStyleMapGet.Find("width");
3443   slantValue                   = fontStyleMapGet.Find("slant");
3444   DALI_TEST_CHECK(!weightValue);
3445   DALI_TEST_CHECK(!widthValue);
3446   DALI_TEST_CHECK(!slantValue);
3447
3448   END_TEST;
3449 }
3450
3451 int UtcDaliTextFieldSettingPlaceholder(void)
3452 {
3453   ToolkitTestApplication application;
3454   tet_infoline("UtcDaliTextFieldSettingPlaceholder");
3455
3456   TextField field = TextField::New();
3457   DALI_TEST_CHECK(field);
3458   application.GetScene().Add(field);
3459
3460   // Check the placeholder property with pixel size
3461   Property::Map placeholderPixelSizeMapSet;
3462   Property::Map placeholderPixelSizeMapGet;
3463   Property::Map placeholderFontstyleMap;
3464   placeholderPixelSizeMapSet[Text::PlaceHolder::Property::TEXT]         = "Setting Placeholder Text";
3465   placeholderPixelSizeMapSet[Text::PlaceHolder::Property::TEXT_FOCUSED] = "Setting Placeholder Text Focused";
3466   placeholderPixelSizeMapSet[Text::PlaceHolder::Property::COLOR]        = Color::BLUE;
3467   placeholderPixelSizeMapSet[Text::PlaceHolder::Property::FONT_FAMILY]  = "Arial";
3468   placeholderPixelSizeMapSet[Text::PlaceHolder::Property::PIXEL_SIZE]   = 15.0f;
3469   placeholderPixelSizeMapSet[Text::PlaceHolder::Property::ELLIPSIS]     = true;
3470
3471   placeholderFontstyleMap.Insert("weight", "bold");
3472   placeholderPixelSizeMapSet[Text::PlaceHolder::Property::FONT_STYLE] = placeholderFontstyleMap;
3473   field.SetProperty(TextField::Property::PLACEHOLDER, placeholderPixelSizeMapSet);
3474
3475   placeholderPixelSizeMapGet = field.GetProperty<Property::Map>(TextField::Property::PLACEHOLDER);
3476   DALI_TEST_EQUALS(placeholderPixelSizeMapGet.Count(), placeholderPixelSizeMapSet.Count(), TEST_LOCATION);
3477   DALI_TEST_EQUALS(DaliTestCheckMaps(placeholderPixelSizeMapGet, placeholderPixelSizeMapSet), true, TEST_LOCATION);
3478
3479   // Check the placeholder property with point size
3480   Property::Map placeholderMapSet;
3481   Property::Map placeholderMapGet;
3482   placeholderMapSet[Text::PlaceHolder::Property::TEXT]         = "Setting Placeholder Text";
3483   placeholderMapSet[Text::PlaceHolder::Property::TEXT_FOCUSED] = "Setting Placeholder Text Focused";
3484   placeholderMapSet[Text::PlaceHolder::Property::COLOR]        = Color::RED;
3485   placeholderMapSet[Text::PlaceHolder::Property::FONT_FAMILY]  = "Arial";
3486   placeholderMapSet[Text::PlaceHolder::Property::POINT_SIZE]   = 12.0f;
3487   placeholderMapSet[Text::PlaceHolder::Property::ELLIPSIS]     = false;
3488
3489   // Check the placeholder font style property
3490   placeholderFontstyleMap.Clear();
3491
3492   placeholderFontstyleMap.Insert("weight", "bold");
3493   placeholderFontstyleMap.Insert("width", "condensed");
3494   placeholderFontstyleMap.Insert("slant", "italic");
3495   placeholderMapSet[Text::PlaceHolder::Property::FONT_STYLE] = placeholderFontstyleMap;
3496   field.SetProperty(TextField::Property::PLACEHOLDER, placeholderMapSet);
3497
3498   placeholderMapGet = field.GetProperty<Property::Map>(TextField::Property::PLACEHOLDER);
3499   DALI_TEST_EQUALS(placeholderMapGet.Count(), placeholderMapSet.Count(), TEST_LOCATION);
3500   DALI_TEST_EQUALS(DaliTestCheckMaps(placeholderMapGet, placeholderMapSet), true, TEST_LOCATION);
3501
3502   // Reset font style.
3503   placeholderFontstyleMap.Clear();
3504   placeholderFontstyleMap.Insert("weight", "normal");
3505   placeholderFontstyleMap.Insert("slant", "oblique");
3506   placeholderMapSet[Text::PlaceHolder::Property::FONT_STYLE] = placeholderFontstyleMap;
3507   field.SetProperty(TextField::Property::PLACEHOLDER, placeholderMapSet);
3508
3509   placeholderMapGet = field.GetProperty<Property::Map>(TextField::Property::PLACEHOLDER);
3510   DALI_TEST_EQUALS(placeholderMapGet.Count(), placeholderMapSet.Count(), TEST_LOCATION);
3511   DALI_TEST_EQUALS(DaliTestCheckMaps(placeholderMapGet, placeholderMapSet), true, TEST_LOCATION);
3512
3513   placeholderFontstyleMap.Clear();
3514   placeholderFontstyleMap.Insert("slant", "roman");
3515   placeholderMapSet[Text::PlaceHolder::Property::FONT_STYLE] = placeholderFontstyleMap;
3516   field.SetProperty(TextField::Property::PLACEHOLDER, placeholderMapSet);
3517
3518   placeholderMapGet = field.GetProperty<Property::Map>(TextField::Property::PLACEHOLDER);
3519
3520   placeholderFontstyleMap.Clear();
3521   placeholderMapSet[Text::PlaceHolder::Property::FONT_STYLE] = placeholderFontstyleMap;
3522
3523   field.SetProperty(TextField::Property::PLACEHOLDER, placeholderMapSet);
3524   placeholderMapGet = field.GetProperty<Property::Map>(TextField::Property::PLACEHOLDER);
3525   DALI_TEST_EQUALS(placeholderMapGet.Count(), placeholderMapSet.Count(), TEST_LOCATION);
3526   DALI_TEST_EQUALS(DaliTestCheckMaps(placeholderMapGet, placeholderMapSet), true, TEST_LOCATION);
3527
3528   END_TEST;
3529 }
3530
3531 int UtcDaliTextFieldPlaceholderCoverage(void)
3532 {
3533   ToolkitTestApplication application;
3534   tet_infoline("UtcDaliTextFieldPlaceholderCoverage");
3535
3536   // mPlaceholderFont is created only once, so create a new control for coverage.
3537   TextField fieldForCoverage = TextField::New();
3538   DALI_TEST_CHECK(fieldForCoverage);
3539   application.GetScene().Add(fieldForCoverage);
3540
3541   // for SetPlaceholderFontFamily() coverage.
3542   Property::Map fontFamilyMap;
3543   fontFamilyMap[Text::PlaceHolder::Property::FONT_FAMILY] = "Arial";
3544   fieldForCoverage.SetProperty(TextField::Property::PLACEHOLDER, fontFamilyMap);
3545
3546   // mPlaceholderFont is created only once, so create a new control for coverage.
3547   fieldForCoverage = TextField::New();
3548   DALI_TEST_CHECK(fieldForCoverage);
3549   application.GetScene().Add(fieldForCoverage);
3550
3551   // for SetPlaceholderTextFontSize coverage.
3552   Property::Map fontSizeMap;
3553   fontSizeMap[Text::PlaceHolder::Property::PIXEL_SIZE] = 15.0f;
3554   fieldForCoverage.SetProperty(TextField::Property::PLACEHOLDER, fontSizeMap);
3555
3556   // mPlaceholderFont is created only once, so create a new control for coverage.
3557   fieldForCoverage = TextField::New();
3558   DALI_TEST_CHECK(fieldForCoverage);
3559   application.GetScene().Add(fieldForCoverage);
3560
3561   // for SetPlaceholderTextFontWeight coverage.
3562   Property::Map fontStyleWeightMap;
3563   Property::Map fontStyleWeightPropertyMap;
3564   fontStyleWeightPropertyMap.Insert("weight", "bold");
3565   fontStyleWeightMap[Text::PlaceHolder::Property::FONT_STYLE] = fontStyleWeightPropertyMap;
3566   fieldForCoverage.SetProperty(TextField::Property::PLACEHOLDER, fontStyleWeightMap);
3567
3568   // mPlaceholderFont is created only once, so create a new control for coverage.
3569   fieldForCoverage = TextField::New();
3570   DALI_TEST_CHECK(fieldForCoverage);
3571   application.GetScene().Add(fieldForCoverage);
3572
3573   // for SetPlaceholderTextFontWidth coverage.
3574   Property::Map fontStyleWidthMap;
3575   Property::Map fontStyleWidthPropertyMap;
3576   fontStyleWidthPropertyMap.Insert("width", "expanded");
3577   fontStyleWidthMap[Text::PlaceHolder::Property::FONT_STYLE] = fontStyleWidthPropertyMap;
3578   fieldForCoverage.SetProperty(TextField::Property::PLACEHOLDER, fontStyleWidthMap);
3579
3580   // mPlaceholderFont is created only once, so create a new control for coverage.
3581   fieldForCoverage = TextField::New();
3582   DALI_TEST_CHECK(fieldForCoverage);
3583   application.GetScene().Add(fieldForCoverage);
3584
3585   // for SetPlaceholderTextFontSlant coverage.
3586   Property::Map fontStyleSlantMap;
3587   Property::Map fontStyleSlantPropertyMap;
3588   fontStyleSlantPropertyMap.Insert("slant", "italic");
3589   fontStyleSlantMap[Text::PlaceHolder::Property::FONT_STYLE] = fontStyleSlantPropertyMap;
3590   fieldForCoverage.SetProperty(TextField::Property::PLACEHOLDER, fontStyleSlantMap);
3591
3592   END_TEST;
3593 }
3594
3595 int UtcDaliTextFieldSetPaddingProperty(void)
3596 {
3597   ToolkitTestApplication application;
3598   tet_infoline("UtcDaliTextFieldSetPaddingProperty\n");
3599
3600   TextField field = TextField::New();
3601   DALI_TEST_CHECK(field);
3602   field.SetProperty(Actor::Property::SIZE, Vector2(300.f, 50.f));
3603   field.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT);
3604   field.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
3605   application.GetScene().Add(field);
3606
3607   application.SendNotification();
3608   application.Render();
3609
3610   Vector3 originalSize = field.GetNaturalSize();
3611
3612   field.SetProperty(Toolkit::Control::Property::PADDING, Extents(10, 10, 10, 10));
3613
3614   application.SendNotification();
3615   application.Render();
3616
3617   DALI_TEST_EQUALS(field.GetProperty<Extents>(Toolkit::Control::Property::PADDING), Extents(10, 10, 10, 10), TEST_LOCATION);
3618
3619   Vector3 paddingAddedSize = field.GetNaturalSize();
3620
3621   DALI_TEST_EQUALS(originalSize.width + 10 + 10, paddingAddedSize.width, Math::MACHINE_EPSILON_1000, TEST_LOCATION);
3622
3623   DALI_TEST_EQUALS(originalSize.height + 10 + 10, paddingAddedSize.height, Math::MACHINE_EPSILON_1000, TEST_LOCATION);
3624
3625   END_TEST;
3626 }
3627
3628 int UtcDaliTextFieldEnableShiftSelectionProperty(void)
3629 {
3630   ToolkitTestApplication application;
3631   tet_infoline("UtcDaliTextFieldEnableShiftSelectionProperty");
3632
3633   TextField field = TextField::New();
3634   DALI_TEST_CHECK(field);
3635   field.SetProperty(Actor::Property::SIZE, Vector2(300.f, 50.f));
3636   field.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT);
3637   field.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
3638   application.GetScene().Add(field);
3639
3640   application.SendNotification();
3641   application.Render();
3642
3643   // The default value of ENABLE_SHIFT_SELECTION is 'true'.
3644   DALI_TEST_EQUALS(field.GetProperty<bool>(DevelTextField::Property::ENABLE_SHIFT_SELECTION), true, TEST_LOCATION);
3645
3646   // Check the enable shift selection property
3647   field.SetProperty(DevelTextField::Property::ENABLE_SHIFT_SELECTION, false);
3648   DALI_TEST_EQUALS(field.GetProperty<bool>(DevelTextField::Property::ENABLE_SHIFT_SELECTION), false, TEST_LOCATION);
3649
3650   application.SendNotification();
3651   application.Render();
3652
3653   END_TEST;
3654 }
3655
3656 int UtcDaliTextFieldEnableGrabHandleProperty(void)
3657 {
3658   ToolkitTestApplication application;
3659   tet_infoline("UtcDaliTextFieldEnableGrabHandleProperty");
3660
3661   TextField field = TextField::New();
3662   DALI_TEST_CHECK(field);
3663   field.SetProperty(Actor::Property::SIZE, Vector2(300.f, 50.f));
3664   field.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT);
3665   field.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
3666   application.GetScene().Add(field);
3667
3668   application.SendNotification();
3669   application.Render();
3670
3671   // The default value of ENABLE_GRAB_HANDLE is 'true'.
3672   DALI_TEST_EQUALS(field.GetProperty<bool>(DevelTextField::Property::ENABLE_GRAB_HANDLE), true, TEST_LOCATION);
3673
3674   // Check the enable grab handle property
3675   field.SetProperty(DevelTextField::Property::ENABLE_GRAB_HANDLE, false);
3676   DALI_TEST_EQUALS(field.GetProperty<bool>(DevelTextField::Property::ENABLE_GRAB_HANDLE), false, TEST_LOCATION);
3677
3678   application.SendNotification();
3679   application.Render();
3680
3681   END_TEST;
3682 }
3683
3684 int UtcDaliTextFieldMatchSystemLanguageDirectionProperty(void)
3685 {
3686   ToolkitTestApplication application;
3687   tet_infoline("UtcDaliTextFieldMatchSystemLanguageDirectionProperty");
3688
3689   TextField field = TextField::New();
3690   DALI_TEST_CHECK(field);
3691   field.SetProperty(Actor::Property::SIZE, Vector2(300.f, 50.f));
3692   field.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT);
3693   field.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
3694   application.GetScene().Add(field);
3695
3696   application.SendNotification();
3697   application.Render();
3698
3699   // The default value of MATCH_SYSTEM_LANGUAGE_DIRECTION is 'true'.
3700   DALI_TEST_EQUALS(field.GetProperty<bool>(DevelTextField::Property::MATCH_SYSTEM_LANGUAGE_DIRECTION), true, TEST_LOCATION);
3701
3702   // Check the match system language direction property
3703   field.SetProperty(DevelTextField::Property::MATCH_SYSTEM_LANGUAGE_DIRECTION, false);
3704   DALI_TEST_EQUALS(field.GetProperty<bool>(DevelTextField::Property::MATCH_SYSTEM_LANGUAGE_DIRECTION), false, TEST_LOCATION);
3705
3706   application.SendNotification();
3707   application.Render();
3708
3709   END_TEST;
3710 }
3711
3712 int utcDaliTextFieldLayoutDirectionCoverage(void)
3713 {
3714   ToolkitTestApplication application;
3715   tet_infoline(" utcDaliTextFieldLayoutDirectionCoverage");
3716
3717   // Creates a tap event. After creating a tap event the text field should
3718   // have the focus and add text with key events should be possible.
3719   TextField field = TextField::New();
3720   DALI_TEST_CHECK(field);
3721
3722   application.GetScene().Add(field);
3723
3724   field.SetProperty(Actor::Property::SIZE, Vector2(300.f, 50.f));
3725   field.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT);
3726   field.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
3727
3728   // Avoid a crash when core load gl resources.
3729   application.GetGlAbstraction().SetCheckFramebufferStatusResult(GL_FRAMEBUFFER_COMPLETE);
3730
3731   // Render and notify
3732   application.SendNotification();
3733   application.Render();
3734
3735   // init direction for coverage
3736   // Set horizontal alignment END
3737   field.SetProperty(TextField::Property::HORIZONTAL_ALIGNMENT, "END");
3738
3739   // Create a tap event to touch the text field.
3740   TestGenerateTap(application, 150.0f, 25.0f);
3741
3742   // Render and notify
3743   application.SendNotification();
3744   application.Render();
3745
3746   // Set MATCH_SYSTEM_LANGUAGE_DIRECTION to true to use the layout direction.
3747   field.SetProperty(DevelTextField::Property::MATCH_SYSTEM_LANGUAGE_DIRECTION, true);
3748   field.SetProperty(Actor::Property::LAYOUT_DIRECTION, LayoutDirection::RIGHT_TO_LEFT);
3749
3750   // Set horizontal alignment BEGIN
3751   field.SetProperty(TextField::Property::HORIZONTAL_ALIGNMENT, "BEGIN");
3752
3753   // Create a tap event to touch the text field.
3754   TestGenerateTap(application, 150.0f, 25.0f);
3755
3756   // Render and notify
3757   application.SendNotification();
3758   application.Render();
3759
3760   // Set horizontal alignment CENTER
3761   field.SetProperty(TextField::Property::HORIZONTAL_ALIGNMENT, "CENTER");
3762
3763   // Create a tap event to touch the text field.
3764   TestGenerateTap(application, 150.0f, 25.0f);
3765
3766   // Render and notify
3767   application.SendNotification();
3768   application.Render();
3769
3770   // Set horizontal alignment END
3771   field.SetProperty(TextField::Property::HORIZONTAL_ALIGNMENT, "END");
3772
3773   // Create a tap event to touch the text field.
3774   TestGenerateTap(application, 150.0f, 25.0f);
3775
3776   // Render and notify
3777   application.SendNotification();
3778   application.Render();
3779
3780   // Generate a Esc key event. The text field should lose the focus.
3781   application.ProcessEvent(GenerateKey("", "", "", DALI_KEY_ESCAPE, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
3782   application.ProcessEvent(GenerateKey("", "", "", DALI_KEY_ESCAPE, 0, 0, Integration::KeyEvent::UP, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
3783
3784   // Render and notify
3785   application.SendNotification();
3786   application.Render();
3787
3788   DALI_TEST_EQUALS(false, field.HasKeyInputFocus(), TEST_LOCATION);
3789
3790   END_TEST;
3791 }
3792
3793 int UtcDaliTextFieldGetInputMethodContext(void)
3794 {
3795   ToolkitTestApplication application;
3796   tet_infoline("UtcDaliTextFieldGetInputMethodContext");
3797
3798   TextField field = TextField::New();
3799   DALI_TEST_CHECK(DevelTextField::GetInputMethodContext(field));
3800
3801   END_TEST;
3802 }
3803
3804 int UtcDaliTextFieldSelectWholeText(void)
3805 {
3806   ToolkitTestApplication application;
3807   tet_infoline(" UtcDaliTextFieldSelectWholeText ");
3808
3809   TextField textField = TextField::New();
3810
3811   application.GetScene().Add(textField);
3812
3813   textField.SetProperty(Actor::Property::SIZE, Vector2(300.f, 50.f));
3814   textField.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT);
3815   textField.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
3816
3817   // Avoid a crash when core load gl resources.
3818   application.GetGlAbstraction().SetCheckFramebufferStatusResult(GL_FRAMEBUFFER_COMPLETE);
3819
3820   application.SendNotification();
3821   application.Render();
3822
3823   DALI_TEST_EQUALS(1u, textField.GetChildCount(), TEST_LOCATION);
3824
3825   DevelTextField::SelectWholeText(textField);
3826
3827   application.SendNotification();
3828   application.Render();
3829
3830   // Nothing should have been selected. The number of children is still 1
3831   DALI_TEST_EQUALS(1u, textField.GetChildCount(), TEST_LOCATION);
3832
3833   textField.SetProperty(TextField::Property::TEXT, "Hello world");
3834
3835   application.SendNotification();
3836   application.Render();
3837
3838   DevelTextField::SelectWholeText(textField);
3839
3840   application.SendNotification();
3841   application.Render();
3842
3843   // Even if resize, selection should remain.
3844   textField.SetProperty(Actor::Property::SIZE, Vector2(150.f, 50.f));
3845
3846   application.SendNotification();
3847   application.Render();
3848
3849   // Should be 2 children, the stencil and the layer
3850   DALI_TEST_EQUALS(2u, textField.GetChildCount(), TEST_LOCATION);
3851
3852   // The offscreen root actor should have two actors: the renderer and the highlight actor.
3853   Actor stencil = textField.GetChildAt(0u);
3854
3855   // The highlight actor is drawn first, so is the first actor in the list
3856   Renderer highlight = stencil.GetChildAt(0u).GetRendererAt(0u);
3857   DALI_TEST_CHECK(highlight);
3858
3859   END_TEST;
3860 }
3861
3862 int UtcDaliTextFieldSelectText(void)
3863 {
3864   ToolkitTestApplication application;
3865   tet_infoline(" UtcDaliTextFieldSelectText ");
3866
3867   TextField textField = TextField::New();
3868
3869   application.GetScene().Add(textField);
3870
3871   textField.SetProperty(Actor::Property::SIZE, Vector2(300.f, 50.f));
3872   textField.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT);
3873   textField.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
3874
3875   // Avoid a crash when core load gl resources.
3876   application.GetGlAbstraction().SetCheckFramebufferStatusResult(GL_FRAMEBUFFER_COMPLETE);
3877
3878   application.SendNotification();
3879   application.Render();
3880
3881   DevelTextField::SelectText(textField, 0, 5);
3882
3883   application.SendNotification();
3884   application.Render();
3885
3886   // Nothing is selected
3887   std::string selectedText = textField.GetProperty(DevelTextField::Property::SELECTED_TEXT).Get<std::string>();
3888   DALI_TEST_EQUALS("", selectedText, TEST_LOCATION);
3889
3890   textField.SetProperty(TextField::Property::TEXT, "Hello world");
3891
3892   application.SendNotification();
3893   application.Render();
3894
3895   // Hello is selected
3896   DevelTextField::SelectText(textField, 0, 5);
3897
3898   application.SendNotification();
3899   application.Render();
3900
3901   selectedText = textField.GetProperty(DevelTextField::Property::SELECTED_TEXT).Get<std::string>();
3902   DALI_TEST_EQUALS("Hello", selectedText, TEST_LOCATION);
3903
3904   DALI_TEST_EQUALS(textField.GetProperty(DevelTextField::Property::SELECTED_TEXT_START).Get<int>(), 0, TEST_LOCATION);
3905   DALI_TEST_EQUALS(textField.GetProperty(DevelTextField::Property::SELECTED_TEXT_END).Get<int>(), 5, TEST_LOCATION);
3906
3907   // world is selected
3908   DevelTextField::SelectText(textField, 6, 11);
3909
3910   application.SendNotification();
3911   application.Render();
3912
3913   selectedText = textField.GetProperty(DevelTextField::Property::SELECTED_TEXT).Get<std::string>();
3914   DALI_TEST_EQUALS("world", selectedText, TEST_LOCATION);
3915
3916   DALI_TEST_EQUALS(textField.GetProperty(DevelTextField::Property::SELECTED_TEXT_START).Get<int>(), 6, TEST_LOCATION);
3917   DALI_TEST_EQUALS(textField.GetProperty(DevelTextField::Property::SELECTED_TEXT_END).Get<int>(), 11, TEST_LOCATION);
3918
3919   END_TEST;
3920 }
3921
3922 int UtcDaliTextFieldSelectNone(void)
3923 {
3924   ToolkitTestApplication application;
3925   tet_infoline(" UtcDaliTextFieldSelectWholeText ");
3926
3927   TextField textField = TextField::New();
3928
3929   application.GetScene().Add(textField);
3930
3931   textField.SetProperty(Actor::Property::SIZE, Vector2(300.f, 50.f));
3932   textField.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT);
3933   textField.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
3934
3935   // Avoid a crash when core load gl resources.
3936   application.GetGlAbstraction().SetCheckFramebufferStatusResult(GL_FRAMEBUFFER_COMPLETE);
3937
3938   application.SendNotification();
3939   application.Render();
3940
3941   textField.SetProperty(TextField::Property::TEXT, "Hello world");
3942
3943   application.SendNotification();
3944   application.Render();
3945
3946   // Nothing is selected
3947   std::string selectedText = textField.GetProperty(DevelTextField::Property::SELECTED_TEXT).Get<std::string>();
3948   DALI_TEST_EQUALS("", selectedText, TEST_LOCATION);
3949
3950   DevelTextField::SelectWholeText(textField);
3951
3952   application.SendNotification();
3953   application.Render();
3954
3955   // whole text is selected
3956   selectedText = textField.GetProperty(DevelTextField::Property::SELECTED_TEXT).Get<std::string>();
3957   DALI_TEST_EQUALS("Hello world", selectedText, TEST_LOCATION);
3958
3959   DevelTextField::SelectNone(textField);
3960
3961   application.SendNotification();
3962   application.Render();
3963
3964   // Nothing is selected
3965   selectedText = textField.GetProperty(DevelTextField::Property::SELECTED_TEXT).Get<std::string>();
3966   DALI_TEST_EQUALS("", selectedText, TEST_LOCATION);
3967
3968   END_TEST;
3969 }
3970
3971 int UtcDaliTextFieldSelectRange(void)
3972 {
3973   ToolkitTestApplication application;
3974   tet_infoline(" UtcDaliTextFieldSelectRange ");
3975
3976   TextField textField = TextField::New();
3977
3978   application.GetScene().Add(textField);
3979
3980   textField.SetProperty(Actor::Property::SIZE, Vector2(300.f, 50.f));
3981   textField.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT);
3982   textField.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
3983
3984   // Avoid a crash when core load gl resources.
3985   application.GetGlAbstraction().SetCheckFramebufferStatusResult(GL_FRAMEBUFFER_COMPLETE);
3986
3987   application.SendNotification();
3988   application.Render();
3989
3990   textField.SetProperty(TextField::Property::TEXT, "Hello world");
3991
3992   application.SendNotification();
3993   application.Render();
3994
3995   textField.SetProperty(DevelTextField::Property::SELECTED_TEXT_START, 0);
3996   textField.SetProperty(DevelTextField::Property::SELECTED_TEXT_END, 5);
3997
3998   // Hello is selected
3999   std::string selectedText = textField.GetProperty(DevelTextField::Property::SELECTED_TEXT).Get<std::string>();
4000   DALI_TEST_EQUALS("Hello", selectedText, TEST_LOCATION);
4001
4002   DALI_TEST_EQUALS(textField.GetProperty(DevelTextField::Property::SELECTED_TEXT_START).Get<int>(), 0, TEST_LOCATION);
4003   DALI_TEST_EQUALS(textField.GetProperty(DevelTextField::Property::SELECTED_TEXT_END).Get<int>(), 5, TEST_LOCATION);
4004
4005   textField.SetProperty(DevelTextField::Property::SELECTED_TEXT_START, 6);
4006   textField.SetProperty(DevelTextField::Property::SELECTED_TEXT_END, 11);
4007
4008   // world is selected
4009   selectedText = textField.GetProperty(DevelTextField::Property::SELECTED_TEXT).Get<std::string>();
4010   DALI_TEST_EQUALS("world", selectedText, TEST_LOCATION);
4011
4012   DALI_TEST_EQUALS(textField.GetProperty(DevelTextField::Property::SELECTED_TEXT_START).Get<int>(), 6, TEST_LOCATION);
4013   DALI_TEST_EQUALS(textField.GetProperty(DevelTextField::Property::SELECTED_TEXT_END).Get<int>(), 11, TEST_LOCATION);
4014
4015   END_TEST;
4016 }
4017
4018 int UtcDaliTextFieldEnableEditing(void)
4019 {
4020   ToolkitTestApplication application;
4021   tet_infoline(" UtcDaliTextFieldEnableEditing ");
4022
4023   TextField textField = TextField::New();
4024
4025   application.GetScene().Add(textField);
4026
4027   textField.SetProperty(Actor::Property::SIZE, Vector2(300.f, 50.f));
4028   textField.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT);
4029   textField.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
4030
4031   // Avoid a crash when core load gl resources.
4032   application.GetGlAbstraction().SetCheckFramebufferStatusResult(GL_FRAMEBUFFER_COMPLETE);
4033
4034   application.SendNotification();
4035   application.Render();
4036
4037   textField.SetProperty(DevelActor::Property::USER_INTERACTION_ENABLED, true);
4038   DALI_TEST_EQUALS(textField.GetProperty(DevelActor::Property::USER_INTERACTION_ENABLED).Get<bool>(), true, TEST_LOCATION);
4039
4040   textField.SetKeyInputFocus();
4041   textField.SetProperty(DevelTextField::Property::ENABLE_EDITING, false);
4042   application.ProcessEvent(GenerateKey("D", "", "D", KEY_D_CODE, 0, 0, Integration::KeyEvent::DOWN, "D", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
4043
4044   // Render and notify
4045   application.SendNotification();
4046   application.Render();
4047
4048   DALI_TEST_EQUALS(textField.GetProperty(TextField::Property::TEXT).Get<std::string>(), "", TEST_LOCATION);
4049   DALI_TEST_EQUALS(textField.GetProperty(DevelTextField::Property::ENABLE_EDITING).Get<bool>(), false, TEST_LOCATION);
4050
4051   textField.SetKeyInputFocus();
4052   textField.SetProperty(DevelTextField::Property::ENABLE_EDITING, true);
4053   application.ProcessEvent(GenerateKey("D", "", "D", KEY_D_CODE, 0, 0, Integration::KeyEvent::DOWN, "D", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
4054
4055   // Render and notify
4056   application.SendNotification();
4057   application.Render();
4058
4059   DALI_TEST_EQUALS(textField.GetProperty(TextField::Property::TEXT).Get<std::string>(), "D", TEST_LOCATION);
4060   DALI_TEST_EQUALS(textField.GetProperty(DevelTextField::Property::ENABLE_EDITING).Get<bool>(), true, TEST_LOCATION);
4061
4062   // Check the user interaction enabled and for coverage
4063   DevelTextField::SelectWholeText(textField);
4064
4065   // Render and notify
4066   application.SendNotification();
4067   application.Render();
4068
4069   textField.SetKeyInputFocus();
4070   textField.SetProperty(DevelActor::Property::USER_INTERACTION_ENABLED, false);
4071   application.ProcessEvent(GenerateKey("D", "", "D", KEY_D_CODE, 0, 0, Integration::KeyEvent::DOWN, "D", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
4072
4073   // Render and notify
4074   application.SendNotification();
4075   application.Render();
4076
4077   DALI_TEST_EQUALS(textField.GetProperty(TextField::Property::TEXT).Get<std::string>(), "D", TEST_LOCATION);
4078   DALI_TEST_EQUALS(textField.GetProperty(DevelActor::Property::USER_INTERACTION_ENABLED).Get<bool>(), false, TEST_LOCATION);
4079
4080   END_TEST;
4081 }
4082
4083 int UtcDaliToolkitTextFieldFontSizeScale(void)
4084 {
4085   ToolkitTestApplication application;
4086   tet_infoline(" UtcDaliToolkitTextFieldFontSizeScale");
4087
4088   TextField textField = TextField::New();
4089   textField.SetProperty(TextField::Property::POINT_SIZE, 30.f);
4090   textField.SetProperty(TextField::Property::TEXT, "Test");
4091   Vector3 nonScaledSize = textField.GetNaturalSize();
4092
4093   TextField textFieldScaled = TextField::New();
4094   textFieldScaled.SetProperty(TextField::Property::POINT_SIZE, 15.f);
4095   textFieldScaled.SetProperty(Toolkit::DevelTextField::Property::FONT_SIZE_SCALE, 2.f);
4096   textFieldScaled.SetProperty(TextField::Property::TEXT, "Test");
4097   Vector3 scaledSize = textFieldScaled.GetNaturalSize();
4098
4099   DALI_TEST_EQUALS(nonScaledSize, scaledSize, TEST_LOCATION);
4100
4101   textField.SetProperty(TextField::Property::PIXEL_SIZE, 30.f);
4102   textField.SetProperty(TextField::Property::TEXT, "Test");
4103   nonScaledSize = textField.GetNaturalSize();
4104
4105   textFieldScaled.SetProperty(TextField::Property::PIXEL_SIZE, 15.f);
4106   textFieldScaled.SetProperty(Toolkit::DevelTextField::Property::FONT_SIZE_SCALE, 2.f);
4107   textFieldScaled.SetProperty(TextField::Property::TEXT, "Test");
4108   scaledSize = textFieldScaled.GetNaturalSize();
4109
4110   DALI_TEST_EQUALS(nonScaledSize, scaledSize, TEST_LOCATION);
4111
4112   END_TEST;
4113 }
4114
4115 int UtcDaliTextFieldPrimaryCursorPosition(void)
4116 {
4117   ToolkitTestApplication application;
4118   tet_infoline(" UtcDaliTextFieldPrimaryCursorPosition ");
4119
4120   TextField textField = TextField::New();
4121
4122   application.GetScene().Add(textField);
4123
4124   textField.SetProperty(TextField::Property::TEXT, "ABCEF");
4125   textField.SetProperty(Actor::Property::SIZE, Vector2(300.f, 50.f));
4126   textField.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT);
4127   textField.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
4128
4129   // Avoid a crash when core load gl resources.
4130   application.GetGlAbstraction().SetCheckFramebufferStatusResult(GL_FRAMEBUFFER_COMPLETE);
4131
4132   textField.SetProperty(DevelTextField::Property::PRIMARY_CURSOR_POSITION, 3);
4133   application.SendNotification();
4134   application.Render();
4135   textField.SetKeyInputFocus();
4136
4137   application.ProcessEvent(GenerateKey("D", "", "D", KEY_D_CODE, 0, 0, Integration::KeyEvent::DOWN, "D", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
4138
4139   // Render and notify
4140   application.SendNotification();
4141   application.Render();
4142
4143   DALI_TEST_EQUALS(textField.GetProperty(TextField::Property::TEXT).Get<std::string>(), "ABCDEF", TEST_LOCATION);
4144   DALI_TEST_EQUALS(textField.GetProperty(DevelTextField::Property::PRIMARY_CURSOR_POSITION).Get<int>(), 4, TEST_LOCATION);
4145
4146   END_TEST;
4147 }
4148
4149 // test max length when set after setting long text
4150 int utcDaliTextFieldMaxCharactersReachedAfterSetText(void)
4151 {
4152   ToolkitTestApplication application;
4153   tet_infoline(" utcDaliTextFieldMaxCharactersReachedAfterSetText");
4154   TextField field = TextField::New();
4155   DALI_TEST_CHECK(field);
4156
4157   application.GetScene().Add(field);
4158
4159   field.SetProperty(TextField::Property::TEXT, "123456789");
4160
4161   const int maxNumberOfCharacters = 3;
4162   field.SetProperty(TextField::Property::MAX_LENGTH, maxNumberOfCharacters);
4163
4164   field.SetKeyInputFocus();
4165
4166   // connect to the text max lengh reached signal.
4167   ConnectionTracker* testTracker            = new ConnectionTracker();
4168   bool               maxLengthReachedSignal = false;
4169   field.ConnectSignal(testTracker, "maxLengthReached", CallbackFunctor(&maxLengthReachedSignal));
4170
4171   application.ProcessEvent(GenerateKey("a", "", "a", KEY_A_CODE, 0, 0, Integration::KeyEvent::DOWN, "a", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
4172   application.ProcessEvent(GenerateKey("a", "", "a", KEY_A_CODE, 0, 0, Integration::KeyEvent::DOWN, "a", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
4173
4174   DALI_TEST_CHECK(maxLengthReachedSignal);
4175
4176   DALI_TEST_EQUALS(field.GetProperty(TextField::Property::TEXT).Get<std::string>(), "123456789", TEST_LOCATION);
4177
4178   END_TEST;
4179 }
4180
4181 int UtcDaliTextFieldAtlasLimitationIsEnabledForLargeFontPointSize(void)
4182 {
4183   ToolkitTestApplication application;
4184   tet_infoline(" UtcDaliTextFieldAtlasLimitationIsEnabledForLargeFontPointSize ");
4185
4186   // +2: First one to handle the equal case. Second one to handle odd to even case of GetNaturalSize
4187   const uint32_t lessThanWidth  = TextAbstraction::FontClient::MAX_TEXT_ATLAS_WIDTH - TextAbstraction::FontClient::PADDING_TEXT_ATLAS_BLOCK + 2;
4188   const uint32_t lessThanHeight = TextAbstraction::FontClient::MAX_TEXT_ATLAS_HEIGHT - TextAbstraction::FontClient::PADDING_TEXT_ATLAS_BLOCK + 2;
4189
4190   // Create a text field
4191   TextField textField = TextField::New();
4192
4193   //Set size to avoid automatic eliding
4194   textField.SetProperty(Actor::Property::SIZE, Vector2(1025, 1025));
4195   //Set very large font-size using point-size
4196   textField.SetProperty(TextField::Property::POINT_SIZE, 1000);
4197   //Specify font-family
4198   textField.SetProperty(TextField::Property::FONT_FAMILY, "DejaVu Sans");
4199   //Set text to check if appear or not
4200   textField.SetProperty(TextField::Property::TEXT, "A");
4201
4202   application.GetScene().Add(textField);
4203
4204   application.SendNotification();
4205   application.Render();
4206   //Use GetNaturalSize to verify that size of block does not exceed Atlas size
4207   Vector3 naturalSize = textField.GetNaturalSize();
4208
4209   DALI_TEST_GREATER(lessThanWidth, static_cast<uint32_t>(naturalSize.width), TEST_LOCATION);
4210   DALI_TEST_GREATER(lessThanHeight, static_cast<uint32_t>(naturalSize.height), TEST_LOCATION);
4211
4212   END_TEST;
4213 }
4214
4215 int UtcDaliTextFieldAtlasLimitationIsEnabledPerformanceCases(void)
4216 {
4217   ToolkitTestApplication application;
4218   tet_infoline(" UtcDaliTextFieldAtlasLimitationIsEnabledPerformanceCases ");
4219
4220   // +2: First one to handle the equal case. Second one to handle odd to even case of GetNaturalSize
4221   const uint32_t lessThanWidth  = TextAbstraction::FontClient::MAX_TEXT_ATLAS_WIDTH - TextAbstraction::FontClient::PADDING_TEXT_ATLAS_BLOCK + 2;
4222   const uint32_t lessThanHeight = TextAbstraction::FontClient::MAX_TEXT_ATLAS_HEIGHT - TextAbstraction::FontClient::PADDING_TEXT_ATLAS_BLOCK + 2;
4223
4224   Vector3 naturalSize; //Use GetNaturalSize to verify that size of block does not exceed Atlas size
4225   // Create a text editor
4226   TextField textField = TextField::New();
4227
4228   //Set size to avoid automatic eliding
4229   textField.SetProperty(Actor::Property::SIZE, Vector2(1025, 1025));
4230   textField.SetProperty(TextField::Property::FONT_FAMILY, "DejaVu Sans");
4231   textField.SetProperty(TextField::Property::TEXT, "A");
4232
4233   const int numberOfCases             = 6;
4234   int       arrayCases[numberOfCases] = {323, 326, 330, 600, 1630, 2500};
4235
4236   for(int index = 0; index < numberOfCases; index++)
4237   {
4238     tet_printf(" UtcDaliTextFieldAtlasLimitationIsEnabledPerformanceCases point-size= %d \n", arrayCases[index]);
4239     textField.SetProperty(TextField::Property::POINT_SIZE, arrayCases[index]);
4240     application.GetScene().Add(textField);
4241     application.SendNotification();
4242     application.Render();
4243     naturalSize = textField.GetNaturalSize();
4244     DALI_TEST_GREATER(lessThanWidth, static_cast<uint32_t>(naturalSize.width), TEST_LOCATION);
4245     DALI_TEST_GREATER(lessThanHeight, static_cast<uint32_t>(naturalSize.height), TEST_LOCATION);
4246   }
4247
4248   END_TEST;
4249 }
4250
4251 int UtcDaliToolkitTextFieldEllipsisPositionProperty(void)
4252 {
4253   ToolkitTestApplication application;
4254   tet_infoline(" UtcDaliToolkitTextFieldEllipsisPositionProperty ");
4255   TextField textField = TextField::New();
4256
4257   tet_infoline(" UtcDaliToolkitTextFieldEllipsisPositionProperty - Default is END");
4258   DALI_TEST_EQUALS(textField.GetProperty<int>(DevelTextField::Property::ELLIPSIS_POSITION), static_cast<int>(Toolkit::DevelText::EllipsisPosition::END), TEST_LOCATION);
4259
4260   tet_infoline(" UtcDaliToolkitTextFieldEllipsisPositionProperty - Change to START");
4261   textField.SetProperty(DevelTextField::Property::ELLIPSIS_POSITION, DevelText::EllipsisPosition::START);
4262   DALI_TEST_EQUALS(textField.GetProperty<int>(DevelTextField::Property::ELLIPSIS_POSITION), static_cast<int>(Toolkit::DevelText::EllipsisPosition::START), TEST_LOCATION);
4263
4264   tet_infoline(" UtcDaliToolkitTextFieldEllipsisPositionProperty - Change to MIDDLE");
4265   textField.SetProperty(DevelTextField::Property::ELLIPSIS_POSITION, DevelText::EllipsisPosition::MIDDLE);
4266   DALI_TEST_EQUALS(textField.GetProperty<int>(DevelTextField::Property::ELLIPSIS_POSITION), static_cast<int>(Toolkit::DevelText::EllipsisPosition::MIDDLE), TEST_LOCATION);
4267
4268   tet_infoline(" UtcDaliToolkitTextFieldEllipsisPositionProperty - Change to END");
4269   textField.SetProperty(DevelTextField::Property::ELLIPSIS_POSITION, DevelText::EllipsisPosition::END);
4270   DALI_TEST_EQUALS(textField.GetProperty<int>(DevelTextField::Property::ELLIPSIS_POSITION), static_cast<int>(Toolkit::DevelText::EllipsisPosition::END), TEST_LOCATION);
4271
4272   tet_infoline(" UtcDaliToolkitTextFieldEllipsisPositionProperty - Change to START using integer");
4273   textField.SetProperty(DevelTextField::Property::ELLIPSIS_POSITION, 1);
4274   DALI_TEST_EQUALS(textField.GetProperty<int>(DevelTextField::Property::ELLIPSIS_POSITION), static_cast<int>(Toolkit::DevelText::EllipsisPosition::START), TEST_LOCATION);
4275
4276   tet_infoline(" UtcDaliToolkitTextFieldEllipsisPositionProperty - Change to MIDDLE using integer");
4277   textField.SetProperty(DevelTextField::Property::ELLIPSIS_POSITION, 2);
4278   DALI_TEST_EQUALS(textField.GetProperty<int>(DevelTextField::Property::ELLIPSIS_POSITION), static_cast<int>(Toolkit::DevelText::EllipsisPosition::MIDDLE), TEST_LOCATION);
4279
4280   tet_infoline(" UtcDaliToolkitTextFieldEllipsisPositionProperty - Change to END using integer");
4281   textField.SetProperty(DevelTextField::Property::ELLIPSIS_POSITION, 0);
4282   DALI_TEST_EQUALS(textField.GetProperty<int>(DevelTextField::Property::ELLIPSIS_POSITION), static_cast<int>(Toolkit::DevelText::EllipsisPosition::END), TEST_LOCATION);
4283
4284   tet_infoline(" UtcDaliToolkitTextlabelEllipsisPositionProperty - Change to START using string - uppercase");
4285   textField.SetProperty(DevelTextField::Property::ELLIPSIS_POSITION, "START");
4286   DALI_TEST_EQUALS(textField.GetProperty<int>(DevelTextField::Property::ELLIPSIS_POSITION), static_cast<int>(Toolkit::DevelText::EllipsisPosition::START), TEST_LOCATION);
4287
4288   tet_infoline(" UtcDaliToolkitTextlabelEllipsisPositionProperty - Change to MIDDLE using string - uppercase");
4289   textField.SetProperty(DevelTextField::Property::ELLIPSIS_POSITION, "MIDDLE");
4290   DALI_TEST_EQUALS(textField.GetProperty<int>(DevelTextField::Property::ELLIPSIS_POSITION), static_cast<int>(Toolkit::DevelText::EllipsisPosition::MIDDLE), TEST_LOCATION);
4291
4292   tet_infoline(" UtcDaliToolkitTextlabelEllipsisPositionProperty - Change to END using string - uppercase");
4293   textField.SetProperty(DevelTextField::Property::ELLIPSIS_POSITION, "END");
4294   DALI_TEST_EQUALS(textField.GetProperty<int>(DevelTextField::Property::ELLIPSIS_POSITION), static_cast<int>(Toolkit::DevelText::EllipsisPosition::END), TEST_LOCATION);
4295
4296   tet_infoline(" UtcDaliToolkitTextlabelEllipsisPositionProperty - Change to START using string - lowercase");
4297   textField.SetProperty(DevelTextField::Property::ELLIPSIS_POSITION, "start");
4298   DALI_TEST_EQUALS(textField.GetProperty<int>(DevelTextField::Property::ELLIPSIS_POSITION), static_cast<int>(Toolkit::DevelText::EllipsisPosition::START), TEST_LOCATION);
4299
4300   tet_infoline(" UtcDaliToolkitTextlabelEllipsisPositionProperty - Change to MIDDLE using string - lowercase");
4301   textField.SetProperty(DevelTextField::Property::ELLIPSIS_POSITION, "middle");
4302   DALI_TEST_EQUALS(textField.GetProperty<int>(DevelTextField::Property::ELLIPSIS_POSITION), static_cast<int>(Toolkit::DevelText::EllipsisPosition::MIDDLE), TEST_LOCATION);
4303
4304   tet_infoline(" UtcDaliToolkitTextlabelEllipsisPositionProperty - Change to END using string - lowercase");
4305   textField.SetProperty(DevelTextField::Property::ELLIPSIS_POSITION, "end");
4306   DALI_TEST_EQUALS(textField.GetProperty<int>(DevelTextField::Property::ELLIPSIS_POSITION), static_cast<int>(Toolkit::DevelText::EllipsisPosition::END), TEST_LOCATION);
4307
4308   END_TEST;
4309 }
4310
4311 int UtcDaliTextFieldCopyText(void)
4312 {
4313   ToolkitTestApplication application;
4314   tet_infoline(" UtcDaliTextFieldCopyText ");
4315
4316   TextField textField = TextField::New();
4317
4318   std::string selectedText = "";
4319   std::string copiedText   = "";
4320
4321   application.GetScene().Add(textField);
4322
4323   textField.SetProperty(Actor::Property::SIZE, Vector2(300.f, 50.f));
4324   textField.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT);
4325   textField.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
4326
4327   // Avoid a crash when core load gl resources.
4328   application.GetGlAbstraction().SetCheckFramebufferStatusResult(GL_FRAMEBUFFER_COMPLETE);
4329
4330   application.SendNotification();
4331   application.Render();
4332
4333   textField.SetProperty(TextField::Property::TEXT, "Hello world");
4334
4335   application.SendNotification();
4336   application.Render();
4337
4338   // Hello is selected
4339   DevelTextField::SelectText(textField, 0, 5);
4340
4341   application.SendNotification();
4342   application.Render();
4343
4344   selectedText = textField.GetProperty(DevelTextField::Property::SELECTED_TEXT).Get<std::string>();
4345   DALI_TEST_EQUALS("Hello", selectedText, TEST_LOCATION);
4346
4347   DALI_TEST_EQUALS(textField.GetProperty(DevelTextField::Property::SELECTED_TEXT_START).Get<int>(), 0, TEST_LOCATION);
4348   DALI_TEST_EQUALS(textField.GetProperty(DevelTextField::Property::SELECTED_TEXT_END).Get<int>(), 5, TEST_LOCATION);
4349
4350   // Hello is copied
4351   copiedText = DevelTextField::CopyText(textField);
4352   DALI_TEST_EQUALS("Hello", copiedText, TEST_LOCATION);
4353
4354   // world is selected
4355   DevelTextField::SelectText(textField, 6, 11);
4356
4357   application.SendNotification();
4358   application.Render();
4359
4360   selectedText = textField.GetProperty(DevelTextField::Property::SELECTED_TEXT).Get<std::string>();
4361   DALI_TEST_EQUALS("world", selectedText, TEST_LOCATION);
4362
4363   DALI_TEST_EQUALS(textField.GetProperty(DevelTextField::Property::SELECTED_TEXT_START).Get<int>(), 6, TEST_LOCATION);
4364   DALI_TEST_EQUALS(textField.GetProperty(DevelTextField::Property::SELECTED_TEXT_END).Get<int>(), 11, TEST_LOCATION);
4365
4366   // world is copied
4367   copiedText = DevelTextField::CopyText(textField);
4368   DALI_TEST_EQUALS("world", copiedText, TEST_LOCATION);
4369
4370   // "lo wo" is selected
4371   DevelTextField::SelectText(textField, 3, 8);
4372
4373   application.SendNotification();
4374   application.Render();
4375
4376   selectedText = textField.GetProperty(DevelTextField::Property::SELECTED_TEXT).Get<std::string>();
4377   DALI_TEST_EQUALS("lo wo", selectedText, TEST_LOCATION);
4378
4379   DALI_TEST_EQUALS(textField.GetProperty(DevelTextField::Property::SELECTED_TEXT_START).Get<int>(), 3, TEST_LOCATION);
4380   DALI_TEST_EQUALS(textField.GetProperty(DevelTextField::Property::SELECTED_TEXT_END).Get<int>(), 8, TEST_LOCATION);
4381
4382   // "lo wo" is copied
4383   copiedText = DevelTextField::CopyText(textField);
4384   DALI_TEST_EQUALS("lo wo", copiedText, TEST_LOCATION);
4385
4386   END_TEST;
4387 }
4388
4389 int UtcDaliTextFieldCutText(void)
4390 {
4391   ToolkitTestApplication application;
4392   tet_infoline(" UtcDaliTextFieldCutText ");
4393
4394   TextField textField = TextField::New();
4395
4396   std::string selectedText = "";
4397
4398   application.GetScene().Add(textField);
4399
4400   textField.SetProperty(Actor::Property::SIZE, Vector2(300.f, 50.f));
4401   textField.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT);
4402   textField.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
4403
4404   // Avoid a crash when core load gl resources.
4405   application.GetGlAbstraction().SetCheckFramebufferStatusResult(GL_FRAMEBUFFER_COMPLETE);
4406
4407   application.SendNotification();
4408   application.Render();
4409
4410   textField.SetProperty(TextField::Property::TEXT, "Hello world");
4411
4412   application.SendNotification();
4413   application.Render();
4414
4415   // Hello is selected
4416   DevelTextField::SelectText(textField, 0, 5);
4417
4418   application.SendNotification();
4419   application.Render();
4420
4421   selectedText = textField.GetProperty(DevelTextField::Property::SELECTED_TEXT).Get<std::string>();
4422   DALI_TEST_EQUALS("Hello", selectedText, TEST_LOCATION);
4423
4424   DALI_TEST_EQUALS(textField.GetProperty(DevelTextField::Property::SELECTED_TEXT_START).Get<int>(), 0, TEST_LOCATION);
4425   DALI_TEST_EQUALS(textField.GetProperty(DevelTextField::Property::SELECTED_TEXT_END).Get<int>(), 5, TEST_LOCATION);
4426
4427   // Hello is cut
4428   DALI_TEST_EQUALS("Hello", DevelTextField::CutText(textField), TEST_LOCATION);
4429
4430   DALI_TEST_EQUALS(textField.GetProperty(TextField::Property::TEXT).Get<std::string>(), " world", TEST_LOCATION);
4431
4432   // " w" is selected
4433   DevelTextField::SelectText(textField, 0, 2);
4434
4435   application.SendNotification();
4436   application.Render();
4437
4438   selectedText = textField.GetProperty(DevelTextField::Property::SELECTED_TEXT).Get<std::string>();
4439   DALI_TEST_EQUALS(" w", selectedText, TEST_LOCATION);
4440
4441   DALI_TEST_EQUALS(textField.GetProperty(DevelTextField::Property::SELECTED_TEXT_START).Get<int>(), 0, TEST_LOCATION);
4442   DALI_TEST_EQUALS(textField.GetProperty(DevelTextField::Property::SELECTED_TEXT_END).Get<int>(), 2, TEST_LOCATION);
4443
4444   // " w" is cut
4445   DALI_TEST_EQUALS(" w", DevelTextField::CutText(textField), TEST_LOCATION);
4446
4447   application.SendNotification();
4448   application.Render();
4449
4450   DALI_TEST_EQUALS(textField.GetProperty(TextField::Property::TEXT).Get<std::string>(), "orld", TEST_LOCATION);
4451
4452   // Test Cut from the middle
4453
4454   // "rl" is selected
4455   DevelTextField::SelectText(textField, 1, 3);
4456
4457   application.SendNotification();
4458   application.Render();
4459
4460   selectedText = textField.GetProperty(DevelTextField::Property::SELECTED_TEXT).Get<std::string>();
4461   DALI_TEST_EQUALS("rl", selectedText, TEST_LOCATION);
4462
4463   DALI_TEST_EQUALS(textField.GetProperty(DevelTextField::Property::SELECTED_TEXT_START).Get<int>(), 1, TEST_LOCATION);
4464   DALI_TEST_EQUALS(textField.GetProperty(DevelTextField::Property::SELECTED_TEXT_END).Get<int>(), 3, TEST_LOCATION);
4465
4466   // "rl" is cut
4467   DALI_TEST_EQUALS("rl", DevelTextField::CutText(textField), TEST_LOCATION);
4468
4469   application.SendNotification();
4470   application.Render();
4471
4472   DALI_TEST_EQUALS(textField.GetProperty(TextField::Property::TEXT).Get<std::string>(), "od", TEST_LOCATION);
4473
4474   // Test Cut from the end
4475
4476   // "d" is selected
4477   DevelTextField::SelectText(textField, 1, 2);
4478
4479   application.SendNotification();
4480   application.Render();
4481
4482   selectedText = textField.GetProperty(DevelTextField::Property::SELECTED_TEXT).Get<std::string>();
4483   DALI_TEST_EQUALS("d", selectedText, TEST_LOCATION);
4484
4485   DALI_TEST_EQUALS(textField.GetProperty(DevelTextField::Property::SELECTED_TEXT_START).Get<int>(), 1, TEST_LOCATION);
4486   DALI_TEST_EQUALS(textField.GetProperty(DevelTextField::Property::SELECTED_TEXT_END).Get<int>(), 2, TEST_LOCATION);
4487
4488   // "d" is cut
4489   DALI_TEST_EQUALS("d", DevelTextField::CutText(textField), TEST_LOCATION);
4490
4491   application.SendNotification();
4492   application.Render();
4493
4494   DALI_TEST_EQUALS(textField.GetProperty(TextField::Property::TEXT).Get<std::string>(), "o", TEST_LOCATION);
4495
4496   END_TEST;
4497 }
4498
4499 int UtcDaliTextFieldPasteText(void)
4500 {
4501   ToolkitTestApplication application;
4502   tet_infoline(" UtcDaliTextFieldPasteText ");
4503
4504   TextField textField = TextField::New();
4505
4506   application.GetScene().Add(textField);
4507
4508   std::string cutText    = "";
4509   std::string copiedText = "";
4510
4511   textField.SetProperty(Actor::Property::SIZE, Vector2(300.f, 50.f));
4512   textField.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT);
4513   textField.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
4514
4515   // Avoid a crash when core load gl resources.
4516   application.GetGlAbstraction().SetCheckFramebufferStatusResult(GL_FRAMEBUFFER_COMPLETE);
4517
4518   application.SendNotification();
4519   application.Render();
4520
4521   textField.SetProperty(TextField::Property::TEXT, "Hello World");
4522
4523   application.SendNotification();
4524   application.Render();
4525
4526   // Tap on the text editor
4527   TestGenerateTap(application, 3.0f, 25.0f);
4528
4529   // Render and notify
4530   application.SendNotification();
4531   application.Render();
4532
4533   // Select some text in the right of the current cursor position
4534   DevelTextField::SelectText(textField, 0, 3);
4535
4536   // Render and notify
4537   application.SendNotification();
4538   application.Render();
4539
4540   // Cut the selected text
4541   cutText = DevelTextField::CutText(textField);
4542
4543   // Render and notify
4544   application.SendNotification();
4545   application.Render();
4546
4547   DALI_TEST_EQUALS("Hel", cutText, TEST_LOCATION);
4548   DALI_TEST_EQUALS(textField.GetProperty(TextField::Property::TEXT).Get<std::string>(), "lo World", TEST_LOCATION);
4549
4550   DevelTextField::SelectText(textField, 0, 3);
4551
4552   // Render and notify
4553   application.SendNotification();
4554   application.Render();
4555
4556   // Copy the selected text
4557   copiedText = DevelTextField::CopyText(textField);
4558
4559   // Render and notify
4560   application.SendNotification();
4561   application.Render();
4562
4563   DALI_TEST_EQUALS("lo ", copiedText, TEST_LOCATION);
4564   DALI_TEST_EQUALS("lo World", textField.GetProperty<std::string>(TextField::Property::TEXT), TEST_LOCATION);
4565
4566   // Move the cursor to the end of the line
4567   application.ProcessEvent(GenerateKey("", "", "", DALI_KEY_CURSOR_RIGHT, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
4568   application.ProcessEvent(GenerateKey("", "", "", DALI_KEY_CURSOR_RIGHT, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
4569   application.ProcessEvent(GenerateKey("", "", "", DALI_KEY_CURSOR_RIGHT, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
4570   application.ProcessEvent(GenerateKey("", "", "", DALI_KEY_CURSOR_RIGHT, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
4571   application.ProcessEvent(GenerateKey("", "", "", DALI_KEY_CURSOR_RIGHT, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
4572   application.ProcessEvent(GenerateKey("", "", "", DALI_KEY_CURSOR_RIGHT, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
4573   application.ProcessEvent(GenerateKey("", "", "", DALI_KEY_CURSOR_RIGHT, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
4574   application.ProcessEvent(GenerateKey("", "", "", DALI_KEY_CURSOR_RIGHT, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
4575
4576   // Render and notify
4577   application.SendNotification();
4578   application.Render();
4579
4580   // Paste the selected text at the current cursor position
4581   DevelTextField::PasteText(textField);
4582
4583   // Render and notify
4584   application.SendNotification();
4585   application.Render();
4586
4587   DALI_TEST_EQUALS(textField.GetProperty(TextField::Property::TEXT).Get<std::string>(), "lo Worldlo ", TEST_LOCATION);
4588
4589   END_TEST;
4590 }
4591
4592 int utcDaliTextFieldCursorPositionChangedSignal(void)
4593 {
4594   ToolkitTestApplication application;
4595   tet_infoline(" utcDaliTextFieldCursorPositionChangedSignal");
4596
4597   TextField field = TextField::New();
4598   DALI_TEST_CHECK(field);
4599
4600   application.GetScene().Add(field);
4601
4602   // connect to the selection changed signal.
4603   ConnectionTracker* testTracker = new ConnectionTracker();
4604   DevelTextField::CursorPositionChangedSignal(field).Connect(&TestCursorPositionChangedCallback);
4605   bool cursorPositionChangedSignal = false;
4606   field.ConnectSignal(testTracker, "cursorPositionChanged", CallbackFunctor(&cursorPositionChangedSignal));
4607
4608   field.SetProperty(TextField::Property::TEXT, "Hello world Hello world");
4609   field.SetProperty(TextField::Property::POINT_SIZE, 10.f);
4610   field.SetProperty(Actor::Property::SIZE, Vector2(100.f, 50.f));
4611   field.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT);
4612   field.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
4613
4614   // Avoid a crash when core load gl resources.
4615   application.GetGlAbstraction().SetCheckFramebufferStatusResult(GL_FRAMEBUFFER_COMPLETE);
4616
4617   // Render and notify
4618   application.SendNotification();
4619   application.Render();
4620
4621   field.SetKeyInputFocus();
4622
4623   // Tap on the text field
4624   TestGenerateTap(application, 3.0f, 25.0f);
4625
4626   // Render and notify
4627   application.SendNotification();
4628   application.Render();
4629
4630   DALI_TEST_CHECK(gCursorPositionChangedCallbackCalled);
4631   DALI_TEST_EQUALS(oldCursorPos, 23, TEST_LOCATION);
4632
4633   gCursorPositionChangedCallbackCalled = false;
4634
4635   // Move to left.
4636   application.ProcessEvent(GenerateKey("", "", "", DALI_KEY_CURSOR_LEFT, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
4637
4638   // Render and notify
4639   application.SendNotification();
4640   application.Render();
4641
4642   DALI_TEST_CHECK(gCursorPositionChangedCallbackCalled);
4643   DALI_TEST_EQUALS(oldCursorPos, 17, TEST_LOCATION);
4644
4645   gCursorPositionChangedCallbackCalled = false;
4646
4647   // Insert D
4648   application.ProcessEvent(GenerateKey("D", "", "D", KEY_D_CODE, 0, 0, Integration::KeyEvent::DOWN, "D", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
4649
4650   // Render and notify
4651   application.SendNotification();
4652   application.Render();
4653
4654   DALI_TEST_CHECK(gCursorPositionChangedCallbackCalled);
4655   DALI_TEST_EQUALS(oldCursorPos, 16, TEST_LOCATION);
4656
4657   gCursorPositionChangedCallbackCalled = false;
4658
4659   //delete one character
4660   application.ProcessEvent(GenerateKey("", "", "", DALI_KEY_BACKSPACE, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
4661
4662   // Render and notify
4663   application.SendNotification();
4664   application.Render();
4665
4666   DALI_TEST_CHECK(gCursorPositionChangedCallbackCalled);
4667   DALI_TEST_EQUALS(oldCursorPos, 17, TEST_LOCATION);
4668
4669   gCursorPositionChangedCallbackCalled = false;
4670
4671   field.SetProperty(TextField::Property::TEXT, "Hello");
4672
4673   // Render and notify
4674   application.SendNotification();
4675   application.Render();
4676
4677   DALI_TEST_CHECK(gCursorPositionChangedCallbackCalled);
4678   DALI_TEST_EQUALS(oldCursorPos, 16, TEST_LOCATION);
4679
4680   gCursorPositionChangedCallbackCalled = false;
4681
4682   field.SetProperty(DevelTextField::Property::PRIMARY_CURSOR_POSITION, 3);
4683
4684   // Render and notify
4685   application.SendNotification();
4686   application.Render();
4687
4688   DALI_TEST_CHECK(gCursorPositionChangedCallbackCalled);
4689   DALI_TEST_EQUALS(oldCursorPos, 5, TEST_LOCATION);
4690
4691   END_TEST;
4692 }
4693
4694 int utcDaliTextFieldGeometryEllipsisStart(void)
4695 {
4696   ToolkitTestApplication application;
4697   tet_infoline(" utcDaliTextFieldGeometryEllipsisStart");
4698
4699   TextField field = TextField::New();
4700   DALI_TEST_CHECK(field);
4701
4702   application.GetScene().Add(field);
4703
4704   field.SetProperty(TextField::Property::POINT_SIZE, 7.f);
4705   field.SetProperty(Actor::Property::SIZE, Vector2(250.f, 50.f));
4706   field.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT);
4707   field.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
4708   field.SetProperty(TextField::Property::ENABLE_MARKUP, true);
4709   field.SetProperty(DevelTextField::Property::ELLIPSIS, true);
4710   field.SetProperty(DevelTextField::Property::ELLIPSIS_POSITION, DevelText::EllipsisPosition::START);
4711   field.SetProperty(TextField::Property::TEXT, "Hello World");
4712
4713   // Avoid a crash when core load gl resources.
4714   application.GetGlAbstraction().SetCheckFramebufferStatusResult(GL_FRAMEBUFFER_COMPLETE);
4715
4716   // Render and notify
4717   application.SendNotification();
4718   application.Render();
4719
4720   unsigned int expectedCount = 1;
4721   unsigned int startIndex    = 0;
4722   unsigned int endIndex      = 10;
4723
4724   Vector<Vector2> positionsList = DevelTextField::GetTextPosition(field, startIndex, endIndex);
4725   Vector<Vector2> sizeList      = DevelTextField::GetTextSize(field, startIndex, endIndex);
4726
4727   DALI_TEST_EQUALS(positionsList.Size(), expectedCount, TEST_LOCATION);
4728   DALI_TEST_EQUALS(sizeList.Size(), expectedCount, TEST_LOCATION);
4729
4730   Vector<Vector2> expectedSizes;
4731   Vector<Vector2> expectedPositions;
4732
4733   expectedPositions.PushBack(Vector2(14, 0));
4734   expectedSizes.PushBack(Vector2(106, 25));
4735
4736   TestTextGeometryUtils::CheckGeometryResult(positionsList, sizeList, expectedPositions, expectedSizes);
4737
4738   END_TEST;
4739 }
4740
4741 int utcDaliTextFieldGeometryEllipsisEnd(void)
4742 {
4743   ToolkitTestApplication application;
4744   tet_infoline(" utcDaliTextFieldGeometryEllipsisEnd");
4745
4746   TextField field = TextField::New();
4747   DALI_TEST_CHECK(field);
4748
4749   application.GetScene().Add(field);
4750
4751   field.SetProperty(TextField::Property::POINT_SIZE, 7.f);
4752   field.SetProperty(Actor::Property::SIZE, Vector2(250.f, 50.f));
4753   field.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT);
4754   field.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
4755   field.SetProperty(TextField::Property::ENABLE_MARKUP, true);
4756   field.SetProperty(DevelTextField::Property::ELLIPSIS, true);
4757   field.SetProperty(DevelTextField::Property::ELLIPSIS_POSITION, DevelText::EllipsisPosition::END);
4758   field.SetProperty(TextField::Property::TEXT, "Hello World");
4759
4760   // Avoid a crash when core load gl resources.
4761   application.GetGlAbstraction().SetCheckFramebufferStatusResult(GL_FRAMEBUFFER_COMPLETE);
4762
4763   // Render and notify
4764   application.SendNotification();
4765   application.Render();
4766
4767   unsigned int expectedCount = 1;
4768   unsigned int startIndex    = 0;
4769   unsigned int endIndex      = 10;
4770
4771   Vector<Vector2> positionsList = DevelTextField::GetTextPosition(field, startIndex, endIndex);
4772   Vector<Vector2> sizeList      = DevelTextField::GetTextSize(field, startIndex, endIndex);
4773
4774   DALI_TEST_EQUALS(positionsList.Size(), expectedCount, TEST_LOCATION);
4775   DALI_TEST_EQUALS(sizeList.Size(), expectedCount, TEST_LOCATION);
4776
4777   Vector<Vector2> expectedSizes;
4778   Vector<Vector2> expectedPositions;
4779
4780   expectedPositions.PushBack(Vector2(-2, 0));
4781   expectedSizes.PushBack(Vector2(122, 25));
4782
4783   TestTextGeometryUtils::CheckGeometryResult(positionsList, sizeList, expectedPositions, expectedSizes);
4784
4785   END_TEST;
4786 }
4787
4788 int utcDaliTextFieldGeometryRTL(void)
4789 {
4790   ToolkitTestApplication application;
4791   tet_infoline(" utcDaliTextFieldGeometryRTL");
4792
4793   TextField field = TextField::New();
4794   DALI_TEST_CHECK(field);
4795
4796   application.GetScene().Add(field);
4797
4798   field.SetProperty(TextField::Property::POINT_SIZE, 7.f);
4799   field.SetProperty(Actor::Property::SIZE, Vector2(300.f, 50.f));
4800   field.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT);
4801   field.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
4802   field.SetProperty(TextField::Property::ENABLE_MARKUP, true);
4803   field.SetProperty(TextField::Property::TEXT, "السطر الاخير");
4804
4805   // Avoid a crash when core load gl resources.
4806   application.GetGlAbstraction().SetCheckFramebufferStatusResult(GL_FRAMEBUFFER_COMPLETE);
4807
4808   // Render and notify
4809   application.SendNotification();
4810   application.Render();
4811
4812   unsigned int expectedCount = 1;
4813   unsigned int startIndex    = 1;
4814   unsigned int endIndex      = 7;
4815
4816   Vector<Vector2> positionsList = DevelTextField::GetTextPosition(field, startIndex, endIndex);
4817   Vector<Vector2> sizeList      = DevelTextField::GetTextSize(field, startIndex, endIndex);
4818
4819   DALI_TEST_EQUALS(positionsList.Size(), expectedCount, TEST_LOCATION);
4820   DALI_TEST_EQUALS(sizeList.Size(), expectedCount, TEST_LOCATION);
4821
4822   Vector<Vector2> expectedSizes;
4823   Vector<Vector2> expectedPositions;
4824
4825   expectedPositions.PushBack(Vector2(38, 0));
4826   expectedSizes.PushBack(Vector2(73, 25));
4827
4828   TestTextGeometryUtils::CheckGeometryResult(positionsList, sizeList, expectedPositions, expectedSizes);
4829
4830   END_TEST;
4831 }
4832
4833 int utcDaliTextFieldGeometryGlyphMiddle(void)
4834 {
4835   ToolkitTestApplication application;
4836   tet_infoline(" utcDaliTextFieldGeometryGlyphMiddle");
4837
4838   TextField field = TextField::New();
4839   DALI_TEST_CHECK(field);
4840
4841   application.GetScene().Add(field);
4842
4843   field.SetProperty(TextField::Property::POINT_SIZE, 7.f);
4844   field.SetProperty(Actor::Property::SIZE, Vector2(150.f, 200.f));
4845   field.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT);
4846   field.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
4847   field.SetProperty(TextField::Property::ENABLE_MARKUP, true);
4848   field.SetProperty(TextField::Property::TEXT, "لا تحتوي على لا");
4849
4850   // Avoid a crash when core load gl resources.
4851   application.GetGlAbstraction().SetCheckFramebufferStatusResult(GL_FRAMEBUFFER_COMPLETE);
4852
4853   // Render and notify
4854   application.SendNotification();
4855   application.Render();
4856
4857   unsigned int expectedCount = 1;
4858   unsigned int startIndex    = 1;
4859   unsigned int endIndex      = 13;
4860
4861   Vector<Vector2> positionsList = DevelTextField::GetTextPosition(field, startIndex, endIndex);
4862   Vector<Vector2> sizeList      = DevelTextField::GetTextSize(field, startIndex, endIndex);
4863
4864   DALI_TEST_EQUALS(positionsList.Size(), expectedCount, TEST_LOCATION);
4865   DALI_TEST_EQUALS(sizeList.Size(), expectedCount, TEST_LOCATION);
4866
4867   Vector<Vector2> expectedSizes;
4868   Vector<Vector2> expectedPositions;
4869
4870   expectedPositions.PushBack(Vector2(6, 0));
4871   expectedSizes.PushBack(Vector2(124, 25));
4872
4873   TestTextGeometryUtils::CheckGeometryResult(positionsList, sizeList, expectedPositions, expectedSizes);
4874
4875   END_TEST;
4876 }
4877
4878 int utcDaliTextFieldSelectionClearedSignal(void)
4879 {
4880   ToolkitTestApplication application;
4881   tet_infoline(" utcDaliTextFieldSelectionClearedSignal");
4882
4883   TextField field = TextField::New();
4884   DALI_TEST_CHECK(field);
4885
4886   application.GetScene().Add(field);
4887
4888   // connect to the selection changed signal.
4889   ConnectionTracker* testTracker = new ConnectionTracker();
4890   DevelTextField::SelectionClearedSignal(field).Connect(&TestSelectionClearedCallback);
4891   bool selectionClearedSignal = false;
4892   field.ConnectSignal(testTracker, "selectionCleared", CallbackFunctor(&selectionClearedSignal));
4893
4894   field.SetProperty(TextField::Property::TEXT, "Hello\nworld\nHello world");
4895   field.SetProperty(TextField::Property::POINT_SIZE, 10.f);
4896   field.SetProperty(Actor::Property::SIZE, Vector2(100.f, 50.f));
4897   field.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT);
4898   field.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
4899
4900   // Avoid a crash when core load gl resources.
4901   application.GetGlAbstraction().SetCheckFramebufferStatusResult(GL_FRAMEBUFFER_COMPLETE);
4902
4903   // Render and notify
4904   application.SendNotification();
4905   application.Render();
4906
4907   // Tap on the text editor
4908   TestGenerateTap(application, 3.0f, 25.0f);
4909
4910   // Render and notify
4911   application.SendNotification();
4912   application.Render();
4913
4914   // Move to second line of the text & Select some text in the right of the current cursor position
4915   application.ProcessEvent(GenerateKey("", "", "", DALI_KEY_CURSOR_DOWN, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
4916   application.ProcessEvent(GenerateKey("", "", "", DALI_KEY_CURSOR_RIGHT, KEY_SHIFT_MODIFIER, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
4917
4918   // remove selection
4919   application.ProcessEvent(GenerateKey("", "", "", DALI_KEY_ESCAPE, 0, 0, Integration::KeyEvent::UP, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
4920
4921   // Render and notify
4922   application.SendNotification();
4923   application.Render();
4924
4925   DALI_TEST_CHECK(gSelectionClearedCallbackCalled);
4926
4927   // Render and notify
4928   application.SendNotification();
4929   application.Render();
4930
4931   // Tap on the text editor
4932   TestGenerateTap(application, 3.0f, 25.0f);
4933
4934   // Render and notify
4935   application.SendNotification();
4936   application.Render();
4937
4938   gSelectionClearedCallbackCalled = false;
4939
4940   // Move to second line of the text & select.
4941   application.ProcessEvent(GenerateKey("", "", "", DALI_KEY_CURSOR_DOWN, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
4942   application.ProcessEvent(GenerateKey("", "", "", DALI_KEY_CURSOR_RIGHT, KEY_SHIFT_MODIFIER, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
4943
4944   //remove selection
4945   application.ProcessEvent(GenerateKey("", "", "", DALI_KEY_CURSOR_RIGHT, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
4946
4947   // Render and notify
4948   application.SendNotification();
4949   application.Render();
4950
4951   DALI_TEST_CHECK(gSelectionClearedCallbackCalled);
4952
4953   gSelectionClearedCallbackCalled = false;
4954
4955   // Render and notify
4956   application.SendNotification();
4957   application.Render();
4958
4959   // Move to second line of the text & select.
4960   application.ProcessEvent(GenerateKey("", "", "", DALI_KEY_CURSOR_DOWN, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
4961   application.ProcessEvent(GenerateKey("", "", "", DALI_KEY_CURSOR_RIGHT, KEY_SHIFT_MODIFIER, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
4962
4963   // replace D with selected text
4964   application.ProcessEvent(GenerateKey("D", "", "D", KEY_D_CODE, 0, 0, Integration::KeyEvent::DOWN, "D", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
4965
4966   // Render and notify
4967   application.SendNotification();
4968   application.Render();
4969
4970   DALI_TEST_CHECK(gSelectionClearedCallbackCalled);
4971
4972   gSelectionClearedCallbackCalled = false;
4973
4974   // Render and notify
4975   application.SendNotification();
4976   application.Render();
4977
4978   DevelTextField::SelectText(field, 1, 3);
4979
4980   // Render and notify
4981   application.SendNotification();
4982   application.Render();
4983
4984   field.SetProperty(DevelTextField::Property::PRIMARY_CURSOR_POSITION, 3);
4985
4986   // Render and notify
4987   application.SendNotification();
4988   application.Render();
4989
4990   DALI_TEST_CHECK(gSelectionClearedCallbackCalled);
4991
4992   gSelectionClearedCallbackCalled = false;
4993
4994   DevelTextField::SelectText(field, 1, 3);
4995
4996   // Render and notify
4997   application.SendNotification();
4998   application.Render();
4999
5000   // select none
5001   DevelTextField::SelectNone(field);
5002
5003   // Render and notify
5004   application.SendNotification();
5005   application.Render();
5006
5007   DALI_TEST_CHECK(gSelectionClearedCallbackCalled);
5008
5009   END_TEST;
5010 }
5011
5012 int utcDaliTextFieldSelectionStartedSignal(void)
5013 {
5014   ToolkitTestApplication application;
5015   tet_infoline(" utcDaliTextFieldSelectionStartedSignal");
5016
5017   TextField field = TextField::New();
5018   DALI_TEST_CHECK(field);
5019
5020   application.GetScene().Add(field);
5021
5022   // connect to the selection changed signal.
5023   ConnectionTracker* testTracker = new ConnectionTracker();
5024   DevelTextField::SelectionStartedSignal(field).Connect(&TestSelectionStartedCallback);
5025   bool selectionStartedSignal = false;
5026   field.ConnectSignal(testTracker, "selectionStarted", CallbackFunctor(&selectionStartedSignal));
5027
5028   field.SetProperty(TextField::Property::TEXT, "Hello\nworld\nHello world");
5029   field.SetProperty(TextField::Property::POINT_SIZE, 10.f);
5030   field.SetProperty(Actor::Property::SIZE, Vector2(100.f, 50.f));
5031   field.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT);
5032   field.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
5033
5034   // Avoid a crash when core load gl resources.
5035   application.GetGlAbstraction().SetCheckFramebufferStatusResult(GL_FRAMEBUFFER_COMPLETE);
5036
5037   // Render and notify
5038   application.SendNotification();
5039   application.Render();
5040
5041   // Tap on the text field
5042   TestGenerateTap(application, 3.0f, 25.0f);
5043
5044   // Render and notify
5045   application.SendNotification();
5046   application.Render();
5047
5048   // Move to second line of the text & Select some text in the right of the current cursor position
5049   application.ProcessEvent(GenerateKey("", "", "", DALI_KEY_CURSOR_DOWN, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
5050   application.ProcessEvent(GenerateKey("", "", "", DALI_KEY_CURSOR_RIGHT, KEY_SHIFT_MODIFIER, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
5051
5052   // Render and notify
5053   application.SendNotification();
5054   application.Render();
5055
5056   DALI_TEST_CHECK(gSelectionStartedCallbackCalled);
5057
5058   // remove selection
5059   application.ProcessEvent(GenerateKey("", "", "", DALI_KEY_ESCAPE, 0, 0, Integration::KeyEvent::UP, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
5060
5061   // Render and notify
5062   application.SendNotification();
5063   application.Render();
5064
5065   gSelectionStartedCallbackCalled = false;
5066
5067   DevelTextField::SelectText(field, 1, 3);
5068
5069   // Render and notify
5070   application.SendNotification();
5071   application.Render();
5072
5073   DALI_TEST_CHECK(gSelectionStartedCallbackCalled);
5074
5075   END_TEST;
5076 }
5077
5078 int utcDaliTextFieldSelectionChangedSignal(void)
5079 {
5080   ToolkitTestApplication application;
5081   tet_infoline(" utcDaliTextFieldSelectionChangedSignal");
5082
5083   TextField field = TextField::New();
5084   DALI_TEST_CHECK(field);
5085
5086   application.GetScene().Add(field);
5087
5088   // connect to the selection changed signal.
5089   ConnectionTracker* testTracker = new ConnectionTracker();
5090   DevelTextField::SelectionChangedSignal(field).Connect(&TestSelectionChangedCallback);
5091   bool selectionChangedSignal = false;
5092   field.ConnectSignal(testTracker, "selectionChanged", CallbackFunctor(&selectionChangedSignal));
5093
5094   field.SetProperty(TextField::Property::TEXT, "Hello world Hello world");
5095   field.SetProperty(TextField::Property::POINT_SIZE, 10.f);
5096   field.SetProperty(Actor::Property::SIZE, Vector2(100.f, 50.f));
5097   field.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT);
5098   field.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
5099
5100   // Avoid a crash when core load gl resources.
5101   application.GetGlAbstraction().SetCheckFramebufferStatusResult(GL_FRAMEBUFFER_COMPLETE);
5102
5103   // Render and notify
5104   application.SendNotification();
5105   application.Render();
5106
5107   // Tap on the text field
5108   TestGenerateTap(application, 3.0f, 25.0f);
5109
5110   // Render and notify
5111   application.SendNotification();
5112   application.Render();
5113
5114   // Select some text in the right of the current cursor position
5115   application.ProcessEvent(GenerateKey("", "", "", DALI_KEY_SHIFT_LEFT, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
5116   application.ProcessEvent(GenerateKey("", "", "", DALI_KEY_CURSOR_RIGHT, KEY_SHIFT_MODIFIER, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
5117
5118   // Render and notify
5119   application.SendNotification();
5120   application.Render();
5121
5122   DALI_TEST_CHECK(gSelectionChangedCallbackCalled);
5123   DALI_TEST_EQUALS(oldSelectionStart, oldSelectionEnd, TEST_LOCATION);
5124
5125   gSelectionChangedCallbackCalled = false;
5126
5127   application.ProcessEvent(GenerateKey("", "", "", DALI_KEY_CURSOR_RIGHT, KEY_SHIFT_MODIFIER, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
5128
5129   // Render and notify
5130   application.SendNotification();
5131   application.Render();
5132
5133   DALI_TEST_CHECK(gSelectionChangedCallbackCalled);
5134   DALI_TEST_EQUALS(oldSelectionStart, 0, TEST_LOCATION);
5135   DALI_TEST_EQUALS(oldSelectionEnd, 1, TEST_LOCATION);
5136
5137   gSelectionChangedCallbackCalled = false;
5138
5139   application.ProcessEvent(GenerateKey("", "", "", DALI_KEY_ESCAPE, 0, 0, Integration::KeyEvent::UP, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
5140
5141   // Render and notify
5142   application.SendNotification();
5143   application.Render();
5144
5145   DALI_TEST_CHECK(gSelectionChangedCallbackCalled);
5146   DALI_TEST_EQUALS(oldSelectionStart, 0, TEST_LOCATION);
5147   DALI_TEST_EQUALS(oldSelectionEnd, 2, TEST_LOCATION);
5148
5149   gSelectionChangedCallbackCalled = false;
5150   field.SetKeyInputFocus();
5151
5152   // Render and notify
5153   application.SendNotification();
5154   application.Render();
5155
5156   DevelTextField::SelectText(field, 0, 5);
5157
5158   application.SendNotification();
5159   application.Render();
5160
5161   DALI_TEST_CHECK(gSelectionChangedCallbackCalled);
5162   DALI_TEST_EQUALS(oldSelectionStart, oldSelectionEnd, TEST_LOCATION);
5163
5164   gSelectionChangedCallbackCalled = false;
5165
5166   field.SetProperty(DevelTextField::Property::PRIMARY_CURSOR_POSITION, 3);
5167
5168   // Render and notify
5169   application.SendNotification();
5170   application.Render();
5171
5172   DALI_TEST_CHECK(gSelectionChangedCallbackCalled);
5173   DALI_TEST_EQUALS(oldSelectionStart, 0, TEST_LOCATION);
5174   DALI_TEST_EQUALS(oldSelectionEnd, 5, TEST_LOCATION);
5175
5176   gSelectionChangedCallbackCalled = false;
5177
5178   // select all text
5179   DevelTextField::SelectWholeText(field);
5180
5181   // Render and notify
5182   application.SendNotification();
5183   application.Render();
5184
5185   DALI_TEST_CHECK(gSelectionChangedCallbackCalled);
5186   DALI_TEST_EQUALS(oldSelectionStart, oldSelectionEnd, TEST_LOCATION);
5187
5188   gSelectionChangedCallbackCalled = false;
5189
5190   // select none
5191   DevelTextField::SelectNone(field);
5192
5193   // Render and notify
5194   application.SendNotification();
5195   application.Render();
5196
5197   DALI_TEST_CHECK(gSelectionChangedCallbackCalled);
5198   DALI_TEST_EQUALS(oldSelectionStart, 0, TEST_LOCATION);
5199   DALI_TEST_EQUALS(oldSelectionEnd, 23, TEST_LOCATION);
5200
5201   END_TEST;
5202 }
5203
5204 int UtcDaliToolkitTextFieldStrikethroughGeneration(void)
5205 {
5206   ToolkitTestApplication application;
5207   tet_infoline(" UtcDaliToolkitTextFieldStrikethroughGeneration");
5208
5209   TextField textField = TextField::New();
5210   textField.SetProperty(TextField::Property::TEXT, "Test");
5211   textField.SetProperty(Actor::Property::SIZE, Vector2(200.0f, 100.f));
5212   textField.SetProperty(TextField::Property::POINT_SIZE, 10);
5213   textField.SetProperty(TextField::Property::FONT_FAMILY, "DejaVu Sans");
5214
5215   application.GetScene().Add(textField);
5216   application.SendNotification();
5217   application.Render();
5218
5219   Property::Map strikethroughMapSet;
5220   Property::Map strikethroughMapGet;
5221
5222   strikethroughMapSet.Insert("enable", true);
5223   strikethroughMapSet.Insert("color", Color::RED);
5224   strikethroughMapSet.Insert("height", 2.0f);
5225
5226   // Check the strikethrough property
5227   textField.SetProperty(DevelTextField::Property::STRIKETHROUGH, strikethroughMapSet);
5228   strikethroughMapGet = textField.GetProperty<Property::Map>(DevelTextField::Property::STRIKETHROUGH);
5229   textField.SetProperty(TextField::Property::TEXT, "Test1");
5230   DALI_TEST_EQUALS(strikethroughMapGet.Count(), strikethroughMapSet.Count(), TEST_LOCATION);
5231   DALI_TEST_EQUALS(DaliTestCheckMaps(strikethroughMapGet, strikethroughMapSet), true, TEST_LOCATION);
5232
5233   // Render and notify
5234   application.SendNotification();
5235   application.Render();
5236
5237   strikethroughMapSet.Clear();
5238   strikethroughMapGet.Clear();
5239
5240   END_TEST;
5241 }
5242
5243 int UtcDaliToolkitTextFieldInputStrikethroughGeneration(void)
5244 {
5245   ToolkitTestApplication application;
5246   tet_infoline(" UtcDaliToolkitTextFieldInputStrikethroughGeneration");
5247
5248   TextField textField = TextField::New();
5249   textField.SetProperty(TextField::Property::TEXT, "Test");
5250   textField.SetProperty(Actor::Property::SIZE, Vector2(200.0f, 100.f));
5251   textField.SetProperty(TextField::Property::POINT_SIZE, 10);
5252   textField.SetProperty(TextField::Property::FONT_FAMILY, "DejaVu Sans");
5253
5254   application.GetScene().Add(textField);
5255   application.SendNotification();
5256   application.Render();
5257
5258   std::string strikethroughSettings1("{\"enable\":\"true\",\"color\":\"red\",\"height\":\"2\"}");
5259
5260   // Check the strikethrough property
5261   textField.SetProperty(DevelTextField::Property::INPUT_STRIKETHROUGH, strikethroughSettings1);
5262   textField.SetProperty(TextField::Property::TEXT, "Test1");
5263   DALI_TEST_EQUALS(textField.GetProperty<std::string>(DevelTextField::Property::INPUT_STRIKETHROUGH), strikethroughSettings1, TEST_LOCATION);
5264
5265   // Render and notify
5266   application.SendNotification();
5267   application.Render();
5268
5269   END_TEST;
5270 }
5271
5272 int UtcDaliToolkitTextFieldUnderlineTypesGeneration1(void)
5273 {
5274   ToolkitTestApplication application;
5275   tet_infoline(" UtcDaliToolkitTextFieldUnderlineTypesGeneration1");
5276   TextField field = TextField::New();
5277   field.SetProperty(TextField::Property::TEXT, "Test");
5278   field.SetProperty(Actor::Property::SIZE, Vector2(200.0f, 100.f));
5279   field.SetProperty(TextField::Property::POINT_SIZE, 10);
5280   field.SetProperty(TextField::Property::FONT_FAMILY, "DejaVu Sans");
5281
5282   application.GetScene().Add(field);
5283   application.SendNotification();
5284   application.Render();
5285
5286   Property::Map underlineMapSet;
5287   Property::Map underlineMapGet;
5288
5289   underlineMapSet.Insert("enable", true);
5290   underlineMapSet.Insert("color", Color::RED);
5291   underlineMapSet.Insert("height", 1);
5292   underlineMapSet.Insert("type", Text::Underline::SOLID);
5293   underlineMapSet.Insert("dashWidth", 2);
5294   underlineMapSet.Insert("dashGap", 1);
5295
5296   // Check the underline property
5297   field.SetProperty(TextField::Property::UNDERLINE, underlineMapSet);
5298
5299   underlineMapGet = field.GetProperty<Property::Map>(TextField::Property::UNDERLINE);
5300   DALI_TEST_EQUALS(underlineMapGet.Count(), underlineMapSet.Count(), TEST_LOCATION);
5301   DALI_TEST_EQUALS(DaliTestCheckMaps(underlineMapGet, underlineMapSet), true, TEST_LOCATION);
5302
5303   // Render and notify
5304   application.SendNotification();
5305   application.Render();
5306
5307   underlineMapSet.Clear();
5308   underlineMapGet.Clear();
5309
5310   underlineMapSet.Insert("enable", true);
5311   underlineMapSet.Insert("color", Color::BLUE);
5312   underlineMapSet.Insert("height", 1);
5313   underlineMapSet.Insert("type", Text::Underline::DASHED);
5314   underlineMapSet.Insert("dashWidth", 4);
5315   underlineMapSet.Insert("dashGap", 2);
5316
5317   // Check the dashed underline property
5318   field.SetProperty(TextField::Property::UNDERLINE, underlineMapSet);
5319
5320   underlineMapGet = field.GetProperty<Property::Map>(TextField::Property::UNDERLINE);
5321   DALI_TEST_EQUALS(underlineMapGet.Count(), underlineMapSet.Count(), TEST_LOCATION);
5322   DALI_TEST_EQUALS(DaliTestCheckMaps(underlineMapGet, underlineMapSet), true, TEST_LOCATION);
5323
5324   // Render and notify
5325   application.SendNotification();
5326   application.Render();
5327
5328   underlineMapSet.Clear();
5329   underlineMapGet.Clear();
5330
5331   underlineMapSet.Insert("enable", true);
5332   underlineMapSet.Insert("color", Color::BLUE);
5333   underlineMapSet.Insert("height", 1);
5334   underlineMapSet.Insert("type", Text::Underline::DOUBLE);
5335   underlineMapSet.Insert("dashWidth", 4);
5336   underlineMapSet.Insert("dashGap", 2);
5337
5338   // Check the dashed underline property
5339   field.SetProperty(TextField::Property::UNDERLINE, underlineMapSet);
5340
5341   underlineMapGet = field.GetProperty<Property::Map>(TextField::Property::UNDERLINE);
5342   DALI_TEST_EQUALS(underlineMapGet.Count(), underlineMapSet.Count(), TEST_LOCATION);
5343   DALI_TEST_EQUALS(DaliTestCheckMaps(underlineMapGet, underlineMapSet), true, TEST_LOCATION);
5344
5345   // Render and notify
5346   application.SendNotification();
5347   application.Render();
5348
5349   underlineMapSet.Clear();
5350   underlineMapGet.Clear();
5351
5352   END_TEST;
5353 }
5354
5355 int UtcDaliToolkitTextFieldUnderlineTypesGeneration2(void)
5356 {
5357   ToolkitTestApplication application;
5358   tet_infoline(" UtcDaliToolkitTextFieldUnderlineTypesGeneration2");
5359
5360   TextField field1 = TextField::New();
5361   field1.SetProperty(TextField::Property::TEXT, "Test");
5362   field1.SetProperty(Actor::Property::SIZE, Vector2(200.0f, 100.f));
5363   field1.SetProperty(TextField::Property::POINT_SIZE, 10);
5364   field1.SetProperty(TextField::Property::FONT_FAMILY, "DejaVu Sans");
5365
5366   Property::Map underlineMapSet1;
5367   Property::Map underlineMapGet1;
5368
5369   underlineMapSet1.Insert("enable", true);
5370   underlineMapSet1.Insert("color", Color::RED);
5371   underlineMapSet1.Insert("height", 1);
5372   underlineMapSet1.Insert("type", Text::Underline::SOLID);
5373   underlineMapSet1.Insert("dashWidth", 2);
5374   underlineMapSet1.Insert("dashGap", 1);
5375
5376   // Check the underline property
5377   field1.SetProperty(TextField::Property::UNDERLINE, underlineMapSet1);
5378
5379   underlineMapGet1 = field1.GetProperty<Property::Map>(TextField::Property::UNDERLINE);
5380   DALI_TEST_EQUALS(underlineMapGet1.Count(), underlineMapSet1.Count(), TEST_LOCATION);
5381   DALI_TEST_EQUALS(DaliTestCheckMaps(underlineMapGet1, underlineMapSet1), true, TEST_LOCATION);
5382
5383   application.GetScene().Add(field1);
5384   application.SendNotification();
5385   application.Render();
5386
5387   TextField field2 = TextField::New();
5388   field2.SetProperty(TextField::Property::TEXT, "Test");
5389   field2.SetProperty(Actor::Property::SIZE, Vector2(200.0f, 100.f));
5390   field2.SetProperty(TextField::Property::POINT_SIZE, 10);
5391   field2.SetProperty(TextField::Property::FONT_FAMILY, "DejaVu Sans");
5392
5393   Property::Map underlineMapSet2;
5394   Property::Map underlineMapGet2;
5395
5396   underlineMapSet2.Insert("enable", true);
5397   underlineMapSet2.Insert("color", Color::BLUE);
5398   underlineMapSet2.Insert("height", 1);
5399   underlineMapSet2.Insert("type", Text::Underline::DASHED);
5400   underlineMapSet2.Insert("dashWidth", 4);
5401   underlineMapSet2.Insert("dashGap", 2);
5402
5403   // Check the dashed underline property
5404   field2.SetProperty(TextField::Property::UNDERLINE, underlineMapSet2);
5405
5406   underlineMapGet2 = field2.GetProperty<Property::Map>(TextField::Property::UNDERLINE);
5407   DALI_TEST_EQUALS(underlineMapGet2.Count(), underlineMapSet2.Count(), TEST_LOCATION);
5408   DALI_TEST_EQUALS(DaliTestCheckMaps(underlineMapGet2, underlineMapSet2), true, TEST_LOCATION);
5409
5410   application.GetScene().Add(field2);
5411   application.SendNotification();
5412   application.Render();
5413
5414   TextField field3 = TextField::New();
5415   field3.SetProperty(TextField::Property::TEXT, "Test");
5416   field3.SetProperty(Actor::Property::SIZE, Vector2(200.0f, 100.f));
5417   field3.SetProperty(TextField::Property::POINT_SIZE, 10);
5418   field3.SetProperty(TextField::Property::FONT_FAMILY, "DejaVu Sans");
5419
5420   Property::Map underlineMapSet3;
5421   Property::Map underlineMapGet3;
5422
5423   underlineMapSet3.Insert("enable", true);
5424   underlineMapSet3.Insert("color", Color::BLUE);
5425   underlineMapSet3.Insert("height", 1);
5426   underlineMapSet3.Insert("type", Text::Underline::DOUBLE);
5427   underlineMapSet3.Insert("dashWidth", 4);
5428   underlineMapSet3.Insert("dashGap", 2);
5429
5430   // Check the dashed underline property
5431   field3.SetProperty(TextField::Property::UNDERLINE, underlineMapSet3);
5432
5433   underlineMapGet3 = field3.GetProperty<Property::Map>(TextField::Property::UNDERLINE);
5434   DALI_TEST_EQUALS(underlineMapGet3.Count(), underlineMapSet3.Count(), TEST_LOCATION);
5435   DALI_TEST_EQUALS(DaliTestCheckMaps(underlineMapGet3, underlineMapSet3), true, TEST_LOCATION);
5436
5437   application.GetScene().Add(field3);
5438
5439   application.SendNotification();
5440   application.Render();
5441
5442   END_TEST;
5443 }
5444
5445 int UtcDaliTextFieldCharacterSpacing(void)
5446 {
5447   ToolkitTestApplication application;
5448   tet_infoline(" UtcDaliTextFieldCharacterSpacing ");
5449
5450   TextField textField = TextField::New();
5451
5452   textField.SetProperty(Actor::Property::SIZE, Vector2(150.0f, 300.f));
5453
5454   application.GetScene().Add(textField);
5455   application.SendNotification();
5456   application.Render();
5457
5458   textField.SetProperty(TextField::Property::TEXT, "Hi Experiment");
5459   textField.SetProperty(DevelTextField::Property::CHARACTER_SPACING, 10.f);
5460   DALI_TEST_EQUALS(textField.GetProperty<float>(DevelTextField::Property::CHARACTER_SPACING), 10.f, Math::MACHINE_EPSILON_1000, TEST_LOCATION);
5461
5462   application.SendNotification();
5463   application.Render();
5464
5465   END_TEST;
5466 }
5467
5468 int UtcDaliToolkitTextFieldUnderlineTypesGeneration3(void)
5469 {
5470   ToolkitTestApplication application;
5471   tet_infoline(" UtcDaliToolkitTextFieldUnderlineTypesGeneration3");
5472
5473   TextField field1 = TextField::New();
5474   field1.SetProperty(TextField::Property::TEXT, "Test1");
5475   field1.SetProperty(Actor::Property::SIZE, Vector2(200.0f, 100.f));
5476   field1.SetProperty(TextField::Property::POINT_SIZE, 10);
5477   field1.SetProperty(TextField::Property::FONT_FAMILY, "DejaVu Sans");
5478
5479   Property::Map underlineMapSet1;
5480   Property::Map underlineMapGet1;
5481
5482   underlineMapSet1.Insert("enable", true);
5483   underlineMapSet1.Insert("color", Color::RED);
5484   underlineMapSet1.Insert("height", 1);
5485   underlineMapSet1.Insert("type", Text::Underline::SOLID);
5486   underlineMapSet1.Insert("dashWidth", 2);
5487   underlineMapSet1.Insert("dashGap", 1);
5488
5489   // Check the underline property
5490   field1.SetProperty(TextField::Property::UNDERLINE, underlineMapSet1);
5491   //field1.SetProperty( TextField::Property::TEXT, "Test2" );
5492
5493   underlineMapGet1 = field1.GetProperty<Property::Map>(TextField::Property::UNDERLINE);
5494   DALI_TEST_EQUALS(underlineMapGet1.Count(), underlineMapSet1.Count(), TEST_LOCATION);
5495   DALI_TEST_EQUALS(DaliTestCheckMaps(underlineMapGet1, underlineMapSet1), true, TEST_LOCATION);
5496
5497   application.GetScene().Add(field1);
5498   application.SendNotification();
5499   application.Render();
5500
5501   END_TEST;
5502 }
5503
5504 int UtcDaliToolkitTextfieldParagraphTag(void)
5505 {
5506   ToolkitTestApplication application;
5507   tet_infoline(" UtcDaliToolkitTextfieldParagraphTag");
5508   TextField fieldNewlineSeparator = TextField::New();
5509   TextField fieldParagraphTag     = TextField::New();
5510   DALI_TEST_CHECK(fieldNewlineSeparator);
5511   DALI_TEST_CHECK(fieldParagraphTag);
5512
5513   application.GetScene().Add(fieldNewlineSeparator);
5514   application.GetScene().Add(fieldParagraphTag);
5515
5516   //Same utterance uses new-line to split paragraphs should give similar results for paragraph tag.
5517   fieldNewlineSeparator.SetProperty(TextField::Property::ENABLE_MARKUP, true);
5518   fieldNewlineSeparator.SetProperty(Actor::Property::SIZE, Vector2(100.f, 50.f));
5519   fieldNewlineSeparator.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT);
5520   fieldNewlineSeparator.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
5521   fieldNewlineSeparator.SetProperty(TextField::Property::TEXT, "test paragraph tag \ntest paragraph tag \ntest paragraph tag ");
5522
5523   fieldParagraphTag.SetProperty(TextField::Property::ENABLE_MARKUP, true);
5524   fieldParagraphTag.SetProperty(Actor::Property::SIZE, Vector2(100.f, 50.f));
5525   fieldParagraphTag.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT);
5526   fieldParagraphTag.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
5527   fieldParagraphTag.SetProperty(TextField::Property::TEXT, "test paragraph tag <p>test paragraph tag </p>test paragraph tag ");
5528
5529   application.SendNotification();
5530   application.Render();
5531
5532   Vector3 textNaturalSizeNewlineSeparator = fieldNewlineSeparator.GetNaturalSize();
5533   Vector3 textNaturalSizeParagraphTag     = fieldParagraphTag.GetNaturalSize();
5534
5535   DALI_TEST_EQUALS(textNaturalSizeNewlineSeparator, textNaturalSizeParagraphTag, TEST_LOCATION);
5536
5537   application.SendNotification();
5538   application.Render();
5539
5540   END_TEST;
5541 }
5542
5543 //Handle Emoji clustering for cursor handling
5544 int utcDaliTextFieldClusteredEmojiDeletionBackSpaceKey(void)
5545 {
5546   ToolkitTestApplication application;
5547   tet_infoline(" utcDaliTextFieldClusteredEmojiDeletionBackSpaceKey ");
5548   TextField textField = TextField::New();
5549   DALI_TEST_CHECK(textField);
5550
5551   application.GetScene().Add(textField);
5552
5553   // Avoid a crash when core load gl resources.
5554   application.GetGlAbstraction().SetCheckFramebufferStatusResult(GL_FRAMEBUFFER_COMPLETE);
5555
5556   textField.SetProperty(TextField::Property::TEXT, "ABC&#x1F468;&#x200D;&#x1F469;&#x200D;&#x1F467;&#x200D;&#x1F466;XY");
5557   textField.SetProperty(Dali::Toolkit::TextField::Property::ENABLE_MARKUP, true);
5558
5559   // Render and notify
5560   application.SendNotification();
5561   application.Render();
5562
5563   // Set currsor
5564   textField.SetProperty(DevelTextField::Property::PRIMARY_CURSOR_POSITION, 10);
5565   application.SendNotification();
5566   application.Render();
5567
5568   // Set focus and remove Emoji
5569   textField.SetKeyInputFocus();
5570   application.ProcessEvent(GenerateKey("", "", "", DALI_KEY_BACKSPACE, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
5571
5572   //Check the changed text and cursor position
5573   DALI_TEST_EQUALS(textField.GetProperty(TextField::Property::TEXT).Get<std::string>(), "ABCXY", TEST_LOCATION);
5574   DALI_TEST_EQUALS(textField.GetProperty(DevelTextField::Property::PRIMARY_CURSOR_POSITION).Get<int>(), 3, TEST_LOCATION);
5575
5576   // Render and notify
5577   application.SendNotification();
5578   application.Render();
5579
5580   END_TEST;
5581 }
5582
5583 int utcDaliTextFieldClusteredEmojiDeletionDeleteKey(void)
5584 {
5585   ToolkitTestApplication application;
5586   tet_infoline(" utcDaliTextFieldClusteredEmojiDeletionDeleteKey ");
5587   TextField textField = TextField::New();
5588   DALI_TEST_CHECK(textField);
5589
5590   application.GetScene().Add(textField);
5591
5592   // Avoid a crash when core load gl resources.
5593   application.GetGlAbstraction().SetCheckFramebufferStatusResult(GL_FRAMEBUFFER_COMPLETE);
5594
5595   textField.SetProperty(TextField::Property::TEXT, "ABC&#x1F468;&#x200D;&#x1F469;&#x200D;&#x1F467;&#x200D;&#x1F466;XY");
5596   textField.SetProperty(Dali::Toolkit::TextField::Property::ENABLE_MARKUP, true);
5597
5598   // Render and notify
5599   application.SendNotification();
5600   application.Render();
5601
5602   // Set currsor
5603   textField.SetProperty(DevelTextField::Property::PRIMARY_CURSOR_POSITION, 3);
5604   application.SendNotification();
5605   application.Render();
5606
5607   // Set focus and remove Emoji
5608   textField.SetKeyInputFocus();
5609   application.ProcessEvent(GenerateKey("", "", "", Dali::DevelKey::DALI_KEY_DELETE, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
5610
5611   //Check the changed text and cursor position
5612   DALI_TEST_EQUALS(textField.GetProperty(TextField::Property::TEXT).Get<std::string>(), "ABCXY", TEST_LOCATION);
5613   DALI_TEST_EQUALS(textField.GetProperty(DevelTextField::Property::PRIMARY_CURSOR_POSITION).Get<int>(), 3, TEST_LOCATION);
5614
5615   // Render and notify
5616   application.SendNotification();
5617   application.Render();
5618
5619   END_TEST;
5620 }
5621
5622 int utcDaliTextFieldPanGesturePropagation(void)
5623 {
5624   ToolkitTestApplication application;
5625   tet_infoline(" utcDaliTextFieldPanGesturePropagation");
5626
5627   Actor actor = Actor::New();
5628   actor.SetProperty(Actor::Property::SIZE, Vector2(100.0f, 100.0f));
5629   actor.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
5630   application.GetScene().Add(actor);
5631
5632   TextField field = TextField::New();
5633   DALI_TEST_CHECK(field);
5634
5635   field.SetProperty(TextField::Property::TEXT, "This is a long text for the size of the text-field.");
5636   field.SetProperty(TextField::Property::POINT_SIZE, 10.f);
5637
5638   field.SetProperty(Actor::Property::SIZE, Vector2(50.f, 100.f));
5639   field.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT);
5640   field.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
5641
5642   actor.Add(field);
5643
5644   // Render and notify
5645   application.SendNotification();
5646   application.Render();
5647
5648   SignalData             data;
5649   GestureReceivedFunctor functor(data);
5650
5651   PanGestureDetector detector = PanGestureDetector::New();
5652   detector.Attach(actor);
5653   detector.DetectedSignal().Connect(&application, functor);
5654
5655   // Tap first to get the focus.
5656   TestGenerateTap(application, 3.0f, 25.0f, 100);
5657
5658   // Render and notify
5659   application.SendNotification();
5660   application.Render();
5661
5662   // Pan the text field
5663   uint32_t time = 100;
5664   TestStartPan(application, Vector2(40.0f, 50.0f), Vector2(40.0f, 50.0f), time);
5665   TestMovePan(application, Vector2(10.0f, 50.0f), time);
5666   TestEndPan(application, Vector2(40.0f, 50.0f), time);
5667   application.SendNotification();
5668   application.Render();
5669
5670   // The text scrolls because there is text that is scrolling.
5671   DALI_TEST_EQUALS(false, data.functorCalled, TEST_LOCATION);
5672   data.Reset();
5673
5674   // Set the size large enough to prevent scrolling.
5675   field.SetProperty(Actor::Property::SIZE, Vector2(700.f, 100.f));
5676
5677   // Render and notify
5678   application.SendNotification();
5679   application.Render();
5680
5681   time = 200;
5682   TestStartPan(application, Vector2(40.0f, 50.0f), Vector2(40.0f, 50.0f), time);
5683   TestMovePan(application, Vector2(10.0f, 50.0f), time);
5684   TestEndPan(application, Vector2(40.0f, 50.0f), time);
5685
5686   // Because scrolling is not possible, the pan gesture is propagated.
5687   DALI_TEST_EQUALS(true, data.functorCalled, TEST_LOCATION);
5688   data.Reset();
5689
5690
5691   END_TEST;
5692 }