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