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