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