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