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