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