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