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