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