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