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