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