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