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