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