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