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