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