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