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