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