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