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