Fixing the issue where characters were being drawn at the same location whenever...
[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   // Remove all text
979   editor.SetProperty( TextField::Property::TEXT, "" );
980
981   // Pressing backspace key: TextChangedCallback should not be called when there is no text in texteditor.
982   gTextChangedCallBackCalled = false;
983   application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_BACKSPACE, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
984   DALI_TEST_CHECK( !gTextChangedCallBackCalled );
985
986   // Pressing delete key: TextChangedCallback should not be called when there is no text in texteditor.
987   gTextChangedCallBackCalled = false;
988   application.ProcessEvent( GenerateKey( "", "", "", Dali::DevelKey::DALI_KEY_DELETE, 0, 0, Integration::KeyEvent::DOWN, "Delete", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
989   DALI_TEST_CHECK( !gTextChangedCallBackCalled );
990
991   END_TEST;
992 }
993
994 int utcDaliTextEditorInputStyleChanged01(void)
995 {
996   // The text-editor emits signals when the input style changes. These changes of style are
997   // detected during the relayout process (size negotiation), i.e after the cursor has been moved. Signals
998   // can't be emitted during the size negotiation as the callbacks may update the UI.
999   // The text-editor adds an idle callback to the adaptor to emit the signals after the size negotiation.
1000   // The ToolkitTestApplication creates an implementation of the adaptor stub and a queue of idle callbacks.
1001   ToolkitTestApplication application;
1002   tet_infoline(" utcDaliTextEditorInputStyleChanged01");
1003
1004   // Load some fonts.
1005
1006   char* pathNamePtr = get_current_dir_name();
1007   const std::string pathName( pathNamePtr );
1008   free( pathNamePtr );
1009
1010   TextAbstraction::FontClient fontClient = TextAbstraction::FontClient::Get();
1011   fontClient.SetDpi( 93u, 93u );
1012
1013   fontClient.GetFontId( pathName + DEFAULT_FONT_DIR + "/dejavu/DejaVuSerif.ttf", DEFAULT_FONT_SIZE );
1014   fontClient.GetFontId( pathName + DEFAULT_FONT_DIR + "/dejavu/DejaVuSerif-Bold.ttf", DEFAULT_FONT_SIZE );
1015
1016   TextEditor editor = TextEditor::New();
1017   DALI_TEST_CHECK( editor );
1018
1019
1020   editor.SetProperty( Actor::Property::SIZE, Vector2( 300.f, 50.f ) );
1021   editor.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT );
1022   editor.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT );
1023
1024   editor.SetProperty( TextEditor::Property::ENABLE_MARKUP, true );
1025   editor.SetProperty( TextEditor::Property::TEXT, "<font family='DejaVuSerif' size='18'>He<color value='green'>llo</color> <font weight='bold'>world</font> demo</font>" );
1026
1027   // connect to the text changed signal.
1028   ConnectionTracker* testTracker = new ConnectionTracker();
1029   editor.InputStyleChangedSignal().Connect( &TestInputStyleChangedCallback );
1030   bool inputStyleChangedSignal = false;
1031   editor.ConnectSignal( testTracker, "inputStyleChanged",   CallbackFunctor(&inputStyleChangedSignal) );
1032
1033   application.GetScene().Add( editor );
1034
1035   // Render and notify
1036   application.SendNotification();
1037   application.Render();
1038
1039   // Executes the idle callbacks added by the text control on the change of input style.
1040   application.RunIdles();
1041
1042   gInputStyleChangedCallbackCalled = false;
1043   gInputStyleMask = TextEditor::InputStyle::NONE;
1044   inputStyleChangedSignal = false;
1045
1046   // Create a tap event to touch the text editor.
1047   TestGenerateTap( application, 18.0f, 25.0f );
1048
1049   // Render and notify
1050   application.SendNotification();
1051   application.Render();
1052
1053   // Executes the idle callbacks added by the text control on the change of input style.
1054   application.RunIdles();
1055
1056   DALI_TEST_CHECK( gInputStyleChangedCallbackCalled );
1057   if( gInputStyleChangedCallbackCalled )
1058   {
1059     DALI_TEST_EQUALS( static_cast<unsigned int>( gInputStyleMask ), static_cast<unsigned int>( TextEditor::InputStyle::FONT_FAMILY | TextEditor::InputStyle::POINT_SIZE ), TEST_LOCATION );
1060
1061     const std::string fontFamily = editor.GetProperty( TextEditor::Property::INPUT_FONT_FAMILY ).Get<std::string>();
1062     DALI_TEST_EQUALS( fontFamily, "DejaVuSerif", TEST_LOCATION );
1063
1064     const float pointSize = editor.GetProperty( TextEditor::Property::INPUT_POINT_SIZE ).Get<float>();
1065     DALI_TEST_EQUALS( pointSize, 18.f, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
1066   }
1067   DALI_TEST_CHECK( inputStyleChangedSignal );
1068
1069   gInputStyleChangedCallbackCalled = false;
1070   gInputStyleMask = TextEditor::InputStyle::NONE;
1071   inputStyleChangedSignal = false;
1072
1073   // Create a tap event to touch the text editor.
1074   TestGenerateTap( application, 30.0f, 25.0f );
1075
1076   // Render and notify
1077   application.SendNotification();
1078   application.Render();
1079
1080   // Executes the idle callbacks added by the text control on the change of input style.
1081   application.RunIdles();
1082
1083   DALI_TEST_CHECK( !gInputStyleChangedCallbackCalled );
1084   DALI_TEST_CHECK( !inputStyleChangedSignal );
1085
1086   gInputStyleChangedCallbackCalled = false;
1087   gInputStyleMask = TextEditor::InputStyle::NONE;
1088   inputStyleChangedSignal = false;
1089
1090   // Create a tap event to touch the text editor.
1091   TestGenerateTap( application, 43.0f, 25.0f );
1092
1093   // Render and notify
1094   application.SendNotification();
1095   application.Render();
1096
1097   // Executes the idle callbacks added by the text control on the change of input style.
1098   application.RunIdles();
1099
1100   DALI_TEST_CHECK( gInputStyleChangedCallbackCalled );
1101   if( gInputStyleChangedCallbackCalled )
1102   {
1103     DALI_TEST_EQUALS( static_cast<unsigned int>( gInputStyleMask ), static_cast<unsigned int>( TextEditor::InputStyle::COLOR ), TEST_LOCATION );
1104
1105     const Vector4 color = editor.GetProperty( TextEditor::Property::INPUT_COLOR ).Get<Vector4>();
1106     DALI_TEST_EQUALS( color, Color::GREEN, TEST_LOCATION );
1107   }
1108   DALI_TEST_CHECK( inputStyleChangedSignal );
1109
1110   gInputStyleChangedCallbackCalled = false;
1111   gInputStyleMask = TextEditor::InputStyle::NONE;
1112   inputStyleChangedSignal = false;
1113
1114   // Create a tap event to touch the text editor.
1115   TestGenerateTap( application, 88.0f, 25.0f );
1116
1117   // Render and notify
1118   application.SendNotification();
1119   application.Render();
1120
1121   // Executes the idle callbacks added by the text control on the change of input style.
1122   application.RunIdles();
1123
1124   DALI_TEST_CHECK( gInputStyleChangedCallbackCalled );
1125   if( gInputStyleChangedCallbackCalled )
1126   {
1127     DALI_TEST_EQUALS( static_cast<unsigned int>( gInputStyleMask ), static_cast<unsigned int>( TextEditor::InputStyle::COLOR | TextEditor::InputStyle::FONT_STYLE ), TEST_LOCATION );
1128
1129     const Vector4 color = editor.GetProperty( TextEditor::Property::INPUT_COLOR ).Get<Vector4>();
1130     DALI_TEST_EQUALS( color, Color::BLACK, TEST_LOCATION );
1131
1132     Property::Map fontStyleMapSet;
1133     Property::Map fontStyleMapGet;
1134
1135     fontStyleMapSet.Insert( "weight", "bold" );
1136
1137     fontStyleMapGet = editor.GetProperty<Property::Map>( TextEditor::Property::INPUT_FONT_STYLE );
1138     DALI_TEST_EQUALS( fontStyleMapGet.Count(), fontStyleMapSet.Count(), TEST_LOCATION );
1139     DALI_TEST_EQUALS( DaliTestCheckMaps( fontStyleMapGet, fontStyleMapSet ), true, TEST_LOCATION );
1140   }
1141   DALI_TEST_CHECK( inputStyleChangedSignal );
1142
1143   gInputStyleChangedCallbackCalled = false;
1144   gInputStyleMask = TextEditor::InputStyle::NONE;
1145   inputStyleChangedSignal = false;
1146
1147   // Create a tap event to touch the text editor.
1148   TestGenerateTap( application, 115.0f, 25.0f );
1149
1150   // Render and notify
1151   application.SendNotification();
1152   application.Render();
1153
1154   // Executes the idle callbacks added by the text control on the change of input style.
1155   application.RunIdles();
1156
1157   DALI_TEST_CHECK( !gInputStyleChangedCallbackCalled );
1158   DALI_TEST_CHECK( !inputStyleChangedSignal );
1159
1160   gInputStyleChangedCallbackCalled = false;
1161   gInputStyleMask = TextEditor::InputStyle::NONE;
1162   inputStyleChangedSignal = false;
1163
1164   // Create a tap event to touch the text editor.
1165   TestGenerateTap( application, 164.0f, 25.0f );
1166
1167   // Render and notify
1168   application.SendNotification();
1169   application.Render();
1170
1171   // Executes the idle callbacks added by the text control on the change of input style.
1172   application.RunIdles();
1173
1174   DALI_TEST_CHECK( gInputStyleChangedCallbackCalled );
1175   if( gInputStyleChangedCallbackCalled )
1176   {
1177     DALI_TEST_EQUALS( static_cast<unsigned int>( gInputStyleMask ), static_cast<unsigned int>( TextEditor::InputStyle::FONT_STYLE ), TEST_LOCATION );
1178
1179     Property::Map fontStyleMapSet;
1180     Property::Map fontStyleMapGet;
1181
1182     fontStyleMapGet = editor.GetProperty<Property::Map>( TextEditor::Property::INPUT_FONT_STYLE );
1183     DALI_TEST_EQUALS( fontStyleMapGet.Count(), fontStyleMapSet.Count(), TEST_LOCATION );
1184     DALI_TEST_EQUALS( DaliTestCheckMaps( fontStyleMapGet, fontStyleMapSet ), true, TEST_LOCATION );
1185   }
1186   DALI_TEST_CHECK( inputStyleChangedSignal );
1187
1188   gInputStyleChangedCallbackCalled = false;
1189   gInputStyleMask = TextEditor::InputStyle::NONE;
1190   inputStyleChangedSignal = false;
1191
1192   // Create a tap event to touch the text editor.
1193   TestGenerateTap( application, 191.0f, 25.0f );
1194
1195   // Render and notify
1196   application.SendNotification();
1197   application.Render();
1198
1199   // Executes the idle callbacks added by the text control on the change of input style.
1200   application.RunIdles();
1201
1202   DALI_TEST_CHECK( !gInputStyleChangedCallbackCalled );
1203   DALI_TEST_CHECK( !inputStyleChangedSignal );
1204
1205   END_TEST;
1206 }
1207
1208 int utcDaliTextEditorInputStyleChanged02(void)
1209 {
1210   // The text-editor emits signals when the input style changes. These changes of style are
1211   // detected during the relayout process (size negotiation), i.e after the cursor has been moved. Signals
1212   // can't be emitted during the size negotiation as the callbacks may update the UI.
1213   // The text-editor adds an idle callback to the adaptor to emit the signals after the size negotiation.
1214   // The ToolkitTestApplication creates an implementation of the adaptor stub and a queue of idle callbacks.
1215   ToolkitTestApplication application;
1216   tet_infoline(" utcDaliTextEditorInputStyleChanged02");
1217
1218   // Load some fonts.
1219
1220   char* pathNamePtr = get_current_dir_name();
1221   const std::string pathName( pathNamePtr );
1222   free( pathNamePtr );
1223
1224   TextAbstraction::FontClient fontClient = TextAbstraction::FontClient::Get();
1225   fontClient.SetDpi( 93u, 93u );
1226
1227   fontClient.GetFontId( pathName + DEFAULT_FONT_DIR + "/dejavu/DejaVuSerif.ttf", DEFAULT_FONT_SIZE );
1228   fontClient.GetFontId( pathName + DEFAULT_FONT_DIR + "/dejavu/DejaVuSerif-Bold.ttf", DEFAULT_FONT_SIZE );
1229
1230   TextEditor editor = TextEditor::New();
1231   DALI_TEST_CHECK( editor );
1232
1233
1234   editor.SetProperty( Actor::Property::SIZE, Vector2( 300.f, 50.f ) );
1235   editor.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT );
1236   editor.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT );
1237
1238   editor.SetProperty( TextEditor::Property::ENABLE_MARKUP, true );
1239   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>" );
1240
1241   // connect to the text changed signal.
1242   ConnectionTracker* testTracker = new ConnectionTracker();
1243   editor.InputStyleChangedSignal().Connect( &TestInputStyleChangedCallback );
1244   bool inputStyleChangedSignal = false;
1245   editor.ConnectSignal( testTracker, "inputStyleChanged",   CallbackFunctor(&inputStyleChangedSignal) );
1246
1247   application.GetScene().Add( editor );
1248
1249   // Render and notify
1250   application.SendNotification();
1251   application.Render();
1252
1253   // Executes the idle callbacks added by the text control on the change of input style.
1254   application.RunIdles();
1255
1256   gInputStyleChangedCallbackCalled = false;
1257   gInputStyleMask = TextEditor::InputStyle::NONE;
1258   inputStyleChangedSignal = false;
1259
1260   // Create a tap event to touch the text editor.
1261   TestGenerateTap( application, 53.0f, 25.0f, 100 );
1262   TestGenerateTap( application, 53.0f, 25.0f, 200 );
1263
1264   // Render and notify
1265   application.SendNotification();
1266   application.Render();
1267
1268   // Executes the idle callbacks added by the text control on the change of input style.
1269   application.RunIdles();
1270
1271   DALI_TEST_CHECK( gInputStyleChangedCallbackCalled );
1272   if( gInputStyleChangedCallbackCalled )
1273   {
1274     DALI_TEST_EQUALS( static_cast<unsigned int>( gInputStyleMask ),
1275                       static_cast<unsigned int>( TextEditor::InputStyle::FONT_FAMILY |
1276                                                  TextEditor::InputStyle::POINT_SIZE  |
1277                                                  TextEditor::InputStyle::COLOR ),
1278                       TEST_LOCATION );
1279
1280     const Vector4 color = editor.GetProperty( TextEditor::Property::INPUT_COLOR ).Get<Vector4>();
1281     DALI_TEST_EQUALS( color, Color::GREEN, TEST_LOCATION );
1282
1283     const std::string fontFamily = editor.GetProperty( TextEditor::Property::INPUT_FONT_FAMILY ).Get<std::string>();
1284     DALI_TEST_EQUALS( fontFamily, "DejaVuSerif", TEST_LOCATION );
1285
1286     const float pointSize = editor.GetProperty( TextEditor::Property::INPUT_POINT_SIZE ).Get<float>();
1287     DALI_TEST_EQUALS( pointSize, 18.f, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
1288   }
1289   DALI_TEST_CHECK( inputStyleChangedSignal );
1290
1291   gInputStyleChangedCallbackCalled = false;
1292   gInputStyleMask = TextEditor::InputStyle::NONE;
1293   inputStyleChangedSignal = false;
1294
1295   application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_BACKSPACE, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
1296
1297   // Render and notify
1298   application.SendNotification();
1299   application.Render();
1300
1301   // Executes the idle callbacks added by the text control on the change of input style.
1302   application.RunIdles();
1303
1304   DALI_TEST_CHECK( gInputStyleChangedCallbackCalled );
1305   if( gInputStyleChangedCallbackCalled )
1306   {
1307     DALI_TEST_EQUALS( static_cast<unsigned int>( gInputStyleMask ),
1308                       static_cast<unsigned int>( TextEditor::InputStyle::COLOR ),
1309                       TEST_LOCATION );
1310
1311     const Vector4 color = editor.GetProperty( TextEditor::Property::INPUT_COLOR ).Get<Vector4>();
1312     DALI_TEST_EQUALS( color, Color::BLUE, TEST_LOCATION );
1313   }
1314   DALI_TEST_CHECK( inputStyleChangedSignal );
1315
1316   gInputStyleChangedCallbackCalled = false;
1317   gInputStyleMask = TextEditor::InputStyle::NONE;
1318   inputStyleChangedSignal = false;
1319
1320   application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_BACKSPACE, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
1321
1322   // Render and notify
1323   application.SendNotification();
1324   application.Render();
1325
1326   // Executes the idle callbacks added by the text control on the change of input style.
1327   application.RunIdles();
1328
1329   DALI_TEST_CHECK( !gInputStyleChangedCallbackCalled );
1330   DALI_TEST_CHECK( !inputStyleChangedSignal );
1331
1332   gInputStyleChangedCallbackCalled = false;
1333   gInputStyleMask = TextEditor::InputStyle::NONE;
1334   inputStyleChangedSignal = false;
1335
1336   application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_BACKSPACE, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
1337
1338   // Render and notify
1339   application.SendNotification();
1340   application.Render();
1341
1342   // Executes the idle callbacks added by the text control on the change of input style.
1343   application.RunIdles();
1344
1345   DALI_TEST_CHECK( gInputStyleChangedCallbackCalled );
1346   if( gInputStyleChangedCallbackCalled )
1347   {
1348     DALI_TEST_EQUALS( static_cast<unsigned int>( gInputStyleMask ),
1349                       static_cast<unsigned int>( TextEditor::InputStyle::COLOR ),
1350                       TEST_LOCATION );
1351
1352     const Vector4 color = editor.GetProperty( TextEditor::Property::INPUT_COLOR ).Get<Vector4>();
1353     DALI_TEST_EQUALS( color, Color::BLACK, TEST_LOCATION );
1354   }
1355   DALI_TEST_CHECK( inputStyleChangedSignal );
1356
1357   gInputStyleChangedCallbackCalled = false;
1358   gInputStyleMask = TextEditor::InputStyle::NONE;
1359   inputStyleChangedSignal = false;
1360
1361   editor.SetProperty( TextEditor::Property::INPUT_COLOR, Color::YELLOW );
1362
1363   Property::Map fontStyleMapSet;
1364   fontStyleMapSet.Insert( "weight", "thin" );
1365   fontStyleMapSet.Insert( "width", "condensed" );
1366   fontStyleMapSet.Insert( "slant", "italic" );
1367
1368   editor.SetProperty( TextEditor::Property::INPUT_FONT_STYLE, fontStyleMapSet );
1369   editor.SetProperty( TextEditor::Property::INPUT_POINT_SIZE, 20.f );
1370   editor.SetProperty( TextEditor::Property::INPUT_LINE_SPACING, 5.f );
1371
1372   editor.SetProperty( TextEditor::Property::INPUT_UNDERLINE, "underline" );
1373   editor.SetProperty( TextEditor::Property::INPUT_SHADOW, "shadow" );
1374   editor.SetProperty( TextEditor::Property::INPUT_EMBOSS, "emboss" );
1375   editor.SetProperty( TextEditor::Property::INPUT_OUTLINE, "outline" );
1376
1377   application.ProcessEvent( GenerateKey( "a", "", "a", KEY_A_CODE, 0, 0, Integration::KeyEvent::DOWN, "a", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
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   DALI_TEST_CHECK( !inputStyleChangedSignal );
1388
1389   // Create a tap event to touch the text editor.
1390   TestGenerateTap( application, 63.0f, 25.0f, 900 );
1391
1392   // Render and notify
1393   application.SendNotification();
1394   application.Render();
1395
1396   // Executes the idle callbacks added by the text control on the change of input style.
1397   application.RunIdles();
1398
1399   DALI_TEST_CHECK( gInputStyleChangedCallbackCalled );
1400   if( gInputStyleChangedCallbackCalled )
1401   {
1402     DALI_TEST_EQUALS( static_cast<unsigned int>( gInputStyleMask ),
1403                       static_cast<unsigned int>( TextEditor::InputStyle::COLOR |
1404                                                  TextEditor::InputStyle::POINT_SIZE |
1405                                                  TextEditor::InputStyle::FONT_STYLE |
1406                                                  TextEditor::InputStyle::LINE_SPACING |
1407                                                  TextEditor::InputStyle::UNDERLINE |
1408                                                  TextEditor::InputStyle::SHADOW |
1409                                                  TextEditor::InputStyle::EMBOSS |
1410                                                  TextEditor::InputStyle::OUTLINE ),
1411                       TEST_LOCATION );
1412
1413     const Vector4 color = editor.GetProperty( TextEditor::Property::INPUT_COLOR ).Get<Vector4>();
1414     DALI_TEST_EQUALS( color, Color::BLACK, TEST_LOCATION );
1415   }
1416   DALI_TEST_CHECK( inputStyleChangedSignal );
1417
1418   gInputStyleChangedCallbackCalled = false;
1419   gInputStyleMask = TextEditor::InputStyle::NONE;
1420   inputStyleChangedSignal = false;
1421
1422   editor.SetProperty( TextEditor::Property::FONT_FAMILY, "DejaVuSerif" );
1423
1424   fontStyleMapSet.Clear();
1425   fontStyleMapSet.Insert( "weight", "black" );
1426   fontStyleMapSet.Insert( "width", "expanded" );
1427   fontStyleMapSet.Insert( "slant", "oblique" );
1428
1429   editor.SetProperty( TextEditor::Property::FONT_STYLE, fontStyleMapSet );
1430
1431   // Create a tap event to touch the text editor.
1432   TestGenerateTap( application, 30.0f, 25.0f, 1500 );
1433
1434   // Render and notify
1435   application.SendNotification();
1436   application.Render();
1437
1438   // Executes the idle callbacks added by the text control on the change of input style.
1439   application.RunIdles();
1440
1441   DALI_TEST_CHECK( gInputStyleChangedCallbackCalled );
1442   if( gInputStyleChangedCallbackCalled )
1443   {
1444     DALI_TEST_EQUALS( static_cast<unsigned int>( gInputStyleMask ),
1445                       static_cast<unsigned int>( TextEditor::InputStyle::COLOR |
1446                                                  TextEditor::InputStyle::POINT_SIZE |
1447                                                  TextEditor::InputStyle::FONT_STYLE ),
1448                       TEST_LOCATION );
1449
1450     const Vector4 color = editor.GetProperty( TextEditor::Property::INPUT_COLOR ).Get<Vector4>();
1451     DALI_TEST_EQUALS( color, Color::YELLOW, TEST_LOCATION );
1452   }
1453   DALI_TEST_CHECK( inputStyleChangedSignal );
1454
1455   END_TEST;
1456 }
1457
1458 int utcDaliTextEditorEvent01(void)
1459 {
1460   ToolkitTestApplication application;
1461   tet_infoline(" utcDaliTextEditorEvent01");
1462
1463   // Creates a tap event. After creating a tap event the text editor should
1464   // have the focus and add text with key events should be possible.
1465
1466   TextEditor editor = TextEditor::New();
1467   DALI_TEST_CHECK( editor );
1468
1469   application.GetScene().Add( editor );
1470
1471   editor.SetProperty( Actor::Property::SIZE, Vector2( 300.f, 50.f ) );
1472   editor.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT );
1473   editor.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT );
1474
1475   // Avoid a crash when core load gl resources.
1476   application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
1477
1478   // Render and notify
1479   application.SendNotification();
1480   application.Render();
1481
1482   // Add a key event but as the text editor has not the focus it should do nothing.
1483   application.ProcessEvent( GenerateKey( "a", "", "a", KEY_A_CODE, 0, 0, Integration::KeyEvent::DOWN, "a", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
1484
1485   // Render and notify
1486   application.SendNotification();
1487   application.Render();
1488
1489   DALI_TEST_EQUALS( editor.GetProperty<std::string>( TextEditor::Property::TEXT ), std::string(""), TEST_LOCATION );
1490
1491   // Create a tap event to touch the text editor.
1492   TestGenerateTap( application, 150.0f, 25.0f );
1493
1494   // Render and notify
1495   application.SendNotification();
1496   application.Render();
1497
1498   // Now the text editor has the focus, so it can handle the key events.
1499   application.ProcessEvent( GenerateKey( "a", "", "a", KEY_A_CODE, 0, 0, Integration::KeyEvent::DOWN, "a", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
1500   application.ProcessEvent( GenerateKey( "a", "", "a", KEY_A_CODE, 0, 0, Integration::KeyEvent::DOWN, "a", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
1501
1502   // Render and notify
1503   application.SendNotification();
1504   application.Render();
1505
1506   DALI_TEST_EQUALS( editor.GetProperty<std::string>( TextEditor::Property::TEXT ), std::string("aa"), TEST_LOCATION );
1507
1508   // Create a second text editor and send key events to it.
1509   TextEditor editor2 = TextEditor::New();
1510
1511   editor2.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT );
1512   editor2.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT );
1513   editor2.SetProperty( Actor::Property::SIZE, Vector2( 100.f, 100.f ) );
1514   editor2.SetProperty( Actor::Property::POSITION, Vector2( 100.f, 100.f ));
1515
1516   application.GetScene().Add( editor2 );
1517
1518   // Render and notify
1519   application.SendNotification();
1520   application.Render();
1521
1522   // Create a tap event on the second text editor.
1523   TestGenerateTap( application, 150.0f, 125.0f );
1524
1525   // Render and notify
1526   application.SendNotification();
1527   application.Render();
1528
1529   // The second text editor has the focus. It should handle the key events.
1530   application.ProcessEvent( GenerateKey( "a", "", "a", KEY_A_CODE, 0, 0, Integration::KeyEvent::DOWN, "a", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
1531   application.ProcessEvent( GenerateKey( "a", "", "a", KEY_A_CODE, 0, 0, Integration::KeyEvent::DOWN, "a", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
1532
1533   // Render and notify
1534   application.SendNotification();
1535   application.Render();
1536
1537   // Check the text has been added to the second text editor.
1538   DALI_TEST_EQUALS( editor2.GetProperty<std::string>( TextEditor::Property::TEXT ), std::string("aa"), TEST_LOCATION );
1539
1540   END_TEST;
1541 }
1542
1543 int utcDaliTextEditorEvent02(void)
1544 {
1545   ToolkitTestApplication application;
1546   tet_infoline(" utcDaliTextEditorEvent02");
1547
1548   // Checks if the right number of actors are created.
1549
1550   TextEditor editor = TextEditor::New();
1551   editor.SetProperty( TextEditor::Property::POINT_SIZE, 10.f );
1552   DALI_TEST_CHECK( editor );
1553
1554   application.GetScene().Add( editor );
1555
1556   editor.SetProperty( Actor::Property::SIZE, Vector2( 300.f, 50.f ) );
1557   editor.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT );
1558   editor.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT );
1559
1560   // Avoid a crash when core load gl resources.
1561   application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
1562
1563   // Render and notify
1564   application.SendNotification();
1565   application.Render();
1566
1567   // Check there are the expected number of children (the stencil).
1568   DALI_TEST_EQUALS( editor.GetChildCount(), 1u, TEST_LOCATION );
1569
1570   Actor stencil = editor.GetChildAt( 0u );
1571
1572   // Create a tap event to touch the text editor.
1573   TestGenerateTap( application, 150.0f, 25.0f, 100 );
1574
1575   // Render and notify
1576   application.SendNotification();
1577   application.Render();
1578
1579   Actor layer = editor.GetChildAt( 1u );
1580   DALI_TEST_EQUALS( layer.GetChildCount(), 1u, TEST_LOCATION ); // The cursor.
1581   DALI_TEST_EQUALS( stencil.GetChildCount(), 0u, TEST_LOCATION );
1582
1583   // Now the text editor has the focus, so it can handle the key events.
1584   application.ProcessEvent( GenerateKey( "a", "", "a", KEY_A_CODE, 0, 0, Integration::KeyEvent::DOWN, "a", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
1585   application.ProcessEvent( GenerateKey( "a", "", "a", KEY_A_CODE, 0, 0, Integration::KeyEvent::DOWN, "a", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
1586
1587   // Render and notify
1588   application.SendNotification();
1589   application.Render();
1590
1591   // Checks the cursor and the renderer have been created.
1592   DALI_TEST_EQUALS( layer.GetChildCount(), 1u, TEST_LOCATION ); // The cursor.
1593   DALI_TEST_EQUALS( stencil.GetChildCount(), 1u, TEST_LOCATION ); // The renderer
1594
1595   Control cursor = Control::DownCast( layer.GetChildAt( 0u ) );
1596   DALI_TEST_CHECK( cursor );
1597
1598   // The stencil actor has a container with all the actors which contain the text renderers.
1599   Actor container = stencil.GetChildAt( 0u );
1600   for( unsigned int index = 0; index < container.GetChildCount(); ++index )
1601   {
1602     Renderer renderer = container.GetChildAt( index ).GetRendererAt( 0u );
1603     DALI_TEST_CHECK( renderer );
1604   }
1605
1606   // Move the cursor and check the position changes.
1607   Vector3 position1 = cursor.GetCurrentProperty< Vector3 >( Actor::Property::POSITION );
1608
1609   application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_LEFT, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
1610   application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_LEFT, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
1611
1612   // Render and notify
1613   application.SendNotification();
1614   application.Render();
1615
1616   Vector3 position2 = cursor.GetCurrentProperty< Vector3 >( Actor::Property::POSITION );
1617
1618   DALI_TEST_CHECK( position2.x < position1.x );
1619
1620   application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_RIGHT, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
1621   application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_RIGHT, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
1622
1623   // Render and notify
1624   application.SendNotification();
1625   application.Render();
1626
1627   Vector3 position3 = cursor.GetCurrentProperty< Vector3 >( Actor::Property::POSITION );
1628
1629   DALI_TEST_EQUALS( position1, position3, TEST_LOCATION ); // Should be in the same position1.
1630
1631   // Send some taps and check the cursor positions.
1632
1633   // Try to tap at the beginning.
1634   TestGenerateTap( application, 1.0f, 25.0f, 700 );
1635
1636   // Render and notify
1637   application.SendNotification();
1638   application.Render();
1639
1640   // Cursor position should be the same than position1.
1641   Vector3 position4 = cursor.GetCurrentProperty< Vector3 >( Actor::Property::POSITION );
1642
1643   DALI_TEST_EQUALS( position2, position4, TEST_LOCATION ); // Should be in the same position2.
1644
1645   // Tap away from the start position.
1646   TestGenerateTap( application, 16.0f, 25.0f, 1400 );
1647
1648   // Render and notify
1649   application.SendNotification();
1650   application.Render();
1651
1652   Vector3 position5 = cursor.GetCurrentProperty< Vector3 >( Actor::Property::POSITION );
1653
1654   DALI_TEST_CHECK( position5.x > position4.x );
1655
1656   // Remove all the text.
1657   application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_BACKSPACE, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
1658   application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_BACKSPACE, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
1659   editor.SetProperty( TextEditor::Property::TEXT, "" );
1660
1661   // Render and notify
1662   application.SendNotification();
1663   application.Render();
1664
1665   // Cursor position should be the same than position2.
1666   Vector3 position6 = cursor.GetCurrentProperty< Vector3 >( Actor::Property::POSITION );
1667
1668   DALI_TEST_EQUALS( position2, position6, TEST_LOCATION );// Should be in the same position2.
1669
1670   // Should not be a renderer.
1671   DALI_TEST_EQUALS( stencil.GetChildCount(), 0u, TEST_LOCATION );
1672
1673   END_TEST;
1674 }
1675
1676 int utcDaliTextEditorEvent03(void)
1677 {
1678   ToolkitTestApplication application;
1679   tet_infoline(" utcDaliTextEditorEvent03");
1680
1681   // Checks if the highlight actor is created.
1682
1683   TextEditor editor = TextEditor::New();
1684   DALI_TEST_CHECK( editor );
1685
1686   application.GetScene().Add( editor );
1687
1688   editor.SetProperty( TextEditor::Property::TEXT, "This is a long text for the size of the text-editor." );
1689   editor.SetProperty( TextEditor::Property::POINT_SIZE, 10.f );
1690   editor.SetProperty( Actor::Property::SIZE, Vector2( 30.f, 50.f ) );
1691   editor.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT );
1692   editor.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT );
1693
1694   // Avoid a crash when core load gl resources.
1695   application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
1696
1697   // Render and notify
1698   application.SendNotification();
1699   application.Render();
1700
1701   // Send some taps and check text controller with clipboard window
1702   Dali::Clipboard clipboard = Clipboard::Get();
1703   clipboard.ShowClipboard();
1704   TestGenerateTap( application, 3.0f, 25.0f, 100 );
1705   clipboard.HideClipboard();
1706
1707   // Render and notify
1708   application.SendNotification();
1709   application.Render();
1710
1711   // Tap first to get the focus.
1712   TestGenerateTap( application, 3.0f, 25.0f, 1000 );
1713
1714   // Render and notify
1715   application.SendNotification();
1716   application.Render();
1717
1718   // Double tap to select a word.
1719   TestGenerateTap( application, 3.0f, 25.0f, 1100 );
1720
1721   // Render and notify
1722   application.SendNotification();
1723   application.Render();
1724
1725   // The stencil actor should have two actors: the renderer and the highlight actor.
1726   Actor stencil = editor.GetChildAt( 0u );
1727
1728   // Highlight needs to be drawn before text, so should come first in child order
1729   Renderer highlight = stencil.GetChildAt( 0u ).GetRendererAt( 0u );
1730   DALI_TEST_CHECK( highlight );
1731
1732   // The stencil actor has a container with all the actors which contain the text renderers.
1733   Actor container = stencil.GetChildAt( 1u );
1734   for( unsigned int index = 0; index < container.GetChildCount(); ++index )
1735   {
1736     Renderer renderer = container.GetChildAt( index ).GetRendererAt( 0u );
1737     DALI_TEST_CHECK( renderer );
1738   }
1739
1740   // Double tap out of bounds
1741   TestGenerateTap( application, 29.0f, 25.0f, 1700 );
1742   TestGenerateTap( application, 29.0f, 25.0f, 1800 );
1743
1744   // Render and notify
1745   application.SendNotification();
1746   application.Render();
1747
1748   // The stencil actor should have one actors: the renderer actor.
1749   stencil = editor.GetChildAt( 0u );
1750
1751   // The stencil actor has a container with all the actors which contain the text renderers.
1752   container = stencil.GetChildAt( 0u );
1753   for( unsigned int index = 0; index < container.GetChildCount(); ++index )
1754   {
1755     Renderer renderer = container.GetChildAt( index ).GetRendererAt( 0u );
1756     DALI_TEST_CHECK( renderer );
1757   }
1758
1759   // Long Press
1760   TestGenerateLongPress(application, 1.0f, 25.0f);
1761
1762   // Render and notify
1763   application.SendNotification();
1764   application.Render();
1765
1766   // Pan Press
1767   TestGenerateMiniPan(application);
1768
1769   // Render and notify
1770   application.SendNotification();
1771   application.Render();
1772
1773   END_TEST;
1774 }
1775
1776 int utcDaliTextEditorEvent04(void)
1777 {
1778   ToolkitTestApplication application;
1779   tet_infoline(" utcDaliTextEditorEvent04");
1780
1781   // Checks if the highlight actor is created.
1782
1783   TextEditor editor = TextEditor::New();
1784   DALI_TEST_CHECK( editor );
1785
1786   application.GetScene().Add( editor );
1787
1788   editor.SetProperty( TextEditor::Property::TEXT, "Hello\nworl" );
1789   editor.SetProperty( TextEditor::Property::POINT_SIZE, 10.f );
1790   editor.SetProperty( Actor::Property::SIZE, Vector2( 100.f, 50.f ) );
1791   editor.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT );
1792   editor.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT );
1793
1794   // Avoid a crash when core load gl resources.
1795   application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
1796
1797   // Render and notify
1798   application.SendNotification();
1799   application.Render();
1800
1801   // Tap on the text editor
1802   TestGenerateTap( application, 3.0f, 25.0f );
1803
1804   // Render and notify
1805   application.SendNotification();
1806   application.Render();
1807
1808   // Move at the end of the text.
1809   application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_DOWN, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
1810   application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_DOWN, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
1811
1812   // Render and notify
1813   application.SendNotification();
1814   application.Render();
1815
1816   for( unsigned int index = 0u; index < 10u; ++index )
1817   {
1818     application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_RIGHT, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
1819     application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_RIGHT, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
1820
1821     // Render and notify
1822     application.SendNotification();
1823     application.Render();
1824   }
1825
1826   // Add a character
1827   application.ProcessEvent( GenerateKey( "d", "", "d", KEY_D_CODE, 0, 0, Integration::KeyEvent::DOWN, "d", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
1828
1829   // Render and notify
1830   application.SendNotification();
1831   application.Render();
1832
1833   DALI_TEST_EQUALS( "Hello\nworld", editor.GetProperty<std::string>( TextEditor::Property::TEXT ), TEST_LOCATION );
1834
1835   // Add some key events
1836   application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_UP, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
1837   application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_UP, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
1838
1839   // Render and notify
1840   application.SendNotification();
1841   application.Render();
1842
1843   for( unsigned int index = 0u; index < 10u; ++index )
1844   {
1845     application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_LEFT, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
1846     application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_LEFT, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
1847
1848     // Render and notify
1849     application.SendNotification();
1850     application.Render();
1851   }
1852
1853   // Add a character
1854   application.ProcessEvent( GenerateKey( " ", "", " ", KEY_WHITE_SPACE_CODE, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
1855
1856   // Render and notify
1857   application.SendNotification();
1858   application.Render();
1859
1860   DALI_TEST_EQUALS( " Hello\nworld", editor.GetProperty<std::string>( TextEditor::Property::TEXT ), TEST_LOCATION );
1861
1862   END_TEST;
1863 }
1864
1865 int utcDaliTextEditorEvent05(void)
1866 {
1867   ToolkitTestApplication application;
1868   tet_infoline(" utcDaliTextEditorEvent05");
1869
1870   // Checks if the highlight actor is created.
1871
1872   TextEditor editor = TextEditor::New();
1873   DALI_TEST_CHECK( editor );
1874
1875   application.GetScene().Add( editor );
1876
1877   editor.SetProperty( TextEditor::Property::TEXT, "Hello\nworl" );
1878   editor.SetProperty( TextEditor::Property::POINT_SIZE, 10.f );
1879   editor.SetProperty( Actor::Property::SIZE, Vector2( 50.f, 50.f ) );
1880   editor.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT );
1881   editor.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT );
1882   editor.SetProperty( TextEditor::Property::SMOOTH_SCROLL, true );
1883   editor.SetProperty( TextEditor::Property::SMOOTH_SCROLL_DURATION, 0.2f );
1884   editor.SetProperty( TextEditor::Property::ENABLE_SCROLL_BAR, true );
1885   editor.SetProperty( TextEditor::Property::SCROLL_BAR_SHOW_DURATION, 0.3f );
1886   editor.SetProperty( TextEditor::Property::SCROLL_BAR_FADE_DURATION, 0.2f );
1887
1888   // Avoid a crash when core load gl resources.
1889   application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
1890
1891   // Render and notify
1892   application.SendNotification();
1893   application.Render();
1894
1895   // Tap on the text editor
1896   TestGenerateTap( application, 3.0f, 25.0f );
1897
1898   // Render and notify
1899   application.SendNotification();
1900   application.Render();
1901
1902   // Move at the end of the text.
1903   application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_DOWN, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
1904   application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_DOWN, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
1905
1906   // Render and notify
1907   application.SendNotification();
1908   application.Render();
1909
1910   for( unsigned int index = 0u; index < 10u; ++index )
1911   {
1912     // Add a character
1913     application.ProcessEvent( GenerateKey( "d", "", "d", KEY_D_CODE, 0, 0, Integration::KeyEvent::DOWN, "d", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
1914
1915     // Render and notify
1916     application.SendNotification();
1917     application.Render();
1918   }
1919   // Modify duration after scroll is enabled
1920   editor.SetProperty( TextEditor::Property::SMOOTH_SCROLL_DURATION, 0.1f );
1921
1922   // Continuous scroll left to increase coverage
1923   for( unsigned int index = 0u; index < 10u; ++index )
1924   {
1925     application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_LEFT, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
1926
1927     // Render and notify
1928     application.SendNotification();
1929     application.Render();
1930   }
1931   DALI_TEST_EQUALS( editor.GetProperty<float>( TextEditor::Property::SMOOTH_SCROLL_DURATION ), 0.1f, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
1932   DALI_TEST_EQUALS( editor.GetProperty<bool>( TextEditor::Property::SMOOTH_SCROLL ), true, TEST_LOCATION );
1933   DALI_TEST_EQUALS( editor.GetProperty<bool>( TextEditor::Property::ENABLE_SCROLL_BAR ), true, TEST_LOCATION );
1934   DALI_TEST_EQUALS( editor.GetProperty<float>( TextEditor::Property::SCROLL_BAR_SHOW_DURATION ), 0.3f, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
1935   DALI_TEST_EQUALS( editor.GetProperty<float>( TextEditor::Property::SCROLL_BAR_FADE_DURATION ), 0.2f, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
1936
1937   // Press Escape to increase coverage
1938   application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_ESCAPE, 0, 0, Integration::KeyEvent::UP, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
1939   application.SendNotification();
1940   application.Render();
1941
1942   DALI_TEST_CHECK( !editor.HasKeyInputFocus() );
1943
1944   END_TEST;
1945 }
1946
1947 int utcDaliTextEditorEvent06(void)
1948 {
1949   ToolkitTestApplication application;
1950   tet_infoline(" utcDaliTextEditorEvent06");
1951
1952   // Checks if the highlight actor is created.
1953
1954   TextEditor editor = TextEditor::New();
1955   DALI_TEST_CHECK( editor );
1956
1957   application.GetScene().Add( editor );
1958
1959   editor.SetProperty( TextEditor::Property::TEXT, "Hello\nworld\nHello world" );
1960   editor.SetProperty( TextEditor::Property::POINT_SIZE, 10.f );
1961   editor.SetProperty( Actor::Property::SIZE, Vector2( 100.f, 50.f ) );
1962   editor.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT );
1963   editor.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT );
1964
1965   // Avoid a crash when core load gl resources.
1966   application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
1967
1968   // Render and notify
1969   application.SendNotification();
1970   application.Render();
1971
1972   // Tap on the text editor
1973   TestGenerateTap( application, 3.0f, 25.0f );
1974
1975   // Render and notify
1976   application.SendNotification();
1977   application.Render();
1978
1979   // Move to seconds line of the text.
1980   application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_DOWN, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
1981
1982   // Render and notify
1983   application.SendNotification();
1984   application.Render();
1985
1986   float layoutHeight = editor.GetHeightForWidth( 100.f );
1987
1988
1989   // Add  another script characters ( glyph height is defferent )
1990   application.ProcessEvent( GenerateKey( "d", "", "ㅁ", KEY_D_CODE, 0, 0, Integration::KeyEvent::DOWN, "ㅁ", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
1991   application.ProcessEvent( GenerateKey( "d", "", "ኢ", KEY_D_CODE, 0, 0, Integration::KeyEvent::DOWN, "ኢ", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
1992
1993   // Delete characters
1994   application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_BACKSPACE, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
1995   application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_BACKSPACE, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
1996
1997   DALI_TEST_EQUALS( layoutHeight, editor.GetHeightForWidth( 100.f ), TEST_LOCATION );
1998
1999   // Render and notify
2000   application.SendNotification();
2001   application.Render();
2002
2003   DALI_TEST_EQUALS( "Hello\nworld\nHello world", editor.GetProperty<std::string>( TextEditor::Property::TEXT ), TEST_LOCATION );
2004
2005   // For coverage
2006   application.ProcessEvent( GenerateKey( "", "", "", 0, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2007   application.SendNotification();
2008   application.Render();
2009
2010   application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_SHIFT_LEFT, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2011   application.SendNotification();
2012   application.Render();
2013
2014   application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_VOLUME_UP, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2015   application.SendNotification();
2016   application.Render();
2017
2018   application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_VOLUME_DOWN, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2019   application.SendNotification();
2020   application.Render();
2021
2022   application.ProcessEvent( GenerateKey( "", "", "", Dali::DevelKey::DALI_KEY_DELETE, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2023   application.SendNotification();
2024   application.Render();
2025
2026   application.ProcessEvent( GenerateKey( "", "", "", Dali::DevelKey::DALI_KEY_CONTROL_LEFT, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2027   application.SendNotification();
2028   application.Render();
2029
2030   application.ProcessEvent( GenerateKey( "", "", "", Dali::DevelKey::DALI_KEY_CONTROL_RIGHT, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2031   application.SendNotification();
2032   application.Render();
2033
2034   END_TEST;
2035 }
2036
2037 int utcDaliTextEditorEvent07(void)
2038 {
2039   ToolkitTestApplication application;
2040   tet_infoline(" utcDaliTextEditorEvent07");
2041
2042   // Checks if the highlight actor is created.
2043
2044   TextEditor editor = TextEditor::New();
2045   DALI_TEST_CHECK( editor );
2046
2047   application.GetScene().Add( editor );
2048
2049   editor.SetProperty( TextEditor::Property::TEXT, "Hello\nworld\nHello world" );
2050   editor.SetProperty( TextEditor::Property::POINT_SIZE, 10.f );
2051   editor.SetProperty( Actor::Property::SIZE, Vector2( 100.f, 50.f ) );
2052   editor.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT );
2053   editor.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT );
2054
2055   // Avoid a crash when core load gl resources.
2056   application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
2057
2058   // Render and notify
2059   application.SendNotification();
2060   application.Render();
2061
2062   // Tap on the text editor
2063   TestGenerateTap( application, 3.0f, 25.0f );
2064
2065   // Render and notify
2066   application.SendNotification();
2067   application.Render();
2068
2069   // Move to second line of the text.
2070   application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_DOWN, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2071
2072   // Render and notify
2073   application.SendNotification();
2074   application.Render();
2075
2076   // Select some text in the right of the current cursor position
2077   application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_SHIFT_LEFT, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2078   application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_RIGHT, KEY_SHIFT_MODIFIER, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2079   application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_RIGHT, KEY_SHIFT_MODIFIER, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2080   application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_RIGHT, KEY_SHIFT_MODIFIER, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2081
2082   // Render and notify
2083   application.SendNotification();
2084   application.Render();
2085
2086   // Cut the selected text
2087   application.ProcessEvent( GenerateKey( "", "", "", Dali::DevelKey::DALI_KEY_CONTROL_LEFT, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2088   application.ProcessEvent( GenerateKey( "x", "", "x", KEY_X_CODE, KEY_CONTROL_MODIFIER, 0, Integration::KeyEvent::DOWN, "x", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2089
2090   // Render and notify
2091   application.SendNotification();
2092   application.Render();
2093
2094   DALI_TEST_EQUALS( "Hello\nld\nHello world", editor.GetProperty<std::string>( TextEditor::Property::TEXT ), TEST_LOCATION );
2095
2096   // Select some text in the left of the current cursor position
2097   application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_SHIFT_LEFT, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2098   application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_LEFT, KEY_SHIFT_MODIFIER, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2099   application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_LEFT, KEY_SHIFT_MODIFIER, 0, Integration::KeyEvent::DOWN,  "",DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2100   application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_LEFT, KEY_SHIFT_MODIFIER, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2101
2102   // Render and notify
2103   application.SendNotification();
2104   application.Render();
2105
2106   // Copy the selected text
2107   application.ProcessEvent( GenerateKey( "", "", "", Dali::DevelKey::DALI_KEY_CONTROL_LEFT, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2108   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 ) );
2109
2110   // Render and notify
2111   application.SendNotification();
2112   application.Render();
2113
2114   // Move the cursor to the third line
2115   application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_DOWN, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2116   application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_DOWN, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2117
2118   // Render and notify
2119   application.SendNotification();
2120   application.Render();
2121
2122   // Paste the selected text at the current cursor position
2123   application.ProcessEvent( GenerateKey( "", "", "", Dali::DevelKey::DALI_KEY_CONTROL_LEFT, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2124   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 ) );
2125
2126   // Render and notify
2127   application.SendNotification();
2128   application.Render();
2129
2130   DALI_TEST_EQUALS( "Hello\nld\nHello lo\nworld", editor.GetProperty<std::string>( TextEditor::Property::TEXT ), TEST_LOCATION );
2131
2132
2133   // Disable Shift Selection
2134   editor.SetProperty( DevelTextEditor::Property::ENABLE_SHIFT_SELECTION, false );
2135
2136   // Test to select some text in the right of the current cursor position
2137   application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_SHIFT_LEFT, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2138   application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_RIGHT, KEY_SHIFT_MODIFIER, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2139   application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_RIGHT, KEY_SHIFT_MODIFIER, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2140   application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_RIGHT, KEY_SHIFT_MODIFIER, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2141
2142   // Render and notify
2143   application.SendNotification();
2144   application.Render();
2145
2146   // Cut the selected text
2147   application.ProcessEvent( GenerateKey( "", "", "", Dali::DevelKey::DALI_KEY_CONTROL_LEFT, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2148   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 ) );
2149
2150   // Render and notify
2151   application.SendNotification();
2152   application.Render();
2153
2154   // The text isn't selected and not changed because of 'SetProperty( DevelTextEditor::Property::ENABLE_SHIFT_SELECTION, false )'
2155   DALI_TEST_EQUALS( "Hello\nld\nHello lo\nworld", editor.GetProperty<std::string>( TextEditor::Property::TEXT ), TEST_LOCATION );
2156
2157   // Test to select some text in the left of the current cursor position
2158   application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_SHIFT_LEFT, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2159   application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_LEFT, KEY_SHIFT_MODIFIER, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2160   application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_LEFT, KEY_SHIFT_MODIFIER, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2161   application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_LEFT, KEY_SHIFT_MODIFIER, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2162
2163   // Render and notify
2164   application.SendNotification();
2165   application.Render();
2166
2167   // Copy the selected text
2168   application.ProcessEvent( GenerateKey( "", "", "", Dali::DevelKey::DALI_KEY_CONTROL_LEFT, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2169   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 ) );
2170
2171   // Render and notify
2172   application.SendNotification();
2173   application.Render();
2174
2175   // The text is not selected and not changed because of 'SetProperty( DevelTextEditor::Property::ENABLE_SHIFT_SELECTION, false )'
2176   DALI_TEST_EQUALS( "Hello\nld\nHello lo\nworld", editor.GetProperty<std::string>( TextEditor::Property::TEXT ), TEST_LOCATION );
2177
2178   // Select all Text
2179   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 ) );
2180
2181   // Render and notify
2182   application.SendNotification();
2183   application.Render();
2184
2185   // replace text with "c"
2186   application.ProcessEvent( GenerateKey( "c", "", "c", KEY_C_CODE, 0, 0, Integration::KeyEvent::DOWN, "c", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2187
2188   // Render and notify
2189   application.SendNotification();
2190   application.Render();
2191
2192   //text is "c"
2193   DALI_TEST_EQUALS( "c", editor.GetProperty<std::string>( TextEditor::Property::TEXT ), TEST_LOCATION );
2194
2195   // select all text
2196   DevelTextEditor::SelectWholeText(editor);
2197
2198   // Render and notify
2199   application.SendNotification();
2200   application.Render();
2201
2202   // Copy the selected text using logical keys
2203   application.ProcessEvent( GenerateKey( "", "", "", Dali::DevelKey::DALI_KEY_CONTROL_LEFT, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2204   application.ProcessEvent( GenerateKey( "ؤ", "c", "ؤ", KEY_C_CODE, KEY_CONTROL_MODIFIER, 0, Integration::KeyEvent::DOWN, "c", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2205
2206   // Render and notify
2207   application.SendNotification();
2208   application.Render();
2209
2210   // select none
2211   DevelTextEditor::SelectNone(editor);
2212
2213   // Render and notify
2214   application.SendNotification();
2215   application.Render();
2216
2217   // Paste the selected using logical keys
2218   application.ProcessEvent( GenerateKey( "", "", "", Dali::DevelKey::DALI_KEY_CONTROL_LEFT, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2219   application.ProcessEvent( GenerateKey( "ر", "v", "ر", KEY_V_CODE, KEY_CONTROL_MODIFIER, 0, Integration::KeyEvent::DOWN, "v", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2220
2221   //text is "cc"
2222   DALI_TEST_EQUALS( "cc", editor.GetProperty<std::string>( TextEditor::Property::TEXT ), TEST_LOCATION );
2223
2224   // select all using logical keys
2225   application.ProcessEvent( GenerateKey( "", "", "", Dali::DevelKey::DALI_KEY_CONTROL_LEFT, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2226   application.ProcessEvent( GenerateKey( "ش", "a", "ش", KEY_A_CODE, KEY_CONTROL_MODIFIER, 0, Integration::KeyEvent::DOWN, "a", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2227
2228   // Render and notify
2229   application.SendNotification();
2230   application.Render();
2231
2232   // cut text using logical keys
2233   application.ProcessEvent( GenerateKey( "", "", "", Dali::DevelKey::DALI_KEY_CONTROL_LEFT, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2234   application.ProcessEvent( GenerateKey( "ء", "x", "ء", KEY_X_CODE, KEY_CONTROL_MODIFIER, 0, Integration::KeyEvent::DOWN, "x", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2235
2236   // Render and notify
2237   application.SendNotification();
2238   application.Render();
2239
2240   //text is ""
2241   DALI_TEST_EQUALS( "", editor.GetProperty<std::string>( TextEditor::Property::TEXT ), TEST_LOCATION );
2242
2243   END_TEST;
2244 }
2245
2246 int utcDaliTextEditorEvent08(void)
2247 {
2248   ToolkitTestApplication application;
2249   tet_infoline(" utcDaliTextEditorEvent08");
2250
2251   // Checks if the highlight actor is released correctly.
2252
2253   TextEditor editor = TextEditor::New();
2254   DALI_TEST_CHECK( editor );
2255
2256   application.GetScene().Add( editor );
2257
2258   editor.SetProperty( TextEditor::Property::TEXT, "DALi" );
2259   editor.SetProperty( TextEditor::Property::POINT_SIZE, 10.f );
2260   editor.SetProperty( Actor::Property::SIZE, Vector2( 100.f, 50.f ) );
2261   editor.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT );
2262   editor.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT );
2263
2264   // Avoid a crash when core load gl resources.
2265   application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
2266
2267   // Render and notify
2268   application.SendNotification();
2269   application.Render();
2270
2271   // Tap on the text editor
2272   TestGenerateTap( application, 3.0f, 25.0f );
2273
2274   // Render and notify
2275   application.SendNotification();
2276   application.Render();
2277
2278   // When the left selection handle and the right selection handle are at the same position, the highlight box should be deactivated.
2279   // Test to select some text in the left of the current cursor position
2280   application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_SHIFT_LEFT, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2281   application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_LEFT, KEY_SHIFT_MODIFIER, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2282   application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_LEFT, KEY_SHIFT_MODIFIER, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2283   application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_LEFT, KEY_SHIFT_MODIFIER, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2284
2285   // Render and notify
2286   application.SendNotification();
2287   application.Render();
2288
2289   // Test to the left selection handle position and the right selection handle position
2290   application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_SHIFT_LEFT, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2291   application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_RIGHT, KEY_SHIFT_MODIFIER, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2292   application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_RIGHT, KEY_SHIFT_MODIFIER, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2293   application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_RIGHT, KEY_SHIFT_MODIFIER, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2294
2295   // Render and notify
2296   application.SendNotification();
2297   application.Render();
2298
2299   // Test to select full text in the left of the current cursor position
2300   application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_SHIFT_LEFT, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2301   application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_LEFT, KEY_SHIFT_MODIFIER, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2302   application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_LEFT, KEY_SHIFT_MODIFIER, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2303   application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_LEFT, KEY_SHIFT_MODIFIER, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2304   application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_LEFT, KEY_SHIFT_MODIFIER, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2305   application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_LEFT, KEY_SHIFT_MODIFIER, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2306
2307   // Render and notify
2308   application.SendNotification();
2309   application.Render();
2310
2311   // Test to release the current full text selection
2312   application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_LEFT, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2313   application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_LEFT, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2314
2315   // Render and notify
2316   application.SendNotification();
2317   application.Render();
2318
2319   // Test to move the current cursor position correctly
2320   application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_RIGHT, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2321
2322   // Render and notify
2323   application.SendNotification();
2324   application.Render();
2325
2326   // Add a character
2327   application.ProcessEvent( GenerateKey( "d", "", "d", KEY_D_CODE, 0, 0, Integration::KeyEvent::DOWN, "d", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2328
2329   // Render and notify
2330   application.SendNotification();
2331   application.Render();
2332
2333   DALI_TEST_EQUALS( "DdALi", editor.GetProperty<std::string>( TextEditor::Property::TEXT ), TEST_LOCATION );
2334
2335   // Test to select some text in the right of the current cursor position
2336   application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_SHIFT_LEFT, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2337   application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_RIGHT, KEY_SHIFT_MODIFIER, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2338   application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_RIGHT, KEY_SHIFT_MODIFIER, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2339
2340   // Render and notify
2341   application.SendNotification();
2342   application.Render();
2343
2344   // Test the cursor position with right arrow key
2345   application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_RIGHT, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2346
2347   // Render and notify
2348   application.SendNotification();
2349   application.Render();
2350
2351   // Add a character
2352   application.ProcessEvent( GenerateKey( "c", "", "c", KEY_C_CODE, 0, 0, Integration::KeyEvent::DOWN, "c", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2353
2354   // Render and notify
2355   application.SendNotification();
2356   application.Render();
2357
2358   DALI_TEST_EQUALS( "DdALci", editor.GetProperty<std::string>( TextEditor::Property::TEXT ), TEST_LOCATION );
2359
2360   // Test to select some text in the left of the current cursor position
2361   application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_SHIFT_LEFT, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2362   application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_LEFT, KEY_SHIFT_MODIFIER, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2363   application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_LEFT, KEY_SHIFT_MODIFIER, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2364   application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_LEFT, KEY_SHIFT_MODIFIER, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2365   application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_LEFT, KEY_SHIFT_MODIFIER, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2366
2367   // Render and notify
2368   application.SendNotification();
2369   application.Render();
2370
2371   // Test the cursor position with left arrow key
2372   application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_LEFT, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2373
2374   // Render and notify
2375   application.SendNotification();
2376   application.Render();
2377
2378   // Add a character
2379   application.ProcessEvent( GenerateKey( "c", "", "c", KEY_C_CODE, 0, 0, Integration::KeyEvent::DOWN, "c", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2380
2381   // Render and notify
2382   application.SendNotification();
2383   application.Render();
2384
2385   DALI_TEST_EQUALS( "DcdALci", editor.GetProperty<std::string>( TextEditor::Property::TEXT ), TEST_LOCATION );
2386
2387   // Test to select some text in the right of the current cursor position
2388   application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_SHIFT_LEFT, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2389   application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_RIGHT, KEY_SHIFT_MODIFIER, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2390   application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_RIGHT, KEY_SHIFT_MODIFIER, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2391   application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_RIGHT, KEY_SHIFT_MODIFIER, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2392
2393   // Render and notify
2394   application.SendNotification();
2395   application.Render();
2396
2397   // Test the cursor position with left arrow key
2398   application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_LEFT, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2399
2400   // Render and notify
2401   application.SendNotification();
2402   application.Render();
2403
2404   // Add a character
2405   application.ProcessEvent( GenerateKey( "x", "", "x", KEY_X_CODE, 0, 0, Integration::KeyEvent::DOWN, "x", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2406
2407   // Render and notify
2408   application.SendNotification();
2409   application.Render();
2410
2411   DALI_TEST_EQUALS( "DcxdALci", editor.GetProperty<std::string>( TextEditor::Property::TEXT ), TEST_LOCATION );
2412
2413   // Test to select some text in the left of the current cursor position
2414   application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_SHIFT_LEFT, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2415   application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_LEFT, KEY_SHIFT_MODIFIER, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2416   application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_LEFT, KEY_SHIFT_MODIFIER, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2417   application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_LEFT, KEY_SHIFT_MODIFIER, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2418
2419   // Render and notify
2420   application.SendNotification();
2421   application.Render();
2422
2423   // Test the cursor position with right arrow key
2424   application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_RIGHT, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2425
2426   // Render and notify
2427   application.SendNotification();
2428   application.Render();
2429
2430   // Add a character
2431   application.ProcessEvent( GenerateKey( "c", "", "c", KEY_C_CODE, 0, 0, Integration::KeyEvent::DOWN, "c", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2432
2433   // Render and notify
2434   application.SendNotification();
2435   application.Render();
2436
2437   DALI_TEST_EQUALS( "DcxcdALci", editor.GetProperty<std::string>( TextEditor::Property::TEXT ), TEST_LOCATION );
2438
2439   END_TEST;
2440 }
2441
2442 int utcDaliTextEditorHandles(void)
2443 {
2444   ToolkitTestApplication application;
2445   tet_infoline(" utcDaliTextEditorHandles");
2446
2447   TextEditor editor = TextEditor::New();
2448   DALI_TEST_CHECK( editor );
2449
2450   application.GetScene().Add( editor );
2451
2452   editor.SetProperty( TextEditor::Property::TEXT, "This is a long text for the size of the text-editor." );
2453   editor.SetProperty( TextEditor::Property::POINT_SIZE, 10.f );
2454   editor.SetProperty( TextEditor::Property::GRAB_HANDLE_IMAGE, HANDLE_IMAGE_FILE_NAME );
2455   editor.SetProperty( TextEditor::Property::SMOOTH_SCROLL, true );
2456
2457   editor.SetProperty( TextEditor::Property::SELECTION_HANDLE_IMAGE_LEFT, Property::Map{ {"filename", HANDLE_LEFT_SELECTION_FILE_NAME } } );
2458   editor.SetProperty( TextEditor::Property::SELECTION_HANDLE_IMAGE_RIGHT, Property::Map{ {"filename", HANDLE_LEFT_SELECTION_FILE_NAME } } );
2459   editor.SetProperty( TextEditor::Property::SELECTION_HANDLE_PRESSED_IMAGE_LEFT, Property::Map{ {"filename", HANDLE_RIGHT_SELECTION_FILE_NAME } } );
2460   editor.SetProperty( TextEditor::Property::SELECTION_HANDLE_PRESSED_IMAGE_RIGHT, Property::Map{ {"filename", HANDLE_RIGHT_SELECTION_FILE_NAME } } );
2461
2462   editor.SetProperty( Actor::Property::SIZE, Vector2( 30.f, 500.f ) );
2463   editor.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT );
2464   editor.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT );
2465
2466   // Avoid a crash when core load gl resources.
2467   application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
2468
2469   // Render and notify
2470   application.SendNotification();
2471   application.Render();
2472
2473   // Tap first to get the focus.
2474   TestGenerateTap( application, 3.0f, 25.0f, 100 );
2475
2476   // Render and notify
2477   application.SendNotification();
2478   application.Render();
2479
2480   // Tap to create the grab handle.
2481   TestGenerateTap( application, 3.0f, 25.0f, 700 );
2482
2483   // Render and notify
2484   application.SendNotification();
2485   application.Render();
2486
2487   // Get the active layer where the text's decoration is added.
2488   Actor activeLayer = editor.GetChildAt( 1u );
2489
2490   // Get the handle's actor.
2491   Actor handle = activeLayer.GetChildAt( 1u );
2492   handle.SetProperty( Actor::Property::SIZE, Vector2( 100.f, 100.f ) );
2493
2494   // Render and notify
2495   application.SendNotification();
2496   application.Render();
2497
2498   // Touch the grab handle to set it as pressed.
2499   Vector2 touchPos( 10.0f, 50.0f );
2500   Dali::Integration::TouchEvent event;
2501   event = Dali::Integration::TouchEvent();
2502   event.AddPoint( GetPointDownInside( touchPos ) );
2503   application.ProcessEvent( event );
2504
2505   // Render and notify
2506   application.SendNotification();
2507   application.Render();
2508
2509   // Pan the grab handle
2510   uint32_t time = 100;
2511   TestStartPan( application, Vector2(10.0f, 50.0f), Vector2(10.0f, 50.0f), time );
2512   TestMovePan( application, Vector2(10.0f, 30.0f), time );
2513   TestEndPan( application, Vector2(10.0f, 50.0f), time);
2514   application.SendNotification();
2515   application.Render();
2516
2517
2518   // Release the grab handle.
2519   event = Dali::Integration::TouchEvent();
2520   event.AddPoint( GetPointUpInside( touchPos ) );
2521   application.ProcessEvent( event );
2522
2523   // Render and notify
2524   application.SendNotification();
2525   application.Render();
2526
2527   // Tap first to get the focus.
2528   TestGenerateTap( application, 3.0f, 25.0f, 1400 );
2529
2530   // Render and notify
2531   application.SendNotification();
2532   application.Render();
2533
2534   // Double tap to select a word and create the selection handles.
2535   TestGenerateTap( application, 3.0f, 25.0f, 1500 );
2536
2537   // Render and notify
2538   application.SendNotification();
2539   application.Render();
2540
2541   touchPos = Vector2( 10.0f, 50.0f );
2542
2543   // Touch the left selection handle to set it as pressed.
2544   event = Dali::Integration::TouchEvent();
2545   event.AddPoint( GetPointDownInside( touchPos ) );
2546   application.ProcessEvent( event );
2547
2548   // Render and notify
2549   application.SendNotification();
2550   application.Render();
2551
2552   // Release the left selection handle.
2553   event = Dali::Integration::TouchEvent();
2554   event.AddPoint( GetPointUpInside( touchPos ) );
2555   application.ProcessEvent( event );
2556
2557   // Render and notify
2558   application.SendNotification();
2559   application.Render();
2560
2561   END_TEST;
2562 }
2563
2564 int utcDaliTextEditorUnderPropertyStringP(void)
2565 {
2566   ToolkitTestApplication application;
2567   tet_infoline(" utcDaliTextEditorUnderPropertyStringP");
2568   TextEditor editor = TextEditor::New();
2569   DALI_TEST_CHECK( editor );
2570
2571   std::string underlineSettings1( "{\"enable\":\"true\",\"color\":\"red\",\"height\":\"1\"}" );
2572
2573   application.GetScene().Add( editor );
2574
2575   editor.SetProperty( TextEditor::Property::UNDERLINE, underlineSettings1 );
2576   DALI_TEST_EQUALS( editor.GetProperty<std::string>( TextEditor::Property::UNDERLINE ), underlineSettings1, TEST_LOCATION );
2577
2578   tet_infoline("Set underline settings with a map");
2579   // Check the input underline property
2580   Property::Map underlineMapSet;
2581   Property::Map underlineMapGet;
2582   underlineMapSet.Insert( "enable", true );
2583   underlineMapSet.Insert( "color", Color::BLUE );
2584   underlineMapSet.Insert( "height", 2 );
2585
2586   editor.SetProperty( TextEditor::Property::UNDERLINE, underlineMapSet );
2587   underlineMapGet = editor.GetProperty<Property::Map>( TextEditor::Property::UNDERLINE );
2588   DALI_TEST_EQUALS( underlineMapGet.Count(), underlineMapSet.Count(), TEST_LOCATION );
2589   DALI_TEST_EQUALS( DaliTestCheckMaps( underlineMapSet, underlineMapGet ), true,  TEST_LOCATION );
2590
2591   tet_infoline("Set underline settings with a string");
2592   editor.SetProperty( TextEditor::Property::UNDERLINE, underlineSettings1 );
2593   Property::Value value = editor.GetProperty( TextEditor::Property::UNDERLINE );
2594   std::string result;
2595   value.Get(result);
2596   DALI_TEST_EQUALS( result , underlineSettings1, TEST_LOCATION  );
2597
2598   tet_infoline("Trying to set invalid underline settings, should not update and stay at previous settings");
2599   std::string underlineSettingsVoid( "{\"enable\":\"true\",\"coooolor\":\"blue\",\"heeeight\":\"4\"}" );
2600   editor.SetProperty( TextEditor::Property::UNDERLINE, underlineSettingsVoid );
2601   value = editor.GetProperty( TextEditor::Property::UNDERLINE );
2602   value.Get(result);
2603   DALI_TEST_EQUALS( result , underlineSettings1, TEST_LOCATION  );
2604
2605   END_TEST;
2606 }
2607
2608 int utcDaliTextEditorShadowPropertyStringP(void)
2609 {
2610   ToolkitTestApplication application;
2611   tet_infoline(" utcDaliTextEditorUnderPropertyStringP Setting Shadow propeties by string");
2612
2613   TextEditor editor = TextEditor::New();
2614
2615   std::string shadowSettings( "{\"color\":\"green\",\"offset\":\"2 2\",\"blurRadius\":\"0\"}" );
2616
2617   application.GetScene().Add( editor );
2618
2619   editor.SetProperty( TextEditor::Property::SHADOW, "{\"color\":\"green\",\"offset\":\"2 2\",\"blurRadius\":\"0\"}" );
2620
2621   Property::Value value = editor.GetProperty<std::string>( TextEditor::Property::SHADOW );
2622   std::string result;
2623   value.Get(result);
2624
2625   DALI_TEST_EQUALS( result, shadowSettings, TEST_LOCATION );
2626
2627   END_TEST;
2628 }
2629
2630 int utcDaliTextEditorFontStylePropertyStringP(void)
2631 {
2632   ToolkitTestApplication application;
2633   tet_infoline(" utcDaliTextEditorFontStylePropertyStringP Setting FontStyle propeties by string");
2634
2635   TextEditor editor = TextEditor::New();
2636
2637   std::string fontStyleSettings( "{\"weight\":\"bold\",\"width\":\"condensed\",\"slant\":\"italic\"}" );
2638
2639   application.GetScene().Add( editor );
2640
2641   editor.SetProperty( TextEditor::Property::FONT_STYLE, "{\"weight\":\"bold\",\"width\":\"condensed\",\"slant\":\"italic\"}" );
2642
2643   Property::Value value = editor.GetProperty<std::string>( TextEditor::Property::FONT_STYLE );
2644   std::string result;
2645   value.Get(result);
2646
2647   DALI_TEST_EQUALS( result, fontStyleSettings, TEST_LOCATION );
2648
2649   END_TEST;
2650 }
2651
2652 int utcDaliTextEditorGetPropertyLinecountP(void)
2653 {
2654   ToolkitTestApplication application;
2655
2656   tet_infoline(" utcDaliTextEditorGetPropertyLinecount getting line count property");
2657
2658   int lineCount =0 ;
2659
2660   TextEditor editor = TextEditor::New();
2661   editor.SetProperty( TextEditor::Property::POINT_SIZE, 10) ;
2662   editor.SetProperty( TextEditor::Property::TEXT,
2663                        "TEST TEST TEST TEST TEST TEST TEST TEST TEST TEST TEST TEST TEST TEST ");
2664
2665   application.GetScene().Add( editor );
2666
2667   editor.SetProperty( Actor::Property::SIZE, Vector2( 100.f, 100.f ) );
2668   lineCount =  editor.GetProperty<int>( TextEditor::Property::LINE_COUNT );
2669   DALI_TEST_EQUALS( lineCount, 14, TEST_LOCATION );
2670
2671   editor.SetProperty( Actor::Property::SIZE, Vector2( 50.f, 100.f ) );
2672   lineCount =  editor.GetProperty<int>( TextEditor::Property::LINE_COUNT );
2673   DALI_TEST_EQUALS( lineCount, 28, TEST_LOCATION );
2674
2675   END_TEST;
2676 }
2677
2678 int utcDaliTextEditorScrollStateChangedSignalTest(void)
2679 {
2680
2681   ToolkitTestApplication application;
2682   tet_infoline(" UtcDaliTextEditorScrollStateChangedSignalTest");
2683
2684   TextEditor editor = TextEditor::New();
2685   DALI_TEST_CHECK( editor );
2686
2687   application.GetScene().Add( editor );
2688
2689   editor.SetProperty( TextEditor::Property::POINT_SIZE, 10.f );
2690   editor.SetProperty( Actor::Property::SIZE, Vector2( 50.f, 50.f ) );
2691   editor.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT );
2692   editor.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT );
2693   editor.SetProperty( TextEditor::Property::ENABLE_SCROLL_BAR, true );
2694   editor.SetProperty( Actor::Property::KEYBOARD_FOCUSABLE,true);
2695
2696   bool startedCalled = false;
2697   bool finishedCalled = false;
2698
2699   ScrollStateChangeCallback callback( startedCalled, finishedCalled );
2700   editor.ScrollStateChangedSignal().Connect( &callback, &ScrollStateChangeCallback::Callback );
2701
2702   KeyboardFocusManager::Get().SetCurrentFocusActor( editor );
2703
2704   // Render and notify
2705   application.SendNotification();
2706   application.Render();
2707
2708   editor.SetProperty( TextEditor::Property::TEXT, "Long enough message for TextEditor!");
2709   application.SendNotification();
2710   application.Render(6000);
2711
2712   application.SendNotification();
2713   DALI_TEST_EQUALS( startedCalled, true, TEST_LOCATION );
2714   DALI_TEST_EQUALS( finishedCalled, true, TEST_LOCATION );
2715
2716   END_TEST;
2717 }
2718
2719 int UtcDaliToolkitTextEditorTextWrapMode(void)
2720 {
2721   ToolkitTestApplication application;
2722   tet_infoline(" UtcDaliToolkitTextEditorTextWarpMode");
2723
2724   int lineCount =0 ;
2725
2726   TextEditor editor = TextEditor::New();
2727   editor.SetProperty( Actor::Property::SIZE, Vector2( 150.0f, 300.f ) );
2728   editor.SetProperty( TextEditor::Property::TEXT, "Hello world Hello world" );
2729
2730   application.GetScene().Add( editor );
2731
2732   editor.SetProperty( TextEditor::Property::LINE_WRAP_MODE, "WORD" );
2733   DALI_TEST_EQUALS( editor.GetProperty< int >( TextEditor::Property::LINE_WRAP_MODE ), static_cast< int >( Text::LineWrap::WORD ), TEST_LOCATION );
2734
2735   application.SendNotification();
2736   application.Render();
2737
2738   lineCount =  editor.GetProperty<int>( TextEditor::Property::LINE_COUNT );
2739   DALI_TEST_EQUALS( lineCount, 4, TEST_LOCATION );
2740
2741   editor.SetProperty( TextEditor::Property::LINE_WRAP_MODE, "CHARACTER" );
2742   DALI_TEST_EQUALS( editor.GetProperty< int >( TextEditor::Property::LINE_WRAP_MODE ), static_cast< int >( Text::LineWrap::CHARACTER ), TEST_LOCATION );
2743
2744   application.SendNotification();
2745   application.Render();
2746
2747   lineCount =  editor.GetProperty<int>( TextEditor::Property::LINE_COUNT );
2748   DALI_TEST_EQUALS( lineCount, 3, TEST_LOCATION );
2749
2750   editor.SetProperty( TextEditor::Property::LINE_WRAP_MODE, Text::LineWrap::WORD );
2751   DALI_TEST_EQUALS( editor.GetProperty< int >( TextEditor::Property::LINE_WRAP_MODE ), static_cast< int >( Text::LineWrap::WORD ), TEST_LOCATION );
2752
2753   application.SendNotification();
2754   application.Render();
2755
2756   lineCount =  editor.GetProperty<int>( TextEditor::Property::LINE_COUNT );
2757   DALI_TEST_EQUALS( lineCount, 4, TEST_LOCATION );
2758
2759   editor.SetProperty( TextEditor::Property::LINE_WRAP_MODE, Text::LineWrap::CHARACTER );
2760   DALI_TEST_EQUALS( editor.GetProperty< int >( TextEditor::Property::LINE_WRAP_MODE ), static_cast< int >( Text::LineWrap::CHARACTER ), TEST_LOCATION );
2761
2762   application.SendNotification();
2763   application.Render();
2764
2765   lineCount =  editor.GetProperty<int>( TextEditor::Property::LINE_COUNT );
2766   DALI_TEST_EQUALS( lineCount, 3, TEST_LOCATION );
2767
2768   END_TEST;
2769 }
2770
2771 int UtcDaliTextEditorSetPaddingProperty(void)
2772 {
2773   ToolkitTestApplication application;
2774   tet_infoline("UtcDaliTextEditorSetPaddingProperty\n");
2775
2776   TextEditor editor = TextEditor::New();
2777   DALI_TEST_CHECK( editor );
2778   editor.SetProperty( Actor::Property::SIZE, Vector2( 300.f, 50.f ) );
2779   editor.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT );
2780   editor.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT );
2781   application.GetScene().Add( editor );
2782
2783   application.SendNotification();
2784   application.Render();
2785
2786   Vector3 originalSize = editor.GetNaturalSize();
2787
2788   editor.SetProperty( Toolkit::Control::Property::PADDING, Extents( 10, 10, 10, 10 ) );
2789
2790   application.SendNotification();
2791   application.Render();
2792
2793   DALI_TEST_EQUALS( editor.GetProperty<Extents>( Toolkit::Control::Property::PADDING ), Extents( 10, 10, 10, 10 ), TEST_LOCATION );
2794
2795   Vector3 paddingAddedSize = editor.GetNaturalSize();
2796
2797   DALI_TEST_EQUALS( originalSize.width + 10 + 10 , paddingAddedSize.width, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
2798
2799   DALI_TEST_EQUALS( originalSize.height + 10 + 10 , paddingAddedSize.height, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
2800
2801   END_TEST;
2802 }
2803
2804 int UtcDaliTextEditorEnableShiftSelectionProperty(void)
2805 {
2806   ToolkitTestApplication application;
2807   tet_infoline("UtcDaliTextEditorEnableShiftSelectionProperty");
2808
2809   TextEditor editor = TextEditor::New();
2810   DALI_TEST_CHECK( editor );
2811   editor.SetProperty( Actor::Property::SIZE, Vector2( 300.f, 50.f ) );
2812   editor.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT );
2813   editor.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT );
2814   application.GetScene().Add( editor );
2815
2816   application.SendNotification();
2817   application.Render();
2818
2819   // The default value of ENABLE_SHIFT_SELECTION is 'true'.
2820   DALI_TEST_EQUALS( editor.GetProperty<bool>( DevelTextEditor::Property::ENABLE_SHIFT_SELECTION ), true, TEST_LOCATION );
2821
2822   // Check the enable shift selection property
2823   editor.SetProperty( DevelTextEditor::Property::ENABLE_SHIFT_SELECTION, false );
2824   DALI_TEST_EQUALS( editor.GetProperty<bool>( DevelTextEditor::Property::ENABLE_SHIFT_SELECTION ), false, TEST_LOCATION );
2825
2826   application.SendNotification();
2827   application.Render();
2828
2829   END_TEST;
2830 }
2831
2832 int UtcDaliTextEditorEnableGrabHandleProperty(void)
2833 {
2834   ToolkitTestApplication application;
2835   tet_infoline("UtcDaliTextEditorEnableGrabHandleProperty");
2836
2837   TextEditor editor = TextEditor::New();
2838   DALI_TEST_CHECK( editor );
2839   editor.SetProperty( Actor::Property::SIZE, Vector2( 300.f, 50.f ) );
2840   editor.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT );
2841   editor.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT );
2842   application.GetScene().Add( editor );
2843
2844   application.SendNotification();
2845   application.Render();
2846
2847   // The default value of ENABLE_GRAB_HANDLE is 'true'.
2848   DALI_TEST_EQUALS( editor.GetProperty<bool>( DevelTextEditor::Property::ENABLE_GRAB_HANDLE ), true, TEST_LOCATION );
2849
2850   // Check the enable grab handle property
2851   editor.SetProperty( DevelTextEditor::Property::ENABLE_GRAB_HANDLE, false );
2852   DALI_TEST_EQUALS( editor.GetProperty<bool>( DevelTextEditor::Property::ENABLE_GRAB_HANDLE ), false, TEST_LOCATION );
2853
2854   application.SendNotification();
2855   application.Render();
2856
2857   END_TEST;
2858 }
2859
2860 int UtcDaliTextEditorMatchSystemLanguageDirectionProperty(void)
2861 {
2862   ToolkitTestApplication application;
2863   tet_infoline("UtcDaliTextEditorMatchSystemLanguageDirectionProperty");
2864
2865   TextEditor editor = TextEditor::New();
2866   DALI_TEST_CHECK( editor );
2867   editor.SetProperty( Actor::Property::SIZE, Vector2( 300.f, 50.f ) );
2868   editor.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT );
2869   editor.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT );
2870   application.GetScene().Add( editor );
2871
2872   application.SendNotification();
2873   application.Render();
2874
2875   // The default value of MATCH_SYSTEM_LANGUAGE_DIRECTION is 'false'.
2876   DALI_TEST_EQUALS( editor.GetProperty<bool>( DevelTextEditor::Property::MATCH_SYSTEM_LANGUAGE_DIRECTION ), false, TEST_LOCATION );
2877
2878   // Check the enable match system language direction property
2879   editor.SetProperty( DevelTextEditor::Property::MATCH_SYSTEM_LANGUAGE_DIRECTION, true );
2880   DALI_TEST_EQUALS( editor.GetProperty<bool>( DevelTextEditor::Property::MATCH_SYSTEM_LANGUAGE_DIRECTION ), true, TEST_LOCATION );
2881
2882   application.SendNotification();
2883   application.Render();
2884
2885   END_TEST;
2886 }
2887
2888 int UtcDaliTextEditorGetInputMethodContext(void)
2889 {
2890   ToolkitTestApplication application;
2891   tet_infoline("UtcDaliTextEditorGetInputMethodContext");
2892
2893   TextEditor editor = TextEditor::New();
2894   DALI_TEST_CHECK( DevelTextEditor::GetInputMethodContext( editor ) );
2895
2896   END_TEST;
2897 }
2898
2899 int utcDaliTextEditorMaxCharactersReached(void)
2900 {
2901   ToolkitTestApplication application;
2902   tet_infoline("utcDaliTextEditorMaxCharactersReached");
2903
2904   TextEditor editor = TextEditor::New();
2905   DALI_TEST_CHECK( editor );
2906
2907   application.GetScene().Add( editor );
2908
2909   const int maxNumberOfCharacters = 1;
2910   editor.SetProperty( DevelTextEditor::Property::MAX_LENGTH, maxNumberOfCharacters );
2911   DALI_TEST_EQUALS( editor.GetProperty<int>( DevelTextEditor::Property::MAX_LENGTH ), maxNumberOfCharacters, TEST_LOCATION );
2912
2913   editor.SetKeyInputFocus();
2914
2915   // connect to the text changed signal.
2916   ConnectionTracker* testTracker = new ConnectionTracker();
2917   DevelTextEditor::MaxLengthReachedSignal( editor ).Connect(&TestMaxLengthReachedCallback);
2918   bool maxLengthReachedSignal = false;
2919   editor.ConnectSignal( testTracker, "maxLengthReached", CallbackFunctor(&maxLengthReachedSignal) );
2920
2921   gMaxCharactersCallBackCalled = false;
2922
2923   application.ProcessEvent( GenerateKey( "a", "", "a", KEY_A_CODE, 0, 0, Integration::KeyEvent::DOWN, "a", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2924   application.ProcessEvent( GenerateKey( "a", "", "a", KEY_A_CODE, 0, 0, Integration::KeyEvent::DOWN, "a", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2925
2926   DALI_TEST_CHECK( gMaxCharactersCallBackCalled );
2927   DALI_TEST_CHECK( maxLengthReachedSignal );
2928
2929   END_TEST;
2930 }
2931
2932 int UtcDaliTextEditorSelectWholeText(void)
2933 {
2934   ToolkitTestApplication application;
2935   tet_infoline(" UtcDaliTextEditorSelectWholeText ");
2936
2937   TextEditor textEditor = TextEditor::New();
2938
2939   application.GetScene().Add( textEditor );
2940
2941   textEditor.SetProperty( Actor::Property::SIZE, Vector2( 300.f, 50.f ) );
2942   textEditor.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT );
2943   textEditor.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT );
2944
2945   // Avoid a crash when core load gl resources.
2946   application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
2947
2948   application.SendNotification();
2949   application.Render();
2950
2951   DALI_TEST_EQUALS( 1u, textEditor.GetChildCount(), TEST_LOCATION );
2952
2953   DevelTextEditor::SelectWholeText( textEditor );
2954
2955   application.SendNotification();
2956   application.Render();
2957
2958   // Nothing should have been selected. The number of children is still 1
2959   DALI_TEST_EQUALS( 1u, textEditor.GetChildCount(), TEST_LOCATION );
2960
2961   textEditor.SetProperty( TextEditor::Property::TEXT, "Hello world" );
2962
2963   application.SendNotification();
2964   application.Render();
2965
2966   DevelTextEditor::SelectWholeText( textEditor );
2967
2968   application.SendNotification();
2969   application.Render();
2970
2971   // Should be 2 children, the stencil and the layer
2972   DALI_TEST_EQUALS( 2u, textEditor.GetChildCount(), TEST_LOCATION );
2973
2974   // The offscreen root actor should have two actors: the renderer and the highlight actor.
2975   Actor stencil = textEditor.GetChildAt( 0u );
2976
2977   // The highlight actor is drawn first, so is the first actor in the list
2978   Renderer highlight = stencil.GetChildAt( 0u ).GetRendererAt( 0u );
2979   DALI_TEST_CHECK( highlight );
2980
2981   END_TEST;
2982 }
2983
2984 int UtcDaliTextEditorSelectNone(void)
2985 {
2986   ToolkitTestApplication application;
2987   tet_infoline(" UtcDaliTextEditorSelectWholeText ");
2988
2989   TextEditor textEditor = TextEditor::New();
2990
2991   application.GetScene().Add( textEditor );
2992
2993   textEditor.SetProperty( Actor::Property::SIZE, Vector2( 300.f, 50.f ) );
2994   textEditor.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT );
2995   textEditor.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT );
2996
2997   // Avoid a crash when core load gl resources.
2998   application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
2999
3000   application.SendNotification();
3001   application.Render();
3002
3003   textEditor.SetProperty( TextEditor::Property::TEXT, "Hello world" );
3004
3005   application.SendNotification();
3006   application.Render();
3007
3008   // Nothing is selected
3009   std::string selectedText = textEditor.GetProperty( DevelTextEditor::Property::SELECTED_TEXT ).Get<std::string>();
3010   DALI_TEST_EQUALS( "", selectedText, TEST_LOCATION );
3011
3012   DevelTextEditor::SelectWholeText( textEditor );
3013
3014   application.SendNotification();
3015   application.Render();
3016
3017   // whole text is selected
3018   selectedText = textEditor.GetProperty( DevelTextEditor::Property::SELECTED_TEXT ).Get<std::string>();
3019   DALI_TEST_EQUALS( "Hello world", selectedText, TEST_LOCATION );
3020
3021   DevelTextEditor::SelectNone( textEditor );
3022
3023   application.SendNotification();
3024   application.Render();
3025
3026   // Nothing is selected
3027   selectedText = textEditor.GetProperty( DevelTextEditor::Property::SELECTED_TEXT ).Get<std::string>();
3028   DALI_TEST_EQUALS( "", selectedText, TEST_LOCATION );
3029
3030   END_TEST;
3031 }
3032
3033 int UtcDaliTextEditorSelectRange(void)
3034 {
3035   ToolkitTestApplication application;
3036   tet_infoline("utcDaliTextEditorSelectRange");
3037
3038   TextEditor textEditor = TextEditor::New();
3039   DALI_TEST_CHECK( textEditor );
3040
3041   application.GetScene().Add( textEditor );
3042
3043   // Avoid a crash when core load gl resources.
3044   application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
3045
3046   application.SendNotification();
3047   application.Render();
3048
3049   textEditor.SetProperty( TextEditor::Property::TEXT, "Hello world" );
3050
3051   textEditor.SetProperty( DevelTextEditor::Property::SELECTED_TEXT_START, 0 );
3052   textEditor.SetProperty( DevelTextEditor::Property::SELECTED_TEXT_END, 5 );
3053
3054   // Hello is selected
3055   std::string selectedText = textEditor.GetProperty( DevelTextEditor::Property::SELECTED_TEXT ).Get<std::string>();
3056   DALI_TEST_EQUALS( "Hello", selectedText, TEST_LOCATION );
3057
3058   DALI_TEST_EQUALS( textEditor.GetProperty( DevelTextEditor::Property::SELECTED_TEXT_START ).Get<int>(), 0, TEST_LOCATION );
3059   DALI_TEST_EQUALS( textEditor.GetProperty( DevelTextEditor::Property::SELECTED_TEXT_END ).Get<int>(), 5, TEST_LOCATION );
3060
3061   END_TEST;
3062 }
3063
3064 int UtcDaliTextEditorEnableEditing(void)
3065 {
3066   ToolkitTestApplication application;
3067   tet_infoline(" UtcDaliTextEditorEnableEditing ");
3068
3069   TextEditor textEditor = TextEditor::New();
3070
3071   application.GetScene().Add( textEditor );
3072
3073   textEditor.SetProperty( Actor::Property::SIZE, Vector2( 300.f, 50.f ) );
3074   textEditor.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT );
3075   textEditor.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT );
3076
3077   // Avoid a crash when core load gl resources.
3078   application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
3079
3080   application.SendNotification();
3081   application.Render();
3082
3083   textEditor.SetKeyInputFocus();
3084   textEditor.SetProperty( DevelTextEditor::Property::ENABLE_EDITING, false );
3085   application.ProcessEvent( GenerateKey( "D", "", "D", KEY_D_CODE, 0, 0, Integration::KeyEvent::DOWN, "D", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
3086
3087   // Render and notify
3088   application.SendNotification();
3089   application.Render();
3090
3091   DALI_TEST_EQUALS( textEditor.GetProperty( TextEditor::Property::TEXT ).Get<std::string>(), "", TEST_LOCATION );
3092   DALI_TEST_EQUALS( textEditor.GetProperty( DevelTextEditor::Property::ENABLE_EDITING ).Get<bool>(), false, TEST_LOCATION );
3093
3094   textEditor.SetKeyInputFocus();
3095   textEditor.SetProperty( DevelTextEditor::Property::ENABLE_EDITING, true );
3096   application.ProcessEvent( GenerateKey( "D", "", "D", KEY_D_CODE, 0, 0, Integration::KeyEvent::DOWN, "D", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
3097
3098   // Render and notify
3099   application.SendNotification();
3100   application.Render();
3101
3102   DALI_TEST_EQUALS( textEditor.GetProperty( TextEditor::Property::TEXT ).Get<std::string>(), "D", TEST_LOCATION );
3103   DALI_TEST_EQUALS( textEditor.GetProperty( DevelTextEditor::Property::ENABLE_EDITING ).Get<bool>(), true, TEST_LOCATION );
3104
3105   END_TEST;
3106 }
3107
3108 int UtcDaliTextEditorScrolling(void)
3109 {
3110   ToolkitTestApplication application;
3111   tet_infoline(" UtcDaliTextEditorScrolling ");
3112
3113   TextEditor textEditor = TextEditor::New();
3114   DALI_TEST_CHECK( textEditor );
3115
3116   application.GetScene().Add( textEditor );
3117
3118   // Avoid a crash when core load gl resources.
3119   application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
3120
3121   application.SendNotification();
3122   application.Render();
3123
3124   textEditor.SetProperty(TextEditor::Property::TEXT, "Tex1\nTex2\nTex3\nTex4\nTex5\nTex6\nTex7\nTex8");
3125   textEditor.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_CENTER);
3126   textEditor.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_CENTER);
3127   textEditor.SetProperty(Actor::Property::SIZE, Vector2(60.0f, 160.0f));
3128
3129   application.SendNotification();
3130   application.Render();
3131
3132   DALI_TEST_EQUALS( textEditor.GetProperty( DevelTextEditor::Property::VERTICAL_SCROLL_POSITION ).Get<float>(), 0.0f, TEST_LOCATION );
3133   DALI_TEST_EQUALS( textEditor.GetProperty( DevelTextEditor::Property::HORIZONTAL_SCROLL_POSITION ).Get<float>(), 0.0f, TEST_LOCATION );
3134
3135
3136   DevelTextEditor::ScrollBy(textEditor, Vector2(1.0f, 1.0f));
3137
3138   DALI_TEST_EQUALS( textEditor.GetProperty( DevelTextEditor::Property::VERTICAL_SCROLL_POSITION ).Get<float>(), 1.0f, TEST_LOCATION );
3139   DALI_TEST_EQUALS( textEditor.GetProperty( DevelTextEditor::Property::HORIZONTAL_SCROLL_POSITION ).Get<float>(), 0.0f, TEST_LOCATION );
3140
3141   DevelTextEditor::ScrollBy(textEditor, Vector2(0.0f, 1000.0f));
3142
3143   DALI_TEST_NOT_EQUALS( textEditor.GetProperty( DevelTextEditor::Property::VERTICAL_SCROLL_POSITION ).Get<float>(), 1.0f, 0.1f, TEST_LOCATION );
3144   DALI_TEST_EQUALS( textEditor.GetProperty( DevelTextEditor::Property::HORIZONTAL_SCROLL_POSITION ).Get<float>(), 0.0f, TEST_LOCATION );
3145
3146   textEditor.SetProperty(DevelTextEditor::Property::VERTICAL_SCROLL_POSITION , 0.0f);
3147   textEditor.SetProperty(DevelTextEditor::Property::HORIZONTAL_SCROLL_POSITION , 0.0f);
3148
3149   DALI_TEST_EQUALS( textEditor.GetProperty( DevelTextEditor::Property::VERTICAL_SCROLL_POSITION ).Get<float>(), 0.0f, TEST_LOCATION );
3150   DALI_TEST_EQUALS( textEditor.GetProperty( DevelTextEditor::Property::HORIZONTAL_SCROLL_POSITION ).Get<float>(), 0.0f, TEST_LOCATION );
3151
3152   END_TEST;
3153 }
3154
3155 int UtcDaliToolkitTextEditorFontSizeScale(void)
3156 {
3157   ToolkitTestApplication application;
3158   tet_infoline(" UtcDaliToolkitTextEditorFontSizeScale");
3159
3160   TextEditor textEditor = TextEditor::New();
3161   textEditor.SetProperty( TextEditor::Property::POINT_SIZE, 30.f );
3162   textEditor.SetProperty( TextEditor::Property::TEXT, "Test" );
3163   Vector3 nonScaledSize = textEditor.GetNaturalSize();
3164
3165   TextEditor textEditorScaled = TextEditor::New();
3166   textEditorScaled.SetProperty( TextEditor::Property::POINT_SIZE, 15.f );
3167   textEditorScaled.SetProperty( Toolkit::DevelTextEditor::Property::FONT_SIZE_SCALE, 2.f );
3168   textEditorScaled.SetProperty( TextEditor::Property::TEXT, "Test" );
3169   Vector3 scaledSize = textEditorScaled.GetNaturalSize();
3170
3171   DALI_TEST_EQUALS( nonScaledSize, scaledSize, TEST_LOCATION );
3172
3173   textEditor.SetProperty( TextEditor::Property::PIXEL_SIZE, 30.f );
3174   textEditor.SetProperty( TextEditor::Property::TEXT, "Test" );
3175   nonScaledSize = textEditor.GetNaturalSize();
3176
3177   textEditorScaled.SetProperty( TextEditor::Property::PIXEL_SIZE, 15.f );
3178   textEditorScaled.SetProperty( Toolkit::DevelTextEditor::Property::FONT_SIZE_SCALE, 2.f );
3179   textEditorScaled.SetProperty( TextEditor::Property::TEXT, "Test" );
3180   scaledSize = textEditorScaled.GetNaturalSize();
3181
3182   DALI_TEST_EQUALS( nonScaledSize, scaledSize, TEST_LOCATION );
3183
3184   END_TEST;
3185 }
3186
3187 int UtcDaliTextEditorPrimaryCursorPosition(void)
3188 {
3189   ToolkitTestApplication application;
3190   tet_infoline(" UtcDaliTextPrimaryCursorPosition ");
3191
3192   TextEditor textEditor = TextEditor::New();
3193
3194   application.GetScene().Add( textEditor );
3195
3196   textEditor.SetProperty( TextEditor::Property::TEXT, "ABCEF");
3197   textEditor.SetProperty( Actor::Property::SIZE, Vector2( 300.f, 50.f ) );
3198   textEditor.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT );
3199   textEditor.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT );
3200
3201   // Avoid a crash when core load gl resources.
3202   application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
3203
3204   textEditor.SetProperty( DevelTextEditor::Property::PRIMARY_CURSOR_POSITION, 3);
3205   application.SendNotification();
3206   application.Render();
3207
3208   application.ProcessEvent( GenerateKey( "D", "", "D", KEY_D_CODE, 0, 0, Integration::KeyEvent::DOWN, "D", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
3209
3210   // Render and notify
3211   application.SendNotification();
3212   application.Render();
3213
3214   DALI_TEST_EQUALS( textEditor.GetProperty( TextEditor::Property::TEXT ).Get<std::string>(), "ABCDEF", TEST_LOCATION );
3215   DALI_TEST_EQUALS( textEditor.GetProperty( DevelTextEditor::Property::PRIMARY_CURSOR_POSITION ).Get<int>(), 4, TEST_LOCATION );
3216
3217   END_TEST;
3218 }
3219
3220 int UtcDaliTextEditorLineCountAfterGetNaturalSize(void)
3221 {
3222   ToolkitTestApplication application;
3223   tet_infoline(" UtcDaliTextEditorLineCountAfterGetNaturalSize ");
3224
3225   TextEditor textEditor = TextEditor::New();
3226   textEditor.SetProperty(TextEditor::Property::TEXT, "A\nB\nC\nD\nE\nF\n");
3227   textEditor.SetProperty( Actor::Property::SIZE, Vector2( 300.f, 50.f ) );
3228   textEditor.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT );
3229   textEditor.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT );
3230   application.GetScene().Add( textEditor );
3231
3232   application.SendNotification();
3233   application.Render();
3234
3235   int lineCount = 0;
3236   lineCount =  textEditor.GetProperty<int>( TextEditor::Property::LINE_COUNT );
3237   DALI_TEST_EQUALS( lineCount, 7, TEST_LOCATION );
3238
3239   textEditor.GetNaturalSize();
3240
3241   // Create a tap event to touch the text editor.
3242   TestGenerateTap( application, 18.0f, 25.0f );
3243
3244   application.SendNotification();
3245   application.Render();
3246
3247   lineCount =  textEditor.GetProperty<int>( TextEditor::Property::LINE_COUNT );
3248   DALI_TEST_EQUALS( lineCount, 7, TEST_LOCATION );
3249
3250   END_TEST;
3251 }