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