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