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