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