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