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