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