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