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