Merge "DALi Version 2.1.17" into devel/master
[platform/core/uifw/dali-toolkit.git] / automated-tests / src / dali-toolkit / utc-Dali-TextEditor.cpp
1 /*
2  * Copyright (c) 2022 Samsung Electronics Co., Ltd.
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  * http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  *
16  */
17
18 #include <dali-toolkit-test-suite-utils.h>
19 #include <dali-toolkit/dali-toolkit.h>
20 #include <dali-toolkit/devel-api/controls/text-controls/text-editor-devel.h>
21 #include <dali-toolkit/devel-api/text/rendering-backend.h>
22 #include <dali-toolkit/devel-api/text/text-enumerations-devel.h>
23
24 #include <dali/devel-api/actors/actor-devel.h>
25 #include <dali/devel-api/adaptor-framework/clipboard.h>
26 #include <dali/devel-api/adaptor-framework/key-devel.h>
27 #include <dali/devel-api/text-abstraction/font-client.h>
28 #include <dali/integration-api/events/key-event-integ.h>
29 #include <dali/integration-api/events/touch-event-integ.h>
30 #include <dali/public-api/rendering/renderer.h>
31 #include <stdlib.h>
32 #include <unistd.h>
33 #include <iostream>
34 #include "test-text-geometry-utils.h"
35
36 using namespace Dali;
37 using namespace Toolkit;
38
39 void dali_texteditor_startup(void)
40 {
41   test_return_value = TET_UNDEF;
42 }
43
44 void dali_texteditor_cleanup(void)
45 {
46   test_return_value = TET_PASS;
47 }
48
49 namespace
50 {
51 const char* const PROPERTY_NAME_RENDERING_BACKEND                    = "renderingBackend";
52 const char* const PROPERTY_NAME_TEXT                                 = "text";
53 const char* const PROPERTY_NAME_TEXT_COLOR                           = "textColor";
54 const char* const PROPERTY_NAME_FONT_FAMILY                          = "fontFamily";
55 const char* const PROPERTY_NAME_FONT_STYLE                           = "fontStyle";
56 const char* const PROPERTY_NAME_POINT_SIZE                           = "pointSize";
57 const char* const PROPERTY_NAME_HORIZONTAL_ALIGNMENT                 = "horizontalAlignment";
58 const char* const PROPERTY_NAME_SCROLL_THRESHOLD                     = "scrollThreshold";
59 const char* const PROPERTY_NAME_SCROLL_SPEED                         = "scrollSpeed";
60 const char* const PROPERTY_NAME_PRIMARY_CURSOR_COLOR                 = "primaryCursorColor";
61 const char* const PROPERTY_NAME_SECONDARY_CURSOR_COLOR               = "secondaryCursorColor";
62 const char* const PROPERTY_NAME_ENABLE_CURSOR_BLINK                  = "enableCursorBlink";
63 const char* const PROPERTY_NAME_CURSOR_BLINK_INTERVAL                = "cursorBlinkInterval";
64 const char* const PROPERTY_NAME_CURSOR_BLINK_DURATION                = "cursorBlinkDuration";
65 const char* const PROPERTY_NAME_CURSOR_WIDTH                         = "cursorWidth";
66 const char* const PROPERTY_NAME_GRAB_HANDLE_IMAGE                    = "grabHandleImage";
67 const char* const PROPERTY_NAME_GRAB_HANDLE_PRESSED_IMAGE            = "grabHandlePressedImage";
68 const char* const PROPERTY_NAME_SELECTION_HANDLE_IMAGE_LEFT          = "selectionHandleImageLeft";
69 const char* const PROPERTY_NAME_SELECTION_HANDLE_IMAGE_RIGHT         = "selectionHandleImageRight";
70 const char* const PROPERTY_NAME_SELECTION_HANDLE_PRESSED_IMAGE_LEFT  = "selectionHandlePressedImageLeft";
71 const char* const PROPERTY_NAME_SELECTION_HANDLE_PRESSED_IMAGE_RIGHT = "selectionHandlePressedImageRight";
72 const char* const PROPERTY_NAME_SELECTION_HANDLE_MARKER_IMAGE_LEFT   = "selectionHandleMarkerImageLeft";
73 const char* const PROPERTY_NAME_SELECTION_HANDLE_MARKER_IMAGE_RIGHT  = "selectionHandleMarkerImageRight";
74 const char* const PROPERTY_NAME_SELECTION_HIGHLIGHT_COLOR            = "selectionHighlightColor";
75 const char* const PROPERTY_NAME_DECORATION_BOUNDING_BOX              = "decorationBoundingBox";
76 const char* const PROPERTY_NAME_ENABLE_MARKUP                        = "enableMarkup";
77 const char* const PROPERTY_NAME_INPUT_COLOR                          = "inputColor";
78 const char* const PROPERTY_NAME_INPUT_FONT_FAMILY                    = "inputFontFamily";
79 const char* const PROPERTY_NAME_INPUT_FONT_STYLE                     = "inputFontStyle";
80 const char* const PROPERTY_NAME_INPUT_POINT_SIZE                     = "inputPointSize";
81
82 const char* const PROPERTY_NAME_LINE_SPACING        = "lineSpacing";
83 const char* const PROPERTY_NAME_INPUT_LINE_SPACING  = "inputLineSpacing";
84 const char* const PROPERTY_NAME_UNDERLINE           = "underline";
85 const char* const PROPERTY_NAME_INPUT_UNDERLINE     = "inputUnderline";
86 const char* const PROPERTY_NAME_SHADOW              = "shadow";
87 const char* const PROPERTY_NAME_INPUT_SHADOW        = "inputShadow";
88 const char* const PROPERTY_NAME_EMBOSS              = "emboss";
89 const char* const PROPERTY_NAME_INPUT_EMBOSS        = "inputEmboss";
90 const char* const PROPERTY_NAME_OUTLINE             = "outline";
91 const char* const PROPERTY_NAME_INPUT_OUTLINE       = "inputOutline";
92 const char* const PROPERTY_NAME_STRIKETHROUGH       = "strikethrough";
93 const char* const PROPERTY_NAME_INPUT_STRIKETHROUGH = "inputStrikethrough";
94
95 const char* const PROPERTY_NAME_SMOOTH_SCROLL                   = "smoothScroll";
96 const char* const PROPERTY_NAME_SMOOTH_SCROLL_DURATION          = "smoothScrollDuration";
97 const char* const PROPERTY_NAME_ENABLE_SCROLL_BAR               = "enableScrollBar";
98 const char* const PROPERTY_NAME_SCROLL_BAR_SHOW_DURATION        = "scrollBarShowDuration";
99 const char* const PROPERTY_NAME_SCROLL_BAR_FADE_DURATION        = "scrollBarFadeDuration";
100 const char* const PROPERTY_NAME_PIXEL_SIZE                      = "pixelSize";
101 const char* const PROPERTY_NAME_LINE_COUNT                      = "lineCount";
102 const char* const PROPERTY_NAME_PLACEHOLDER_TEXT                = "placeholderText";
103 const char* const PROPERTY_NAME_PLACEHOLDER_TEXT_COLOR          = "placeholderTextColor";
104 const char* const PROPERTY_NAME_ENABLE_SELECTION                = "enableSelection";
105 const char* const PROPERTY_NAME_PLACEHOLDER                     = "placeholder";
106 const char* const PROPERTY_NAME_ENABLE_SHIFT_SELECTION          = "enableShiftSelection";
107 const char* const PROPERTY_NAME_ENABLE_GRAB_HANDLE              = "enableGrabHandle";
108 const char* const PROPERTY_NAME_MATCH_SYSTEM_LANGUAGE_DIRECTION = "matchSystemLanguageDirection";
109 const char* const PROPERTY_NAME_MAX_LENGTH                      = "maxLength";
110 const char* const PROPERTY_NAME_FONT_SIZE_SCALE                 = "fontSizeScale";
111 const char* const PROPERTY_NAME_ENABLE_FONT_SIZE_SCALE          = "enableFontSizeScale";
112 const char* const PROPERTY_NAME_GRAB_HANDLE_COLOR               = "grabHandleColor";
113 const char* const PROPERTY_NAME_ENABLE_GRAB_HANDLE_POPUP        = "enableGrabHandlePopup";
114 const char* const PROPERTY_NAME_INPUT_METHOD_SETTINGS           = "inputMethodSettings";
115 const char* const PROPERTY_NAME_INPUT_FILTER                    = "inputFilter";
116
117 const Vector4       PLACEHOLDER_TEXT_COLOR(0.8f, 0.8f, 0.8f, 0.8f);
118 const Dali::Vector4 LIGHT_BLUE(0.75f, 0.96f, 1.f, 1.f); // The text highlight color.
119
120 const float RENDER_FRAME_INTERVAL = 16.66f;
121
122 const unsigned int DEFAULT_FONT_SIZE = 1152u;
123 const std::string  DEFAULT_FONT_DIR("/resources/fonts");
124
125 const int KEY_A_CODE           = 38;
126 const int KEY_D_CODE           = 40;
127 const int KEY_C_CODE           = 54;
128 const int KEY_V_CODE           = 55;
129 const int KEY_X_CODE           = 53;
130 const int KEY_WHITE_SPACE_CODE = 65;
131
132 const int KEY_SHIFT_MODIFIER   = 257;
133 const int KEY_CONTROL_MODIFIER = 258;
134
135 const char* HANDLE_IMAGE_FILE_NAME           = TEST_RESOURCE_DIR "/insertpoint-icon.png";
136 const char* HANDLE_LEFT_SELECTION_FILE_NAME  = TEST_RESOURCE_DIR "/selection_handle_drop_left.png";
137 const char* HANDLE_RIGHT_SELECTION_FILE_NAME = TEST_RESOURCE_DIR "/selection_handle_drop_right.png";
138
139 const std::string DEFAULT_DEVICE_NAME("hwKeyboard");
140
141 static bool                                        gSelectionChangedCallbackCalled;
142 static uint32_t                                    oldSelectionStart;
143 static uint32_t                                    oldSelectionEnd;
144 static bool                                        gSelectionClearedCallbackCalled;
145 static bool                                        gSelectionStartedCallbackCalled;
146 static bool                                        gAnchorClickedCallBackCalled;
147 static bool                                        gAnchorClickedCallBackNotCalled;
148 static bool                                        gTextChangedCallBackCalled;
149 static bool                                        gInputFilteredAcceptedCallbackCalled;
150 static bool                                        gInputFilteredRejectedCallbackCalled;
151 static bool                                        gInputStyleChangedCallbackCalled;
152 static bool                                        gMaxCharactersCallBackCalled;
153 static bool                                        gCursorPositionChangedCallbackCalled;
154 static uint32_t                                    oldCursorPos;
155 static Dali::Toolkit::TextEditor::InputStyle::Mask gInputStyleMask;
156
157 struct CallbackFunctor
158 {
159   CallbackFunctor(bool* callbackFlag)
160   : mCallbackFlag(callbackFlag)
161   {
162   }
163
164   void operator()()
165   {
166     *mCallbackFlag = true;
167   }
168   bool* mCallbackFlag;
169 };
170
171 static void TestSelectionStartedCallback(TextEditor control)
172 {
173   tet_infoline(" TestSelectionStartedCallback");
174
175   gSelectionStartedCallbackCalled = true;
176 }
177
178 static void TestSelectionClearedCallback(TextEditor control)
179 {
180   tet_infoline(" TestSelectionClearedCallback");
181
182   gSelectionClearedCallbackCalled = true;
183 }
184
185 static void TestSelectionChangedCallback(TextEditor control, uint32_t oldStart, uint32_t oldEnd)
186 {
187   tet_infoline(" TestSelectionChangedCallback");
188
189   gSelectionChangedCallbackCalled = true;
190   oldSelectionStart               = oldStart;
191   oldSelectionEnd                 = oldEnd;
192 }
193
194 static void TestAnchorClickedCallback(TextEditor control, const char* href, unsigned int hrefLength)
195 {
196   tet_infoline(" TestAnchorClickedCallback");
197
198   gAnchorClickedCallBackNotCalled = false;
199
200   if(!strcmp(href, "https://www.tizen.org") && hrefLength == strlen(href))
201   {
202     gAnchorClickedCallBackCalled = true;
203   }
204 }
205
206 static void TestCursorPositionChangedCallback(TextEditor control, unsigned int oldPos)
207 {
208   tet_infoline(" TestCursorPositionChangedCallback");
209
210   gCursorPositionChangedCallbackCalled = true;
211   oldCursorPos                         = oldPos;
212 }
213
214 static void TestTextChangedCallback(TextEditor control)
215 {
216   tet_infoline(" TestTextChangedCallback");
217
218   gTextChangedCallBackCalled = true;
219 }
220
221 static void TestInputStyleChangedCallback(TextEditor control, TextEditor::InputStyle::Mask mask)
222 {
223   tet_infoline(" TestInputStyleChangedCallback");
224
225   gInputStyleChangedCallbackCalled = true;
226   gInputStyleMask                  = mask;
227 }
228
229 static void TestMaxLengthReachedCallback(TextEditor control)
230 {
231   tet_infoline(" TestMaxLengthReachedCallback");
232
233   gMaxCharactersCallBackCalled = true;
234 }
235
236 static void TestInputFilteredCallback(TextEditor control, Toolkit::InputFilter::Property::Type type)
237 {
238   tet_infoline(" TestInputFilteredCallback");
239
240   if(type == Toolkit::InputFilter::Property::ACCEPTED)
241   {
242     gInputFilteredAcceptedCallbackCalled = true;
243   }
244   else if(type == Toolkit::InputFilter::Property::REJECTED)
245   {
246     gInputFilteredRejectedCallbackCalled = true;
247   }
248 }
249
250 // Generate a KeyEvent to send to Core.
251 Integration::KeyEvent GenerateKey(const std::string&                  keyName,
252                                   const std::string&                  logicalKey,
253                                   const std::string&                  keyString,
254                                   int                                 keyCode,
255                                   int                                 keyModifier,
256                                   unsigned long                       timeStamp,
257                                   const Integration::KeyEvent::State& keyState,
258                                   const std::string&                  compose        = "",
259                                   const std::string&                  deviceName     = DEFAULT_DEVICE_NAME,
260                                   const Device::Class::Type&          deviceClass    = Device::Class::NONE,
261                                   const Device::Subclass::Type&       deviceSubclass = Device::Subclass::NONE)
262 {
263   return Integration::KeyEvent(keyName,
264                                logicalKey,
265                                keyString,
266                                keyCode,
267                                keyModifier,
268                                timeStamp,
269                                keyState,
270                                compose,
271                                deviceName,
272                                deviceClass,
273                                deviceSubclass);
274 }
275
276 Dali::Integration::Point GetPointDownInside(Vector2& pos)
277 {
278   Dali::Integration::Point point;
279   point.SetState(PointState::DOWN);
280   point.SetScreenPosition(pos);
281   return point;
282 }
283
284 Dali::Integration::Point GetPointUpInside(Vector2& pos)
285 {
286   Dali::Integration::Point point;
287   point.SetState(PointState::UP);
288   point.SetScreenPosition(pos);
289   return point;
290 }
291
292 bool DaliTestCheckMaps(const Property::Map& fontStyleMapGet, const Property::Map& fontStyleMapSet)
293 {
294   if(fontStyleMapGet.Count() == fontStyleMapSet.Count())
295   {
296     for(unsigned int index = 0u; index < fontStyleMapGet.Count(); ++index)
297     {
298       const KeyValuePair& valueGet = fontStyleMapGet.GetKeyValue(index);
299
300       Property::Value* valueSet = NULL;
301       if(valueGet.first.type == Property::Key::INDEX)
302       {
303         valueSet = fontStyleMapSet.Find(valueGet.first.indexKey);
304       }
305       else
306       {
307         // Get Key is a string so searching Set Map for a string key
308         valueSet = fontStyleMapSet.Find(valueGet.first.stringKey);
309       }
310
311       if(NULL != valueSet)
312       {
313         if(valueSet->GetType() == Dali::Property::STRING && (valueGet.second.Get<std::string>() != valueSet->Get<std::string>()))
314         {
315           tet_printf("Value got : [%s], expected : [%s]", valueGet.second.Get<std::string>().c_str(), valueSet->Get<std::string>().c_str());
316           return false;
317         }
318         else if(valueSet->GetType() == Dali::Property::BOOLEAN && (valueGet.second.Get<bool>() != valueSet->Get<bool>()))
319         {
320           tet_printf("Value got : [%d], expected : [%d]", valueGet.second.Get<bool>(), valueSet->Get<bool>());
321           return false;
322         }
323         else if(valueSet->GetType() == Dali::Property::INTEGER && (valueGet.second.Get<int>() != valueSet->Get<int>()))
324         {
325           tet_printf("Value got : [%d], expected : [%d]", valueGet.second.Get<int>(), valueSet->Get<int>());
326           return false;
327         }
328         else if(valueSet->GetType() == Dali::Property::FLOAT && (valueGet.second.Get<float>() != valueSet->Get<float>()))
329         {
330           tet_printf("Value got : [%f], expected : [%f]", valueGet.second.Get<float>(), valueSet->Get<float>());
331           return false;
332         }
333         else if(valueSet->GetType() == Dali::Property::VECTOR2 && (valueGet.second.Get<Vector2>() != valueSet->Get<Vector2>()))
334         {
335           Vector2 vector2Get = valueGet.second.Get<Vector2>();
336           Vector2 vector2Set = valueSet->Get<Vector2>();
337           tet_printf("Value got : [%f, %f], expected : [%f, %f]", vector2Get.x, vector2Get.y, vector2Set.x, vector2Set.y);
338           return false;
339         }
340         else if(valueSet->GetType() == Dali::Property::VECTOR4 && (valueGet.second.Get<Vector4>() != valueSet->Get<Vector4>()))
341         {
342           Vector4 vector4Get = valueGet.second.Get<Vector4>();
343           Vector4 vector4Set = valueSet->Get<Vector4>();
344           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);
345           return false;
346         }
347       }
348       else
349       {
350         if(valueGet.first.type == Property::Key::INDEX)
351         {
352           tet_printf("  The key %d doesn't exist.", valueGet.first.indexKey);
353         }
354         else
355         {
356           tet_printf("  The key %s doesn't exist.", valueGet.first.stringKey.c_str());
357         }
358         return false;
359       }
360     }
361   }
362
363   return true;
364 }
365
366 class ScrollStateChangeCallback : public Dali::ConnectionTracker
367 {
368 public:
369   ScrollStateChangeCallback(bool& startedCalled, bool& finishedCalled)
370   : mStartedCalled(startedCalled),
371     mFinishedCalled(finishedCalled)
372   {
373   }
374
375   void Callback(TextEditor editor, TextEditor::Scroll::Type type)
376   {
377     if(type == TextEditor::Scroll::STARTED)
378     {
379       mStartedCalled = true;
380     }
381     else if(type == TextEditor::Scroll::FINISHED)
382     {
383       mFinishedCalled = true;
384     }
385   }
386
387   bool& mStartedCalled;
388   bool& mFinishedCalled;
389 };
390
391 } // namespace
392
393 int UtcDaliToolkitTextEditorConstructorP(void)
394 {
395   ToolkitTestApplication application;
396   tet_infoline(" UtcDaliToolkitTextEditorConstructorP");
397   TextEditor textEditor;
398   DALI_TEST_CHECK(!textEditor);
399   END_TEST;
400 }
401
402 int UtcDaliToolkitTextEditorNewP(void)
403 {
404   ToolkitTestApplication application;
405   tet_infoline(" UtcDaliToolkitTextEditorNewP");
406   TextEditor textEditor = TextEditor::New();
407   DALI_TEST_CHECK(textEditor);
408   END_TEST;
409 }
410
411 int UtcDaliToolkitTextEditorDownCastP(void)
412 {
413   ToolkitTestApplication application;
414   tet_infoline(" UtcDaliToolkitTextEditorDownCastP");
415   TextEditor textEditor1 = TextEditor::New();
416   BaseHandle object(textEditor1);
417
418   TextEditor textEditor2 = TextEditor::DownCast(object);
419   DALI_TEST_CHECK(textEditor2);
420
421   TextEditor textEditor3 = DownCast<TextEditor>(object);
422   DALI_TEST_CHECK(textEditor3);
423   END_TEST;
424 }
425
426 int UtcDaliToolkitTextEditorDownCastN(void)
427 {
428   ToolkitTestApplication application;
429   tet_infoline(" UtcDaliToolkitTextEditorDownCastN");
430   BaseHandle uninitializedObject;
431   TextEditor textEditor1 = TextEditor::DownCast(uninitializedObject);
432   DALI_TEST_CHECK(!textEditor1);
433
434   TextEditor textEditor2 = DownCast<TextEditor>(uninitializedObject);
435   DALI_TEST_CHECK(!textEditor2);
436   END_TEST;
437 }
438
439 int UtcDaliToolkitTextEditorCopyConstructorP(void)
440 {
441   ToolkitTestApplication application;
442   tet_infoline(" UtcDaliToolkitTextEditorCopyConstructorP");
443   TextEditor textEditor = TextEditor::New();
444   textEditor.SetProperty(TextEditor::Property::TEXT, "Test");
445
446   TextEditor copy(textEditor);
447   DALI_TEST_CHECK(copy);
448   DALI_TEST_CHECK(copy.GetProperty<std::string>(TextEditor::Property::TEXT) == textEditor.GetProperty<std::string>(TextEditor::Property::TEXT));
449   END_TEST;
450 }
451
452 int UtcDaliTextEditorMoveConstructor(void)
453 {
454   ToolkitTestApplication application;
455
456   TextEditor textEditor = TextEditor::New();
457   textEditor.SetProperty(TextEditor::Property::TEXT, "Test");
458   DALI_TEST_CHECK(textEditor.GetProperty<std::string>(TextEditor::Property::TEXT) == "Test");
459
460   TextEditor moved = std::move(textEditor);
461   DALI_TEST_CHECK(moved);
462   DALI_TEST_EQUALS(1, moved.GetBaseObject().ReferenceCount(), TEST_LOCATION);
463   DALI_TEST_CHECK(moved.GetProperty<std::string>(TextEditor::Property::TEXT) == "Test");
464   DALI_TEST_CHECK(!textEditor);
465
466   END_TEST;
467 }
468
469 int UtcDaliToolkitTextEditorAssignmentOperatorP(void)
470 {
471   ToolkitTestApplication application;
472   tet_infoline(" UtcDaliToolkitTextEditorAssignmentOperatorP");
473   TextEditor textEditor = TextEditor::New();
474   textEditor.SetProperty(TextEditor::Property::TEXT, "Test");
475
476   TextEditor copy = textEditor;
477   DALI_TEST_CHECK(copy);
478   DALI_TEST_CHECK(copy.GetProperty<std::string>(TextEditor::Property::TEXT) == textEditor.GetProperty<std::string>(TextEditor::Property::TEXT));
479   END_TEST;
480 }
481
482 int UtcDaliTextEditorMoveAssignment(void)
483 {
484   ToolkitTestApplication application;
485
486   TextEditor textEditor = TextEditor::New();
487   textEditor.SetProperty(TextEditor::Property::TEXT, "Test");
488   DALI_TEST_CHECK(textEditor.GetProperty<std::string>(TextEditor::Property::TEXT) == "Test");
489
490   TextEditor moved;
491   moved = std::move(textEditor);
492   DALI_TEST_CHECK(moved);
493   DALI_TEST_EQUALS(1, moved.GetBaseObject().ReferenceCount(), TEST_LOCATION);
494   DALI_TEST_CHECK(moved.GetProperty<std::string>(TextEditor::Property::TEXT) == "Test");
495   DALI_TEST_CHECK(!textEditor);
496
497   END_TEST;
498 }
499
500 int UtcDaliTextEditorNewP(void)
501 {
502   ToolkitTestApplication application;
503   tet_infoline(" UtcDaliToolkitTextEditorNewP");
504   TextEditor textEditor = TextEditor::New();
505   DALI_TEST_CHECK(textEditor);
506   END_TEST;
507 }
508
509 // Positive test case for a method
510 int UtcDaliTextEditorGetPropertyP(void)
511 {
512   ToolkitTestApplication application;
513   tet_infoline(" UtcDaliToolkitTextEditorGetPropertyP");
514   TextEditor editor = TextEditor::New();
515   DALI_TEST_CHECK(editor);
516
517   // Check Property Indices are correct
518   DALI_TEST_CHECK(editor.GetPropertyIndex(PROPERTY_NAME_RENDERING_BACKEND) == DevelTextEditor::Property::RENDERING_BACKEND);
519   DALI_TEST_CHECK(editor.GetPropertyIndex(PROPERTY_NAME_TEXT) == TextEditor::Property::TEXT);
520   DALI_TEST_CHECK(editor.GetPropertyIndex(PROPERTY_NAME_TEXT_COLOR) == TextEditor::Property::TEXT_COLOR);
521   DALI_TEST_CHECK(editor.GetPropertyIndex(PROPERTY_NAME_FONT_FAMILY) == TextEditor::Property::FONT_FAMILY);
522   DALI_TEST_CHECK(editor.GetPropertyIndex(PROPERTY_NAME_FONT_STYLE) == TextEditor::Property::FONT_STYLE);
523   DALI_TEST_CHECK(editor.GetPropertyIndex(PROPERTY_NAME_POINT_SIZE) == TextEditor::Property::POINT_SIZE);
524   DALI_TEST_CHECK(editor.GetPropertyIndex(PROPERTY_NAME_HORIZONTAL_ALIGNMENT) == TextEditor::Property::HORIZONTAL_ALIGNMENT);
525   DALI_TEST_CHECK(editor.GetPropertyIndex(PROPERTY_NAME_SCROLL_THRESHOLD) == TextEditor::Property::SCROLL_THRESHOLD);
526   DALI_TEST_CHECK(editor.GetPropertyIndex(PROPERTY_NAME_SCROLL_SPEED) == TextEditor::Property::SCROLL_SPEED);
527   DALI_TEST_CHECK(editor.GetPropertyIndex(PROPERTY_NAME_PRIMARY_CURSOR_COLOR) == TextEditor::Property::PRIMARY_CURSOR_COLOR);
528   DALI_TEST_CHECK(editor.GetPropertyIndex(PROPERTY_NAME_SECONDARY_CURSOR_COLOR) == TextEditor::Property::SECONDARY_CURSOR_COLOR);
529   DALI_TEST_CHECK(editor.GetPropertyIndex(PROPERTY_NAME_ENABLE_CURSOR_BLINK) == TextEditor::Property::ENABLE_CURSOR_BLINK);
530   DALI_TEST_CHECK(editor.GetPropertyIndex(PROPERTY_NAME_CURSOR_BLINK_INTERVAL) == TextEditor::Property::CURSOR_BLINK_INTERVAL);
531   DALI_TEST_CHECK(editor.GetPropertyIndex(PROPERTY_NAME_CURSOR_BLINK_DURATION) == TextEditor::Property::CURSOR_BLINK_DURATION);
532   DALI_TEST_CHECK(editor.GetPropertyIndex(PROPERTY_NAME_CURSOR_WIDTH) == TextEditor::Property::CURSOR_WIDTH);
533   DALI_TEST_CHECK(editor.GetPropertyIndex(PROPERTY_NAME_GRAB_HANDLE_IMAGE) == TextEditor::Property::GRAB_HANDLE_IMAGE);
534   DALI_TEST_CHECK(editor.GetPropertyIndex(PROPERTY_NAME_GRAB_HANDLE_PRESSED_IMAGE) == TextEditor::Property::GRAB_HANDLE_PRESSED_IMAGE);
535   DALI_TEST_CHECK(editor.GetPropertyIndex(PROPERTY_NAME_SELECTION_HANDLE_IMAGE_LEFT) == TextEditor::Property::SELECTION_HANDLE_IMAGE_LEFT);
536   DALI_TEST_CHECK(editor.GetPropertyIndex(PROPERTY_NAME_SELECTION_HANDLE_IMAGE_RIGHT) == TextEditor::Property::SELECTION_HANDLE_IMAGE_RIGHT);
537   DALI_TEST_CHECK(editor.GetPropertyIndex(PROPERTY_NAME_SELECTION_HANDLE_PRESSED_IMAGE_LEFT) == TextEditor::Property::SELECTION_HANDLE_PRESSED_IMAGE_LEFT);
538   DALI_TEST_CHECK(editor.GetPropertyIndex(PROPERTY_NAME_SELECTION_HANDLE_PRESSED_IMAGE_RIGHT) == TextEditor::Property::SELECTION_HANDLE_PRESSED_IMAGE_RIGHT);
539   DALI_TEST_CHECK(editor.GetPropertyIndex(PROPERTY_NAME_SELECTION_HANDLE_MARKER_IMAGE_LEFT) == TextEditor::Property::SELECTION_HANDLE_MARKER_IMAGE_LEFT);
540   DALI_TEST_CHECK(editor.GetPropertyIndex(PROPERTY_NAME_SELECTION_HANDLE_MARKER_IMAGE_RIGHT) == TextEditor::Property::SELECTION_HANDLE_MARKER_IMAGE_RIGHT);
541   DALI_TEST_CHECK(editor.GetPropertyIndex(PROPERTY_NAME_SELECTION_HIGHLIGHT_COLOR) == TextEditor::Property::SELECTION_HIGHLIGHT_COLOR);
542   DALI_TEST_CHECK(editor.GetPropertyIndex(PROPERTY_NAME_DECORATION_BOUNDING_BOX) == TextEditor::Property::DECORATION_BOUNDING_BOX);
543   DALI_TEST_CHECK(editor.GetPropertyIndex(PROPERTY_NAME_ENABLE_MARKUP) == TextEditor::Property::ENABLE_MARKUP);
544   DALI_TEST_CHECK(editor.GetPropertyIndex(PROPERTY_NAME_INPUT_COLOR) == TextEditor::Property::INPUT_COLOR);
545   DALI_TEST_CHECK(editor.GetPropertyIndex(PROPERTY_NAME_INPUT_FONT_FAMILY) == TextEditor::Property::INPUT_FONT_FAMILY);
546   DALI_TEST_CHECK(editor.GetPropertyIndex(PROPERTY_NAME_INPUT_FONT_STYLE) == TextEditor::Property::INPUT_FONT_STYLE);
547   DALI_TEST_CHECK(editor.GetPropertyIndex(PROPERTY_NAME_INPUT_POINT_SIZE) == TextEditor::Property::INPUT_POINT_SIZE);
548
549   DALI_TEST_CHECK(editor.GetPropertyIndex(PROPERTY_NAME_LINE_SPACING) == TextEditor::Property::LINE_SPACING);
550   DALI_TEST_CHECK(editor.GetPropertyIndex(PROPERTY_NAME_INPUT_LINE_SPACING) == TextEditor::Property::INPUT_LINE_SPACING);
551   DALI_TEST_CHECK(editor.GetPropertyIndex(PROPERTY_NAME_UNDERLINE) == TextEditor::Property::UNDERLINE);
552   DALI_TEST_CHECK(editor.GetPropertyIndex(PROPERTY_NAME_INPUT_UNDERLINE) == TextEditor::Property::INPUT_UNDERLINE);
553   DALI_TEST_CHECK(editor.GetPropertyIndex(PROPERTY_NAME_SHADOW) == TextEditor::Property::SHADOW);
554   DALI_TEST_CHECK(editor.GetPropertyIndex(PROPERTY_NAME_INPUT_SHADOW) == TextEditor::Property::INPUT_SHADOW);
555   DALI_TEST_CHECK(editor.GetPropertyIndex(PROPERTY_NAME_EMBOSS) == TextEditor::Property::EMBOSS);
556   DALI_TEST_CHECK(editor.GetPropertyIndex(PROPERTY_NAME_INPUT_EMBOSS) == TextEditor::Property::INPUT_EMBOSS);
557   DALI_TEST_CHECK(editor.GetPropertyIndex(PROPERTY_NAME_OUTLINE) == TextEditor::Property::OUTLINE);
558   DALI_TEST_CHECK(editor.GetPropertyIndex(PROPERTY_NAME_INPUT_OUTLINE) == TextEditor::Property::INPUT_OUTLINE);
559   DALI_TEST_CHECK(editor.GetPropertyIndex(PROPERTY_NAME_STRIKETHROUGH) == DevelTextEditor::Property::STRIKETHROUGH);
560   DALI_TEST_CHECK(editor.GetPropertyIndex(PROPERTY_NAME_INPUT_STRIKETHROUGH) == DevelTextEditor::Property::INPUT_STRIKETHROUGH);
561   DALI_TEST_CHECK(editor.GetPropertyIndex(PROPERTY_NAME_SMOOTH_SCROLL) == TextEditor::Property::SMOOTH_SCROLL);
562   DALI_TEST_CHECK(editor.GetPropertyIndex(PROPERTY_NAME_SMOOTH_SCROLL_DURATION) == TextEditor::Property::SMOOTH_SCROLL_DURATION);
563   DALI_TEST_CHECK(editor.GetPropertyIndex(PROPERTY_NAME_ENABLE_SCROLL_BAR) == TextEditor::Property::ENABLE_SCROLL_BAR);
564   DALI_TEST_CHECK(editor.GetPropertyIndex(PROPERTY_NAME_SCROLL_BAR_SHOW_DURATION) == TextEditor::Property::SCROLL_BAR_SHOW_DURATION);
565   DALI_TEST_CHECK(editor.GetPropertyIndex(PROPERTY_NAME_SCROLL_BAR_FADE_DURATION) == TextEditor::Property::SCROLL_BAR_FADE_DURATION);
566   DALI_TEST_CHECK(editor.GetPropertyIndex(PROPERTY_NAME_PIXEL_SIZE) == TextEditor::Property::PIXEL_SIZE);
567   DALI_TEST_CHECK(editor.GetPropertyIndex(PROPERTY_NAME_LINE_COUNT) == TextEditor::Property::LINE_COUNT);
568   DALI_TEST_CHECK(editor.GetPropertyIndex(PROPERTY_NAME_ENABLE_SELECTION) == TextEditor::Property::ENABLE_SELECTION);
569   DALI_TEST_CHECK(editor.GetPropertyIndex(PROPERTY_NAME_PLACEHOLDER) == TextEditor::Property::PLACEHOLDER);
570   DALI_TEST_CHECK(editor.GetPropertyIndex(PROPERTY_NAME_FONT_SIZE_SCALE) == DevelTextEditor::Property::FONT_SIZE_SCALE);
571   DALI_TEST_CHECK(editor.GetPropertyIndex(PROPERTY_NAME_ENABLE_FONT_SIZE_SCALE) == DevelTextEditor::Property::ENABLE_FONT_SIZE_SCALE);
572   DALI_TEST_CHECK(editor.GetPropertyIndex(PROPERTY_NAME_PLACEHOLDER_TEXT) == DevelTextEditor::Property::PLACEHOLDER_TEXT);
573   DALI_TEST_CHECK(editor.GetPropertyIndex(PROPERTY_NAME_PLACEHOLDER_TEXT_COLOR) == DevelTextEditor::Property::PLACEHOLDER_TEXT_COLOR);
574   DALI_TEST_CHECK(editor.GetPropertyIndex(PROPERTY_NAME_ENABLE_SHIFT_SELECTION) == DevelTextEditor::Property::ENABLE_SHIFT_SELECTION);
575   DALI_TEST_CHECK(editor.GetPropertyIndex(PROPERTY_NAME_ENABLE_GRAB_HANDLE) == DevelTextEditor::Property::ENABLE_GRAB_HANDLE);
576   DALI_TEST_CHECK(editor.GetPropertyIndex(PROPERTY_NAME_MATCH_SYSTEM_LANGUAGE_DIRECTION) == DevelTextEditor::Property::MATCH_SYSTEM_LANGUAGE_DIRECTION);
577   DALI_TEST_CHECK(editor.GetPropertyIndex(PROPERTY_NAME_MAX_LENGTH) == DevelTextEditor::Property::MAX_LENGTH);
578   DALI_TEST_CHECK(editor.GetPropertyIndex(PROPERTY_NAME_GRAB_HANDLE_COLOR) == DevelTextEditor::Property::GRAB_HANDLE_COLOR);
579   DALI_TEST_CHECK(editor.GetPropertyIndex(PROPERTY_NAME_ENABLE_GRAB_HANDLE_POPUP) == DevelTextEditor::Property::ENABLE_GRAB_HANDLE_POPUP);
580   DALI_TEST_CHECK(editor.GetPropertyIndex(PROPERTY_NAME_INPUT_METHOD_SETTINGS) == DevelTextEditor::Property::INPUT_METHOD_SETTINGS);
581   DALI_TEST_CHECK(editor.GetPropertyIndex(PROPERTY_NAME_INPUT_FILTER) == DevelTextEditor::Property::INPUT_FILTER);
582   DALI_TEST_CHECK(editor.GetPropertyIndex(PROPERTY_NAME_STRIKETHROUGH) == DevelTextEditor::Property::STRIKETHROUGH);
583   DALI_TEST_CHECK(editor.GetPropertyIndex(PROPERTY_NAME_INPUT_STRIKETHROUGH) == DevelTextEditor::Property::INPUT_STRIKETHROUGH);
584
585   END_TEST;
586 }
587
588 bool SetPropertyMapRetrieved(TextEditor& editor, const Property::Index property, const std::string mapKey, const std::string mapValue)
589 {
590   bool          result = false;
591   Property::Map imageMap;
592   imageMap[mapKey] = mapValue;
593
594   editor.SetProperty(property, imageMap);
595   Property::Value propValue = editor.GetProperty(property);
596   Property::Map*  resultMap = propValue.GetMap();
597
598   if(resultMap->Find(mapKey)->Get<std::string>() == mapValue)
599   {
600     result = true;
601   }
602
603   return result;
604 }
605
606 // Positive test case for a method
607 int UtcDaliTextEditorSetPropertyP(void)
608 {
609   ToolkitTestApplication application;
610   tet_infoline(" UtcDaliToolkitTextEditorSetPropertyP");
611   TextEditor editor = TextEditor::New();
612   DALI_TEST_CHECK(editor);
613   application.GetScene().Add(editor);
614
615   // Note - we can't check the defaults since the stylesheets are platform-specific
616
617   // Check the render backend property.
618   editor.SetProperty(DevelTextEditor::Property::RENDERING_BACKEND, DevelText::RENDERING_SHARED_ATLAS);
619   DALI_TEST_EQUALS((DevelText::RenderingType)editor.GetProperty<int>(DevelTextEditor::Property::RENDERING_BACKEND), DevelText::RENDERING_SHARED_ATLAS, TEST_LOCATION);
620
621   // Check text property.
622   editor.SetProperty(TextEditor::Property::TEXT, "Setting Text");
623   DALI_TEST_EQUALS(editor.GetProperty<std::string>(TextEditor::Property::TEXT), std::string("Setting Text"), TEST_LOCATION);
624
625   // Check text's color property
626   editor.SetProperty(TextEditor::Property::TEXT_COLOR, Color::WHITE);
627   DALI_TEST_EQUALS(editor.GetProperty<Vector4>(TextEditor::Property::TEXT_COLOR), Color::WHITE, TEST_LOCATION);
628
629   // Check font properties.
630   editor.SetProperty(TextEditor::Property::FONT_FAMILY, "Setting font family");
631   DALI_TEST_EQUALS(editor.GetProperty<std::string>(TextEditor::Property::FONT_FAMILY), std::string("Setting font family"), TEST_LOCATION);
632
633   Property::Map    fontStyleMapSet;
634   Property::Map    fontStyleMapGet;
635   Property::Value* slantValue = NULL;
636
637   fontStyleMapSet.Insert("weight", "bold");
638   fontStyleMapSet.Insert("width", "condensed");
639   fontStyleMapSet.Insert("slant", "italic");
640
641   editor.SetProperty(TextEditor::Property::FONT_STYLE, fontStyleMapSet);
642   fontStyleMapGet = editor.GetProperty<Property::Map>(TextEditor::Property::FONT_STYLE);
643   DALI_TEST_EQUALS(fontStyleMapGet.Count(), fontStyleMapSet.Count(), TEST_LOCATION);
644   DALI_TEST_EQUALS(DaliTestCheckMaps(fontStyleMapGet, fontStyleMapSet), true, TEST_LOCATION);
645
646   editor.SetProperty(TextEditor::Property::POINT_SIZE, 10.f);
647   DALI_TEST_EQUALS(editor.GetProperty<float>(TextEditor::Property::POINT_SIZE), 10.f, Math::MACHINE_EPSILON_1000, TEST_LOCATION);
648
649   editor.SetProperty(DevelTextEditor::Property::FONT_SIZE_SCALE, 2.5f);
650   DALI_TEST_EQUALS(editor.GetProperty<float>(DevelTextEditor::Property::FONT_SIZE_SCALE), 2.5f, Math::MACHINE_EPSILON_1000, TEST_LOCATION);
651   editor.SetProperty(DevelTextEditor::Property::FONT_SIZE_SCALE, 1.0f);
652
653   editor.SetProperty(DevelTextEditor::Property::ENABLE_FONT_SIZE_SCALE, false);
654   DALI_TEST_EQUALS(editor.GetProperty<bool>(DevelTextEditor::Property::ENABLE_FONT_SIZE_SCALE), false, TEST_LOCATION);
655   editor.SetProperty(DevelTextEditor::Property::ENABLE_FONT_SIZE_SCALE, true);
656
657   // Reset font style.
658   fontStyleMapSet.Clear();
659   fontStyleMapSet.Insert("weight", "normal");
660   fontStyleMapSet.Insert("slant", "oblique");
661   editor.SetProperty(TextEditor::Property::FONT_STYLE, fontStyleMapSet);
662   fontStyleMapGet = editor.GetProperty<Property::Map>(TextEditor::Property::FONT_STYLE);
663   DALI_TEST_EQUALS(fontStyleMapGet.Count(), fontStyleMapSet.Count(), TEST_LOCATION);
664   DALI_TEST_EQUALS(DaliTestCheckMaps(fontStyleMapGet, fontStyleMapSet), true, TEST_LOCATION);
665
666   fontStyleMapSet.Clear();
667   fontStyleMapSet.Insert("slant", "roman");
668   editor.SetProperty(TextEditor::Property::FONT_STYLE, fontStyleMapSet);
669   fontStyleMapGet = editor.GetProperty<Property::Map>(TextEditor::Property::FONT_STYLE);
670
671   // Replace 'roman' for 'normal'.
672   slantValue = fontStyleMapGet.Find("slant");
673   if(NULL != slantValue)
674   {
675     if("normal" == slantValue->Get<std::string>())
676     {
677       fontStyleMapGet["slant"] = "roman";
678     }
679   }
680   DALI_TEST_EQUALS(fontStyleMapGet.Count(), fontStyleMapSet.Count(), TEST_LOCATION);
681   DALI_TEST_EQUALS(DaliTestCheckMaps(fontStyleMapGet, fontStyleMapSet), true, TEST_LOCATION);
682
683   fontStyleMapSet.Clear();
684
685   editor.SetProperty(TextEditor::Property::FONT_STYLE, fontStyleMapSet);
686   fontStyleMapGet = editor.GetProperty<Property::Map>(TextEditor::Property::FONT_STYLE);
687   DALI_TEST_EQUALS(fontStyleMapGet.Count(), fontStyleMapSet.Count(), TEST_LOCATION);
688   DALI_TEST_EQUALS(DaliTestCheckMaps(fontStyleMapGet, fontStyleMapSet), true, TEST_LOCATION);
689
690   // Check that the Alignment properties can be correctly set
691   editor.SetProperty(TextEditor::Property::HORIZONTAL_ALIGNMENT, "END");
692   DALI_TEST_EQUALS(editor.GetProperty<std::string>(TextEditor::Property::HORIZONTAL_ALIGNMENT), "END", TEST_LOCATION);
693
694   // Check that the Alignment properties can be correctly set
695   editor.SetProperty(DevelTextEditor::Property::VERTICAL_ALIGNMENT, "BOTTOM");
696   DALI_TEST_EQUALS(editor.GetProperty<std::string>(DevelTextEditor::Property::VERTICAL_ALIGNMENT), "BOTTOM", TEST_LOCATION);
697   editor.SetProperty(DevelTextEditor::Property::VERTICAL_ALIGNMENT, "CENTER");
698   DALI_TEST_EQUALS(editor.GetProperty<std::string>(DevelTextEditor::Property::VERTICAL_ALIGNMENT), "CENTER", TEST_LOCATION);
699   editor.SetProperty(DevelTextEditor::Property::VERTICAL_ALIGNMENT, "TOP");
700   DALI_TEST_EQUALS(editor.GetProperty<std::string>(DevelTextEditor::Property::VERTICAL_ALIGNMENT), "TOP", TEST_LOCATION);
701
702   // Check scroll properties.
703   editor.SetProperty(TextEditor::Property::SCROLL_THRESHOLD, 1.f);
704   DALI_TEST_EQUALS(editor.GetProperty<float>(TextEditor::Property::SCROLL_THRESHOLD), 1.f, Math::MACHINE_EPSILON_1000, TEST_LOCATION);
705   editor.SetProperty(TextEditor::Property::SCROLL_SPEED, 100.f);
706   DALI_TEST_EQUALS(editor.GetProperty<float>(TextEditor::Property::SCROLL_SPEED), 100.f, Math::MACHINE_EPSILON_1000, TEST_LOCATION);
707
708   // Check cursor properties
709   editor.SetProperty(TextEditor::Property::PRIMARY_CURSOR_COLOR, Color::RED);
710   DALI_TEST_EQUALS(editor.GetProperty<Vector4>(TextEditor::Property::PRIMARY_CURSOR_COLOR), Color::RED, TEST_LOCATION);
711   editor.SetProperty(TextEditor::Property::SECONDARY_CURSOR_COLOR, Color::BLUE);
712   DALI_TEST_EQUALS(editor.GetProperty<Vector4>(TextEditor::Property::SECONDARY_CURSOR_COLOR), Color::BLUE, TEST_LOCATION);
713
714   editor.SetProperty(TextEditor::Property::ENABLE_CURSOR_BLINK, false);
715   DALI_TEST_EQUALS(editor.GetProperty<bool>(TextEditor::Property::ENABLE_CURSOR_BLINK), false, TEST_LOCATION);
716   editor.SetProperty(TextEditor::Property::CURSOR_BLINK_INTERVAL, 1.f);
717   DALI_TEST_EQUALS(editor.GetProperty<float>(TextEditor::Property::CURSOR_BLINK_INTERVAL), 1.f, Math::MACHINE_EPSILON_1000, TEST_LOCATION);
718   editor.SetProperty(TextEditor::Property::CURSOR_BLINK_DURATION, 10.f);
719   DALI_TEST_EQUALS(editor.GetProperty<float>(TextEditor::Property::CURSOR_BLINK_DURATION), 10.f, Math::MACHINE_EPSILON_1000, TEST_LOCATION);
720   editor.SetProperty(TextEditor::Property::CURSOR_WIDTH, 1);
721   DALI_TEST_EQUALS(editor.GetProperty<int>(TextEditor::Property::CURSOR_WIDTH), 1, TEST_LOCATION);
722
723   // Check handle images
724   editor.SetProperty(TextEditor::Property::GRAB_HANDLE_IMAGE, "image1");
725   DALI_TEST_EQUALS(editor.GetProperty<std::string>(TextEditor::Property::GRAB_HANDLE_IMAGE), "image1", TEST_LOCATION);
726   editor.SetProperty(TextEditor::Property::GRAB_HANDLE_PRESSED_IMAGE, "image2");
727   DALI_TEST_EQUALS(editor.GetProperty<std::string>(TextEditor::Property::GRAB_HANDLE_PRESSED_IMAGE), "image2", TEST_LOCATION);
728   editor.SetProperty(TextEditor::Property::SELECTION_HANDLE_IMAGE_LEFT, "image3");
729
730   // Check handle images
731   DALI_TEST_CHECK(SetPropertyMapRetrieved(editor, TextEditor::Property::SELECTION_HANDLE_IMAGE_LEFT, "filename", "leftHandleImage"));
732   DALI_TEST_CHECK(SetPropertyMapRetrieved(editor, TextEditor::Property::SELECTION_HANDLE_IMAGE_RIGHT, "filename", "rightHandleImage"));
733   DALI_TEST_CHECK(SetPropertyMapRetrieved(editor, TextEditor::Property::SELECTION_HANDLE_PRESSED_IMAGE_LEFT, "filename", "leftHandleImagePressed"));
734   DALI_TEST_CHECK(SetPropertyMapRetrieved(editor, TextEditor::Property::SELECTION_HANDLE_PRESSED_IMAGE_RIGHT, "filename", "rightHandleImagePressed"));
735   DALI_TEST_CHECK(SetPropertyMapRetrieved(editor, TextEditor::Property::SELECTION_HANDLE_MARKER_IMAGE_LEFT, "filename", "leftHandleMarkerImage"));
736   DALI_TEST_CHECK(SetPropertyMapRetrieved(editor, TextEditor::Property::SELECTION_HANDLE_MARKER_IMAGE_RIGHT, "filename", "rightHandleMarkerImage"));
737
738   // Check the highlight color
739   editor.SetProperty(TextEditor::Property::SELECTION_HIGHLIGHT_COLOR, Color::GREEN);
740   DALI_TEST_EQUALS(editor.GetProperty<Vector4>(TextEditor::Property::SELECTION_HIGHLIGHT_COLOR), Color::GREEN, TEST_LOCATION);
741
742   // Decoration bounding box
743   editor.SetProperty(TextEditor::Property::DECORATION_BOUNDING_BOX, Rect<int>(0, 0, 1, 1));
744   DALI_TEST_EQUALS(editor.GetProperty<Rect<int> >(TextEditor::Property::DECORATION_BOUNDING_BOX), Rect<int>(0, 0, 1, 1), TEST_LOCATION);
745
746   // Check the enable markup property.
747   DALI_TEST_CHECK(!editor.GetProperty<bool>(TextEditor::Property::ENABLE_MARKUP));
748   editor.SetProperty(TextEditor::Property::ENABLE_MARKUP, true);
749   DALI_TEST_CHECK(editor.GetProperty<bool>(TextEditor::Property::ENABLE_MARKUP));
750
751   // Check input color property.
752   editor.SetProperty(TextEditor::Property::INPUT_COLOR, Color::YELLOW);
753   DALI_TEST_EQUALS(editor.GetProperty<Vector4>(TextEditor::Property::INPUT_COLOR), Color::YELLOW, TEST_LOCATION);
754
755   // Check input font properties.
756   editor.SetProperty(TextEditor::Property::INPUT_FONT_FAMILY, "Setting input font family");
757   DALI_TEST_EQUALS(editor.GetProperty<std::string>(TextEditor::Property::INPUT_FONT_FAMILY), "Setting input font family", TEST_LOCATION);
758
759   fontStyleMapSet.Clear();
760   fontStyleMapSet.Insert("weight", "bold");
761   fontStyleMapSet.Insert("width", "condensed");
762   fontStyleMapSet.Insert("slant", "italic");
763
764   editor.SetProperty(TextEditor::Property::INPUT_FONT_STYLE, fontStyleMapSet);
765   fontStyleMapGet = editor.GetProperty<Property::Map>(TextEditor::Property::INPUT_FONT_STYLE);
766   DALI_TEST_EQUALS(fontStyleMapGet.Count(), fontStyleMapSet.Count(), TEST_LOCATION);
767   DALI_TEST_EQUALS(DaliTestCheckMaps(fontStyleMapGet, fontStyleMapSet), true, TEST_LOCATION);
768
769   editor.SetProperty(TextEditor::Property::INPUT_POINT_SIZE, 12.f);
770   DALI_TEST_EQUALS(editor.GetProperty<float>(TextEditor::Property::INPUT_POINT_SIZE), 12.f, Math::MACHINE_EPSILON_1000, TEST_LOCATION);
771
772   // Reset input font style.
773   fontStyleMapSet.Clear();
774   fontStyleMapSet.Insert("weight", "normal");
775   fontStyleMapSet.Insert("slant", "oblique");
776
777   editor.SetProperty(TextEditor::Property::INPUT_FONT_STYLE, fontStyleMapSet);
778   fontStyleMapGet = editor.GetProperty<Property::Map>(TextEditor::Property::INPUT_FONT_STYLE);
779   DALI_TEST_EQUALS(fontStyleMapGet.Count(), fontStyleMapSet.Count(), TEST_LOCATION);
780   DALI_TEST_EQUALS(DaliTestCheckMaps(fontStyleMapGet, fontStyleMapSet), true, TEST_LOCATION);
781
782   fontStyleMapSet.Clear();
783   fontStyleMapSet.Insert("slant", "roman");
784
785   editor.SetProperty(TextEditor::Property::INPUT_FONT_STYLE, fontStyleMapSet);
786   fontStyleMapGet = editor.GetProperty<Property::Map>(TextEditor::Property::INPUT_FONT_STYLE);
787
788   // Replace 'roman' for 'normal'.
789   slantValue = fontStyleMapGet.Find("slant");
790   if(NULL != slantValue)
791   {
792     if("normal" == slantValue->Get<std::string>())
793     {
794       fontStyleMapGet["slant"] = "roman";
795     }
796   }
797   DALI_TEST_EQUALS(fontStyleMapGet.Count(), fontStyleMapSet.Count(), TEST_LOCATION);
798   DALI_TEST_EQUALS(DaliTestCheckMaps(fontStyleMapGet, fontStyleMapSet), true, TEST_LOCATION);
799
800   fontStyleMapSet.Clear();
801
802   editor.SetProperty(TextEditor::Property::INPUT_FONT_STYLE, fontStyleMapSet);
803   fontStyleMapGet = editor.GetProperty<Property::Map>(TextEditor::Property::INPUT_FONT_STYLE);
804   DALI_TEST_EQUALS(fontStyleMapGet.Count(), fontStyleMapSet.Count(), TEST_LOCATION);
805   DALI_TEST_EQUALS(DaliTestCheckMaps(fontStyleMapGet, fontStyleMapSet), true, TEST_LOCATION);
806
807   // Check the line spacing property
808   DALI_TEST_EQUALS(editor.GetProperty<float>(TextEditor::Property::LINE_SPACING), 0.0f, Math::MACHINE_EPSILON_1000, TEST_LOCATION);
809   editor.SetProperty(TextEditor::Property::LINE_SPACING, 10.f);
810   DALI_TEST_EQUALS(editor.GetProperty<float>(TextEditor::Property::LINE_SPACING), 10.0f, Math::MACHINE_EPSILON_1000, TEST_LOCATION);
811
812   // Check the input line spacing property
813   DALI_TEST_EQUALS(editor.GetProperty<float>(TextEditor::Property::INPUT_LINE_SPACING), 0.0f, Math::MACHINE_EPSILON_1000, TEST_LOCATION);
814   editor.SetProperty(TextEditor::Property::INPUT_LINE_SPACING, 20.f);
815   DALI_TEST_EQUALS(editor.GetProperty<float>(TextEditor::Property::INPUT_LINE_SPACING), 20.0f, Math::MACHINE_EPSILON_1000, TEST_LOCATION);
816
817   // Check the underline property
818
819   Property::Map underlineMapSet;
820   Property::Map underlineMapGet;
821
822   underlineMapSet.Insert("enable", true);
823   underlineMapSet.Insert("color", Color::RED);
824   underlineMapSet.Insert("height", 1);
825   underlineMapSet.Insert("type", Text::Underline::SOLID);
826   underlineMapSet.Insert("dashWidth", 5);
827   underlineMapSet.Insert("dashGap", 3);
828
829   editor.SetProperty(TextEditor::Property::UNDERLINE, underlineMapSet);
830
831   underlineMapGet = editor.GetProperty<Property::Map>(TextEditor::Property::UNDERLINE);
832   DALI_TEST_EQUALS(underlineMapGet.Count(), underlineMapSet.Count(), TEST_LOCATION);
833   DALI_TEST_EQUALS(DaliTestCheckMaps(underlineMapGet, underlineMapSet), true, TEST_LOCATION);
834
835   application.SendNotification();
836   application.Render();
837
838   // Check the dashed underline property
839
840   underlineMapSet.Clear();
841   underlineMapGet.Clear();
842
843   underlineMapSet.Insert("enable", true);
844   underlineMapSet.Insert("color", Color::RED);
845   underlineMapSet.Insert("height", 1);
846   underlineMapSet.Insert("type", Text::Underline::DASHED);
847   underlineMapSet.Insert("dashWidth", 5);
848   underlineMapSet.Insert("dashGap", 3);
849
850   editor.SetProperty(TextEditor::Property::UNDERLINE, underlineMapSet);
851
852   underlineMapGet = editor.GetProperty<Property::Map>(TextEditor::Property::UNDERLINE);
853   DALI_TEST_EQUALS(underlineMapGet.Count(), underlineMapSet.Count(), TEST_LOCATION);
854   DALI_TEST_EQUALS(DaliTestCheckMaps(underlineMapGet, underlineMapSet), true, TEST_LOCATION);
855
856   application.SendNotification();
857   application.Render();
858
859   underlineMapSet.Clear();
860   underlineMapGet.Clear();
861
862   // Check the double underline property
863
864   underlineMapSet.Clear();
865   underlineMapGet.Clear();
866
867   underlineMapSet.Insert("enable", true);
868   underlineMapSet.Insert("color", Color::RED);
869   underlineMapSet.Insert("height", 1);
870   underlineMapSet.Insert("type", Text::Underline::DOUBLE);
871   underlineMapSet.Insert("dashWidth", 5);
872   underlineMapSet.Insert("dashGap", 3);
873
874   editor.SetProperty(TextEditor::Property::UNDERLINE, underlineMapSet);
875
876   underlineMapGet = editor.GetProperty<Property::Map>(TextEditor::Property::UNDERLINE);
877   DALI_TEST_EQUALS(underlineMapGet.Count(), underlineMapSet.Count(), TEST_LOCATION);
878   DALI_TEST_EQUALS(DaliTestCheckMaps(underlineMapGet, underlineMapSet), true, TEST_LOCATION);
879
880   application.SendNotification();
881   application.Render();
882
883   underlineMapSet.Clear();
884   underlineMapGet.Clear();
885
886   // Check the input underline property
887   editor.SetProperty(TextEditor::Property::INPUT_UNDERLINE, "Underline input properties");
888   DALI_TEST_EQUALS(editor.GetProperty<std::string>(TextEditor::Property::INPUT_UNDERLINE), std::string("Underline input properties"), TEST_LOCATION);
889
890   // Check the shadow property
891   Property::Map shadowMapSet;
892   Property::Map shadowMapGet;
893
894   shadowMapSet.Insert("color", Color::GREEN);
895   shadowMapSet.Insert("offset", Vector2(2.0f, 2.0f));
896   shadowMapSet.Insert("blurRadius", 3.0f);
897
898   editor.SetProperty(TextEditor::Property::SHADOW, shadowMapSet);
899
900   shadowMapGet = editor.GetProperty<Property::Map>(TextEditor::Property::SHADOW);
901   DALI_TEST_EQUALS(shadowMapGet.Count(), shadowMapSet.Count(), TEST_LOCATION);
902   DALI_TEST_EQUALS(DaliTestCheckMaps(shadowMapGet, shadowMapSet), true, TEST_LOCATION);
903
904   // Check the input shadow property
905   editor.SetProperty(TextEditor::Property::INPUT_SHADOW, "Shadow input properties");
906   DALI_TEST_EQUALS(editor.GetProperty<std::string>(TextEditor::Property::INPUT_SHADOW), std::string("Shadow input properties"), TEST_LOCATION);
907
908   // Check the emboss property
909   editor.SetProperty(TextEditor::Property::EMBOSS, "Emboss properties");
910   DALI_TEST_EQUALS(editor.GetProperty<std::string>(TextEditor::Property::EMBOSS), std::string("Emboss properties"), TEST_LOCATION);
911
912   // Check the input emboss property
913   editor.SetProperty(TextEditor::Property::INPUT_EMBOSS, "Emboss input properties");
914   DALI_TEST_EQUALS(editor.GetProperty<std::string>(TextEditor::Property::INPUT_EMBOSS), std::string("Emboss input properties"), TEST_LOCATION);
915
916   // Check the outline property
917
918   // Test string type first
919   // This is purely to maintain backward compatibility, but we don't support string as the outline property type.
920   editor.SetProperty(TextEditor::Property::OUTLINE, "Outline properties");
921   DALI_TEST_EQUALS(editor.GetProperty<std::string>(TextEditor::Property::OUTLINE), std::string("Outline properties"), TEST_LOCATION);
922
923   // Then test the property map type
924   Property::Map outlineMapSet;
925   Property::Map outlineMapGet;
926
927   outlineMapSet["color"] = Color::RED;
928   outlineMapSet["width"] = 2.0f;
929
930   editor.SetProperty(TextEditor::Property::OUTLINE, outlineMapSet);
931
932   outlineMapGet = editor.GetProperty<Property::Map>(TextEditor::Property::OUTLINE);
933   DALI_TEST_EQUALS(outlineMapGet.Count(), outlineMapSet.Count(), TEST_LOCATION);
934   DALI_TEST_EQUALS(DaliTestCheckMaps(outlineMapGet, outlineMapSet), true, TEST_LOCATION);
935
936   // Check the input outline property
937   editor.SetProperty(TextEditor::Property::INPUT_OUTLINE, "Outline input properties");
938   DALI_TEST_EQUALS(editor.GetProperty<std::string>(TextEditor::Property::INPUT_OUTLINE), std::string("Outline input properties"), TEST_LOCATION);
939
940   // Check the smooth scroll property
941   DALI_TEST_EQUALS(editor.GetProperty<bool>(TextEditor::Property::SMOOTH_SCROLL), false, TEST_LOCATION);
942   editor.SetProperty(TextEditor::Property::SMOOTH_SCROLL, true);
943   DALI_TEST_EQUALS(editor.GetProperty<bool>(TextEditor::Property::SMOOTH_SCROLL), true, TEST_LOCATION);
944
945   // Check the smooth scroll duration property
946   editor.SetProperty(TextEditor::Property::SMOOTH_SCROLL_DURATION, 0.2f);
947   DALI_TEST_EQUALS(editor.GetProperty<float>(TextEditor::Property::SMOOTH_SCROLL_DURATION), 0.2f, Math::MACHINE_EPSILON_1000, TEST_LOCATION);
948
949   // Check the scroll bar property
950   DALI_TEST_EQUALS(editor.GetProperty<bool>(TextEditor::Property::ENABLE_SCROLL_BAR), false, TEST_LOCATION);
951   editor.SetProperty(TextEditor::Property::ENABLE_SCROLL_BAR, true);
952   DALI_TEST_EQUALS(editor.GetProperty<bool>(TextEditor::Property::ENABLE_SCROLL_BAR), true, TEST_LOCATION);
953
954   editor.SetProperty(TextEditor::Property::SCROLL_BAR_SHOW_DURATION, 0.3f);
955   DALI_TEST_EQUALS(editor.GetProperty<float>(TextEditor::Property::SCROLL_BAR_SHOW_DURATION), 0.3f, Math::MACHINE_EPSILON_1000, TEST_LOCATION);
956   editor.SetProperty(TextEditor::Property::SCROLL_BAR_FADE_DURATION, 0.2f);
957   DALI_TEST_EQUALS(editor.GetProperty<float>(TextEditor::Property::SCROLL_BAR_FADE_DURATION), 0.2f, Math::MACHINE_EPSILON_1000, TEST_LOCATION);
958
959   // Check the pixel size of font
960   editor.SetProperty(TextEditor::Property::PIXEL_SIZE, 20.f);
961   DALI_TEST_EQUALS(editor.GetProperty<float>(TextEditor::Property::PIXEL_SIZE), 20.f, Math::MACHINE_EPSILON_1000, TEST_LOCATION);
962
963   // Check placeholder text properties.
964   editor.SetProperty(DevelTextEditor::Property::PLACEHOLDER_TEXT, "Setting Placeholder Text");
965   DALI_TEST_EQUALS(editor.GetProperty<std::string>(DevelTextEditor::Property::PLACEHOLDER_TEXT), std::string("Setting Placeholder Text"), TEST_LOCATION);
966
967   // Check placeholder text's color property.
968   editor.SetProperty(DevelTextEditor::Property::PLACEHOLDER_TEXT_COLOR, Color::RED);
969   DALI_TEST_EQUALS(editor.GetProperty<Vector4>(DevelTextEditor::Property::PLACEHOLDER_TEXT_COLOR), Color::RED, TEST_LOCATION);
970
971   // Check the enable selection property
972   editor.SetProperty(TextEditor::Property::ENABLE_SELECTION, false);
973   DALI_TEST_EQUALS(editor.GetProperty<bool>(TextEditor::Property::ENABLE_SELECTION), false, TEST_LOCATION);
974
975   // Check the placeholder property with pixel size
976   Property::Map placeholderPixelSizeMapSet;
977   Property::Map placeholderPixelSizeMapGet;
978   Property::Map placeholderFontstyleMap;
979   placeholderPixelSizeMapSet["text"]        = "Setting Placeholder Text";
980   placeholderPixelSizeMapSet["textFocused"] = "Setting Placeholder Text Focused";
981   placeholderPixelSizeMapSet["color"]       = Color::BLUE;
982   placeholderPixelSizeMapSet["fontFamily"]  = "Arial";
983   placeholderPixelSizeMapSet["pixelSize"]   = 15.0f;
984
985   placeholderFontstyleMap.Insert("weight", "bold");
986   placeholderPixelSizeMapSet["fontStyle"] = placeholderFontstyleMap;
987   editor.SetProperty(TextEditor::Property::PLACEHOLDER, placeholderPixelSizeMapSet);
988
989   placeholderPixelSizeMapGet = editor.GetProperty<Property::Map>(TextEditor::Property::PLACEHOLDER);
990   DALI_TEST_EQUALS(placeholderPixelSizeMapGet.Count(), placeholderPixelSizeMapSet.Count(), TEST_LOCATION);
991
992   tet_infoline("Test Placeholder settings set as strings is converted correctly to Property Index key and holds set value");
993   Property::Map placeholderConversionMap;
994   placeholderConversionMap[Text::PlaceHolder::Property::TEXT]         = placeholderPixelSizeMapSet["text"];
995   placeholderConversionMap[Text::PlaceHolder::Property::TEXT_FOCUSED] = placeholderPixelSizeMapSet["textFocused"];
996   placeholderConversionMap[Text::PlaceHolder::Property::COLOR]        = placeholderPixelSizeMapSet["color"];
997   placeholderConversionMap[Text::PlaceHolder::Property::FONT_STYLE]   = placeholderPixelSizeMapSet["fontStyle"];
998   placeholderConversionMap[Text::PlaceHolder::Property::FONT_FAMILY]  = placeholderPixelSizeMapSet["fontFamily"];
999   placeholderConversionMap[Text::PlaceHolder::Property::PIXEL_SIZE]   = placeholderPixelSizeMapSet["pixelSize"];
1000
1001   DALI_TEST_EQUALS(DaliTestCheckMaps(placeholderPixelSizeMapGet, placeholderConversionMap), true, TEST_LOCATION);
1002
1003   // Check the placeholder property with point size
1004   Property::Map placeholderMapSet;
1005   Property::Map placeholderMapGet;
1006   placeholderMapSet["text"]        = "Setting Placeholder Text";
1007   placeholderMapSet["textFocused"] = "Setting Placeholder Text Focused";
1008   placeholderMapSet["color"]       = Color::RED;
1009   placeholderMapSet["fontFamily"]  = "Arial";
1010   placeholderMapSet["pointSize"]   = 12.0f;
1011   // Check the placeholder font style property
1012   placeholderFontstyleMap.Clear();
1013
1014   placeholderFontstyleMap.Insert("weight", "bold");
1015   placeholderFontstyleMap.Insert("width", "condensed");
1016   placeholderFontstyleMap.Insert("slant", "italic");
1017   placeholderMapSet["fontStyle"] = placeholderFontstyleMap;
1018   editor.SetProperty(TextEditor::Property::PLACEHOLDER, placeholderMapSet);
1019
1020   placeholderMapGet = editor.GetProperty<Property::Map>(TextEditor::Property::PLACEHOLDER);
1021   DALI_TEST_EQUALS(placeholderMapGet.Count(), placeholderMapSet.Count(), TEST_LOCATION);
1022
1023   tet_infoline("Test Placeholder settings set as strings is converted correctly to Property Index key and holds set value");
1024   placeholderConversionMap.Clear();
1025   placeholderConversionMap[Text::PlaceHolder::Property::TEXT]         = placeholderMapSet["text"];
1026   placeholderConversionMap[Text::PlaceHolder::Property::TEXT_FOCUSED] = placeholderMapSet["textFocused"];
1027   placeholderConversionMap[Text::PlaceHolder::Property::COLOR]        = placeholderMapSet["color"];
1028   placeholderConversionMap[Text::PlaceHolder::Property::FONT_STYLE]   = placeholderPixelSizeMapSet["fontStyle"];
1029   placeholderConversionMap[Text::PlaceHolder::Property::FONT_FAMILY]  = placeholderMapSet["fontFamily"];
1030   placeholderConversionMap[Text::PlaceHolder::Property::POINT_SIZE]   = placeholderMapSet["pointSize"];
1031   DALI_TEST_EQUALS(DaliTestCheckMaps(placeholderMapGet, placeholderConversionMap), true, TEST_LOCATION);
1032
1033   // Reset font style.
1034   placeholderFontstyleMap.Clear();
1035   placeholderFontstyleMap.Insert("weight", "normal");
1036   placeholderFontstyleMap.Insert("slant", "oblique");
1037   placeholderMapSet["fontStyle"] = placeholderFontstyleMap;
1038   editor.SetProperty(TextEditor::Property::PLACEHOLDER, placeholderMapSet);
1039
1040   placeholderMapGet = editor.GetProperty<Property::Map>(TextEditor::Property::PLACEHOLDER);
1041   DALI_TEST_EQUALS(placeholderMapGet.Count(), placeholderMapSet.Count(), TEST_LOCATION);
1042   placeholderConversionMap[Text::PlaceHolder::Property::FONT_STYLE] = placeholderMapSet["fontStyle"];
1043   DALI_TEST_EQUALS(DaliTestCheckMaps(placeholderMapGet, placeholderConversionMap), true, TEST_LOCATION);
1044
1045   placeholderFontstyleMap.Clear();
1046   placeholderFontstyleMap.Insert("slant", "roman");
1047   placeholderMapSet["fontStyle"] = placeholderFontstyleMap;
1048   editor.SetProperty(TextEditor::Property::PLACEHOLDER, placeholderMapSet);
1049
1050   placeholderMapGet = editor.GetProperty<Property::Map>(TextEditor::Property::PLACEHOLDER);
1051
1052   placeholderFontstyleMap.Clear();
1053   placeholderMapSet["fontStyle"] = placeholderFontstyleMap;
1054
1055   editor.SetProperty(TextEditor::Property::PLACEHOLDER, placeholderMapSet);
1056   placeholderMapGet = editor.GetProperty<Property::Map>(TextEditor::Property::PLACEHOLDER);
1057   DALI_TEST_EQUALS(placeholderMapGet.Count(), placeholderMapSet.Count(), TEST_LOCATION);
1058   placeholderConversionMap[Text::PlaceHolder::Property::FONT_STYLE] = placeholderMapSet["fontStyle"];
1059   DALI_TEST_EQUALS(DaliTestCheckMaps(placeholderMapGet, placeholderConversionMap), true, TEST_LOCATION);
1060
1061   editor.SetProperty(Actor::Property::LAYOUT_DIRECTION, LayoutDirection::RIGHT_TO_LEFT);
1062   DALI_TEST_EQUALS(editor.GetProperty<int>(Actor::Property::LAYOUT_DIRECTION), static_cast<int>(LayoutDirection::RIGHT_TO_LEFT), TEST_LOCATION);
1063
1064   // Check handle color
1065   editor.SetProperty(DevelTextEditor::Property::GRAB_HANDLE_COLOR, Color::GREEN);
1066   DALI_TEST_EQUALS(editor.GetProperty<Vector4>(DevelTextEditor::Property::GRAB_HANDLE_COLOR), Color::GREEN, TEST_LOCATION);
1067
1068   // Test the ENABLE_GRAB_HANDLE_POPUP property
1069   editor.SetProperty(DevelTextEditor::Property::ENABLE_GRAB_HANDLE_POPUP, false);
1070   DALI_TEST_EQUALS(editor.GetProperty<bool>(DevelTextEditor::Property::ENABLE_GRAB_HANDLE_POPUP), false, TEST_LOCATION);
1071
1072   // Check the input method setting
1073   Property::Map                   propertyMap;
1074   InputMethod::PanelLayout::Type  panelLayout    = InputMethod::PanelLayout::NUMBER;
1075   InputMethod::AutoCapital::Type  autoCapital    = InputMethod::AutoCapital::WORD;
1076   InputMethod::ButtonAction::Type buttonAction   = InputMethod::ButtonAction::GO;
1077   int                             inputVariation = 1;
1078   propertyMap["PANEL_LAYOUT"]                    = panelLayout;
1079   propertyMap["AUTO_CAPITALIZE"]                 = autoCapital;
1080   propertyMap["BUTTON_ACTION"]                   = buttonAction;
1081   propertyMap["VARIATION"]                       = inputVariation;
1082   editor.SetProperty(DevelTextEditor::Property::INPUT_METHOD_SETTINGS, propertyMap);
1083
1084   Property::Value value = editor.GetProperty(DevelTextEditor::Property::INPUT_METHOD_SETTINGS);
1085   Property::Map   map;
1086   DALI_TEST_CHECK(value.Get(map));
1087
1088   int layout = 0;
1089   DALI_TEST_CHECK(map["PANEL_LAYOUT"].Get(layout));
1090   DALI_TEST_EQUALS(static_cast<int>(panelLayout), layout, TEST_LOCATION);
1091
1092   int capital = 0;
1093   DALI_TEST_CHECK(map["AUTO_CAPITALIZE"].Get(capital));
1094   DALI_TEST_EQUALS(static_cast<int>(autoCapital), capital, TEST_LOCATION);
1095
1096   int action = 0;
1097   DALI_TEST_CHECK(map["BUTTON_ACTION"].Get(action));
1098   DALI_TEST_EQUALS(static_cast<int>(buttonAction), action, TEST_LOCATION);
1099
1100   int variation = 0;
1101   DALI_TEST_CHECK(map["VARIATION"].Get(variation));
1102   DALI_TEST_EQUALS(inputVariation, variation, TEST_LOCATION);
1103
1104   // Check the input filter property
1105   Property::Map inputFilterMapSet;
1106   Property::Map inputFilterMapGet;
1107   inputFilterMapSet[InputFilter::Property::ACCEPTED] = "[\\w]";
1108   inputFilterMapSet[InputFilter::Property::REJECTED] = "[\\d]";
1109
1110   editor.SetProperty(DevelTextEditor::Property::INPUT_FILTER, inputFilterMapSet);
1111
1112   inputFilterMapGet = editor.GetProperty<Property::Map>(DevelTextEditor::Property::INPUT_FILTER);
1113   DALI_TEST_EQUALS(inputFilterMapGet.Count(), inputFilterMapSet.Count(), TEST_LOCATION);
1114
1115   // Clear
1116   inputFilterMapSet.Clear();
1117   editor.SetProperty(DevelTextEditor::Property::INPUT_FILTER, inputFilterMapSet);
1118
1119   // Check the strikethrough property
1120
1121   Property::Map strikethroughMapSet;
1122   Property::Map strikethroughMapGet;
1123
1124   application.SendNotification();
1125   application.Render();
1126
1127   // Check the input strikethrough property
1128
1129   strikethroughMapSet.Clear();
1130   strikethroughMapGet.Clear();
1131   strikethroughMapSet.Insert("enable", true);
1132   strikethroughMapSet.Insert("color", Color::BLUE);
1133   strikethroughMapSet.Insert("height", 2.0f);
1134
1135   editor.SetProperty(DevelTextEditor::Property::STRIKETHROUGH, strikethroughMapSet);
1136
1137   application.SendNotification();
1138   application.Render();
1139
1140   strikethroughMapGet = editor.GetProperty<Property::Map>(DevelTextEditor::Property::STRIKETHROUGH);
1141
1142   DALI_TEST_EQUALS(strikethroughMapGet.Count(), strikethroughMapSet.Count(), TEST_LOCATION);
1143   DALI_TEST_EQUALS(DaliTestCheckMaps(strikethroughMapSet, strikethroughMapGet), true, TEST_LOCATION);
1144
1145   // Check the input strikethrough property
1146   editor.SetProperty(DevelTextEditor::Property::INPUT_STRIKETHROUGH, "Strikethrough input properties");
1147   DALI_TEST_EQUALS(editor.GetProperty<std::string>(DevelTextEditor::Property::INPUT_STRIKETHROUGH), std::string("Strikethrough input properties"), TEST_LOCATION);
1148
1149   application.SendNotification();
1150   application.Render();
1151
1152   // Check the line size property
1153   DALI_TEST_EQUALS(editor.GetProperty<float>(DevelTextEditor::Property::MIN_LINE_SIZE), 0.0f, Math::MACHINE_EPSILON_1000, TEST_LOCATION);
1154   editor.SetProperty(DevelTextEditor::Property::MIN_LINE_SIZE, 50.f);
1155   DALI_TEST_EQUALS(editor.GetProperty<float>(DevelTextEditor::Property::MIN_LINE_SIZE), 50.0f, Math::MACHINE_EPSILON_1000, TEST_LOCATION);
1156
1157   END_TEST;
1158 }
1159
1160 // Positive Atlas Text Renderer test
1161 int utcDaliTextEditorAtlasRenderP(void)
1162 {
1163   ToolkitTestApplication application;
1164   tet_infoline(" UtcDaliToolkitTextEditorAtlasRenderP");
1165   StyleManager styleManager = StyleManager::Get();
1166   styleManager.ApplyDefaultTheme();
1167   TextEditor editor = TextEditor::New();
1168   DALI_TEST_CHECK(editor);
1169
1170   editor.SetProperty(TextEditor::Property::HORIZONTAL_ALIGNMENT, "CENTER");
1171
1172   application.GetGlAbstraction().SetCheckFramebufferStatusResult(GL_FRAMEBUFFER_COMPLETE);
1173
1174   application.GetScene().Add(editor);
1175
1176   try
1177   {
1178     // Render some text with the shared atlas backend
1179     editor.SetProperty(DevelTextEditor::Property::RENDERING_BACKEND, DevelText::RENDERING_SHARED_ATLAS);
1180     application.SendNotification();
1181     application.Render();
1182   }
1183   catch(...)
1184   {
1185     tet_result(TET_FAIL);
1186   }
1187   END_TEST;
1188 }
1189
1190 // Positive test for the anchorClicked signal.
1191 int utcDaliTextEditorAnchorClickedP(void)
1192 {
1193   ToolkitTestApplication application;
1194   tet_infoline(" utcDaliTextEditorAnchorClickedP");
1195   TextEditor editor = TextEditor::New();
1196   DALI_TEST_CHECK(editor);
1197
1198   application.GetScene().Add(editor);
1199
1200   // connect to the anchor clicked signal.
1201   ConnectionTracker* testTracker = new ConnectionTracker();
1202   DevelTextEditor::AnchorClickedSignal(editor).Connect(&TestAnchorClickedCallback);
1203   bool anchorClickedSignal = false;
1204   editor.ConnectSignal(testTracker, "anchorClicked", CallbackFunctor(&anchorClickedSignal));
1205
1206   gAnchorClickedCallBackCalled = false;
1207   editor.SetProperty(TextEditor::Property::TEXT, "<a href='https://www.tizen.org'>TIZEN</a>");
1208   editor.SetProperty(TextEditor::Property::ENABLE_MARKUP, true);
1209   editor.SetProperty(Actor::Property::SIZE, Vector2(100.f, 50.f));
1210   editor.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT);
1211   editor.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
1212
1213   application.SendNotification();
1214   application.Render();
1215   editor.SetKeyInputFocus();
1216
1217   // Create a tap event to touch the text editor.
1218   TestGenerateTap(application, 5.0f, 5.0f);
1219   application.SendNotification();
1220   application.Render();
1221
1222   DALI_TEST_CHECK(gAnchorClickedCallBackCalled);
1223   DALI_TEST_CHECK(anchorClickedSignal);
1224
1225   gAnchorClickedCallBackNotCalled = true;
1226   // Tap the outside of anchor, callback should not be called.
1227   TestGenerateTap(application, 150.f, 100.f);
1228   application.SendNotification();
1229   application.Render();
1230
1231   DALI_TEST_CHECK(gAnchorClickedCallBackNotCalled);
1232
1233   END_TEST;
1234 }
1235
1236 // Positive test for the textChanged signal.
1237 int utcDaliTextEditorTextChangedP(void)
1238 {
1239   ToolkitTestApplication application;
1240   tet_infoline(" utcDaliTextEditorTextChangedP");
1241   TextEditor editor = TextEditor::New();
1242   DALI_TEST_CHECK(editor);
1243
1244   application.GetScene().Add(editor);
1245
1246   // connect to the text changed signal.
1247   ConnectionTracker* testTracker = new ConnectionTracker();
1248   editor.TextChangedSignal().Connect(&TestTextChangedCallback);
1249   bool textChangedSignal = false;
1250   editor.ConnectSignal(testTracker, "textChanged", CallbackFunctor(&textChangedSignal));
1251
1252   gTextChangedCallBackCalled = false;
1253   editor.SetProperty(TextEditor::Property::TEXT, "ABC");
1254   DALI_TEST_CHECK(gTextChangedCallBackCalled);
1255   DALI_TEST_CHECK(textChangedSignal);
1256
1257   application.SendNotification();
1258   editor.SetKeyInputFocus();
1259
1260   gTextChangedCallBackCalled = false;
1261   application.ProcessEvent(GenerateKey("D", "", "D", KEY_D_CODE, 0, 0, Integration::KeyEvent::DOWN, "D", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
1262   DALI_TEST_CHECK(gTextChangedCallBackCalled);
1263
1264   // Remove all text
1265   editor.SetProperty(TextField::Property::TEXT, "");
1266
1267   // Pressing backspace key: TextChangedCallback should not be called when there is no text in texteditor.
1268   gTextChangedCallBackCalled = false;
1269   application.ProcessEvent(GenerateKey("", "", "", DALI_KEY_BACKSPACE, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
1270   DALI_TEST_CHECK(!gTextChangedCallBackCalled);
1271
1272   // Pressing delete key: TextChangedCallback should not be called when there is no text in texteditor.
1273   gTextChangedCallBackCalled = false;
1274   application.ProcessEvent(GenerateKey("", "", "", Dali::DevelKey::DALI_KEY_DELETE, 0, 0, Integration::KeyEvent::DOWN, "Delete", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
1275   DALI_TEST_CHECK(!gTextChangedCallBackCalled);
1276
1277   END_TEST;
1278 }
1279
1280 int utcDaliTextEditorTextChangedWithInputMethodContext(void)
1281 {
1282   ToolkitTestApplication application;
1283   tet_infoline(" utcDaliTextEditorTextChangedWithInputMethodContext");
1284   TextEditor editor = TextEditor::New();
1285   DALI_TEST_CHECK(editor);
1286
1287   application.GetScene().Add(editor);
1288
1289   // connect to the text changed signal.
1290   ConnectionTracker* testTracker = new ConnectionTracker();
1291   editor.TextChangedSignal().Connect(&TestTextChangedCallback);
1292   bool textChangedSignal = false;
1293   editor.ConnectSignal(testTracker, "textChanged", CallbackFunctor(&textChangedSignal));
1294
1295   // get InputMethodContext
1296   std::string                   text;
1297   InputMethodContext::EventData imfEvent;
1298   InputMethodContext            inputMethodContext = DevelTextEditor::GetInputMethodContext(editor);
1299
1300   editor.SetKeyInputFocus();
1301   editor.SetProperty(DevelTextEditor::Property::ENABLE_EDITING, true);
1302
1303   // input text
1304   gTextChangedCallBackCalled = false;
1305   imfEvent                   = InputMethodContext::EventData(InputMethodContext::PRE_EDIT, "ㅎ", 0, 1);
1306   inputMethodContext.EventReceivedSignal().Emit(inputMethodContext, imfEvent);
1307   application.SendNotification();
1308   application.Render();
1309   DALI_TEST_CHECK(gTextChangedCallBackCalled);
1310   DALI_TEST_EQUALS(editor.GetProperty<std::string>(TextEditor::Property::TEXT), std::string("ㅎ"), TEST_LOCATION);
1311
1312   gTextChangedCallBackCalled = false;
1313   imfEvent                   = InputMethodContext::EventData(InputMethodContext::PRE_EDIT, "호", 0, 1);
1314   inputMethodContext.EventReceivedSignal().Emit(inputMethodContext, imfEvent);
1315   application.SendNotification();
1316   application.Render();
1317   DALI_TEST_CHECK(gTextChangedCallBackCalled);
1318   DALI_TEST_EQUALS(editor.GetProperty<std::string>(TextEditor::Property::TEXT), std::string("호"), TEST_LOCATION);
1319
1320   gTextChangedCallBackCalled = false;
1321   imfEvent                   = InputMethodContext::EventData(InputMethodContext::PRE_EDIT, "혿", 0, 1);
1322   inputMethodContext.EventReceivedSignal().Emit(inputMethodContext, imfEvent);
1323   application.SendNotification();
1324   application.Render();
1325   DALI_TEST_CHECK(gTextChangedCallBackCalled);
1326   DALI_TEST_EQUALS(editor.GetProperty<std::string>(TextEditor::Property::TEXT), std::string("혿"), TEST_LOCATION);
1327
1328   gTextChangedCallBackCalled = false;
1329   imfEvent                   = InputMethodContext::EventData(InputMethodContext::PRE_EDIT, "", 0, 1);
1330   inputMethodContext.EventReceivedSignal().Emit(inputMethodContext, imfEvent);
1331   DALI_TEST_CHECK(!gTextChangedCallBackCalled);
1332
1333   imfEvent = InputMethodContext::EventData(InputMethodContext::COMMIT, "호", 0, 1);
1334   inputMethodContext.EventReceivedSignal().Emit(inputMethodContext, imfEvent);
1335   DALI_TEST_CHECK(!gTextChangedCallBackCalled);
1336
1337   imfEvent = InputMethodContext::EventData(InputMethodContext::PRE_EDIT, "두", 1, 2);
1338   inputMethodContext.EventReceivedSignal().Emit(inputMethodContext, imfEvent);
1339   DALI_TEST_CHECK(!gTextChangedCallBackCalled);
1340
1341   application.SendNotification();
1342   application.Render();
1343   DALI_TEST_CHECK(gTextChangedCallBackCalled);
1344   DALI_TEST_EQUALS(editor.GetProperty<std::string>(TextEditor::Property::TEXT), std::string("호두"), TEST_LOCATION);
1345
1346   END_TEST;
1347 }
1348
1349 int utcDaliTextEditorInputStyleChanged01(void)
1350 {
1351   // The text-editor emits signals when the input style changes. These changes of style are
1352   // detected during the relayout process (size negotiation), i.e after the cursor has been moved. Signals
1353   // can't be emitted during the size negotiation as the callbacks may update the UI.
1354   // The text-editor adds an idle callback to the adaptor to emit the signals after the size negotiation.
1355   // The ToolkitTestApplication creates an implementation of the adaptor stub and a queue of idle callbacks.
1356   ToolkitTestApplication application;
1357   tet_infoline(" utcDaliTextEditorInputStyleChanged01");
1358
1359   // Load some fonts.
1360
1361   char*             pathNamePtr = get_current_dir_name();
1362   const std::string pathName(pathNamePtr);
1363   free(pathNamePtr);
1364
1365   TextAbstraction::FontClient fontClient = TextAbstraction::FontClient::Get();
1366   fontClient.SetDpi(93u, 93u);
1367
1368   fontClient.GetFontId(pathName + DEFAULT_FONT_DIR + "/dejavu/DejaVuSerif.ttf", DEFAULT_FONT_SIZE);
1369   fontClient.GetFontId(pathName + DEFAULT_FONT_DIR + "/dejavu/DejaVuSerif-Bold.ttf", DEFAULT_FONT_SIZE);
1370
1371   TextEditor editor = TextEditor::New();
1372   DALI_TEST_CHECK(editor);
1373
1374   editor.SetProperty(Actor::Property::SIZE, Vector2(300.f, 50.f));
1375   editor.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT);
1376   editor.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
1377
1378   editor.SetProperty(TextEditor::Property::ENABLE_MARKUP, true);
1379   editor.SetProperty(TextEditor::Property::TEXT, "<font family='DejaVuSerif' size='18'>He<color value='green'>llo</color> <font weight='bold'>world</font> demo</font>");
1380
1381   // connect to the text changed signal.
1382   ConnectionTracker* testTracker = new ConnectionTracker();
1383   editor.InputStyleChangedSignal().Connect(&TestInputStyleChangedCallback);
1384   bool inputStyleChangedSignal = false;
1385   editor.ConnectSignal(testTracker, "inputStyleChanged", CallbackFunctor(&inputStyleChangedSignal));
1386
1387   application.GetScene().Add(editor);
1388
1389   // Render and notify
1390   application.SendNotification();
1391   application.Render();
1392
1393   // Executes the idle callbacks added by the text control on the change of input style.
1394   application.RunIdles();
1395
1396   gInputStyleChangedCallbackCalled = false;
1397   gInputStyleMask                  = TextEditor::InputStyle::NONE;
1398   inputStyleChangedSignal          = false;
1399
1400   // Create a tap event to touch the text editor.
1401   TestGenerateTap(application, 18.0f, 25.0f);
1402
1403   // Render and notify
1404   application.SendNotification();
1405   application.Render();
1406
1407   // Executes the idle callbacks added by the text control on the change of input style.
1408   application.RunIdles();
1409
1410   DALI_TEST_CHECK(gInputStyleChangedCallbackCalled);
1411   if(gInputStyleChangedCallbackCalled)
1412   {
1413     DALI_TEST_EQUALS(static_cast<unsigned int>(gInputStyleMask), static_cast<unsigned int>(TextEditor::InputStyle::FONT_FAMILY | TextEditor::InputStyle::POINT_SIZE), TEST_LOCATION);
1414
1415     const std::string fontFamily = editor.GetProperty(TextEditor::Property::INPUT_FONT_FAMILY).Get<std::string>();
1416     DALI_TEST_EQUALS(fontFamily, "DejaVuSerif", TEST_LOCATION);
1417
1418     const float pointSize = editor.GetProperty(TextEditor::Property::INPUT_POINT_SIZE).Get<float>();
1419     DALI_TEST_EQUALS(pointSize, 18.f, Math::MACHINE_EPSILON_1000, TEST_LOCATION);
1420   }
1421   DALI_TEST_CHECK(inputStyleChangedSignal);
1422
1423   gInputStyleChangedCallbackCalled = false;
1424   gInputStyleMask                  = TextEditor::InputStyle::NONE;
1425   inputStyleChangedSignal          = false;
1426
1427   // Create a tap event to touch the text editor.
1428   TestGenerateTap(application, 30.0f, 25.0f);
1429
1430   // Render and notify
1431   application.SendNotification();
1432   application.Render();
1433
1434   // Executes the idle callbacks added by the text control on the change of input style.
1435   application.RunIdles();
1436
1437   DALI_TEST_CHECK(!gInputStyleChangedCallbackCalled);
1438   DALI_TEST_CHECK(!inputStyleChangedSignal);
1439
1440   gInputStyleChangedCallbackCalled = false;
1441   gInputStyleMask                  = TextEditor::InputStyle::NONE;
1442   inputStyleChangedSignal          = false;
1443
1444   // Create a tap event to touch the text editor.
1445   TestGenerateTap(application, 43.0f, 25.0f);
1446
1447   // Render and notify
1448   application.SendNotification();
1449   application.Render();
1450
1451   // Executes the idle callbacks added by the text control on the change of input style.
1452   application.RunIdles();
1453
1454   DALI_TEST_CHECK(gInputStyleChangedCallbackCalled);
1455   if(gInputStyleChangedCallbackCalled)
1456   {
1457     DALI_TEST_EQUALS(static_cast<unsigned int>(gInputStyleMask), static_cast<unsigned int>(TextEditor::InputStyle::COLOR), TEST_LOCATION);
1458
1459     const Vector4 color = editor.GetProperty(TextEditor::Property::INPUT_COLOR).Get<Vector4>();
1460     DALI_TEST_EQUALS(color, Color::GREEN, TEST_LOCATION);
1461   }
1462   DALI_TEST_CHECK(inputStyleChangedSignal);
1463
1464   gInputStyleChangedCallbackCalled = false;
1465   gInputStyleMask                  = TextEditor::InputStyle::NONE;
1466   inputStyleChangedSignal          = false;
1467
1468   // Create a tap event to touch the text editor.
1469   TestGenerateTap(application, 88.0f, 25.0f);
1470
1471   // Render and notify
1472   application.SendNotification();
1473   application.Render();
1474
1475   // Executes the idle callbacks added by the text control on the change of input style.
1476   application.RunIdles();
1477
1478   DALI_TEST_CHECK(gInputStyleChangedCallbackCalled);
1479   if(gInputStyleChangedCallbackCalled)
1480   {
1481     DALI_TEST_EQUALS(static_cast<unsigned int>(gInputStyleMask), static_cast<unsigned int>(TextEditor::InputStyle::COLOR | TextEditor::InputStyle::FONT_STYLE), TEST_LOCATION);
1482
1483     const Vector4 color = editor.GetProperty(TextEditor::Property::INPUT_COLOR).Get<Vector4>();
1484     DALI_TEST_EQUALS(color, Color::BLACK, TEST_LOCATION);
1485
1486     Property::Map fontStyleMapSet;
1487     Property::Map fontStyleMapGet;
1488
1489     fontStyleMapSet.Insert("weight", "bold");
1490
1491     fontStyleMapGet = editor.GetProperty<Property::Map>(TextEditor::Property::INPUT_FONT_STYLE);
1492     DALI_TEST_EQUALS(fontStyleMapGet.Count(), fontStyleMapSet.Count(), TEST_LOCATION);
1493     DALI_TEST_EQUALS(DaliTestCheckMaps(fontStyleMapGet, fontStyleMapSet), true, TEST_LOCATION);
1494   }
1495   DALI_TEST_CHECK(inputStyleChangedSignal);
1496
1497   gInputStyleChangedCallbackCalled = false;
1498   gInputStyleMask                  = TextEditor::InputStyle::NONE;
1499   inputStyleChangedSignal          = false;
1500
1501   // Create a tap event to touch the text editor.
1502   TestGenerateTap(application, 115.0f, 25.0f);
1503
1504   // Render and notify
1505   application.SendNotification();
1506   application.Render();
1507
1508   // Executes the idle callbacks added by the text control on the change of input style.
1509   application.RunIdles();
1510
1511   DALI_TEST_CHECK(!gInputStyleChangedCallbackCalled);
1512   DALI_TEST_CHECK(!inputStyleChangedSignal);
1513
1514   gInputStyleChangedCallbackCalled = false;
1515   gInputStyleMask                  = TextEditor::InputStyle::NONE;
1516   inputStyleChangedSignal          = false;
1517
1518   // Create a tap event to touch the text editor.
1519   TestGenerateTap(application, 164.0f, 25.0f);
1520
1521   // Render and notify
1522   application.SendNotification();
1523   application.Render();
1524
1525   // Executes the idle callbacks added by the text control on the change of input style.
1526   application.RunIdles();
1527
1528   DALI_TEST_CHECK(gInputStyleChangedCallbackCalled);
1529   if(gInputStyleChangedCallbackCalled)
1530   {
1531     DALI_TEST_EQUALS(static_cast<unsigned int>(gInputStyleMask), static_cast<unsigned int>(TextEditor::InputStyle::FONT_STYLE), TEST_LOCATION);
1532
1533     Property::Map fontStyleMapSet;
1534     Property::Map fontStyleMapGet;
1535
1536     fontStyleMapGet = editor.GetProperty<Property::Map>(TextEditor::Property::INPUT_FONT_STYLE);
1537     DALI_TEST_EQUALS(fontStyleMapGet.Count(), fontStyleMapSet.Count(), TEST_LOCATION);
1538     DALI_TEST_EQUALS(DaliTestCheckMaps(fontStyleMapGet, fontStyleMapSet), true, TEST_LOCATION);
1539   }
1540   DALI_TEST_CHECK(inputStyleChangedSignal);
1541
1542   gInputStyleChangedCallbackCalled = false;
1543   gInputStyleMask                  = TextEditor::InputStyle::NONE;
1544   inputStyleChangedSignal          = false;
1545
1546   // Create a tap event to touch the text editor.
1547   TestGenerateTap(application, 191.0f, 25.0f);
1548
1549   // Render and notify
1550   application.SendNotification();
1551   application.Render();
1552
1553   // Executes the idle callbacks added by the text control on the change of input style.
1554   application.RunIdles();
1555
1556   DALI_TEST_CHECK(!gInputStyleChangedCallbackCalled);
1557   DALI_TEST_CHECK(!inputStyleChangedSignal);
1558
1559   END_TEST;
1560 }
1561
1562 int utcDaliTextEditorInputStyleChanged02(void)
1563 {
1564   // The text-editor emits signals when the input style changes. These changes of style are
1565   // detected during the relayout process (size negotiation), i.e after the cursor has been moved. Signals
1566   // can't be emitted during the size negotiation as the callbacks may update the UI.
1567   // The text-editor adds an idle callback to the adaptor to emit the signals after the size negotiation.
1568   // The ToolkitTestApplication creates an implementation of the adaptor stub and a queue of idle callbacks.
1569   ToolkitTestApplication application;
1570   tet_infoline(" utcDaliTextEditorInputStyleChanged02");
1571
1572   // Load some fonts.
1573
1574   char*             pathNamePtr = get_current_dir_name();
1575   const std::string pathName(pathNamePtr);
1576   free(pathNamePtr);
1577
1578   TextAbstraction::FontClient fontClient = TextAbstraction::FontClient::Get();
1579   fontClient.SetDpi(93u, 93u);
1580
1581   fontClient.GetFontId(pathName + DEFAULT_FONT_DIR + "/dejavu/DejaVuSerif.ttf", DEFAULT_FONT_SIZE);
1582   fontClient.GetFontId(pathName + DEFAULT_FONT_DIR + "/dejavu/DejaVuSerif-Bold.ttf", DEFAULT_FONT_SIZE);
1583
1584   TextEditor editor = TextEditor::New();
1585   DALI_TEST_CHECK(editor);
1586
1587   editor.SetProperty(Actor::Property::SIZE, Vector2(300.f, 50.f));
1588   editor.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT);
1589   editor.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
1590
1591   editor.SetProperty(TextEditor::Property::ENABLE_MARKUP, true);
1592   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>");
1593
1594   // connect to the text changed signal.
1595   ConnectionTracker* testTracker = new ConnectionTracker();
1596   editor.InputStyleChangedSignal().Connect(&TestInputStyleChangedCallback);
1597   bool inputStyleChangedSignal = false;
1598   editor.ConnectSignal(testTracker, "inputStyleChanged", CallbackFunctor(&inputStyleChangedSignal));
1599
1600   application.GetScene().Add(editor);
1601
1602   // Render and notify
1603   application.SendNotification();
1604   application.Render();
1605
1606   // Executes the idle callbacks added by the text control on the change of input style.
1607   application.RunIdles();
1608
1609   gInputStyleChangedCallbackCalled = false;
1610   gInputStyleMask                  = TextEditor::InputStyle::NONE;
1611   inputStyleChangedSignal          = false;
1612
1613   // Create a tap event to touch the text editor.
1614   TestGenerateTap(application, 53.0f, 25.0f, 100);
1615   TestGenerateTap(application, 53.0f, 25.0f, 200);
1616
1617   // Render and notify
1618   application.SendNotification();
1619   application.Render();
1620
1621   // Executes the idle callbacks added by the text control on the change of input style.
1622   application.RunIdles();
1623
1624   DALI_TEST_CHECK(gInputStyleChangedCallbackCalled);
1625   if(gInputStyleChangedCallbackCalled)
1626   {
1627     DALI_TEST_EQUALS(static_cast<unsigned int>(gInputStyleMask),
1628                      static_cast<unsigned int>(TextEditor::InputStyle::FONT_FAMILY |
1629                                                TextEditor::InputStyle::POINT_SIZE |
1630                                                TextEditor::InputStyle::COLOR),
1631                      TEST_LOCATION);
1632
1633     const Vector4 color = editor.GetProperty(TextEditor::Property::INPUT_COLOR).Get<Vector4>();
1634     DALI_TEST_EQUALS(color, Color::GREEN, TEST_LOCATION);
1635
1636     const std::string fontFamily = editor.GetProperty(TextEditor::Property::INPUT_FONT_FAMILY).Get<std::string>();
1637     DALI_TEST_EQUALS(fontFamily, "DejaVuSerif", TEST_LOCATION);
1638
1639     const float pointSize = editor.GetProperty(TextEditor::Property::INPUT_POINT_SIZE).Get<float>();
1640     DALI_TEST_EQUALS(pointSize, 18.f, Math::MACHINE_EPSILON_1000, TEST_LOCATION);
1641   }
1642   DALI_TEST_CHECK(inputStyleChangedSignal);
1643
1644   gInputStyleChangedCallbackCalled = false;
1645   gInputStyleMask                  = TextEditor::InputStyle::NONE;
1646   inputStyleChangedSignal          = false;
1647
1648   application.ProcessEvent(GenerateKey("", "", "", DALI_KEY_BACKSPACE, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
1649
1650   // Render and notify
1651   application.SendNotification();
1652   application.Render();
1653
1654   // Executes the idle callbacks added by the text control on the change of input style.
1655   application.RunIdles();
1656
1657   DALI_TEST_CHECK(gInputStyleChangedCallbackCalled);
1658   if(gInputStyleChangedCallbackCalled)
1659   {
1660     DALI_TEST_EQUALS(static_cast<unsigned int>(gInputStyleMask),
1661                      static_cast<unsigned int>(TextEditor::InputStyle::COLOR),
1662                      TEST_LOCATION);
1663
1664     const Vector4 color = editor.GetProperty(TextEditor::Property::INPUT_COLOR).Get<Vector4>();
1665     DALI_TEST_EQUALS(color, Color::BLUE, TEST_LOCATION);
1666   }
1667   DALI_TEST_CHECK(inputStyleChangedSignal);
1668
1669   gInputStyleChangedCallbackCalled = false;
1670   gInputStyleMask                  = TextEditor::InputStyle::NONE;
1671   inputStyleChangedSignal          = false;
1672
1673   application.ProcessEvent(GenerateKey("", "", "", DALI_KEY_BACKSPACE, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
1674
1675   // Render and notify
1676   application.SendNotification();
1677   application.Render();
1678
1679   // Executes the idle callbacks added by the text control on the change of input style.
1680   application.RunIdles();
1681
1682   DALI_TEST_CHECK(!gInputStyleChangedCallbackCalled);
1683   DALI_TEST_CHECK(!inputStyleChangedSignal);
1684
1685   gInputStyleChangedCallbackCalled = false;
1686   gInputStyleMask                  = TextEditor::InputStyle::NONE;
1687   inputStyleChangedSignal          = false;
1688
1689   application.ProcessEvent(GenerateKey("", "", "", DALI_KEY_BACKSPACE, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
1690
1691   // Render and notify
1692   application.SendNotification();
1693   application.Render();
1694
1695   // Executes the idle callbacks added by the text control on the change of input style.
1696   application.RunIdles();
1697
1698   DALI_TEST_CHECK(gInputStyleChangedCallbackCalled);
1699   if(gInputStyleChangedCallbackCalled)
1700   {
1701     DALI_TEST_EQUALS(static_cast<unsigned int>(gInputStyleMask),
1702                      static_cast<unsigned int>(TextEditor::InputStyle::COLOR),
1703                      TEST_LOCATION);
1704
1705     const Vector4 color = editor.GetProperty(TextEditor::Property::INPUT_COLOR).Get<Vector4>();
1706     DALI_TEST_EQUALS(color, Color::BLACK, TEST_LOCATION);
1707   }
1708   DALI_TEST_CHECK(inputStyleChangedSignal);
1709
1710   gInputStyleChangedCallbackCalled = false;
1711   gInputStyleMask                  = TextEditor::InputStyle::NONE;
1712   inputStyleChangedSignal          = false;
1713
1714   editor.SetProperty(TextEditor::Property::INPUT_COLOR, Color::YELLOW);
1715
1716   Property::Map fontStyleMapSet;
1717   fontStyleMapSet.Insert("weight", "thin");
1718   fontStyleMapSet.Insert("width", "condensed");
1719   fontStyleMapSet.Insert("slant", "italic");
1720
1721   editor.SetProperty(TextEditor::Property::INPUT_FONT_STYLE, fontStyleMapSet);
1722   editor.SetProperty(TextEditor::Property::INPUT_POINT_SIZE, 20.f);
1723   editor.SetProperty(TextEditor::Property::INPUT_LINE_SPACING, 5.f);
1724
1725   editor.SetProperty(TextEditor::Property::INPUT_UNDERLINE, "underline");
1726   editor.SetProperty(TextEditor::Property::INPUT_SHADOW, "shadow");
1727   editor.SetProperty(TextEditor::Property::INPUT_EMBOSS, "emboss");
1728   editor.SetProperty(TextEditor::Property::INPUT_OUTLINE, "outline");
1729   editor.SetProperty(DevelTextEditor::Property::INPUT_STRIKETHROUGH, "strikethrough");
1730
1731   application.ProcessEvent(GenerateKey("a", "", "a", KEY_A_CODE, 0, 0, Integration::KeyEvent::DOWN, "a", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
1732
1733   // Render and notify
1734   application.SendNotification();
1735   application.Render();
1736
1737   // Executes the idle callbacks added by the text control on the change of input style.
1738   application.RunIdles();
1739
1740   DALI_TEST_CHECK(!gInputStyleChangedCallbackCalled);
1741   DALI_TEST_CHECK(!inputStyleChangedSignal);
1742
1743   // Create a tap event to touch the text editor.
1744   TestGenerateTap(application, 63.0f, 25.0f, 900);
1745
1746   // Render and notify
1747   application.SendNotification();
1748   application.Render();
1749
1750   // Executes the idle callbacks added by the text control on the change of input style.
1751   application.RunIdles();
1752
1753   DALI_TEST_CHECK(gInputStyleChangedCallbackCalled);
1754   if(gInputStyleChangedCallbackCalled)
1755   {
1756     DALI_TEST_EQUALS(static_cast<unsigned int>(gInputStyleMask),
1757                      static_cast<unsigned int>(TextEditor::InputStyle::COLOR |
1758                                                TextEditor::InputStyle::POINT_SIZE |
1759                                                TextEditor::InputStyle::FONT_STYLE |
1760                                                TextEditor::InputStyle::LINE_SPACING |
1761                                                TextEditor::InputStyle::UNDERLINE |
1762                                                TextEditor::InputStyle::SHADOW |
1763                                                TextEditor::InputStyle::EMBOSS |
1764                                                TextEditor::InputStyle::OUTLINE),
1765                      TEST_LOCATION);
1766
1767     const Vector4 color = editor.GetProperty(TextEditor::Property::INPUT_COLOR).Get<Vector4>();
1768     DALI_TEST_EQUALS(color, Color::BLACK, TEST_LOCATION);
1769   }
1770   DALI_TEST_CHECK(inputStyleChangedSignal);
1771
1772   gInputStyleChangedCallbackCalled = false;
1773   gInputStyleMask                  = TextEditor::InputStyle::NONE;
1774   inputStyleChangedSignal          = false;
1775
1776   editor.SetProperty(TextEditor::Property::FONT_FAMILY, "DejaVuSerif");
1777
1778   fontStyleMapSet.Clear();
1779   fontStyleMapSet.Insert("weight", "black");
1780   fontStyleMapSet.Insert("width", "expanded");
1781   fontStyleMapSet.Insert("slant", "oblique");
1782
1783   editor.SetProperty(TextEditor::Property::FONT_STYLE, fontStyleMapSet);
1784
1785   // Create a tap event to touch the text editor.
1786   TestGenerateTap(application, 30.0f, 25.0f, 1500);
1787
1788   // Render and notify
1789   application.SendNotification();
1790   application.Render();
1791
1792   // Executes the idle callbacks added by the text control on the change of input style.
1793   application.RunIdles();
1794
1795   DALI_TEST_CHECK(gInputStyleChangedCallbackCalled);
1796   if(gInputStyleChangedCallbackCalled)
1797   {
1798     DALI_TEST_EQUALS(static_cast<unsigned int>(gInputStyleMask),
1799                      static_cast<unsigned int>(TextEditor::InputStyle::COLOR |
1800                                                TextEditor::InputStyle::POINT_SIZE |
1801                                                TextEditor::InputStyle::FONT_STYLE),
1802                      TEST_LOCATION);
1803
1804     const Vector4 color = editor.GetProperty(TextEditor::Property::INPUT_COLOR).Get<Vector4>();
1805     DALI_TEST_EQUALS(color, Color::YELLOW, TEST_LOCATION);
1806   }
1807   DALI_TEST_CHECK(inputStyleChangedSignal);
1808
1809   END_TEST;
1810 }
1811
1812 int utcDaliTextEditorEvent01(void)
1813 {
1814   ToolkitTestApplication application;
1815   tet_infoline(" utcDaliTextEditorEvent01");
1816
1817   // Creates a tap event. After creating a tap event the text editor should
1818   // have the focus and add text with key events should be possible.
1819
1820   TextEditor editor = TextEditor::New();
1821   DALI_TEST_CHECK(editor);
1822
1823   application.GetScene().Add(editor);
1824
1825   editor.SetProperty(Actor::Property::SIZE, Vector2(300.f, 50.f));
1826   editor.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT);
1827   editor.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
1828
1829   // Avoid a crash when core load gl resources.
1830   application.GetGlAbstraction().SetCheckFramebufferStatusResult(GL_FRAMEBUFFER_COMPLETE);
1831
1832   // Render and notify
1833   application.SendNotification();
1834   application.Render();
1835
1836   // Add a key event but as the text editor has not the focus it should do nothing.
1837   application.ProcessEvent(GenerateKey("a", "", "a", KEY_A_CODE, 0, 0, Integration::KeyEvent::DOWN, "a", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
1838
1839   // Render and notify
1840   application.SendNotification();
1841   application.Render();
1842
1843   DALI_TEST_EQUALS(editor.GetProperty<std::string>(TextEditor::Property::TEXT), std::string(""), TEST_LOCATION);
1844
1845   // Create a tap event to touch the text editor.
1846   TestGenerateTap(application, 150.0f, 25.0f);
1847
1848   // Render and notify
1849   application.SendNotification();
1850   application.Render();
1851
1852   // Now the text editor has the focus, so it can handle the key events.
1853   application.ProcessEvent(GenerateKey("a", "", "a", KEY_A_CODE, 0, 0, Integration::KeyEvent::DOWN, "a", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
1854   application.ProcessEvent(GenerateKey("a", "", "a", KEY_A_CODE, 0, 0, Integration::KeyEvent::DOWN, "a", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
1855
1856   // Render and notify
1857   application.SendNotification();
1858   application.Render();
1859
1860   DALI_TEST_EQUALS(editor.GetProperty<std::string>(TextEditor::Property::TEXT), std::string("aa"), TEST_LOCATION);
1861
1862   // Create a second text editor and send key events to it.
1863   TextEditor editor2 = TextEditor::New();
1864
1865   editor2.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT);
1866   editor2.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
1867   editor2.SetProperty(Actor::Property::SIZE, Vector2(100.f, 100.f));
1868   editor2.SetProperty(Actor::Property::POSITION, Vector2(100.f, 100.f));
1869
1870   application.GetScene().Add(editor2);
1871
1872   // Render and notify
1873   application.SendNotification();
1874   application.Render();
1875
1876   // Create a tap event on the second text editor.
1877   TestGenerateTap(application, 150.0f, 125.0f);
1878
1879   // Render and notify
1880   application.SendNotification();
1881   application.Render();
1882
1883   // The second text editor has the focus. It should handle the key events.
1884   application.ProcessEvent(GenerateKey("a", "", "a", KEY_A_CODE, 0, 0, Integration::KeyEvent::DOWN, "a", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
1885   application.ProcessEvent(GenerateKey("a", "", "a", KEY_A_CODE, 0, 0, Integration::KeyEvent::DOWN, "a", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
1886
1887   // Render and notify
1888   application.SendNotification();
1889   application.Render();
1890
1891   // Check the text has been added to the second text editor.
1892   DALI_TEST_EQUALS(editor2.GetProperty<std::string>(TextEditor::Property::TEXT), std::string("aa"), TEST_LOCATION);
1893
1894   END_TEST;
1895 }
1896
1897 int utcDaliTextEditorEvent02(void)
1898 {
1899   ToolkitTestApplication application;
1900   tet_infoline(" utcDaliTextEditorEvent02");
1901
1902   // Checks if the right number of actors are created.
1903
1904   TextEditor editor = TextEditor::New();
1905   editor.SetProperty(TextEditor::Property::POINT_SIZE, 10.f);
1906   DALI_TEST_CHECK(editor);
1907
1908   application.GetScene().Add(editor);
1909
1910   editor.SetProperty(Actor::Property::SIZE, Vector2(300.f, 50.f));
1911   editor.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT);
1912   editor.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
1913
1914   // Avoid a crash when core load gl resources.
1915   application.GetGlAbstraction().SetCheckFramebufferStatusResult(GL_FRAMEBUFFER_COMPLETE);
1916
1917   // Render and notify
1918   application.SendNotification();
1919   application.Render();
1920
1921   // Check there are the expected number of children (the stencil).
1922   DALI_TEST_EQUALS(editor.GetChildCount(), 1u, TEST_LOCATION);
1923
1924   Actor stencil = editor.GetChildAt(0u);
1925
1926   // Create a tap event to touch the text editor.
1927   TestGenerateTap(application, 150.0f, 25.0f, 100);
1928
1929   // Render and notify
1930   application.SendNotification();
1931   application.Render();
1932
1933   Actor layer = editor.GetChildAt(2u);
1934   DALI_TEST_EQUALS(layer.GetChildCount(), 1u, TEST_LOCATION); // The cursor.
1935   DALI_TEST_EQUALS(stencil.GetChildCount(), 0u, TEST_LOCATION);
1936
1937   // Now the text editor has the focus, so it can handle the key events.
1938   application.ProcessEvent(GenerateKey("a", "", "a", KEY_A_CODE, 0, 0, Integration::KeyEvent::DOWN, "a", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
1939   application.ProcessEvent(GenerateKey("a", "", "a", KEY_A_CODE, 0, 0, Integration::KeyEvent::DOWN, "a", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
1940
1941   // Render and notify
1942   application.SendNotification();
1943   application.Render();
1944
1945   // Checks the cursor and the renderer have been created.
1946   DALI_TEST_EQUALS(layer.GetChildCount(), 1u, TEST_LOCATION);   // The cursor.
1947   DALI_TEST_EQUALS(stencil.GetChildCount(), 2u, TEST_LOCATION); // The renderer, clipped cursor
1948
1949   Control cursor = Control::DownCast(layer.GetChildAt(0u));
1950   DALI_TEST_CHECK(cursor);
1951
1952   // The stencil actor has a container with all the actors which contain the text renderers.
1953   Actor container = stencil.GetChildAt(0u);
1954   for(unsigned int index = 0; index < container.GetChildCount(); ++index)
1955   {
1956     Renderer renderer = container.GetChildAt(index).GetRendererAt(0u);
1957     DALI_TEST_CHECK(renderer);
1958   }
1959
1960   // Move the cursor and check the position changes.
1961   Vector3 position1 = cursor.GetCurrentProperty<Vector3>(Actor::Property::POSITION);
1962
1963   application.ProcessEvent(GenerateKey("", "", "", DALI_KEY_CURSOR_LEFT, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
1964   application.ProcessEvent(GenerateKey("", "", "", DALI_KEY_CURSOR_LEFT, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
1965
1966   // Render and notify
1967   application.SendNotification();
1968   application.Render();
1969
1970   Vector3 position2 = cursor.GetCurrentProperty<Vector3>(Actor::Property::POSITION);
1971
1972   DALI_TEST_CHECK(position2.x < position1.x);
1973
1974   application.ProcessEvent(GenerateKey("", "", "", DALI_KEY_CURSOR_RIGHT, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
1975   application.ProcessEvent(GenerateKey("", "", "", DALI_KEY_CURSOR_RIGHT, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
1976
1977   // Render and notify
1978   application.SendNotification();
1979   application.Render();
1980
1981   Vector3 position3 = cursor.GetCurrentProperty<Vector3>(Actor::Property::POSITION);
1982
1983   DALI_TEST_EQUALS(position1, position3, TEST_LOCATION); // Should be in the same position1.
1984
1985   // Send some taps and check the cursor positions.
1986
1987   // Try to tap at the beginning.
1988   TestGenerateTap(application, 1.0f, 25.0f, 700);
1989
1990   // Render and notify
1991   application.SendNotification();
1992   application.Render();
1993
1994   // Cursor position should be the same than position1.
1995   Vector3 position4 = cursor.GetCurrentProperty<Vector3>(Actor::Property::POSITION);
1996
1997   DALI_TEST_EQUALS(position2, position4, TEST_LOCATION); // Should be in the same position2.
1998
1999   // Tap away from the start position.
2000   TestGenerateTap(application, 16.0f, 25.0f, 1400);
2001
2002   // Render and notify
2003   application.SendNotification();
2004   application.Render();
2005
2006   Vector3 position5 = cursor.GetCurrentProperty<Vector3>(Actor::Property::POSITION);
2007
2008   DALI_TEST_CHECK(position5.x > position4.x);
2009
2010   // Remove all the text.
2011   application.ProcessEvent(GenerateKey("", "", "", DALI_KEY_BACKSPACE, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
2012   application.ProcessEvent(GenerateKey("", "", "", DALI_KEY_BACKSPACE, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
2013   editor.SetProperty(TextEditor::Property::TEXT, "");
2014
2015   // Render and notify
2016   application.SendNotification();
2017   application.Render();
2018
2019   // Cursor position should be the same than position2.
2020   Vector3 position6 = cursor.GetCurrentProperty<Vector3>(Actor::Property::POSITION);
2021
2022   DALI_TEST_EQUALS(position2, position6, TEST_LOCATION); // Should be in the same position2.
2023
2024   // Should not be a renderer, there is only a clipped cursor.
2025   DALI_TEST_EQUALS(stencil.GetChildCount(), 1u, TEST_LOCATION);
2026
2027   END_TEST;
2028 }
2029
2030 int utcDaliTextEditorEvent03(void)
2031 {
2032   ToolkitTestApplication application;
2033   tet_infoline(" utcDaliTextEditorEvent03");
2034
2035   // Checks if the highlight actor is created.
2036
2037   TextEditor editor = TextEditor::New();
2038   DALI_TEST_CHECK(editor);
2039
2040   application.GetScene().Add(editor);
2041
2042   editor.SetProperty(TextEditor::Property::TEXT, "This is a long text for the size of the text-editor.");
2043   editor.SetProperty(TextEditor::Property::POINT_SIZE, 10.f);
2044   editor.SetProperty(Actor::Property::SIZE, Vector2(30.f, 50.f));
2045   editor.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT);
2046   editor.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
2047
2048   // Avoid a crash when core load gl resources.
2049   application.GetGlAbstraction().SetCheckFramebufferStatusResult(GL_FRAMEBUFFER_COMPLETE);
2050
2051   // Render and notify
2052   application.SendNotification();
2053   application.Render();
2054
2055   // Send some taps and check text controller with clipboard window
2056   Dali::Clipboard clipboard = Clipboard::Get();
2057   clipboard.ShowClipboard();
2058   TestGenerateTap(application, 3.0f, 25.0f, 100);
2059   clipboard.HideClipboard();
2060
2061   // Render and notify
2062   application.SendNotification();
2063   application.Render();
2064
2065   // Tap first to get the focus.
2066   TestGenerateTap(application, 3.0f, 25.0f, 1000);
2067
2068   // Render and notify
2069   application.SendNotification();
2070   application.Render();
2071
2072   // Double tap to select a word.
2073   TestGenerateTap(application, 3.0f, 25.0f, 1100);
2074
2075   // Render and notify
2076   application.SendNotification();
2077   application.Render();
2078
2079   // The stencil actor should have two actors: the renderer and the highlight actor.
2080   Actor stencil = editor.GetChildAt(0u);
2081
2082   // Highlight needs to be drawn before text, so should come first in child order
2083   Renderer highlight = stencil.GetChildAt(0u).GetRendererAt(0u);
2084   DALI_TEST_CHECK(highlight);
2085
2086   // The stencil actor has a container with all the actors which contain the text renderers.
2087   Actor container = stencil.GetChildAt(1u);
2088   for(unsigned int index = 0; index < container.GetChildCount(); ++index)
2089   {
2090     Renderer renderer = container.GetChildAt(index).GetRendererAt(0u);
2091     DALI_TEST_CHECK(renderer);
2092   }
2093
2094   // Double tap out of bounds
2095   TestGenerateTap(application, 29.0f, 25.0f, 1700);
2096   TestGenerateTap(application, 29.0f, 25.0f, 1800);
2097
2098   // Render and notify
2099   application.SendNotification();
2100   application.Render();
2101
2102   // The stencil actor should have one actors: the renderer actor.
2103   stencil = editor.GetChildAt(0u);
2104
2105   // The stencil actor has a container with all the actors which contain the text renderers.
2106   container = stencil.GetChildAt(0u);
2107   for(unsigned int index = 0; index < container.GetChildCount(); ++index)
2108   {
2109     Renderer renderer = container.GetChildAt(index).GetRendererAt(0u);
2110     DALI_TEST_CHECK(renderer);
2111   }
2112
2113   // Long Press
2114   TestGenerateLongPress(application, 1.0f, 25.0f);
2115
2116   // Render and notify
2117   application.SendNotification();
2118   application.Render();
2119
2120   // Pan Press
2121   TestGenerateMiniPan(application);
2122
2123   // Render and notify
2124   application.SendNotification();
2125   application.Render();
2126
2127   END_TEST;
2128 }
2129
2130 int utcDaliTextEditorEvent04(void)
2131 {
2132   ToolkitTestApplication application;
2133   tet_infoline(" utcDaliTextEditorEvent04");
2134
2135   // Checks if the highlight actor is created.
2136
2137   TextEditor editor = TextEditor::New();
2138   DALI_TEST_CHECK(editor);
2139
2140   application.GetScene().Add(editor);
2141
2142   editor.SetProperty(TextEditor::Property::TEXT, "Hello\nworl");
2143   editor.SetProperty(TextEditor::Property::POINT_SIZE, 10.f);
2144   editor.SetProperty(Actor::Property::SIZE, Vector2(100.f, 50.f));
2145   editor.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT);
2146   editor.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
2147
2148   // Avoid a crash when core load gl resources.
2149   application.GetGlAbstraction().SetCheckFramebufferStatusResult(GL_FRAMEBUFFER_COMPLETE);
2150
2151   // Render and notify
2152   application.SendNotification();
2153   application.Render();
2154
2155   // Tap on the text editor
2156   TestGenerateTap(application, 3.0f, 25.0f);
2157
2158   // Render and notify
2159   application.SendNotification();
2160   application.Render();
2161
2162   // Move at the end of the text.
2163   application.ProcessEvent(GenerateKey("", "", "", DALI_KEY_CURSOR_DOWN, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
2164   application.ProcessEvent(GenerateKey("", "", "", DALI_KEY_CURSOR_DOWN, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
2165
2166   // Render and notify
2167   application.SendNotification();
2168   application.Render();
2169
2170   for(unsigned int index = 0u; index < 10u; ++index)
2171   {
2172     application.ProcessEvent(GenerateKey("", "", "", DALI_KEY_CURSOR_RIGHT, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
2173     application.ProcessEvent(GenerateKey("", "", "", DALI_KEY_CURSOR_RIGHT, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
2174
2175     // Render and notify
2176     application.SendNotification();
2177     application.Render();
2178   }
2179
2180   // Add a character
2181   application.ProcessEvent(GenerateKey("d", "", "d", KEY_D_CODE, 0, 0, Integration::KeyEvent::DOWN, "d", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
2182
2183   // Render and notify
2184   application.SendNotification();
2185   application.Render();
2186
2187   DALI_TEST_EQUALS("Hello\nworld", editor.GetProperty<std::string>(TextEditor::Property::TEXT), TEST_LOCATION);
2188
2189   // Add some key events
2190   application.ProcessEvent(GenerateKey("", "", "", DALI_KEY_CURSOR_UP, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
2191   application.ProcessEvent(GenerateKey("", "", "", DALI_KEY_CURSOR_UP, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
2192
2193   // Render and notify
2194   application.SendNotification();
2195   application.Render();
2196
2197   for(unsigned int index = 0u; index < 10u; ++index)
2198   {
2199     application.ProcessEvent(GenerateKey("", "", "", DALI_KEY_CURSOR_LEFT, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
2200     application.ProcessEvent(GenerateKey("", "", "", DALI_KEY_CURSOR_LEFT, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
2201
2202     // Render and notify
2203     application.SendNotification();
2204     application.Render();
2205   }
2206
2207   // Add a character
2208   application.ProcessEvent(GenerateKey(" ", "", " ", KEY_WHITE_SPACE_CODE, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
2209
2210   // Render and notify
2211   application.SendNotification();
2212   application.Render();
2213
2214   DALI_TEST_EQUALS(" Hello\nworld", editor.GetProperty<std::string>(TextEditor::Property::TEXT), TEST_LOCATION);
2215
2216   END_TEST;
2217 }
2218
2219 int utcDaliTextEditorEvent05(void)
2220 {
2221   ToolkitTestApplication application;
2222   tet_infoline(" utcDaliTextEditorEvent05");
2223
2224   // Checks if the highlight actor is created.
2225
2226   TextEditor editor = TextEditor::New();
2227   DALI_TEST_CHECK(editor);
2228
2229   application.GetScene().Add(editor);
2230
2231   editor.SetProperty(TextEditor::Property::TEXT, "Hello\nworl");
2232   editor.SetProperty(TextEditor::Property::POINT_SIZE, 10.f);
2233   editor.SetProperty(Actor::Property::SIZE, Vector2(50.f, 50.f));
2234   editor.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT);
2235   editor.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
2236   editor.SetProperty(TextEditor::Property::SMOOTH_SCROLL, true);
2237   editor.SetProperty(TextEditor::Property::SMOOTH_SCROLL_DURATION, 0.2f);
2238   editor.SetProperty(TextEditor::Property::ENABLE_SCROLL_BAR, true);
2239   editor.SetProperty(TextEditor::Property::SCROLL_BAR_SHOW_DURATION, 0.3f);
2240   editor.SetProperty(TextEditor::Property::SCROLL_BAR_FADE_DURATION, 0.2f);
2241
2242   // Avoid a crash when core load gl resources.
2243   application.GetGlAbstraction().SetCheckFramebufferStatusResult(GL_FRAMEBUFFER_COMPLETE);
2244
2245   // Render and notify
2246   application.SendNotification();
2247   application.Render();
2248
2249   // Tap on the text editor
2250   TestGenerateTap(application, 3.0f, 25.0f);
2251
2252   // Render and notify
2253   application.SendNotification();
2254   application.Render();
2255
2256   // Move at the end of the text.
2257   application.ProcessEvent(GenerateKey("", "", "", DALI_KEY_CURSOR_DOWN, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
2258   application.ProcessEvent(GenerateKey("", "", "", DALI_KEY_CURSOR_DOWN, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
2259
2260   // Render and notify
2261   application.SendNotification();
2262   application.Render();
2263
2264   for(unsigned int index = 0u; index < 10u; ++index)
2265   {
2266     // Add a character
2267     application.ProcessEvent(GenerateKey("d", "", "d", KEY_D_CODE, 0, 0, Integration::KeyEvent::DOWN, "d", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
2268
2269     // Render and notify
2270     application.SendNotification();
2271     application.Render();
2272   }
2273   // Modify duration after scroll is enabled
2274   editor.SetProperty(TextEditor::Property::SMOOTH_SCROLL_DURATION, 0.1f);
2275
2276   // Continuous scroll left to increase coverage
2277   for(unsigned int index = 0u; index < 10u; ++index)
2278   {
2279     application.ProcessEvent(GenerateKey("", "", "", DALI_KEY_CURSOR_LEFT, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
2280
2281     // Render and notify
2282     application.SendNotification();
2283     application.Render();
2284   }
2285   DALI_TEST_EQUALS(editor.GetProperty<float>(TextEditor::Property::SMOOTH_SCROLL_DURATION), 0.1f, Math::MACHINE_EPSILON_1000, TEST_LOCATION);
2286   DALI_TEST_EQUALS(editor.GetProperty<bool>(TextEditor::Property::SMOOTH_SCROLL), true, TEST_LOCATION);
2287   DALI_TEST_EQUALS(editor.GetProperty<bool>(TextEditor::Property::ENABLE_SCROLL_BAR), true, TEST_LOCATION);
2288   DALI_TEST_EQUALS(editor.GetProperty<float>(TextEditor::Property::SCROLL_BAR_SHOW_DURATION), 0.3f, Math::MACHINE_EPSILON_1000, TEST_LOCATION);
2289   DALI_TEST_EQUALS(editor.GetProperty<float>(TextEditor::Property::SCROLL_BAR_FADE_DURATION), 0.2f, Math::MACHINE_EPSILON_1000, TEST_LOCATION);
2290
2291   // Press Escape to increase coverage
2292   application.ProcessEvent(GenerateKey("", "", "", DALI_KEY_ESCAPE, 0, 0, Integration::KeyEvent::UP, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
2293   application.SendNotification();
2294   application.Render();
2295
2296   DALI_TEST_CHECK(!editor.HasKeyInputFocus());
2297
2298   END_TEST;
2299 }
2300
2301 int utcDaliTextEditorEvent06(void)
2302 {
2303   ToolkitTestApplication application;
2304   tet_infoline(" utcDaliTextEditorEvent06");
2305
2306   // Checks if the highlight actor is created.
2307
2308   TextEditor editor = TextEditor::New();
2309   DALI_TEST_CHECK(editor);
2310
2311   application.GetScene().Add(editor);
2312
2313   editor.SetProperty(TextEditor::Property::TEXT, "Hello\nworld\nHello world");
2314   editor.SetProperty(TextEditor::Property::POINT_SIZE, 10.f);
2315   editor.SetProperty(Actor::Property::SIZE, Vector2(100.f, 50.f));
2316   editor.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT);
2317   editor.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
2318
2319   // Avoid a crash when core load gl resources.
2320   application.GetGlAbstraction().SetCheckFramebufferStatusResult(GL_FRAMEBUFFER_COMPLETE);
2321
2322   // Render and notify
2323   application.SendNotification();
2324   application.Render();
2325
2326   // Tap on the text editor
2327   TestGenerateTap(application, 3.0f, 25.0f);
2328
2329   // Render and notify
2330   application.SendNotification();
2331   application.Render();
2332
2333   // Move to seconds line of the text.
2334   application.ProcessEvent(GenerateKey("", "", "", DALI_KEY_CURSOR_DOWN, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
2335
2336   // Render and notify
2337   application.SendNotification();
2338   application.Render();
2339
2340   float layoutHeight = editor.GetHeightForWidth(100.f);
2341
2342   // Add  another script characters ( glyph height is defferent )
2343   application.ProcessEvent(GenerateKey("d", "", "ㅁ", KEY_D_CODE, 0, 0, Integration::KeyEvent::DOWN, "ㅁ", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
2344   application.ProcessEvent(GenerateKey("d", "", "ኢ", KEY_D_CODE, 0, 0, Integration::KeyEvent::DOWN, "ኢ", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
2345
2346   // Delete characters
2347   application.ProcessEvent(GenerateKey("", "", "", DALI_KEY_BACKSPACE, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
2348   application.ProcessEvent(GenerateKey("", "", "", DALI_KEY_BACKSPACE, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
2349
2350   DALI_TEST_EQUALS(layoutHeight, editor.GetHeightForWidth(100.f), TEST_LOCATION);
2351
2352   // Render and notify
2353   application.SendNotification();
2354   application.Render();
2355
2356   DALI_TEST_EQUALS("Hello\nworld\nHello world", editor.GetProperty<std::string>(TextEditor::Property::TEXT), TEST_LOCATION);
2357
2358   // For coverage
2359   application.ProcessEvent(GenerateKey("", "", "", 0, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
2360   application.SendNotification();
2361   application.Render();
2362
2363   application.ProcessEvent(GenerateKey("", "", "", DALI_KEY_SHIFT_LEFT, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
2364   application.SendNotification();
2365   application.Render();
2366
2367   application.ProcessEvent(GenerateKey("", "", "", DALI_KEY_VOLUME_UP, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
2368   application.SendNotification();
2369   application.Render();
2370
2371   application.ProcessEvent(GenerateKey("", "", "", DALI_KEY_VOLUME_DOWN, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
2372   application.SendNotification();
2373   application.Render();
2374
2375   application.ProcessEvent(GenerateKey("", "", "", Dali::DevelKey::DALI_KEY_DELETE, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
2376   application.SendNotification();
2377   application.Render();
2378
2379   application.ProcessEvent(GenerateKey("", "", "", Dali::DevelKey::DALI_KEY_CONTROL_LEFT, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
2380   application.SendNotification();
2381   application.Render();
2382
2383   application.ProcessEvent(GenerateKey("", "", "", Dali::DevelKey::DALI_KEY_CONTROL_RIGHT, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
2384   application.SendNotification();
2385   application.Render();
2386
2387   END_TEST;
2388 }
2389
2390 int utcDaliTextEditorEvent07(void)
2391 {
2392   ToolkitTestApplication application;
2393   tet_infoline(" utcDaliTextEditorEvent07");
2394
2395   // Checks if the highlight actor is created.
2396
2397   TextEditor editor = TextEditor::New();
2398   DALI_TEST_CHECK(editor);
2399
2400   application.GetScene().Add(editor);
2401
2402   editor.SetProperty(TextEditor::Property::TEXT, "Hello\nworld\nHello world");
2403   editor.SetProperty(TextEditor::Property::POINT_SIZE, 10.f);
2404   editor.SetProperty(Actor::Property::SIZE, Vector2(100.f, 50.f));
2405   editor.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT);
2406   editor.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
2407
2408   // Avoid a crash when core load gl resources.
2409   application.GetGlAbstraction().SetCheckFramebufferStatusResult(GL_FRAMEBUFFER_COMPLETE);
2410
2411   // Render and notify
2412   application.SendNotification();
2413   application.Render();
2414
2415   // Tap on the text editor
2416   TestGenerateTap(application, 3.0f, 25.0f);
2417
2418   // Render and notify
2419   application.SendNotification();
2420   application.Render();
2421
2422   // Move to second line of the text.
2423   application.ProcessEvent(GenerateKey("", "", "", DALI_KEY_CURSOR_DOWN, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
2424
2425   // Render and notify
2426   application.SendNotification();
2427   application.Render();
2428
2429   // Select some text in the right of the current cursor position
2430   application.ProcessEvent(GenerateKey("", "", "", DALI_KEY_SHIFT_LEFT, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
2431   application.ProcessEvent(GenerateKey("", "", "", DALI_KEY_CURSOR_RIGHT, KEY_SHIFT_MODIFIER, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
2432   application.ProcessEvent(GenerateKey("", "", "", DALI_KEY_CURSOR_RIGHT, KEY_SHIFT_MODIFIER, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
2433   application.ProcessEvent(GenerateKey("", "", "", DALI_KEY_CURSOR_RIGHT, KEY_SHIFT_MODIFIER, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
2434
2435   // Render and notify
2436   application.SendNotification();
2437   application.Render();
2438
2439   // Cut the selected text
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.ProcessEvent(GenerateKey("x", "", "x", KEY_X_CODE, KEY_CONTROL_MODIFIER, 0, Integration::KeyEvent::DOWN, "x", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
2442
2443   // Render and notify
2444   application.SendNotification();
2445   application.Render();
2446
2447   DALI_TEST_EQUALS("Hello\nld\nHello world", editor.GetProperty<std::string>(TextEditor::Property::TEXT), TEST_LOCATION);
2448
2449   // Select some text in the left of the current cursor position
2450   application.ProcessEvent(GenerateKey("", "", "", DALI_KEY_SHIFT_LEFT, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
2451   application.ProcessEvent(GenerateKey("", "", "", DALI_KEY_CURSOR_LEFT, KEY_SHIFT_MODIFIER, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
2452   application.ProcessEvent(GenerateKey("", "", "", DALI_KEY_CURSOR_LEFT, KEY_SHIFT_MODIFIER, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
2453   application.ProcessEvent(GenerateKey("", "", "", DALI_KEY_CURSOR_LEFT, KEY_SHIFT_MODIFIER, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
2454
2455   // Render and notify
2456   application.SendNotification();
2457   application.Render();
2458
2459   // Copy the selected text
2460   application.ProcessEvent(GenerateKey("", "", "", Dali::DevelKey::DALI_KEY_CONTROL_LEFT, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
2461   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));
2462
2463   // Render and notify
2464   application.SendNotification();
2465   application.Render();
2466
2467   // Move the cursor to the third line
2468   application.ProcessEvent(GenerateKey("", "", "", DALI_KEY_CURSOR_DOWN, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
2469   application.ProcessEvent(GenerateKey("", "", "", DALI_KEY_CURSOR_DOWN, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
2470
2471   // Render and notify
2472   application.SendNotification();
2473   application.Render();
2474
2475   // Paste the selected text at the current cursor position
2476   application.ProcessEvent(GenerateKey("", "", "", Dali::DevelKey::DALI_KEY_CONTROL_LEFT, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
2477   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));
2478
2479   // Render and notify
2480   application.SendNotification();
2481   application.Render();
2482
2483   DALI_TEST_EQUALS("Hello\nld\nHello lo\nworld", editor.GetProperty<std::string>(TextEditor::Property::TEXT), TEST_LOCATION);
2484
2485   // Disable Shift Selection
2486   editor.SetProperty(DevelTextEditor::Property::ENABLE_SHIFT_SELECTION, false);
2487
2488   // Test to select some text in the right of the current cursor position
2489   application.ProcessEvent(GenerateKey("", "", "", DALI_KEY_SHIFT_LEFT, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
2490   application.ProcessEvent(GenerateKey("", "", "", DALI_KEY_CURSOR_RIGHT, KEY_SHIFT_MODIFIER, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
2491   application.ProcessEvent(GenerateKey("", "", "", DALI_KEY_CURSOR_RIGHT, KEY_SHIFT_MODIFIER, 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
2494   // Render and notify
2495   application.SendNotification();
2496   application.Render();
2497
2498   // Cut the selected text
2499   application.ProcessEvent(GenerateKey("", "", "", Dali::DevelKey::DALI_KEY_CONTROL_LEFT, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
2500   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));
2501
2502   // Render and notify
2503   application.SendNotification();
2504   application.Render();
2505
2506   // The text isn't selected and not changed because of 'SetProperty( DevelTextEditor::Property::ENABLE_SHIFT_SELECTION, false )'
2507   DALI_TEST_EQUALS("Hello\nld\nHello lo\nworld", editor.GetProperty<std::string>(TextEditor::Property::TEXT), TEST_LOCATION);
2508
2509   // Test to select some text in the left of the current cursor position
2510   application.ProcessEvent(GenerateKey("", "", "", DALI_KEY_SHIFT_LEFT, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
2511   application.ProcessEvent(GenerateKey("", "", "", DALI_KEY_CURSOR_LEFT, KEY_SHIFT_MODIFIER, 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
2515   // Render and notify
2516   application.SendNotification();
2517   application.Render();
2518
2519   // Copy the selected text
2520   application.ProcessEvent(GenerateKey("", "", "", Dali::DevelKey::DALI_KEY_CONTROL_LEFT, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
2521   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));
2522
2523   // Render and notify
2524   application.SendNotification();
2525   application.Render();
2526
2527   // The text is not selected and not changed because of 'SetProperty( DevelTextEditor::Property::ENABLE_SHIFT_SELECTION, false )'
2528   DALI_TEST_EQUALS("Hello\nld\nHello lo\nworld", editor.GetProperty<std::string>(TextEditor::Property::TEXT), TEST_LOCATION);
2529
2530   // Select all Text
2531   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));
2532
2533   // Render and notify
2534   application.SendNotification();
2535   application.Render();
2536
2537   // replace text with "c"
2538   application.ProcessEvent(GenerateKey("c", "", "c", KEY_C_CODE, 0, 0, Integration::KeyEvent::DOWN, "c", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
2539
2540   // Render and notify
2541   application.SendNotification();
2542   application.Render();
2543
2544   //text is "c"
2545   DALI_TEST_EQUALS("c", editor.GetProperty<std::string>(TextEditor::Property::TEXT), TEST_LOCATION);
2546
2547   // select all text
2548   DevelTextEditor::SelectWholeText(editor);
2549
2550   // Render and notify
2551   application.SendNotification();
2552   application.Render();
2553
2554   // Copy the selected text using logical keys
2555   application.ProcessEvent(GenerateKey("", "", "", Dali::DevelKey::DALI_KEY_CONTROL_LEFT, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
2556   application.ProcessEvent(GenerateKey("ؤ", "c", "ؤ", KEY_C_CODE, KEY_CONTROL_MODIFIER, 0, Integration::KeyEvent::DOWN, "c", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
2557
2558   // Render and notify
2559   application.SendNotification();
2560   application.Render();
2561
2562   // select none
2563   DevelTextEditor::SelectNone(editor);
2564
2565   // Render and notify
2566   application.SendNotification();
2567   application.Render();
2568
2569   // Paste the selected using logical keys
2570   application.ProcessEvent(GenerateKey("", "", "", Dali::DevelKey::DALI_KEY_CONTROL_LEFT, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
2571   application.ProcessEvent(GenerateKey("ر", "v", "ر", KEY_V_CODE, KEY_CONTROL_MODIFIER, 0, Integration::KeyEvent::DOWN, "v", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
2572
2573   //text is "cc"
2574   DALI_TEST_EQUALS("cc", editor.GetProperty<std::string>(TextEditor::Property::TEXT), TEST_LOCATION);
2575
2576   // select all using logical keys
2577   application.ProcessEvent(GenerateKey("", "", "", Dali::DevelKey::DALI_KEY_CONTROL_LEFT, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
2578   application.ProcessEvent(GenerateKey("ش", "a", "ش", KEY_A_CODE, KEY_CONTROL_MODIFIER, 0, Integration::KeyEvent::DOWN, "a", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
2579
2580   // Render and notify
2581   application.SendNotification();
2582   application.Render();
2583
2584   // cut text using logical keys
2585   application.ProcessEvent(GenerateKey("", "", "", Dali::DevelKey::DALI_KEY_CONTROL_LEFT, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
2586   application.ProcessEvent(GenerateKey("ء", "x", "ء", KEY_X_CODE, KEY_CONTROL_MODIFIER, 0, Integration::KeyEvent::DOWN, "x", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
2587
2588   // Render and notify
2589   application.SendNotification();
2590   application.Render();
2591
2592   //text is ""
2593   DALI_TEST_EQUALS("", editor.GetProperty<std::string>(TextEditor::Property::TEXT), TEST_LOCATION);
2594
2595   END_TEST;
2596 }
2597
2598 int utcDaliTextEditorEvent08(void)
2599 {
2600   ToolkitTestApplication application;
2601   tet_infoline(" utcDaliTextEditorEvent08");
2602
2603   // Checks if the highlight actor is released correctly.
2604
2605   TextEditor editor = TextEditor::New();
2606   DALI_TEST_CHECK(editor);
2607
2608   application.GetScene().Add(editor);
2609
2610   editor.SetProperty(TextEditor::Property::TEXT, "DALi");
2611   editor.SetProperty(TextEditor::Property::POINT_SIZE, 10.f);
2612   editor.SetProperty(Actor::Property::SIZE, Vector2(100.f, 50.f));
2613   editor.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT);
2614   editor.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
2615
2616   // Avoid a crash when core load gl resources.
2617   application.GetGlAbstraction().SetCheckFramebufferStatusResult(GL_FRAMEBUFFER_COMPLETE);
2618
2619   // Render and notify
2620   application.SendNotification();
2621   application.Render();
2622
2623   // Tap on the text editor
2624   TestGenerateTap(application, 3.0f, 25.0f);
2625
2626   // Render and notify
2627   application.SendNotification();
2628   application.Render();
2629
2630   // When the left selection handle and the right selection handle are at the same position, the highlight box should be deactivated.
2631   // Test to select some text in the left of the current cursor position
2632   application.ProcessEvent(GenerateKey("", "", "", DALI_KEY_SHIFT_LEFT, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
2633   application.ProcessEvent(GenerateKey("", "", "", DALI_KEY_CURSOR_LEFT, KEY_SHIFT_MODIFIER, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
2634   application.ProcessEvent(GenerateKey("", "", "", DALI_KEY_CURSOR_LEFT, KEY_SHIFT_MODIFIER, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
2635   application.ProcessEvent(GenerateKey("", "", "", DALI_KEY_CURSOR_LEFT, KEY_SHIFT_MODIFIER, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
2636
2637   // Render and notify
2638   application.SendNotification();
2639   application.Render();
2640
2641   // Test to the left selection handle position and the right selection handle position
2642   application.ProcessEvent(GenerateKey("", "", "", DALI_KEY_SHIFT_LEFT, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
2643   application.ProcessEvent(GenerateKey("", "", "", DALI_KEY_CURSOR_RIGHT, KEY_SHIFT_MODIFIER, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
2644   application.ProcessEvent(GenerateKey("", "", "", DALI_KEY_CURSOR_RIGHT, KEY_SHIFT_MODIFIER, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
2645   application.ProcessEvent(GenerateKey("", "", "", DALI_KEY_CURSOR_RIGHT, KEY_SHIFT_MODIFIER, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
2646
2647   // Render and notify
2648   application.SendNotification();
2649   application.Render();
2650
2651   // Test to select full text in the left of the current cursor position
2652   application.ProcessEvent(GenerateKey("", "", "", DALI_KEY_SHIFT_LEFT, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
2653   application.ProcessEvent(GenerateKey("", "", "", DALI_KEY_CURSOR_LEFT, KEY_SHIFT_MODIFIER, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
2654   application.ProcessEvent(GenerateKey("", "", "", DALI_KEY_CURSOR_LEFT, KEY_SHIFT_MODIFIER, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
2655   application.ProcessEvent(GenerateKey("", "", "", DALI_KEY_CURSOR_LEFT, KEY_SHIFT_MODIFIER, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
2656   application.ProcessEvent(GenerateKey("", "", "", DALI_KEY_CURSOR_LEFT, KEY_SHIFT_MODIFIER, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
2657   application.ProcessEvent(GenerateKey("", "", "", DALI_KEY_CURSOR_LEFT, KEY_SHIFT_MODIFIER, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
2658
2659   // Render and notify
2660   application.SendNotification();
2661   application.Render();
2662
2663   // Test to release the current full text selection
2664   application.ProcessEvent(GenerateKey("", "", "", DALI_KEY_CURSOR_LEFT, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
2665   application.ProcessEvent(GenerateKey("", "", "", DALI_KEY_CURSOR_LEFT, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
2666
2667   // Render and notify
2668   application.SendNotification();
2669   application.Render();
2670
2671   // Test to move the current cursor position correctly
2672   application.ProcessEvent(GenerateKey("", "", "", DALI_KEY_CURSOR_RIGHT, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
2673
2674   // Render and notify
2675   application.SendNotification();
2676   application.Render();
2677
2678   // Add a character
2679   application.ProcessEvent(GenerateKey("d", "", "d", KEY_D_CODE, 0, 0, Integration::KeyEvent::DOWN, "d", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
2680
2681   // Render and notify
2682   application.SendNotification();
2683   application.Render();
2684
2685   DALI_TEST_EQUALS("DdALi", editor.GetProperty<std::string>(TextEditor::Property::TEXT), TEST_LOCATION);
2686
2687   // Test to select some text in the right of the current cursor position
2688   application.ProcessEvent(GenerateKey("", "", "", DALI_KEY_SHIFT_LEFT, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
2689   application.ProcessEvent(GenerateKey("", "", "", DALI_KEY_CURSOR_RIGHT, KEY_SHIFT_MODIFIER, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
2690   application.ProcessEvent(GenerateKey("", "", "", DALI_KEY_CURSOR_RIGHT, KEY_SHIFT_MODIFIER, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
2691
2692   // Render and notify
2693   application.SendNotification();
2694   application.Render();
2695
2696   // Test the cursor position with right arrow key
2697   application.ProcessEvent(GenerateKey("", "", "", DALI_KEY_CURSOR_RIGHT, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
2698
2699   // Render and notify
2700   application.SendNotification();
2701   application.Render();
2702
2703   // Add a character
2704   application.ProcessEvent(GenerateKey("c", "", "c", KEY_C_CODE, 0, 0, Integration::KeyEvent::DOWN, "c", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
2705
2706   // Render and notify
2707   application.SendNotification();
2708   application.Render();
2709
2710   DALI_TEST_EQUALS("DdALci", editor.GetProperty<std::string>(TextEditor::Property::TEXT), TEST_LOCATION);
2711
2712   // Test to select some 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
2719   // Render and notify
2720   application.SendNotification();
2721   application.Render();
2722
2723   // Test the cursor position with left arrow key
2724   application.ProcessEvent(GenerateKey("", "", "", DALI_KEY_CURSOR_LEFT, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
2725
2726   // Render and notify
2727   application.SendNotification();
2728   application.Render();
2729
2730   // Add a character
2731   application.ProcessEvent(GenerateKey("c", "", "c", KEY_C_CODE, 0, 0, Integration::KeyEvent::DOWN, "c", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
2732
2733   // Render and notify
2734   application.SendNotification();
2735   application.Render();
2736
2737   DALI_TEST_EQUALS("DcdALci", editor.GetProperty<std::string>(TextEditor::Property::TEXT), TEST_LOCATION);
2738
2739   // Test to select some text in the right of the current cursor position
2740   application.ProcessEvent(GenerateKey("", "", "", DALI_KEY_SHIFT_LEFT, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
2741   application.ProcessEvent(GenerateKey("", "", "", DALI_KEY_CURSOR_RIGHT, KEY_SHIFT_MODIFIER, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
2742   application.ProcessEvent(GenerateKey("", "", "", DALI_KEY_CURSOR_RIGHT, KEY_SHIFT_MODIFIER, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
2743   application.ProcessEvent(GenerateKey("", "", "", DALI_KEY_CURSOR_RIGHT, KEY_SHIFT_MODIFIER, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
2744
2745   // Render and notify
2746   application.SendNotification();
2747   application.Render();
2748
2749   // Test the cursor position with left arrow key
2750   application.ProcessEvent(GenerateKey("", "", "", DALI_KEY_CURSOR_LEFT, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
2751
2752   // Render and notify
2753   application.SendNotification();
2754   application.Render();
2755
2756   // Add a character
2757   application.ProcessEvent(GenerateKey("x", "", "x", KEY_X_CODE, 0, 0, Integration::KeyEvent::DOWN, "x", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
2758
2759   // Render and notify
2760   application.SendNotification();
2761   application.Render();
2762
2763   DALI_TEST_EQUALS("DcxdALci", editor.GetProperty<std::string>(TextEditor::Property::TEXT), TEST_LOCATION);
2764
2765   // Test to select some text in the left of the current cursor position
2766   application.ProcessEvent(GenerateKey("", "", "", DALI_KEY_SHIFT_LEFT, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
2767   application.ProcessEvent(GenerateKey("", "", "", DALI_KEY_CURSOR_LEFT, KEY_SHIFT_MODIFIER, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
2768   application.ProcessEvent(GenerateKey("", "", "", DALI_KEY_CURSOR_LEFT, KEY_SHIFT_MODIFIER, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
2769   application.ProcessEvent(GenerateKey("", "", "", DALI_KEY_CURSOR_LEFT, KEY_SHIFT_MODIFIER, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
2770
2771   // Render and notify
2772   application.SendNotification();
2773   application.Render();
2774
2775   // Test the cursor position with right arrow key
2776   application.ProcessEvent(GenerateKey("", "", "", DALI_KEY_CURSOR_RIGHT, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
2777
2778   // Render and notify
2779   application.SendNotification();
2780   application.Render();
2781
2782   // Add a character
2783   application.ProcessEvent(GenerateKey("c", "", "c", KEY_C_CODE, 0, 0, Integration::KeyEvent::DOWN, "c", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
2784
2785   // Render and notify
2786   application.SendNotification();
2787   application.Render();
2788
2789   DALI_TEST_EQUALS("DcxcdALci", editor.GetProperty<std::string>(TextEditor::Property::TEXT), TEST_LOCATION);
2790
2791   END_TEST;
2792 }
2793
2794 int utcDaliTextEditorHandles(void)
2795 {
2796   ToolkitTestApplication application;
2797   tet_infoline(" utcDaliTextEditorHandles");
2798
2799   TextEditor editor = TextEditor::New();
2800   DALI_TEST_CHECK(editor);
2801
2802   application.GetScene().Add(editor);
2803
2804   editor.SetProperty(TextEditor::Property::TEXT, "This is a long text for the size of the text-editor.");
2805   editor.SetProperty(TextEditor::Property::POINT_SIZE, 10.f);
2806   editor.SetProperty(TextEditor::Property::GRAB_HANDLE_IMAGE, HANDLE_IMAGE_FILE_NAME);
2807   editor.SetProperty(TextEditor::Property::SMOOTH_SCROLL, true);
2808
2809   editor.SetProperty(TextEditor::Property::SELECTION_HANDLE_IMAGE_LEFT, Property::Map{{"filename", HANDLE_LEFT_SELECTION_FILE_NAME}});
2810   editor.SetProperty(TextEditor::Property::SELECTION_HANDLE_IMAGE_RIGHT, Property::Map{{"filename", HANDLE_LEFT_SELECTION_FILE_NAME}});
2811   editor.SetProperty(TextEditor::Property::SELECTION_HANDLE_PRESSED_IMAGE_LEFT, Property::Map{{"filename", HANDLE_RIGHT_SELECTION_FILE_NAME}});
2812   editor.SetProperty(TextEditor::Property::SELECTION_HANDLE_PRESSED_IMAGE_RIGHT, Property::Map{{"filename", HANDLE_RIGHT_SELECTION_FILE_NAME}});
2813
2814   editor.SetProperty(Actor::Property::SIZE, Vector2(30.f, 500.f));
2815   editor.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT);
2816   editor.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
2817
2818   // Avoid a crash when core load gl resources.
2819   application.GetGlAbstraction().SetCheckFramebufferStatusResult(GL_FRAMEBUFFER_COMPLETE);
2820
2821   // Render and notify
2822   application.SendNotification();
2823   application.Render();
2824
2825   // Tap first to get the focus.
2826   TestGenerateTap(application, 3.0f, 25.0f, 100);
2827
2828   // Render and notify
2829   application.SendNotification();
2830   application.Render();
2831
2832   // Tap to create the grab handle.
2833   TestGenerateTap(application, 3.0f, 25.0f, 700);
2834
2835   // Render and notify
2836   application.SendNotification();
2837   application.Render();
2838
2839   // Get the active layer where the text's decoration is added.
2840   Actor activeLayer = editor.GetChildAt(1u);
2841
2842   // Get the handle's actor.
2843   Actor handle = activeLayer.GetChildAt(0u);
2844   handle.SetProperty(Actor::Property::SIZE, Vector2(100.f, 100.f));
2845
2846   // Render and notify
2847   application.SendNotification();
2848   application.Render();
2849
2850   // Touch the grab handle to set it as pressed.
2851   Vector2                       touchPos(10.0f, 50.0f);
2852   Dali::Integration::TouchEvent event;
2853   event = Dali::Integration::TouchEvent();
2854   event.AddPoint(GetPointDownInside(touchPos));
2855   application.ProcessEvent(event);
2856
2857   // Render and notify
2858   application.SendNotification();
2859   application.Render();
2860
2861   // Pan the grab handle
2862   uint32_t time = 100;
2863   TestStartPan(application, Vector2(10.0f, 50.0f), Vector2(10.0f, 50.0f), time);
2864   TestMovePan(application, Vector2(10.0f, 30.0f), time);
2865   TestEndPan(application, Vector2(10.0f, 50.0f), time);
2866   application.SendNotification();
2867   application.Render();
2868
2869   // Release the grab handle.
2870   event = Dali::Integration::TouchEvent();
2871   event.AddPoint(GetPointUpInside(touchPos));
2872   application.ProcessEvent(event);
2873
2874   // Render and notify
2875   application.SendNotification();
2876   application.Render();
2877
2878   // Tap first to get the focus.
2879   TestGenerateTap(application, 3.0f, 25.0f, 1400);
2880
2881   // Render and notify
2882   application.SendNotification();
2883   application.Render();
2884
2885   // Double tap to select a word and create the selection handles.
2886   TestGenerateTap(application, 3.0f, 25.0f, 1500);
2887
2888   // Render and notify
2889   application.SendNotification();
2890   application.Render();
2891
2892   touchPos = Vector2(10.0f, 50.0f);
2893
2894   // Touch the left selection handle to set it as pressed.
2895   event = Dali::Integration::TouchEvent();
2896   event.AddPoint(GetPointDownInside(touchPos));
2897   application.ProcessEvent(event);
2898
2899   // Render and notify
2900   application.SendNotification();
2901   application.Render();
2902
2903   // Release the left selection handle.
2904   event = Dali::Integration::TouchEvent();
2905   event.AddPoint(GetPointUpInside(touchPos));
2906   application.ProcessEvent(event);
2907
2908   // Render and notify
2909   application.SendNotification();
2910   application.Render();
2911
2912   END_TEST;
2913 }
2914
2915 int utcDaliTextEditorUnderPropertyStringP(void)
2916 {
2917   ToolkitTestApplication application;
2918   tet_infoline(" utcDaliTextEditorUnderPropertyStringP");
2919   TextEditor editor = TextEditor::New();
2920   DALI_TEST_CHECK(editor);
2921
2922   std::string underlineSettings1("{\"enable\":\"true\",\"color\":\"red\",\"height\":\"1\",\"type\":\"SOLID\",\"dashWidth\":\"2\",\"dashGap\":\"1\"}");
2923
2924   application.GetScene().Add(editor);
2925
2926   editor.SetProperty(TextEditor::Property::UNDERLINE, underlineSettings1);
2927   DALI_TEST_EQUALS(editor.GetProperty<std::string>(TextEditor::Property::UNDERLINE), underlineSettings1, TEST_LOCATION);
2928
2929   tet_infoline("Set underline settings with a map");
2930   // Check the input underline property
2931   Property::Map underlineMapSet;
2932   Property::Map underlineMapGet;
2933   underlineMapSet.Insert("enable", true);
2934   underlineMapSet.Insert("color", Color::BLUE);
2935   underlineMapSet.Insert("height", 1);
2936   underlineMapSet.Insert("type", Text::Underline::SOLID);
2937   underlineMapSet.Insert("dashWidth", 2);
2938   underlineMapSet.Insert("dashGap", 1);
2939
2940   editor.SetProperty(TextEditor::Property::UNDERLINE, underlineMapSet);
2941   editor.SetProperty(TextEditor::Property::TEXT, "text");
2942   underlineMapGet = editor.GetProperty<Property::Map>(TextEditor::Property::UNDERLINE);
2943   DALI_TEST_EQUALS(underlineMapGet.Count(), underlineMapSet.Count(), TEST_LOCATION);
2944   DALI_TEST_EQUALS(DaliTestCheckMaps(underlineMapSet, underlineMapGet), true, TEST_LOCATION);
2945
2946   application.SendNotification();
2947   application.Render();
2948
2949   underlineMapSet.Clear();
2950   underlineMapGet.Clear();
2951
2952   tet_infoline("Set dashed underline settings with a map");
2953   // Check the input underline property
2954   underlineMapSet.Clear();
2955   underlineMapGet.Clear();
2956   underlineMapSet.Insert("enable", true);
2957   underlineMapSet.Insert("color", Color::BLUE);
2958   underlineMapSet.Insert("height", 1);
2959   underlineMapSet.Insert("type", Text::Underline::DASHED);
2960   underlineMapSet.Insert("dashWidth", 5);
2961   underlineMapSet.Insert("dashGap", 3);
2962
2963   editor.SetProperty(TextEditor::Property::UNDERLINE, underlineMapSet);
2964   editor.SetProperty(TextEditor::Property::TEXT, "text");
2965   underlineMapGet = editor.GetProperty<Property::Map>(TextEditor::Property::UNDERLINE);
2966   DALI_TEST_EQUALS(underlineMapGet.Count(), underlineMapSet.Count(), TEST_LOCATION);
2967   DALI_TEST_EQUALS(DaliTestCheckMaps(underlineMapSet, underlineMapGet), true, TEST_LOCATION);
2968
2969   // Check the input underline property
2970   underlineMapSet.Clear();
2971   underlineMapGet.Clear();
2972   underlineMapSet.Insert("enable", true);
2973   underlineMapSet.Insert("color", Color::BLUE);
2974   underlineMapSet.Insert("height", 1);
2975   underlineMapSet.Insert("type", Text::Underline::DOUBLE);
2976   underlineMapSet.Insert("dashWidth", 5);
2977   underlineMapSet.Insert("dashGap", 3);
2978
2979   editor.SetProperty(TextEditor::Property::UNDERLINE, underlineMapSet);
2980   editor.SetProperty(TextEditor::Property::TEXT, "text");
2981   underlineMapGet = editor.GetProperty<Property::Map>(TextEditor::Property::UNDERLINE);
2982   DALI_TEST_EQUALS(underlineMapGet.Count(), underlineMapSet.Count(), TEST_LOCATION);
2983   DALI_TEST_EQUALS(DaliTestCheckMaps(underlineMapSet, underlineMapGet), true, TEST_LOCATION);
2984
2985   editor.SetProperty(TextEditor::Property::UNDERLINE, underlineMapSet);
2986   editor.SetProperty(TextEditor::Property::TEXT, "text");
2987   underlineMapGet = editor.GetProperty<Property::Map>(TextEditor::Property::UNDERLINE);
2988   DALI_TEST_EQUALS(underlineMapGet.Count(), underlineMapSet.Count(), TEST_LOCATION);
2989   DALI_TEST_EQUALS(DaliTestCheckMaps(underlineMapSet, underlineMapGet), true, TEST_LOCATION);
2990
2991   application.SendNotification();
2992   application.Render();
2993
2994   underlineMapSet.Clear();
2995   underlineMapGet.Clear();
2996
2997   tet_infoline("Set underline settings with a string");
2998   editor.SetProperty(TextEditor::Property::UNDERLINE, underlineSettings1);
2999   Property::Value value = editor.GetProperty(TextEditor::Property::UNDERLINE);
3000   std::string     result;
3001   value.Get(result);
3002   DALI_TEST_EQUALS(result, underlineSettings1, TEST_LOCATION);
3003
3004   tet_infoline("Trying to set invalid underline settings, should not update and stay at previous settings");
3005   std::string underlineSettingsVoid("{\"enable\":\"true\",\"coooolor\":\"blue\",\"heeeight\":\"4\"}");
3006   editor.SetProperty(TextEditor::Property::UNDERLINE, underlineSettingsVoid);
3007   value = editor.GetProperty(TextEditor::Property::UNDERLINE);
3008   value.Get(result);
3009   DALI_TEST_EQUALS(result, underlineSettings1, TEST_LOCATION);
3010
3011   END_TEST;
3012 }
3013
3014 int utcDaliTextEditorStrikethroughPropertyStringP(void)
3015 {
3016   ToolkitTestApplication application;
3017   tet_infoline(" utcDaliTextEditorStrikethroughPropertyStringP");
3018   TextEditor editor = TextEditor::New();
3019   DALI_TEST_CHECK(editor);