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