Update double tap and long press behaviour.
[platform/core/uifw/dali-toolkit.git] / automated-tests / src / dali-toolkit / utc-Dali-TextEditor.cpp
1 /*
2  * Copyright (c) 2017 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
22 #include <dali/public-api/rendering/renderer.h>
23 #include <dali/devel-api/adaptor-framework/clipboard.h>
24 #include <dali/integration-api/events/key-event-integ.h>
25 #include <dali/integration-api/events/touch-event-integ.h>
26 #include <dali/integration-api/events/tap-gesture-event.h>
27 #include <dali/integration-api/events/pan-gesture-event.h>
28 #include <dali-toolkit-test-suite-utils.h>
29 #include <dali-toolkit/dali-toolkit.h>
30 #include <dali-toolkit/devel-api/controls/text-controls/text-editor-devel.h>
31
32 using namespace Dali;
33 using namespace Toolkit;
34
35 void dali_texteditor_startup(void)
36 {
37   test_return_value = TET_UNDEF;
38 }
39
40 void dali_texteditor_cleanup(void)
41 {
42   test_return_value = TET_PASS;
43 }
44
45 namespace
46 {
47
48 const char* const PROPERTY_NAME_RENDERING_BACKEND                    = "renderingBackend";
49 const char* const PROPERTY_NAME_TEXT                                 = "text";
50 const char* const PROPERTY_NAME_TEXT_COLOR                           = "textColor";
51 const char* const PROPERTY_NAME_FONT_FAMILY                          = "fontFamily";
52 const char* const PROPERTY_NAME_FONT_STYLE                           = "fontStyle";
53 const char* const PROPERTY_NAME_POINT_SIZE                           = "pointSize";
54 const char* const PROPERTY_NAME_HORIZONTAL_ALIGNMENT                 = "horizontalAlignment";
55 const char* const PROPERTY_NAME_SCROLL_THRESHOLD                     = "scrollThreshold";
56 const char* const PROPERTY_NAME_SCROLL_SPEED                         = "scrollSpeed";
57 const char* const PROPERTY_NAME_PRIMARY_CURSOR_COLOR                 = "primaryCursorColor";
58 const char* const PROPERTY_NAME_SECONDARY_CURSOR_COLOR               = "secondaryCursorColor";
59 const char* const PROPERTY_NAME_ENABLE_CURSOR_BLINK                  = "enableCursorBlink";
60 const char* const PROPERTY_NAME_CURSOR_BLINK_INTERVAL                = "cursorBlinkInterval";
61 const char* const PROPERTY_NAME_CURSOR_BLINK_DURATION                = "cursorBlinkDuration";
62 const char* const PROPERTY_NAME_CURSOR_WIDTH                         = "cursorWidth";
63 const char* const PROPERTY_NAME_GRAB_HANDLE_IMAGE                    = "grabHandleImage";
64 const char* const PROPERTY_NAME_GRAB_HANDLE_PRESSED_IMAGE            = "grabHandlePressedImage";
65 const char* const PROPERTY_NAME_SELECTION_HANDLE_IMAGE_LEFT          = "selectionHandleImageLeft";
66 const char* const PROPERTY_NAME_SELECTION_HANDLE_IMAGE_RIGHT         = "selectionHandleImageRight";
67 const char* const PROPERTY_NAME_SELECTION_HANDLE_PRESSED_IMAGE_LEFT  = "selectionHandlePressedImageLeft";
68 const char* const PROPERTY_NAME_SELECTION_HANDLE_PRESSED_IMAGE_RIGHT = "selectionHandlePressedImageRight";
69 const char* const PROPERTY_NAME_SELECTION_HANDLE_MARKER_IMAGE_LEFT   = "selectionHandleMarkerImageLeft";
70 const char* const PROPERTY_NAME_SELECTION_HANDLE_MARKER_IMAGE_RIGHT  = "selectionHandleMarkerImageRight";
71 const char* const PROPERTY_NAME_SELECTION_HIGHLIGHT_COLOR            = "selectionHighlightColor";
72 const char* const PROPERTY_NAME_DECORATION_BOUNDING_BOX              = "decorationBoundingBox";
73 const char* const PROPERTY_NAME_ENABLE_MARKUP                        = "enableMarkup";
74 const char* const PROPERTY_NAME_INPUT_COLOR                          = "inputColor";
75 const char* const PROPERTY_NAME_INPUT_FONT_FAMILY                    = "inputFontFamily";
76 const char* const PROPERTY_NAME_INPUT_FONT_STYLE                     = "inputFontStyle";
77 const char* const PROPERTY_NAME_INPUT_POINT_SIZE                     = "inputPointSize";
78
79 const char* const PROPERTY_NAME_LINE_SPACING                         = "lineSpacing";
80 const char* const PROPERTY_NAME_INPUT_LINE_SPACING                   = "inputLineSpacing";
81 const char* const PROPERTY_NAME_UNDERLINE                            = "underline";
82 const char* const PROPERTY_NAME_INPUT_UNDERLINE                      = "inputUnderline";
83 const char* const PROPERTY_NAME_SHADOW                               = "shadow";
84 const char* const PROPERTY_NAME_INPUT_SHADOW                         = "inputShadow";
85 const char* const PROPERTY_NAME_EMBOSS                               = "emboss";
86 const char* const PROPERTY_NAME_INPUT_EMBOSS                         = "inputEmboss";
87 const char* const PROPERTY_NAME_OUTLINE                              = "outline";
88 const char* const PROPERTY_NAME_INPUT_OUTLINE                        = "inputOutline";
89
90 const char* const PROPERTY_NAME_SMOOTH_SCROLL                        = "smoothScroll";
91 const char* const PROPERTY_NAME_SMOOTH_SCROLL_DURATION               = "smoothScrollDuration";
92 const char* const PROPERTY_NAME_ENABLE_SCROLL_BAR                    = "enableScrollBar";
93 const char* const PROPERTY_NAME_SCROLL_BAR_SHOW_DURATION             = "scrollBarShowDuration";
94 const char* const PROPERTY_NAME_SCROLL_BAR_FADE_DURATION             = "scrollBarFadeDuration";
95
96 const int DEFAULT_RENDERING_BACKEND = Dali::Toolkit::Text::DEFAULT_RENDERING_BACKEND;
97
98 const Dali::Vector4 LIGHT_BLUE( 0.75f, 0.96f, 1.f, 1.f ); // The text highlight color.
99
100 const unsigned int CURSOR_BLINK_INTERVAL = 500u; // Cursor blink interval
101 const float TO_MILLISECONDS = 1000.f;
102 const float TO_SECONDS = 1.f / TO_MILLISECONDS;
103 const float RENDER_FRAME_INTERVAL = 16.66f;
104
105 const float SCROLL_THRESHOLD = 10.f;
106 const float SCROLL_SPEED = 300.f;
107
108 const unsigned int DEFAULT_FONT_SIZE = 1152u;
109 const std::string DEFAULT_FONT_DIR( "/resources/fonts" );
110
111 const int KEY_A_CODE = 38;
112 const int KEY_D_CODE = 40;
113 const int KEY_WHITE_SPACE_CODE = 65;
114
115 const char* HANDLE_IMAGE_FILE_NAME = TEST_RESOURCE_DIR "/insertpoint-icon.png";
116
117 static bool gTextChangedCallBackCalled;
118 static bool gInputStyleChangedCallbackCalled;
119 static Dali::Toolkit::TextEditor::InputStyle::Mask gInputStyleMask;
120
121 struct CallbackFunctor
122 {
123   CallbackFunctor(bool* callbackFlag)
124   : mCallbackFlag( callbackFlag )
125   {
126   }
127
128   void operator()()
129   {
130     *mCallbackFlag = true;
131   }
132   bool* mCallbackFlag;
133 };
134
135 static void TestTextChangedCallback( TextEditor control )
136 {
137   tet_infoline(" TestTextChangedCallback");
138
139   gTextChangedCallBackCalled = true;
140 }
141
142 static void TestInputStyleChangedCallback( TextEditor control, TextEditor::InputStyle::Mask mask )
143 {
144   tet_infoline(" TestInputStyleChangedCallback");
145
146   gInputStyleChangedCallbackCalled = true;
147   gInputStyleMask = mask;
148 }
149
150 // Generate a TapGestureEvent to send to Core.
151 Integration::TapGestureEvent GenerateTap(
152     Gesture::State state,
153     unsigned int numberOfTaps,
154     unsigned int numberOfTouches,
155     Vector2 point)
156 {
157   Integration::TapGestureEvent tap( state );
158
159   tap.numberOfTaps = numberOfTaps;
160   tap.numberOfTouches = numberOfTouches;
161   tap.point = point;
162
163   return tap;
164 }
165
166 // Generate a PanGestureEvent to send to Core
167 Integration::PanGestureEvent GeneratePan( Gesture::State state,
168                                           const Vector2& previousPosition,
169                                           const Vector2& currentPosition,
170                                           unsigned long timeDelta,
171                                           unsigned int numberOfTouches = 1u )
172 {
173   Integration::PanGestureEvent pan(state);
174
175   pan.previousPosition = previousPosition;
176   pan.currentPosition = currentPosition;
177   pan.timeDelta = timeDelta;
178   pan.numberOfTouches = numberOfTouches;
179
180   return pan;
181 }
182
183 // Generate a KeyEvent to send to Core.
184 Integration::KeyEvent GenerateKey( const std::string& keyName,
185                                    const std::string& keyString,
186                                    int keyCode,
187                                    int keyModifier,
188                                    unsigned long timeStamp,
189                                    const Integration::KeyEvent::State& keyState )
190 {
191   return Integration::KeyEvent( keyName,
192                                 keyString,
193                                 keyCode,
194                                 keyModifier,
195                                 timeStamp,
196                                 keyState );
197 }
198
199 /**
200  * Helper to generate PanGestureEvent
201  *
202  * @param[in] application Application instance
203  * @param[in] state The Gesture State
204  * @param[in] pos The current position of touch.
205  */
206 static void SendPan(ToolkitTestApplication& application, Gesture::State state, const Vector2& pos)
207 {
208   static Vector2 last;
209
210   if( (state == Gesture::Started) ||
211       (state == Gesture::Possible) )
212   {
213     last.x = pos.x;
214     last.y = pos.y;
215   }
216
217   application.ProcessEvent( GeneratePan( state, last, pos, 16 ) );
218
219   last.x = pos.x;
220   last.y = pos.y;
221 }
222
223 /*
224  * Simulate time passed by.
225  *
226  * @note this will always process at least 1 frame (1/60 sec)
227  *
228  * @param application Test application instance
229  * @param duration Time to pass in milliseconds.
230  * @return The actual time passed in milliseconds
231  */
232 static int Wait(ToolkitTestApplication& application, int duration = 0)
233 {
234   int time = 0;
235
236   for(int i = 0; i <= ( duration / RENDER_FRAME_INTERVAL); i++)
237   {
238     application.SendNotification();
239     application.Render(RENDER_FRAME_INTERVAL);
240     time += RENDER_FRAME_INTERVAL;
241   }
242
243   return time;
244 }
245
246 Dali::Integration::Point GetPointDownInside( Vector2& pos )
247 {
248   Dali::Integration::Point point;
249   point.SetState( PointState::DOWN );
250   point.SetScreenPosition( pos );
251   return point;
252 }
253
254 Dali::Integration::Point GetPointUpInside( Vector2& pos )
255 {
256   Dali::Integration::Point point;
257   point.SetState( PointState::UP );
258   point.SetScreenPosition( pos );
259   return point;
260 }
261
262 bool DaliTestCheckMaps( const Property::Map& fontStyleMapGet, const Property::Map& fontStyleMapSet )
263 {
264   if( fontStyleMapGet.Count() == fontStyleMapSet.Count() )
265   {
266     for( unsigned int index = 0u; index < fontStyleMapGet.Count(); ++index )
267     {
268       const KeyValuePair& valueGet = fontStyleMapGet.GetKeyValue( index );
269
270       Property::Value* valueSet = fontStyleMapSet.Find( valueGet.first.stringKey );
271       if( NULL != valueSet )
272       {
273         if( valueGet.second.Get<std::string>() != valueSet->Get<std::string>() )
274         {
275           tet_printf( "  Value got : [%s], expected : [%s]", valueGet.second.Get<std::string>().c_str(), valueSet->Get<std::string>().c_str() );
276           return false;
277         }
278       }
279       else
280       {
281         tet_printf( "  The key %s doesn't exist.", valueGet.first.stringKey.c_str() );
282         return false;
283       }
284     }
285   }
286
287   return true;
288 }
289
290 } // namespace
291
292 int UtcDaliToolkitTextEditorConstructorP(void)
293 {
294   ToolkitTestApplication application;
295   tet_infoline(" UtcDaliToolkitTextEditorConstructorP");
296   TextEditor textEditor;
297   DALI_TEST_CHECK( !textEditor );
298   END_TEST;
299 }
300
301 int UtcDaliToolkitTextEditorNewP(void)
302 {
303   ToolkitTestApplication application;
304   tet_infoline(" UtcDaliToolkitTextEditorNewP");
305   TextEditor textEditor = TextEditor::New();
306   DALI_TEST_CHECK( textEditor );
307   END_TEST;
308 }
309
310 int UtcDaliToolkitTextEditorDownCastP(void)
311 {
312   ToolkitTestApplication application;
313   tet_infoline(" UtcDaliToolkitTextEditorDownCastP");
314   TextEditor textEditor1 = TextEditor::New();
315   BaseHandle object( textEditor1 );
316
317   TextEditor textEditor2 = TextEditor::DownCast( object );
318   DALI_TEST_CHECK( textEditor2 );
319
320   TextEditor textEditor3 = DownCast< TextEditor >( object );
321   DALI_TEST_CHECK( textEditor3 );
322   END_TEST;
323 }
324
325 int UtcDaliToolkitTextEditorDownCastN(void)
326 {
327   ToolkitTestApplication application;
328   tet_infoline(" UtcDaliToolkitTextEditorDownCastN");
329   BaseHandle uninitializedObject;
330   TextEditor textEditor1 = TextEditor::DownCast( uninitializedObject );
331   DALI_TEST_CHECK( !textEditor1 );
332
333   TextEditor textEditor2 = DownCast< TextEditor >( uninitializedObject );
334   DALI_TEST_CHECK( !textEditor2 );
335   END_TEST;
336 }
337
338 int UtcDaliToolkitTextEditorCopyConstructorP(void)
339 {
340   ToolkitTestApplication application;
341   tet_infoline(" UtcDaliToolkitTextEditorCopyConstructorP");
342   TextEditor textEditor = TextEditor::New();
343   textEditor.SetProperty( TextEditor::Property::TEXT, "Test" );
344
345   TextEditor copy( textEditor );
346   DALI_TEST_CHECK( copy );
347   DALI_TEST_CHECK( copy.GetProperty<std::string>( TextEditor::Property::TEXT ) == textEditor.GetProperty<std::string>( TextEditor::Property::TEXT ) );
348   END_TEST;
349 }
350
351 int UtcDaliToolkitTextEditorAssignmentOperatorP(void)
352 {
353   ToolkitTestApplication application;
354   tet_infoline(" UtcDaliToolkitTextEditorAssignmentOperatorP");
355   TextEditor textEditor = TextEditor::New();
356   textEditor.SetProperty( TextEditor::Property::TEXT, "Test" );
357
358   TextEditor copy = textEditor;
359   DALI_TEST_CHECK( copy );
360   DALI_TEST_CHECK( copy.GetProperty<std::string>( TextEditor::Property::TEXT ) == textEditor.GetProperty<std::string>( TextEditor::Property::TEXT ) );
361   END_TEST;
362 }
363
364 int UtcDaliTextEditorNewP(void)
365 {
366   ToolkitTestApplication application;
367   tet_infoline(" UtcDaliToolkitTextEditorNewP");
368   TextEditor textEditor = TextEditor::New();
369   DALI_TEST_CHECK( textEditor );
370   END_TEST;
371 }
372
373 // Positive test case for a method
374 int UtcDaliTextEditorGetPropertyP(void)
375 {
376   ToolkitTestApplication application;
377   tet_infoline(" UtcDaliToolkitTextEditorGetPropertyP");
378   TextEditor editor = TextEditor::New();
379   DALI_TEST_CHECK( editor );
380
381   // Check Property Indices are correct
382   DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_RENDERING_BACKEND ) == TextEditor::Property::RENDERING_BACKEND );
383   DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_TEXT ) == TextEditor::Property::TEXT );
384   DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_TEXT_COLOR ) == TextEditor::Property::TEXT_COLOR );
385   DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_FONT_FAMILY ) == TextEditor::Property::FONT_FAMILY );
386   DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_FONT_STYLE ) == TextEditor::Property::FONT_STYLE );
387   DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_POINT_SIZE ) == TextEditor::Property::POINT_SIZE );
388   DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_HORIZONTAL_ALIGNMENT ) == TextEditor::Property::HORIZONTAL_ALIGNMENT );
389   DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_SCROLL_THRESHOLD ) == TextEditor::Property::SCROLL_THRESHOLD );
390   DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_SCROLL_SPEED ) == TextEditor::Property::SCROLL_SPEED );
391   DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_PRIMARY_CURSOR_COLOR ) == TextEditor::Property::PRIMARY_CURSOR_COLOR );
392   DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_SECONDARY_CURSOR_COLOR ) == TextEditor::Property::SECONDARY_CURSOR_COLOR );
393   DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_ENABLE_CURSOR_BLINK ) == TextEditor::Property::ENABLE_CURSOR_BLINK );
394   DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_CURSOR_BLINK_INTERVAL ) == TextEditor::Property::CURSOR_BLINK_INTERVAL );
395   DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_CURSOR_BLINK_DURATION ) == TextEditor::Property::CURSOR_BLINK_DURATION );
396   DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_CURSOR_WIDTH ) == TextEditor::Property::CURSOR_WIDTH );
397   DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_GRAB_HANDLE_IMAGE ) == TextEditor::Property::GRAB_HANDLE_IMAGE );
398   DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_GRAB_HANDLE_PRESSED_IMAGE ) == TextEditor::Property::GRAB_HANDLE_PRESSED_IMAGE );
399   DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_SELECTION_HANDLE_IMAGE_LEFT ) == TextEditor::Property::SELECTION_HANDLE_IMAGE_LEFT );
400   DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_SELECTION_HANDLE_IMAGE_RIGHT ) == TextEditor::Property::SELECTION_HANDLE_IMAGE_RIGHT );
401   DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_SELECTION_HANDLE_PRESSED_IMAGE_LEFT ) == TextEditor::Property::SELECTION_HANDLE_PRESSED_IMAGE_LEFT );
402   DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_SELECTION_HANDLE_PRESSED_IMAGE_RIGHT ) == TextEditor::Property::SELECTION_HANDLE_PRESSED_IMAGE_RIGHT );
403   DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_SELECTION_HANDLE_MARKER_IMAGE_LEFT ) == TextEditor::Property::SELECTION_HANDLE_MARKER_IMAGE_LEFT );
404   DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_SELECTION_HANDLE_MARKER_IMAGE_RIGHT ) == TextEditor::Property::SELECTION_HANDLE_MARKER_IMAGE_RIGHT );
405   DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_SELECTION_HIGHLIGHT_COLOR ) == TextEditor::Property::SELECTION_HIGHLIGHT_COLOR );
406   DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_DECORATION_BOUNDING_BOX ) == TextEditor::Property::DECORATION_BOUNDING_BOX );
407   DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_ENABLE_MARKUP ) == TextEditor::Property::ENABLE_MARKUP );
408   DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_INPUT_COLOR ) == TextEditor::Property::INPUT_COLOR );
409   DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_INPUT_FONT_FAMILY ) == TextEditor::Property::INPUT_FONT_FAMILY );
410   DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_INPUT_FONT_STYLE ) == TextEditor::Property::INPUT_FONT_STYLE );
411   DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_INPUT_POINT_SIZE ) == TextEditor::Property::INPUT_POINT_SIZE );
412
413   DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_LINE_SPACING ) == TextEditor::Property::LINE_SPACING );
414   DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_INPUT_LINE_SPACING ) == TextEditor::Property::INPUT_LINE_SPACING );
415   DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_UNDERLINE ) == TextEditor::Property::UNDERLINE );
416   DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_INPUT_UNDERLINE ) == TextEditor::Property::INPUT_UNDERLINE );
417   DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_SHADOW ) == TextEditor::Property::SHADOW );
418   DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_INPUT_SHADOW ) == TextEditor::Property::INPUT_SHADOW );
419   DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_EMBOSS ) == TextEditor::Property::EMBOSS );
420   DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_INPUT_EMBOSS ) == TextEditor::Property::INPUT_EMBOSS );
421   DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_OUTLINE ) == TextEditor::Property::OUTLINE );
422   DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_INPUT_OUTLINE ) == TextEditor::Property::INPUT_OUTLINE );
423   DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_SMOOTH_SCROLL ) == DevelTextEditor::Property::SMOOTH_SCROLL );
424   DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_SMOOTH_SCROLL_DURATION ) == DevelTextEditor::Property::SMOOTH_SCROLL_DURATION );
425   DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_ENABLE_SCROLL_BAR ) == DevelTextEditor::Property::ENABLE_SCROLL_BAR );
426   DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_SCROLL_BAR_SHOW_DURATION ) == DevelTextEditor::Property::SCROLL_BAR_SHOW_DURATION );
427   DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_SCROLL_BAR_FADE_DURATION ) == DevelTextEditor::Property::SCROLL_BAR_FADE_DURATION );
428
429   END_TEST;
430 }
431
432 bool SetPropertyMapRetrieved( TextEditor& editor, const Property::Index property, const std::string mapKey, const std::string mapValue )
433 {
434   bool result = false;
435   Property::Map imageMap;
436   imageMap[mapKey] =mapValue;
437
438   editor.SetProperty( property , imageMap );
439   Property::Value propValue = editor.GetProperty( property );
440   Property::Map* resultMap = propValue.GetMap();
441
442   if ( resultMap->Find( mapKey )->Get< std::string>() == mapValue )
443   {
444     result = true;
445   }
446
447   return result;
448 }
449
450 // Positive test case for a method
451 int UtcDaliTextEditorSetPropertyP(void)
452 {
453   ToolkitTestApplication application;
454   tet_infoline(" UtcDaliToolkitTextEditorSetPropertyP");
455   TextEditor editor = TextEditor::New();
456   DALI_TEST_CHECK( editor );
457   Stage::GetCurrent().Add( editor );
458
459   // Note - we can't check the defaults since the stylesheets are platform-specific
460
461   // Check the render backend property.
462   editor.SetProperty( TextEditor::Property::RENDERING_BACKEND, Text::RENDERING_SHARED_ATLAS );
463   DALI_TEST_EQUALS( (Text::RenderingType)editor.GetProperty<int>( TextEditor::Property::RENDERING_BACKEND ), Text::RENDERING_SHARED_ATLAS, TEST_LOCATION );
464
465   // Check text property.
466   editor.SetProperty( TextEditor::Property::TEXT, "Setting Text" );
467   DALI_TEST_EQUALS( editor.GetProperty<std::string>( TextEditor::Property::TEXT ), std::string("Setting Text"), TEST_LOCATION );
468
469   // Check text's color property
470   editor.SetProperty( TextEditor::Property::TEXT_COLOR, Color::WHITE );
471   DALI_TEST_EQUALS( editor.GetProperty<Vector4>( TextEditor::Property::TEXT_COLOR ), Color::WHITE, TEST_LOCATION );
472
473   // Check font properties.
474   editor.SetProperty( TextEditor::Property::FONT_FAMILY, "Setting font family" );
475   DALI_TEST_EQUALS( editor.GetProperty<std::string>( TextEditor::Property::FONT_FAMILY ), std::string("Setting font family"), TEST_LOCATION );
476
477   Property::Map fontStyleMapSet;
478   Property::Map fontStyleMapGet;
479   Property::Value* slantValue = NULL;
480
481   fontStyleMapSet.Insert( "weight", "bold" );
482   fontStyleMapSet.Insert( "width", "condensed" );
483   fontStyleMapSet.Insert( "slant", "italic" );
484
485   editor.SetProperty( TextEditor::Property::FONT_STYLE, fontStyleMapSet );
486   fontStyleMapGet = editor.GetProperty<Property::Map>( TextEditor::Property::FONT_STYLE );
487   DALI_TEST_EQUALS( fontStyleMapGet.Count(), fontStyleMapSet.Count(), TEST_LOCATION );
488   DALI_TEST_EQUALS( DaliTestCheckMaps( fontStyleMapGet, fontStyleMapSet ), true, TEST_LOCATION );
489
490   editor.SetProperty( TextEditor::Property::POINT_SIZE, 10.f );
491   DALI_TEST_EQUALS( editor.GetProperty<float>( TextEditor::Property::POINT_SIZE ), 10.f, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
492
493   // Reset font style.
494   fontStyleMapSet.Clear();
495   fontStyleMapSet.Insert( "weight", "normal" );
496   fontStyleMapSet.Insert( "slant", "oblique" );
497   editor.SetProperty( TextEditor::Property::FONT_STYLE, fontStyleMapSet );
498   fontStyleMapGet = editor.GetProperty<Property::Map>( TextEditor::Property::FONT_STYLE );
499   DALI_TEST_EQUALS( fontStyleMapGet.Count(), fontStyleMapSet.Count(), TEST_LOCATION );
500   DALI_TEST_EQUALS( DaliTestCheckMaps( fontStyleMapGet, fontStyleMapSet ), true, TEST_LOCATION );
501
502   fontStyleMapSet.Clear();
503   fontStyleMapSet.Insert( "slant", "roman" );
504   editor.SetProperty( TextEditor::Property::FONT_STYLE, fontStyleMapSet );
505   fontStyleMapGet = editor.GetProperty<Property::Map>( TextEditor::Property::FONT_STYLE );
506
507   // Replace 'roman' for 'normal'.
508   slantValue = fontStyleMapGet.Find( "slant" );
509   if( NULL != slantValue )
510   {
511     if( "normal" == slantValue->Get<std::string>() )
512     {
513       fontStyleMapGet["slant"] = "roman";
514     }
515   }
516   DALI_TEST_EQUALS( fontStyleMapGet.Count(), fontStyleMapSet.Count(), TEST_LOCATION );
517   DALI_TEST_EQUALS( DaliTestCheckMaps( fontStyleMapGet, fontStyleMapSet ), true, TEST_LOCATION );
518
519   fontStyleMapSet.Clear();
520
521   editor.SetProperty( TextEditor::Property::FONT_STYLE, fontStyleMapSet );
522   fontStyleMapGet = editor.GetProperty<Property::Map>( TextEditor::Property::FONT_STYLE );
523   DALI_TEST_EQUALS( fontStyleMapGet.Count(), fontStyleMapSet.Count(), TEST_LOCATION );
524   DALI_TEST_EQUALS( DaliTestCheckMaps( fontStyleMapGet, fontStyleMapSet ), true, TEST_LOCATION );
525
526   // Check that the Alignment properties can be correctly set
527   editor.SetProperty( TextEditor::Property::HORIZONTAL_ALIGNMENT, "END" );
528   DALI_TEST_EQUALS( editor.GetProperty<std::string>( TextEditor::Property::HORIZONTAL_ALIGNMENT ), "END", TEST_LOCATION );
529
530   // Check scroll properties.
531   editor.SetProperty( TextEditor::Property::SCROLL_THRESHOLD, 1.f );
532   DALI_TEST_EQUALS( editor.GetProperty<float>( TextEditor::Property::SCROLL_THRESHOLD ), 1.f, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
533   editor.SetProperty( TextEditor::Property::SCROLL_SPEED, 100.f );
534   DALI_TEST_EQUALS( editor.GetProperty<float>( TextEditor::Property::SCROLL_SPEED ), 100.f, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
535
536   // Check cursor properties
537   editor.SetProperty( TextEditor::Property::PRIMARY_CURSOR_COLOR, Color::RED );
538   DALI_TEST_EQUALS( editor.GetProperty<Vector4>( TextEditor::Property::PRIMARY_CURSOR_COLOR ), Color::RED, TEST_LOCATION );
539   editor.SetProperty( TextEditor::Property::SECONDARY_CURSOR_COLOR, Color::BLUE );
540   DALI_TEST_EQUALS( editor.GetProperty<Vector4>( TextEditor::Property::SECONDARY_CURSOR_COLOR ), Color::BLUE, TEST_LOCATION );
541
542   editor.SetProperty( TextEditor::Property::ENABLE_CURSOR_BLINK, false );
543   DALI_TEST_EQUALS( editor.GetProperty<bool>( TextEditor::Property::ENABLE_CURSOR_BLINK ), false, TEST_LOCATION );
544   editor.SetProperty( TextEditor::Property::CURSOR_BLINK_INTERVAL, 1.f );
545   DALI_TEST_EQUALS( editor.GetProperty<float>( TextEditor::Property::CURSOR_BLINK_INTERVAL ), 1.f, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
546   editor.SetProperty( TextEditor::Property::CURSOR_BLINK_DURATION, 10.f );
547   DALI_TEST_EQUALS( editor.GetProperty<float>( TextEditor::Property::CURSOR_BLINK_DURATION ), 10.f, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
548   editor.SetProperty( TextEditor::Property::CURSOR_WIDTH, 1 );
549   DALI_TEST_EQUALS( editor.GetProperty<int>( TextEditor::Property::CURSOR_WIDTH ), 1, TEST_LOCATION );
550
551   // Check handle images
552   editor.SetProperty( TextEditor::Property::GRAB_HANDLE_IMAGE, "image1" );
553   DALI_TEST_EQUALS( editor.GetProperty<std::string>( TextEditor::Property::GRAB_HANDLE_IMAGE ), "image1", TEST_LOCATION );
554   editor.SetProperty( TextEditor::Property::GRAB_HANDLE_PRESSED_IMAGE, "image2" );
555   DALI_TEST_EQUALS( editor.GetProperty<std::string>( TextEditor::Property::GRAB_HANDLE_PRESSED_IMAGE ), "image2", TEST_LOCATION );
556   editor.SetProperty( TextEditor::Property::SELECTION_HANDLE_IMAGE_LEFT, "image3" );
557
558   // Check handle images
559   DALI_TEST_CHECK( SetPropertyMapRetrieved( editor, TextEditor::Property::SELECTION_HANDLE_IMAGE_LEFT, "filename", "leftHandleImage" )  );
560   DALI_TEST_CHECK( SetPropertyMapRetrieved( editor, TextEditor::Property::SELECTION_HANDLE_IMAGE_RIGHT, "filename", "rightHandleImage" )  );
561   DALI_TEST_CHECK( SetPropertyMapRetrieved( editor, TextEditor::Property::SELECTION_HANDLE_PRESSED_IMAGE_LEFT, "filename", "leftHandleImagePressed" )  );
562   DALI_TEST_CHECK( SetPropertyMapRetrieved( editor, TextEditor::Property::SELECTION_HANDLE_PRESSED_IMAGE_RIGHT, "filename", "rightHandleImagePressed" )  );
563   DALI_TEST_CHECK( SetPropertyMapRetrieved( editor, TextEditor::Property::SELECTION_HANDLE_MARKER_IMAGE_LEFT, "filename", "leftHandleMarkerImage" )  );
564   DALI_TEST_CHECK( SetPropertyMapRetrieved( editor, TextEditor::Property::SELECTION_HANDLE_MARKER_IMAGE_RIGHT, "filename", "rightHandleMarkerImage" )  );
565
566   // Check the highlight color
567   editor.SetProperty( TextEditor::Property::SELECTION_HIGHLIGHT_COLOR, Color::GREEN );
568   DALI_TEST_EQUALS( editor.GetProperty<Vector4>( TextEditor::Property::SELECTION_HIGHLIGHT_COLOR ), Color::GREEN, TEST_LOCATION );
569
570   // Decoration bounding box
571   editor.SetProperty( TextEditor::Property::DECORATION_BOUNDING_BOX, Rect<int>( 0, 0, 1, 1 ) );
572   DALI_TEST_EQUALS( editor.GetProperty<Rect <int > >( TextEditor::Property::DECORATION_BOUNDING_BOX ), Rect<int>( 0, 0, 1, 1 ), TEST_LOCATION );
573
574   // Check the enable markup property.
575   DALI_TEST_CHECK( !editor.GetProperty<bool>( TextEditor::Property::ENABLE_MARKUP ) );
576   editor.SetProperty( TextEditor::Property::ENABLE_MARKUP, true );
577   DALI_TEST_CHECK( editor.GetProperty<bool>( TextEditor::Property::ENABLE_MARKUP ) );
578
579   // Check input color property.
580   editor.SetProperty( TextEditor::Property::INPUT_COLOR, Color::YELLOW );
581   DALI_TEST_EQUALS( editor.GetProperty<Vector4>( TextEditor::Property::INPUT_COLOR ), Color::YELLOW, TEST_LOCATION );
582
583   // Check input font properties.
584   editor.SetProperty( TextEditor::Property::INPUT_FONT_FAMILY, "Setting input font family" );
585   DALI_TEST_EQUALS( editor.GetProperty<std::string>( TextEditor::Property::INPUT_FONT_FAMILY ), "Setting input font family", TEST_LOCATION );
586
587   fontStyleMapSet.Clear();
588   fontStyleMapSet.Insert( "weight", "bold" );
589   fontStyleMapSet.Insert( "width", "condensed" );
590   fontStyleMapSet.Insert( "slant", "italic" );
591
592   editor.SetProperty( TextEditor::Property::INPUT_FONT_STYLE, fontStyleMapSet );
593   fontStyleMapGet = editor.GetProperty<Property::Map>( TextEditor::Property::INPUT_FONT_STYLE );
594   DALI_TEST_EQUALS( fontStyleMapGet.Count(), fontStyleMapSet.Count(), TEST_LOCATION );
595   DALI_TEST_EQUALS( DaliTestCheckMaps( fontStyleMapGet, fontStyleMapSet ), true, TEST_LOCATION );
596
597   editor.SetProperty( TextEditor::Property::INPUT_POINT_SIZE, 12.f );
598   DALI_TEST_EQUALS( editor.GetProperty<float>( TextEditor::Property::INPUT_POINT_SIZE ), 12.f, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
599
600   // Reset input font style.
601   fontStyleMapSet.Clear();
602   fontStyleMapSet.Insert( "weight", "normal" );
603   fontStyleMapSet.Insert( "slant", "oblique" );
604
605   editor.SetProperty( TextEditor::Property::INPUT_FONT_STYLE, fontStyleMapSet );
606   fontStyleMapGet = editor.GetProperty<Property::Map>( TextEditor::Property::INPUT_FONT_STYLE );
607   DALI_TEST_EQUALS( fontStyleMapGet.Count(), fontStyleMapSet.Count(), TEST_LOCATION );
608   DALI_TEST_EQUALS( DaliTestCheckMaps( fontStyleMapGet, fontStyleMapSet ), true, TEST_LOCATION );
609
610   fontStyleMapSet.Clear();
611   fontStyleMapSet.Insert( "slant", "roman" );
612
613   editor.SetProperty( TextEditor::Property::INPUT_FONT_STYLE, fontStyleMapSet );
614   fontStyleMapGet = editor.GetProperty<Property::Map>( TextEditor::Property::INPUT_FONT_STYLE );
615
616   // Replace 'roman' for 'normal'.
617   slantValue = fontStyleMapGet.Find( "slant" );
618   if( NULL != slantValue )
619   {
620     if( "normal" == slantValue->Get<std::string>() )
621     {
622       fontStyleMapGet["slant"] = "roman";
623     }
624   }
625   DALI_TEST_EQUALS( fontStyleMapGet.Count(), fontStyleMapSet.Count(), TEST_LOCATION );
626   DALI_TEST_EQUALS( DaliTestCheckMaps( fontStyleMapGet, fontStyleMapSet ), true, TEST_LOCATION );
627
628   fontStyleMapSet.Clear();
629
630   editor.SetProperty( TextEditor::Property::INPUT_FONT_STYLE, fontStyleMapSet );
631   fontStyleMapGet = editor.GetProperty<Property::Map>( TextEditor::Property::INPUT_FONT_STYLE );
632   DALI_TEST_EQUALS( fontStyleMapGet.Count(), fontStyleMapSet.Count(), TEST_LOCATION );
633   DALI_TEST_EQUALS( DaliTestCheckMaps( fontStyleMapGet, fontStyleMapSet ), true, TEST_LOCATION );
634
635   // Check the line spacing property
636   DALI_TEST_EQUALS( editor.GetProperty<float>( TextEditor::Property::LINE_SPACING ), 0.0f, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
637   editor.SetProperty( TextEditor::Property::LINE_SPACING, 10.f );
638   DALI_TEST_EQUALS( editor.GetProperty<float>( TextEditor::Property::LINE_SPACING ), 10.0f, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
639
640   // Check the input line spacing property
641   DALI_TEST_EQUALS( editor.GetProperty<float>( TextEditor::Property::INPUT_LINE_SPACING ), 0.0f, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
642   editor.SetProperty( TextEditor::Property::INPUT_LINE_SPACING, 20.f );
643   DALI_TEST_EQUALS( editor.GetProperty<float>( TextEditor::Property::INPUT_LINE_SPACING ), 20.0f, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
644
645   // Check the underline property
646
647   Property::Map underlineMapSet;
648   Property::Map underlineMapGet;
649
650   underlineMapSet.Insert( "enable", "true" );
651   underlineMapSet.Insert( "color", "red" );
652   underlineMapSet.Insert( "height", "1" );
653
654   editor.SetProperty( TextEditor::Property::UNDERLINE, underlineMapSet );
655
656   underlineMapGet = editor.GetProperty<Property::Map>( TextEditor::Property::UNDERLINE );
657   DALI_TEST_EQUALS( underlineMapGet.Count(), underlineMapSet.Count(), TEST_LOCATION );
658   DALI_TEST_EQUALS( DaliTestCheckMaps( underlineMapGet, underlineMapSet ), true, TEST_LOCATION );
659
660   // Check the input underline property
661   editor.SetProperty( TextEditor::Property::INPUT_UNDERLINE, "Underline input properties" );
662   DALI_TEST_EQUALS( editor.GetProperty<std::string>( TextEditor::Property::INPUT_UNDERLINE ), std::string("Underline input properties"), TEST_LOCATION );
663
664   // Check the shadow property
665   Property::Map shadowMapSet;
666   Property::Map shadowMapGet;
667
668   shadowMapSet.Insert( "color", "green" );
669   shadowMapSet.Insert( "offset", "2 2" );
670
671   editor.SetProperty( TextEditor::Property::SHADOW, shadowMapSet );
672
673   shadowMapGet = editor.GetProperty<Property::Map>( TextEditor::Property::SHADOW );
674   DALI_TEST_EQUALS( shadowMapGet.Count(), shadowMapSet.Count(), TEST_LOCATION );
675   DALI_TEST_EQUALS( DaliTestCheckMaps( shadowMapGet, shadowMapSet ), true, TEST_LOCATION );
676
677   // Check the input shadow property
678   editor.SetProperty( TextEditor::Property::INPUT_SHADOW, "Shadow input properties" );
679   DALI_TEST_EQUALS( editor.GetProperty<std::string>( TextEditor::Property::INPUT_SHADOW ), std::string("Shadow input properties"), TEST_LOCATION );
680
681   // Check the emboss property
682   editor.SetProperty( TextEditor::Property::EMBOSS, "Emboss properties" );
683   DALI_TEST_EQUALS( editor.GetProperty<std::string>( TextEditor::Property::EMBOSS ), std::string("Emboss properties"), TEST_LOCATION );
684
685   // Check the input emboss property
686   editor.SetProperty( TextEditor::Property::INPUT_EMBOSS, "Emboss input properties" );
687   DALI_TEST_EQUALS( editor.GetProperty<std::string>( TextEditor::Property::INPUT_EMBOSS ), std::string("Emboss input properties"), TEST_LOCATION );
688
689   // Check the outline property
690   editor.SetProperty( TextEditor::Property::OUTLINE, "Outline properties" );
691   DALI_TEST_EQUALS( editor.GetProperty<std::string>( TextEditor::Property::OUTLINE ), std::string("Outline properties"), TEST_LOCATION );
692
693   // Check the input outline property
694   editor.SetProperty( TextEditor::Property::INPUT_OUTLINE, "Outline input properties" );
695   DALI_TEST_EQUALS( editor.GetProperty<std::string>( TextEditor::Property::INPUT_OUTLINE ), std::string("Outline input properties"), TEST_LOCATION );
696
697   // Check the smooth scroll property
698   DALI_TEST_EQUALS( editor.GetProperty<bool>( DevelTextEditor::Property::SMOOTH_SCROLL ), false, TEST_LOCATION );
699   editor.SetProperty( DevelTextEditor::Property::SMOOTH_SCROLL, true );
700   DALI_TEST_EQUALS( editor.GetProperty<bool>( DevelTextEditor::Property::SMOOTH_SCROLL ), true, TEST_LOCATION );
701
702   // Check the smooth scroll duration property
703   editor.SetProperty( DevelTextEditor::Property::SMOOTH_SCROLL_DURATION, 0.2f );
704   DALI_TEST_EQUALS( editor.GetProperty<float>( DevelTextEditor::Property::SMOOTH_SCROLL_DURATION ), 0.2f, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
705
706   // Check the scroll bar property
707   DALI_TEST_EQUALS( editor.GetProperty<bool>( DevelTextEditor::Property::ENABLE_SCROLL_BAR ), false, TEST_LOCATION );
708   editor.SetProperty( DevelTextEditor::Property::ENABLE_SCROLL_BAR, true );
709   DALI_TEST_EQUALS( editor.GetProperty<bool>( DevelTextEditor::Property::ENABLE_SCROLL_BAR ), true, TEST_LOCATION );
710
711   editor.SetProperty( DevelTextEditor::Property::SCROLL_BAR_SHOW_DURATION, 0.3f );
712   DALI_TEST_EQUALS( editor.GetProperty<float>( DevelTextEditor::Property::SCROLL_BAR_SHOW_DURATION ), 0.3f, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
713   editor.SetProperty( DevelTextEditor::Property::SCROLL_BAR_FADE_DURATION, 0.2f );
714   DALI_TEST_EQUALS( editor.GetProperty<float>( DevelTextEditor::Property::SCROLL_BAR_FADE_DURATION ), 0.2f, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
715
716   END_TEST;
717 }
718
719 // Positive Atlas Text Renderer test
720 int utcDaliTextEditorAtlasRenderP(void)
721 {
722   ToolkitTestApplication application;
723   tet_infoline(" UtcDaliToolkitTextEditorAtlasRenderP");
724   StyleManager styleManager = StyleManager::Get();
725   styleManager.ApplyDefaultTheme();
726   TextEditor editor = TextEditor::New();
727   DALI_TEST_CHECK( editor );
728
729   editor.SetProperty( TextEditor::Property::HORIZONTAL_ALIGNMENT, "CENTER" );
730
731   application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
732
733   Stage::GetCurrent().Add( editor );
734
735   try
736   {
737     // Render some text with the shared atlas backend
738     editor.SetProperty( TextEditor::Property::RENDERING_BACKEND, Text::RENDERING_SHARED_ATLAS );
739     application.SendNotification();
740     application.Render();
741   }
742   catch( ... )
743   {
744     tet_result(TET_FAIL);
745   }
746   END_TEST;
747 }
748
749 // Positive test for the textChanged signal.
750 int utcDaliTextEditorTextChangedP(void)
751 {
752   ToolkitTestApplication application;
753   tet_infoline(" utcDaliTextEditorTextChangedP");
754   TextEditor editor = TextEditor::New();
755   DALI_TEST_CHECK( editor );
756
757   Stage::GetCurrent().Add( editor );
758
759   // connect to the text changed signal.
760   ConnectionTracker* testTracker = new ConnectionTracker();
761   editor.TextChangedSignal().Connect( &TestTextChangedCallback );
762   bool textChangedSignal = false;
763   editor.ConnectSignal( testTracker, "textChanged",   CallbackFunctor(&textChangedSignal) );
764
765   gTextChangedCallBackCalled = false;
766   editor.SetProperty( TextEditor::Property::TEXT, "ABC" );
767   DALI_TEST_CHECK( gTextChangedCallBackCalled );
768   DALI_TEST_CHECK( textChangedSignal );
769
770   application.SendNotification();
771
772   editor.SetKeyInputFocus();
773
774   gTextChangedCallBackCalled = false;
775   application.ProcessEvent( GenerateKey( "D", "D", KEY_D_CODE, 0, 0, Integration::KeyEvent::Down ) );
776   DALI_TEST_CHECK( gTextChangedCallBackCalled );
777
778   END_TEST;
779 }
780
781 int utcDaliTextEditorInputStyleChanged01(void)
782 {
783   ToolkitTestApplication application;
784   tet_infoline(" utcDaliTextEditorInputStyleChanged01");
785
786   // The text-editor emits signals when the input style changes. These changes of style are
787   // detected during the relayout process (size negotiation), i.e after the cursor has been moved. Signals
788   // can't be emitted during the size negotiation as the callbacks may update the UI.
789   // The text-editor adds an idle callback to the adaptor to emit the signals after the size negotiation.
790   // This creates an implementation of the adaptor stub and a queue of idle callbacks.
791   application.CreateAdaptor();
792
793   // Load some fonts.
794
795   char* pathNamePtr = get_current_dir_name();
796   const std::string pathName( pathNamePtr );
797   free( pathNamePtr );
798
799   TextAbstraction::FontClient fontClient = TextAbstraction::FontClient::Get();
800   fontClient.SetDpi( 93u, 93u );
801
802   fontClient.GetFontId( pathName + DEFAULT_FONT_DIR + "/dejavu/DejaVuSerif.ttf", DEFAULT_FONT_SIZE );
803   fontClient.GetFontId( pathName + DEFAULT_FONT_DIR + "/dejavu/DejaVuSerif-Bold.ttf", DEFAULT_FONT_SIZE );
804
805   TextEditor editor = TextEditor::New();
806   DALI_TEST_CHECK( editor );
807
808
809   editor.SetSize( 300.f, 50.f );
810   editor.SetParentOrigin( ParentOrigin::TOP_LEFT );
811   editor.SetAnchorPoint( AnchorPoint::TOP_LEFT );
812
813   editor.SetProperty( TextEditor::Property::ENABLE_MARKUP, true );
814   editor.SetProperty( TextEditor::Property::TEXT, "<font family='DejaVuSerif' size='18'>He<color value='green'>llo</color> <font weight='bold'>world</font> demo</font>" );
815
816   // connect to the text changed signal.
817   ConnectionTracker* testTracker = new ConnectionTracker();
818   editor.InputStyleChangedSignal().Connect( &TestInputStyleChangedCallback );
819   bool inputStyleChangedSignal = false;
820   editor.ConnectSignal( testTracker, "inputStyleChanged",   CallbackFunctor(&inputStyleChangedSignal) );
821
822   Stage::GetCurrent().Add( editor );
823
824   // Render and notify
825   application.SendNotification();
826   application.Render();
827
828   // Executes the idle callbacks added by the text control on the change of input style.
829   application.RunIdles();
830
831   gInputStyleChangedCallbackCalled = false;
832   gInputStyleMask = TextEditor::InputStyle::NONE;
833   inputStyleChangedSignal = false;
834
835   // Create a tap event to touch the text editor.
836   application.ProcessEvent( GenerateTap( Gesture::Possible, 1u, 1u, Vector2( 18.f, 25.f ) ) );
837   application.ProcessEvent( GenerateTap( Gesture::Started, 1u, 1u, Vector2( 18.f, 25.f ) ) );
838
839   // Render and notify
840   application.SendNotification();
841   application.Render();
842
843   // Executes the idle callbacks added by the text control on the change of input style.
844   application.RunIdles();
845
846   DALI_TEST_CHECK( gInputStyleChangedCallbackCalled );
847   if( gInputStyleChangedCallbackCalled )
848   {
849     DALI_TEST_EQUALS( static_cast<unsigned int>( gInputStyleMask ), static_cast<unsigned int>( TextEditor::InputStyle::FONT_FAMILY | TextEditor::InputStyle::POINT_SIZE ), TEST_LOCATION );
850
851     const std::string fontFamily = editor.GetProperty( TextEditor::Property::INPUT_FONT_FAMILY ).Get<std::string>();
852     DALI_TEST_EQUALS( fontFamily, "DejaVuSerif", TEST_LOCATION );
853
854     const float pointSize = editor.GetProperty( TextEditor::Property::INPUT_POINT_SIZE ).Get<float>();
855     DALI_TEST_EQUALS( pointSize, 18.f, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
856   }
857   DALI_TEST_CHECK( inputStyleChangedSignal );
858
859   gInputStyleChangedCallbackCalled = false;
860   gInputStyleMask = TextEditor::InputStyle::NONE;
861   inputStyleChangedSignal = false;
862
863   // Create a tap event to touch the text editor.
864   application.ProcessEvent( GenerateTap( Gesture::Possible, 1u, 1u, Vector2( 30.f, 25.f ) ) );
865   application.ProcessEvent( GenerateTap( Gesture::Started, 1u, 1u, Vector2( 30.f, 25.f ) ) );
866
867   // Render and notify
868   application.SendNotification();
869   application.Render();
870
871   // Executes the idle callbacks added by the text control on the change of input style.
872   application.RunIdles();
873
874   DALI_TEST_CHECK( !gInputStyleChangedCallbackCalled );
875   DALI_TEST_CHECK( !inputStyleChangedSignal );
876
877   gInputStyleChangedCallbackCalled = false;
878   gInputStyleMask = TextEditor::InputStyle::NONE;
879   inputStyleChangedSignal = false;
880
881   // Create a tap event to touch the text editor.
882   application.ProcessEvent( GenerateTap( Gesture::Possible, 1u, 1u, Vector2( 43.f, 25.f ) ) );
883   application.ProcessEvent( GenerateTap( Gesture::Started, 1u, 1u, Vector2( 43.f, 25.f ) ) );
884
885   // Render and notify
886   application.SendNotification();
887   application.Render();
888
889   // Executes the idle callbacks added by the text control on the change of input style.
890   application.RunIdles();
891
892   DALI_TEST_CHECK( gInputStyleChangedCallbackCalled );
893   if( gInputStyleChangedCallbackCalled )
894   {
895     DALI_TEST_EQUALS( static_cast<unsigned int>( gInputStyleMask ), static_cast<unsigned int>( TextEditor::InputStyle::COLOR ), TEST_LOCATION );
896
897     const Vector4 color = editor.GetProperty( TextEditor::Property::INPUT_COLOR ).Get<Vector4>();
898     DALI_TEST_EQUALS( color, Color::GREEN, TEST_LOCATION );
899   }
900   DALI_TEST_CHECK( inputStyleChangedSignal );
901
902   gInputStyleChangedCallbackCalled = false;
903   gInputStyleMask = TextEditor::InputStyle::NONE;
904   inputStyleChangedSignal = false;
905
906   // Create a tap event to touch the text editor.
907   application.ProcessEvent( GenerateTap( Gesture::Possible, 1u, 1u, Vector2( 88.f, 25.f ) ) );
908   application.ProcessEvent( GenerateTap( Gesture::Started, 1u, 1u, Vector2( 88.f, 25.f ) ) );
909
910   // Render and notify
911   application.SendNotification();
912   application.Render();
913
914   // Executes the idle callbacks added by the text control on the change of input style.
915   application.RunIdles();
916
917   DALI_TEST_CHECK( gInputStyleChangedCallbackCalled );
918   if( gInputStyleChangedCallbackCalled )
919   {
920     DALI_TEST_EQUALS( static_cast<unsigned int>( gInputStyleMask ), static_cast<unsigned int>( TextEditor::InputStyle::COLOR | TextEditor::InputStyle::FONT_STYLE ), TEST_LOCATION );
921
922     const Vector4 color = editor.GetProperty( TextEditor::Property::INPUT_COLOR ).Get<Vector4>();
923     DALI_TEST_EQUALS( color, Color::BLACK, TEST_LOCATION );
924
925     Property::Map fontStyleMapSet;
926     Property::Map fontStyleMapGet;
927
928     fontStyleMapSet.Insert( "weight", "bold" );
929
930     fontStyleMapGet = editor.GetProperty<Property::Map>( TextEditor::Property::INPUT_FONT_STYLE );
931     DALI_TEST_EQUALS( fontStyleMapGet.Count(), fontStyleMapSet.Count(), TEST_LOCATION );
932     DALI_TEST_EQUALS( DaliTestCheckMaps( fontStyleMapGet, fontStyleMapSet ), true, TEST_LOCATION );
933   }
934   DALI_TEST_CHECK( inputStyleChangedSignal );
935
936   gInputStyleChangedCallbackCalled = false;
937   gInputStyleMask = TextEditor::InputStyle::NONE;
938   inputStyleChangedSignal = false;
939
940   // Create a tap event to touch the text editor.
941   application.ProcessEvent( GenerateTap( Gesture::Possible, 1u, 1u, Vector2( 115.f, 25.f ) ) );
942   application.ProcessEvent( GenerateTap( Gesture::Started, 1u, 1u, Vector2( 115.f, 25.f ) ) );
943
944   // Render and notify
945   application.SendNotification();
946   application.Render();
947
948   // Executes the idle callbacks added by the text control on the change of input style.
949   application.RunIdles();
950
951   DALI_TEST_CHECK( !gInputStyleChangedCallbackCalled );
952   DALI_TEST_CHECK( !inputStyleChangedSignal );
953
954   gInputStyleChangedCallbackCalled = false;
955   gInputStyleMask = TextEditor::InputStyle::NONE;
956   inputStyleChangedSignal = false;
957
958   // Create a tap event to touch the text editor.
959   application.ProcessEvent( GenerateTap( Gesture::Possible, 1u, 1u, Vector2( 164.f, 25.f ) ) );
960   application.ProcessEvent( GenerateTap( Gesture::Started, 1u, 1u, Vector2( 164.f, 25.f ) ) );
961
962   // Render and notify
963   application.SendNotification();
964   application.Render();
965
966   // Executes the idle callbacks added by the text control on the change of input style.
967   application.RunIdles();
968
969   DALI_TEST_CHECK( gInputStyleChangedCallbackCalled );
970   if( gInputStyleChangedCallbackCalled )
971   {
972     DALI_TEST_EQUALS( static_cast<unsigned int>( gInputStyleMask ), static_cast<unsigned int>( TextEditor::InputStyle::FONT_STYLE ), TEST_LOCATION );
973
974     Property::Map fontStyleMapSet;
975     Property::Map fontStyleMapGet;
976
977     fontStyleMapGet = editor.GetProperty<Property::Map>( TextEditor::Property::INPUT_FONT_STYLE );
978     DALI_TEST_EQUALS( fontStyleMapGet.Count(), fontStyleMapSet.Count(), TEST_LOCATION );
979     DALI_TEST_EQUALS( DaliTestCheckMaps( fontStyleMapGet, fontStyleMapSet ), true, TEST_LOCATION );
980   }
981   DALI_TEST_CHECK( inputStyleChangedSignal );
982
983   gInputStyleChangedCallbackCalled = false;
984   gInputStyleMask = TextEditor::InputStyle::NONE;
985   inputStyleChangedSignal = false;
986
987   // Create a tap event to touch the text editor.
988   application.ProcessEvent( GenerateTap( Gesture::Possible, 1u, 1u, Vector2( 191.f, 25.f ) ) );
989   application.ProcessEvent( GenerateTap( Gesture::Started, 1u, 1u, Vector2( 191.f, 25.f ) ) );
990
991   // Render and notify
992   application.SendNotification();
993   application.Render();
994
995   // Executes the idle callbacks added by the text control on the change of input style.
996   application.RunIdles();
997
998   DALI_TEST_CHECK( !gInputStyleChangedCallbackCalled );
999   DALI_TEST_CHECK( !inputStyleChangedSignal );
1000
1001   END_TEST;
1002 }
1003
1004 int utcDaliTextEditorInputStyleChanged02(void)
1005 {
1006   ToolkitTestApplication application;
1007   tet_infoline(" utcDaliTextEditorInputStyleChanged02");
1008
1009   // The text-editor emits signals when the input style changes. These changes of style are
1010   // detected during the relayout process (size negotiation), i.e after the cursor has been moved. Signals
1011   // can't be emitted during the size negotiation as the callbacks may update the UI.
1012   // The text-editor adds an idle callback to the adaptor to emit the signals after the size negotiation.
1013   // This creates an implementation of the adaptor stub and a queue of idle callbacks.
1014   application.CreateAdaptor();
1015
1016   // Load some fonts.
1017
1018   char* pathNamePtr = get_current_dir_name();
1019   const std::string pathName( pathNamePtr );
1020   free( pathNamePtr );
1021
1022   TextAbstraction::FontClient fontClient = TextAbstraction::FontClient::Get();
1023   fontClient.SetDpi( 93u, 93u );
1024
1025   fontClient.GetFontId( pathName + DEFAULT_FONT_DIR + "/dejavu/DejaVuSerif.ttf", DEFAULT_FONT_SIZE );
1026   fontClient.GetFontId( pathName + DEFAULT_FONT_DIR + "/dejavu/DejaVuSerif-Bold.ttf", DEFAULT_FONT_SIZE );
1027
1028   TextEditor editor = TextEditor::New();
1029   DALI_TEST_CHECK( editor );
1030
1031
1032   editor.SetSize( 300.f, 50.f );
1033   editor.SetParentOrigin( ParentOrigin::TOP_LEFT );
1034   editor.SetAnchorPoint( AnchorPoint::TOP_LEFT );
1035
1036   editor.SetProperty( TextEditor::Property::ENABLE_MARKUP, true );
1037   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>" );
1038
1039   // connect to the text changed signal.
1040   ConnectionTracker* testTracker = new ConnectionTracker();
1041   editor.InputStyleChangedSignal().Connect( &TestInputStyleChangedCallback );
1042   bool inputStyleChangedSignal = false;
1043   editor.ConnectSignal( testTracker, "inputStyleChanged",   CallbackFunctor(&inputStyleChangedSignal) );
1044
1045   Stage::GetCurrent().Add( editor );
1046
1047   // Render and notify
1048   application.SendNotification();
1049   application.Render();
1050
1051   // Executes the idle callbacks added by the text control on the change of input style.
1052   application.RunIdles();
1053
1054   gInputStyleChangedCallbackCalled = false;
1055   gInputStyleMask = TextEditor::InputStyle::NONE;
1056   inputStyleChangedSignal = false;
1057
1058   // Create a tap event to touch the text editor.
1059   application.ProcessEvent( GenerateTap( Gesture::Possible, 1u, 1u, Vector2( 53.f, 25.f ) ) );
1060   application.ProcessEvent( GenerateTap( Gesture::Started, 1u, 1u, Vector2( 53.f, 25.f ) ) );
1061   application.ProcessEvent( GenerateTap( Gesture::Possible, 2u, 1u, Vector2( 53.f, 25.f ) ) );
1062   application.ProcessEvent( GenerateTap( Gesture::Started, 2u, 1u, Vector2( 53.f, 25.f ) ) );
1063
1064   // Render and notify
1065   application.SendNotification();
1066   application.Render();
1067
1068   // Executes the idle callbacks added by the text control on the change of input style.
1069   application.RunIdles();
1070
1071   DALI_TEST_CHECK( gInputStyleChangedCallbackCalled );
1072   if( gInputStyleChangedCallbackCalled )
1073   {
1074     DALI_TEST_EQUALS( static_cast<unsigned int>( gInputStyleMask ),
1075                       static_cast<unsigned int>( TextEditor::InputStyle::FONT_FAMILY |
1076                                                  TextEditor::InputStyle::POINT_SIZE  |
1077                                                  TextEditor::InputStyle::COLOR ),
1078                       TEST_LOCATION );
1079
1080     const Vector4 color = editor.GetProperty( TextEditor::Property::INPUT_COLOR ).Get<Vector4>();
1081     DALI_TEST_EQUALS( color, Color::GREEN, TEST_LOCATION );
1082
1083     const std::string fontFamily = editor.GetProperty( TextEditor::Property::INPUT_FONT_FAMILY ).Get<std::string>();
1084     DALI_TEST_EQUALS( fontFamily, "DejaVuSerif", TEST_LOCATION );
1085
1086     const float pointSize = editor.GetProperty( TextEditor::Property::INPUT_POINT_SIZE ).Get<float>();
1087     DALI_TEST_EQUALS( pointSize, 18.f, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
1088   }
1089   DALI_TEST_CHECK( inputStyleChangedSignal );
1090
1091   gInputStyleChangedCallbackCalled = false;
1092   gInputStyleMask = TextEditor::InputStyle::NONE;
1093   inputStyleChangedSignal = false;
1094
1095   application.ProcessEvent( GenerateKey( "", "", DALI_KEY_BACKSPACE, 0, 0, Integration::KeyEvent::Down ) );
1096
1097   // Render and notify
1098   application.SendNotification();
1099   application.Render();
1100
1101   // Executes the idle callbacks added by the text control on the change of input style.
1102   application.RunIdles();
1103
1104   DALI_TEST_CHECK( gInputStyleChangedCallbackCalled );
1105   if( gInputStyleChangedCallbackCalled )
1106   {
1107     DALI_TEST_EQUALS( static_cast<unsigned int>( gInputStyleMask ),
1108                       static_cast<unsigned int>( TextEditor::InputStyle::COLOR ),
1109                       TEST_LOCATION );
1110
1111     const Vector4 color = editor.GetProperty( TextEditor::Property::INPUT_COLOR ).Get<Vector4>();
1112     DALI_TEST_EQUALS( color, Color::BLUE, TEST_LOCATION );
1113   }
1114   DALI_TEST_CHECK( inputStyleChangedSignal );
1115
1116   gInputStyleChangedCallbackCalled = false;
1117   gInputStyleMask = TextEditor::InputStyle::NONE;
1118   inputStyleChangedSignal = false;
1119
1120   application.ProcessEvent( GenerateKey( "", "", DALI_KEY_BACKSPACE, 0, 0, Integration::KeyEvent::Down ) );
1121
1122   // Render and notify
1123   application.SendNotification();
1124   application.Render();
1125
1126   // Executes the idle callbacks added by the text control on the change of input style.
1127   application.RunIdles();
1128
1129   DALI_TEST_CHECK( !gInputStyleChangedCallbackCalled );
1130   DALI_TEST_CHECK( !inputStyleChangedSignal );
1131
1132   gInputStyleChangedCallbackCalled = false;
1133   gInputStyleMask = TextEditor::InputStyle::NONE;
1134   inputStyleChangedSignal = false;
1135
1136   application.ProcessEvent( GenerateKey( "", "", DALI_KEY_BACKSPACE, 0, 0, Integration::KeyEvent::Down ) );
1137
1138   // Render and notify
1139   application.SendNotification();
1140   application.Render();
1141
1142   // Executes the idle callbacks added by the text control on the change of input style.
1143   application.RunIdles();
1144
1145   DALI_TEST_CHECK( gInputStyleChangedCallbackCalled );
1146   if( gInputStyleChangedCallbackCalled )
1147   {
1148     DALI_TEST_EQUALS( static_cast<unsigned int>( gInputStyleMask ),
1149                       static_cast<unsigned int>( TextEditor::InputStyle::COLOR ),
1150                       TEST_LOCATION );
1151
1152     const Vector4 color = editor.GetProperty( TextEditor::Property::INPUT_COLOR ).Get<Vector4>();
1153     DALI_TEST_EQUALS( color, Color::BLACK, TEST_LOCATION );
1154   }
1155   DALI_TEST_CHECK( inputStyleChangedSignal );
1156
1157   gInputStyleChangedCallbackCalled = false;
1158   gInputStyleMask = TextEditor::InputStyle::NONE;
1159   inputStyleChangedSignal = false;
1160
1161   editor.SetProperty( TextEditor::Property::INPUT_COLOR, Color::YELLOW );
1162
1163   Property::Map fontStyleMapSet;
1164   fontStyleMapSet.Insert( "weight", "thin" );
1165   fontStyleMapSet.Insert( "width", "condensed" );
1166   fontStyleMapSet.Insert( "slant", "italic" );
1167
1168   editor.SetProperty( TextEditor::Property::INPUT_FONT_STYLE, fontStyleMapSet );
1169   editor.SetProperty( TextEditor::Property::INPUT_POINT_SIZE, 20.f );
1170   editor.SetProperty( TextEditor::Property::INPUT_LINE_SPACING, 5.f );
1171
1172   editor.SetProperty( TextEditor::Property::INPUT_UNDERLINE, "underline" );
1173   editor.SetProperty( TextEditor::Property::INPUT_SHADOW, "shadow" );
1174   editor.SetProperty( TextEditor::Property::INPUT_EMBOSS, "emboss" );
1175   editor.SetProperty( TextEditor::Property::INPUT_OUTLINE, "outline" );
1176
1177   application.ProcessEvent( GenerateKey( "a", "a", KEY_A_CODE, 0, 0, Integration::KeyEvent::Down ) );
1178
1179   // Render and notify
1180   application.SendNotification();
1181   application.Render();
1182
1183   // Executes the idle callbacks added by the text control on the change of input style.
1184   application.RunIdles();
1185
1186   DALI_TEST_CHECK( !gInputStyleChangedCallbackCalled );
1187   DALI_TEST_CHECK( !inputStyleChangedSignal );
1188
1189   // Create a tap event to touch the text editor.
1190   application.ProcessEvent( GenerateTap( Gesture::Possible, 1u, 1u, Vector2( 63.f, 25.f ) ) );
1191   application.ProcessEvent( GenerateTap( Gesture::Started, 1u, 1u, Vector2( 63.f, 25.f ) ) );
1192
1193   // Render and notify
1194   application.SendNotification();
1195   application.Render();
1196
1197   // Executes the idle callbacks added by the text control on the change of input style.
1198   application.RunIdles();
1199
1200   DALI_TEST_CHECK( gInputStyleChangedCallbackCalled );
1201   if( gInputStyleChangedCallbackCalled )
1202   {
1203     DALI_TEST_EQUALS( static_cast<unsigned int>( gInputStyleMask ),
1204                       static_cast<unsigned int>( TextEditor::InputStyle::COLOR |
1205                                                  TextEditor::InputStyle::POINT_SIZE |
1206                                                  TextEditor::InputStyle::FONT_STYLE |
1207                                                  TextEditor::InputStyle::LINE_SPACING |
1208                                                  TextEditor::InputStyle::UNDERLINE |
1209                                                  TextEditor::InputStyle::SHADOW |
1210                                                  TextEditor::InputStyle::EMBOSS |
1211                                                  TextEditor::InputStyle::OUTLINE ),
1212                       TEST_LOCATION );
1213
1214     const Vector4 color = editor.GetProperty( TextEditor::Property::INPUT_COLOR ).Get<Vector4>();
1215     DALI_TEST_EQUALS( color, Color::BLACK, TEST_LOCATION );
1216   }
1217   DALI_TEST_CHECK( inputStyleChangedSignal );
1218
1219   gInputStyleChangedCallbackCalled = false;
1220   gInputStyleMask = TextEditor::InputStyle::NONE;
1221   inputStyleChangedSignal = false;
1222
1223   editor.SetProperty( TextEditor::Property::FONT_FAMILY, "DejaVuSerif" );
1224
1225   fontStyleMapSet.Clear();
1226   fontStyleMapSet.Insert( "weight", "black" );
1227   fontStyleMapSet.Insert( "width", "expanded" );
1228   fontStyleMapSet.Insert( "slant", "oblique" );
1229
1230   editor.SetProperty( TextEditor::Property::FONT_STYLE, fontStyleMapSet );
1231
1232   // Create a tap event to touch the text editor.
1233   application.ProcessEvent( GenerateTap( Gesture::Possible, 1u, 1u, Vector2( 30.f, 25.f ) ) );
1234   application.ProcessEvent( GenerateTap( Gesture::Started, 1u, 1u, Vector2( 30.f, 25.f ) ) );
1235
1236   // Render and notify
1237   application.SendNotification();
1238   application.Render();
1239
1240   // Executes the idle callbacks added by the text control on the change of input style.
1241   application.RunIdles();
1242
1243   DALI_TEST_CHECK( gInputStyleChangedCallbackCalled );
1244   if( gInputStyleChangedCallbackCalled )
1245   {
1246     DALI_TEST_EQUALS( static_cast<unsigned int>( gInputStyleMask ),
1247                       static_cast<unsigned int>( TextEditor::InputStyle::COLOR |
1248                                                  TextEditor::InputStyle::POINT_SIZE |
1249                                                  TextEditor::InputStyle::FONT_STYLE ),
1250                       TEST_LOCATION );
1251
1252     const Vector4 color = editor.GetProperty( TextEditor::Property::INPUT_COLOR ).Get<Vector4>();
1253     DALI_TEST_EQUALS( color, Color::YELLOW, TEST_LOCATION );
1254   }
1255   DALI_TEST_CHECK( inputStyleChangedSignal );
1256
1257   END_TEST;
1258 }
1259
1260 int utcDaliTextEditorEvent01(void)
1261 {
1262   ToolkitTestApplication application;
1263   tet_infoline(" utcDaliTextEditorEvent01");
1264
1265   // Creates a tap event. After creating a tap event the text editor should
1266   // have the focus and add text with key events should be possible.
1267
1268   TextEditor editor = TextEditor::New();
1269   DALI_TEST_CHECK( editor );
1270
1271   Stage::GetCurrent().Add( editor );
1272
1273   editor.SetSize( 300.f, 50.f );
1274   editor.SetParentOrigin( ParentOrigin::TOP_LEFT );
1275   editor.SetAnchorPoint( AnchorPoint::TOP_LEFT );
1276
1277   // Avoid a crash when core load gl resources.
1278   application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
1279
1280   // Render and notify
1281   application.SendNotification();
1282   application.Render();
1283
1284   // Add a key event but as the text editor has not the focus it should do nothing.
1285   application.ProcessEvent( GenerateKey( "a", "a", KEY_A_CODE, 0, 0, Integration::KeyEvent::Down ) );
1286
1287   // Render and notify
1288   application.SendNotification();
1289   application.Render();
1290
1291   DALI_TEST_EQUALS( editor.GetProperty<std::string>( TextEditor::Property::TEXT ), std::string(""), TEST_LOCATION );
1292
1293   // Create a tap event to touch the text editor.
1294   application.ProcessEvent( GenerateTap( Gesture::Possible, 1u, 1u, Vector2( 150.0f, 25.0f ) ) );
1295   application.ProcessEvent( GenerateTap( Gesture::Started, 1u, 1u, Vector2( 150.0f, 25.0f ) ) );
1296
1297   // Render and notify
1298   application.SendNotification();
1299   application.Render();
1300
1301   // Now the text editor has the focus, so it can handle the key events.
1302   application.ProcessEvent( GenerateKey( "a", "a", KEY_A_CODE, 0, 0, Integration::KeyEvent::Down ) );
1303   application.ProcessEvent( GenerateKey( "a", "a", KEY_A_CODE, 0, 0, Integration::KeyEvent::Down ) );
1304
1305   // Render and notify
1306   application.SendNotification();
1307   application.Render();
1308
1309   DALI_TEST_EQUALS( editor.GetProperty<std::string>( TextEditor::Property::TEXT ), std::string("aa"), TEST_LOCATION );
1310
1311   // Create a second text editor and send key events to it.
1312   TextEditor editor2 = TextEditor::New();
1313
1314   editor2.SetParentOrigin( ParentOrigin::TOP_LEFT );
1315   editor2.SetAnchorPoint( AnchorPoint::TOP_LEFT );
1316   editor2.SetSize( 100.f, 100.f );
1317   editor2.SetPosition( 100.f, 100.f );
1318
1319   Stage::GetCurrent().Add( editor2 );
1320
1321   // Render and notify
1322   application.SendNotification();
1323   application.Render();
1324
1325   // Create a tap event on the second text editor.
1326   application.ProcessEvent( GenerateTap( Gesture::Possible, 1u, 1u, Vector2( 150.0f, 125.0f ) ) );
1327   application.ProcessEvent( GenerateTap( Gesture::Started, 1u, 1u, Vector2( 150.0f, 125.0f ) ) );
1328
1329   // Render and notify
1330   application.SendNotification();
1331   application.Render();
1332
1333   // The second text editor has the focus. It should handle the key events.
1334   application.ProcessEvent( GenerateKey( "a", "a", KEY_A_CODE, 0, 0, Integration::KeyEvent::Down ) );
1335   application.ProcessEvent( GenerateKey( "a", "a", KEY_A_CODE, 0, 0, Integration::KeyEvent::Down ) );
1336
1337   // Render and notify
1338   application.SendNotification();
1339   application.Render();
1340
1341   // Check the text has been added to the second text editor.
1342   DALI_TEST_EQUALS( editor2.GetProperty<std::string>( TextEditor::Property::TEXT ), std::string("aa"), TEST_LOCATION );
1343
1344   END_TEST;
1345 }
1346
1347 int utcDaliTextEditorEvent02(void)
1348 {
1349   ToolkitTestApplication application;
1350   tet_infoline(" utcDaliTextEditorEvent02");
1351
1352   // Checks if the right number of actors are created.
1353
1354   TextEditor editor = TextEditor::New();
1355   editor.SetProperty( TextEditor::Property::POINT_SIZE, 10.f );
1356   DALI_TEST_CHECK( editor );
1357
1358   Stage::GetCurrent().Add( editor );
1359
1360   editor.SetSize( 300.f, 50.f );
1361   editor.SetParentOrigin( ParentOrigin::TOP_LEFT );
1362   editor.SetAnchorPoint( AnchorPoint::TOP_LEFT );
1363
1364   // Avoid a crash when core load gl resources.
1365   application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
1366
1367   // Render and notify
1368   application.SendNotification();
1369   application.Render();
1370
1371   // Check there are the expected number of children (the stencil).
1372   DALI_TEST_EQUALS( editor.GetChildCount(), 1u, TEST_LOCATION );
1373
1374   Actor stencil = editor.GetChildAt( 0u );
1375
1376   // Create a tap event to touch the text editor.
1377   application.ProcessEvent( GenerateTap( Gesture::Possible, 1u, 1u, Vector2( 150.0f, 25.0f ) ) );
1378   application.ProcessEvent( GenerateTap( Gesture::Started, 1u, 1u, Vector2( 150.0f, 25.0f ) ) );
1379
1380   // Render and notify
1381   application.SendNotification();
1382   application.Render();
1383
1384   Actor layer = editor.GetChildAt( 1u );
1385   DALI_TEST_CHECK( layer.IsLayer() );
1386
1387   DALI_TEST_EQUALS( layer.GetChildCount(), 1u, TEST_LOCATION ); // The cursor.
1388   DALI_TEST_EQUALS( stencil.GetChildCount(), 0u, TEST_LOCATION );
1389
1390   // Now the text editor has the focus, so it can handle the key events.
1391   application.ProcessEvent( GenerateKey( "a", "a", KEY_A_CODE, 0, 0, Integration::KeyEvent::Down ) );
1392   application.ProcessEvent( GenerateKey( "a", "a", KEY_A_CODE, 0, 0, Integration::KeyEvent::Down ) );
1393
1394   // Render and notify
1395   application.SendNotification();
1396   application.Render();
1397
1398   // Checks the cursor and the renderer have been created.
1399   DALI_TEST_EQUALS( layer.GetChildCount(), 1u, TEST_LOCATION ); // The cursor.
1400   DALI_TEST_EQUALS( stencil.GetChildCount(), 1u, TEST_LOCATION ); // The renderer
1401
1402   Control cursor = Control::DownCast( layer.GetChildAt( 0u ) );
1403   DALI_TEST_CHECK( cursor );
1404
1405   // The stencil actor has a container with all the actors which contain the text renderers.
1406   Actor container = stencil.GetChildAt( 0u );
1407   for( unsigned int index = 0; index < container.GetChildCount(); ++index )
1408   {
1409     Renderer renderer = container.GetChildAt( index ).GetRendererAt( 0u );
1410     DALI_TEST_CHECK( renderer );
1411   }
1412
1413   // Move the cursor and check the position changes.
1414   Vector3 position1 = cursor.GetCurrentPosition();
1415
1416   application.ProcessEvent( GenerateKey( "", "", DALI_KEY_CURSOR_LEFT, 0, 0, Integration::KeyEvent::Down ) );
1417   application.ProcessEvent( GenerateKey( "", "", DALI_KEY_CURSOR_LEFT, 0, 0, Integration::KeyEvent::Down ) );
1418
1419   // Render and notify
1420   application.SendNotification();
1421   application.Render();
1422
1423   Vector3 position2 = cursor.GetCurrentPosition();
1424
1425   DALI_TEST_CHECK( position2.x < position1.x );
1426
1427   application.ProcessEvent( GenerateKey( "", "", DALI_KEY_CURSOR_RIGHT, 0, 0, Integration::KeyEvent::Down ) );
1428   application.ProcessEvent( GenerateKey( "", "", DALI_KEY_CURSOR_RIGHT, 0, 0, Integration::KeyEvent::Down ) );
1429
1430   // Render and notify
1431   application.SendNotification();
1432   application.Render();
1433
1434   Vector3 position3 = cursor.GetCurrentPosition();
1435
1436   DALI_TEST_EQUALS( position1, position3, TEST_LOCATION ); // Should be in the same position1.
1437
1438   // Send some taps and check the cursor positions.
1439
1440   // Try to tap at the beginning.
1441   application.ProcessEvent( GenerateTap( Gesture::Possible, 1u, 1u, Vector2( 1.f, 25.0f ) ) );
1442   application.ProcessEvent( GenerateTap( Gesture::Started, 1u, 1u, Vector2( 1.f, 25.0f ) ) );
1443
1444   // Render and notify
1445   application.SendNotification();
1446   application.Render();
1447
1448   // Cursor position should be the same than position1.
1449   Vector3 position4 = cursor.GetCurrentPosition();
1450
1451   DALI_TEST_EQUALS( position2, position4, TEST_LOCATION ); // Should be in the same position2.
1452
1453   // Tap away from the start position.
1454   application.ProcessEvent( GenerateTap( Gesture::Possible, 1u, 1u, Vector2( 16.f, 25.0f ) ) );
1455   application.ProcessEvent( GenerateTap( Gesture::Started, 1u, 1u, Vector2( 16.0f, 25.0f ) ) );
1456
1457   // Render and notify
1458   application.SendNotification();
1459   application.Render();
1460
1461   Vector3 position5 = cursor.GetCurrentPosition();
1462
1463   DALI_TEST_CHECK( position5.x > position4.x );
1464
1465   // Remove all the text.
1466   application.ProcessEvent( GenerateKey( "", "", DALI_KEY_BACKSPACE, 0, 0, Integration::KeyEvent::Down ) );
1467   application.ProcessEvent( GenerateKey( "", "", DALI_KEY_BACKSPACE, 0, 0, Integration::KeyEvent::Down ) );
1468   editor.SetProperty( TextEditor::Property::TEXT, "" );
1469
1470   // Render and notify
1471   application.SendNotification();
1472   application.Render();
1473
1474   // Cursor position should be the same than position2.
1475   Vector3 position6 = cursor.GetCurrentPosition();
1476
1477   DALI_TEST_EQUALS( position2, position6, TEST_LOCATION );// Should be in the same position2.
1478
1479   // Should not be a renderer.
1480   DALI_TEST_EQUALS( stencil.GetChildCount(), 0u, TEST_LOCATION );
1481
1482   END_TEST;
1483 }
1484
1485 int utcDaliTextEditorEvent03(void)
1486 {
1487   ToolkitTestApplication application;
1488   tet_infoline(" utcDaliTextEditorEvent03");
1489
1490   // Checks if the highlight actor is created.
1491
1492   TextEditor editor = TextEditor::New();
1493   DALI_TEST_CHECK( editor );
1494
1495   Stage::GetCurrent().Add( editor );
1496
1497   editor.SetProperty( TextEditor::Property::TEXT, "This is a long text for the size of the text-editor." );
1498   editor.SetProperty( TextEditor::Property::POINT_SIZE, 10.f );
1499   editor.SetSize( 30.f, 50.f );
1500   editor.SetParentOrigin( ParentOrigin::TOP_LEFT );
1501   editor.SetAnchorPoint( AnchorPoint::TOP_LEFT );
1502
1503   // Avoid a crash when core load gl resources.
1504   application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
1505
1506   // Render and notify
1507   application.SendNotification();
1508   application.Render();
1509
1510   // Send some taps and check text controller with clipboard window
1511   Dali::Clipboard clipboard = Clipboard::Get();
1512   clipboard.ShowClipboard();
1513   application.ProcessEvent( GenerateTap( Gesture::Possible, 1u, 1u, Vector2( 3.f, 25.0f ) ) );
1514   application.ProcessEvent( GenerateTap( Gesture::Started, 1u, 1u, Vector2( 3.f, 25.0f ) ) );
1515   clipboard.HideClipboard();
1516
1517   // Render and notify
1518   application.SendNotification();
1519   application.Render();
1520
1521   // Tap first to get the focus.
1522   application.ProcessEvent( GenerateTap( Gesture::Possible, 1u, 1u, Vector2( 3.f, 25.0f ) ) );
1523   application.ProcessEvent( GenerateTap( Gesture::Started, 1u, 1u, Vector2( 3.f, 25.0f ) ) );
1524
1525   // Render and notify
1526   application.SendNotification();
1527   application.Render();
1528
1529   // Double tap to select a word.
1530   application.ProcessEvent( GenerateTap( Gesture::Possible, 2u, 1u, Vector2( 3.f, 25.0f ) ) );
1531   application.ProcessEvent( GenerateTap( Gesture::Started, 2u, 1u, Vector2( 3.f, 25.0f ) ) );
1532
1533   // Render and notify
1534   application.SendNotification();
1535   application.Render();
1536
1537   // The stencil actor should have two actors: the renderer and the highlight actor.
1538   Actor stencil = editor.GetChildAt( 0u );
1539
1540   // The stencil actor has a container with all the actors which contain the text renderers.
1541   Actor container = stencil.GetChildAt( 0u );
1542   for( unsigned int index = 0; index < container.GetChildCount(); ++index )
1543   {
1544     Renderer renderer = container.GetChildAt( index ).GetRendererAt( 0u );
1545     DALI_TEST_CHECK( renderer );
1546   }
1547
1548   Renderer highlight = stencil.GetChildAt( 1u ).GetRendererAt( 0u );
1549   DALI_TEST_CHECK( highlight );
1550
1551   // Double tap out of bounds
1552   application.ProcessEvent( GenerateTap( Gesture::Possible, 2u, 1u, Vector2( 29.f, 25.0f ) ) );
1553   application.ProcessEvent( GenerateTap( Gesture::Started, 2u, 1u, Vector2( 29.f, 25.0f ) ) );
1554
1555   // Render and notify
1556   application.SendNotification();
1557   application.Render();
1558
1559   // The stencil actor should have one actors: the renderer actor.
1560   stencil = editor.GetChildAt( 0u );
1561
1562   // The stencil actor has a container with all the actors which contain the text renderers.
1563   container = stencil.GetChildAt( 0u );
1564   for( unsigned int index = 0; index < container.GetChildCount(); ++index )
1565   {
1566     Renderer renderer = container.GetChildAt( index ).GetRendererAt( 0u );
1567     DALI_TEST_CHECK( renderer );
1568   }
1569
1570   END_TEST;
1571 }
1572
1573 int utcDaliTextEditorEvent04(void)
1574 {
1575   ToolkitTestApplication application;
1576   tet_infoline(" utcDaliTextEditorEvent04");
1577
1578   // Checks if the highlight actor is created.
1579
1580   TextEditor editor = TextEditor::New();
1581   DALI_TEST_CHECK( editor );
1582
1583   Stage::GetCurrent().Add( editor );
1584
1585   editor.SetProperty( TextEditor::Property::TEXT, "Hello\nworl" );
1586   editor.SetProperty( TextEditor::Property::POINT_SIZE, 10.f );
1587   editor.SetSize( 100.f, 50.f );
1588   editor.SetParentOrigin( ParentOrigin::TOP_LEFT );
1589   editor.SetAnchorPoint( AnchorPoint::TOP_LEFT );
1590
1591   // Avoid a crash when core load gl resources.
1592   application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
1593
1594   // Render and notify
1595   application.SendNotification();
1596   application.Render();
1597
1598   // Tap on the text editor
1599   application.ProcessEvent( GenerateTap( Gesture::Possible, 1u, 1u, Vector2( 3.f, 25.0f ) ) );
1600   application.ProcessEvent( GenerateTap( Gesture::Started, 1u, 1u, Vector2( 3.f, 25.0f ) ) );
1601
1602   // Render and notify
1603   application.SendNotification();
1604   application.Render();
1605
1606   // Move at the end of the text.
1607   application.ProcessEvent( GenerateKey( "", "", DALI_KEY_CURSOR_DOWN, 0, 0, Integration::KeyEvent::Down ) );
1608   application.ProcessEvent( GenerateKey( "", "", DALI_KEY_CURSOR_DOWN, 0, 0, Integration::KeyEvent::Down ) );
1609
1610   // Render and notify
1611   application.SendNotification();
1612   application.Render();
1613
1614   for( unsigned int index = 0u; index < 10u; ++index )
1615   {
1616     application.ProcessEvent( GenerateKey( "", "", DALI_KEY_CURSOR_RIGHT, 0, 0, Integration::KeyEvent::Down ) );
1617     application.ProcessEvent( GenerateKey( "", "", DALI_KEY_CURSOR_RIGHT, 0, 0, Integration::KeyEvent::Down ) );
1618
1619     // Render and notify
1620     application.SendNotification();
1621     application.Render();
1622   }
1623
1624   // Add a character
1625   application.ProcessEvent( GenerateKey( "d", "d", KEY_D_CODE, 0, 0, Integration::KeyEvent::Down ) );
1626
1627   // Render and notify
1628   application.SendNotification();
1629   application.Render();
1630
1631   DALI_TEST_EQUALS( "Hello\nworld", editor.GetProperty<std::string>( TextEditor::Property::TEXT ), TEST_LOCATION );
1632
1633   // Add some key events
1634   application.ProcessEvent( GenerateKey( "", "", DALI_KEY_CURSOR_UP, 0, 0, Integration::KeyEvent::Down ) );
1635   application.ProcessEvent( GenerateKey( "", "", DALI_KEY_CURSOR_UP, 0, 0, Integration::KeyEvent::Down ) );
1636
1637   // Render and notify
1638   application.SendNotification();
1639   application.Render();
1640
1641   for( unsigned int index = 0u; index < 10u; ++index )
1642   {
1643     application.ProcessEvent( GenerateKey( "", "", DALI_KEY_CURSOR_LEFT, 0, 0, Integration::KeyEvent::Down ) );
1644     application.ProcessEvent( GenerateKey( "", "", DALI_KEY_CURSOR_LEFT, 0, 0, Integration::KeyEvent::Down ) );
1645
1646     // Render and notify
1647     application.SendNotification();
1648     application.Render();
1649   }
1650
1651   // Add a character
1652   application.ProcessEvent( GenerateKey( " ", " ", KEY_WHITE_SPACE_CODE, 0, 0, Integration::KeyEvent::Down ) );
1653
1654   // Render and notify
1655   application.SendNotification();
1656   application.Render();
1657
1658   DALI_TEST_EQUALS( " Hello\nworld", editor.GetProperty<std::string>( TextEditor::Property::TEXT ), TEST_LOCATION );
1659
1660   END_TEST;
1661 }
1662
1663 int utcDaliTextEditorEvent05(void)
1664 {
1665   ToolkitTestApplication application;
1666   tet_infoline(" utcDaliTextEditorEvent05");
1667
1668   // Checks if the highlight actor is created.
1669
1670   TextEditor editor = TextEditor::New();
1671   DALI_TEST_CHECK( editor );
1672
1673   Stage::GetCurrent().Add( editor );
1674
1675   editor.SetProperty( TextEditor::Property::TEXT, "Hello\nworl" );
1676   editor.SetProperty( TextEditor::Property::POINT_SIZE, 10.f );
1677   editor.SetSize( 50.f, 50.f );
1678   editor.SetParentOrigin( ParentOrigin::TOP_LEFT );
1679   editor.SetAnchorPoint( AnchorPoint::TOP_LEFT );
1680   editor.SetProperty( DevelTextEditor::Property::SMOOTH_SCROLL, true );
1681   editor.SetProperty( DevelTextEditor::Property::SMOOTH_SCROLL_DURATION, 0.2f );
1682   editor.SetProperty( DevelTextEditor::Property::ENABLE_SCROLL_BAR, true );
1683   editor.SetProperty( DevelTextEditor::Property::SCROLL_BAR_SHOW_DURATION, 0.3f );
1684   editor.SetProperty( DevelTextEditor::Property::SCROLL_BAR_FADE_DURATION, 0.2f );
1685
1686   // Avoid a crash when core load gl resources.
1687   application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
1688
1689   // Render and notify
1690   application.SendNotification();
1691   application.Render();
1692
1693   // Tap on the text editor
1694   application.ProcessEvent( GenerateTap( Gesture::Possible, 1u, 1u, Vector2( 3.f, 25.0f ) ) );
1695   application.ProcessEvent( GenerateTap( Gesture::Started, 1u, 1u, Vector2( 3.f, 25.0f ) ) );
1696
1697   // Render and notify
1698   application.SendNotification();
1699   application.Render();
1700
1701   // Move at the end of the text.
1702   application.ProcessEvent( GenerateKey( "", "", DALI_KEY_CURSOR_DOWN, 0, 0, Integration::KeyEvent::Down ) );
1703   application.ProcessEvent( GenerateKey( "", "", DALI_KEY_CURSOR_DOWN, 0, 0, Integration::KeyEvent::Down ) );
1704
1705   // Render and notify
1706   application.SendNotification();
1707   application.Render();
1708
1709   for( unsigned int index = 0u; index < 10u; ++index )
1710   {
1711     // Add a character
1712     application.ProcessEvent( GenerateKey( "d", "d", KEY_D_CODE, 0, 0, Integration::KeyEvent::Down ) );
1713
1714     // Render and notify
1715     application.SendNotification();
1716     application.Render();
1717   }
1718   // Modify duration after scroll is enabled
1719   editor.SetProperty( DevelTextEditor::Property::SMOOTH_SCROLL_DURATION, 0.1f );
1720
1721   // Continuous scroll left to increase coverage
1722   for( unsigned int index = 0u; index < 10u; ++index )
1723   {
1724     application.ProcessEvent( GenerateKey( "", "", DALI_KEY_CURSOR_LEFT, 0, 0, Integration::KeyEvent::Down ) );
1725
1726     // Render and notify
1727     application.SendNotification();
1728     application.Render();
1729   }
1730   DALI_TEST_EQUALS( editor.GetProperty<float>( DevelTextEditor::Property::SMOOTH_SCROLL_DURATION ), 0.1f, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
1731   DALI_TEST_EQUALS( editor.GetProperty<bool>( DevelTextEditor::Property::SMOOTH_SCROLL ), true, TEST_LOCATION );
1732   DALI_TEST_EQUALS( editor.GetProperty<bool>( DevelTextEditor::Property::ENABLE_SCROLL_BAR ), true, TEST_LOCATION );
1733   DALI_TEST_EQUALS( editor.GetProperty<float>( DevelTextEditor::Property::SCROLL_BAR_SHOW_DURATION ), 0.3f, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
1734   DALI_TEST_EQUALS( editor.GetProperty<float>( DevelTextEditor::Property::SCROLL_BAR_FADE_DURATION ), 0.2f, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
1735
1736   // Press Escape to increase coverage
1737   application.ProcessEvent( GenerateKey( "", "", DALI_KEY_ESCAPE, 0, 0, Integration::KeyEvent::Up ) );
1738   application.SendNotification();
1739   application.Render();
1740
1741   DALI_TEST_CHECK( !editor.HasKeyInputFocus() );
1742
1743   END_TEST;
1744 }
1745
1746 int utcDaliTextEditorHandles(void)
1747 {
1748   ToolkitTestApplication application;
1749   tet_infoline(" utcDaliTextEditorHandles");
1750
1751   TextEditor editor = TextEditor::New();
1752   DALI_TEST_CHECK( editor );
1753
1754   Stage::GetCurrent().Add( editor );
1755
1756   editor.SetProperty( TextEditor::Property::TEXT, "This is a long text for the size of the text-editor." );
1757   editor.SetProperty( TextEditor::Property::POINT_SIZE, 10.f );
1758   editor.SetProperty( TextEditor::Property::GRAB_HANDLE_IMAGE, HANDLE_IMAGE_FILE_NAME );
1759   editor.SetProperty( DevelTextEditor::Property::SMOOTH_SCROLL, true );
1760
1761   editor.SetSize( 30.f, 500.f );
1762   editor.SetParentOrigin( ParentOrigin::TOP_LEFT );
1763   editor.SetAnchorPoint( AnchorPoint::TOP_LEFT );
1764
1765   // Avoid a crash when core load gl resources.
1766   application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
1767
1768   // Render and notify
1769   application.SendNotification();
1770   application.Render();
1771
1772   // Tap first to get the focus.
1773   application.ProcessEvent( GenerateTap( Gesture::Possible, 1u, 1u, Vector2( 3.f, 25.0f ) ) );
1774   application.ProcessEvent( GenerateTap( Gesture::Started, 1u, 1u, Vector2( 3.f, 25.0f ) ) );
1775
1776   // Render and notify
1777   application.SendNotification();
1778   application.Render();
1779
1780   // Tap to create the grab handle.
1781   application.ProcessEvent( GenerateTap( Gesture::Possible, 1u, 1u, Vector2( 3.f, 25.0f ) ) );
1782   application.ProcessEvent( GenerateTap( Gesture::Started, 1u, 1u, Vector2( 3.f, 25.0f ) ) );
1783
1784   // Render and notify
1785   application.SendNotification();
1786   application.Render();
1787
1788   // Get the active layer where the text's decoration is added.
1789   Actor activeLayer = editor.GetChildAt( 1u );
1790
1791   // Get the handle's actor.
1792   Actor handle = activeLayer.GetChildAt( 1u );
1793   handle.SetSize( 100.f, 100.f );
1794
1795   // Render and notify
1796   application.SendNotification();
1797   application.Render();
1798
1799   // Touch the grab handle to set it as pressed.
1800   Vector2 touchPos( 10.0f, 50.0f );
1801   Dali::Integration::TouchEvent event;
1802   event = Dali::Integration::TouchEvent();
1803   event.AddPoint( GetPointDownInside( touchPos ) );
1804   application.ProcessEvent( event );
1805
1806   // Render and notify
1807   application.SendNotification();
1808   application.Render();
1809
1810   // drag grab handle right
1811   SendPan(application, Gesture::Possible, touchPos);
1812   SendPan(application, Gesture::Started, touchPos);
1813   touchPos.x += 5.0f;
1814   Wait(application, 100);
1815
1816   for(int i = 0;i<20;i++)
1817   {
1818     SendPan(application, Gesture::Continuing, touchPos);
1819     touchPos.x += 5.0f;
1820     Wait(application);
1821   }
1822
1823   SendPan(application, Gesture::Finished, touchPos);
1824   Wait(application);
1825
1826   // Release the grab handle.
1827   event = Dali::Integration::TouchEvent();
1828   event.AddPoint( GetPointUpInside( touchPos ) );
1829   application.ProcessEvent( event );
1830
1831   // Render and notify
1832   application.SendNotification();
1833   application.Render();
1834
1835   END_TEST;
1836 }
1837