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