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