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