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