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