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