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