Merge "Add text selection popup style" into devel/master
[platform/core/uifw/dali-toolkit.git] / automated-tests / src / dali-toolkit / utc-Dali-TextEditor.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 <dali-toolkit-test-suite-utils.h>
19 #include <dali-toolkit/dali-toolkit.h>
20 #include <dali-toolkit/devel-api/controls/text-controls/text-editor-devel.h>
21 #include <dali-toolkit/devel-api/text/rendering-backend.h>
22 #include <dali-toolkit/devel-api/text/text-enumerations-devel.h>
23 #include <dali-toolkit/devel-api/controls/text-controls/text-selection-popup.h>
24
25 #include <dali/devel-api/actors/actor-devel.h>
26 #include <dali/devel-api/adaptor-framework/clipboard.h>
27 #include <dali/devel-api/adaptor-framework/key-devel.h>
28 #include <dali/devel-api/text-abstraction/font-client.h>
29 #include <dali/integration-api/events/key-event-integ.h>
30 #include <dali/integration-api/events/touch-event-integ.h>
31 #include <dali/public-api/rendering/renderer.h>
32 #include <stdlib.h>
33 #include <unistd.h>
34 #include <iostream>
35 #include "test-text-geometry-utils.h"
36
37 using namespace Dali;
38 using namespace Toolkit;
39
40 void dali_texteditor_startup(void)
41 {
42   test_return_value = TET_UNDEF;
43 }
44
45 void dali_texteditor_cleanup(void)
46 {
47   test_return_value = TET_PASS;
48 }
49
50 namespace
51 {
52 const char* const PROPERTY_NAME_RENDERING_BACKEND                    = "renderingBackend";
53 const char* const PROPERTY_NAME_TEXT                                 = "text";
54 const char* const PROPERTY_NAME_TEXT_COLOR                           = "textColor";
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_HORIZONTAL_ALIGNMENT                 = "horizontalAlignment";
59 const char* const PROPERTY_NAME_SCROLL_THRESHOLD                     = "scrollThreshold";
60 const char* const PROPERTY_NAME_SCROLL_SPEED                         = "scrollSpeed";
61 const char* const PROPERTY_NAME_PRIMARY_CURSOR_COLOR                 = "primaryCursorColor";
62 const char* const PROPERTY_NAME_SECONDARY_CURSOR_COLOR               = "secondaryCursorColor";
63 const char* const PROPERTY_NAME_ENABLE_CURSOR_BLINK                  = "enableCursorBlink";
64 const char* const PROPERTY_NAME_CURSOR_BLINK_INTERVAL                = "cursorBlinkInterval";
65 const char* const PROPERTY_NAME_CURSOR_BLINK_DURATION                = "cursorBlinkDuration";
66 const char* const PROPERTY_NAME_CURSOR_WIDTH                         = "cursorWidth";
67 const char* const PROPERTY_NAME_GRAB_HANDLE_IMAGE                    = "grabHandleImage";
68 const char* const PROPERTY_NAME_GRAB_HANDLE_PRESSED_IMAGE            = "grabHandlePressedImage";
69 const char* const PROPERTY_NAME_SELECTION_POPUP_STYLE                = "selectionPopupStyle";
70 const char* const PROPERTY_NAME_SELECTION_HANDLE_IMAGE_LEFT          = "selectionHandleImageLeft";
71 const char* const PROPERTY_NAME_SELECTION_HANDLE_IMAGE_RIGHT         = "selectionHandleImageRight";
72 const char* const PROPERTY_NAME_SELECTION_HANDLE_PRESSED_IMAGE_LEFT  = "selectionHandlePressedImageLeft";
73 const char* const PROPERTY_NAME_SELECTION_HANDLE_PRESSED_IMAGE_RIGHT = "selectionHandlePressedImageRight";
74 const char* const PROPERTY_NAME_SELECTION_HANDLE_MARKER_IMAGE_LEFT   = "selectionHandleMarkerImageLeft";
75 const char* const PROPERTY_NAME_SELECTION_HANDLE_MARKER_IMAGE_RIGHT  = "selectionHandleMarkerImageRight";
76 const char* const PROPERTY_NAME_SELECTION_HIGHLIGHT_COLOR            = "selectionHighlightColor";
77 const char* const PROPERTY_NAME_DECORATION_BOUNDING_BOX              = "decorationBoundingBox";
78 const char* const PROPERTY_NAME_ENABLE_MARKUP                        = "enableMarkup";
79 const char* const PROPERTY_NAME_INPUT_COLOR                          = "inputColor";
80 const char* const PROPERTY_NAME_INPUT_FONT_FAMILY                    = "inputFontFamily";
81 const char* const PROPERTY_NAME_INPUT_FONT_STYLE                     = "inputFontStyle";
82 const char* const PROPERTY_NAME_INPUT_POINT_SIZE                     = "inputPointSize";
83
84 const char* const PROPERTY_NAME_LINE_SPACING        = "lineSpacing";
85 const char* const PROPERTY_NAME_INPUT_LINE_SPACING  = "inputLineSpacing";
86 const char* const PROPERTY_NAME_UNDERLINE           = "underline";
87 const char* const PROPERTY_NAME_INPUT_UNDERLINE     = "inputUnderline";
88 const char* const PROPERTY_NAME_SHADOW              = "shadow";
89 const char* const PROPERTY_NAME_INPUT_SHADOW        = "inputShadow";
90 const char* const PROPERTY_NAME_EMBOSS              = "emboss";
91 const char* const PROPERTY_NAME_INPUT_EMBOSS        = "inputEmboss";
92 const char* const PROPERTY_NAME_OUTLINE             = "outline";
93 const char* const PROPERTY_NAME_INPUT_OUTLINE       = "inputOutline";
94 const char* const PROPERTY_NAME_STRIKETHROUGH       = "strikethrough";
95 const char* const PROPERTY_NAME_INPUT_STRIKETHROUGH = "inputStrikethrough";
96
97 const char* const PROPERTY_NAME_SMOOTH_SCROLL                   = "smoothScroll";
98 const char* const PROPERTY_NAME_SMOOTH_SCROLL_DURATION          = "smoothScrollDuration";
99 const char* const PROPERTY_NAME_ENABLE_SCROLL_BAR               = "enableScrollBar";
100 const char* const PROPERTY_NAME_SCROLL_BAR_SHOW_DURATION        = "scrollBarShowDuration";
101 const char* const PROPERTY_NAME_SCROLL_BAR_FADE_DURATION        = "scrollBarFadeDuration";
102 const char* const PROPERTY_NAME_PIXEL_SIZE                      = "pixelSize";
103 const char* const PROPERTY_NAME_LINE_COUNT                      = "lineCount";
104 const char* const PROPERTY_NAME_PLACEHOLDER_TEXT                = "placeholderText";
105 const char* const PROPERTY_NAME_PLACEHOLDER_TEXT_COLOR          = "placeholderTextColor";
106 const char* const PROPERTY_NAME_ENABLE_SELECTION                = "enableSelection";
107 const char* const PROPERTY_NAME_PLACEHOLDER                     = "placeholder";
108 const char* const PROPERTY_NAME_ENABLE_SHIFT_SELECTION          = "enableShiftSelection";
109 const char* const PROPERTY_NAME_ENABLE_GRAB_HANDLE              = "enableGrabHandle";
110 const char* const PROPERTY_NAME_MATCH_SYSTEM_LANGUAGE_DIRECTION = "matchSystemLanguageDirection";
111 const char* const PROPERTY_NAME_MAX_LENGTH                      = "maxLength";
112 const char* const PROPERTY_NAME_FONT_SIZE_SCALE                 = "fontSizeScale";
113 const char* const PROPERTY_NAME_ENABLE_FONT_SIZE_SCALE          = "enableFontSizeScale";
114 const char* const PROPERTY_NAME_GRAB_HANDLE_COLOR               = "grabHandleColor";
115 const char* const PROPERTY_NAME_ENABLE_GRAB_HANDLE_POPUP        = "enableGrabHandlePopup";
116 const char* const PROPERTY_NAME_INPUT_METHOD_SETTINGS           = "inputMethodSettings";
117 const char* const PROPERTY_NAME_INPUT_FILTER                    = "inputFilter";
118
119 const Vector4       PLACEHOLDER_TEXT_COLOR(0.8f, 0.8f, 0.8f, 0.8f);
120 const Dali::Vector4 LIGHT_BLUE(0.75f, 0.96f, 1.f, 1.f); // The text highlight color.
121
122 const float RENDER_FRAME_INTERVAL = 16.66f;
123
124 const unsigned int DEFAULT_FONT_SIZE = 1152u;
125 const std::string  DEFAULT_FONT_DIR("/resources/fonts");
126
127 const int KEY_A_CODE           = 38;
128 const int KEY_D_CODE           = 40;
129 const int KEY_C_CODE           = 54;
130 const int KEY_V_CODE           = 55;
131 const int KEY_X_CODE           = 53;
132 const int KEY_WHITE_SPACE_CODE = 65;
133
134 const int KEY_SHIFT_MODIFIER   = 257;
135 const int KEY_CONTROL_MODIFIER = 258;
136
137 const char* HANDLE_IMAGE_FILE_NAME           = TEST_RESOURCE_DIR "/insertpoint-icon.png";
138 const char* HANDLE_LEFT_SELECTION_FILE_NAME  = TEST_RESOURCE_DIR "/selection_handle_drop_left.png";
139 const char* HANDLE_RIGHT_SELECTION_FILE_NAME = TEST_RESOURCE_DIR "/selection_handle_drop_right.png";
140
141 const std::string DEFAULT_DEVICE_NAME("hwKeyboard");
142
143 static bool                                        gSelectionChangedCallbackCalled;
144 static uint32_t                                    oldSelectionStart;
145 static uint32_t                                    oldSelectionEnd;
146 static bool                                        gSelectionClearedCallbackCalled;
147 static bool                                        gSelectionStartedCallbackCalled;
148 static bool                                        gAnchorClickedCallBackCalled;
149 static bool                                        gAnchorClickedCallBackNotCalled;
150 static bool                                        gTextChangedCallBackCalled;
151 static bool                                        gInputFilteredAcceptedCallbackCalled;
152 static bool                                        gInputFilteredRejectedCallbackCalled;
153 static bool                                        gInputStyleChangedCallbackCalled;
154 static bool                                        gMaxCharactersCallBackCalled;
155 static bool                                        gCursorPositionChangedCallbackCalled;
156 static uint32_t                                    oldCursorPos;
157 static Dali::Toolkit::TextEditor::InputStyle::Mask gInputStyleMask;
158
159 struct CallbackFunctor
160 {
161   CallbackFunctor(bool* callbackFlag)
162   : mCallbackFlag(callbackFlag)
163   {
164   }
165
166   void operator()()
167   {
168     *mCallbackFlag = true;
169   }
170   bool* mCallbackFlag;
171 };
172
173 static void TestSelectionStartedCallback(TextEditor control)
174 {
175   tet_infoline(" TestSelectionStartedCallback");
176
177   gSelectionStartedCallbackCalled = true;
178 }
179
180 static void TestSelectionClearedCallback(TextEditor control)
181 {
182   tet_infoline(" TestSelectionClearedCallback");
183
184   gSelectionClearedCallbackCalled = true;
185 }
186
187 static void TestSelectionChangedCallback(TextEditor control, uint32_t oldStart, uint32_t oldEnd)
188 {
189   tet_infoline(" TestSelectionChangedCallback");
190
191   gSelectionChangedCallbackCalled = true;
192   oldSelectionStart               = oldStart;
193   oldSelectionEnd                 = oldEnd;
194 }
195
196 static void TestAnchorClickedCallback(TextEditor control, const char* href, unsigned int hrefLength)
197 {
198   tet_infoline(" TestAnchorClickedCallback");
199
200   gAnchorClickedCallBackNotCalled = false;
201
202   if(!strcmp(href, "https://www.tizen.org") && hrefLength == strlen(href))
203   {
204     gAnchorClickedCallBackCalled = true;
205   }
206 }
207
208 static void TestCursorPositionChangedCallback(TextEditor control, unsigned int oldPos)
209 {
210   tet_infoline(" TestCursorPositionChangedCallback");
211
212   gCursorPositionChangedCallbackCalled = true;
213   oldCursorPos                         = oldPos;
214 }
215
216 static void TestTextChangedCallback(TextEditor control)
217 {
218   tet_infoline(" TestTextChangedCallback");
219
220   gTextChangedCallBackCalled = true;
221 }
222
223 static void TestInputStyleChangedCallback(TextEditor control, TextEditor::InputStyle::Mask mask)
224 {
225   tet_infoline(" TestInputStyleChangedCallback");
226
227   gInputStyleChangedCallbackCalled = true;
228   gInputStyleMask                  = mask;
229 }
230
231 static void TestMaxLengthReachedCallback(TextEditor control)
232 {
233   tet_infoline(" TestMaxLengthReachedCallback");
234
235   gMaxCharactersCallBackCalled = true;
236 }
237
238 static void TestInputFilteredCallback(TextEditor control, Toolkit::InputFilter::Property::Type type)
239 {
240   tet_infoline(" TestInputFilteredCallback");
241
242   if(type == Toolkit::InputFilter::Property::ACCEPTED)
243   {
244     gInputFilteredAcceptedCallbackCalled = true;
245   }
246   else if(type == Toolkit::InputFilter::Property::REJECTED)
247   {
248     gInputFilteredRejectedCallbackCalled = true;
249   }
250 }
251
252 // Generate a KeyEvent to send to Core.
253 Integration::KeyEvent GenerateKey(const std::string&                  keyName,
254                                   const std::string&                  logicalKey,
255                                   const std::string&                  keyString,
256                                   int                                 keyCode,
257                                   int                                 keyModifier,
258                                   unsigned long                       timeStamp,
259                                   const Integration::KeyEvent::State& keyState,
260                                   const std::string&                  compose        = "",
261                                   const std::string&                  deviceName     = DEFAULT_DEVICE_NAME,
262                                   const Device::Class::Type&          deviceClass    = Device::Class::NONE,
263                                   const Device::Subclass::Type&       deviceSubclass = Device::Subclass::NONE)
264 {
265   return Integration::KeyEvent(keyName,
266                                logicalKey,
267                                keyString,
268                                keyCode,
269                                keyModifier,
270                                timeStamp,
271                                keyState,
272                                compose,
273                                deviceName,
274                                deviceClass,
275                                deviceSubclass);
276 }
277
278 Dali::Integration::Point GetPointDownInside(Vector2& pos)
279 {
280   Dali::Integration::Point point;
281   point.SetState(PointState::DOWN);
282   point.SetScreenPosition(pos);
283   return point;
284 }
285
286 Dali::Integration::Point GetPointUpInside(Vector2& pos)
287 {
288   Dali::Integration::Point point;
289   point.SetState(PointState::UP);
290   point.SetScreenPosition(pos);
291   return point;
292 }
293
294 bool DaliTestCheckMaps(const Property::Map& fontStyleMapGet, const Property::Map& fontStyleMapSet)
295 {
296   if(fontStyleMapGet.Count() == fontStyleMapSet.Count())
297   {
298     for(unsigned int index = 0u; index < fontStyleMapGet.Count(); ++index)
299     {
300       const KeyValuePair& valueGet = fontStyleMapGet.GetKeyValue(index);
301
302       Property::Value* valueSet = NULL;
303       if(valueGet.first.type == Property::Key::INDEX)
304       {
305         valueSet = fontStyleMapSet.Find(valueGet.first.indexKey);
306       }
307       else
308       {
309         // Get Key is a string so searching Set Map for a string key
310         valueSet = fontStyleMapSet.Find(valueGet.first.stringKey);
311       }
312
313       if(NULL != valueSet)
314       {
315         if(valueSet->GetType() == Dali::Property::STRING && (valueGet.second.Get<std::string>() != valueSet->Get<std::string>()))
316         {
317           tet_printf("Value got : [%s], expected : [%s]", valueGet.second.Get<std::string>().c_str(), valueSet->Get<std::string>().c_str());
318           return false;
319         }
320         else if(valueSet->GetType() == Dali::Property::BOOLEAN && (valueGet.second.Get<bool>() != valueSet->Get<bool>()))
321         {
322           tet_printf("Value got : [%d], expected : [%d]", valueGet.second.Get<bool>(), valueSet->Get<bool>());
323           return false;
324         }
325         else if(valueSet->GetType() == Dali::Property::INTEGER && (valueGet.second.Get<int>() != valueSet->Get<int>()))
326         {
327           tet_printf("Value got : [%d], expected : [%d]", valueGet.second.Get<int>(), valueSet->Get<int>());
328           return false;
329         }
330         else if(valueSet->GetType() == Dali::Property::FLOAT && (valueGet.second.Get<float>() != valueSet->Get<float>()))
331         {
332           tet_printf("Value got : [%f], expected : [%f]", valueGet.second.Get<float>(), valueSet->Get<float>());
333           return false;
334         }
335         else if(valueSet->GetType() == Dali::Property::VECTOR2 && (valueGet.second.Get<Vector2>() != valueSet->Get<Vector2>()))
336         {
337           Vector2 vector2Get = valueGet.second.Get<Vector2>();
338           Vector2 vector2Set = valueSet->Get<Vector2>();
339           tet_printf("Value got : [%f, %f], expected : [%f, %f]", vector2Get.x, vector2Get.y, vector2Set.x, vector2Set.y);
340           return false;
341         }
342         else if(valueSet->GetType() == Dali::Property::VECTOR4 && (valueGet.second.Get<Vector4>() != valueSet->Get<Vector4>()))
343         {
344           Vector4 vector4Get = valueGet.second.Get<Vector4>();
345           Vector4 vector4Set = valueSet->Get<Vector4>();
346           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);
347           return false;
348         }
349       }
350       else
351       {
352         if(valueGet.first.type == Property::Key::INDEX)
353         {
354           tet_printf("  The key %d doesn't exist.", valueGet.first.indexKey);
355         }
356         else
357         {
358           tet_printf("  The key %s doesn't exist.", valueGet.first.stringKey.c_str());
359         }
360         return false;
361       }
362     }
363   }
364
365   return true;
366 }
367
368 class ScrollStateChangeCallback : public Dali::ConnectionTracker
369 {
370 public:
371   ScrollStateChangeCallback(bool& startedCalled, bool& finishedCalled)
372   : mStartedCalled(startedCalled),
373     mFinishedCalled(finishedCalled)
374   {
375   }
376
377   void Callback(TextEditor editor, TextEditor::Scroll::Type type)
378   {
379     if(type == TextEditor::Scroll::STARTED)
380     {
381       mStartedCalled = true;
382     }
383     else if(type == TextEditor::Scroll::FINISHED)
384     {
385       mFinishedCalled = true;
386     }
387   }
388
389   bool& mStartedCalled;
390   bool& mFinishedCalled;
391 };
392
393 } // namespace
394
395 int UtcDaliToolkitTextEditorConstructorP(void)
396 {
397   ToolkitTestApplication application;
398   tet_infoline(" UtcDaliToolkitTextEditorConstructorP");
399   TextEditor textEditor;
400   DALI_TEST_CHECK(!textEditor);
401   END_TEST;
402 }
403
404 int UtcDaliToolkitTextEditorNewP(void)
405 {
406   ToolkitTestApplication application;
407   tet_infoline(" UtcDaliToolkitTextEditorNewP");
408   TextEditor textEditor = TextEditor::New();
409   DALI_TEST_CHECK(textEditor);
410   END_TEST;
411 }
412
413 int UtcDaliToolkitTextEditorDownCastP(void)
414 {
415   ToolkitTestApplication application;
416   tet_infoline(" UtcDaliToolkitTextEditorDownCastP");
417   TextEditor textEditor1 = TextEditor::New();
418   BaseHandle object(textEditor1);
419
420   TextEditor textEditor2 = TextEditor::DownCast(object);
421   DALI_TEST_CHECK(textEditor2);
422
423   TextEditor textEditor3 = DownCast<TextEditor>(object);
424   DALI_TEST_CHECK(textEditor3);
425   END_TEST;
426 }
427
428 int UtcDaliToolkitTextEditorDownCastN(void)
429 {
430   ToolkitTestApplication application;
431   tet_infoline(" UtcDaliToolkitTextEditorDownCastN");
432   BaseHandle uninitializedObject;
433   TextEditor textEditor1 = TextEditor::DownCast(uninitializedObject);
434   DALI_TEST_CHECK(!textEditor1);
435
436   TextEditor textEditor2 = DownCast<TextEditor>(uninitializedObject);
437   DALI_TEST_CHECK(!textEditor2);
438   END_TEST;
439 }
440
441 int UtcDaliToolkitTextEditorCopyConstructorP(void)
442 {
443   ToolkitTestApplication application;
444   tet_infoline(" UtcDaliToolkitTextEditorCopyConstructorP");
445   TextEditor textEditor = TextEditor::New();
446   textEditor.SetProperty(TextEditor::Property::TEXT, "Test");
447
448   TextEditor copy(textEditor);
449   DALI_TEST_CHECK(copy);
450   DALI_TEST_CHECK(copy.GetProperty<std::string>(TextEditor::Property::TEXT) == textEditor.GetProperty<std::string>(TextEditor::Property::TEXT));
451   END_TEST;
452 }
453
454 int UtcDaliTextEditorMoveConstructor(void)
455 {
456   ToolkitTestApplication application;
457
458   TextEditor textEditor = TextEditor::New();
459   textEditor.SetProperty(TextEditor::Property::TEXT, "Test");
460   DALI_TEST_CHECK(textEditor.GetProperty<std::string>(TextEditor::Property::TEXT) == "Test");
461
462   TextEditor moved = std::move(textEditor);
463   DALI_TEST_CHECK(moved);
464   DALI_TEST_EQUALS(1, moved.GetBaseObject().ReferenceCount(), TEST_LOCATION);
465   DALI_TEST_CHECK(moved.GetProperty<std::string>(TextEditor::Property::TEXT) == "Test");
466   DALI_TEST_CHECK(!textEditor);
467
468   END_TEST;
469 }
470
471 int UtcDaliToolkitTextEditorAssignmentOperatorP(void)
472 {
473   ToolkitTestApplication application;
474   tet_infoline(" UtcDaliToolkitTextEditorAssignmentOperatorP");
475   TextEditor textEditor = TextEditor::New();
476   textEditor.SetProperty(TextEditor::Property::TEXT, "Test");
477
478   TextEditor copy = textEditor;
479   DALI_TEST_CHECK(copy);
480   DALI_TEST_CHECK(copy.GetProperty<std::string>(TextEditor::Property::TEXT) == textEditor.GetProperty<std::string>(TextEditor::Property::TEXT));
481   END_TEST;
482 }
483
484 int UtcDaliTextEditorMoveAssignment(void)
485 {
486   ToolkitTestApplication application;
487
488   TextEditor textEditor = TextEditor::New();
489   textEditor.SetProperty(TextEditor::Property::TEXT, "Test");
490   DALI_TEST_CHECK(textEditor.GetProperty<std::string>(TextEditor::Property::TEXT) == "Test");
491
492   TextEditor moved;
493   moved = std::move(textEditor);
494   DALI_TEST_CHECK(moved);
495   DALI_TEST_EQUALS(1, moved.GetBaseObject().ReferenceCount(), TEST_LOCATION);
496   DALI_TEST_CHECK(moved.GetProperty<std::string>(TextEditor::Property::TEXT) == "Test");
497   DALI_TEST_CHECK(!textEditor);
498
499   END_TEST;
500 }
501
502 int UtcDaliTextEditorNewP(void)
503 {
504   ToolkitTestApplication application;
505   tet_infoline(" UtcDaliToolkitTextEditorNewP");
506   TextEditor textEditor = TextEditor::New();
507   DALI_TEST_CHECK(textEditor);
508   END_TEST;
509 }
510
511 // Positive test case for a method
512 int UtcDaliTextEditorGetPropertyP(void)
513 {
514   ToolkitTestApplication application;
515   tet_infoline(" UtcDaliToolkitTextEditorGetPropertyP");
516   TextEditor editor = TextEditor::New();
517   DALI_TEST_CHECK(editor);
518
519   // Check Property Indices are correct
520   DALI_TEST_CHECK(editor.GetPropertyIndex(PROPERTY_NAME_RENDERING_BACKEND) == DevelTextEditor::Property::RENDERING_BACKEND);
521   DALI_TEST_CHECK(editor.GetPropertyIndex(PROPERTY_NAME_TEXT) == TextEditor::Property::TEXT);
522   DALI_TEST_CHECK(editor.GetPropertyIndex(PROPERTY_NAME_TEXT_COLOR) == TextEditor::Property::TEXT_COLOR);
523   DALI_TEST_CHECK(editor.GetPropertyIndex(PROPERTY_NAME_FONT_FAMILY) == TextEditor::Property::FONT_FAMILY);
524   DALI_TEST_CHECK(editor.GetPropertyIndex(PROPERTY_NAME_FONT_STYLE) == TextEditor::Property::FONT_STYLE);
525   DALI_TEST_CHECK(editor.GetPropertyIndex(PROPERTY_NAME_POINT_SIZE) == TextEditor::Property::POINT_SIZE);
526   DALI_TEST_CHECK(editor.GetPropertyIndex(PROPERTY_NAME_HORIZONTAL_ALIGNMENT) == TextEditor::Property::HORIZONTAL_ALIGNMENT);
527   DALI_TEST_CHECK(editor.GetPropertyIndex(PROPERTY_NAME_SCROLL_THRESHOLD) == TextEditor::Property::SCROLL_THRESHOLD);
528   DALI_TEST_CHECK(editor.GetPropertyIndex(PROPERTY_NAME_SCROLL_SPEED) == TextEditor::Property::SCROLL_SPEED);
529   DALI_TEST_CHECK(editor.GetPropertyIndex(PROPERTY_NAME_PRIMARY_CURSOR_COLOR) == TextEditor::Property::PRIMARY_CURSOR_COLOR);
530   DALI_TEST_CHECK(editor.GetPropertyIndex(PROPERTY_NAME_SECONDARY_CURSOR_COLOR) == TextEditor::Property::SECONDARY_CURSOR_COLOR);
531   DALI_TEST_CHECK(editor.GetPropertyIndex(PROPERTY_NAME_ENABLE_CURSOR_BLINK) == TextEditor::Property::ENABLE_CURSOR_BLINK);
532   DALI_TEST_CHECK(editor.GetPropertyIndex(PROPERTY_NAME_CURSOR_BLINK_INTERVAL) == TextEditor::Property::CURSOR_BLINK_INTERVAL);
533   DALI_TEST_CHECK(editor.GetPropertyIndex(PROPERTY_NAME_CURSOR_BLINK_DURATION) == TextEditor::Property::CURSOR_BLINK_DURATION);
534   DALI_TEST_CHECK(editor.GetPropertyIndex(PROPERTY_NAME_CURSOR_WIDTH) == TextEditor::Property::CURSOR_WIDTH);
535   DALI_TEST_CHECK(editor.GetPropertyIndex(PROPERTY_NAME_GRAB_HANDLE_IMAGE) == TextEditor::Property::GRAB_HANDLE_IMAGE);
536   DALI_TEST_CHECK(editor.GetPropertyIndex(PROPERTY_NAME_GRAB_HANDLE_PRESSED_IMAGE) == TextEditor::Property::GRAB_HANDLE_PRESSED_IMAGE);
537   DALI_TEST_CHECK(editor.GetPropertyIndex(PROPERTY_NAME_SELECTION_HANDLE_IMAGE_LEFT) == TextEditor::Property::SELECTION_HANDLE_IMAGE_LEFT);
538   DALI_TEST_CHECK(editor.GetPropertyIndex(PROPERTY_NAME_SELECTION_HANDLE_IMAGE_RIGHT) == TextEditor::Property::SELECTION_HANDLE_IMAGE_RIGHT);
539   DALI_TEST_CHECK(editor.GetPropertyIndex(PROPERTY_NAME_SELECTION_HANDLE_PRESSED_IMAGE_LEFT) == TextEditor::Property::SELECTION_HANDLE_PRESSED_IMAGE_LEFT);
540   DALI_TEST_CHECK(editor.GetPropertyIndex(PROPERTY_NAME_SELECTION_HANDLE_PRESSED_IMAGE_RIGHT) == TextEditor::Property::SELECTION_HANDLE_PRESSED_IMAGE_RIGHT);
541   DALI_TEST_CHECK(editor.GetPropertyIndex(PROPERTY_NAME_SELECTION_HANDLE_MARKER_IMAGE_LEFT) == TextEditor::Property::SELECTION_HANDLE_MARKER_IMAGE_LEFT);
542   DALI_TEST_CHECK(editor.GetPropertyIndex(PROPERTY_NAME_SELECTION_HANDLE_MARKER_IMAGE_RIGHT) == TextEditor::Property::SELECTION_HANDLE_MARKER_IMAGE_RIGHT);
543   DALI_TEST_CHECK(editor.GetPropertyIndex(PROPERTY_NAME_SELECTION_HIGHLIGHT_COLOR) == TextEditor::Property::SELECTION_HIGHLIGHT_COLOR);
544   DALI_TEST_CHECK(editor.GetPropertyIndex(PROPERTY_NAME_DECORATION_BOUNDING_BOX) == TextEditor::Property::DECORATION_BOUNDING_BOX);
545   DALI_TEST_CHECK(editor.GetPropertyIndex(PROPERTY_NAME_ENABLE_MARKUP) == TextEditor::Property::ENABLE_MARKUP);
546   DALI_TEST_CHECK(editor.GetPropertyIndex(PROPERTY_NAME_INPUT_COLOR) == TextEditor::Property::INPUT_COLOR);
547   DALI_TEST_CHECK(editor.GetPropertyIndex(PROPERTY_NAME_INPUT_FONT_FAMILY) == TextEditor::Property::INPUT_FONT_FAMILY);
548   DALI_TEST_CHECK(editor.GetPropertyIndex(PROPERTY_NAME_INPUT_FONT_STYLE) == TextEditor::Property::INPUT_FONT_STYLE);
549   DALI_TEST_CHECK(editor.GetPropertyIndex(PROPERTY_NAME_INPUT_POINT_SIZE) == TextEditor::Property::INPUT_POINT_SIZE);
550
551   DALI_TEST_CHECK(editor.GetPropertyIndex(PROPERTY_NAME_LINE_SPACING) == TextEditor::Property::LINE_SPACING);
552   DALI_TEST_CHECK(editor.GetPropertyIndex(PROPERTY_NAME_INPUT_LINE_SPACING) == TextEditor::Property::INPUT_LINE_SPACING);
553   DALI_TEST_CHECK(editor.GetPropertyIndex(PROPERTY_NAME_UNDERLINE) == TextEditor::Property::UNDERLINE);
554   DALI_TEST_CHECK(editor.GetPropertyIndex(PROPERTY_NAME_INPUT_UNDERLINE) == TextEditor::Property::INPUT_UNDERLINE);
555   DALI_TEST_CHECK(editor.GetPropertyIndex(PROPERTY_NAME_SHADOW) == TextEditor::Property::SHADOW);
556   DALI_TEST_CHECK(editor.GetPropertyIndex(PROPERTY_NAME_INPUT_SHADOW) == TextEditor::Property::INPUT_SHADOW);
557   DALI_TEST_CHECK(editor.GetPropertyIndex(PROPERTY_NAME_EMBOSS) == TextEditor::Property::EMBOSS);
558   DALI_TEST_CHECK(editor.GetPropertyIndex(PROPERTY_NAME_INPUT_EMBOSS) == TextEditor::Property::INPUT_EMBOSS);
559   DALI_TEST_CHECK(editor.GetPropertyIndex(PROPERTY_NAME_OUTLINE) == TextEditor::Property::OUTLINE);
560   DALI_TEST_CHECK(editor.GetPropertyIndex(PROPERTY_NAME_INPUT_OUTLINE) == TextEditor::Property::INPUT_OUTLINE);
561   DALI_TEST_CHECK(editor.GetPropertyIndex(PROPERTY_NAME_STRIKETHROUGH) == DevelTextEditor::Property::STRIKETHROUGH);
562   DALI_TEST_CHECK(editor.GetPropertyIndex(PROPERTY_NAME_INPUT_STRIKETHROUGH) == DevelTextEditor::Property::INPUT_STRIKETHROUGH);
563   DALI_TEST_CHECK(editor.GetPropertyIndex(PROPERTY_NAME_SMOOTH_SCROLL) == TextEditor::Property::SMOOTH_SCROLL);
564   DALI_TEST_CHECK(editor.GetPropertyIndex(PROPERTY_NAME_SMOOTH_SCROLL_DURATION) == TextEditor::Property::SMOOTH_SCROLL_DURATION);
565   DALI_TEST_CHECK(editor.GetPropertyIndex(PROPERTY_NAME_ENABLE_SCROLL_BAR) == TextEditor::Property::ENABLE_SCROLL_BAR);
566   DALI_TEST_CHECK(editor.GetPropertyIndex(PROPERTY_NAME_SCROLL_BAR_SHOW_DURATION) == TextEditor::Property::SCROLL_BAR_SHOW_DURATION);
567   DALI_TEST_CHECK(editor.GetPropertyIndex(PROPERTY_NAME_SCROLL_BAR_FADE_DURATION) == TextEditor::Property::SCROLL_BAR_FADE_DURATION);
568   DALI_TEST_CHECK(editor.GetPropertyIndex(PROPERTY_NAME_PIXEL_SIZE) == TextEditor::Property::PIXEL_SIZE);
569   DALI_TEST_CHECK(editor.GetPropertyIndex(PROPERTY_NAME_LINE_COUNT) == TextEditor::Property::LINE_COUNT);
570   DALI_TEST_CHECK(editor.GetPropertyIndex(PROPERTY_NAME_ENABLE_SELECTION) == TextEditor::Property::ENABLE_SELECTION);
571   DALI_TEST_CHECK(editor.GetPropertyIndex(PROPERTY_NAME_PLACEHOLDER) == TextEditor::Property::PLACEHOLDER);
572   DALI_TEST_CHECK(editor.GetPropertyIndex(PROPERTY_NAME_FONT_SIZE_SCALE) == DevelTextEditor::Property::FONT_SIZE_SCALE);
573   DALI_TEST_CHECK(editor.GetPropertyIndex(PROPERTY_NAME_ENABLE_FONT_SIZE_SCALE) == DevelTextEditor::Property::ENABLE_FONT_SIZE_SCALE);
574   DALI_TEST_CHECK(editor.GetPropertyIndex(PROPERTY_NAME_PLACEHOLDER_TEXT) == DevelTextEditor::Property::PLACEHOLDER_TEXT);
575   DALI_TEST_CHECK(editor.GetPropertyIndex(PROPERTY_NAME_PLACEHOLDER_TEXT_COLOR) == DevelTextEditor::Property::PLACEHOLDER_TEXT_COLOR);
576   DALI_TEST_CHECK(editor.GetPropertyIndex(PROPERTY_NAME_ENABLE_SHIFT_SELECTION) == DevelTextEditor::Property::ENABLE_SHIFT_SELECTION);
577   DALI_TEST_CHECK(editor.GetPropertyIndex(PROPERTY_NAME_ENABLE_GRAB_HANDLE) == DevelTextEditor::Property::ENABLE_GRAB_HANDLE);
578   DALI_TEST_CHECK(editor.GetPropertyIndex(PROPERTY_NAME_MATCH_SYSTEM_LANGUAGE_DIRECTION) == DevelTextEditor::Property::MATCH_SYSTEM_LANGUAGE_DIRECTION);
579   DALI_TEST_CHECK(editor.GetPropertyIndex(PROPERTY_NAME_MAX_LENGTH) == DevelTextEditor::Property::MAX_LENGTH);
580   DALI_TEST_CHECK(editor.GetPropertyIndex(PROPERTY_NAME_GRAB_HANDLE_COLOR) == DevelTextEditor::Property::GRAB_HANDLE_COLOR);
581   DALI_TEST_CHECK(editor.GetPropertyIndex(PROPERTY_NAME_ENABLE_GRAB_HANDLE_POPUP) == DevelTextEditor::Property::ENABLE_GRAB_HANDLE_POPUP);
582   DALI_TEST_CHECK(editor.GetPropertyIndex(PROPERTY_NAME_INPUT_METHOD_SETTINGS) == DevelTextEditor::Property::INPUT_METHOD_SETTINGS);
583   DALI_TEST_CHECK(editor.GetPropertyIndex(PROPERTY_NAME_INPUT_FILTER) == DevelTextEditor::Property::INPUT_FILTER);
584   DALI_TEST_CHECK(editor.GetPropertyIndex(PROPERTY_NAME_STRIKETHROUGH) == DevelTextEditor::Property::STRIKETHROUGH);
585   DALI_TEST_CHECK(editor.GetPropertyIndex(PROPERTY_NAME_INPUT_STRIKETHROUGH) == DevelTextEditor::Property::INPUT_STRIKETHROUGH);
586   DALI_TEST_CHECK(editor.GetPropertyIndex(PROPERTY_NAME_SELECTION_POPUP_STYLE) == DevelTextEditor::Property::SELECTION_POPUP_STYLE);
587
588   END_TEST;
589 }
590
591 bool SetPropertyMapRetrieved(TextEditor& editor, const Property::Index property, const std::string mapKey, const std::string mapValue)
592 {
593   bool          result = false;
594   Property::Map imageMap;
595   imageMap[mapKey] = mapValue;
596
597   editor.SetProperty(property, imageMap);
598   Property::Value propValue = editor.GetProperty(property);
599   Property::Map*  resultMap = propValue.GetMap();
600
601   if(resultMap->Find(mapKey)->Get<std::string>() == mapValue)
602   {
603     result = true;
604   }
605
606   return result;
607 }
608
609 // Positive test case for a method
610 int UtcDaliTextEditorSetPropertyP(void)
611 {
612   ToolkitTestApplication application;
613   tet_infoline(" UtcDaliToolkitTextEditorSetPropertyP");
614   TextEditor editor = TextEditor::New();
615   DALI_TEST_CHECK(editor);
616   application.GetScene().Add(editor);
617
618   // Note - we can't check the defaults since the stylesheets are platform-specific
619
620   // Check the render backend property.
621   editor.SetProperty(DevelTextEditor::Property::RENDERING_BACKEND, DevelText::RENDERING_SHARED_ATLAS);
622   DALI_TEST_EQUALS((DevelText::RenderingType)editor.GetProperty<int>(DevelTextEditor::Property::RENDERING_BACKEND), DevelText::RENDERING_SHARED_ATLAS, TEST_LOCATION);
623
624   // Check text property.
625   editor.SetProperty(TextEditor::Property::TEXT, "Setting Text");
626   DALI_TEST_EQUALS(editor.GetProperty<std::string>(TextEditor::Property::TEXT), std::string("Setting Text"), TEST_LOCATION);
627
628   // Check text's color property
629   editor.SetProperty(TextEditor::Property::TEXT_COLOR, Color::WHITE);
630   DALI_TEST_EQUALS(editor.GetProperty<Vector4>(TextEditor::Property::TEXT_COLOR), Color::WHITE, TEST_LOCATION);
631
632   // Check font properties.
633   editor.SetProperty(TextEditor::Property::FONT_FAMILY, "Setting font family");
634   DALI_TEST_EQUALS(editor.GetProperty<std::string>(TextEditor::Property::FONT_FAMILY), std::string("Setting font family"), TEST_LOCATION);
635
636   Property::Map    fontStyleMapSet;
637   Property::Map    fontStyleMapGet;
638   Property::Value* slantValue = NULL;
639
640   fontStyleMapSet.Insert("weight", "bold");
641   fontStyleMapSet.Insert("width", "condensed");
642   fontStyleMapSet.Insert("slant", "italic");
643
644   editor.SetProperty(TextEditor::Property::FONT_STYLE, fontStyleMapSet);
645   fontStyleMapGet = editor.GetProperty<Property::Map>(TextEditor::Property::FONT_STYLE);
646   DALI_TEST_EQUALS(fontStyleMapGet.Count(), fontStyleMapSet.Count(), TEST_LOCATION);
647   DALI_TEST_EQUALS(DaliTestCheckMaps(fontStyleMapGet, fontStyleMapSet), true, TEST_LOCATION);
648
649   editor.SetProperty(TextEditor::Property::POINT_SIZE, 10.f);
650   DALI_TEST_EQUALS(editor.GetProperty<float>(TextEditor::Property::POINT_SIZE), 10.f, Math::MACHINE_EPSILON_1000, TEST_LOCATION);
651
652   editor.SetProperty(DevelTextEditor::Property::FONT_SIZE_SCALE, 2.5f);
653   DALI_TEST_EQUALS(editor.GetProperty<float>(DevelTextEditor::Property::FONT_SIZE_SCALE), 2.5f, Math::MACHINE_EPSILON_1000, TEST_LOCATION);
654   editor.SetProperty(DevelTextEditor::Property::FONT_SIZE_SCALE, 1.0f);
655
656   editor.SetProperty(DevelTextEditor::Property::ENABLE_FONT_SIZE_SCALE, false);
657   DALI_TEST_EQUALS(editor.GetProperty<bool>(DevelTextEditor::Property::ENABLE_FONT_SIZE_SCALE), false, TEST_LOCATION);
658   editor.SetProperty(DevelTextEditor::Property::ENABLE_FONT_SIZE_SCALE, true);
659
660   // Reset font style.
661   fontStyleMapSet.Clear();
662   fontStyleMapSet.Insert("weight", "normal");
663   fontStyleMapSet.Insert("slant", "oblique");
664   editor.SetProperty(TextEditor::Property::FONT_STYLE, fontStyleMapSet);
665   fontStyleMapGet = editor.GetProperty<Property::Map>(TextEditor::Property::FONT_STYLE);
666   DALI_TEST_EQUALS(fontStyleMapGet.Count(), fontStyleMapSet.Count(), TEST_LOCATION);
667   DALI_TEST_EQUALS(DaliTestCheckMaps(fontStyleMapGet, fontStyleMapSet), true, TEST_LOCATION);
668
669   fontStyleMapSet.Clear();
670   fontStyleMapSet.Insert("slant", "roman");
671   editor.SetProperty(TextEditor::Property::FONT_STYLE, fontStyleMapSet);
672   fontStyleMapGet = editor.GetProperty<Property::Map>(TextEditor::Property::FONT_STYLE);
673
674   // Replace 'roman' for 'normal'.
675   slantValue = fontStyleMapGet.Find("slant");
676   if(NULL != slantValue)
677   {
678     if("normal" == slantValue->Get<std::string>())
679     {
680       fontStyleMapGet["slant"] = "roman";
681     }
682   }
683   DALI_TEST_EQUALS(fontStyleMapGet.Count(), fontStyleMapSet.Count(), TEST_LOCATION);
684   DALI_TEST_EQUALS(DaliTestCheckMaps(fontStyleMapGet, fontStyleMapSet), true, TEST_LOCATION);
685
686   fontStyleMapSet.Clear();
687
688   editor.SetProperty(TextEditor::Property::FONT_STYLE, fontStyleMapSet);
689   fontStyleMapGet = editor.GetProperty<Property::Map>(TextEditor::Property::FONT_STYLE);
690   DALI_TEST_EQUALS(fontStyleMapGet.Count(), fontStyleMapSet.Count(), TEST_LOCATION);
691   DALI_TEST_EQUALS(DaliTestCheckMaps(fontStyleMapGet, fontStyleMapSet), true, TEST_LOCATION);
692
693   // Check that the Alignment properties can be correctly set
694   editor.SetProperty(TextEditor::Property::HORIZONTAL_ALIGNMENT, "END");
695   DALI_TEST_EQUALS(editor.GetProperty<std::string>(TextEditor::Property::HORIZONTAL_ALIGNMENT), "END", TEST_LOCATION);
696
697   // Check that the Alignment properties can be correctly set
698   editor.SetProperty(DevelTextEditor::Property::VERTICAL_ALIGNMENT, "BOTTOM");
699   DALI_TEST_EQUALS(editor.GetProperty<std::string>(DevelTextEditor::Property::VERTICAL_ALIGNMENT), "BOTTOM", TEST_LOCATION);
700   editor.SetProperty(DevelTextEditor::Property::VERTICAL_ALIGNMENT, "CENTER");
701   DALI_TEST_EQUALS(editor.GetProperty<std::string>(DevelTextEditor::Property::VERTICAL_ALIGNMENT), "CENTER", TEST_LOCATION);
702   editor.SetProperty(DevelTextEditor::Property::VERTICAL_ALIGNMENT, "TOP");
703   DALI_TEST_EQUALS(editor.GetProperty<std::string>(DevelTextEditor::Property::VERTICAL_ALIGNMENT), "TOP", TEST_LOCATION);
704
705   // Check scroll properties.
706   editor.SetProperty(TextEditor::Property::SCROLL_THRESHOLD, 1.f);
707   DALI_TEST_EQUALS(editor.GetProperty<float>(TextEditor::Property::SCROLL_THRESHOLD), 1.f, Math::MACHINE_EPSILON_1000, TEST_LOCATION);
708   editor.SetProperty(TextEditor::Property::SCROLL_SPEED, 100.f);
709   DALI_TEST_EQUALS(editor.GetProperty<float>(TextEditor::Property::SCROLL_SPEED), 100.f, Math::MACHINE_EPSILON_1000, TEST_LOCATION);
710
711   // Check cursor properties
712   editor.SetProperty(TextEditor::Property::PRIMARY_CURSOR_COLOR, Color::RED);
713   DALI_TEST_EQUALS(editor.GetProperty<Vector4>(TextEditor::Property::PRIMARY_CURSOR_COLOR), Color::RED, TEST_LOCATION);
714   editor.SetProperty(TextEditor::Property::SECONDARY_CURSOR_COLOR, Color::BLUE);
715   DALI_TEST_EQUALS(editor.GetProperty<Vector4>(TextEditor::Property::SECONDARY_CURSOR_COLOR), Color::BLUE, TEST_LOCATION);
716
717   editor.SetProperty(TextEditor::Property::ENABLE_CURSOR_BLINK, false);
718   DALI_TEST_EQUALS(editor.GetProperty<bool>(TextEditor::Property::ENABLE_CURSOR_BLINK), false, TEST_LOCATION);
719   editor.SetProperty(TextEditor::Property::CURSOR_BLINK_INTERVAL, 1.f);
720   DALI_TEST_EQUALS(editor.GetProperty<float>(TextEditor::Property::CURSOR_BLINK_INTERVAL), 1.f, Math::MACHINE_EPSILON_1000, TEST_LOCATION);
721   editor.SetProperty(TextEditor::Property::CURSOR_BLINK_DURATION, 10.f);
722   DALI_TEST_EQUALS(editor.GetProperty<float>(TextEditor::Property::CURSOR_BLINK_DURATION), 10.f, Math::MACHINE_EPSILON_1000, TEST_LOCATION);
723   editor.SetProperty(TextEditor::Property::CURSOR_WIDTH, 1);
724   DALI_TEST_EQUALS(editor.GetProperty<int>(TextEditor::Property::CURSOR_WIDTH), 1, TEST_LOCATION);
725
726   // Check handle images
727   editor.SetProperty(TextEditor::Property::GRAB_HANDLE_IMAGE, "image1");
728   DALI_TEST_EQUALS(editor.GetProperty<std::string>(TextEditor::Property::GRAB_HANDLE_IMAGE), "image1", TEST_LOCATION);
729   editor.SetProperty(TextEditor::Property::GRAB_HANDLE_PRESSED_IMAGE, "image2");
730   DALI_TEST_EQUALS(editor.GetProperty<std::string>(TextEditor::Property::GRAB_HANDLE_PRESSED_IMAGE), "image2", TEST_LOCATION);
731   editor.SetProperty(TextEditor::Property::SELECTION_HANDLE_IMAGE_LEFT, "image3");
732
733   // Check handle images
734   DALI_TEST_CHECK(SetPropertyMapRetrieved(editor, TextEditor::Property::SELECTION_HANDLE_IMAGE_LEFT, "filename", "leftHandleImage"));
735   DALI_TEST_CHECK(SetPropertyMapRetrieved(editor, TextEditor::Property::SELECTION_HANDLE_IMAGE_RIGHT, "filename", "rightHandleImage"));
736   DALI_TEST_CHECK(SetPropertyMapRetrieved(editor, TextEditor::Property::SELECTION_HANDLE_PRESSED_IMAGE_LEFT, "filename", "leftHandleImagePressed"));
737   DALI_TEST_CHECK(SetPropertyMapRetrieved(editor, TextEditor::Property::SELECTION_HANDLE_PRESSED_IMAGE_RIGHT, "filename", "rightHandleImagePressed"));
738   DALI_TEST_CHECK(SetPropertyMapRetrieved(editor, TextEditor::Property::SELECTION_HANDLE_MARKER_IMAGE_LEFT, "filename", "leftHandleMarkerImage"));
739   DALI_TEST_CHECK(SetPropertyMapRetrieved(editor, TextEditor::Property::SELECTION_HANDLE_MARKER_IMAGE_RIGHT, "filename", "rightHandleMarkerImage"));
740
741   // Check the selection popup style
742   const Vector2 popupMaxSize(200.0f, 300.0f);
743   const Vector2 optionDividerSize(30.0f, 5.0f);
744   const Vector4 optionDividerPadding(20.0f, 20.0f, 10.0f, 10.0f);
745   const Vector4 labelPadding(5.0f, 5.0f, 50.0f, 25.0f);
746
747   Property::Map selectionPopupStyle;
748   selectionPopupStyle.Insert(TextSelectionPopup::Property::POPUP_MAX_SIZE, popupMaxSize);
749   selectionPopupStyle.Insert(TextSelectionPopup::Property::OPTION_DIVIDER_SIZE, optionDividerSize);
750   selectionPopupStyle.Insert(TextSelectionPopup::Property::OPTION_DIVIDER_PADDING, optionDividerPadding);
751   selectionPopupStyle.Insert(TextSelectionPopup::Property::LABEL_PADDING, labelPadding);
752
753   editor.SetProperty(DevelTextEditor::Property::SELECTION_POPUP_STYLE, selectionPopupStyle);
754
755   Property::Map selectionPopupStyleGet;
756   selectionPopupStyleGet = editor.GetProperty<Property::Map>(DevelTextEditor::Property::SELECTION_POPUP_STYLE);
757
758   Property::Value* popupValue;
759   popupValue = selectionPopupStyleGet.Find(TextSelectionPopup::Property::POPUP_MAX_SIZE);
760   DALI_TEST_CHECK(NULL != popupValue);
761   if(popupValue)
762   {
763     Vector2 popupMaxSizeGet;
764     popupValue->Get(popupMaxSizeGet);
765     DALI_TEST_EQUALS(popupMaxSizeGet, popupMaxSize, TEST_LOCATION);
766   }
767
768   popupValue = selectionPopupStyleGet.Find(TextSelectionPopup::Property::OPTION_DIVIDER_SIZE);
769   DALI_TEST_CHECK(NULL != popupValue);
770   if(popupValue)
771   {
772     Vector2 optionDividerSizeGet;
773     popupValue->Get(optionDividerSizeGet);
774     DALI_TEST_EQUALS(optionDividerSizeGet, optionDividerSize, TEST_LOCATION);
775   }
776
777   popupValue = selectionPopupStyleGet.Find(TextSelectionPopup::Property::OPTION_DIVIDER_PADDING);
778   DALI_TEST_CHECK(NULL != popupValue);
779   if(popupValue)
780   {
781     Vector4 optionDividerPaddingGet;
782     popupValue->Get(optionDividerPaddingGet);
783     DALI_TEST_EQUALS(optionDividerPaddingGet, optionDividerPadding, TEST_LOCATION);
784   }
785
786   popupValue = selectionPopupStyleGet.Find(TextSelectionPopup::Property::LABEL_PADDING);
787   DALI_TEST_CHECK(NULL != popupValue);
788   if(popupValue)
789   {
790     Vector4 labelPaddingGet;
791     popupValue->Get(labelPaddingGet);
792     DALI_TEST_EQUALS(labelPaddingGet, labelPadding, TEST_LOCATION);
793   }
794
795   // Reset selection popup style
796   selectionPopupStyle.Clear();
797   editor.SetProperty(DevelTextEditor::Property::SELECTION_POPUP_STYLE, selectionPopupStyle);
798
799   // Check the highlight color
800   editor.SetProperty(TextEditor::Property::SELECTION_HIGHLIGHT_COLOR, Color::GREEN);
801   DALI_TEST_EQUALS(editor.GetProperty<Vector4>(TextEditor::Property::SELECTION_HIGHLIGHT_COLOR), Color::GREEN, TEST_LOCATION);
802
803   // Decoration bounding box
804   editor.SetProperty(TextEditor::Property::DECORATION_BOUNDING_BOX, Rect<int>(0, 0, 1, 1));
805   DALI_TEST_EQUALS(editor.GetProperty<Rect<int> >(TextEditor::Property::DECORATION_BOUNDING_BOX), Rect<int>(0, 0, 1, 1), TEST_LOCATION);
806
807   // Check the enable markup property.
808   DALI_TEST_CHECK(!editor.GetProperty<bool>(TextEditor::Property::ENABLE_MARKUP));
809   editor.SetProperty(TextEditor::Property::ENABLE_MARKUP, true);
810   DALI_TEST_CHECK(editor.GetProperty<bool>(TextEditor::Property::ENABLE_MARKUP));
811
812   // Check input color property.
813   editor.SetProperty(TextEditor::Property::INPUT_COLOR, Color::YELLOW);
814   DALI_TEST_EQUALS(editor.GetProperty<Vector4>(TextEditor::Property::INPUT_COLOR), Color::YELLOW, TEST_LOCATION);
815
816   // Check input font properties.
817   editor.SetProperty(TextEditor::Property::INPUT_FONT_FAMILY, "Setting input font family");
818   DALI_TEST_EQUALS(editor.GetProperty<std::string>(TextEditor::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   editor.SetProperty(TextEditor::Property::INPUT_FONT_STYLE, fontStyleMapSet);
826   fontStyleMapGet = editor.GetProperty<Property::Map>(TextEditor::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   editor.SetProperty(TextEditor::Property::INPUT_POINT_SIZE, 12.f);
831   DALI_TEST_EQUALS(editor.GetProperty<float>(TextEditor::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   editor.SetProperty(TextEditor::Property::INPUT_FONT_STYLE, fontStyleMapSet);
839   fontStyleMapGet = editor.GetProperty<Property::Map>(TextEditor::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   editor.SetProperty(TextEditor::Property::INPUT_FONT_STYLE, fontStyleMapSet);
847   fontStyleMapGet = editor.GetProperty<Property::Map>(TextEditor::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   editor.SetProperty(TextEditor::Property::INPUT_FONT_STYLE, fontStyleMapSet);
864   fontStyleMapGet = editor.GetProperty<Property::Map>(TextEditor::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   // Check the line spacing property
869   DALI_TEST_EQUALS(editor.GetProperty<float>(TextEditor::Property::LINE_SPACING), 0.0f, Math::MACHINE_EPSILON_1000, TEST_LOCATION);
870   editor.SetProperty(TextEditor::Property::LINE_SPACING, 10.f);
871   DALI_TEST_EQUALS(editor.GetProperty<float>(TextEditor::Property::LINE_SPACING), 10.0f, Math::MACHINE_EPSILON_1000, TEST_LOCATION);
872
873   // Check the input line spacing property
874   DALI_TEST_EQUALS(editor.GetProperty<float>(TextEditor::Property::INPUT_LINE_SPACING), 0.0f, Math::MACHINE_EPSILON_1000, TEST_LOCATION);
875   editor.SetProperty(TextEditor::Property::INPUT_LINE_SPACING, 20.f);
876   DALI_TEST_EQUALS(editor.GetProperty<float>(TextEditor::Property::INPUT_LINE_SPACING), 20.0f, Math::MACHINE_EPSILON_1000, TEST_LOCATION);
877
878   // Check the underline property
879
880   Property::Map underlineMapSet;
881   Property::Map underlineMapGet;
882
883   underlineMapSet.Insert("enable", true);
884   underlineMapSet.Insert("color", Color::RED);
885   underlineMapSet.Insert("height", 1);
886   underlineMapSet.Insert("type", Text::Underline::SOLID);
887   underlineMapSet.Insert("dashWidth", 5);
888   underlineMapSet.Insert("dashGap", 3);
889
890   editor.SetProperty(TextEditor::Property::UNDERLINE, underlineMapSet);
891
892   underlineMapGet = editor.GetProperty<Property::Map>(TextEditor::Property::UNDERLINE);
893   DALI_TEST_EQUALS(underlineMapGet.Count(), underlineMapSet.Count(), TEST_LOCATION);
894   DALI_TEST_EQUALS(DaliTestCheckMaps(underlineMapGet, underlineMapSet), true, TEST_LOCATION);
895
896   application.SendNotification();
897   application.Render();
898
899   // Check the dashed underline property
900
901   underlineMapSet.Clear();
902   underlineMapGet.Clear();
903
904   underlineMapSet.Insert("enable", true);
905   underlineMapSet.Insert("color", Color::RED);
906   underlineMapSet.Insert("height", 1);
907   underlineMapSet.Insert("type", Text::Underline::DASHED);
908   underlineMapSet.Insert("dashWidth", 5);
909   underlineMapSet.Insert("dashGap", 3);
910
911   editor.SetProperty(TextEditor::Property::UNDERLINE, underlineMapSet);
912
913   underlineMapGet = editor.GetProperty<Property::Map>(TextEditor::Property::UNDERLINE);
914   DALI_TEST_EQUALS(underlineMapGet.Count(), underlineMapSet.Count(), TEST_LOCATION);
915   DALI_TEST_EQUALS(DaliTestCheckMaps(underlineMapGet, underlineMapSet), true, TEST_LOCATION);
916
917   application.SendNotification();
918   application.Render();
919
920   underlineMapSet.Clear();
921   underlineMapGet.Clear();
922
923   // Check the double underline property
924
925   underlineMapSet.Clear();
926   underlineMapGet.Clear();
927
928   underlineMapSet.Insert("enable", true);
929   underlineMapSet.Insert("color", Color::RED);
930   underlineMapSet.Insert("height", 1);
931   underlineMapSet.Insert("type", Text::Underline::DOUBLE);
932   underlineMapSet.Insert("dashWidth", 5);
933   underlineMapSet.Insert("dashGap", 3);
934
935   editor.SetProperty(TextEditor::Property::UNDERLINE, underlineMapSet);
936
937   underlineMapGet = editor.GetProperty<Property::Map>(TextEditor::Property::UNDERLINE);
938   DALI_TEST_EQUALS(underlineMapGet.Count(), underlineMapSet.Count(), TEST_LOCATION);
939   DALI_TEST_EQUALS(DaliTestCheckMaps(underlineMapGet, underlineMapSet), true, TEST_LOCATION);
940
941   application.SendNotification();
942   application.Render();
943
944   underlineMapSet.Clear();
945   underlineMapGet.Clear();
946
947   // Check the input underline property
948   editor.SetProperty(TextEditor::Property::INPUT_UNDERLINE, "Underline input properties");
949   DALI_TEST_EQUALS(editor.GetProperty<std::string>(TextEditor::Property::INPUT_UNDERLINE), std::string("Underline input properties"), TEST_LOCATION);
950
951   // Check the shadow property
952   Property::Map shadowMapSet;
953   Property::Map shadowMapGet;
954
955   shadowMapSet.Insert("color", Color::GREEN);
956   shadowMapSet.Insert("offset", Vector2(2.0f, 2.0f));
957   shadowMapSet.Insert("blurRadius", 3.0f);
958
959   editor.SetProperty(TextEditor::Property::SHADOW, shadowMapSet);
960
961   shadowMapGet = editor.GetProperty<Property::Map>(TextEditor::Property::SHADOW);
962   DALI_TEST_EQUALS(shadowMapGet.Count(), shadowMapSet.Count(), TEST_LOCATION);
963   DALI_TEST_EQUALS(DaliTestCheckMaps(shadowMapGet, shadowMapSet), true, TEST_LOCATION);
964
965   // Check the input shadow property
966   editor.SetProperty(TextEditor::Property::INPUT_SHADOW, "Shadow input properties");
967   DALI_TEST_EQUALS(editor.GetProperty<std::string>(TextEditor::Property::INPUT_SHADOW), std::string("Shadow input properties"), TEST_LOCATION);
968
969   // Check the emboss property
970   editor.SetProperty(TextEditor::Property::EMBOSS, "Emboss properties");
971   DALI_TEST_EQUALS(editor.GetProperty<std::string>(TextEditor::Property::EMBOSS), std::string("Emboss properties"), TEST_LOCATION);
972
973   // Check the input emboss property
974   editor.SetProperty(TextEditor::Property::INPUT_EMBOSS, "Emboss input properties");
975   DALI_TEST_EQUALS(editor.GetProperty<std::string>(TextEditor::Property::INPUT_EMBOSS), std::string("Emboss input properties"), TEST_LOCATION);
976
977   // Check the outline property
978
979   // Test string type first
980   // This is purely to maintain backward compatibility, but we don't support string as the outline property type.
981   editor.SetProperty(TextEditor::Property::OUTLINE, "Outline properties");
982   DALI_TEST_EQUALS(editor.GetProperty<std::string>(TextEditor::Property::OUTLINE), std::string("Outline properties"), TEST_LOCATION);
983
984   // Then test the property map type
985   Property::Map outlineMapSet;
986   Property::Map outlineMapGet;
987
988   outlineMapSet["color"] = Color::RED;
989   outlineMapSet["width"] = 2.0f;
990
991   editor.SetProperty(TextEditor::Property::OUTLINE, outlineMapSet);
992
993   outlineMapGet = editor.GetProperty<Property::Map>(TextEditor::Property::OUTLINE);
994   DALI_TEST_EQUALS(outlineMapGet.Count(), outlineMapSet.Count(), TEST_LOCATION);
995   DALI_TEST_EQUALS(DaliTestCheckMaps(outlineMapGet, outlineMapSet), true, TEST_LOCATION);
996
997   // Check the input outline property
998   editor.SetProperty(TextEditor::Property::INPUT_OUTLINE, "Outline input properties");
999   DALI_TEST_EQUALS(editor.GetProperty<std::string>(TextEditor::Property::INPUT_OUTLINE), std::string("Outline input properties"), TEST_LOCATION);
1000
1001   // Check the smooth scroll property
1002   DALI_TEST_EQUALS(editor.GetProperty<bool>(TextEditor::Property::SMOOTH_SCROLL), false, TEST_LOCATION);
1003   editor.SetProperty(TextEditor::Property::SMOOTH_SCROLL, true);
1004   DALI_TEST_EQUALS(editor.GetProperty<bool>(TextEditor::Property::SMOOTH_SCROLL), true, TEST_LOCATION);
1005
1006   // Check the smooth scroll duration property
1007   editor.SetProperty(TextEditor::Property::SMOOTH_SCROLL_DURATION, 0.2f);
1008   DALI_TEST_EQUALS(editor.GetProperty<float>(TextEditor::Property::SMOOTH_SCROLL_DURATION), 0.2f, Math::MACHINE_EPSILON_1000, TEST_LOCATION);
1009
1010   // Check the scroll bar property
1011   DALI_TEST_EQUALS(editor.GetProperty<bool>(TextEditor::Property::ENABLE_SCROLL_BAR), false, TEST_LOCATION);
1012   editor.SetProperty(TextEditor::Property::ENABLE_SCROLL_BAR, true);
1013   DALI_TEST_EQUALS(editor.GetProperty<bool>(TextEditor::Property::ENABLE_SCROLL_BAR), true, TEST_LOCATION);
1014
1015   editor.SetProperty(TextEditor::Property::SCROLL_BAR_SHOW_DURATION, 0.3f);
1016   DALI_TEST_EQUALS(editor.GetProperty<float>(TextEditor::Property::SCROLL_BAR_SHOW_DURATION), 0.3f, Math::MACHINE_EPSILON_1000, TEST_LOCATION);
1017   editor.SetProperty(TextEditor::Property::SCROLL_BAR_FADE_DURATION, 0.2f);
1018   DALI_TEST_EQUALS(editor.GetProperty<float>(TextEditor::Property::SCROLL_BAR_FADE_DURATION), 0.2f, Math::MACHINE_EPSILON_1000, TEST_LOCATION);
1019
1020   // Check the pixel size of font
1021   editor.SetProperty(TextEditor::Property::PIXEL_SIZE, 20.f);
1022   DALI_TEST_EQUALS(editor.GetProperty<float>(TextEditor::Property::PIXEL_SIZE), 20.f, Math::MACHINE_EPSILON_1000, TEST_LOCATION);
1023
1024   // Check placeholder text properties.
1025   editor.SetProperty(DevelTextEditor::Property::PLACEHOLDER_TEXT, "Setting Placeholder Text");
1026   DALI_TEST_EQUALS(editor.GetProperty<std::string>(DevelTextEditor::Property::PLACEHOLDER_TEXT), std::string("Setting Placeholder Text"), TEST_LOCATION);
1027
1028   // Check placeholder text's color property.
1029   editor.SetProperty(DevelTextEditor::Property::PLACEHOLDER_TEXT_COLOR, Color::RED);
1030   DALI_TEST_EQUALS(editor.GetProperty<Vector4>(DevelTextEditor::Property::PLACEHOLDER_TEXT_COLOR), Color::RED, TEST_LOCATION);
1031
1032   // Check the enable selection property
1033   editor.SetProperty(TextEditor::Property::ENABLE_SELECTION, false);
1034   DALI_TEST_EQUALS(editor.GetProperty<bool>(TextEditor::Property::ENABLE_SELECTION), false, TEST_LOCATION);
1035
1036   // Check the placeholder property with pixel size
1037   Property::Map placeholderPixelSizeMapSet;
1038   Property::Map placeholderPixelSizeMapGet;
1039   Property::Map placeholderFontstyleMap;
1040   placeholderPixelSizeMapSet["text"]        = "Setting Placeholder Text";
1041   placeholderPixelSizeMapSet["textFocused"] = "Setting Placeholder Text Focused";
1042   placeholderPixelSizeMapSet["color"]       = Color::BLUE;
1043   placeholderPixelSizeMapSet["fontFamily"]  = "Arial";
1044   placeholderPixelSizeMapSet["pixelSize"]   = 15.0f;
1045
1046   placeholderFontstyleMap.Insert("weight", "bold");
1047   placeholderPixelSizeMapSet["fontStyle"] = placeholderFontstyleMap;
1048   editor.SetProperty(TextEditor::Property::PLACEHOLDER, placeholderPixelSizeMapSet);
1049
1050   placeholderPixelSizeMapGet = editor.GetProperty<Property::Map>(TextEditor::Property::PLACEHOLDER);
1051   DALI_TEST_EQUALS(placeholderPixelSizeMapGet.Count(), placeholderPixelSizeMapSet.Count(), TEST_LOCATION);
1052
1053   tet_infoline("Test Placeholder settings set as strings is converted correctly to Property Index key and holds set value");
1054   Property::Map placeholderConversionMap;
1055   placeholderConversionMap[Text::PlaceHolder::Property::TEXT]         = placeholderPixelSizeMapSet["text"];
1056   placeholderConversionMap[Text::PlaceHolder::Property::TEXT_FOCUSED] = placeholderPixelSizeMapSet["textFocused"];
1057   placeholderConversionMap[Text::PlaceHolder::Property::COLOR]        = placeholderPixelSizeMapSet["color"];
1058   placeholderConversionMap[Text::PlaceHolder::Property::FONT_STYLE]   = placeholderPixelSizeMapSet["fontStyle"];
1059   placeholderConversionMap[Text::PlaceHolder::Property::FONT_FAMILY]  = placeholderPixelSizeMapSet["fontFamily"];
1060   placeholderConversionMap[Text::PlaceHolder::Property::PIXEL_SIZE]   = placeholderPixelSizeMapSet["pixelSize"];
1061
1062   DALI_TEST_EQUALS(DaliTestCheckMaps(placeholderPixelSizeMapGet, placeholderConversionMap), true, TEST_LOCATION);
1063
1064   // Check the placeholder property with point size
1065   Property::Map placeholderMapSet;
1066   Property::Map placeholderMapGet;
1067   placeholderMapSet["text"]        = "Setting Placeholder Text";
1068   placeholderMapSet["textFocused"] = "Setting Placeholder Text Focused";
1069   placeholderMapSet["color"]       = Color::RED;
1070   placeholderMapSet["fontFamily"]  = "Arial";
1071   placeholderMapSet["pointSize"]   = 12.0f;
1072   // Check the placeholder font style property
1073   placeholderFontstyleMap.Clear();
1074
1075   placeholderFontstyleMap.Insert("weight", "bold");
1076   placeholderFontstyleMap.Insert("width", "condensed");
1077   placeholderFontstyleMap.Insert("slant", "italic");
1078   placeholderMapSet["fontStyle"] = placeholderFontstyleMap;
1079   editor.SetProperty(TextEditor::Property::PLACEHOLDER, placeholderMapSet);
1080
1081   placeholderMapGet = editor.GetProperty<Property::Map>(TextEditor::Property::PLACEHOLDER);
1082   DALI_TEST_EQUALS(placeholderMapGet.Count(), placeholderMapSet.Count(), TEST_LOCATION);
1083
1084   tet_infoline("Test Placeholder settings set as strings is converted correctly to Property Index key and holds set value");
1085   placeholderConversionMap.Clear();
1086   placeholderConversionMap[Text::PlaceHolder::Property::TEXT]         = placeholderMapSet["text"];
1087   placeholderConversionMap[Text::PlaceHolder::Property::TEXT_FOCUSED] = placeholderMapSet["textFocused"];
1088   placeholderConversionMap[Text::PlaceHolder::Property::COLOR]        = placeholderMapSet["color"];
1089   placeholderConversionMap[Text::PlaceHolder::Property::FONT_STYLE]   = placeholderPixelSizeMapSet["fontStyle"];
1090   placeholderConversionMap[Text::PlaceHolder::Property::FONT_FAMILY]  = placeholderMapSet["fontFamily"];
1091   placeholderConversionMap[Text::PlaceHolder::Property::POINT_SIZE]   = placeholderMapSet["pointSize"];
1092   DALI_TEST_EQUALS(DaliTestCheckMaps(placeholderMapGet, placeholderConversionMap), true, TEST_LOCATION);
1093
1094   // Reset font style.
1095   placeholderFontstyleMap.Clear();
1096   placeholderFontstyleMap.Insert("weight", "normal");
1097   placeholderFontstyleMap.Insert("slant", "oblique");
1098   placeholderMapSet["fontStyle"] = placeholderFontstyleMap;
1099   editor.SetProperty(TextEditor::Property::PLACEHOLDER, placeholderMapSet);
1100
1101   placeholderMapGet = editor.GetProperty<Property::Map>(TextEditor::Property::PLACEHOLDER);
1102   DALI_TEST_EQUALS(placeholderMapGet.Count(), placeholderMapSet.Count(), TEST_LOCATION);
1103   placeholderConversionMap[Text::PlaceHolder::Property::FONT_STYLE] = placeholderMapSet["fontStyle"];
1104   DALI_TEST_EQUALS(DaliTestCheckMaps(placeholderMapGet, placeholderConversionMap), true, TEST_LOCATION);
1105
1106   placeholderFontstyleMap.Clear();
1107   placeholderFontstyleMap.Insert("slant", "roman");
1108   placeholderMapSet["fontStyle"] = placeholderFontstyleMap;
1109   editor.SetProperty(TextEditor::Property::PLACEHOLDER, placeholderMapSet);
1110
1111   placeholderMapGet = editor.GetProperty<Property::Map>(TextEditor::Property::PLACEHOLDER);
1112
1113   placeholderFontstyleMap.Clear();
1114   placeholderMapSet["fontStyle"] = placeholderFontstyleMap;
1115
1116   editor.SetProperty(TextEditor::Property::PLACEHOLDER, placeholderMapSet);
1117   placeholderMapGet = editor.GetProperty<Property::Map>(TextEditor::Property::PLACEHOLDER);
1118   DALI_TEST_EQUALS(placeholderMapGet.Count(), placeholderMapSet.Count(), TEST_LOCATION);
1119   placeholderConversionMap[Text::PlaceHolder::Property::FONT_STYLE] = placeholderMapSet["fontStyle"];
1120   DALI_TEST_EQUALS(DaliTestCheckMaps(placeholderMapGet, placeholderConversionMap), true, TEST_LOCATION);
1121
1122   editor.SetProperty(Actor::Property::LAYOUT_DIRECTION, LayoutDirection::RIGHT_TO_LEFT);
1123   DALI_TEST_EQUALS(editor.GetProperty<int>(Actor::Property::LAYOUT_DIRECTION), static_cast<int>(LayoutDirection::RIGHT_TO_LEFT), TEST_LOCATION);
1124
1125   // Check handle color
1126   editor.SetProperty(DevelTextEditor::Property::GRAB_HANDLE_COLOR, Color::GREEN);
1127   DALI_TEST_EQUALS(editor.GetProperty<Vector4>(DevelTextEditor::Property::GRAB_HANDLE_COLOR), Color::GREEN, TEST_LOCATION);
1128
1129   // Test the ENABLE_GRAB_HANDLE_POPUP property
1130   editor.SetProperty(DevelTextEditor::Property::ENABLE_GRAB_HANDLE_POPUP, false);
1131   DALI_TEST_EQUALS(editor.GetProperty<bool>(DevelTextEditor::Property::ENABLE_GRAB_HANDLE_POPUP), false, TEST_LOCATION);
1132
1133   // Check the input method setting
1134   Property::Map                   propertyMap;
1135   InputMethod::PanelLayout::Type  panelLayout    = InputMethod::PanelLayout::NUMBER;
1136   InputMethod::AutoCapital::Type  autoCapital    = InputMethod::AutoCapital::WORD;
1137   InputMethod::ButtonAction::Type buttonAction   = InputMethod::ButtonAction::GO;
1138   int                             inputVariation = 1;
1139   propertyMap["PANEL_LAYOUT"]                    = panelLayout;
1140   propertyMap["AUTO_CAPITALIZE"]                 = autoCapital;
1141   propertyMap["BUTTON_ACTION"]                   = buttonAction;
1142   propertyMap["VARIATION"]                       = inputVariation;
1143   editor.SetProperty(DevelTextEditor::Property::INPUT_METHOD_SETTINGS, propertyMap);
1144
1145   Property::Value value = editor.GetProperty(DevelTextEditor::Property::INPUT_METHOD_SETTINGS);
1146   Property::Map   map;
1147   DALI_TEST_CHECK(value.Get(map));
1148
1149   int layout = 0;
1150   DALI_TEST_CHECK(map["PANEL_LAYOUT"].Get(layout));
1151   DALI_TEST_EQUALS(static_cast<int>(panelLayout), layout, TEST_LOCATION);
1152
1153   int capital = 0;
1154   DALI_TEST_CHECK(map["AUTO_CAPITALIZE"].Get(capital));
1155   DALI_TEST_EQUALS(static_cast<int>(autoCapital), capital, TEST_LOCATION);
1156
1157   int action = 0;
1158   DALI_TEST_CHECK(map["BUTTON_ACTION"].Get(action));
1159   DALI_TEST_EQUALS(static_cast<int>(buttonAction), action, TEST_LOCATION);
1160
1161   int variation = 0;
1162   DALI_TEST_CHECK(map["VARIATION"].Get(variation));
1163   DALI_TEST_EQUALS(inputVariation, variation, TEST_LOCATION);
1164
1165   // Check the input filter property
1166   Property::Map inputFilterMapSet;
1167   Property::Map inputFilterMapGet;
1168   inputFilterMapSet[InputFilter::Property::ACCEPTED] = "[\\w]";
1169   inputFilterMapSet[InputFilter::Property::REJECTED] = "[\\d]";
1170
1171   editor.SetProperty(DevelTextEditor::Property::INPUT_FILTER, inputFilterMapSet);
1172
1173   inputFilterMapGet = editor.GetProperty<Property::Map>(DevelTextEditor::Property::INPUT_FILTER);
1174   DALI_TEST_EQUALS(inputFilterMapGet.Count(), inputFilterMapSet.Count(), TEST_LOCATION);
1175
1176   // Clear
1177   inputFilterMapSet.Clear();
1178   editor.SetProperty(DevelTextEditor::Property::INPUT_FILTER, inputFilterMapSet);
1179
1180   // Check the strikethrough property
1181
1182   Property::Map strikethroughMapSet;
1183   Property::Map strikethroughMapGet;
1184
1185   application.SendNotification();
1186   application.Render();
1187
1188   // Check the input strikethrough property
1189
1190   strikethroughMapSet.Clear();
1191   strikethroughMapGet.Clear();
1192   strikethroughMapSet.Insert("enable", true);
1193   strikethroughMapSet.Insert("color", Color::BLUE);
1194   strikethroughMapSet.Insert("height", 2.0f);
1195
1196   editor.SetProperty(DevelTextEditor::Property::STRIKETHROUGH, strikethroughMapSet);
1197
1198   application.SendNotification();
1199   application.Render();
1200
1201   strikethroughMapGet = editor.GetProperty<Property::Map>(DevelTextEditor::Property::STRIKETHROUGH);
1202
1203   DALI_TEST_EQUALS(strikethroughMapGet.Count(), strikethroughMapSet.Count(), TEST_LOCATION);
1204   DALI_TEST_EQUALS(DaliTestCheckMaps(strikethroughMapSet, strikethroughMapGet), true, TEST_LOCATION);
1205
1206   // Check the input strikethrough property
1207   editor.SetProperty(DevelTextEditor::Property::INPUT_STRIKETHROUGH, "Strikethrough input properties");
1208   DALI_TEST_EQUALS(editor.GetProperty<std::string>(DevelTextEditor::Property::INPUT_STRIKETHROUGH), std::string("Strikethrough input properties"), TEST_LOCATION);
1209
1210   application.SendNotification();
1211   application.Render();
1212
1213   // Check the line size property
1214   DALI_TEST_EQUALS(editor.GetProperty<float>(DevelTextEditor::Property::MIN_LINE_SIZE), 0.0f, Math::MACHINE_EPSILON_1000, TEST_LOCATION);
1215   editor.SetProperty(DevelTextEditor::Property::MIN_LINE_SIZE, 50.f);
1216   DALI_TEST_EQUALS(editor.GetProperty<float>(DevelTextEditor::Property::MIN_LINE_SIZE), 50.0f, Math::MACHINE_EPSILON_1000, TEST_LOCATION);
1217
1218   END_TEST;
1219 }
1220
1221 // Positive Atlas Text Renderer test
1222 int utcDaliTextEditorAtlasRenderP(void)
1223 {
1224   ToolkitTestApplication application;
1225   tet_infoline(" UtcDaliToolkitTextEditorAtlasRenderP");
1226   StyleManager styleManager = StyleManager::Get();
1227   styleManager.ApplyDefaultTheme();
1228   TextEditor editor = TextEditor::New();
1229   DALI_TEST_CHECK(editor);
1230
1231   editor.SetProperty(TextEditor::Property::HORIZONTAL_ALIGNMENT, "CENTER");
1232
1233   application.GetGlAbstraction().SetCheckFramebufferStatusResult(GL_FRAMEBUFFER_COMPLETE);
1234
1235   application.GetScene().Add(editor);
1236
1237   try
1238   {
1239     // Render some text with the shared atlas backend
1240     editor.SetProperty(DevelTextEditor::Property::RENDERING_BACKEND, DevelText::RENDERING_SHARED_ATLAS);
1241     application.SendNotification();
1242     application.Render();
1243   }
1244   catch(...)
1245   {
1246     tet_result(TET_FAIL);
1247   }
1248   END_TEST;
1249 }
1250
1251 // Positive test for the anchorClicked signal.
1252 int utcDaliTextEditorAnchorClickedP(void)
1253 {
1254   ToolkitTestApplication application;
1255   tet_infoline(" utcDaliTextEditorAnchorClickedP");
1256   TextEditor editor = TextEditor::New();
1257   DALI_TEST_CHECK(editor);
1258
1259   application.GetScene().Add(editor);
1260
1261   // connect to the anchor clicked signal.
1262   ConnectionTracker* testTracker = new ConnectionTracker();
1263   DevelTextEditor::AnchorClickedSignal(editor).Connect(&TestAnchorClickedCallback);
1264   bool anchorClickedSignal = false;
1265   editor.ConnectSignal(testTracker, "anchorClicked", CallbackFunctor(&anchorClickedSignal));
1266
1267   gAnchorClickedCallBackCalled = false;
1268   editor.SetProperty(TextEditor::Property::TEXT, "<a href='https://www.tizen.org'>TIZEN</a>");
1269   editor.SetProperty(TextEditor::Property::ENABLE_MARKUP, true);
1270   editor.SetProperty(Actor::Property::SIZE, Vector2(100.f, 50.f));
1271   editor.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT);
1272   editor.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
1273
1274   application.SendNotification();
1275   application.Render();
1276   editor.SetKeyInputFocus();
1277
1278   // Create a tap event to touch the text editor.
1279   TestGenerateTap(application, 5.0f, 5.0f);
1280   application.SendNotification();
1281   application.Render();
1282
1283   DALI_TEST_CHECK(gAnchorClickedCallBackCalled);
1284   DALI_TEST_CHECK(anchorClickedSignal);
1285
1286   gAnchorClickedCallBackNotCalled = true;
1287   // Tap the outside of anchor, callback should not be called.
1288   TestGenerateTap(application, 150.f, 100.f);
1289   application.SendNotification();
1290   application.Render();
1291
1292   DALI_TEST_CHECK(gAnchorClickedCallBackNotCalled);
1293
1294   END_TEST;
1295 }
1296
1297 // Positive test for the textChanged signal.
1298 int utcDaliTextEditorTextChangedP(void)
1299 {
1300   ToolkitTestApplication application;
1301   tet_infoline(" utcDaliTextEditorTextChangedP");
1302   TextEditor editor = TextEditor::New();
1303   DALI_TEST_CHECK(editor);
1304
1305   application.GetScene().Add(editor);
1306
1307   // connect to the text changed signal.
1308   ConnectionTracker* testTracker = new ConnectionTracker();
1309   editor.TextChangedSignal().Connect(&TestTextChangedCallback);
1310   bool textChangedSignal = false;
1311   editor.ConnectSignal(testTracker, "textChanged", CallbackFunctor(&textChangedSignal));
1312
1313   gTextChangedCallBackCalled = false;
1314   editor.SetProperty(TextEditor::Property::TEXT, "ABC");
1315   DALI_TEST_CHECK(gTextChangedCallBackCalled);
1316   DALI_TEST_CHECK(textChangedSignal);
1317
1318   application.SendNotification();
1319   editor.SetKeyInputFocus();
1320
1321   gTextChangedCallBackCalled = false;
1322   application.ProcessEvent(GenerateKey("D", "", "D", KEY_D_CODE, 0, 0, Integration::KeyEvent::DOWN, "D", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
1323   DALI_TEST_CHECK(gTextChangedCallBackCalled);
1324
1325   // Remove all text
1326   editor.SetProperty(TextField::Property::TEXT, "");
1327
1328   // Pressing backspace key: TextChangedCallback should not be called when there is no text in texteditor.
1329   gTextChangedCallBackCalled = false;
1330   application.ProcessEvent(GenerateKey("", "", "", DALI_KEY_BACKSPACE, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
1331   DALI_TEST_CHECK(!gTextChangedCallBackCalled);
1332
1333   // Pressing delete key: TextChangedCallback should not be called when there is no text in texteditor.
1334   gTextChangedCallBackCalled = false;
1335   application.ProcessEvent(GenerateKey("", "", "", Dali::DevelKey::DALI_KEY_DELETE, 0, 0, Integration::KeyEvent::DOWN, "Delete", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
1336   DALI_TEST_CHECK(!gTextChangedCallBackCalled);
1337
1338   END_TEST;
1339 }
1340
1341 int utcDaliTextEditorTextChangedWithInputMethodContext(void)
1342 {
1343   ToolkitTestApplication application;
1344   tet_infoline(" utcDaliTextEditorTextChangedWithInputMethodContext");
1345   TextEditor editor = TextEditor::New();
1346   DALI_TEST_CHECK(editor);
1347
1348   application.GetScene().Add(editor);
1349
1350   // connect to the text changed signal.
1351   ConnectionTracker* testTracker = new ConnectionTracker();
1352   editor.TextChangedSignal().Connect(&TestTextChangedCallback);
1353   bool textChangedSignal = false;
1354   editor.ConnectSignal(testTracker, "textChanged", CallbackFunctor(&textChangedSignal));
1355
1356   // get InputMethodContext
1357   std::string                   text;
1358   InputMethodContext::EventData imfEvent;
1359   InputMethodContext            inputMethodContext = DevelTextEditor::GetInputMethodContext(editor);
1360
1361   editor.SetKeyInputFocus();
1362   editor.SetProperty(DevelTextEditor::Property::ENABLE_EDITING, true);
1363
1364   // input text
1365   gTextChangedCallBackCalled = false;
1366   imfEvent                   = InputMethodContext::EventData(InputMethodContext::PRE_EDIT, "ㅎ", 0, 1);
1367   inputMethodContext.EventReceivedSignal().Emit(inputMethodContext, imfEvent);
1368   application.SendNotification();
1369   application.Render();
1370   DALI_TEST_CHECK(gTextChangedCallBackCalled);
1371   DALI_TEST_EQUALS(editor.GetProperty<std::string>(TextEditor::Property::TEXT), std::string("ㅎ"), TEST_LOCATION);
1372
1373   gTextChangedCallBackCalled = false;
1374   imfEvent                   = InputMethodContext::EventData(InputMethodContext::PRE_EDIT, "호", 0, 1);
1375   inputMethodContext.EventReceivedSignal().Emit(inputMethodContext, imfEvent);
1376   application.SendNotification();
1377   application.Render();
1378   DALI_TEST_CHECK(gTextChangedCallBackCalled);
1379   DALI_TEST_EQUALS(editor.GetProperty<std::string>(TextEditor::Property::TEXT), std::string("호"), TEST_LOCATION);
1380
1381   gTextChangedCallBackCalled = false;
1382   imfEvent                   = InputMethodContext::EventData(InputMethodContext::PRE_EDIT, "혿", 0, 1);
1383   inputMethodContext.EventReceivedSignal().Emit(inputMethodContext, imfEvent);
1384   application.SendNotification();
1385   application.Render();
1386   DALI_TEST_CHECK(gTextChangedCallBackCalled);
1387   DALI_TEST_EQUALS(editor.GetProperty<std::string>(TextEditor::Property::TEXT), std::string("혿"), TEST_LOCATION);
1388
1389   gTextChangedCallBackCalled = false;
1390   imfEvent                   = InputMethodContext::EventData(InputMethodContext::PRE_EDIT, "", 0, 1);
1391   inputMethodContext.EventReceivedSignal().Emit(inputMethodContext, imfEvent);
1392   DALI_TEST_CHECK(!gTextChangedCallBackCalled);
1393
1394   imfEvent = InputMethodContext::EventData(InputMethodContext::COMMIT, "호", 0, 1);
1395   inputMethodContext.EventReceivedSignal().Emit(inputMethodContext, imfEvent);
1396   DALI_TEST_CHECK(!gTextChangedCallBackCalled);
1397
1398   imfEvent = InputMethodContext::EventData(InputMethodContext::PRE_EDIT, "두", 1, 2);
1399   inputMethodContext.EventReceivedSignal().Emit(inputMethodContext, imfEvent);
1400   DALI_TEST_CHECK(!gTextChangedCallBackCalled);
1401
1402   application.SendNotification();
1403   application.Render();
1404   DALI_TEST_CHECK(gTextChangedCallBackCalled);
1405   DALI_TEST_EQUALS(editor.GetProperty<std::string>(TextEditor::Property::TEXT), std::string("호두"), TEST_LOCATION);
1406
1407   END_TEST;
1408 }
1409
1410 int utcDaliTextEditorInputStyleChanged01(void)
1411 {
1412   // The text-editor emits signals when the input style changes. These changes of style are
1413   // detected during the relayout process (size negotiation), i.e after the cursor has been moved. Signals
1414   // can't be emitted during the size negotiation as the callbacks may update the UI.
1415   // The text-editor adds an idle callback to the adaptor to emit the signals after the size negotiation.
1416   // The ToolkitTestApplication creates an implementation of the adaptor stub and a queue of idle callbacks.
1417   ToolkitTestApplication application;
1418   tet_infoline(" utcDaliTextEditorInputStyleChanged01");
1419
1420   // Load some fonts.
1421
1422   char*             pathNamePtr = get_current_dir_name();
1423   const std::string pathName(pathNamePtr);
1424   free(pathNamePtr);
1425
1426   TextAbstraction::FontClient fontClient = TextAbstraction::FontClient::Get();
1427   fontClient.SetDpi(93u, 93u);
1428
1429   fontClient.GetFontId(pathName + DEFAULT_FONT_DIR + "/dejavu/DejaVuSerif.ttf", DEFAULT_FONT_SIZE);
1430   fontClient.GetFontId(pathName + DEFAULT_FONT_DIR + "/dejavu/DejaVuSerif-Bold.ttf", DEFAULT_FONT_SIZE);
1431
1432   TextEditor editor = TextEditor::New();
1433   DALI_TEST_CHECK(editor);
1434
1435   editor.SetProperty(Actor::Property::SIZE, Vector2(300.f, 50.f));
1436   editor.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT);
1437   editor.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
1438
1439   editor.SetProperty(TextEditor::Property::ENABLE_MARKUP, true);
1440   editor.SetProperty(TextEditor::Property::TEXT, "<font family='DejaVuSerif' size='18'>He<color value='green'>llo</color> <font weight='bold'>world</font> demo</font>");
1441
1442   // connect to the text changed signal.
1443   ConnectionTracker* testTracker = new ConnectionTracker();
1444   editor.InputStyleChangedSignal().Connect(&TestInputStyleChangedCallback);
1445   bool inputStyleChangedSignal = false;
1446   editor.ConnectSignal(testTracker, "inputStyleChanged", CallbackFunctor(&inputStyleChangedSignal));
1447
1448   application.GetScene().Add(editor);
1449
1450   // Render and notify
1451   application.SendNotification();
1452   application.Render();
1453
1454   // Executes the idle callbacks added by the text control on the change of input style.
1455   application.RunIdles();
1456
1457   gInputStyleChangedCallbackCalled = false;
1458   gInputStyleMask                  = TextEditor::InputStyle::NONE;
1459   inputStyleChangedSignal          = false;
1460
1461   // Create a tap event to touch the text editor.
1462   TestGenerateTap(application, 18.0f, 25.0f);
1463
1464   // Render and notify
1465   application.SendNotification();
1466   application.Render();
1467
1468   // Executes the idle callbacks added by the text control on the change of input style.
1469   application.RunIdles();
1470
1471   DALI_TEST_CHECK(gInputStyleChangedCallbackCalled);
1472   if(gInputStyleChangedCallbackCalled)
1473   {
1474     DALI_TEST_EQUALS(static_cast<unsigned int>(gInputStyleMask), static_cast<unsigned int>(TextEditor::InputStyle::FONT_FAMILY | TextEditor::InputStyle::POINT_SIZE), TEST_LOCATION);
1475
1476     const std::string fontFamily = editor.GetProperty(TextEditor::Property::INPUT_FONT_FAMILY).Get<std::string>();
1477     DALI_TEST_EQUALS(fontFamily, "DejaVuSerif", TEST_LOCATION);
1478
1479     const float pointSize = editor.GetProperty(TextEditor::Property::INPUT_POINT_SIZE).Get<float>();
1480     DALI_TEST_EQUALS(pointSize, 18.f, Math::MACHINE_EPSILON_1000, TEST_LOCATION);
1481   }
1482   DALI_TEST_CHECK(inputStyleChangedSignal);
1483
1484   gInputStyleChangedCallbackCalled = false;
1485   gInputStyleMask                  = TextEditor::InputStyle::NONE;
1486   inputStyleChangedSignal          = false;
1487
1488   // Create a tap event to touch the text editor.
1489   TestGenerateTap(application, 30.0f, 25.0f);
1490
1491   // Render and notify
1492   application.SendNotification();
1493   application.Render();
1494
1495   // Executes the idle callbacks added by the text control on the change of input style.
1496   application.RunIdles();
1497
1498   DALI_TEST_CHECK(!gInputStyleChangedCallbackCalled);
1499   DALI_TEST_CHECK(!inputStyleChangedSignal);
1500
1501   gInputStyleChangedCallbackCalled = false;
1502   gInputStyleMask                  = TextEditor::InputStyle::NONE;
1503   inputStyleChangedSignal          = false;
1504
1505   // Create a tap event to touch the text editor.
1506   TestGenerateTap(application, 43.0f, 25.0f);
1507
1508   // Render and notify
1509   application.SendNotification();
1510   application.Render();
1511
1512   // Executes the idle callbacks added by the text control on the change of input style.
1513   application.RunIdles();
1514
1515   DALI_TEST_CHECK(gInputStyleChangedCallbackCalled);
1516   if(gInputStyleChangedCallbackCalled)
1517   {
1518     DALI_TEST_EQUALS(static_cast<unsigned int>(gInputStyleMask), static_cast<unsigned int>(TextEditor::InputStyle::COLOR), TEST_LOCATION);
1519
1520     const Vector4 color = editor.GetProperty(TextEditor::Property::INPUT_COLOR).Get<Vector4>();
1521     DALI_TEST_EQUALS(color, Color::GREEN, TEST_LOCATION);
1522   }
1523   DALI_TEST_CHECK(inputStyleChangedSignal);
1524
1525   gInputStyleChangedCallbackCalled = false;
1526   gInputStyleMask                  = TextEditor::InputStyle::NONE;
1527   inputStyleChangedSignal          = false;
1528
1529   // Create a tap event to touch the text editor.
1530   TestGenerateTap(application, 88.0f, 25.0f);
1531
1532   // Render and notify
1533   application.SendNotification();
1534   application.Render();
1535
1536   // Executes the idle callbacks added by the text control on the change of input style.
1537   application.RunIdles();
1538
1539   DALI_TEST_CHECK(gInputStyleChangedCallbackCalled);
1540   if(gInputStyleChangedCallbackCalled)
1541   {
1542     DALI_TEST_EQUALS(static_cast<unsigned int>(gInputStyleMask), static_cast<unsigned int>(TextEditor::InputStyle::COLOR | TextEditor::InputStyle::FONT_STYLE), TEST_LOCATION);
1543
1544     const Vector4 color = editor.GetProperty(TextEditor::Property::INPUT_COLOR).Get<Vector4>();
1545     DALI_TEST_EQUALS(color, Color::BLACK, TEST_LOCATION);
1546
1547     Property::Map fontStyleMapSet;
1548     Property::Map fontStyleMapGet;
1549
1550     fontStyleMapSet.Insert("weight", "bold");
1551
1552     fontStyleMapGet = editor.GetProperty<Property::Map>(TextEditor::Property::INPUT_FONT_STYLE);
1553     DALI_TEST_EQUALS(fontStyleMapGet.Count(), fontStyleMapSet.Count(), TEST_LOCATION);
1554     DALI_TEST_EQUALS(DaliTestCheckMaps(fontStyleMapGet, fontStyleMapSet), true, TEST_LOCATION);
1555   }
1556   DALI_TEST_CHECK(inputStyleChangedSignal);
1557
1558   gInputStyleChangedCallbackCalled = false;
1559   gInputStyleMask                  = TextEditor::InputStyle::NONE;
1560   inputStyleChangedSignal          = false;
1561
1562   // Create a tap event to touch the text editor.
1563   TestGenerateTap(application, 115.0f, 25.0f);
1564
1565   // Render and notify
1566   application.SendNotification();
1567   application.Render();
1568
1569   // Executes the idle callbacks added by the text control on the change of input style.
1570   application.RunIdles();
1571
1572   DALI_TEST_CHECK(!gInputStyleChangedCallbackCalled);
1573   DALI_TEST_CHECK(!inputStyleChangedSignal);
1574
1575   gInputStyleChangedCallbackCalled = false;
1576   gInputStyleMask                  = TextEditor::InputStyle::NONE;
1577   inputStyleChangedSignal          = false;
1578
1579   // Create a tap event to touch the text editor.
1580   TestGenerateTap(application, 164.0f, 25.0f);
1581
1582   // Render and notify
1583   application.SendNotification();
1584   application.Render();
1585
1586   // Executes the idle callbacks added by the text control on the change of input style.
1587   application.RunIdles();
1588
1589   DALI_TEST_CHECK(gInputStyleChangedCallbackCalled);
1590   if(gInputStyleChangedCallbackCalled)
1591   {
1592     DALI_TEST_EQUALS(static_cast<unsigned int>(gInputStyleMask), static_cast<unsigned int>(TextEditor::InputStyle::FONT_STYLE), TEST_LOCATION);
1593
1594     Property::Map fontStyleMapSet;
1595     Property::Map fontStyleMapGet;
1596
1597     fontStyleMapGet = editor.GetProperty<Property::Map>(TextEditor::Property::INPUT_FONT_STYLE);
1598     DALI_TEST_EQUALS(fontStyleMapGet.Count(), fontStyleMapSet.Count(), TEST_LOCATION);
1599     DALI_TEST_EQUALS(DaliTestCheckMaps(fontStyleMapGet, fontStyleMapSet), true, TEST_LOCATION);
1600   }
1601   DALI_TEST_CHECK(inputStyleChangedSignal);
1602
1603   gInputStyleChangedCallbackCalled = false;
1604   gInputStyleMask                  = TextEditor::InputStyle::NONE;
1605   inputStyleChangedSignal          = false;
1606
1607   // Create a tap event to touch the text editor.
1608   TestGenerateTap(application, 191.0f, 25.0f);
1609
1610   // Render and notify
1611   application.SendNotification();
1612   application.Render();
1613
1614   // Executes the idle callbacks added by the text control on the change of input style.
1615   application.RunIdles();
1616
1617   DALI_TEST_CHECK(!gInputStyleChangedCallbackCalled);
1618   DALI_TEST_CHECK(!inputStyleChangedSignal);
1619
1620   END_TEST;
1621 }
1622
1623 int utcDaliTextEditorInputStyleChanged02(void)
1624 {
1625   // The text-editor emits signals when the input style changes. These changes of style are
1626   // detected during the relayout process (size negotiation), i.e after the cursor has been moved. Signals
1627   // can't be emitted during the size negotiation as the callbacks may update the UI.
1628   // The text-editor adds an idle callback to the adaptor to emit the signals after the size negotiation.
1629   // The ToolkitTestApplication creates an implementation of the adaptor stub and a queue of idle callbacks.
1630   ToolkitTestApplication application;
1631   tet_infoline(" utcDaliTextEditorInputStyleChanged02");
1632
1633   // Load some fonts.
1634
1635   char*             pathNamePtr = get_current_dir_name();
1636   const std::string pathName(pathNamePtr);
1637   free(pathNamePtr);
1638
1639   TextAbstraction::FontClient fontClient = TextAbstraction::FontClient::Get();
1640   fontClient.SetDpi(93u, 93u);
1641
1642   fontClient.GetFontId(pathName + DEFAULT_FONT_DIR + "/dejavu/DejaVuSerif.ttf", DEFAULT_FONT_SIZE);
1643   fontClient.GetFontId(pathName + DEFAULT_FONT_DIR + "/dejavu/DejaVuSerif-Bold.ttf", DEFAULT_FONT_SIZE);
1644
1645   TextEditor editor = TextEditor::New();
1646   DALI_TEST_CHECK(editor);
1647
1648   editor.SetProperty(Actor::Property::SIZE, Vector2(300.f, 50.f));
1649   editor.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT);
1650   editor.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
1651
1652   editor.SetProperty(TextEditor::Property::ENABLE_MARKUP, true);
1653   editor.SetProperty(TextEditor::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>");
1654
1655   // connect to the text changed signal.
1656   ConnectionTracker* testTracker = new ConnectionTracker();
1657   editor.InputStyleChangedSignal().Connect(&TestInputStyleChangedCallback);
1658   bool inputStyleChangedSignal = false;
1659   editor.ConnectSignal(testTracker, "inputStyleChanged", CallbackFunctor(&inputStyleChangedSignal));
1660
1661   application.GetScene().Add(editor);
1662
1663   // Render and notify
1664   application.SendNotification();
1665   application.Render();
1666
1667   // Executes the idle callbacks added by the text control on the change of input style.
1668   application.RunIdles();
1669
1670   gInputStyleChangedCallbackCalled = false;
1671   gInputStyleMask                  = TextEditor::InputStyle::NONE;
1672   inputStyleChangedSignal          = false;
1673
1674   // Create a tap event to touch the text editor.
1675   TestGenerateTap(application, 53.0f, 25.0f, 100);
1676   TestGenerateTap(application, 53.0f, 25.0f, 200);
1677
1678   // Render and notify
1679   application.SendNotification();
1680   application.Render();
1681
1682   // Executes the idle callbacks added by the text control on the change of input style.
1683   application.RunIdles();
1684
1685   DALI_TEST_CHECK(gInputStyleChangedCallbackCalled);
1686   if(gInputStyleChangedCallbackCalled)
1687   {
1688     DALI_TEST_EQUALS(static_cast<unsigned int>(gInputStyleMask),
1689                      static_cast<unsigned int>(TextEditor::InputStyle::FONT_FAMILY |
1690                                                TextEditor::InputStyle::POINT_SIZE |
1691                                                TextEditor::InputStyle::COLOR),
1692                      TEST_LOCATION);
1693
1694     const Vector4 color = editor.GetProperty(TextEditor::Property::INPUT_COLOR).Get<Vector4>();
1695     DALI_TEST_EQUALS(color, Color::GREEN, TEST_LOCATION);
1696
1697     const std::string fontFamily = editor.GetProperty(TextEditor::Property::INPUT_FONT_FAMILY).Get<std::string>();
1698     DALI_TEST_EQUALS(fontFamily, "DejaVuSerif", TEST_LOCATION);
1699
1700     const float pointSize = editor.GetProperty(TextEditor::Property::INPUT_POINT_SIZE).Get<float>();
1701     DALI_TEST_EQUALS(pointSize, 18.f, Math::MACHINE_EPSILON_1000, TEST_LOCATION);
1702   }
1703   DALI_TEST_CHECK(inputStyleChangedSignal);
1704
1705   gInputStyleChangedCallbackCalled = false;
1706   gInputStyleMask                  = TextEditor::InputStyle::NONE;
1707   inputStyleChangedSignal          = false;
1708
1709   application.ProcessEvent(GenerateKey("", "", "", DALI_KEY_BACKSPACE, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
1710
1711   // Render and notify
1712   application.SendNotification();
1713   application.Render();
1714
1715   // Executes the idle callbacks added by the text control on the change of input style.
1716   application.RunIdles();
1717
1718   DALI_TEST_CHECK(gInputStyleChangedCallbackCalled);
1719   if(gInputStyleChangedCallbackCalled)
1720   {
1721     DALI_TEST_EQUALS(static_cast<unsigned int>(gInputStyleMask),
1722                      static_cast<unsigned int>(TextEditor::InputStyle::COLOR),
1723                      TEST_LOCATION);
1724
1725     const Vector4 color = editor.GetProperty(TextEditor::Property::INPUT_COLOR).Get<Vector4>();
1726     DALI_TEST_EQUALS(color, Color::BLUE, TEST_LOCATION);
1727   }
1728   DALI_TEST_CHECK(inputStyleChangedSignal);
1729
1730   gInputStyleChangedCallbackCalled = false;
1731   gInputStyleMask                  = TextEditor::InputStyle::NONE;
1732   inputStyleChangedSignal          = false;
1733
1734   application.ProcessEvent(GenerateKey("", "", "", DALI_KEY_BACKSPACE, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
1735
1736   // Render and notify
1737   application.SendNotification();
1738   application.Render();
1739
1740   // Executes the idle callbacks added by the text control on the change of input style.
1741   application.RunIdles();
1742
1743   DALI_TEST_CHECK(!gInputStyleChangedCallbackCalled);
1744   DALI_TEST_CHECK(!inputStyleChangedSignal);
1745
1746   gInputStyleChangedCallbackCalled = false;
1747   gInputStyleMask                  = TextEditor::InputStyle::NONE;
1748   inputStyleChangedSignal          = false;
1749
1750   application.ProcessEvent(GenerateKey("", "", "", DALI_KEY_BACKSPACE, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
1751
1752   // Render and notify
1753   application.SendNotification();
1754   application.Render();
1755
1756   // Executes the idle callbacks added by the text control on the change of input style.
1757   application.RunIdles();
1758
1759   DALI_TEST_CHECK(gInputStyleChangedCallbackCalled);
1760   if(gInputStyleChangedCallbackCalled)
1761   {
1762     DALI_TEST_EQUALS(static_cast<unsigned int>(gInputStyleMask),
1763                      static_cast<unsigned int>(TextEditor::InputStyle::COLOR),
1764                      TEST_LOCATION);
1765
1766     const Vector4 color = editor.GetProperty(TextEditor::Property::INPUT_COLOR).Get<Vector4>();
1767     DALI_TEST_EQUALS(color, Color::BLACK, TEST_LOCATION);
1768   }
1769   DALI_TEST_CHECK(inputStyleChangedSignal);
1770
1771   gInputStyleChangedCallbackCalled = false;
1772   gInputStyleMask                  = TextEditor::InputStyle::NONE;
1773   inputStyleChangedSignal          = false;
1774
1775   editor.SetProperty(TextEditor::Property::INPUT_COLOR, Color::YELLOW);
1776
1777   Property::Map fontStyleMapSet;
1778   fontStyleMapSet.Insert("weight", "thin");
1779   fontStyleMapSet.Insert("width", "condensed");
1780   fontStyleMapSet.Insert("slant", "italic");
1781
1782   editor.SetProperty(TextEditor::Property::INPUT_FONT_STYLE, fontStyleMapSet);
1783   editor.SetProperty(TextEditor::Property::INPUT_POINT_SIZE, 20.f);
1784   editor.SetProperty(TextEditor::Property::INPUT_LINE_SPACING, 5.f);
1785
1786   editor.SetProperty(TextEditor::Property::INPUT_UNDERLINE, "underline");
1787   editor.SetProperty(TextEditor::Property::INPUT_SHADOW, "shadow");
1788   editor.SetProperty(TextEditor::Property::INPUT_EMBOSS, "emboss");
1789   editor.SetProperty(TextEditor::Property::INPUT_OUTLINE, "outline");
1790   editor.SetProperty(DevelTextEditor::Property::INPUT_STRIKETHROUGH, "strikethrough");
1791
1792   application.ProcessEvent(GenerateKey("a", "", "a", KEY_A_CODE, 0, 0, Integration::KeyEvent::DOWN, "a", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
1793
1794   // Render and notify
1795   application.SendNotification();
1796   application.Render();
1797
1798   // Executes the idle callbacks added by the text control on the change of input style.
1799   application.RunIdles();
1800
1801   DALI_TEST_CHECK(!gInputStyleChangedCallbackCalled);
1802   DALI_TEST_CHECK(!inputStyleChangedSignal);
1803
1804   // Create a tap event to touch the text editor.
1805   TestGenerateTap(application, 63.0f, 25.0f, 900);
1806
1807   // Render and notify
1808   application.SendNotification();
1809   application.Render();
1810
1811   // Executes the idle callbacks added by the text control on the change of input style.
1812   application.RunIdles();
1813
1814   DALI_TEST_CHECK(gInputStyleChangedCallbackCalled);
1815   if(gInputStyleChangedCallbackCalled)
1816   {
1817     DALI_TEST_EQUALS(static_cast<unsigned int>(gInputStyleMask),
1818                      static_cast<unsigned int>(TextEditor::InputStyle::COLOR |
1819                                                TextEditor::InputStyle::POINT_SIZE |
1820                                                TextEditor::InputStyle::FONT_STYLE |
1821                                                TextEditor::InputStyle::LINE_SPACING |
1822                                                TextEditor::InputStyle::UNDERLINE |
1823                                                TextEditor::InputStyle::SHADOW |
1824                                                TextEditor::InputStyle::EMBOSS |
1825                                                TextEditor::InputStyle::OUTLINE),
1826                      TEST_LOCATION);
1827
1828     const Vector4 color = editor.GetProperty(TextEditor::Property::INPUT_COLOR).Get<Vector4>();
1829     DALI_TEST_EQUALS(color, Color::BLACK, TEST_LOCATION);
1830   }
1831   DALI_TEST_CHECK(inputStyleChangedSignal);
1832
1833   gInputStyleChangedCallbackCalled = false;
1834   gInputStyleMask                  = TextEditor::InputStyle::NONE;
1835   inputStyleChangedSignal          = false;
1836
1837   editor.SetProperty(TextEditor::Property::FONT_FAMILY, "DejaVuSerif");
1838
1839   fontStyleMapSet.Clear();
1840   fontStyleMapSet.Insert("weight", "black");
1841   fontStyleMapSet.Insert("width", "expanded");
1842   fontStyleMapSet.Insert("slant", "oblique");
1843
1844   editor.SetProperty(TextEditor::Property::FONT_STYLE, fontStyleMapSet);
1845
1846   // Create a tap event to touch the text editor.
1847   TestGenerateTap(application, 30.0f, 25.0f, 1500);
1848
1849   // Render and notify
1850   application.SendNotification();
1851   application.Render();
1852
1853   // Executes the idle callbacks added by the text control on the change of input style.
1854   application.RunIdles();
1855
1856   DALI_TEST_CHECK(gInputStyleChangedCallbackCalled);
1857   if(gInputStyleChangedCallbackCalled)
1858   {
1859     DALI_TEST_EQUALS(static_cast<unsigned int>(gInputStyleMask),
1860                      static_cast<unsigned int>(TextEditor::InputStyle::COLOR |
1861                                                TextEditor::InputStyle::POINT_SIZE |
1862                                                TextEditor::InputStyle::FONT_STYLE),
1863                      TEST_LOCATION);
1864
1865     const Vector4 color = editor.GetProperty(TextEditor::Property::INPUT_COLOR).Get<Vector4>();
1866     DALI_TEST_EQUALS(color, Color::YELLOW, TEST_LOCATION);
1867   }
1868   DALI_TEST_CHECK(inputStyleChangedSignal);
1869
1870   END_TEST;
1871 }
1872
1873 int utcDaliTextEditorEvent01(void)
1874 {
1875   ToolkitTestApplication application;
1876   tet_infoline(" utcDaliTextEditorEvent01");
1877
1878   // Creates a tap event. After creating a tap event the text editor should
1879   // have the focus and add text with key events should be possible.
1880
1881   TextEditor editor = TextEditor::New();
1882   DALI_TEST_CHECK(editor);
1883
1884   application.GetScene().Add(editor);
1885
1886   editor.SetProperty(Actor::Property::SIZE, Vector2(300.f, 50.f));
1887   editor.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT);
1888   editor.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
1889
1890   // Avoid a crash when core load gl resources.
1891   application.GetGlAbstraction().SetCheckFramebufferStatusResult(GL_FRAMEBUFFER_COMPLETE);
1892
1893   // Render and notify
1894   application.SendNotification();
1895   application.Render();
1896
1897   // Add a key event but as the text editor has not the focus it should do nothing.
1898   application.ProcessEvent(GenerateKey("a", "", "a", KEY_A_CODE, 0, 0, Integration::KeyEvent::DOWN, "a", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
1899
1900   // Render and notify
1901   application.SendNotification();
1902   application.Render();
1903
1904   DALI_TEST_EQUALS(editor.GetProperty<std::string>(TextEditor::Property::TEXT), std::string(""), TEST_LOCATION);
1905
1906   // Create a tap event to touch the text editor.
1907   TestGenerateTap(application, 150.0f, 25.0f);
1908
1909   // Render and notify
1910   application.SendNotification();
1911   application.Render();
1912
1913   // Now the text editor has the focus, so it can handle the key events.
1914   application.ProcessEvent(GenerateKey("a", "", "a", KEY_A_CODE, 0, 0, Integration::KeyEvent::DOWN, "a", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
1915   application.ProcessEvent(GenerateKey("a", "", "a", KEY_A_CODE, 0, 0, Integration::KeyEvent::DOWN, "a", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
1916
1917   // Render and notify
1918   application.SendNotification();
1919   application.Render();
1920
1921   DALI_TEST_EQUALS(editor.GetProperty<std::string>(TextEditor::Property::TEXT), std::string("aa"), TEST_LOCATION);
1922
1923   // Create a second text editor and send key events to it.
1924   TextEditor editor2 = TextEditor::New();
1925
1926   editor2.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT);
1927   editor2.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
1928   editor2.SetProperty(Actor::Property::SIZE, Vector2(100.f, 100.f));
1929   editor2.SetProperty(Actor::Property::POSITION, Vector2(100.f, 100.f));
1930
1931   application.GetScene().Add(editor2);
1932
1933   // Render and notify
1934   application.SendNotification();
1935   application.Render();
1936
1937   // Create a tap event on the second text editor.
1938   TestGenerateTap(application, 150.0f, 125.0f);
1939
1940   // Render and notify
1941   application.SendNotification();
1942   application.Render();
1943
1944   // The second text editor has the focus. It should handle the key events.
1945   application.ProcessEvent(GenerateKey("a", "", "a", KEY_A_CODE, 0, 0, Integration::KeyEvent::DOWN, "a", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
1946   application.ProcessEvent(GenerateKey("a", "", "a", KEY_A_CODE, 0, 0, Integration::KeyEvent::DOWN, "a", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
1947
1948   // Render and notify
1949   application.SendNotification();
1950   application.Render();
1951
1952   // Check the text has been added to the second text editor.
1953   DALI_TEST_EQUALS(editor2.GetProperty<std::string>(TextEditor::Property::TEXT), std::string("aa"), TEST_LOCATION);
1954
1955   END_TEST;
1956 }
1957
1958 int utcDaliTextEditorEvent02(void)
1959 {
1960   ToolkitTestApplication application;
1961   tet_infoline(" utcDaliTextEditorEvent02");
1962
1963   // Checks if the right number of actors are created.
1964
1965   TextEditor editor = TextEditor::New();
1966   editor.SetProperty(TextEditor::Property::POINT_SIZE, 10.f);
1967   DALI_TEST_CHECK(editor);
1968
1969   application.GetScene().Add(editor);
1970
1971   editor.SetProperty(Actor::Property::SIZE, Vector2(300.f, 50.f));
1972   editor.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT);
1973   editor.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
1974
1975   // Avoid a crash when core load gl resources.
1976   application.GetGlAbstraction().SetCheckFramebufferStatusResult(GL_FRAMEBUFFER_COMPLETE);
1977
1978   // Render and notify
1979   application.SendNotification();
1980   application.Render();
1981
1982   // Check there are the expected number of children (the stencil).
1983   DALI_TEST_EQUALS(editor.GetChildCount(), 1u, TEST_LOCATION);
1984
1985   Actor stencil = editor.GetChildAt(0u);
1986
1987   // Create a tap event to touch the text editor.
1988   TestGenerateTap(application, 150.0f, 25.0f, 100);
1989
1990   // Render and notify
1991   application.SendNotification();
1992   application.Render();
1993
1994   Actor layer = editor.GetChildAt(2u);
1995   DALI_TEST_EQUALS(layer.GetChildCount(), 1u, TEST_LOCATION); // The cursor.
1996   DALI_TEST_EQUALS(stencil.GetChildCount(), 0u, TEST_LOCATION);
1997
1998   // Now the text editor has the focus, so it can handle the key events.
1999   application.ProcessEvent(GenerateKey("a", "", "a", KEY_A_CODE, 0, 0, Integration::KeyEvent::DOWN, "a", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
2000   application.ProcessEvent(GenerateKey("a", "", "a", KEY_A_CODE, 0, 0, Integration::KeyEvent::DOWN, "a", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
2001
2002   // Render and notify
2003   application.SendNotification();
2004   application.Render();
2005
2006   // Checks the cursor and the renderer have been created.
2007   DALI_TEST_EQUALS(layer.GetChildCount(), 1u, TEST_LOCATION);   // The cursor.
2008   DALI_TEST_EQUALS(stencil.GetChildCount(), 2u, TEST_LOCATION); // The renderer, clipped cursor
2009
2010   Control cursor = Control::DownCast(layer.GetChildAt(0u));
2011   DALI_TEST_CHECK(cursor);
2012
2013   // The stencil actor has a container with all the actors which contain the text renderers.
2014   Actor container = stencil.GetChildAt(0u);
2015   for(unsigned int index = 0; index < container.GetChildCount(); ++index)
2016   {
2017     Renderer renderer = container.GetChildAt(index).GetRendererAt(0u);
2018     DALI_TEST_CHECK(renderer);
2019   }
2020
2021   // Move the cursor and check the position changes.
2022   Vector3 position1 = cursor.GetCurrentProperty<Vector3>(Actor::Property::POSITION);
2023
2024   application.ProcessEvent(GenerateKey("", "", "", DALI_KEY_CURSOR_LEFT, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
2025   application.ProcessEvent(GenerateKey("", "", "", DALI_KEY_CURSOR_LEFT, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
2026
2027   // Render and notify
2028   application.SendNotification();
2029   application.Render();
2030
2031   Vector3 position2 = cursor.GetCurrentProperty<Vector3>(Actor::Property::POSITION);
2032
2033   DALI_TEST_CHECK(position2.x < position1.x);
2034
2035   application.ProcessEvent(GenerateKey("", "", "", DALI_KEY_CURSOR_RIGHT, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
2036   application.ProcessEvent(GenerateKey("", "", "", DALI_KEY_CURSOR_RIGHT, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
2037
2038   // Render and notify
2039   application.SendNotification();
2040   application.Render();
2041
2042   Vector3 position3 = cursor.GetCurrentProperty<Vector3>(Actor::Property::POSITION);
2043
2044   DALI_TEST_EQUALS(position1, position3, TEST_LOCATION); // Should be in the same position1.
2045
2046   // Send some taps and check the cursor positions.
2047
2048   // Try to tap at the beginning.
2049   TestGenerateTap(application, 1.0f, 25.0f, 700);
2050
2051   // Render and notify
2052   application.SendNotification();
2053   application.Render();
2054
2055   // Cursor position should be the same than position1.
2056   Vector3 position4 = cursor.GetCurrentProperty<Vector3>(Actor::Property::POSITION);
2057
2058   DALI_TEST_EQUALS(position2, position4, TEST_LOCATION); // Should be in the same position2.
2059
2060   // Tap away from the start position.
2061   TestGenerateTap(application, 16.0f, 25.0f, 1400);
2062
2063   // Render and notify
2064   application.SendNotification();
2065   application.Render();
2066
2067   Vector3 position5 = cursor.GetCurrentProperty<Vector3>(Actor::Property::POSITION);
2068
2069   DALI_TEST_CHECK(position5.x > position4.x);
2070
2071   // Remove all the text.
2072   application.ProcessEvent(GenerateKey("", "", "", DALI_KEY_BACKSPACE, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
2073   application.ProcessEvent(GenerateKey("", "", "", DALI_KEY_BACKSPACE, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
2074   editor.SetProperty(TextEditor::Property::TEXT, "");
2075
2076   // Render and notify
2077   application.SendNotification();
2078   application.Render();
2079
2080   // Cursor position should be the same than position2.
2081   Vector3 position6 = cursor.GetCurrentProperty<Vector3>(Actor::Property::POSITION);
2082
2083   DALI_TEST_EQUALS(position2, position6, TEST_LOCATION); // Should be in the same position2.
2084
2085   // Should not be a renderer, there is only a clipped cursor.
2086   DALI_TEST_EQUALS(stencil.GetChildCount(), 1u, TEST_LOCATION);
2087
2088   END_TEST;
2089 }
2090
2091 int utcDaliTextEditorEvent03(void)
2092 {
2093   ToolkitTestApplication application;
2094   tet_infoline(" utcDaliTextEditorEvent03");
2095
2096   // Checks if the highlight actor is created.
2097
2098   TextEditor editor = TextEditor::New();
2099   DALI_TEST_CHECK(editor);
2100
2101   application.GetScene().Add(editor);
2102
2103   editor.SetProperty(TextEditor::Property::TEXT, "This is a long text for the size of the text-editor.");
2104   editor.SetProperty(TextEditor::Property::POINT_SIZE, 10.f);
2105   editor.SetProperty(Actor::Property::SIZE, Vector2(30.f, 50.f));
2106   editor.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT);
2107   editor.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
2108
2109   // Avoid a crash when core load gl resources.
2110   application.GetGlAbstraction().SetCheckFramebufferStatusResult(GL_FRAMEBUFFER_COMPLETE);
2111
2112   // Render and notify
2113   application.SendNotification();
2114   application.Render();
2115
2116   // Send some taps and check text controller with clipboard window
2117   Dali::Clipboard clipboard = Clipboard::Get();
2118   clipboard.ShowClipboard();
2119   TestGenerateTap(application, 3.0f, 25.0f, 100);
2120   clipboard.HideClipboard();
2121
2122   // Render and notify
2123   application.SendNotification();
2124   application.Render();
2125
2126   // Tap first to get the focus.
2127   TestGenerateTap(application, 3.0f, 25.0f, 1000);
2128
2129   // Render and notify
2130   application.SendNotification();
2131   application.Render();
2132
2133   // Double tap to select a word.
2134   TestGenerateTap(application, 3.0f, 25.0f, 1100);
2135
2136   // Render and notify
2137   application.SendNotification();
2138   application.Render();
2139
2140   // The stencil actor should have two actors: the renderer and the highlight actor.
2141   Actor stencil = editor.GetChildAt(0u);
2142
2143   // Highlight needs to be drawn before text, so should come first in child order
2144   Renderer highlight = stencil.GetChildAt(0u).GetRendererAt(0u);
2145   DALI_TEST_CHECK(highlight);
2146
2147   // The stencil actor has a container with all the actors which contain the text renderers.
2148   Actor container = stencil.GetChildAt(1u);
2149   for(unsigned int index = 0; index < container.GetChildCount(); ++index)
2150   {
2151     Renderer renderer = container.GetChildAt(index).GetRendererAt(0u);
2152     DALI_TEST_CHECK(renderer);
2153   }
2154
2155   // Double tap out of bounds
2156   TestGenerateTap(application, 29.0f, 25.0f, 1700);
2157   TestGenerateTap(application, 29.0f, 25.0f, 1800);
2158
2159   // Render and notify
2160   application.SendNotification();
2161   application.Render();
2162
2163   // The stencil actor should have one actors: the renderer actor.
2164   stencil = editor.GetChildAt(0u);
2165
2166   // The stencil actor has a container with all the actors which contain the text renderers.
2167   container = stencil.GetChildAt(0u);
2168   for(unsigned int index = 0; index < container.GetChildCount(); ++index)
2169   {
2170     Renderer renderer = container.GetChildAt(index).GetRendererAt(0u);
2171     DALI_TEST_CHECK(renderer);
2172   }
2173
2174   // Long Press
2175   TestGenerateLongPress(application, 1.0f, 25.0f);
2176
2177   // Render and notify
2178   application.SendNotification();
2179   application.Render();
2180
2181   // Pan Press
2182   TestGenerateMiniPan(application);
2183
2184   // Render and notify
2185   application.SendNotification();
2186   application.Render();
2187
2188   END_TEST;
2189 }
2190
2191 int utcDaliTextEditorEvent04(void)
2192 {
2193   ToolkitTestApplication application;
2194   tet_infoline(" utcDaliTextEditorEvent04");
2195
2196   // Checks if the highlight actor is created.
2197
2198   TextEditor editor = TextEditor::New();
2199   DALI_TEST_CHECK(editor);
2200
2201   application.GetScene().Add(editor);
2202
2203   editor.SetProperty(TextEditor::Property::TEXT, "Hello\nworl");
2204   editor.SetProperty(TextEditor::Property::POINT_SIZE, 10.f);
2205   editor.SetProperty(Actor::Property::SIZE, Vector2(100.f, 50.f));
2206   editor.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT);
2207   editor.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
2208
2209   // Avoid a crash when core load gl resources.
2210   application.GetGlAbstraction().SetCheckFramebufferStatusResult(GL_FRAMEBUFFER_COMPLETE);
2211
2212   // Render and notify
2213   application.SendNotification();
2214   application.Render();
2215
2216   // Tap on the text editor
2217   TestGenerateTap(application, 3.0f, 25.0f);
2218
2219   // Render and notify
2220   application.SendNotification();
2221   application.Render();
2222
2223   // Move at the end of the text.
2224   application.ProcessEvent(GenerateKey("", "", "", DALI_KEY_CURSOR_DOWN, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
2225   application.ProcessEvent(GenerateKey("", "", "", DALI_KEY_CURSOR_DOWN, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
2226
2227   // Render and notify
2228   application.SendNotification();
2229   application.Render();
2230
2231   for(unsigned int index = 0u; index < 10u; ++index)
2232   {
2233     application.ProcessEvent(GenerateKey("", "", "", DALI_KEY_CURSOR_RIGHT, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
2234     application.ProcessEvent(GenerateKey("", "", "", DALI_KEY_CURSOR_RIGHT, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
2235
2236     // Render and notify
2237     application.SendNotification();
2238     application.Render();
2239   }
2240
2241   // Add a character
2242   application.ProcessEvent(GenerateKey("d", "", "d", KEY_D_CODE, 0, 0, Integration::KeyEvent::DOWN, "d", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
2243
2244   // Render and notify
2245   application.SendNotification();
2246   application.Render();
2247
2248   DALI_TEST_EQUALS("Hello\nworld", editor.GetProperty<std::string>(TextEditor::Property::TEXT), TEST_LOCATION);
2249
2250   // Add some key events
2251   application.ProcessEvent(GenerateKey("", "", "", DALI_KEY_CURSOR_UP, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
2252   application.ProcessEvent(GenerateKey("", "", "", DALI_KEY_CURSOR_UP, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
2253
2254   // Render and notify
2255   application.SendNotification();
2256   application.Render();
2257
2258   for(unsigned int index = 0u; index < 10u; ++index)
2259   {
2260     application.ProcessEvent(GenerateKey("", "", "", DALI_KEY_CURSOR_LEFT, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
2261     application.ProcessEvent(GenerateKey("", "", "", DALI_KEY_CURSOR_LEFT, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
2262
2263     // Render and notify
2264     application.SendNotification();
2265     application.Render();
2266   }
2267
2268   // Add a character
2269   application.ProcessEvent(GenerateKey(" ", "", " ", KEY_WHITE_SPACE_CODE, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
2270
2271   // Render and notify
2272   application.SendNotification();
2273   application.Render();
2274
2275   DALI_TEST_EQUALS(" Hello\nworld", editor.GetProperty<std::string>(TextEditor::Property::TEXT), TEST_LOCATION);
2276
2277   END_TEST;
2278 }
2279
2280 int utcDaliTextEditorEvent05(void)
2281 {
2282   ToolkitTestApplication application;
2283   tet_infoline(" utcDaliTextEditorEvent05");
2284
2285   // Checks if the highlight actor is created.
2286
2287   TextEditor editor = TextEditor::New();
2288   DALI_TEST_CHECK(editor);
2289
2290   application.GetScene().Add(editor);
2291
2292   editor.SetProperty(TextEditor::Property::TEXT, "Hello\nworl");
2293   editor.SetProperty(TextEditor::Property::POINT_SIZE, 10.f);
2294   editor.SetProperty(Actor::Property::SIZE, Vector2(50.f, 50.f));
2295   editor.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT);
2296   editor.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
2297   editor.SetProperty(TextEditor::Property::SMOOTH_SCROLL, true);
2298   editor.SetProperty(TextEditor::Property::SMOOTH_SCROLL_DURATION, 0.2f);
2299   editor.SetProperty(TextEditor::Property::ENABLE_SCROLL_BAR, true);
2300   editor.SetProperty(TextEditor::Property::SCROLL_BAR_SHOW_DURATION, 0.3f);
2301   editor.SetProperty(TextEditor::Property::SCROLL_BAR_FADE_DURATION, 0.2f);
2302
2303   // Avoid a crash when core load gl resources.
2304   application.GetGlAbstraction().SetCheckFramebufferStatusResult(GL_FRAMEBUFFER_COMPLETE);
2305
2306   // Render and notify
2307   application.SendNotification();
2308   application.Render();
2309
2310   // Tap on the text editor
2311   TestGenerateTap(application, 3.0f, 25.0f);
2312
2313   // Render and notify
2314   application.SendNotification();
2315   application.Render();
2316
2317   // Move at the end of the text.
2318   application.ProcessEvent(GenerateKey("", "", "", DALI_KEY_CURSOR_DOWN, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
2319   application.ProcessEvent(GenerateKey("", "", "", DALI_KEY_CURSOR_DOWN, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
2320
2321   // Render and notify
2322   application.SendNotification();
2323   application.Render();
2324
2325   for(unsigned int index = 0u; index < 10u; ++index)
2326   {
2327     // Add a character
2328     application.ProcessEvent(GenerateKey("d", "", "d", KEY_D_CODE, 0, 0, Integration::KeyEvent::DOWN, "d", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
2329
2330     // Render and notify
2331     application.SendNotification();
2332     application.Render();
2333   }
2334   // Modify duration after scroll is enabled
2335   editor.SetProperty(TextEditor::Property::SMOOTH_SCROLL_DURATION, 0.1f);
2336
2337   // Continuous scroll left to increase coverage
2338   for(unsigned int index = 0u; index < 10u; ++index)
2339   {
2340     application.ProcessEvent(GenerateKey("", "", "", DALI_KEY_CURSOR_LEFT, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
2341
2342     // Render and notify
2343     application.SendNotification();
2344     application.Render();
2345   }
2346   DALI_TEST_EQUALS(editor.GetProperty<float>(TextEditor::Property::SMOOTH_SCROLL_DURATION), 0.1f, Math::MACHINE_EPSILON_1000, TEST_LOCATION);
2347   DALI_TEST_EQUALS(editor.GetProperty<bool>(TextEditor::Property::SMOOTH_SCROLL), true, TEST_LOCATION);
2348   DALI_TEST_EQUALS(editor.GetProperty<bool>(TextEditor::Property::ENABLE_SCROLL_BAR), true, TEST_LOCATION);
2349   DALI_TEST_EQUALS(editor.GetProperty<float>(TextEditor::Property::SCROLL_BAR_SHOW_DURATION), 0.3f, Math::MACHINE_EPSILON_1000, TEST_LOCATION);
2350   DALI_TEST_EQUALS(editor.GetProperty<float>(TextEditor::Property::SCROLL_BAR_FADE_DURATION), 0.2f, Math::MACHINE_EPSILON_1000, TEST_LOCATION);
2351
2352   // Press Escape to increase coverage
2353   application.ProcessEvent(GenerateKey("", "", "", DALI_KEY_ESCAPE, 0, 0, Integration::KeyEvent::UP, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
2354   application.SendNotification();
2355   application.Render();
2356
2357   DALI_TEST_CHECK(!editor.HasKeyInputFocus());
2358
2359   END_TEST;
2360 }
2361
2362 int utcDaliTextEditorEvent06(void)
2363 {
2364   ToolkitTestApplication application;
2365   tet_infoline(" utcDaliTextEditorEvent06");
2366
2367   // Checks if the highlight actor is created.
2368
2369   TextEditor editor = TextEditor::New();
2370   DALI_TEST_CHECK(editor);
2371
2372   application.GetScene().Add(editor);
2373
2374   editor.SetProperty(TextEditor::Property::TEXT, "Hello\nworld\nHello world");
2375   editor.SetProperty(TextEditor::Property::POINT_SIZE, 10.f);
2376   editor.SetProperty(Actor::Property::SIZE, Vector2(100.f, 50.f));
2377   editor.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT);
2378   editor.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
2379
2380   // Avoid a crash when core load gl resources.
2381   application.GetGlAbstraction().SetCheckFramebufferStatusResult(GL_FRAMEBUFFER_COMPLETE);
2382
2383   // Render and notify
2384   application.SendNotification();
2385   application.Render();
2386
2387   // Tap on the text editor
2388   TestGenerateTap(application, 3.0f, 25.0f);
2389
2390   // Render and notify
2391   application.SendNotification();
2392   application.Render();
2393
2394   // Move to seconds line of the text.
2395   application.ProcessEvent(GenerateKey("", "", "", DALI_KEY_CURSOR_DOWN, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
2396
2397   // Render and notify
2398   application.SendNotification();
2399   application.Render();
2400
2401   float layoutHeight = editor.GetHeightForWidth(100.f);
2402
2403   // Add  another script characters ( glyph height is defferent )
2404   application.ProcessEvent(GenerateKey("d", "", "ㅁ", KEY_D_CODE, 0, 0, Integration::KeyEvent::DOWN, "ㅁ", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
2405   application.ProcessEvent(GenerateKey("d", "", "ኢ", KEY_D_CODE, 0, 0, Integration::KeyEvent::DOWN, "ኢ", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
2406
2407   // Delete characters
2408   application.ProcessEvent(GenerateKey("", "", "", DALI_KEY_BACKSPACE, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
2409   application.ProcessEvent(GenerateKey("", "", "", DALI_KEY_BACKSPACE, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
2410
2411   DALI_TEST_EQUALS(layoutHeight, editor.GetHeightForWidth(100.f), TEST_LOCATION);
2412
2413   // Render and notify
2414   application.SendNotification();
2415   application.Render();
2416
2417   DALI_TEST_EQUALS("Hello\nworld\nHello world", editor.GetProperty<std::string>(TextEditor::Property::TEXT), TEST_LOCATION);
2418
2419   // For coverage
2420   application.ProcessEvent(GenerateKey("", "", "", 0, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
2421   application.SendNotification();
2422   application.Render();
2423
2424   application.ProcessEvent(GenerateKey("", "", "", DALI_KEY_SHIFT_LEFT, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
2425   application.SendNotification();
2426   application.Render();
2427
2428   application.ProcessEvent(GenerateKey("", "", "", DALI_KEY_VOLUME_UP, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
2429   application.SendNotification();
2430   application.Render();
2431
2432   application.ProcessEvent(GenerateKey("", "", "", DALI_KEY_VOLUME_DOWN, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
2433   application.SendNotification();
2434   application.Render();
2435
2436   application.ProcessEvent(GenerateKey("", "", "", Dali::DevelKey::DALI_KEY_DELETE, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
2437   application.SendNotification();
2438   application.Render();
2439
2440   application.ProcessEvent(GenerateKey("", "", "", Dali::DevelKey::DALI_KEY_CONTROL_LEFT, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
2441   application.SendNotification();
2442   application.Render();
2443
2444   application.ProcessEvent(GenerateKey("", "", "", Dali::DevelKey::DALI_KEY_CONTROL_RIGHT, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
2445   application.SendNotification();
2446   application.Render();
2447
2448   END_TEST;
2449 }
2450
2451 int utcDaliTextEditorEvent07(void)
2452 {
2453   ToolkitTestApplication application;
2454   tet_infoline(" utcDaliTextEditorEvent07");
2455
2456   // Checks if the highlight actor is created.
2457
2458   TextEditor editor = TextEditor::New();
2459   DALI_TEST_CHECK(editor);
2460
2461   application.GetScene().Add(editor);
2462
2463   editor.SetProperty(TextEditor::Property::TEXT, "Hello\nworld\nHello world");
2464   editor.SetProperty(TextEditor::Property::POINT_SIZE, 10.f);
2465   editor.SetProperty(Actor::Property::SIZE, Vector2(100.f, 50.f));
2466   editor.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT);
2467   editor.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
2468
2469   // Avoid a crash when core load gl resources.
2470   application.GetGlAbstraction().SetCheckFramebufferStatusResult(GL_FRAMEBUFFER_COMPLETE);
2471
2472   // Render and notify
2473   application.SendNotification();
2474   application.Render();
2475
2476   // Tap on the text editor
2477   TestGenerateTap(application, 3.0f, 25.0f);
2478
2479   // Render and notify
2480   application.SendNotification();
2481   application.Render();
2482
2483   // Move to second line of the text.
2484   application.ProcessEvent(GenerateKey("", "", "", DALI_KEY_CURSOR_DOWN, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
2485
2486   // Render and notify
2487   application.SendNotification();
2488   application.Render();
2489
2490   // Select some text in the right of the current cursor position
2491   application.ProcessEvent(GenerateKey("", "", "", DALI_KEY_SHIFT_LEFT, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
2492   application.ProcessEvent(GenerateKey("", "", "", DALI_KEY_CURSOR_RIGHT, KEY_SHIFT_MODIFIER, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
2493   application.ProcessEvent(GenerateKey("", "", "", DALI_KEY_CURSOR_RIGHT, KEY_SHIFT_MODIFIER, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
2494   application.ProcessEvent(GenerateKey("", "", "", DALI_KEY_CURSOR_RIGHT, KEY_SHIFT_MODIFIER, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
2495
2496   // Render and notify
2497   application.SendNotification();
2498   application.Render();
2499
2500   // Cut the selected text
2501   application.ProcessEvent(GenerateKey("", "", "", Dali::DevelKey::DALI_KEY_CONTROL_LEFT, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
2502   application.ProcessEvent(GenerateKey("x", "", "x", KEY_X_CODE, KEY_CONTROL_MODIFIER, 0, Integration::KeyEvent::DOWN, "x", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
2503
2504   // Render and notify
2505   application.SendNotification();
2506   application.Render();
2507
2508   DALI_TEST_EQUALS("Hello\nld\nHello world", editor.GetProperty<std::string>(TextEditor::Property::TEXT), TEST_LOCATION);
2509
2510   // Select some text in the left of the current cursor position
2511   application.ProcessEvent(GenerateKey("", "", "", DALI_KEY_SHIFT_LEFT, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
2512   application.ProcessEvent(GenerateKey("", "", "", DALI_KEY_CURSOR_LEFT, KEY_SHIFT_MODIFIER, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
2513   application.ProcessEvent(GenerateKey("", "", "", DALI_KEY_CURSOR_LEFT, KEY_SHIFT_MODIFIER, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
2514   application.ProcessEvent(GenerateKey("", "", "", DALI_KEY_CURSOR_LEFT, KEY_SHIFT_MODIFIER, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
2515
2516   // Render and notify
2517   application.SendNotification();
2518   application.Render();
2519
2520   // Copy the selected text
2521   application.ProcessEvent(GenerateKey("", "", "", Dali::DevelKey::DALI_KEY_CONTROL_LEFT, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
2522   application.ProcessEvent(GenerateKey("c", "", "c", KEY_C_CODE, KEY_CONTROL_MODIFIER, 0, Integration::KeyEvent::DOWN, "c", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
2523
2524   // Render and notify
2525   application.SendNotification();
2526   application.Render();
2527
2528   // Move the cursor to the third line
2529   application.ProcessEvent(GenerateKey("", "", "", DALI_KEY_CURSOR_DOWN, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
2530   application.ProcessEvent(GenerateKey("", "", "", DALI_KEY_CURSOR_DOWN, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
2531
2532   // Render and notify
2533   application.SendNotification();
2534   application.Render();
2535
2536   // Paste the selected text at the current cursor position
2537   application.ProcessEvent(GenerateKey("", "", "", Dali::DevelKey::DALI_KEY_CONTROL_LEFT, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
2538   application.ProcessEvent(GenerateKey("v", "", "v", KEY_V_CODE, KEY_CONTROL_MODIFIER, 0, Integration::KeyEvent::DOWN, "v", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
2539
2540   // Render and notify
2541   application.SendNotification();
2542   application.Render();
2543
2544   DALI_TEST_EQUALS("Hello\nld\nHello lo\nworld", editor.GetProperty<std::string>(TextEditor::Property::TEXT), TEST_LOCATION);
2545
2546   // Disable Shift Selection
2547   editor.SetProperty(DevelTextEditor::Property::ENABLE_SHIFT_SELECTION, false);
2548
2549   // Test to select some text in the right of the current cursor position
2550   application.ProcessEvent(GenerateKey("", "", "", DALI_KEY_SHIFT_LEFT, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
2551   application.ProcessEvent(GenerateKey("", "", "", DALI_KEY_CURSOR_RIGHT, KEY_SHIFT_MODIFIER, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
2552   application.ProcessEvent(GenerateKey("", "", "", DALI_KEY_CURSOR_RIGHT, KEY_SHIFT_MODIFIER, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
2553   application.ProcessEvent(GenerateKey("", "", "", DALI_KEY_CURSOR_RIGHT, KEY_SHIFT_MODIFIER, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
2554
2555   // Render and notify
2556   application.SendNotification();
2557   application.Render();
2558
2559   // Cut the selected text
2560   application.ProcessEvent(GenerateKey("", "", "", Dali::DevelKey::DALI_KEY_CONTROL_LEFT, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
2561   application.ProcessEvent(GenerateKey("x", "", "x", KEY_X_CODE, KEY_CONTROL_MODIFIER, 0, Integration::KeyEvent::DOWN, "x", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
2562
2563   // Render and notify
2564   application.SendNotification();
2565   application.Render();
2566
2567   // The text isn't selected and not changed because of 'SetProperty( DevelTextEditor::Property::ENABLE_SHIFT_SELECTION, false )'
2568   DALI_TEST_EQUALS("Hello\nld\nHello lo\nworld", editor.GetProperty<std::string>(TextEditor::Property::TEXT), TEST_LOCATION);
2569
2570   // Test to select some text in the left of the current cursor position
2571   application.ProcessEvent(GenerateKey("", "", "", DALI_KEY_SHIFT_LEFT, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
2572   application.ProcessEvent(GenerateKey("", "", "", DALI_KEY_CURSOR_LEFT, KEY_SHIFT_MODIFIER, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
2573   application.ProcessEvent(GenerateKey("", "", "", DALI_KEY_CURSOR_LEFT, KEY_SHIFT_MODIFIER, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
2574   application.ProcessEvent(GenerateKey("", "", "", DALI_KEY_CURSOR_LEFT, KEY_SHIFT_MODIFIER, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
2575
2576   // Render and notify
2577   application.SendNotification();
2578   application.Render();
2579
2580   // Copy the selected text
2581   application.ProcessEvent(GenerateKey("", "", "", Dali::DevelKey::DALI_KEY_CONTROL_LEFT, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
2582   application.ProcessEvent(GenerateKey("c", "", "c", KEY_C_CODE, KEY_CONTROL_MODIFIER, 0, Integration::KeyEvent::DOWN, "c", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
2583
2584   // Render and notify
2585   application.SendNotification();
2586   application.Render();
2587
2588   // The text is not selected and not changed because of 'SetProperty( DevelTextEditor::Property::ENABLE_SHIFT_SELECTION, false )'
2589   DALI_TEST_EQUALS("Hello\nld\nHello lo\nworld", editor.GetProperty<std::string>(TextEditor::Property::TEXT), TEST_LOCATION);
2590
2591   // Select all Text
2592   application.ProcessEvent(GenerateKey("a", "", "a", KEY_A_CODE, KEY_CONTROL_MODIFIER, 0, Integration::KeyEvent::DOWN, "a", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
2593
2594   // Render and notify
2595   application.SendNotification();
2596   application.Render();
2597
2598   // replace text with "c"
2599   application.ProcessEvent(GenerateKey("c", "", "c", KEY_C_CODE, 0, 0, Integration::KeyEvent::DOWN, "c", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
2600
2601   // Render and notify
2602   application.SendNotification();
2603   application.Render();
2604
2605   //text is "c"
2606   DALI_TEST_EQUALS("c", editor.GetProperty<std::string>(TextEditor::Property::TEXT), TEST_LOCATION);
2607
2608   // select all text
2609   DevelTextEditor::SelectWholeText(editor);
2610
2611   // Render and notify
2612   application.SendNotification();
2613   application.Render();
2614
2615   // Copy the selected text using logical keys
2616   application.ProcessEvent(GenerateKey("", "", "", Dali::DevelKey::DALI_KEY_CONTROL_LEFT, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
2617   application.ProcessEvent(GenerateKey("ؤ", "c", "ؤ", KEY_C_CODE, KEY_CONTROL_MODIFIER, 0, Integration::KeyEvent::DOWN, "c", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
2618
2619   // Render and notify
2620   application.SendNotification();
2621   application.Render();
2622
2623   // select none
2624   DevelTextEditor::SelectNone(editor);
2625
2626   // Render and notify
2627   application.SendNotification();
2628   application.Render();
2629
2630   // Paste the selected using logical keys
2631   application.ProcessEvent(GenerateKey("", "", "", Dali::DevelKey::DALI_KEY_CONTROL_LEFT, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
2632   application.ProcessEvent(GenerateKey("ر", "v", "ر", KEY_V_CODE, KEY_CONTROL_MODIFIER, 0, Integration::KeyEvent::DOWN, "v", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
2633
2634   //text is "cc"
2635   DALI_TEST_EQUALS("cc", editor.GetProperty<std::string>(TextEditor::Property::TEXT), TEST_LOCATION);
2636
2637   // select all using logical keys
2638   application.ProcessEvent(GenerateKey("", "", "", Dali::DevelKey::DALI_KEY_CONTROL_LEFT, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
2639   application.ProcessEvent(GenerateKey("ش", "a", "ش", KEY_A_CODE, KEY_CONTROL_MODIFIER, 0, Integration::KeyEvent::DOWN, "a", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
2640
2641   // Render and notify
2642   application.SendNotification();
2643   application.Render();
2644
2645   // cut text using logical keys
2646   application.ProcessEvent(GenerateKey("", "", "", Dali::DevelKey::DALI_KEY_CONTROL_LEFT, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
2647   application.ProcessEvent(GenerateKey("ء", "x", "ء", KEY_X_CODE, KEY_CONTROL_MODIFIER, 0, Integration::KeyEvent::DOWN, "x", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
2648
2649   // Render and notify
2650   application.SendNotification();
2651   application.Render();
2652
2653   //text is ""
2654   DALI_TEST_EQUALS("", editor.GetProperty<std::string>(TextEditor::Property::TEXT), TEST_LOCATION);
2655
2656   END_TEST;
2657 }
2658
2659 int utcDaliTextEditorEvent08(void)
2660 {
2661   ToolkitTestApplication application;
2662   tet_infoline(" utcDaliTextEditorEvent08");
2663
2664   // Checks if the highlight actor is released correctly.
2665
2666   TextEditor editor = TextEditor::New();
2667   DALI_TEST_CHECK(editor);
2668
2669   application.GetScene().Add(editor);
2670
2671   editor.SetProperty(TextEditor::Property::TEXT, "DALi");
2672   editor.SetProperty(TextEditor::Property::POINT_SIZE, 10.f);
2673   editor.SetProperty(Actor::Property::SIZE, Vector2(100.f, 50.f));
2674   editor.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT);
2675   editor.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
2676
2677   // Avoid a crash when core load gl resources.
2678   application.GetGlAbstraction().SetCheckFramebufferStatusResult(GL_FRAMEBUFFER_COMPLETE);
2679
2680   // Render and notify
2681   application.SendNotification();
2682   application.Render();
2683
2684   // Tap on the text editor
2685   TestGenerateTap(application, 3.0f, 25.0f);
2686
2687   // Render and notify
2688   application.SendNotification();
2689   application.Render();
2690
2691   // When the left selection handle and the right selection handle are at the same position, the highlight box should be deactivated.
2692   // Test to select some text in the left of the current cursor position
2693   application.ProcessEvent(GenerateKey("", "", "", DALI_KEY_SHIFT_LEFT, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
2694   application.ProcessEvent(GenerateKey("", "", "", DALI_KEY_CURSOR_LEFT, KEY_SHIFT_MODIFIER, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
2695   application.ProcessEvent(GenerateKey("", "", "", DALI_KEY_CURSOR_LEFT, KEY_SHIFT_MODIFIER, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
2696   application.ProcessEvent(GenerateKey("", "", "", DALI_KEY_CURSOR_LEFT, KEY_SHIFT_MODIFIER, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
2697
2698   // Render and notify
2699   application.SendNotification();
2700   application.Render();
2701
2702   // Test to the left selection handle position and the right selection handle position
2703   application.ProcessEvent(GenerateKey("", "", "", DALI_KEY_SHIFT_LEFT, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
2704   application.ProcessEvent(GenerateKey("", "", "", DALI_KEY_CURSOR_RIGHT, KEY_SHIFT_MODIFIER, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
2705   application.ProcessEvent(GenerateKey("", "", "", DALI_KEY_CURSOR_RIGHT, KEY_SHIFT_MODIFIER, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
2706   application.ProcessEvent(GenerateKey("", "", "", DALI_KEY_CURSOR_RIGHT, KEY_SHIFT_MODIFIER, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
2707
2708   // Render and notify
2709   application.SendNotification();
2710   application.Render();
2711
2712   // Test to select full text in the left of the current cursor position
2713   application.ProcessEvent(GenerateKey("", "", "", DALI_KEY_SHIFT_LEFT, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
2714   application.ProcessEvent(GenerateKey("", "", "", DALI_KEY_CURSOR_LEFT, KEY_SHIFT_MODIFIER, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
2715   application.ProcessEvent(GenerateKey("", "", "", DALI_KEY_CURSOR_LEFT, KEY_SHIFT_MODIFIER, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
2716   application.ProcessEvent(GenerateKey("", "", "", DALI_KEY_CURSOR_LEFT, KEY_SHIFT_MODIFIER, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
2717   application.ProcessEvent(GenerateKey("", "", "", DALI_KEY_CURSOR_LEFT, KEY_SHIFT_MODIFIER, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
2718   application.ProcessEvent(GenerateKey("", "", "", DALI_KEY_CURSOR_LEFT, KEY_SHIFT_MODIFIER, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
2719
2720   // Render and notify
2721   application.SendNotification();
2722   application.Render();
2723
2724   // Test to release the current full text selection
2725   application.ProcessEvent(GenerateKey("", "", "", DALI_KEY_CURSOR_LEFT, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
2726   application.ProcessEvent(GenerateKey("", "", "", DALI_KEY_CURSOR_LEFT, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
2727
2728   // Render and notify
2729   application.SendNotification();
2730   application.Render();
2731
2732   // Test to move the current cursor position correctly
2733   application.ProcessEvent(GenerateKey("", "", "", DALI_KEY_CURSOR_RIGHT, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
2734
2735   // Render and notify
2736   application.SendNotification();
2737   application.Render();
2738
2739   // Add a character
2740   application.ProcessEvent(GenerateKey("d", "", "d", KEY_D_CODE, 0, 0, Integration::KeyEvent::DOWN, "d", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
2741
2742   // Render and notify
2743   application.SendNotification();
2744   application.Render();
2745
2746   DALI_TEST_EQUALS("DdALi", editor.GetProperty<std::string>(TextEditor::Property::TEXT), TEST_LOCATION);
2747
2748   // Test to select some text in the right of the current cursor position
2749   application.ProcessEvent(GenerateKey("", "", "", DALI_KEY_SHIFT_LEFT, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
2750   application.ProcessEvent(GenerateKey("", "", "", DALI_KEY_CURSOR_RIGHT, KEY_SHIFT_MODIFIER, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
2751   application.ProcessEvent(GenerateKey("", "", "", DALI_KEY_CURSOR_RIGHT, KEY_SHIFT_MODIFIER, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
2752
2753   // Render and notify
2754   application.SendNotification();
2755   application.Render();
2756
2757   // Test the cursor position with right arrow key
2758   application.ProcessEvent(GenerateKey("", "", "", DALI_KEY_CURSOR_RIGHT, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
2759
2760   // Render and notify
2761   application.SendNotification();
2762   application.Render();
2763
2764   // Add a character
2765   application.ProcessEvent(GenerateKey("c", "", "c", KEY_C_CODE, 0, 0, Integration::KeyEvent::DOWN, "c", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
2766
2767   // Render and notify
2768   application.SendNotification();
2769   application.Render();
2770
2771   DALI_TEST_EQUALS("DdALci", editor.GetProperty<std::string>(TextEditor::Property::TEXT), TEST_LOCATION);
2772
2773   // Test to select some text in the left of the current cursor position
2774   application.ProcessEvent(GenerateKey("", "", "", DALI_KEY_SHIFT_LEFT, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
2775   application.ProcessEvent(GenerateKey("", "", "", DALI_KEY_CURSOR_LEFT, KEY_SHIFT_MODIFIER, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
2776   application.ProcessEvent(GenerateKey("", "", "", DALI_KEY_CURSOR_LEFT, KEY_SHIFT_MODIFIER, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
2777   application.ProcessEvent(GenerateKey("", "", "", DALI_KEY_CURSOR_LEFT, KEY_SHIFT_MODIFIER, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
2778   application.ProcessEvent(GenerateKey("", "", "", DALI_KEY_CURSOR_LEFT, KEY_SHIFT_MODIFIER, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
2779
2780   // Render and notify
2781   application.SendNotification();
2782   application.Render();
2783
2784   // Test the cursor position with left arrow key
2785   application.ProcessEvent(GenerateKey("", "", "", DALI_KEY_CURSOR_LEFT, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
2786
2787   // Render and notify
2788   application.SendNotification();
2789   application.Render();
2790
2791   // Add a character
2792   application.ProcessEvent(GenerateKey("c", "", "c", KEY_C_CODE, 0, 0, Integration::KeyEvent::DOWN, "c", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
2793
2794   // Render and notify
2795   application.SendNotification();
2796   application.Render();
2797
2798   DALI_TEST_EQUALS("DcdALci", editor.GetProperty<std::string>(TextEditor::Property::TEXT), TEST_LOCATION);
2799
2800   // Test to select some text in the right of the current cursor position
2801   application.ProcessEvent(GenerateKey("", "", "", DALI_KEY_SHIFT_LEFT, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
2802   application.ProcessEvent(GenerateKey("", "", "", DALI_KEY_CURSOR_RIGHT, KEY_SHIFT_MODIFIER, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
2803   application.ProcessEvent(GenerateKey("", "", "", DALI_KEY_CURSOR_RIGHT, KEY_SHIFT_MODIFIER, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
2804   application.ProcessEvent(GenerateKey("", "", "", DALI_KEY_CURSOR_RIGHT, KEY_SHIFT_MODIFIER, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
2805
2806   // Render and notify
2807   application.SendNotification();
2808   application.Render();
2809
2810   // Test the cursor position with left arrow key
2811   application.ProcessEvent(GenerateKey("", "", "", DALI_KEY_CURSOR_LEFT, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
2812
2813   // Render and notify
2814   application.SendNotification();
2815   application.Render();
2816
2817   // Add a character
2818   application.ProcessEvent(GenerateKey("x", "", "x", KEY_X_CODE, 0, 0, Integration::KeyEvent::DOWN, "x", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
2819
2820   // Render and notify
2821   application.SendNotification();
2822   application.Render();
2823
2824   DALI_TEST_EQUALS("DcxdALci", editor.GetProperty<std::string>(TextEditor::Property::TEXT), TEST_LOCATION);
2825
2826   // Test to select some text in the left of the current cursor position
2827   application.ProcessEvent(GenerateKey("", "", "", DALI_KEY_SHIFT_LEFT, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
2828   application.ProcessEvent(GenerateKey("", "", "", DALI_KEY_CURSOR_LEFT, KEY_SHIFT_MODIFIER, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
2829   application.ProcessEvent(GenerateKey("", "", "", DALI_KEY_CURSOR_LEFT, KEY_SHIFT_MODIFIER, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
2830   application.ProcessEvent(GenerateKey("", "", "", DALI_KEY_CURSOR_LEFT, KEY_SHIFT_MODIFIER, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
2831
2832   // Render and notify
2833   application.SendNotification();
2834   application.Render();
2835
2836   // Test the cursor position with right arrow key
2837   application.ProcessEvent(GenerateKey("", "", "", DALI_KEY_CURSOR_RIGHT, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
2838
2839   // Render and notify
2840   application.SendNotification();
2841   application.Render();
2842
2843   // Add a character
2844   application.ProcessEvent(GenerateKey("c", "", "c", KEY_C_CODE, 0, 0, Integration::KeyEvent::DOWN, "c", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
2845
2846   // Render and notify
2847   application.SendNotification();
2848   application.Render();
2849
2850   DALI_TEST_EQUALS("DcxcdALci", editor.GetProperty<std::string>(TextEditor::Property::TEXT), TEST_LOCATION);
2851
2852   END_TEST;
2853 }
2854
2855 int utcDaliTextEditorHandles(void)
2856 {
2857   ToolkitTestApplication application;
2858   tet_infoline(" utcDaliTextEditorHandles");
2859
2860   TextEditor editor = TextEditor::New();
2861   DALI_TEST_CHECK(editor);
2862
2863   application.GetScene().Add(editor);
2864
2865   editor.SetProperty(TextEditor::Property::TEXT, "This is a long text for the size of the text-editor.");
2866   editor.SetProperty(TextEditor::Property::POINT_SIZE, 10.f);
2867   editor.SetProperty(TextEditor::Property::GRAB_HANDLE_IMAGE, HANDLE_IMAGE_FILE_NAME);
2868   editor.SetProperty(TextEditor::Property::SMOOTH_SCROLL, true);
2869
2870   editor.SetProperty(TextEditor::Property::SELECTION_HANDLE_IMAGE_LEFT, Property::Map{{"filename", HANDLE_LEFT_SELECTION_FILE_NAME}});
2871   editor.SetProperty(TextEditor::Property::SELECTION_HANDLE_IMAGE_RIGHT, Property::Map{{"filename", HANDLE_LEFT_SELECTION_FILE_NAME}});
2872   editor.SetProperty(TextEditor::Property::SELECTION_HANDLE_PRESSED_IMAGE_LEFT, Property::Map{{"filename", HANDLE_RIGHT_SELECTION_FILE_NAME}});
2873   editor.SetProperty(TextEditor::Property::SELECTION_HANDLE_PRESSED_IMAGE_RIGHT, Property::Map{{"filename", HANDLE_RIGHT_SELECTION_FILE_NAME}});
2874
2875   editor.SetProperty(Actor::Property::SIZE, Vector2(30.f, 500.f));
2876   editor.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT);
2877   editor.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
2878
2879   // Avoid a crash when core load gl resources.
2880   application.GetGlAbstraction().SetCheckFramebufferStatusResult(GL_FRAMEBUFFER_COMPLETE);
2881
2882   // Render and notify
2883   application.SendNotification();
2884   application.Render();
2885
2886   // Tap first to get the focus.
2887   TestGenerateTap(application, 3.0f, 25.0f, 100);
2888
2889   // Render and notify
2890   application.SendNotification();
2891   application.Render();
2892
2893   // Tap to create the grab handle.
2894   TestGenerateTap(application, 3.0f, 25.0f, 700);
2895
2896   // Render and notify
2897   application.SendNotification();
2898   application.Render();
2899
2900   // Get the active layer where the text's decoration is added.
2901   Actor activeLayer = editor.GetChildAt(1u);
2902
2903   // Get the handle's actor.
2904   Actor handle = activeLayer.GetChildAt(0u);
2905   handle.SetProperty(Actor::Property::SIZE, Vector2(100.f, 100.f));
2906
2907   // Render and notify
2908   application.SendNotification();
2909   application.Render();
2910
2911   // Touch the grab handle to set it as pressed.
2912   Vector2                       touchPos(10.0f, 50.0f);
2913   Dali::Integration::TouchEvent event;
2914   event = Dali::Integration::TouchEvent();
2915   event.AddPoint(GetPointDownInside(touchPos));
2916   application.ProcessEvent(event);
2917
2918   // Render and notify
2919   application.SendNotification();
2920   application.Render();
2921
2922   // Pan the grab handle
2923   uint32_t time = 100;
2924   TestStartPan(application, Vector2(10.0f, 50.0f), Vector2(10.0f, 50.0f), time);
2925   TestMovePan(application, Vector2(10.0f, 30.0f), time);
2926   TestEndPan(application, Vector2(10.0f, 50.0f), time);
2927   application.SendNotification();
2928   application.Render();
2929
2930   // Release the grab handle.
2931   event = Dali::Integration::TouchEvent();
2932   event.AddPoint(GetPointUpInside(touchPos));
2933   application.ProcessEvent(event);
2934
2935   // Render and notify
2936   application.SendNotification();
2937   application.Render();
2938
2939   // Tap first to get the focus.
2940   TestGenerateTap(application, 3.0f, 25.0f, 1400);
2941
2942   // Render and notify
2943   application.SendNotification();
2944   application.Render();
2945
2946   // Double tap to select a word and create the selection handles.
2947   TestGenerateTap(application, 3.0f, 25.0f, 1500);
2948
2949   // Render and notify
2950   application.SendNotification();
2951   application.Render();
2952
2953   touchPos = Vector2(10.0f, 50.0f);
2954
2955   // Touch the left selection handle to set it as pressed.
2956   event = Dali::Integration::TouchEvent();
2957   event.AddPoint(GetPointDownInside(touchPos));
2958   application.ProcessEvent(event);
2959
2960   // Render and notify
2961   application.SendNotification();
2962   application.Render();
2963
2964   // Release the left selection handle.
2965   event = Dali::Integration::TouchEvent();
2966   event.AddPoint(GetPointUpInside(touchPos));
2967   application.ProcessEvent(event);
2968
2969   // Render and notify
2970   application.SendNotification();
2971   application.Render();
2972
2973   END_TEST;
2974 }
2975
2976 int utcDaliTextEditorUnderPropertyStringP(void)
2977 {
2978   ToolkitTestApplication application;
2979   tet_infoline(" utcDaliTextEditorUnderPropertyStringP");
2980   TextEditor editor = TextEditor::New();
2981   DALI_TEST_CHECK(editor);
2982
2983   std::string underlineSettings1("{\"enable\":\"true\",\"color\":\"red\",\"height\":\"1\",\"type\":\"SOLID\",\"dashWidth\":\"2\",\"dashGap\":\"1\"}");
2984
2985   application.GetScene().Add(editor);
2986
2987   editor.SetProperty(TextEditor::Property::UNDERLINE, underlineSettings1);
2988   DALI_TEST_EQUALS(editor.GetProperty<std::string>(TextEditor::Property::UNDERLINE), underlineSettings1, TEST_LOCATION);
2989
2990   tet_infoline("Set underline settings with a map");
2991   // Check the input underline property
2992   Property::Map underlineMapSet;
2993   Property::Map underlineMapGet;
2994   underlineMapSet.Insert("enable", true);
2995   underlineMapSet.Insert("color", Color::BLUE);
2996   underlineMapSet.Insert("height", 1);
2997   underlineMapSet.Insert("type", Text::Underline::SOLID);
2998   underlineMapSet.Insert("dashWidth", 2);
2999   underlineMapSet.Insert("dashGap", 1);
3000
3001   editor.SetProperty(TextEditor::Property::UNDERLINE, underlineMapSet);
3002   editor.SetProperty(TextEditor::Property::TEXT, "text");
3003   underlineMapGet = editor.GetProperty<Property::Map>(TextEditor::Property::UNDERLINE);
3004   DALI_TEST_EQUALS(underlineMapGet.Count(), underlineMapSet.Count(), TEST_LOCATION);
3005   DALI_TEST_EQUALS(DaliTestCheckMaps(underlineMapSet, underlineMapGet), true, TEST_LOCATION);
3006
3007   application.SendNotification();
3008   application.Render();
3009
3010   underlineMapSet.Clear();
3011   underlineMapGet.Clear();
3012
3013   tet_infoline("Set dashed underline settings with a map");
3014   // Check the input underline property
3015   underlineMapSet.Clear();
3016   underlineMapGet.Clear();
3017   underlineMapSet.Insert("enable", true);
3018   underlineMapSet.Insert("color", Color::BLUE);
3019   underlineMapSet.Insert("height", 1);