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