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