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