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