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