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