Merge "Fixed a problem where text size exceeds maximum texture size." into devel...
[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", "green" );
731   shadowMapSet.Insert( "offset", "2 2" );
732
733   editor.SetProperty( TextEditor::Property::SHADOW, shadowMapSet );
734
735   shadowMapGet = editor.GetProperty<Property::Map>( TextEditor::Property::SHADOW );
736   DALI_TEST_EQUALS( shadowMapGet.Count(), shadowMapSet.Count(), TEST_LOCATION );
737   DALI_TEST_EQUALS( DaliTestCheckMaps( shadowMapGet, shadowMapSet ), true, TEST_LOCATION );
738
739   // Check the input shadow property
740   editor.SetProperty( TextEditor::Property::INPUT_SHADOW, "Shadow input properties" );
741   DALI_TEST_EQUALS( editor.GetProperty<std::string>( TextEditor::Property::INPUT_SHADOW ), std::string("Shadow input properties"), TEST_LOCATION );
742
743   // Check the emboss property
744   editor.SetProperty( TextEditor::Property::EMBOSS, "Emboss properties" );
745   DALI_TEST_EQUALS( editor.GetProperty<std::string>( TextEditor::Property::EMBOSS ), std::string("Emboss properties"), TEST_LOCATION );
746
747   // Check the input emboss property
748   editor.SetProperty( TextEditor::Property::INPUT_EMBOSS, "Emboss input properties" );
749   DALI_TEST_EQUALS( editor.GetProperty<std::string>( TextEditor::Property::INPUT_EMBOSS ), std::string("Emboss input properties"), TEST_LOCATION );
750
751   // Check the outline property
752
753   // Test string type first
754   // This is purely to maintain backward compatibility, but we don't support string as the outline property type.
755   editor.SetProperty( TextEditor::Property::OUTLINE, "Outline properties" );
756   DALI_TEST_EQUALS( editor.GetProperty<std::string>( TextEditor::Property::OUTLINE ), std::string("Outline properties"), TEST_LOCATION );
757
758   // Then test the property map type
759   Property::Map outlineMapSet;
760   Property::Map outlineMapGet;
761
762   outlineMapSet["color"] = Color::RED;
763   outlineMapSet["width"] = 2.0f;
764
765   editor.SetProperty( TextEditor::Property::OUTLINE, outlineMapSet );
766
767   outlineMapSet["color"] = "red";
768   outlineMapSet["width"] = "2";
769   outlineMapGet = editor.GetProperty<Property::Map>( TextEditor::Property::OUTLINE );
770   DALI_TEST_EQUALS( outlineMapGet.Count(), outlineMapSet.Count(), TEST_LOCATION );
771   DALI_TEST_EQUALS( DaliTestCheckMaps( outlineMapGet, outlineMapSet ), true, TEST_LOCATION );
772
773   // Check the input outline property
774   editor.SetProperty( TextEditor::Property::INPUT_OUTLINE, "Outline input properties" );
775   DALI_TEST_EQUALS( editor.GetProperty<std::string>( TextEditor::Property::INPUT_OUTLINE ), std::string("Outline input properties"), TEST_LOCATION );
776
777   // Check the smooth scroll property
778   DALI_TEST_EQUALS( editor.GetProperty<bool>( TextEditor::Property::SMOOTH_SCROLL ), false, TEST_LOCATION );
779   editor.SetProperty( TextEditor::Property::SMOOTH_SCROLL, true );
780   DALI_TEST_EQUALS( editor.GetProperty<bool>( TextEditor::Property::SMOOTH_SCROLL ), true, TEST_LOCATION );
781
782   // Check the smooth scroll duration property
783   editor.SetProperty( TextEditor::Property::SMOOTH_SCROLL_DURATION, 0.2f );
784   DALI_TEST_EQUALS( editor.GetProperty<float>( TextEditor::Property::SMOOTH_SCROLL_DURATION ), 0.2f, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
785
786   // Check the scroll bar property
787   DALI_TEST_EQUALS( editor.GetProperty<bool>( TextEditor::Property::ENABLE_SCROLL_BAR ), false, TEST_LOCATION );
788   editor.SetProperty( TextEditor::Property::ENABLE_SCROLL_BAR, true );
789   DALI_TEST_EQUALS( editor.GetProperty<bool>( TextEditor::Property::ENABLE_SCROLL_BAR ), true, TEST_LOCATION );
790
791   editor.SetProperty( TextEditor::Property::SCROLL_BAR_SHOW_DURATION, 0.3f );
792   DALI_TEST_EQUALS( editor.GetProperty<float>( TextEditor::Property::SCROLL_BAR_SHOW_DURATION ), 0.3f, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
793   editor.SetProperty( TextEditor::Property::SCROLL_BAR_FADE_DURATION, 0.2f );
794   DALI_TEST_EQUALS( editor.GetProperty<float>( TextEditor::Property::SCROLL_BAR_FADE_DURATION ), 0.2f, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
795
796   // Check the pixel size of font
797   editor.SetProperty( TextEditor::Property::PIXEL_SIZE, 20.f );
798   DALI_TEST_EQUALS( editor.GetProperty<float>( TextEditor::Property::PIXEL_SIZE ), 20.f, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
799
800   // Check placeholder text properties.
801   editor.SetProperty( DevelTextEditor::Property::PLACEHOLDER_TEXT, "Setting Placeholder Text" );
802   DALI_TEST_EQUALS( editor.GetProperty<std::string>( DevelTextEditor::Property::PLACEHOLDER_TEXT ), std::string("Setting Placeholder Text"), TEST_LOCATION );
803
804   // Check placeholder text's color property.
805   editor.SetProperty( DevelTextEditor::Property::PLACEHOLDER_TEXT_COLOR, Color::RED );
806   DALI_TEST_EQUALS( editor.GetProperty<Vector4>( DevelTextEditor::Property::PLACEHOLDER_TEXT_COLOR ), Color::RED, TEST_LOCATION );
807
808   // Check the enable selection property
809   editor.SetProperty( TextEditor::Property::ENABLE_SELECTION, false );
810   DALI_TEST_EQUALS( editor.GetProperty<bool>( TextEditor::Property::ENABLE_SELECTION ), false, TEST_LOCATION );
811
812   // Check the placeholder property with pixel size
813   Property::Map placeholderPixelSizeMapSet;
814   Property::Map placeholderPixelSizeMapGet;
815   Property::Map placeholderFontstyleMap;
816   placeholderPixelSizeMapSet["text"] = "Setting Placeholder Text";
817   placeholderPixelSizeMapSet["textFocused"] = "Setting Placeholder Text Focused";
818   placeholderPixelSizeMapSet["color"] = Color::BLUE;
819   placeholderPixelSizeMapSet["fontFamily"] = "Arial";
820   placeholderPixelSizeMapSet["pixelSize"] = 15.0f;
821
822   placeholderFontstyleMap.Insert( "weight", "bold" );
823   placeholderPixelSizeMapSet["fontStyle"] = placeholderFontstyleMap;
824   editor.SetProperty( TextEditor::Property::PLACEHOLDER, placeholderPixelSizeMapSet );
825
826   placeholderPixelSizeMapGet = editor.GetProperty<Property::Map>( TextEditor::Property::PLACEHOLDER );
827   DALI_TEST_EQUALS( placeholderPixelSizeMapGet.Count(), placeholderPixelSizeMapSet.Count(), TEST_LOCATION );
828
829   tet_infoline("Test Placeholder settings set as strings is converted correctly to Property Index key and holds set value");
830   Property::Map placeholderConversionMap;
831   placeholderConversionMap[ Text::PlaceHolder::Property::TEXT ] = placeholderPixelSizeMapSet["text"];
832   placeholderConversionMap[ Text::PlaceHolder::Property::TEXT_FOCUSED ] = placeholderPixelSizeMapSet["textFocused"] ;
833   placeholderConversionMap[ Text::PlaceHolder::Property::COLOR ] = placeholderPixelSizeMapSet["color"];
834   placeholderConversionMap[ Text::PlaceHolder::Property::FONT_STYLE ] = placeholderPixelSizeMapSet["fontStyle"];
835   placeholderConversionMap[ Text::PlaceHolder::Property::FONT_FAMILY ] = placeholderPixelSizeMapSet["fontFamily"];
836   placeholderConversionMap[ Text::PlaceHolder::Property::PIXEL_SIZE ] = placeholderPixelSizeMapSet["pixelSize"];
837
838   DALI_TEST_EQUALS( DaliTestCheckMaps( placeholderPixelSizeMapGet, placeholderConversionMap ), true, TEST_LOCATION );
839
840   // Check the placeholder property with point size
841   Property::Map placeholderMapSet;
842   Property::Map placeholderMapGet;
843   placeholderMapSet["text"] = "Setting Placeholder Text";
844   placeholderMapSet["textFocused"] = "Setting Placeholder Text Focused";
845   placeholderMapSet["color"] = Color::RED;
846   placeholderMapSet["fontFamily"] = "Arial";
847   placeholderMapSet["pointSize"] = 12.0f;
848   // Check the placeholder font style property
849   placeholderFontstyleMap.Clear();
850
851   placeholderFontstyleMap.Insert( "weight", "bold" );
852   placeholderFontstyleMap.Insert( "width", "condensed" );
853   placeholderFontstyleMap.Insert( "slant", "italic" );
854   placeholderMapSet["fontStyle"] = placeholderFontstyleMap;
855   editor.SetProperty( TextEditor::Property::PLACEHOLDER, placeholderMapSet );
856
857   placeholderMapGet = editor.GetProperty<Property::Map>( TextEditor::Property::PLACEHOLDER );
858   DALI_TEST_EQUALS( placeholderMapGet.Count(), placeholderMapSet.Count(), TEST_LOCATION );
859
860   tet_infoline("Test Placeholder settings set as strings is converted correctly to Property Index key and holds set value");
861   placeholderConversionMap.Clear();
862   placeholderConversionMap[ Text::PlaceHolder::Property::TEXT ] = placeholderMapSet["text"];
863   placeholderConversionMap[ Text::PlaceHolder::Property::TEXT_FOCUSED ] = placeholderMapSet["textFocused"] ;
864   placeholderConversionMap[ Text::PlaceHolder::Property::COLOR ] = placeholderMapSet["color"];
865   placeholderConversionMap[ Text::PlaceHolder::Property::FONT_STYLE ] = placeholderPixelSizeMapSet["fontStyle"];
866   placeholderConversionMap[ Text::PlaceHolder::Property::FONT_FAMILY ] = placeholderMapSet["fontFamily"];
867   placeholderConversionMap[ Text::PlaceHolder::Property::POINT_SIZE ] = placeholderMapSet["pointSize"];
868   DALI_TEST_EQUALS( DaliTestCheckMaps( placeholderMapGet, placeholderConversionMap ), true, TEST_LOCATION );
869
870   // Reset font style.
871   placeholderFontstyleMap.Clear();
872   placeholderFontstyleMap.Insert( "weight", "normal" );
873   placeholderFontstyleMap.Insert( "slant", "oblique" );
874   placeholderMapSet["fontStyle"] = placeholderFontstyleMap;
875   editor.SetProperty( TextEditor::Property::PLACEHOLDER, placeholderMapSet );
876
877   placeholderMapGet = editor.GetProperty<Property::Map>( TextEditor::Property::PLACEHOLDER );
878   DALI_TEST_EQUALS( placeholderMapGet.Count(), placeholderMapSet.Count(), TEST_LOCATION );
879   placeholderConversionMap[ Text::PlaceHolder::Property::FONT_STYLE ] = placeholderMapSet["fontStyle"];
880   DALI_TEST_EQUALS( DaliTestCheckMaps( placeholderMapGet, placeholderConversionMap ), true, TEST_LOCATION );
881
882   placeholderFontstyleMap.Clear();
883   placeholderFontstyleMap.Insert( "slant", "roman" );
884   placeholderMapSet["fontStyle"] = placeholderFontstyleMap;
885   editor.SetProperty( TextEditor::Property::PLACEHOLDER, placeholderMapSet );
886
887   placeholderMapGet = editor.GetProperty<Property::Map>( TextEditor::Property::PLACEHOLDER );
888
889   placeholderFontstyleMap.Clear();
890   placeholderMapSet["fontStyle"] = placeholderFontstyleMap;
891
892   editor.SetProperty( TextEditor::Property::PLACEHOLDER, placeholderMapSet );
893   placeholderMapGet = editor.GetProperty<Property::Map>( TextEditor::Property::PLACEHOLDER );
894   DALI_TEST_EQUALS( placeholderMapGet.Count(), placeholderMapSet.Count(), TEST_LOCATION );
895   placeholderConversionMap[ Text::PlaceHolder::Property::FONT_STYLE ] = placeholderMapSet["fontStyle"];
896   DALI_TEST_EQUALS( DaliTestCheckMaps( placeholderMapGet, placeholderConversionMap ), true, TEST_LOCATION );
897
898   END_TEST;
899 }
900
901 // Positive Atlas Text Renderer test
902 int utcDaliTextEditorAtlasRenderP(void)
903 {
904   ToolkitTestApplication application;
905   tet_infoline(" UtcDaliToolkitTextEditorAtlasRenderP");
906   StyleManager styleManager = StyleManager::Get();
907   styleManager.ApplyDefaultTheme();
908   TextEditor editor = TextEditor::New();
909   DALI_TEST_CHECK( editor );
910
911   editor.SetProperty( TextEditor::Property::HORIZONTAL_ALIGNMENT, "CENTER" );
912
913   application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
914
915   Stage::GetCurrent().Add( editor );
916
917   try
918   {
919     // Render some text with the shared atlas backend
920     editor.SetProperty( TextEditor::Property::RENDERING_BACKEND, Text::RENDERING_SHARED_ATLAS );
921     application.SendNotification();
922     application.Render();
923   }
924   catch( ... )
925   {
926     tet_result(TET_FAIL);
927   }
928   END_TEST;
929 }
930
931 // Positive test for the textChanged signal.
932 int utcDaliTextEditorTextChangedP(void)
933 {
934   ToolkitTestApplication application;
935   tet_infoline(" utcDaliTextEditorTextChangedP");
936   TextEditor editor = TextEditor::New();
937   DALI_TEST_CHECK( editor );
938
939   Stage::GetCurrent().Add( editor );
940
941   // connect to the text changed signal.
942   ConnectionTracker* testTracker = new ConnectionTracker();
943   editor.TextChangedSignal().Connect( &TestTextChangedCallback );
944   bool textChangedSignal = false;
945   editor.ConnectSignal( testTracker, "textChanged",   CallbackFunctor(&textChangedSignal) );
946
947   gTextChangedCallBackCalled = false;
948   editor.SetProperty( TextEditor::Property::TEXT, "ABC" );
949   DALI_TEST_CHECK( gTextChangedCallBackCalled );
950   DALI_TEST_CHECK( textChangedSignal );
951
952   application.SendNotification();
953
954   editor.SetKeyInputFocus();
955
956   gTextChangedCallBackCalled = false;
957   application.ProcessEvent( GenerateKey( "D", "D", KEY_D_CODE, 0, 0, Integration::KeyEvent::Down, DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
958   DALI_TEST_CHECK( gTextChangedCallBackCalled );
959
960   END_TEST;
961 }
962
963 int utcDaliTextEditorInputStyleChanged01(void)
964 {
965   ToolkitTestApplication application;
966   tet_infoline(" utcDaliTextEditorInputStyleChanged01");
967
968   // The text-editor emits signals when the input style changes. These changes of style are
969   // detected during the relayout process (size negotiation), i.e after the cursor has been moved. Signals
970   // can't be emitted during the size negotiation as the callbacks may update the UI.
971   // The text-editor adds an idle callback to the adaptor to emit the signals after the size negotiation.
972   // This creates an implementation of the adaptor stub and a queue of idle callbacks.
973   application.CreateAdaptor();
974
975   // Load some fonts.
976
977   char* pathNamePtr = get_current_dir_name();
978   const std::string pathName( pathNamePtr );
979   free( pathNamePtr );
980
981   TextAbstraction::FontClient fontClient = TextAbstraction::FontClient::Get();
982   fontClient.SetDpi( 93u, 93u );
983
984   fontClient.GetFontId( pathName + DEFAULT_FONT_DIR + "/dejavu/DejaVuSerif.ttf", DEFAULT_FONT_SIZE );
985   fontClient.GetFontId( pathName + DEFAULT_FONT_DIR + "/dejavu/DejaVuSerif-Bold.ttf", DEFAULT_FONT_SIZE );
986
987   TextEditor editor = TextEditor::New();
988   DALI_TEST_CHECK( editor );
989
990
991   editor.SetSize( 300.f, 50.f );
992   editor.SetParentOrigin( ParentOrigin::TOP_LEFT );
993   editor.SetAnchorPoint( AnchorPoint::TOP_LEFT );
994
995   editor.SetProperty( TextEditor::Property::ENABLE_MARKUP, true );
996   editor.SetProperty( TextEditor::Property::TEXT, "<font family='DejaVuSerif' size='18'>He<color value='green'>llo</color> <font weight='bold'>world</font> demo</font>" );
997
998   // connect to the text changed signal.
999   ConnectionTracker* testTracker = new ConnectionTracker();
1000   editor.InputStyleChangedSignal().Connect( &TestInputStyleChangedCallback );
1001   bool inputStyleChangedSignal = false;
1002   editor.ConnectSignal( testTracker, "inputStyleChanged",   CallbackFunctor(&inputStyleChangedSignal) );
1003
1004   Stage::GetCurrent().Add( editor );
1005
1006   // Render and notify
1007   application.SendNotification();
1008   application.Render();
1009
1010   // Executes the idle callbacks added by the text control on the change of input style.
1011   application.RunIdles();
1012
1013   gInputStyleChangedCallbackCalled = false;
1014   gInputStyleMask = TextEditor::InputStyle::NONE;
1015   inputStyleChangedSignal = false;
1016
1017   // Create a tap event to touch the text editor.
1018   application.ProcessEvent( GenerateTap( Gesture::Possible, 1u, 1u, Vector2( 18.f, 25.f ) ) );
1019   application.ProcessEvent( GenerateTap( Gesture::Started, 1u, 1u, Vector2( 18.f, 25.f ) ) );
1020
1021   // Render and notify
1022   application.SendNotification();
1023   application.Render();
1024
1025   // Executes the idle callbacks added by the text control on the change of input style.
1026   application.RunIdles();
1027
1028   DALI_TEST_CHECK( gInputStyleChangedCallbackCalled );
1029   if( gInputStyleChangedCallbackCalled )
1030   {
1031     DALI_TEST_EQUALS( static_cast<unsigned int>( gInputStyleMask ), static_cast<unsigned int>( TextEditor::InputStyle::FONT_FAMILY | TextEditor::InputStyle::POINT_SIZE ), TEST_LOCATION );
1032
1033     const std::string fontFamily = editor.GetProperty( TextEditor::Property::INPUT_FONT_FAMILY ).Get<std::string>();
1034     DALI_TEST_EQUALS( fontFamily, "DejaVuSerif", TEST_LOCATION );
1035
1036     const float pointSize = editor.GetProperty( TextEditor::Property::INPUT_POINT_SIZE ).Get<float>();
1037     DALI_TEST_EQUALS( pointSize, 18.f, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
1038   }
1039   DALI_TEST_CHECK( inputStyleChangedSignal );
1040
1041   gInputStyleChangedCallbackCalled = false;
1042   gInputStyleMask = TextEditor::InputStyle::NONE;
1043   inputStyleChangedSignal = false;
1044
1045   // Create a tap event to touch the text editor.
1046   application.ProcessEvent( GenerateTap( Gesture::Possible, 1u, 1u, Vector2( 30.f, 25.f ) ) );
1047   application.ProcessEvent( GenerateTap( Gesture::Started, 1u, 1u, Vector2( 30.f, 25.f ) ) );
1048
1049   // Render and notify
1050   application.SendNotification();
1051   application.Render();
1052
1053   // Executes the idle callbacks added by the text control on the change of input style.
1054   application.RunIdles();
1055
1056   DALI_TEST_CHECK( !gInputStyleChangedCallbackCalled );
1057   DALI_TEST_CHECK( !inputStyleChangedSignal );
1058
1059   gInputStyleChangedCallbackCalled = false;
1060   gInputStyleMask = TextEditor::InputStyle::NONE;
1061   inputStyleChangedSignal = false;
1062
1063   // Create a tap event to touch the text editor.
1064   application.ProcessEvent( GenerateTap( Gesture::Possible, 1u, 1u, Vector2( 43.f, 25.f ) ) );
1065   application.ProcessEvent( GenerateTap( Gesture::Started, 1u, 1u, Vector2( 43.f, 25.f ) ) );
1066
1067   // Render and notify
1068   application.SendNotification();
1069   application.Render();
1070
1071   // Executes the idle callbacks added by the text control on the change of input style.
1072   application.RunIdles();
1073
1074   DALI_TEST_CHECK( gInputStyleChangedCallbackCalled );
1075   if( gInputStyleChangedCallbackCalled )
1076   {
1077     DALI_TEST_EQUALS( static_cast<unsigned int>( gInputStyleMask ), static_cast<unsigned int>( TextEditor::InputStyle::COLOR ), TEST_LOCATION );
1078
1079     const Vector4 color = editor.GetProperty( TextEditor::Property::INPUT_COLOR ).Get<Vector4>();
1080     DALI_TEST_EQUALS( color, Color::GREEN, TEST_LOCATION );
1081   }
1082   DALI_TEST_CHECK( inputStyleChangedSignal );
1083
1084   gInputStyleChangedCallbackCalled = false;
1085   gInputStyleMask = TextEditor::InputStyle::NONE;
1086   inputStyleChangedSignal = false;
1087
1088   // Create a tap event to touch the text editor.
1089   application.ProcessEvent( GenerateTap( Gesture::Possible, 1u, 1u, Vector2( 88.f, 25.f ) ) );
1090   application.ProcessEvent( GenerateTap( Gesture::Started, 1u, 1u, Vector2( 88.f, 25.f ) ) );
1091
1092   // Render and notify
1093   application.SendNotification();
1094   application.Render();
1095
1096   // Executes the idle callbacks added by the text control on the change of input style.
1097   application.RunIdles();
1098
1099   DALI_TEST_CHECK( gInputStyleChangedCallbackCalled );
1100   if( gInputStyleChangedCallbackCalled )
1101   {
1102     DALI_TEST_EQUALS( static_cast<unsigned int>( gInputStyleMask ), static_cast<unsigned int>( TextEditor::InputStyle::COLOR | TextEditor::InputStyle::FONT_STYLE ), TEST_LOCATION );
1103
1104     const Vector4 color = editor.GetProperty( TextEditor::Property::INPUT_COLOR ).Get<Vector4>();
1105     DALI_TEST_EQUALS( color, Color::BLACK, TEST_LOCATION );
1106
1107     Property::Map fontStyleMapSet;
1108     Property::Map fontStyleMapGet;
1109
1110     fontStyleMapSet.Insert( "weight", "bold" );
1111
1112     fontStyleMapGet = editor.GetProperty<Property::Map>( TextEditor::Property::INPUT_FONT_STYLE );
1113     DALI_TEST_EQUALS( fontStyleMapGet.Count(), fontStyleMapSet.Count(), TEST_LOCATION );
1114     DALI_TEST_EQUALS( DaliTestCheckMaps( fontStyleMapGet, fontStyleMapSet ), true, TEST_LOCATION );
1115   }
1116   DALI_TEST_CHECK( inputStyleChangedSignal );
1117
1118   gInputStyleChangedCallbackCalled = false;
1119   gInputStyleMask = TextEditor::InputStyle::NONE;
1120   inputStyleChangedSignal = false;
1121
1122   // Create a tap event to touch the text editor.
1123   application.ProcessEvent( GenerateTap( Gesture::Possible, 1u, 1u, Vector2( 115.f, 25.f ) ) );
1124   application.ProcessEvent( GenerateTap( Gesture::Started, 1u, 1u, Vector2( 115.f, 25.f ) ) );
1125
1126   // Render and notify
1127   application.SendNotification();
1128   application.Render();
1129
1130   // Executes the idle callbacks added by the text control on the change of input style.
1131   application.RunIdles();
1132
1133   DALI_TEST_CHECK( !gInputStyleChangedCallbackCalled );
1134   DALI_TEST_CHECK( !inputStyleChangedSignal );
1135
1136   gInputStyleChangedCallbackCalled = false;
1137   gInputStyleMask = TextEditor::InputStyle::NONE;
1138   inputStyleChangedSignal = false;
1139
1140   // Create a tap event to touch the text editor.
1141   application.ProcessEvent( GenerateTap( Gesture::Possible, 1u, 1u, Vector2( 164.f, 25.f ) ) );
1142   application.ProcessEvent( GenerateTap( Gesture::Started, 1u, 1u, Vector2( 164.f, 25.f ) ) );
1143
1144   // Render and notify
1145   application.SendNotification();
1146   application.Render();
1147
1148   // Executes the idle callbacks added by the text control on the change of input style.
1149   application.RunIdles();
1150
1151   DALI_TEST_CHECK( gInputStyleChangedCallbackCalled );
1152   if( gInputStyleChangedCallbackCalled )
1153   {
1154     DALI_TEST_EQUALS( static_cast<unsigned int>( gInputStyleMask ), static_cast<unsigned int>( TextEditor::InputStyle::FONT_STYLE ), TEST_LOCATION );
1155
1156     Property::Map fontStyleMapSet;
1157     Property::Map fontStyleMapGet;
1158
1159     fontStyleMapGet = editor.GetProperty<Property::Map>( TextEditor::Property::INPUT_FONT_STYLE );
1160     DALI_TEST_EQUALS( fontStyleMapGet.Count(), fontStyleMapSet.Count(), TEST_LOCATION );
1161     DALI_TEST_EQUALS( DaliTestCheckMaps( fontStyleMapGet, fontStyleMapSet ), true, TEST_LOCATION );
1162   }
1163   DALI_TEST_CHECK( inputStyleChangedSignal );
1164
1165   gInputStyleChangedCallbackCalled = false;
1166   gInputStyleMask = TextEditor::InputStyle::NONE;
1167   inputStyleChangedSignal = false;
1168
1169   // Create a tap event to touch the text editor.
1170   application.ProcessEvent( GenerateTap( Gesture::Possible, 1u, 1u, Vector2( 191.f, 25.f ) ) );
1171   application.ProcessEvent( GenerateTap( Gesture::Started, 1u, 1u, Vector2( 191.f, 25.f ) ) );
1172
1173   // Render and notify
1174   application.SendNotification();
1175   application.Render();
1176
1177   // Executes the idle callbacks added by the text control on the change of input style.
1178   application.RunIdles();
1179
1180   DALI_TEST_CHECK( !gInputStyleChangedCallbackCalled );
1181   DALI_TEST_CHECK( !inputStyleChangedSignal );
1182
1183   END_TEST;
1184 }
1185
1186 int utcDaliTextEditorInputStyleChanged02(void)
1187 {
1188   ToolkitTestApplication application;
1189   tet_infoline(" utcDaliTextEditorInputStyleChanged02");
1190
1191   // The text-editor emits signals when the input style changes. These changes of style are
1192   // detected during the relayout process (size negotiation), i.e after the cursor has been moved. Signals
1193   // can't be emitted during the size negotiation as the callbacks may update the UI.
1194   // The text-editor adds an idle callback to the adaptor to emit the signals after the size negotiation.
1195   // This creates an implementation of the adaptor stub and a queue of idle callbacks.
1196   application.CreateAdaptor();
1197
1198   // Load some fonts.
1199
1200   char* pathNamePtr = get_current_dir_name();
1201   const std::string pathName( pathNamePtr );
1202   free( pathNamePtr );
1203
1204   TextAbstraction::FontClient fontClient = TextAbstraction::FontClient::Get();
1205   fontClient.SetDpi( 93u, 93u );
1206
1207   fontClient.GetFontId( pathName + DEFAULT_FONT_DIR + "/dejavu/DejaVuSerif.ttf", DEFAULT_FONT_SIZE );
1208   fontClient.GetFontId( pathName + DEFAULT_FONT_DIR + "/dejavu/DejaVuSerif-Bold.ttf", DEFAULT_FONT_SIZE );
1209
1210   TextEditor editor = TextEditor::New();
1211   DALI_TEST_CHECK( editor );
1212
1213
1214   editor.SetSize( 300.f, 50.f );
1215   editor.SetParentOrigin( ParentOrigin::TOP_LEFT );
1216   editor.SetAnchorPoint( AnchorPoint::TOP_LEFT );
1217
1218   editor.SetProperty( TextEditor::Property::ENABLE_MARKUP, true );
1219   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>" );
1220
1221   // connect to the text changed signal.
1222   ConnectionTracker* testTracker = new ConnectionTracker();
1223   editor.InputStyleChangedSignal().Connect( &TestInputStyleChangedCallback );
1224   bool inputStyleChangedSignal = false;
1225   editor.ConnectSignal( testTracker, "inputStyleChanged",   CallbackFunctor(&inputStyleChangedSignal) );
1226
1227   Stage::GetCurrent().Add( editor );
1228
1229   // Render and notify
1230   application.SendNotification();
1231   application.Render();
1232
1233   // Executes the idle callbacks added by the text control on the change of input style.
1234   application.RunIdles();
1235
1236   gInputStyleChangedCallbackCalled = false;
1237   gInputStyleMask = TextEditor::InputStyle::NONE;
1238   inputStyleChangedSignal = false;
1239
1240   // Create a tap event to touch the text editor.
1241   application.ProcessEvent( GenerateTap( Gesture::Possible, 1u, 1u, Vector2( 53.f, 25.f ) ) );
1242   application.ProcessEvent( GenerateTap( Gesture::Started, 1u, 1u, Vector2( 53.f, 25.f ) ) );
1243   application.ProcessEvent( GenerateTap( Gesture::Possible, 2u, 1u, Vector2( 53.f, 25.f ) ) );
1244   application.ProcessEvent( GenerateTap( Gesture::Started, 2u, 1u, Vector2( 53.f, 25.f ) ) );
1245
1246   // Render and notify
1247   application.SendNotification();
1248   application.Render();
1249
1250   // Executes the idle callbacks added by the text control on the change of input style.
1251   application.RunIdles();
1252
1253   DALI_TEST_CHECK( gInputStyleChangedCallbackCalled );
1254   if( gInputStyleChangedCallbackCalled )
1255   {
1256     DALI_TEST_EQUALS( static_cast<unsigned int>( gInputStyleMask ),
1257                       static_cast<unsigned int>( TextEditor::InputStyle::FONT_FAMILY |
1258                                                  TextEditor::InputStyle::POINT_SIZE  |
1259                                                  TextEditor::InputStyle::COLOR ),
1260                       TEST_LOCATION );
1261
1262     const Vector4 color = editor.GetProperty( TextEditor::Property::INPUT_COLOR ).Get<Vector4>();
1263     DALI_TEST_EQUALS( color, Color::GREEN, TEST_LOCATION );
1264
1265     const std::string fontFamily = editor.GetProperty( TextEditor::Property::INPUT_FONT_FAMILY ).Get<std::string>();
1266     DALI_TEST_EQUALS( fontFamily, "DejaVuSerif", TEST_LOCATION );
1267
1268     const float pointSize = editor.GetProperty( TextEditor::Property::INPUT_POINT_SIZE ).Get<float>();
1269     DALI_TEST_EQUALS( pointSize, 18.f, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
1270   }
1271   DALI_TEST_CHECK( inputStyleChangedSignal );
1272
1273   gInputStyleChangedCallbackCalled = false;
1274   gInputStyleMask = TextEditor::InputStyle::NONE;
1275   inputStyleChangedSignal = false;
1276
1277   application.ProcessEvent( GenerateKey( "", "", DALI_KEY_BACKSPACE, 0, 0, Integration::KeyEvent::Down, DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
1278
1279   // Render and notify
1280   application.SendNotification();
1281   application.Render();
1282
1283   // Executes the idle callbacks added by the text control on the change of input style.
1284   application.RunIdles();
1285
1286   DALI_TEST_CHECK( gInputStyleChangedCallbackCalled );
1287   if( gInputStyleChangedCallbackCalled )
1288   {
1289     DALI_TEST_EQUALS( static_cast<unsigned int>( gInputStyleMask ),
1290                       static_cast<unsigned int>( TextEditor::InputStyle::COLOR ),
1291                       TEST_LOCATION );
1292
1293     const Vector4 color = editor.GetProperty( TextEditor::Property::INPUT_COLOR ).Get<Vector4>();
1294     DALI_TEST_EQUALS( color, Color::BLUE, TEST_LOCATION );
1295   }
1296   DALI_TEST_CHECK( inputStyleChangedSignal );
1297
1298   gInputStyleChangedCallbackCalled = false;
1299   gInputStyleMask = TextEditor::InputStyle::NONE;
1300   inputStyleChangedSignal = false;
1301
1302   application.ProcessEvent( GenerateKey( "", "", DALI_KEY_BACKSPACE, 0, 0, Integration::KeyEvent::Down, DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
1303
1304   // Render and notify
1305   application.SendNotification();
1306   application.Render();
1307
1308   // Executes the idle callbacks added by the text control on the change of input style.
1309   application.RunIdles();
1310
1311   DALI_TEST_CHECK( !gInputStyleChangedCallbackCalled );
1312   DALI_TEST_CHECK( !inputStyleChangedSignal );
1313
1314   gInputStyleChangedCallbackCalled = false;
1315   gInputStyleMask = TextEditor::InputStyle::NONE;
1316   inputStyleChangedSignal = false;
1317
1318   application.ProcessEvent( GenerateKey( "", "", DALI_KEY_BACKSPACE, 0, 0, Integration::KeyEvent::Down, DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
1319
1320   // Render and notify
1321   application.SendNotification();
1322   application.Render();
1323
1324   // Executes the idle callbacks added by the text control on the change of input style.
1325   application.RunIdles();
1326
1327   DALI_TEST_CHECK( gInputStyleChangedCallbackCalled );
1328   if( gInputStyleChangedCallbackCalled )
1329   {
1330     DALI_TEST_EQUALS( static_cast<unsigned int>( gInputStyleMask ),
1331                       static_cast<unsigned int>( TextEditor::InputStyle::COLOR ),
1332                       TEST_LOCATION );
1333
1334     const Vector4 color = editor.GetProperty( TextEditor::Property::INPUT_COLOR ).Get<Vector4>();
1335     DALI_TEST_EQUALS( color, Color::BLACK, TEST_LOCATION );
1336   }
1337   DALI_TEST_CHECK( inputStyleChangedSignal );
1338
1339   gInputStyleChangedCallbackCalled = false;
1340   gInputStyleMask = TextEditor::InputStyle::NONE;
1341   inputStyleChangedSignal = false;
1342
1343   editor.SetProperty( TextEditor::Property::INPUT_COLOR, Color::YELLOW );
1344
1345   Property::Map fontStyleMapSet;
1346   fontStyleMapSet.Insert( "weight", "thin" );
1347   fontStyleMapSet.Insert( "width", "condensed" );
1348   fontStyleMapSet.Insert( "slant", "italic" );
1349
1350   editor.SetProperty( TextEditor::Property::INPUT_FONT_STYLE, fontStyleMapSet );
1351   editor.SetProperty( TextEditor::Property::INPUT_POINT_SIZE, 20.f );
1352   editor.SetProperty( TextEditor::Property::INPUT_LINE_SPACING, 5.f );
1353
1354   editor.SetProperty( TextEditor::Property::INPUT_UNDERLINE, "underline" );
1355   editor.SetProperty( TextEditor::Property::INPUT_SHADOW, "shadow" );
1356   editor.SetProperty( TextEditor::Property::INPUT_EMBOSS, "emboss" );
1357   editor.SetProperty( TextEditor::Property::INPUT_OUTLINE, "outline" );
1358
1359   application.ProcessEvent( GenerateKey( "a", "a", KEY_A_CODE, 0, 0, Integration::KeyEvent::Down, DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
1360
1361   // Render and notify
1362   application.SendNotification();
1363   application.Render();
1364
1365   // Executes the idle callbacks added by the text control on the change of input style.
1366   application.RunIdles();
1367
1368   DALI_TEST_CHECK( !gInputStyleChangedCallbackCalled );
1369   DALI_TEST_CHECK( !inputStyleChangedSignal );
1370
1371   // Create a tap event to touch the text editor.
1372   application.ProcessEvent( GenerateTap( Gesture::Possible, 1u, 1u, Vector2( 63.f, 25.f ) ) );
1373   application.ProcessEvent( GenerateTap( Gesture::Started, 1u, 1u, Vector2( 63.f, 25.f ) ) );
1374
1375   // Render and notify
1376   application.SendNotification();
1377   application.Render();
1378
1379   // Executes the idle callbacks added by the text control on the change of input style.
1380   application.RunIdles();
1381
1382   DALI_TEST_CHECK( gInputStyleChangedCallbackCalled );
1383   if( gInputStyleChangedCallbackCalled )
1384   {
1385     DALI_TEST_EQUALS( static_cast<unsigned int>( gInputStyleMask ),
1386                       static_cast<unsigned int>( TextEditor::InputStyle::COLOR |
1387                                                  TextEditor::InputStyle::POINT_SIZE |
1388                                                  TextEditor::InputStyle::FONT_STYLE |
1389                                                  TextEditor::InputStyle::LINE_SPACING |
1390                                                  TextEditor::InputStyle::UNDERLINE |
1391                                                  TextEditor::InputStyle::SHADOW |
1392                                                  TextEditor::InputStyle::EMBOSS |
1393                                                  TextEditor::InputStyle::OUTLINE ),
1394                       TEST_LOCATION );
1395
1396     const Vector4 color = editor.GetProperty( TextEditor::Property::INPUT_COLOR ).Get<Vector4>();
1397     DALI_TEST_EQUALS( color, Color::BLACK, TEST_LOCATION );
1398   }
1399   DALI_TEST_CHECK( inputStyleChangedSignal );
1400
1401   gInputStyleChangedCallbackCalled = false;
1402   gInputStyleMask = TextEditor::InputStyle::NONE;
1403   inputStyleChangedSignal = false;
1404
1405   editor.SetProperty( TextEditor::Property::FONT_FAMILY, "DejaVuSerif" );
1406
1407   fontStyleMapSet.Clear();
1408   fontStyleMapSet.Insert( "weight", "black" );
1409   fontStyleMapSet.Insert( "width", "expanded" );
1410   fontStyleMapSet.Insert( "slant", "oblique" );
1411
1412   editor.SetProperty( TextEditor::Property::FONT_STYLE, fontStyleMapSet );
1413
1414   // Create a tap event to touch the text editor.
1415   application.ProcessEvent( GenerateTap( Gesture::Possible, 1u, 1u, Vector2( 30.f, 25.f ) ) );
1416   application.ProcessEvent( GenerateTap( Gesture::Started, 1u, 1u, Vector2( 30.f, 25.f ) ) );
1417
1418   // Render and notify
1419   application.SendNotification();
1420   application.Render();
1421
1422   // Executes the idle callbacks added by the text control on the change of input style.
1423   application.RunIdles();
1424
1425   DALI_TEST_CHECK( gInputStyleChangedCallbackCalled );
1426   if( gInputStyleChangedCallbackCalled )
1427   {
1428     DALI_TEST_EQUALS( static_cast<unsigned int>( gInputStyleMask ),
1429                       static_cast<unsigned int>( TextEditor::InputStyle::COLOR |
1430                                                  TextEditor::InputStyle::POINT_SIZE |
1431                                                  TextEditor::InputStyle::FONT_STYLE ),
1432                       TEST_LOCATION );
1433
1434     const Vector4 color = editor.GetProperty( TextEditor::Property::INPUT_COLOR ).Get<Vector4>();
1435     DALI_TEST_EQUALS( color, Color::YELLOW, TEST_LOCATION );
1436   }
1437   DALI_TEST_CHECK( inputStyleChangedSignal );
1438
1439   END_TEST;
1440 }
1441
1442 int utcDaliTextEditorEvent01(void)
1443 {
1444   ToolkitTestApplication application;
1445   tet_infoline(" utcDaliTextEditorEvent01");
1446
1447   // Creates a tap event. After creating a tap event the text editor should
1448   // have the focus and add text with key events should be possible.
1449
1450   TextEditor editor = TextEditor::New();
1451   DALI_TEST_CHECK( editor );
1452
1453   Stage::GetCurrent().Add( editor );
1454
1455   editor.SetSize( 300.f, 50.f );
1456   editor.SetParentOrigin( ParentOrigin::TOP_LEFT );
1457   editor.SetAnchorPoint( AnchorPoint::TOP_LEFT );
1458
1459   // Avoid a crash when core load gl resources.
1460   application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
1461
1462   // Render and notify
1463   application.SendNotification();
1464   application.Render();
1465
1466   // Add a key event but as the text editor has not the focus it should do nothing.
1467   application.ProcessEvent( GenerateKey( "a", "a", KEY_A_CODE, 0, 0, Integration::KeyEvent::Down, DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
1468
1469   // Render and notify
1470   application.SendNotification();
1471   application.Render();
1472
1473   DALI_TEST_EQUALS( editor.GetProperty<std::string>( TextEditor::Property::TEXT ), std::string(""), TEST_LOCATION );
1474
1475   // Create a tap event to touch the text editor.
1476   application.ProcessEvent( GenerateTap( Gesture::Possible, 1u, 1u, Vector2( 150.0f, 25.0f ) ) );
1477   application.ProcessEvent( GenerateTap( Gesture::Started, 1u, 1u, Vector2( 150.0f, 25.0f ) ) );
1478
1479   // Render and notify
1480   application.SendNotification();
1481   application.Render();
1482
1483   // Now the text editor has the focus, so it can handle the key events.
1484   application.ProcessEvent( GenerateKey( "a", "a", KEY_A_CODE, 0, 0, Integration::KeyEvent::Down, DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
1485   application.ProcessEvent( GenerateKey( "a", "a", KEY_A_CODE, 0, 0, Integration::KeyEvent::Down, DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
1486
1487   // Render and notify
1488   application.SendNotification();
1489   application.Render();
1490
1491   DALI_TEST_EQUALS( editor.GetProperty<std::string>( TextEditor::Property::TEXT ), std::string("aa"), TEST_LOCATION );
1492
1493   // Create a second text editor and send key events to it.
1494   TextEditor editor2 = TextEditor::New();
1495
1496   editor2.SetParentOrigin( ParentOrigin::TOP_LEFT );
1497   editor2.SetAnchorPoint( AnchorPoint::TOP_LEFT );
1498   editor2.SetSize( 100.f, 100.f );
1499   editor2.SetPosition( 100.f, 100.f );
1500
1501   Stage::GetCurrent().Add( editor2 );
1502
1503   // Render and notify
1504   application.SendNotification();
1505   application.Render();
1506
1507   // Create a tap event on the second text editor.
1508   application.ProcessEvent( GenerateTap( Gesture::Possible, 1u, 1u, Vector2( 150.0f, 125.0f ) ) );
1509   application.ProcessEvent( GenerateTap( Gesture::Started, 1u, 1u, Vector2( 150.0f, 125.0f ) ) );
1510
1511   // Render and notify
1512   application.SendNotification();
1513   application.Render();
1514
1515   // The second text editor has the focus. It should handle the key events.
1516   application.ProcessEvent( GenerateKey( "a", "a", KEY_A_CODE, 0, 0, Integration::KeyEvent::Down, DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
1517   application.ProcessEvent( GenerateKey( "a", "a", KEY_A_CODE, 0, 0, Integration::KeyEvent::Down, DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
1518
1519   // Render and notify
1520   application.SendNotification();
1521   application.Render();
1522
1523   // Check the text has been added to the second text editor.
1524   DALI_TEST_EQUALS( editor2.GetProperty<std::string>( TextEditor::Property::TEXT ), std::string("aa"), TEST_LOCATION );
1525
1526   END_TEST;
1527 }
1528
1529 int utcDaliTextEditorEvent02(void)
1530 {
1531   ToolkitTestApplication application;
1532   tet_infoline(" utcDaliTextEditorEvent02");
1533
1534   // Checks if the right number of actors are created.
1535
1536   TextEditor editor = TextEditor::New();
1537   editor.SetProperty( TextEditor::Property::POINT_SIZE, 10.f );
1538   DALI_TEST_CHECK( editor );
1539
1540   Stage::GetCurrent().Add( editor );
1541
1542   editor.SetSize( 300.f, 50.f );
1543   editor.SetParentOrigin( ParentOrigin::TOP_LEFT );
1544   editor.SetAnchorPoint( AnchorPoint::TOP_LEFT );
1545
1546   // Avoid a crash when core load gl resources.
1547   application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
1548
1549   // Render and notify
1550   application.SendNotification();
1551   application.Render();
1552
1553   // Check there are the expected number of children (the stencil).
1554   DALI_TEST_EQUALS( editor.GetChildCount(), 1u, TEST_LOCATION );
1555
1556   Actor stencil = editor.GetChildAt( 0u );
1557
1558   // Create a tap event to touch the text editor.
1559   application.ProcessEvent( GenerateTap( Gesture::Possible, 1u, 1u, Vector2( 150.0f, 25.0f ) ) );
1560   application.ProcessEvent( GenerateTap( Gesture::Started, 1u, 1u, Vector2( 150.0f, 25.0f ) ) );
1561
1562   // Render and notify
1563   application.SendNotification();
1564   application.Render();
1565
1566   Actor layer = editor.GetChildAt( 1u );
1567   DALI_TEST_CHECK( layer.IsLayer() );
1568
1569   DALI_TEST_EQUALS( layer.GetChildCount(), 1u, TEST_LOCATION ); // The cursor.
1570   DALI_TEST_EQUALS( stencil.GetChildCount(), 0u, TEST_LOCATION );
1571
1572   // Now the text editor has the focus, so it can handle the key events.
1573   application.ProcessEvent( GenerateKey( "a", "a", KEY_A_CODE, 0, 0, Integration::KeyEvent::Down, DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
1574   application.ProcessEvent( GenerateKey( "a", "a", KEY_A_CODE, 0, 0, Integration::KeyEvent::Down, DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
1575
1576   // Render and notify
1577   application.SendNotification();
1578   application.Render();
1579
1580   // Checks the cursor and the renderer have been created.
1581   DALI_TEST_EQUALS( layer.GetChildCount(), 1u, TEST_LOCATION ); // The cursor.
1582   DALI_TEST_EQUALS( stencil.GetChildCount(), 1u, TEST_LOCATION ); // The renderer
1583
1584   Control cursor = Control::DownCast( layer.GetChildAt( 0u ) );
1585   DALI_TEST_CHECK( cursor );
1586
1587   // The stencil actor has a container with all the actors which contain the text renderers.
1588   Actor container = stencil.GetChildAt( 0u );
1589   for( unsigned int index = 0; index < container.GetChildCount(); ++index )
1590   {
1591     Renderer renderer = container.GetChildAt( index ).GetRendererAt( 0u );
1592     DALI_TEST_CHECK( renderer );
1593   }
1594
1595   // Move the cursor and check the position changes.
1596   Vector3 position1 = cursor.GetCurrentPosition();
1597
1598   application.ProcessEvent( GenerateKey( "", "", DALI_KEY_CURSOR_LEFT, 0, 0, Integration::KeyEvent::Down, DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
1599   application.ProcessEvent( GenerateKey( "", "", DALI_KEY_CURSOR_LEFT, 0, 0, Integration::KeyEvent::Down, DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
1600
1601   // Render and notify
1602   application.SendNotification();
1603   application.Render();
1604
1605   Vector3 position2 = cursor.GetCurrentPosition();
1606
1607   DALI_TEST_CHECK( position2.x < position1.x );
1608
1609   application.ProcessEvent( GenerateKey( "", "", DALI_KEY_CURSOR_RIGHT, 0, 0, Integration::KeyEvent::Down, DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
1610   application.ProcessEvent( GenerateKey( "", "", DALI_KEY_CURSOR_RIGHT, 0, 0, Integration::KeyEvent::Down, DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
1611
1612   // Render and notify
1613   application.SendNotification();
1614   application.Render();
1615
1616   Vector3 position3 = cursor.GetCurrentPosition();
1617
1618   DALI_TEST_EQUALS( position1, position3, TEST_LOCATION ); // Should be in the same position1.
1619
1620   // Send some taps and check the cursor positions.
1621
1622   // Try to tap at the beginning.
1623   application.ProcessEvent( GenerateTap( Gesture::Possible, 1u, 1u, Vector2( 1.f, 25.0f ) ) );
1624   application.ProcessEvent( GenerateTap( Gesture::Started, 1u, 1u, Vector2( 1.f, 25.0f ) ) );
1625
1626   // Render and notify
1627   application.SendNotification();
1628   application.Render();
1629
1630   // Cursor position should be the same than position1.
1631   Vector3 position4 = cursor.GetCurrentPosition();
1632
1633   DALI_TEST_EQUALS( position2, position4, TEST_LOCATION ); // Should be in the same position2.
1634
1635   // Tap away from the start position.
1636   application.ProcessEvent( GenerateTap( Gesture::Possible, 1u, 1u, Vector2( 16.f, 25.0f ) ) );
1637   application.ProcessEvent( GenerateTap( Gesture::Started, 1u, 1u, Vector2( 16.0f, 25.0f ) ) );
1638
1639   // Render and notify
1640   application.SendNotification();
1641   application.Render();
1642
1643   Vector3 position5 = cursor.GetCurrentPosition();
1644
1645   DALI_TEST_CHECK( position5.x > position4.x );
1646
1647   // Remove all the text.
1648   application.ProcessEvent( GenerateKey( "", "", DALI_KEY_BACKSPACE, 0, 0, Integration::KeyEvent::Down, DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
1649   application.ProcessEvent( GenerateKey( "", "", DALI_KEY_BACKSPACE, 0, 0, Integration::KeyEvent::Down, DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
1650   editor.SetProperty( TextEditor::Property::TEXT, "" );
1651
1652   // Render and notify
1653   application.SendNotification();
1654   application.Render();
1655
1656   // Cursor position should be the same than position2.
1657   Vector3 position6 = cursor.GetCurrentPosition();
1658
1659   DALI_TEST_EQUALS( position2, position6, TEST_LOCATION );// Should be in the same position2.
1660
1661   // Should not be a renderer.
1662   DALI_TEST_EQUALS( stencil.GetChildCount(), 0u, TEST_LOCATION );
1663
1664   END_TEST;
1665 }
1666
1667 int utcDaliTextEditorEvent03(void)
1668 {
1669   ToolkitTestApplication application;
1670   tet_infoline(" utcDaliTextEditorEvent03");
1671
1672   // Checks if the highlight actor is created.
1673
1674   TextEditor editor = TextEditor::New();
1675   DALI_TEST_CHECK( editor );
1676
1677   Stage::GetCurrent().Add( editor );
1678
1679   editor.SetProperty( TextEditor::Property::TEXT, "This is a long text for the size of the text-editor." );
1680   editor.SetProperty( TextEditor::Property::POINT_SIZE, 10.f );
1681   editor.SetSize( 30.f, 50.f );
1682   editor.SetParentOrigin( ParentOrigin::TOP_LEFT );
1683   editor.SetAnchorPoint( AnchorPoint::TOP_LEFT );
1684
1685   // Avoid a crash when core load gl resources.
1686   application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
1687
1688   // Render and notify
1689   application.SendNotification();
1690   application.Render();
1691
1692   // Send some taps and check text controller with clipboard window
1693   Dali::Clipboard clipboard = Clipboard::Get();
1694   clipboard.ShowClipboard();
1695   application.ProcessEvent( GenerateTap( Gesture::Possible, 1u, 1u, Vector2( 3.f, 25.0f ) ) );
1696   application.ProcessEvent( GenerateTap( Gesture::Started, 1u, 1u, Vector2( 3.f, 25.0f ) ) );
1697   clipboard.HideClipboard();
1698
1699   // Render and notify
1700   application.SendNotification();
1701   application.Render();
1702
1703   // Tap first to get the focus.
1704   application.ProcessEvent( GenerateTap( Gesture::Possible, 1u, 1u, Vector2( 3.f, 25.0f ) ) );
1705   application.ProcessEvent( GenerateTap( Gesture::Started, 1u, 1u, Vector2( 3.f, 25.0f ) ) );
1706
1707   // Render and notify
1708   application.SendNotification();
1709   application.Render();
1710
1711   // Double tap to select a word.
1712   application.ProcessEvent( GenerateTap( Gesture::Possible, 2u, 1u, Vector2( 3.f, 25.0f ) ) );
1713   application.ProcessEvent( GenerateTap( Gesture::Started, 2u, 1u, Vector2( 3.f, 25.0f ) ) );
1714
1715   // Render and notify
1716   application.SendNotification();
1717   application.Render();
1718
1719   // The stencil actor should have two actors: the renderer and the highlight actor.
1720   Actor stencil = editor.GetChildAt( 0u );
1721
1722   // Highlight needs to be drawn before text, so should come first in child order
1723   Renderer highlight = stencil.GetChildAt( 0u ).GetRendererAt( 0u );
1724   DALI_TEST_CHECK( highlight );
1725
1726   // The stencil actor has a container with all the actors which contain the text renderers.
1727   Actor container = stencil.GetChildAt( 1u );
1728   for( unsigned int index = 0; index < container.GetChildCount(); ++index )
1729   {
1730     Renderer renderer = container.GetChildAt( index ).GetRendererAt( 0u );
1731     DALI_TEST_CHECK( renderer );
1732   }
1733
1734   // Double tap out of bounds
1735   application.ProcessEvent( GenerateTap( Gesture::Possible, 2u, 1u, Vector2( 29.f, 25.0f ) ) );
1736   application.ProcessEvent( GenerateTap( Gesture::Started, 2u, 1u, Vector2( 29.f, 25.0f ) ) );
1737
1738   // Render and notify
1739   application.SendNotification();
1740   application.Render();
1741
1742   // The stencil actor should have one actors: the renderer actor.
1743   stencil = editor.GetChildAt( 0u );
1744
1745   // The stencil actor has a container with all the actors which contain the text renderers.
1746   container = stencil.GetChildAt( 0u );
1747   for( unsigned int index = 0; index < container.GetChildCount(); ++index )
1748   {
1749     Renderer renderer = container.GetChildAt( index ).GetRendererAt( 0u );
1750     DALI_TEST_CHECK( renderer );
1751   }
1752
1753   END_TEST;
1754 }
1755
1756 int utcDaliTextEditorEvent04(void)
1757 {
1758   ToolkitTestApplication application;
1759   tet_infoline(" utcDaliTextEditorEvent04");
1760
1761   // Checks if the highlight actor is created.
1762
1763   TextEditor editor = TextEditor::New();
1764   DALI_TEST_CHECK( editor );
1765
1766   Stage::GetCurrent().Add( editor );
1767
1768   editor.SetProperty( TextEditor::Property::TEXT, "Hello\nworl" );
1769   editor.SetProperty( TextEditor::Property::POINT_SIZE, 10.f );
1770   editor.SetSize( 100.f, 50.f );
1771   editor.SetParentOrigin( ParentOrigin::TOP_LEFT );
1772   editor.SetAnchorPoint( AnchorPoint::TOP_LEFT );
1773
1774   // Avoid a crash when core load gl resources.
1775   application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
1776
1777   // Render and notify
1778   application.SendNotification();
1779   application.Render();
1780
1781   // Tap on the text editor
1782   application.ProcessEvent( GenerateTap( Gesture::Possible, 1u, 1u, Vector2( 3.f, 25.0f ) ) );
1783   application.ProcessEvent( GenerateTap( Gesture::Started, 1u, 1u, Vector2( 3.f, 25.0f ) ) );
1784
1785   // Render and notify
1786   application.SendNotification();
1787   application.Render();
1788
1789   // Move at the end of the text.
1790   application.ProcessEvent( GenerateKey( "", "", DALI_KEY_CURSOR_DOWN, 0, 0, Integration::KeyEvent::Down, DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
1791   application.ProcessEvent( GenerateKey( "", "", DALI_KEY_CURSOR_DOWN, 0, 0, Integration::KeyEvent::Down, DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
1792
1793   // Render and notify
1794   application.SendNotification();
1795   application.Render();
1796
1797   for( unsigned int index = 0u; index < 10u; ++index )
1798   {
1799     application.ProcessEvent( GenerateKey( "", "", DALI_KEY_CURSOR_RIGHT, 0, 0, Integration::KeyEvent::Down, DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
1800     application.ProcessEvent( GenerateKey( "", "", DALI_KEY_CURSOR_RIGHT, 0, 0, Integration::KeyEvent::Down, DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
1801
1802     // Render and notify
1803     application.SendNotification();
1804     application.Render();
1805   }
1806
1807   // Add a character
1808   application.ProcessEvent( GenerateKey( "d", "d", KEY_D_CODE, 0, 0, Integration::KeyEvent::Down, DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
1809
1810   // Render and notify
1811   application.SendNotification();
1812   application.Render();
1813
1814   DALI_TEST_EQUALS( "Hello\nworld", editor.GetProperty<std::string>( TextEditor::Property::TEXT ), TEST_LOCATION );
1815
1816   // Add some key events
1817   application.ProcessEvent( GenerateKey( "", "", DALI_KEY_CURSOR_UP, 0, 0, Integration::KeyEvent::Down, DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
1818   application.ProcessEvent( GenerateKey( "", "", DALI_KEY_CURSOR_UP, 0, 0, Integration::KeyEvent::Down, DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
1819
1820   // Render and notify
1821   application.SendNotification();
1822   application.Render();
1823
1824   for( unsigned int index = 0u; index < 10u; ++index )
1825   {
1826     application.ProcessEvent( GenerateKey( "", "", DALI_KEY_CURSOR_LEFT, 0, 0, Integration::KeyEvent::Down, DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
1827     application.ProcessEvent( GenerateKey( "", "", DALI_KEY_CURSOR_LEFT, 0, 0, Integration::KeyEvent::Down, DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
1828
1829     // Render and notify
1830     application.SendNotification();
1831     application.Render();
1832   }
1833
1834   // Add a character
1835   application.ProcessEvent( GenerateKey( " ", " ", KEY_WHITE_SPACE_CODE, 0, 0, Integration::KeyEvent::Down, DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
1836
1837   // Render and notify
1838   application.SendNotification();
1839   application.Render();
1840
1841   DALI_TEST_EQUALS( " Hello\nworld", editor.GetProperty<std::string>( TextEditor::Property::TEXT ), TEST_LOCATION );
1842
1843   END_TEST;
1844 }
1845
1846 int utcDaliTextEditorEvent05(void)
1847 {
1848   ToolkitTestApplication application;
1849   tet_infoline(" utcDaliTextEditorEvent05");
1850
1851   // Checks if the highlight actor is created.
1852
1853   TextEditor editor = TextEditor::New();
1854   DALI_TEST_CHECK( editor );
1855
1856   Stage::GetCurrent().Add( editor );
1857
1858   editor.SetProperty( TextEditor::Property::TEXT, "Hello\nworl" );
1859   editor.SetProperty( TextEditor::Property::POINT_SIZE, 10.f );
1860   editor.SetSize( 50.f, 50.f );
1861   editor.SetParentOrigin( ParentOrigin::TOP_LEFT );
1862   editor.SetAnchorPoint( AnchorPoint::TOP_LEFT );
1863   editor.SetProperty( TextEditor::Property::SMOOTH_SCROLL, true );
1864   editor.SetProperty( TextEditor::Property::SMOOTH_SCROLL_DURATION, 0.2f );
1865   editor.SetProperty( TextEditor::Property::ENABLE_SCROLL_BAR, true );
1866   editor.SetProperty( TextEditor::Property::SCROLL_BAR_SHOW_DURATION, 0.3f );
1867   editor.SetProperty( TextEditor::Property::SCROLL_BAR_FADE_DURATION, 0.2f );
1868
1869   // Avoid a crash when core load gl resources.
1870   application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
1871
1872   // Render and notify
1873   application.SendNotification();
1874   application.Render();
1875
1876   // Tap on the text editor
1877   application.ProcessEvent( GenerateTap( Gesture::Possible, 1u, 1u, Vector2( 3.f, 25.0f ) ) );
1878   application.ProcessEvent( GenerateTap( Gesture::Started, 1u, 1u, Vector2( 3.f, 25.0f ) ) );
1879
1880   // Render and notify
1881   application.SendNotification();
1882   application.Render();
1883
1884   // Move at the end of the text.
1885   application.ProcessEvent( GenerateKey( "", "", DALI_KEY_CURSOR_DOWN, 0, 0, Integration::KeyEvent::Down, DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
1886   application.ProcessEvent( GenerateKey( "", "", DALI_KEY_CURSOR_DOWN, 0, 0, Integration::KeyEvent::Down, DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
1887
1888   // Render and notify
1889   application.SendNotification();
1890   application.Render();
1891
1892   for( unsigned int index = 0u; index < 10u; ++index )
1893   {
1894     // Add a character
1895     application.ProcessEvent( GenerateKey( "d", "d", KEY_D_CODE, 0, 0, Integration::KeyEvent::Down, DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
1896
1897     // Render and notify
1898     application.SendNotification();
1899     application.Render();
1900   }
1901   // Modify duration after scroll is enabled
1902   editor.SetProperty( TextEditor::Property::SMOOTH_SCROLL_DURATION, 0.1f );
1903
1904   // Continuous scroll left to increase coverage
1905   for( unsigned int index = 0u; index < 10u; ++index )
1906   {
1907     application.ProcessEvent( GenerateKey( "", "", DALI_KEY_CURSOR_LEFT, 0, 0, Integration::KeyEvent::Down, DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
1908
1909     // Render and notify
1910     application.SendNotification();
1911     application.Render();
1912   }
1913   DALI_TEST_EQUALS( editor.GetProperty<float>( TextEditor::Property::SMOOTH_SCROLL_DURATION ), 0.1f, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
1914   DALI_TEST_EQUALS( editor.GetProperty<bool>( TextEditor::Property::SMOOTH_SCROLL ), true, TEST_LOCATION );
1915   DALI_TEST_EQUALS( editor.GetProperty<bool>( TextEditor::Property::ENABLE_SCROLL_BAR ), true, TEST_LOCATION );
1916   DALI_TEST_EQUALS( editor.GetProperty<float>( TextEditor::Property::SCROLL_BAR_SHOW_DURATION ), 0.3f, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
1917   DALI_TEST_EQUALS( editor.GetProperty<float>( TextEditor::Property::SCROLL_BAR_FADE_DURATION ), 0.2f, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
1918
1919   // Press Escape to increase coverage
1920   application.ProcessEvent( GenerateKey( "", "", DALI_KEY_ESCAPE, 0, 0, Integration::KeyEvent::Up, DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
1921   application.SendNotification();
1922   application.Render();
1923
1924   DALI_TEST_CHECK( !editor.HasKeyInputFocus() );
1925
1926   END_TEST;
1927 }
1928
1929 int utcDaliTextEditorEvent06(void)
1930 {
1931   ToolkitTestApplication application;
1932   tet_infoline(" utcDaliTextEditorEvent06");
1933
1934   // Checks if the highlight actor is created.
1935
1936   TextEditor editor = TextEditor::New();
1937   DALI_TEST_CHECK( editor );
1938
1939   Stage::GetCurrent().Add( editor );
1940
1941   editor.SetProperty( TextEditor::Property::TEXT, "Hello\nworld\nHello world" );
1942   editor.SetProperty( TextEditor::Property::POINT_SIZE, 10.f );
1943   editor.SetSize( 100.f, 50.f );
1944   editor.SetParentOrigin( ParentOrigin::TOP_LEFT );
1945   editor.SetAnchorPoint( AnchorPoint::TOP_LEFT );
1946
1947   // Avoid a crash when core load gl resources.
1948   application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
1949
1950   // Render and notify
1951   application.SendNotification();
1952   application.Render();
1953
1954   // Tap on the text editor
1955   application.ProcessEvent( GenerateTap( Gesture::Possible, 1u, 1u, Vector2( 3.f, 25.0f ) ) );
1956   application.ProcessEvent( GenerateTap( Gesture::Started, 1u, 1u, Vector2( 3.f, 25.0f ) ) );
1957
1958   // Render and notify
1959   application.SendNotification();
1960   application.Render();
1961
1962   // Move to seconds line of the text.
1963   application.ProcessEvent( GenerateKey( "", "", DALI_KEY_CURSOR_DOWN, 0, 0, Integration::KeyEvent::Down, DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
1964
1965   // Render and notify
1966   application.SendNotification();
1967   application.Render();
1968
1969   float layoutHeight = editor.GetHeightForWidth( 100.f );
1970
1971
1972   // Add  another script characters ( glyph height is defferent )
1973   application.ProcessEvent( GenerateKey( "d", "ㅁ", KEY_D_CODE, 0, 0, Integration::KeyEvent::Down, DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
1974   application.ProcessEvent( GenerateKey( "d", "ኢ", KEY_D_CODE, 0, 0, Integration::KeyEvent::Down, DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
1975
1976   // Delete characters
1977   application.ProcessEvent( GenerateKey( "", "", DALI_KEY_BACKSPACE, 0, 0, Integration::KeyEvent::Down, DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
1978   application.ProcessEvent( GenerateKey( "", "", DALI_KEY_BACKSPACE, 0, 0, Integration::KeyEvent::Down, DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
1979
1980   DALI_TEST_EQUALS( layoutHeight, editor.GetHeightForWidth( 100.f ), TEST_LOCATION );
1981
1982   // Render and notify
1983   application.SendNotification();
1984   application.Render();
1985
1986   DALI_TEST_EQUALS( "Hello\nworld\nHello world", editor.GetProperty<std::string>( TextEditor::Property::TEXT ), TEST_LOCATION );
1987
1988   // For coverage
1989   application.ProcessEvent( GenerateKey( "", "", 0, 0, 0, Integration::KeyEvent::Down, DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
1990   application.SendNotification();
1991   application.Render();
1992
1993   application.ProcessEvent( GenerateKey( "", "", DALI_KEY_SHIFT_LEFT, 0, 0, Integration::KeyEvent::Down, DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
1994   application.SendNotification();
1995   application.Render();
1996
1997   application.ProcessEvent( GenerateKey( "", "", DALI_KEY_VOLUME_UP, 0, 0, Integration::KeyEvent::Down, DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
1998   application.SendNotification();
1999   application.Render();
2000
2001   application.ProcessEvent( GenerateKey( "", "", DALI_KEY_VOLUME_DOWN, 0, 0, Integration::KeyEvent::Down, DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2002   application.SendNotification();
2003   application.Render();
2004
2005   END_TEST;
2006 }
2007
2008 int utcDaliTextEditorHandles(void)
2009 {
2010   ToolkitTestApplication application;
2011   tet_infoline(" utcDaliTextEditorHandles");
2012
2013   TextEditor editor = TextEditor::New();
2014   DALI_TEST_CHECK( editor );
2015
2016   Stage::GetCurrent().Add( editor );
2017
2018   editor.SetProperty( TextEditor::Property::TEXT, "This is a long text for the size of the text-editor." );
2019   editor.SetProperty( TextEditor::Property::POINT_SIZE, 10.f );
2020   editor.SetProperty( TextEditor::Property::GRAB_HANDLE_IMAGE, HANDLE_IMAGE_FILE_NAME );
2021   editor.SetProperty( TextEditor::Property::SMOOTH_SCROLL, true );
2022
2023   editor.SetSize( 30.f, 500.f );
2024   editor.SetParentOrigin( ParentOrigin::TOP_LEFT );
2025   editor.SetAnchorPoint( AnchorPoint::TOP_LEFT );
2026
2027   // Avoid a crash when core load gl resources.
2028   application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
2029
2030   // Render and notify
2031   application.SendNotification();
2032   application.Render();
2033
2034   // Tap first to get the focus.
2035   application.ProcessEvent( GenerateTap( Gesture::Possible, 1u, 1u, Vector2( 3.f, 25.0f ) ) );
2036   application.ProcessEvent( GenerateTap( Gesture::Started, 1u, 1u, Vector2( 3.f, 25.0f ) ) );
2037
2038   // Render and notify
2039   application.SendNotification();
2040   application.Render();
2041
2042   // Tap to create the grab handle.
2043   application.ProcessEvent( GenerateTap( Gesture::Possible, 1u, 1u, Vector2( 3.f, 25.0f ) ) );
2044   application.ProcessEvent( GenerateTap( Gesture::Started, 1u, 1u, Vector2( 3.f, 25.0f ) ) );
2045
2046   // Render and notify
2047   application.SendNotification();
2048   application.Render();
2049
2050   // Get the active layer where the text's decoration is added.
2051   Actor activeLayer = editor.GetChildAt( 1u );
2052
2053   // Get the handle's actor.
2054   Actor handle = activeLayer.GetChildAt( 1u );
2055   handle.SetSize( 100.f, 100.f );
2056
2057   // Render and notify
2058   application.SendNotification();
2059   application.Render();
2060
2061   // Touch the grab handle to set it as pressed.
2062   Vector2 touchPos( 10.0f, 50.0f );
2063   Dali::Integration::TouchEvent event;
2064   event = Dali::Integration::TouchEvent();
2065   event.AddPoint( GetPointDownInside( touchPos ) );
2066   application.ProcessEvent( event );
2067
2068   // Render and notify
2069   application.SendNotification();
2070   application.Render();
2071
2072   // drag grab handle right
2073   SendPan(application, Gesture::Possible, touchPos);
2074   SendPan(application, Gesture::Started, touchPos);
2075   touchPos.x += 5.0f;
2076   Wait(application, 100);
2077
2078   for(int i = 0;i<20;i++)
2079   {
2080     SendPan(application, Gesture::Continuing, touchPos);
2081     touchPos.x += 5.0f;
2082     Wait(application);
2083   }
2084
2085   SendPan(application, Gesture::Finished, touchPos);
2086   Wait(application);
2087
2088   // Release the grab handle.
2089   event = Dali::Integration::TouchEvent();
2090   event.AddPoint( GetPointUpInside( touchPos ) );
2091   application.ProcessEvent( event );
2092
2093   // Render and notify
2094   application.SendNotification();
2095   application.Render();
2096
2097   END_TEST;
2098 }
2099
2100
2101 int utcDaliTextEditorUnderPropertyStringP(void)
2102 {
2103   ToolkitTestApplication application;
2104   tet_infoline(" utcDaliTextEditorUnderPropertyStringP");
2105   TextEditor editor = TextEditor::New();
2106   DALI_TEST_CHECK( editor );
2107
2108   std::string underlineSettings1( "{\"enable\":\"true\",\"color\":\"red\",\"height\":\"1\"}" );
2109
2110   Stage::GetCurrent().Add( editor );
2111
2112   editor.SetProperty( TextEditor::Property::UNDERLINE, underlineSettings1 );
2113   DALI_TEST_EQUALS( editor.GetProperty<std::string>( TextEditor::Property::UNDERLINE ), underlineSettings1, TEST_LOCATION );
2114
2115   tet_infoline("Set underline settings with a map");
2116   // Check the input underline property
2117   Property::Map underlineMapSet;
2118   Property::Map underlineMapGet;
2119   underlineMapSet.Insert( "enable", "true" );
2120   underlineMapSet.Insert( "color", "blue" );
2121   underlineMapSet.Insert( "height", "2" );
2122
2123   editor.SetProperty( TextEditor::Property::UNDERLINE, underlineMapSet );
2124   underlineMapGet = editor.GetProperty<Property::Map>( TextEditor::Property::UNDERLINE );
2125   DALI_TEST_EQUALS( underlineMapGet.Count(), underlineMapSet.Count(), TEST_LOCATION );
2126   DALI_TEST_EQUALS( DaliTestCheckMaps( underlineMapSet, underlineMapGet ), true,  TEST_LOCATION );
2127
2128   tet_infoline("Set underline settings with a string");
2129   editor.SetProperty( TextEditor::Property::UNDERLINE, underlineSettings1 );
2130   Property::Value value = editor.GetProperty( TextEditor::Property::UNDERLINE );
2131   std::string result;
2132   value.Get(result);
2133   DALI_TEST_EQUALS( result , underlineSettings1, TEST_LOCATION  );
2134
2135   tet_infoline("Trying to set invalid underline settings, should not update and stay at previous settings");
2136   std::string underlineSettingsVoid( "{\"enable\":\"true\",\"coooolor\":\"blue\",\"heeeight\":\"4\"}" );
2137   editor.SetProperty( TextEditor::Property::UNDERLINE, underlineSettingsVoid );
2138   value = editor.GetProperty( TextEditor::Property::UNDERLINE );
2139   value.Get(result);
2140   DALI_TEST_EQUALS( result , underlineSettings1, TEST_LOCATION  );
2141
2142   END_TEST;
2143 }
2144
2145 int utcDaliTextEditorShadowPropertyStringP(void)
2146 {
2147   ToolkitTestApplication application;
2148   tet_infoline(" utcDaliTextEditorUnderPropertyStringP Setting Shadow propeties by string");
2149
2150   TextEditor editor = TextEditor::New();
2151
2152   std::string shadowSettings( "{\"color\":\"green\",\"offset\":\"2 2\"}" );
2153
2154   Stage::GetCurrent().Add( editor );
2155
2156   editor.SetProperty( TextEditor::Property::SHADOW, "{\"color\":\"green\",\"offset\":\"2 2\"}" );
2157
2158   Property::Value value = editor.GetProperty<std::string>( TextEditor::Property::SHADOW );
2159   std::string result;
2160   value.Get(result);
2161
2162   DALI_TEST_EQUALS( result, shadowSettings, TEST_LOCATION );
2163
2164   END_TEST;
2165 }
2166
2167 int utcDaliTextEditorFontStylePropertyStringP(void)
2168 {
2169   ToolkitTestApplication application;
2170   tet_infoline(" utcDaliTextEditorFontStylePropertyStringP Setting FontStyle propeties by string");
2171
2172   TextEditor editor = TextEditor::New();
2173
2174   std::string fontStyleSettings( "{\"weight\":\"bold\",\"width\":\"condensed\",\"slant\":\"italic\"}" );
2175
2176   Stage::GetCurrent().Add( editor );
2177
2178   editor.SetProperty( TextEditor::Property::FONT_STYLE, "{\"weight\":\"bold\",\"width\":\"condensed\",\"slant\":\"italic\"}" );
2179
2180   Property::Value value = editor.GetProperty<std::string>( TextEditor::Property::FONT_STYLE );
2181   std::string result;
2182   value.Get(result);
2183
2184   DALI_TEST_EQUALS( result, fontStyleSettings, TEST_LOCATION );
2185
2186   END_TEST;
2187 }
2188
2189 int utcDaliTextEditorGetPropertyLinecountP(void)
2190 {
2191   ToolkitTestApplication application;
2192
2193   tet_infoline(" utcDaliTextEditorGetPropertyLinecount getting line count property");
2194
2195   int lineCount =0 ;
2196
2197   TextEditor editor = TextEditor::New();
2198   editor.SetProperty( TextEditor::Property::POINT_SIZE, 10) ;
2199   editor.SetProperty( TextEditor::Property::TEXT,
2200                        "TEST TEST TEST TEST TEST TEST TEST TEST TEST TEST TEST TEST TEST TEST ");
2201
2202   Stage::GetCurrent().Add( editor );
2203
2204   editor.SetSize( 100.0f, 100.0f );
2205   lineCount =  editor.GetProperty<int>( TextEditor::Property::LINE_COUNT );
2206   DALI_TEST_EQUALS( lineCount, 14, TEST_LOCATION );
2207
2208   editor.SetSize( 50.0f, 100.0f );
2209   lineCount =  editor.GetProperty<int>( TextEditor::Property::LINE_COUNT );
2210   DALI_TEST_EQUALS( lineCount, 28, TEST_LOCATION );
2211
2212   END_TEST;
2213 }
2214
2215 int utcDaliTextEditorScrollStateChangedSignalTest(void)
2216 {
2217
2218   ToolkitTestApplication application;
2219   tet_infoline(" UtcDaliTextEditorScrollStateChangedSignalTest");
2220
2221   TextEditor editor = TextEditor::New();
2222   DALI_TEST_CHECK( editor );
2223
2224   Stage::GetCurrent().Add( editor );
2225
2226   editor.SetProperty( TextEditor::Property::POINT_SIZE, 10.f );
2227   editor.SetSize( 50.f, 50.f );
2228   editor.SetParentOrigin( ParentOrigin::TOP_LEFT );
2229   editor.SetAnchorPoint( AnchorPoint::TOP_LEFT );
2230   editor.SetProperty( TextEditor::Property::ENABLE_SCROLL_BAR, true );
2231   editor.SetKeyboardFocusable(true);
2232
2233   bool startedCalled = false;
2234   bool finishedCalled = false;
2235
2236   ScrollStateChangeCallback callback( startedCalled, finishedCalled );
2237   editor.ScrollStateChangedSignal().Connect( &callback, &ScrollStateChangeCallback::Callback );
2238
2239   KeyboardFocusManager::Get().SetCurrentFocusActor( editor );
2240
2241   // Render and notify
2242   application.SendNotification();
2243   application.Render();
2244
2245   editor.SetProperty( TextEditor::Property::TEXT, "Long enough message for TextEditor!");
2246   application.SendNotification();
2247   application.Render(6000);
2248
2249   application.SendNotification();
2250   DALI_TEST_EQUALS( startedCalled, true, TEST_LOCATION );
2251   DALI_TEST_EQUALS( finishedCalled, true, TEST_LOCATION );
2252
2253   END_TEST;
2254 }
2255
2256 int UtcDaliToolkitTextEditorTextWrapMode(void)
2257 {
2258   ToolkitTestApplication application;
2259   tet_infoline(" UtcDaliToolkitTextEditorTextWarpMode");
2260
2261   int lineCount =0 ;
2262
2263   TextEditor editor = TextEditor::New();
2264   editor.SetSize( 150.0f, 300.f );
2265   editor.SetProperty( TextEditor::Property::TEXT, "Hello world Hello world" );
2266
2267   Stage::GetCurrent().Add( editor );
2268
2269   editor.SetProperty( TextEditor::Property::LINE_WRAP_MODE, "WORD" );
2270   DALI_TEST_EQUALS( editor.GetProperty< int >( TextEditor::Property::LINE_WRAP_MODE ), static_cast< int >( Text::LineWrap::WORD ), TEST_LOCATION );
2271
2272   application.SendNotification();
2273   application.Render();
2274
2275   lineCount =  editor.GetProperty<int>( TextEditor::Property::LINE_COUNT );
2276   DALI_TEST_EQUALS( lineCount, 4, TEST_LOCATION );
2277
2278   editor.SetProperty( TextEditor::Property::LINE_WRAP_MODE, "CHARACTER" );
2279   DALI_TEST_EQUALS( editor.GetProperty< int >( TextEditor::Property::LINE_WRAP_MODE ), static_cast< int >( Text::LineWrap::CHARACTER ), TEST_LOCATION );
2280
2281   application.SendNotification();
2282   application.Render();
2283
2284   lineCount =  editor.GetProperty<int>( TextEditor::Property::LINE_COUNT );
2285   DALI_TEST_EQUALS( lineCount, 3, TEST_LOCATION );
2286
2287   editor.SetProperty( TextEditor::Property::LINE_WRAP_MODE, Text::LineWrap::WORD );
2288   DALI_TEST_EQUALS( editor.GetProperty< int >( TextEditor::Property::LINE_WRAP_MODE ), static_cast< int >( Text::LineWrap::WORD ), TEST_LOCATION );
2289
2290   application.SendNotification();
2291   application.Render();
2292
2293   lineCount =  editor.GetProperty<int>( TextEditor::Property::LINE_COUNT );
2294   DALI_TEST_EQUALS( lineCount, 4, TEST_LOCATION );
2295
2296   editor.SetProperty( TextEditor::Property::LINE_WRAP_MODE, Text::LineWrap::CHARACTER );
2297   DALI_TEST_EQUALS( editor.GetProperty< int >( TextEditor::Property::LINE_WRAP_MODE ), static_cast< int >( Text::LineWrap::CHARACTER ), TEST_LOCATION );
2298
2299   application.SendNotification();
2300   application.Render();
2301
2302   lineCount =  editor.GetProperty<int>( TextEditor::Property::LINE_COUNT );
2303   DALI_TEST_EQUALS( lineCount, 3, TEST_LOCATION );
2304
2305   END_TEST;
2306 }