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