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