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