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