Merge "Add a callback for navigation policy in web view." into devel/master
[platform/core/uifw/dali-toolkit.git] / automated-tests / src / dali-toolkit / utc-Dali-TextEditor.cpp
1 /*
2  * Copyright (c) 2021 Samsung Electronics Co., Ltd.
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  * http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  *
16  */
17
18 #include <iostream>
19 #include <stdlib.h>
20 #include <unistd.h>
21 #include <dali/public-api/rendering/renderer.h>
22 #include <dali/devel-api/adaptor-framework/clipboard.h>
23 #include <dali/devel-api/adaptor-framework/key-devel.h>
24 #include <dali/devel-api/text-abstraction/font-client.h>
25 #include <dali/integration-api/events/key-event-integ.h>
26 #include <dali/integration-api/events/touch-event-integ.h>
27 #include <dali-toolkit-test-suite-utils.h>
28 #include <dali-toolkit/dali-toolkit.h>
29 #include <dali-toolkit/devel-api/controls/text-controls/text-editor-devel.h>
30 #include <dali-toolkit/devel-api/text/rendering-backend.h>
31 #include <dali-toolkit/devel-api/text/text-enumerations-devel.h>
32 #include "test-text-geometry-utils.h"
33
34 using namespace Dali;
35 using namespace Toolkit;
36
37 void dali_texteditor_startup(void)
38 {
39   test_return_value = TET_UNDEF;
40 }
41
42 void dali_texteditor_cleanup(void)
43 {
44   test_return_value = TET_PASS;
45 }
46
47 namespace
48 {
49
50 const char* const PROPERTY_NAME_RENDERING_BACKEND                    = "renderingBackend";
51 const char* const PROPERTY_NAME_TEXT                                 = "text";
52 const char* const PROPERTY_NAME_TEXT_COLOR                           = "textColor";
53 const char* const PROPERTY_NAME_FONT_FAMILY                          = "fontFamily";
54 const char* const PROPERTY_NAME_FONT_STYLE                           = "fontStyle";
55 const char* const PROPERTY_NAME_POINT_SIZE                           = "pointSize";
56 const char* const PROPERTY_NAME_HORIZONTAL_ALIGNMENT                 = "horizontalAlignment";
57 const char* const PROPERTY_NAME_SCROLL_THRESHOLD                     = "scrollThreshold";
58 const char* const PROPERTY_NAME_SCROLL_SPEED                         = "scrollSpeed";
59 const char* const PROPERTY_NAME_PRIMARY_CURSOR_COLOR                 = "primaryCursorColor";
60 const char* const PROPERTY_NAME_SECONDARY_CURSOR_COLOR               = "secondaryCursorColor";
61 const char* const PROPERTY_NAME_ENABLE_CURSOR_BLINK                  = "enableCursorBlink";
62 const char* const PROPERTY_NAME_CURSOR_BLINK_INTERVAL                = "cursorBlinkInterval";
63 const char* const PROPERTY_NAME_CURSOR_BLINK_DURATION                = "cursorBlinkDuration";
64 const char* const PROPERTY_NAME_CURSOR_WIDTH                         = "cursorWidth";
65 const char* const PROPERTY_NAME_GRAB_HANDLE_IMAGE                    = "grabHandleImage";
66 const char* const PROPERTY_NAME_GRAB_HANDLE_PRESSED_IMAGE            = "grabHandlePressedImage";
67 const char* const PROPERTY_NAME_SELECTION_HANDLE_IMAGE_LEFT          = "selectionHandleImageLeft";
68 const char* const PROPERTY_NAME_SELECTION_HANDLE_IMAGE_RIGHT         = "selectionHandleImageRight";
69 const char* const PROPERTY_NAME_SELECTION_HANDLE_PRESSED_IMAGE_LEFT  = "selectionHandlePressedImageLeft";
70 const char* const PROPERTY_NAME_SELECTION_HANDLE_PRESSED_IMAGE_RIGHT = "selectionHandlePressedImageRight";
71 const char* const PROPERTY_NAME_SELECTION_HANDLE_MARKER_IMAGE_LEFT   = "selectionHandleMarkerImageLeft";
72 const char* const PROPERTY_NAME_SELECTION_HANDLE_MARKER_IMAGE_RIGHT  = "selectionHandleMarkerImageRight";
73 const char* const PROPERTY_NAME_SELECTION_HIGHLIGHT_COLOR            = "selectionHighlightColor";
74 const char* const PROPERTY_NAME_DECORATION_BOUNDING_BOX              = "decorationBoundingBox";
75 const char* const PROPERTY_NAME_ENABLE_MARKUP                        = "enableMarkup";
76 const char* const PROPERTY_NAME_INPUT_COLOR                          = "inputColor";
77 const char* const PROPERTY_NAME_INPUT_FONT_FAMILY                    = "inputFontFamily";
78 const char* const PROPERTY_NAME_INPUT_FONT_STYLE                     = "inputFontStyle";
79 const char* const PROPERTY_NAME_INPUT_POINT_SIZE                     = "inputPointSize";
80
81 const char* const PROPERTY_NAME_LINE_SPACING                         = "lineSpacing";
82 const char* const PROPERTY_NAME_INPUT_LINE_SPACING                   = "inputLineSpacing";
83 const char* const PROPERTY_NAME_UNDERLINE                            = "underline";
84 const char* const PROPERTY_NAME_INPUT_UNDERLINE                      = "inputUnderline";
85 const char* const PROPERTY_NAME_SHADOW                               = "shadow";
86 const char* const PROPERTY_NAME_INPUT_SHADOW                         = "inputShadow";
87 const char* const PROPERTY_NAME_EMBOSS                               = "emboss";
88 const char* const PROPERTY_NAME_INPUT_EMBOSS                         = "inputEmboss";
89 const char* const PROPERTY_NAME_OUTLINE                              = "outline";
90 const char* const PROPERTY_NAME_INPUT_OUTLINE                        = "inputOutline";
91 const char* const PROPERTY_NAME_STRIKETHROUGH                        = "strikethrough";
92 const char* const PROPERTY_NAME_INPUT_STRIKETHROUGH                  = "inputStrikethrough";
93
94 const char* const PROPERTY_NAME_SMOOTH_SCROLL                        = "smoothScroll";
95 const char* const PROPERTY_NAME_SMOOTH_SCROLL_DURATION               = "smoothScrollDuration";
96 const char* const PROPERTY_NAME_ENABLE_SCROLL_BAR                    = "enableScrollBar";
97 const char* const PROPERTY_NAME_SCROLL_BAR_SHOW_DURATION             = "scrollBarShowDuration";
98 const char* const PROPERTY_NAME_SCROLL_BAR_FADE_DURATION             = "scrollBarFadeDuration";
99 const char* const PROPERTY_NAME_PIXEL_SIZE                           = "pixelSize";
100 const char* const PROPERTY_NAME_LINE_COUNT                           = "lineCount";
101 const char* const PROPERTY_NAME_PLACEHOLDER_TEXT                     = "placeholderText";
102 const char* const PROPERTY_NAME_PLACEHOLDER_TEXT_COLOR               = "placeholderTextColor";
103 const char* const PROPERTY_NAME_ENABLE_SELECTION                     = "enableSelection";
104 const char* const PROPERTY_NAME_PLACEHOLDER                          = "placeholder";
105 const char* const PROPERTY_NAME_ENABLE_SHIFT_SELECTION               = "enableShiftSelection";
106 const char* const PROPERTY_NAME_ENABLE_GRAB_HANDLE                   = "enableGrabHandle";
107 const char* const PROPERTY_NAME_MATCH_SYSTEM_LANGUAGE_DIRECTION      = "matchSystemLanguageDirection";
108 const char* const PROPERTY_NAME_MAX_LENGTH                           = "maxLength";
109 const char* const PROPERTY_NAME_FONT_SIZE_SCALE                      = "fontSizeScale";
110 const char* const PROPERTY_NAME_ENABLE_FONT_SIZE_SCALE               = "enableFontSizeScale";
111 const char* const PROPERTY_NAME_GRAB_HANDLE_COLOR                    = "grabHandleColor";
112 const char* const PROPERTY_NAME_ENABLE_GRAB_HANDLE_POPUP             = "enableGrabHandlePopup";
113 const char* const PROPERTY_NAME_INPUT_METHOD_SETTINGS                = "inputMethodSettings";
114 const char* const PROPERTY_NAME_INPUT_FILTER                         = "inputFilter";
115
116 const Vector4 PLACEHOLDER_TEXT_COLOR( 0.8f, 0.8f, 0.8f, 0.8f );
117 const Dali::Vector4 LIGHT_BLUE( 0.75f, 0.96f, 1.f, 1.f ); // The text highlight color.
118
119 const float RENDER_FRAME_INTERVAL = 16.66f;
120
121 const unsigned int DEFAULT_FONT_SIZE = 1152u;
122 const std::string DEFAULT_FONT_DIR( "/resources/fonts" );
123
124 const int KEY_A_CODE = 38;
125 const int KEY_D_CODE = 40;
126 const int KEY_C_CODE = 54;
127 const int KEY_V_CODE = 55;
128 const int KEY_X_CODE = 53;
129 const int KEY_WHITE_SPACE_CODE = 65;
130
131 const int KEY_SHIFT_MODIFIER = 257;
132 const int KEY_CONTROL_MODIFIER = 258;
133
134 const char* HANDLE_IMAGE_FILE_NAME = TEST_RESOURCE_DIR "/insertpoint-icon.png";
135 const char* HANDLE_LEFT_SELECTION_FILE_NAME = TEST_RESOURCE_DIR "/selection_handle_drop_left.png";
136 const char* HANDLE_RIGHT_SELECTION_FILE_NAME = TEST_RESOURCE_DIR "/selection_handle_drop_right.png";
137
138 const std::string DEFAULT_DEVICE_NAME("hwKeyboard");
139
140 static bool gSelectionChangedCallbackCalled;
141 static uint32_t oldSelectionStart;
142 static uint32_t oldSelectionEnd;
143 static bool gSelectionClearedCallbackCalled;
144 static bool gAnchorClickedCallBackCalled;
145 static bool gAnchorClickedCallBackNotCalled;
146 static bool gTextChangedCallBackCalled;
147 static bool gInputFilteredAcceptedCallbackCalled;
148 static bool gInputFilteredRejectedCallbackCalled;
149 static bool gInputStyleChangedCallbackCalled;
150 static bool gMaxCharactersCallBackCalled;
151 static bool gCursorPositionChangedCallbackCalled;
152 static uint32_t oldCursorPos;
153 static Dali::Toolkit::TextEditor::InputStyle::Mask gInputStyleMask;
154
155 struct CallbackFunctor
156 {
157   CallbackFunctor(bool* callbackFlag)
158   : mCallbackFlag( callbackFlag )
159   {
160   }
161
162   void operator()()
163   {
164     *mCallbackFlag = true;
165   }
166   bool* mCallbackFlag;
167 };
168
169 static void TestSelectionClearedCallback(TextEditor control)
170 {
171   tet_infoline(" TestSelectionClearedCallback");
172
173   gSelectionClearedCallbackCalled = true;
174 }
175
176 static void TestSelectionChangedCallback(TextEditor control, uint32_t oldStart, uint32_t oldEnd)
177 {
178   tet_infoline(" TestSelectionChangedCallback");
179
180   gSelectionChangedCallbackCalled = true;
181   oldSelectionStart = oldStart;
182   oldSelectionEnd   = oldEnd;
183 }
184
185 static void TestAnchorClickedCallback(TextEditor control, const char* href, unsigned int hrefLength)
186 {
187   tet_infoline(" TestAnchorClickedCallback");
188
189   gAnchorClickedCallBackNotCalled = false;
190
191   if (!strcmp(href, "https://www.tizen.org") && hrefLength == strlen(href))
192   {
193     gAnchorClickedCallBackCalled = true;
194   }
195 }
196
197 static void TestCursorPositionChangedCallback( TextEditor control, unsigned int oldPos )
198 {
199   tet_infoline(" TestCursorPositionChangedCallback");
200
201   gCursorPositionChangedCallbackCalled = true;
202   oldCursorPos = oldPos;
203 }
204
205 static void TestTextChangedCallback( TextEditor control )
206 {
207   tet_infoline(" TestTextChangedCallback");
208
209   gTextChangedCallBackCalled = true;
210 }
211
212 static void TestInputStyleChangedCallback( TextEditor control, TextEditor::InputStyle::Mask mask )
213 {
214   tet_infoline(" TestInputStyleChangedCallback");
215
216   gInputStyleChangedCallbackCalled = true;
217   gInputStyleMask = mask;
218 }
219
220 static void TestMaxLengthReachedCallback( TextEditor control )
221 {
222   tet_infoline(" TestMaxLengthReachedCallback");
223
224   gMaxCharactersCallBackCalled = true;
225 }
226
227 static void TestInputFilteredCallback(TextEditor control, Toolkit::InputFilter::Property::Type type)
228 {
229   tet_infoline(" TestInputFilteredCallback");
230
231   if(type == Toolkit::InputFilter::Property::ACCEPTED)
232   {
233     gInputFilteredAcceptedCallbackCalled = true;
234   }
235   else if(type == Toolkit::InputFilter::Property::REJECTED)
236   {
237     gInputFilteredRejectedCallbackCalled = true;
238   }
239 }
240
241 // Generate a KeyEvent to send to Core.
242 Integration::KeyEvent GenerateKey( const std::string& keyName,
243                                    const std::string& logicalKey,
244                                    const std::string& keyString,
245                                    int keyCode,
246                                    int keyModifier,
247                                    unsigned long timeStamp,
248                                    const Integration::KeyEvent::State& keyState,
249                                    const std::string& compose = "",
250                                    const std::string& deviceName = DEFAULT_DEVICE_NAME,
251                                    const Device::Class::Type& deviceClass = Device::Class::NONE,
252                                    const Device::Subclass::Type& deviceSubclass = Device::Subclass::NONE )
253 {
254   return Integration::KeyEvent( keyName,
255                                 logicalKey,
256                                 keyString,
257                                 keyCode,
258                                 keyModifier,
259                                 timeStamp,
260                                 keyState,
261                                 compose,
262                                 deviceName,
263                                 deviceClass,
264                                 deviceSubclass );
265 }
266
267 Dali::Integration::Point GetPointDownInside( Vector2& pos )
268 {
269   Dali::Integration::Point point;
270   point.SetState( PointState::DOWN );
271   point.SetScreenPosition( pos );
272   return point;
273 }
274
275 Dali::Integration::Point GetPointUpInside( Vector2& pos )
276 {
277   Dali::Integration::Point point;
278   point.SetState( PointState::UP );
279   point.SetScreenPosition( pos );
280   return point;
281 }
282
283 bool DaliTestCheckMaps( const Property::Map& fontStyleMapGet, const Property::Map& fontStyleMapSet )
284 {
285   if( fontStyleMapGet.Count() == fontStyleMapSet.Count() )
286   {
287     for( unsigned int index = 0u; index < fontStyleMapGet.Count(); ++index )
288     {
289       const KeyValuePair& valueGet = fontStyleMapGet.GetKeyValue( index );
290
291       Property::Value* valueSet = NULL;
292       if ( valueGet.first.type == Property::Key::INDEX )
293       {
294         valueSet = fontStyleMapSet.Find( valueGet.first.indexKey );
295       }
296       else
297       {
298         // Get Key is a string so searching Set Map for a string key
299         valueSet = fontStyleMapSet.Find( valueGet.first.stringKey );
300       }
301
302       if( NULL != valueSet )
303       {
304         if( valueSet->GetType() == Dali::Property::STRING && ( valueGet.second.Get<std::string>() != valueSet->Get<std::string>() ) )
305         {
306           tet_printf( "Value got : [%s], expected : [%s]", valueGet.second.Get<std::string>().c_str(), valueSet->Get<std::string>().c_str() );
307           return false;
308         }
309         else if( valueSet->GetType() == Dali::Property::BOOLEAN && ( valueGet.second.Get<bool>() != valueSet->Get<bool>() ) )
310         {
311           tet_printf( "Value got : [%d], expected : [%d]", valueGet.second.Get<bool>(), valueSet->Get<bool>() );
312           return false;
313         }
314         else if( valueSet->GetType() == Dali::Property::INTEGER && ( valueGet.second.Get<int>() != valueSet->Get<int>() ) )
315         {
316           tet_printf( "Value got : [%d], expected : [%d]", valueGet.second.Get<int>(), valueSet->Get<int>() );
317           return false;
318         }
319         else if( valueSet->GetType() == Dali::Property::FLOAT && ( valueGet.second.Get<float>() != valueSet->Get<float>() ) )
320         {
321           tet_printf( "Value got : [%f], expected : [%f]", valueGet.second.Get<float>(), valueSet->Get<float>() );
322           return false;
323         }
324         else if( valueSet->GetType() == Dali::Property::VECTOR2 && ( valueGet.second.Get<Vector2>() != valueSet->Get<Vector2>() ) )
325         {
326           Vector2 vector2Get = valueGet.second.Get<Vector2>();
327           Vector2 vector2Set = valueSet->Get<Vector2>();
328           tet_printf( "Value got : [%f, %f], expected : [%f, %f]", vector2Get.x, vector2Get.y, vector2Set.x, vector2Set.y );
329           return false;
330         }
331         else if( valueSet->GetType() == Dali::Property::VECTOR4 && ( valueGet.second.Get<Vector4>() != valueSet->Get<Vector4>() ) )
332         {
333           Vector4 vector4Get = valueGet.second.Get<Vector4>();
334           Vector4 vector4Set = valueSet->Get<Vector4>();
335           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 );
336           return false;
337         }
338       }
339       else
340       {
341         if ( valueGet.first.type == Property::Key::INDEX )
342         {
343           tet_printf( "  The key %d doesn't exist.", valueGet.first.indexKey );
344         }
345         else
346         {
347           tet_printf( "  The key %s doesn't exist.", valueGet.first.stringKey.c_str() );
348         }
349         return false;
350       }
351     }
352   }
353
354   return true;
355 }
356
357 class ScrollStateChangeCallback : public Dali::ConnectionTracker
358 {
359 public:
360   ScrollStateChangeCallback(bool& startedCalled, bool& finishedCalled)
361   : mStartedCalled( startedCalled ),
362     mFinishedCalled( finishedCalled )
363   {
364   }
365
366   void Callback( TextEditor editor, TextEditor::Scroll::Type type )
367   {
368     if( type == TextEditor::Scroll::STARTED )
369     {
370       mStartedCalled = true;
371     }
372     else if( type == TextEditor::Scroll::FINISHED )
373     {
374       mFinishedCalled = true;
375     }
376   }
377
378   bool& mStartedCalled;
379   bool& mFinishedCalled;
380 };
381
382 } // namespace
383
384 int UtcDaliToolkitTextEditorConstructorP(void)
385 {
386   ToolkitTestApplication application;
387   tet_infoline(" UtcDaliToolkitTextEditorConstructorP");
388   TextEditor textEditor;
389   DALI_TEST_CHECK( !textEditor );
390   END_TEST;
391 }
392
393 int UtcDaliToolkitTextEditorNewP(void)
394 {
395   ToolkitTestApplication application;
396   tet_infoline(" UtcDaliToolkitTextEditorNewP");
397   TextEditor textEditor = TextEditor::New();
398   DALI_TEST_CHECK( textEditor );
399   END_TEST;
400 }
401
402 int UtcDaliToolkitTextEditorDownCastP(void)
403 {
404   ToolkitTestApplication application;
405   tet_infoline(" UtcDaliToolkitTextEditorDownCastP");
406   TextEditor textEditor1 = TextEditor::New();
407   BaseHandle object( textEditor1 );
408
409   TextEditor textEditor2 = TextEditor::DownCast( object );
410   DALI_TEST_CHECK( textEditor2 );
411
412   TextEditor textEditor3 = DownCast< TextEditor >( object );
413   DALI_TEST_CHECK( textEditor3 );
414   END_TEST;
415 }
416
417 int UtcDaliToolkitTextEditorDownCastN(void)
418 {
419   ToolkitTestApplication application;
420   tet_infoline(" UtcDaliToolkitTextEditorDownCastN");
421   BaseHandle uninitializedObject;
422   TextEditor textEditor1 = TextEditor::DownCast( uninitializedObject );
423   DALI_TEST_CHECK( !textEditor1 );
424
425   TextEditor textEditor2 = DownCast< TextEditor >( uninitializedObject );
426   DALI_TEST_CHECK( !textEditor2 );
427   END_TEST;
428 }
429
430 int UtcDaliToolkitTextEditorCopyConstructorP(void)
431 {
432   ToolkitTestApplication application;
433   tet_infoline(" UtcDaliToolkitTextEditorCopyConstructorP");
434   TextEditor textEditor = TextEditor::New();
435   textEditor.SetProperty( TextEditor::Property::TEXT, "Test" );
436
437   TextEditor copy( textEditor );
438   DALI_TEST_CHECK( copy );
439   DALI_TEST_CHECK( copy.GetProperty<std::string>( TextEditor::Property::TEXT ) == textEditor.GetProperty<std::string>( TextEditor::Property::TEXT ) );
440   END_TEST;
441 }
442
443 int UtcDaliTextEditorMoveConstructor(void)
444 {
445   ToolkitTestApplication application;
446
447   TextEditor textEditor = TextEditor::New();
448   textEditor.SetProperty( TextEditor::Property::TEXT, "Test" );
449   DALI_TEST_CHECK( textEditor.GetProperty<std::string>( TextEditor::Property::TEXT ) == "Test" );
450
451   TextEditor moved = std::move( textEditor );
452   DALI_TEST_CHECK( moved );
453   DALI_TEST_EQUALS( 1, moved.GetBaseObject().ReferenceCount(), TEST_LOCATION );
454   DALI_TEST_CHECK( moved.GetProperty<std::string>( TextEditor::Property::TEXT ) == "Test" );
455   DALI_TEST_CHECK( !textEditor );
456
457   END_TEST;
458 }
459
460 int UtcDaliToolkitTextEditorAssignmentOperatorP(void)
461 {
462   ToolkitTestApplication application;
463   tet_infoline(" UtcDaliToolkitTextEditorAssignmentOperatorP");
464   TextEditor textEditor = TextEditor::New();
465   textEditor.SetProperty( TextEditor::Property::TEXT, "Test" );
466
467   TextEditor copy = textEditor;
468   DALI_TEST_CHECK( copy );
469   DALI_TEST_CHECK( copy.GetProperty<std::string>( TextEditor::Property::TEXT ) == textEditor.GetProperty<std::string>( TextEditor::Property::TEXT ) );
470   END_TEST;
471 }
472
473 int UtcDaliTextEditorMoveAssignment(void)
474 {
475   ToolkitTestApplication application;
476
477   TextEditor textEditor = TextEditor::New();
478   textEditor.SetProperty( TextEditor::Property::TEXT, "Test" );
479   DALI_TEST_CHECK( textEditor.GetProperty<std::string>( TextEditor::Property::TEXT ) == "Test" );
480
481   TextEditor moved;
482   moved = std::move( textEditor );
483   DALI_TEST_CHECK( moved );
484   DALI_TEST_EQUALS( 1, moved.GetBaseObject().ReferenceCount(), TEST_LOCATION );
485   DALI_TEST_CHECK( moved.GetProperty<std::string>( TextEditor::Property::TEXT ) == "Test" );
486   DALI_TEST_CHECK( !textEditor );
487
488   END_TEST;
489 }
490
491 int UtcDaliTextEditorNewP(void)
492 {
493   ToolkitTestApplication application;
494   tet_infoline(" UtcDaliToolkitTextEditorNewP");
495   TextEditor textEditor = TextEditor::New();
496   DALI_TEST_CHECK( textEditor );
497   END_TEST;
498 }
499
500 // Positive test case for a method
501 int UtcDaliTextEditorGetPropertyP(void)
502 {
503   ToolkitTestApplication application;
504   tet_infoline(" UtcDaliToolkitTextEditorGetPropertyP");
505   TextEditor editor = TextEditor::New();
506   DALI_TEST_CHECK( editor );
507
508   // Check Property Indices are correct
509   DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_RENDERING_BACKEND ) == DevelTextEditor::Property::RENDERING_BACKEND );
510   DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_TEXT ) == TextEditor::Property::TEXT );
511   DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_TEXT_COLOR ) == TextEditor::Property::TEXT_COLOR );
512   DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_FONT_FAMILY ) == TextEditor::Property::FONT_FAMILY );
513   DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_FONT_STYLE ) == TextEditor::Property::FONT_STYLE );
514   DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_POINT_SIZE ) == TextEditor::Property::POINT_SIZE );
515   DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_HORIZONTAL_ALIGNMENT ) == TextEditor::Property::HORIZONTAL_ALIGNMENT );
516   DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_SCROLL_THRESHOLD ) == TextEditor::Property::SCROLL_THRESHOLD );
517   DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_SCROLL_SPEED ) == TextEditor::Property::SCROLL_SPEED );
518   DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_PRIMARY_CURSOR_COLOR ) == TextEditor::Property::PRIMARY_CURSOR_COLOR );
519   DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_SECONDARY_CURSOR_COLOR ) == TextEditor::Property::SECONDARY_CURSOR_COLOR );
520   DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_ENABLE_CURSOR_BLINK ) == TextEditor::Property::ENABLE_CURSOR_BLINK );
521   DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_CURSOR_BLINK_INTERVAL ) == TextEditor::Property::CURSOR_BLINK_INTERVAL );
522   DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_CURSOR_BLINK_DURATION ) == TextEditor::Property::CURSOR_BLINK_DURATION );
523   DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_CURSOR_WIDTH ) == TextEditor::Property::CURSOR_WIDTH );
524   DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_GRAB_HANDLE_IMAGE ) == TextEditor::Property::GRAB_HANDLE_IMAGE );
525   DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_GRAB_HANDLE_PRESSED_IMAGE ) == TextEditor::Property::GRAB_HANDLE_PRESSED_IMAGE );
526   DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_SELECTION_HANDLE_IMAGE_LEFT ) == TextEditor::Property::SELECTION_HANDLE_IMAGE_LEFT );
527   DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_SELECTION_HANDLE_IMAGE_RIGHT ) == TextEditor::Property::SELECTION_HANDLE_IMAGE_RIGHT );
528   DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_SELECTION_HANDLE_PRESSED_IMAGE_LEFT ) == TextEditor::Property::SELECTION_HANDLE_PRESSED_IMAGE_LEFT );
529   DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_SELECTION_HANDLE_PRESSED_IMAGE_RIGHT ) == TextEditor::Property::SELECTION_HANDLE_PRESSED_IMAGE_RIGHT );
530   DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_SELECTION_HANDLE_MARKER_IMAGE_LEFT ) == TextEditor::Property::SELECTION_HANDLE_MARKER_IMAGE_LEFT );
531   DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_SELECTION_HANDLE_MARKER_IMAGE_RIGHT ) == TextEditor::Property::SELECTION_HANDLE_MARKER_IMAGE_RIGHT );
532   DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_SELECTION_HIGHLIGHT_COLOR ) == TextEditor::Property::SELECTION_HIGHLIGHT_COLOR );
533   DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_DECORATION_BOUNDING_BOX ) == TextEditor::Property::DECORATION_BOUNDING_BOX );
534   DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_ENABLE_MARKUP ) == TextEditor::Property::ENABLE_MARKUP );
535   DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_INPUT_COLOR ) == TextEditor::Property::INPUT_COLOR );
536   DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_INPUT_FONT_FAMILY ) == TextEditor::Property::INPUT_FONT_FAMILY );
537   DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_INPUT_FONT_STYLE ) == TextEditor::Property::INPUT_FONT_STYLE );
538   DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_INPUT_POINT_SIZE ) == TextEditor::Property::INPUT_POINT_SIZE );
539
540   DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_LINE_SPACING ) == TextEditor::Property::LINE_SPACING );
541   DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_INPUT_LINE_SPACING ) == TextEditor::Property::INPUT_LINE_SPACING );
542   DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_UNDERLINE ) == TextEditor::Property::UNDERLINE );
543   DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_INPUT_UNDERLINE ) == TextEditor::Property::INPUT_UNDERLINE );
544   DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_SHADOW ) == TextEditor::Property::SHADOW );
545   DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_INPUT_SHADOW ) == TextEditor::Property::INPUT_SHADOW );
546   DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_EMBOSS ) == TextEditor::Property::EMBOSS );
547   DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_INPUT_EMBOSS ) == TextEditor::Property::INPUT_EMBOSS );
548   DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_OUTLINE ) == TextEditor::Property::OUTLINE );
549   DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_INPUT_OUTLINE ) == TextEditor::Property::INPUT_OUTLINE );
550   DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_STRIKETHROUGH ) == DevelTextEditor::Property::STRIKETHROUGH );
551   DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_INPUT_STRIKETHROUGH ) == DevelTextEditor::Property::INPUT_STRIKETHROUGH );
552   DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_SMOOTH_SCROLL ) == TextEditor::Property::SMOOTH_SCROLL );
553   DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_SMOOTH_SCROLL_DURATION ) == TextEditor::Property::SMOOTH_SCROLL_DURATION );
554   DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_ENABLE_SCROLL_BAR ) == TextEditor::Property::ENABLE_SCROLL_BAR );
555   DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_SCROLL_BAR_SHOW_DURATION ) == TextEditor::Property::SCROLL_BAR_SHOW_DURATION );
556   DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_SCROLL_BAR_FADE_DURATION ) == TextEditor::Property::SCROLL_BAR_FADE_DURATION );
557   DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_PIXEL_SIZE ) == TextEditor::Property::PIXEL_SIZE );
558   DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_LINE_COUNT) == TextEditor::Property::LINE_COUNT );
559   DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_ENABLE_SELECTION ) == TextEditor::Property::ENABLE_SELECTION );
560   DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_PLACEHOLDER ) == TextEditor::Property::PLACEHOLDER );
561   DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_FONT_SIZE_SCALE ) == DevelTextEditor::Property::FONT_SIZE_SCALE );
562   DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_ENABLE_FONT_SIZE_SCALE ) == DevelTextEditor::Property::ENABLE_FONT_SIZE_SCALE );
563   DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_PLACEHOLDER_TEXT ) == DevelTextEditor::Property::PLACEHOLDER_TEXT );
564   DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_PLACEHOLDER_TEXT_COLOR ) == DevelTextEditor::Property::PLACEHOLDER_TEXT_COLOR );
565   DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_ENABLE_SHIFT_SELECTION ) == DevelTextEditor::Property::ENABLE_SHIFT_SELECTION );
566   DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_ENABLE_GRAB_HANDLE ) == DevelTextEditor::Property::ENABLE_GRAB_HANDLE );
567   DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_MATCH_SYSTEM_LANGUAGE_DIRECTION ) == DevelTextEditor::Property::MATCH_SYSTEM_LANGUAGE_DIRECTION );
568   DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_MAX_LENGTH ) == DevelTextEditor::Property::MAX_LENGTH );
569   DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_GRAB_HANDLE_COLOR ) == DevelTextEditor::Property::GRAB_HANDLE_COLOR );
570   DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_ENABLE_GRAB_HANDLE_POPUP ) == DevelTextEditor::Property::ENABLE_GRAB_HANDLE_POPUP );
571   DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_INPUT_METHOD_SETTINGS ) == DevelTextEditor::Property::INPUT_METHOD_SETTINGS );
572   DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_INPUT_FILTER ) == DevelTextEditor::Property::INPUT_FILTER );
573   DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_STRIKETHROUGH ) == DevelTextEditor::Property::STRIKETHROUGH );
574   DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_INPUT_STRIKETHROUGH ) == DevelTextEditor::Property::INPUT_STRIKETHROUGH );
575
576   END_TEST;
577 }
578
579 bool SetPropertyMapRetrieved( TextEditor& editor, const Property::Index property, const std::string mapKey, const std::string mapValue )
580 {
581   bool result = false;
582   Property::Map imageMap;
583   imageMap[mapKey] =mapValue;
584
585   editor.SetProperty( property , imageMap );
586   Property::Value propValue = editor.GetProperty( property );
587   Property::Map* resultMap = propValue.GetMap();
588
589   if ( resultMap->Find( mapKey )->Get< std::string>() == mapValue )
590   {
591     result = true;
592   }
593
594   return result;
595 }
596
597 // Positive test case for a method
598 int UtcDaliTextEditorSetPropertyP(void)
599 {
600   ToolkitTestApplication application;
601   tet_infoline(" UtcDaliToolkitTextEditorSetPropertyP");
602   TextEditor editor = TextEditor::New();
603   DALI_TEST_CHECK( editor );
604   application.GetScene().Add( editor );
605
606   // Note - we can't check the defaults since the stylesheets are platform-specific
607
608   // Check the render backend property.
609   editor.SetProperty( DevelTextEditor::Property::RENDERING_BACKEND, DevelText::RENDERING_SHARED_ATLAS );
610   DALI_TEST_EQUALS( (DevelText::RenderingType)editor.GetProperty<int>( DevelTextEditor::Property::RENDERING_BACKEND ), DevelText::RENDERING_SHARED_ATLAS, TEST_LOCATION );
611
612   // Check text property.
613   editor.SetProperty( TextEditor::Property::TEXT, "Setting Text" );
614   DALI_TEST_EQUALS( editor.GetProperty<std::string>( TextEditor::Property::TEXT ), std::string("Setting Text"), TEST_LOCATION );
615
616   // Check text's color property
617   editor.SetProperty( TextEditor::Property::TEXT_COLOR, Color::WHITE );
618   DALI_TEST_EQUALS( editor.GetProperty<Vector4>( TextEditor::Property::TEXT_COLOR ), Color::WHITE, TEST_LOCATION );
619
620   // Check font properties.
621   editor.SetProperty( TextEditor::Property::FONT_FAMILY, "Setting font family" );
622   DALI_TEST_EQUALS( editor.GetProperty<std::string>( TextEditor::Property::FONT_FAMILY ), std::string("Setting font family"), TEST_LOCATION );
623
624   Property::Map fontStyleMapSet;
625   Property::Map fontStyleMapGet;
626   Property::Value* slantValue = NULL;
627
628   fontStyleMapSet.Insert( "weight", "bold" );
629   fontStyleMapSet.Insert( "width", "condensed" );
630   fontStyleMapSet.Insert( "slant", "italic" );
631
632   editor.SetProperty( TextEditor::Property::FONT_STYLE, fontStyleMapSet );
633   fontStyleMapGet = editor.GetProperty<Property::Map>( TextEditor::Property::FONT_STYLE );
634   DALI_TEST_EQUALS( fontStyleMapGet.Count(), fontStyleMapSet.Count(), TEST_LOCATION );
635   DALI_TEST_EQUALS( DaliTestCheckMaps( fontStyleMapGet, fontStyleMapSet ), true, TEST_LOCATION );
636
637   editor.SetProperty( TextEditor::Property::POINT_SIZE, 10.f );
638   DALI_TEST_EQUALS( editor.GetProperty<float>( TextEditor::Property::POINT_SIZE ), 10.f, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
639
640   editor.SetProperty( DevelTextEditor::Property::FONT_SIZE_SCALE, 2.5f );
641   DALI_TEST_EQUALS( editor.GetProperty<float>( DevelTextEditor::Property::FONT_SIZE_SCALE ), 2.5f, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
642   editor.SetProperty( DevelTextEditor::Property::FONT_SIZE_SCALE, 1.0f );
643
644   editor.SetProperty( DevelTextEditor::Property::ENABLE_FONT_SIZE_SCALE, false );
645   DALI_TEST_EQUALS( editor.GetProperty<bool>( DevelTextEditor::Property::ENABLE_FONT_SIZE_SCALE ), false, TEST_LOCATION );
646   editor.SetProperty( DevelTextEditor::Property::ENABLE_FONT_SIZE_SCALE, true );
647
648   // Reset font style.
649   fontStyleMapSet.Clear();
650   fontStyleMapSet.Insert( "weight", "normal" );
651   fontStyleMapSet.Insert( "slant", "oblique" );
652   editor.SetProperty( TextEditor::Property::FONT_STYLE, fontStyleMapSet );
653   fontStyleMapGet = editor.GetProperty<Property::Map>( TextEditor::Property::FONT_STYLE );
654   DALI_TEST_EQUALS( fontStyleMapGet.Count(), fontStyleMapSet.Count(), TEST_LOCATION );
655   DALI_TEST_EQUALS( DaliTestCheckMaps( fontStyleMapGet, fontStyleMapSet ), true, TEST_LOCATION );
656
657   fontStyleMapSet.Clear();
658   fontStyleMapSet.Insert( "slant", "roman" );
659   editor.SetProperty( TextEditor::Property::FONT_STYLE, fontStyleMapSet );
660   fontStyleMapGet = editor.GetProperty<Property::Map>( TextEditor::Property::FONT_STYLE );
661
662   // Replace 'roman' for 'normal'.
663   slantValue = fontStyleMapGet.Find( "slant" );
664   if( NULL != slantValue )
665   {
666     if( "normal" == slantValue->Get<std::string>() )
667     {
668       fontStyleMapGet["slant"] = "roman";
669     }
670   }
671   DALI_TEST_EQUALS( fontStyleMapGet.Count(), fontStyleMapSet.Count(), TEST_LOCATION );
672   DALI_TEST_EQUALS( DaliTestCheckMaps( fontStyleMapGet, fontStyleMapSet ), true, TEST_LOCATION );
673
674   fontStyleMapSet.Clear();
675
676   editor.SetProperty( TextEditor::Property::FONT_STYLE, fontStyleMapSet );
677   fontStyleMapGet = editor.GetProperty<Property::Map>( TextEditor::Property::FONT_STYLE );
678   DALI_TEST_EQUALS( fontStyleMapGet.Count(), fontStyleMapSet.Count(), TEST_LOCATION );
679   DALI_TEST_EQUALS( DaliTestCheckMaps( fontStyleMapGet, fontStyleMapSet ), true, TEST_LOCATION );
680
681   // Check that the Alignment properties can be correctly set
682   editor.SetProperty( TextEditor::Property::HORIZONTAL_ALIGNMENT, "END" );
683   DALI_TEST_EQUALS( editor.GetProperty<std::string>( TextEditor::Property::HORIZONTAL_ALIGNMENT ), "END", TEST_LOCATION );
684
685   // Check scroll properties.
686   editor.SetProperty( TextEditor::Property::SCROLL_THRESHOLD, 1.f );
687   DALI_TEST_EQUALS( editor.GetProperty<float>( TextEditor::Property::SCROLL_THRESHOLD ), 1.f, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
688   editor.SetProperty( TextEditor::Property::SCROLL_SPEED, 100.f );
689   DALI_TEST_EQUALS( editor.GetProperty<float>( TextEditor::Property::SCROLL_SPEED ), 100.f, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
690
691   // Check cursor properties
692   editor.SetProperty( TextEditor::Property::PRIMARY_CURSOR_COLOR, Color::RED );
693   DALI_TEST_EQUALS( editor.GetProperty<Vector4>( TextEditor::Property::PRIMARY_CURSOR_COLOR ), Color::RED, TEST_LOCATION );
694   editor.SetProperty( TextEditor::Property::SECONDARY_CURSOR_COLOR, Color::BLUE );
695   DALI_TEST_EQUALS( editor.GetProperty<Vector4>( TextEditor::Property::SECONDARY_CURSOR_COLOR ), Color::BLUE, TEST_LOCATION );
696
697   editor.SetProperty( TextEditor::Property::ENABLE_CURSOR_BLINK, false );
698   DALI_TEST_EQUALS( editor.GetProperty<bool>( TextEditor::Property::ENABLE_CURSOR_BLINK ), false, TEST_LOCATION );
699   editor.SetProperty( TextEditor::Property::CURSOR_BLINK_INTERVAL, 1.f );
700   DALI_TEST_EQUALS( editor.GetProperty<float>( TextEditor::Property::CURSOR_BLINK_INTERVAL ), 1.f, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
701   editor.SetProperty( TextEditor::Property::CURSOR_BLINK_DURATION, 10.f );
702   DALI_TEST_EQUALS( editor.GetProperty<float>( TextEditor::Property::CURSOR_BLINK_DURATION ), 10.f, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
703   editor.SetProperty( TextEditor::Property::CURSOR_WIDTH, 1 );
704   DALI_TEST_EQUALS( editor.GetProperty<int>( TextEditor::Property::CURSOR_WIDTH ), 1, TEST_LOCATION );
705
706   // Check handle images
707   editor.SetProperty( TextEditor::Property::GRAB_HANDLE_IMAGE, "image1" );
708   DALI_TEST_EQUALS( editor.GetProperty<std::string>( TextEditor::Property::GRAB_HANDLE_IMAGE ), "image1", TEST_LOCATION );
709   editor.SetProperty( TextEditor::Property::GRAB_HANDLE_PRESSED_IMAGE, "image2" );
710   DALI_TEST_EQUALS( editor.GetProperty<std::string>( TextEditor::Property::GRAB_HANDLE_PRESSED_IMAGE ), "image2", TEST_LOCATION );
711   editor.SetProperty( TextEditor::Property::SELECTION_HANDLE_IMAGE_LEFT, "image3" );
712
713   // Check handle images
714   DALI_TEST_CHECK( SetPropertyMapRetrieved( editor, TextEditor::Property::SELECTION_HANDLE_IMAGE_LEFT, "filename", "leftHandleImage" )  );
715   DALI_TEST_CHECK( SetPropertyMapRetrieved( editor, TextEditor::Property::SELECTION_HANDLE_IMAGE_RIGHT, "filename", "rightHandleImage" )  );
716   DALI_TEST_CHECK( SetPropertyMapRetrieved( editor, TextEditor::Property::SELECTION_HANDLE_PRESSED_IMAGE_LEFT, "filename", "leftHandleImagePressed" )  );
717   DALI_TEST_CHECK( SetPropertyMapRetrieved( editor, TextEditor::Property::SELECTION_HANDLE_PRESSED_IMAGE_RIGHT, "filename", "rightHandleImagePressed" )  );
718   DALI_TEST_CHECK( SetPropertyMapRetrieved( editor, TextEditor::Property::SELECTION_HANDLE_MARKER_IMAGE_LEFT, "filename", "leftHandleMarkerImage" )  );
719   DALI_TEST_CHECK( SetPropertyMapRetrieved( editor, TextEditor::Property::SELECTION_HANDLE_MARKER_IMAGE_RIGHT, "filename", "rightHandleMarkerImage" )  );
720
721   // Check the highlight color
722   editor.SetProperty( TextEditor::Property::SELECTION_HIGHLIGHT_COLOR, Color::GREEN );
723   DALI_TEST_EQUALS( editor.GetProperty<Vector4>( TextEditor::Property::SELECTION_HIGHLIGHT_COLOR ), Color::GREEN, TEST_LOCATION );
724
725   // Decoration bounding box
726   editor.SetProperty( TextEditor::Property::DECORATION_BOUNDING_BOX, Rect<int>( 0, 0, 1, 1 ) );
727   DALI_TEST_EQUALS( editor.GetProperty<Rect <int > >( TextEditor::Property::DECORATION_BOUNDING_BOX ), Rect<int>( 0, 0, 1, 1 ), TEST_LOCATION );
728
729   // Check the enable markup property.
730   DALI_TEST_CHECK( !editor.GetProperty<bool>( TextEditor::Property::ENABLE_MARKUP ) );
731   editor.SetProperty( TextEditor::Property::ENABLE_MARKUP, true );
732   DALI_TEST_CHECK( editor.GetProperty<bool>( TextEditor::Property::ENABLE_MARKUP ) );
733
734   // Check input color property.
735   editor.SetProperty( TextEditor::Property::INPUT_COLOR, Color::YELLOW );
736   DALI_TEST_EQUALS( editor.GetProperty<Vector4>( TextEditor::Property::INPUT_COLOR ), Color::YELLOW, TEST_LOCATION );
737
738   // Check input font properties.
739   editor.SetProperty( TextEditor::Property::INPUT_FONT_FAMILY, "Setting input font family" );
740   DALI_TEST_EQUALS( editor.GetProperty<std::string>( TextEditor::Property::INPUT_FONT_FAMILY ), "Setting input font family", TEST_LOCATION );
741
742   fontStyleMapSet.Clear();
743   fontStyleMapSet.Insert( "weight", "bold" );
744   fontStyleMapSet.Insert( "width", "condensed" );
745   fontStyleMapSet.Insert( "slant", "italic" );
746
747   editor.SetProperty( TextEditor::Property::INPUT_FONT_STYLE, fontStyleMapSet );
748   fontStyleMapGet = editor.GetProperty<Property::Map>( TextEditor::Property::INPUT_FONT_STYLE );
749   DALI_TEST_EQUALS( fontStyleMapGet.Count(), fontStyleMapSet.Count(), TEST_LOCATION );
750   DALI_TEST_EQUALS( DaliTestCheckMaps( fontStyleMapGet, fontStyleMapSet ), true, TEST_LOCATION );
751
752   editor.SetProperty( TextEditor::Property::INPUT_POINT_SIZE, 12.f );
753   DALI_TEST_EQUALS( editor.GetProperty<float>( TextEditor::Property::INPUT_POINT_SIZE ), 12.f, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
754
755   // Reset input font style.
756   fontStyleMapSet.Clear();
757   fontStyleMapSet.Insert( "weight", "normal" );
758   fontStyleMapSet.Insert( "slant", "oblique" );
759
760   editor.SetProperty( TextEditor::Property::INPUT_FONT_STYLE, fontStyleMapSet );
761   fontStyleMapGet = editor.GetProperty<Property::Map>( TextEditor::Property::INPUT_FONT_STYLE );
762   DALI_TEST_EQUALS( fontStyleMapGet.Count(), fontStyleMapSet.Count(), TEST_LOCATION );
763   DALI_TEST_EQUALS( DaliTestCheckMaps( fontStyleMapGet, fontStyleMapSet ), true, TEST_LOCATION );
764
765   fontStyleMapSet.Clear();
766   fontStyleMapSet.Insert( "slant", "roman" );
767
768   editor.SetProperty( TextEditor::Property::INPUT_FONT_STYLE, fontStyleMapSet );
769   fontStyleMapGet = editor.GetProperty<Property::Map>( TextEditor::Property::INPUT_FONT_STYLE );
770
771   // Replace 'roman' for 'normal'.
772   slantValue = fontStyleMapGet.Find( "slant" );
773   if( NULL != slantValue )
774   {
775     if( "normal" == slantValue->Get<std::string>() )
776     {
777       fontStyleMapGet["slant"] = "roman";
778     }
779   }
780   DALI_TEST_EQUALS( fontStyleMapGet.Count(), fontStyleMapSet.Count(), TEST_LOCATION );
781   DALI_TEST_EQUALS( DaliTestCheckMaps( fontStyleMapGet, fontStyleMapSet ), true, TEST_LOCATION );
782
783   fontStyleMapSet.Clear();
784
785   editor.SetProperty( TextEditor::Property::INPUT_FONT_STYLE, fontStyleMapSet );
786   fontStyleMapGet = editor.GetProperty<Property::Map>( TextEditor::Property::INPUT_FONT_STYLE );
787   DALI_TEST_EQUALS( fontStyleMapGet.Count(), fontStyleMapSet.Count(), TEST_LOCATION );
788   DALI_TEST_EQUALS( DaliTestCheckMaps( fontStyleMapGet, fontStyleMapSet ), true, TEST_LOCATION );
789
790   // Check the line spacing property
791   DALI_TEST_EQUALS( editor.GetProperty<float>( TextEditor::Property::LINE_SPACING ), 0.0f, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
792   editor.SetProperty( TextEditor::Property::LINE_SPACING, 10.f );
793   DALI_TEST_EQUALS( editor.GetProperty<float>( TextEditor::Property::LINE_SPACING ), 10.0f, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
794
795   // Check the input line spacing property
796   DALI_TEST_EQUALS( editor.GetProperty<float>( TextEditor::Property::INPUT_LINE_SPACING ), 0.0f, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
797   editor.SetProperty( TextEditor::Property::INPUT_LINE_SPACING, 20.f );
798   DALI_TEST_EQUALS( editor.GetProperty<float>( TextEditor::Property::INPUT_LINE_SPACING ), 20.0f, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
799
800   // Check the underline property
801
802   Property::Map underlineMapSet;
803   Property::Map underlineMapGet;
804
805   underlineMapSet.Insert( "enable", true );
806   underlineMapSet.Insert( "color", Color::RED );
807   underlineMapSet.Insert( "height", 1 );
808
809   editor.SetProperty( TextEditor::Property::UNDERLINE, underlineMapSet );
810
811   underlineMapGet = editor.GetProperty<Property::Map>( TextEditor::Property::UNDERLINE );
812   DALI_TEST_EQUALS( underlineMapGet.Count(), underlineMapSet.Count(), TEST_LOCATION );
813   DALI_TEST_EQUALS( DaliTestCheckMaps( underlineMapGet, underlineMapSet ), true, TEST_LOCATION );
814
815   // Check the input underline property
816   editor.SetProperty( TextEditor::Property::INPUT_UNDERLINE, "Underline input properties" );
817   DALI_TEST_EQUALS( editor.GetProperty<std::string>( TextEditor::Property::INPUT_UNDERLINE ), std::string("Underline input properties"), TEST_LOCATION );
818
819   // Check the shadow property
820   Property::Map shadowMapSet;
821   Property::Map shadowMapGet;
822
823   shadowMapSet.Insert( "color", Color::GREEN );
824   shadowMapSet.Insert( "offset", Vector2(2.0f, 2.0f) );
825   shadowMapSet.Insert( "blurRadius", 3.0f );
826
827   editor.SetProperty( TextEditor::Property::SHADOW, shadowMapSet );
828
829   shadowMapGet = editor.GetProperty<Property::Map>( TextEditor::Property::SHADOW );
830   DALI_TEST_EQUALS( shadowMapGet.Count(), shadowMapSet.Count(), TEST_LOCATION );
831   DALI_TEST_EQUALS( DaliTestCheckMaps( shadowMapGet, shadowMapSet ), true, TEST_LOCATION );
832
833   // Check the input shadow property
834   editor.SetProperty( TextEditor::Property::INPUT_SHADOW, "Shadow input properties" );
835   DALI_TEST_EQUALS( editor.GetProperty<std::string>( TextEditor::Property::INPUT_SHADOW ), std::string("Shadow input properties"), TEST_LOCATION );
836
837   // Check the emboss property
838   editor.SetProperty( TextEditor::Property::EMBOSS, "Emboss properties" );
839   DALI_TEST_EQUALS( editor.GetProperty<std::string>( TextEditor::Property::EMBOSS ), std::string("Emboss properties"), TEST_LOCATION );
840
841   // Check the input emboss property
842   editor.SetProperty( TextEditor::Property::INPUT_EMBOSS, "Emboss input properties" );
843   DALI_TEST_EQUALS( editor.GetProperty<std::string>( TextEditor::Property::INPUT_EMBOSS ), std::string("Emboss input properties"), TEST_LOCATION );
844
845   // Check the outline property
846
847   // Test string type first
848   // This is purely to maintain backward compatibility, but we don't support string as the outline property type.
849   editor.SetProperty( TextEditor::Property::OUTLINE, "Outline properties" );
850   DALI_TEST_EQUALS( editor.GetProperty<std::string>( TextEditor::Property::OUTLINE ), std::string("Outline properties"), TEST_LOCATION );
851
852   // Then test the property map type
853   Property::Map outlineMapSet;
854   Property::Map outlineMapGet;
855
856   outlineMapSet["color"] = Color::RED;
857   outlineMapSet["width"] = 2.0f;
858
859   editor.SetProperty( TextEditor::Property::OUTLINE, outlineMapSet );
860
861   outlineMapGet = editor.GetProperty<Property::Map>( TextEditor::Property::OUTLINE );
862   DALI_TEST_EQUALS( outlineMapGet.Count(), outlineMapSet.Count(), TEST_LOCATION );
863   DALI_TEST_EQUALS( DaliTestCheckMaps( outlineMapGet, outlineMapSet ), true, TEST_LOCATION );
864
865   // Check the input outline property
866   editor.SetProperty( TextEditor::Property::INPUT_OUTLINE, "Outline input properties" );
867   DALI_TEST_EQUALS( editor.GetProperty<std::string>( TextEditor::Property::INPUT_OUTLINE ), std::string("Outline input properties"), TEST_LOCATION );
868
869   // Check the smooth scroll property
870   DALI_TEST_EQUALS( editor.GetProperty<bool>( TextEditor::Property::SMOOTH_SCROLL ), false, TEST_LOCATION );
871   editor.SetProperty( TextEditor::Property::SMOOTH_SCROLL, true );
872   DALI_TEST_EQUALS( editor.GetProperty<bool>( TextEditor::Property::SMOOTH_SCROLL ), true, TEST_LOCATION );
873
874   // Check the smooth scroll duration property
875   editor.SetProperty( TextEditor::Property::SMOOTH_SCROLL_DURATION, 0.2f );
876   DALI_TEST_EQUALS( editor.GetProperty<float>( TextEditor::Property::SMOOTH_SCROLL_DURATION ), 0.2f, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
877
878   // Check the scroll bar property
879   DALI_TEST_EQUALS( editor.GetProperty<bool>( TextEditor::Property::ENABLE_SCROLL_BAR ), false, TEST_LOCATION );
880   editor.SetProperty( TextEditor::Property::ENABLE_SCROLL_BAR, true );
881   DALI_TEST_EQUALS( editor.GetProperty<bool>( TextEditor::Property::ENABLE_SCROLL_BAR ), true, TEST_LOCATION );
882
883   editor.SetProperty( TextEditor::Property::SCROLL_BAR_SHOW_DURATION, 0.3f );
884   DALI_TEST_EQUALS( editor.GetProperty<float>( TextEditor::Property::SCROLL_BAR_SHOW_DURATION ), 0.3f, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
885   editor.SetProperty( TextEditor::Property::SCROLL_BAR_FADE_DURATION, 0.2f );
886   DALI_TEST_EQUALS( editor.GetProperty<float>( TextEditor::Property::SCROLL_BAR_FADE_DURATION ), 0.2f, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
887
888   // Check the pixel size of font
889   editor.SetProperty( TextEditor::Property::PIXEL_SIZE, 20.f );
890   DALI_TEST_EQUALS( editor.GetProperty<float>( TextEditor::Property::PIXEL_SIZE ), 20.f, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
891
892   // Check placeholder text properties.
893   editor.SetProperty( DevelTextEditor::Property::PLACEHOLDER_TEXT, "Setting Placeholder Text" );
894   DALI_TEST_EQUALS( editor.GetProperty<std::string>( DevelTextEditor::Property::PLACEHOLDER_TEXT ), std::string("Setting Placeholder Text"), TEST_LOCATION );
895
896   // Check placeholder text's color property.
897   editor.SetProperty( DevelTextEditor::Property::PLACEHOLDER_TEXT_COLOR, Color::RED );
898   DALI_TEST_EQUALS( editor.GetProperty<Vector4>( DevelTextEditor::Property::PLACEHOLDER_TEXT_COLOR ), Color::RED, TEST_LOCATION );
899
900   // Check the enable selection property
901   editor.SetProperty( TextEditor::Property::ENABLE_SELECTION, false );
902   DALI_TEST_EQUALS( editor.GetProperty<bool>( TextEditor::Property::ENABLE_SELECTION ), false, TEST_LOCATION );
903
904   // Check the placeholder property with pixel size
905   Property::Map placeholderPixelSizeMapSet;
906   Property::Map placeholderPixelSizeMapGet;
907   Property::Map placeholderFontstyleMap;
908   placeholderPixelSizeMapSet["text"] = "Setting Placeholder Text";
909   placeholderPixelSizeMapSet["textFocused"] = "Setting Placeholder Text Focused";
910   placeholderPixelSizeMapSet["color"] = Color::BLUE;
911   placeholderPixelSizeMapSet["fontFamily"] = "Arial";
912   placeholderPixelSizeMapSet["pixelSize"] = 15.0f;
913
914   placeholderFontstyleMap.Insert( "weight", "bold" );
915   placeholderPixelSizeMapSet["fontStyle"] = placeholderFontstyleMap;
916   editor.SetProperty( TextEditor::Property::PLACEHOLDER, placeholderPixelSizeMapSet );
917
918   placeholderPixelSizeMapGet = editor.GetProperty<Property::Map>( TextEditor::Property::PLACEHOLDER );
919   DALI_TEST_EQUALS( placeholderPixelSizeMapGet.Count(), placeholderPixelSizeMapSet.Count(), TEST_LOCATION );
920
921   tet_infoline("Test Placeholder settings set as strings is converted correctly to Property Index key and holds set value");
922   Property::Map placeholderConversionMap;
923   placeholderConversionMap[ Text::PlaceHolder::Property::TEXT ] = placeholderPixelSizeMapSet["text"];
924   placeholderConversionMap[ Text::PlaceHolder::Property::TEXT_FOCUSED ] = placeholderPixelSizeMapSet["textFocused"] ;
925   placeholderConversionMap[ Text::PlaceHolder::Property::COLOR ] = placeholderPixelSizeMapSet["color"];
926   placeholderConversionMap[ Text::PlaceHolder::Property::FONT_STYLE ] = placeholderPixelSizeMapSet["fontStyle"];
927   placeholderConversionMap[ Text::PlaceHolder::Property::FONT_FAMILY ] = placeholderPixelSizeMapSet["fontFamily"];
928   placeholderConversionMap[ Text::PlaceHolder::Property::PIXEL_SIZE ] = placeholderPixelSizeMapSet["pixelSize"];
929
930   DALI_TEST_EQUALS( DaliTestCheckMaps( placeholderPixelSizeMapGet, placeholderConversionMap ), true, TEST_LOCATION );
931
932   // Check the placeholder property with point size
933   Property::Map placeholderMapSet;
934   Property::Map placeholderMapGet;
935   placeholderMapSet["text"] = "Setting Placeholder Text";
936   placeholderMapSet["textFocused"] = "Setting Placeholder Text Focused";
937   placeholderMapSet["color"] = Color::RED;
938   placeholderMapSet["fontFamily"] = "Arial";
939   placeholderMapSet["pointSize"] = 12.0f;
940   // Check the placeholder font style property
941   placeholderFontstyleMap.Clear();
942
943   placeholderFontstyleMap.Insert( "weight", "bold" );
944   placeholderFontstyleMap.Insert( "width", "condensed" );
945   placeholderFontstyleMap.Insert( "slant", "italic" );
946   placeholderMapSet["fontStyle"] = placeholderFontstyleMap;
947   editor.SetProperty( TextEditor::Property::PLACEHOLDER, placeholderMapSet );
948
949   placeholderMapGet = editor.GetProperty<Property::Map>( TextEditor::Property::PLACEHOLDER );
950   DALI_TEST_EQUALS( placeholderMapGet.Count(), placeholderMapSet.Count(), TEST_LOCATION );
951
952   tet_infoline("Test Placeholder settings set as strings is converted correctly to Property Index key and holds set value");
953   placeholderConversionMap.Clear();
954   placeholderConversionMap[ Text::PlaceHolder::Property::TEXT ] = placeholderMapSet["text"];
955   placeholderConversionMap[ Text::PlaceHolder::Property::TEXT_FOCUSED ] = placeholderMapSet["textFocused"] ;
956   placeholderConversionMap[ Text::PlaceHolder::Property::COLOR ] = placeholderMapSet["color"];
957   placeholderConversionMap[ Text::PlaceHolder::Property::FONT_STYLE ] = placeholderPixelSizeMapSet["fontStyle"];
958   placeholderConversionMap[ Text::PlaceHolder::Property::FONT_FAMILY ] = placeholderMapSet["fontFamily"];
959   placeholderConversionMap[ Text::PlaceHolder::Property::POINT_SIZE ] = placeholderMapSet["pointSize"];
960   DALI_TEST_EQUALS( DaliTestCheckMaps( placeholderMapGet, placeholderConversionMap ), true, TEST_LOCATION );
961
962   // Reset font style.
963   placeholderFontstyleMap.Clear();
964   placeholderFontstyleMap.Insert( "weight", "normal" );
965   placeholderFontstyleMap.Insert( "slant", "oblique" );
966   placeholderMapSet["fontStyle"] = placeholderFontstyleMap;
967   editor.SetProperty( TextEditor::Property::PLACEHOLDER, placeholderMapSet );
968
969   placeholderMapGet = editor.GetProperty<Property::Map>( TextEditor::Property::PLACEHOLDER );
970   DALI_TEST_EQUALS( placeholderMapGet.Count(), placeholderMapSet.Count(), TEST_LOCATION );
971   placeholderConversionMap[ Text::PlaceHolder::Property::FONT_STYLE ] = placeholderMapSet["fontStyle"];
972   DALI_TEST_EQUALS( DaliTestCheckMaps( placeholderMapGet, placeholderConversionMap ), true, TEST_LOCATION );
973
974   placeholderFontstyleMap.Clear();
975   placeholderFontstyleMap.Insert( "slant", "roman" );
976   placeholderMapSet["fontStyle"] = placeholderFontstyleMap;
977   editor.SetProperty( TextEditor::Property::PLACEHOLDER, placeholderMapSet );
978
979   placeholderMapGet = editor.GetProperty<Property::Map>( TextEditor::Property::PLACEHOLDER );
980
981   placeholderFontstyleMap.Clear();
982   placeholderMapSet["fontStyle"] = placeholderFontstyleMap;
983
984   editor.SetProperty( TextEditor::Property::PLACEHOLDER, placeholderMapSet );
985   placeholderMapGet = editor.GetProperty<Property::Map>( TextEditor::Property::PLACEHOLDER );
986   DALI_TEST_EQUALS( placeholderMapGet.Count(), placeholderMapSet.Count(), TEST_LOCATION );
987   placeholderConversionMap[ Text::PlaceHolder::Property::FONT_STYLE ] = placeholderMapSet["fontStyle"];
988   DALI_TEST_EQUALS( DaliTestCheckMaps( placeholderMapGet, placeholderConversionMap ), true, TEST_LOCATION );
989
990   editor.SetProperty( Actor::Property::LAYOUT_DIRECTION, LayoutDirection::RIGHT_TO_LEFT );
991   DALI_TEST_EQUALS( editor.GetProperty<int>( Actor::Property::LAYOUT_DIRECTION ), static_cast<int>( LayoutDirection::RIGHT_TO_LEFT ), TEST_LOCATION );
992
993   // Check handle color
994   editor.SetProperty( DevelTextEditor::Property::GRAB_HANDLE_COLOR, Color::GREEN );
995   DALI_TEST_EQUALS( editor.GetProperty<Vector4>( DevelTextEditor::Property::GRAB_HANDLE_COLOR ), Color::GREEN, TEST_LOCATION );
996
997   // Test the ENABLE_GRAB_HANDLE_POPUP property
998   editor.SetProperty( DevelTextEditor::Property::ENABLE_GRAB_HANDLE_POPUP, false );
999   DALI_TEST_EQUALS( editor.GetProperty<bool>( DevelTextEditor::Property::ENABLE_GRAB_HANDLE_POPUP ), false, TEST_LOCATION);
1000
1001   // Check the input method setting
1002   Property::Map propertyMap;
1003   InputMethod::PanelLayout::Type panelLayout = InputMethod::PanelLayout::NUMBER;
1004   InputMethod::AutoCapital::Type autoCapital = InputMethod::AutoCapital::WORD;
1005   InputMethod::ButtonAction::Type buttonAction = InputMethod::ButtonAction::GO;
1006   int inputVariation = 1;
1007   propertyMap["PANEL_LAYOUT"] = panelLayout;
1008   propertyMap["AUTO_CAPITALIZE"] = autoCapital;
1009   propertyMap["BUTTON_ACTION"] = buttonAction;
1010   propertyMap["VARIATION"] = inputVariation;
1011   editor.SetProperty( DevelTextEditor::Property::INPUT_METHOD_SETTINGS, propertyMap );
1012
1013   Property::Value value = editor.GetProperty( DevelTextEditor::Property::INPUT_METHOD_SETTINGS );
1014   Property::Map map;
1015   DALI_TEST_CHECK( value.Get( map ) );
1016
1017   int layout = 0;
1018   DALI_TEST_CHECK( map[ "PANEL_LAYOUT" ].Get( layout ) );
1019   DALI_TEST_EQUALS( static_cast<int>(panelLayout), layout, TEST_LOCATION );
1020
1021   int capital = 0;
1022   DALI_TEST_CHECK( map[ "AUTO_CAPITALIZE" ].Get( capital ) );
1023   DALI_TEST_EQUALS( static_cast<int>(autoCapital), capital, TEST_LOCATION );
1024
1025   int action = 0;
1026   DALI_TEST_CHECK( map[ "BUTTON_ACTION" ].Get( action ) );
1027   DALI_TEST_EQUALS( static_cast<int>(buttonAction), action, TEST_LOCATION );
1028
1029   int variation = 0;
1030   DALI_TEST_CHECK( map[ "VARIATION" ].Get( variation ) );
1031   DALI_TEST_EQUALS( inputVariation, variation, TEST_LOCATION );
1032
1033   // Check the input filter property
1034   Property::Map inputFilterMapSet;
1035   Property::Map inputFilterMapGet;
1036   inputFilterMapSet[InputFilter::Property::ACCEPTED] = "[\\w]";
1037   inputFilterMapSet[InputFilter::Property::REJECTED] = "[\\d]";
1038
1039   editor.SetProperty(DevelTextEditor::Property::INPUT_FILTER, inputFilterMapSet);
1040
1041   inputFilterMapGet = editor.GetProperty<Property::Map>(DevelTextEditor::Property::INPUT_FILTER);
1042   DALI_TEST_EQUALS(inputFilterMapGet.Count(), inputFilterMapSet.Count(), TEST_LOCATION);
1043
1044   // Clear
1045   inputFilterMapSet.Clear();
1046   editor.SetProperty(DevelTextEditor::Property::INPUT_FILTER, inputFilterMapSet);
1047
1048   // Check the strikethrough property
1049
1050   Property::Map strikethroughMapSet;
1051   Property::Map strikethroughMapGet;
1052
1053   application.SendNotification();
1054   application.Render();
1055
1056   // Check the input strikethrough property
1057
1058   strikethroughMapSet.Clear();
1059   strikethroughMapGet.Clear();
1060   strikethroughMapSet.Insert( "enable", true );
1061   strikethroughMapSet.Insert( "color", Color::BLUE );
1062   strikethroughMapSet.Insert( "height", 2.0f );
1063
1064   editor.SetProperty( DevelTextEditor::Property::STRIKETHROUGH, strikethroughMapSet );
1065
1066   application.SendNotification();
1067   application.Render();
1068
1069   strikethroughMapGet = editor.GetProperty<Property::Map>( DevelTextEditor::Property::STRIKETHROUGH );
1070
1071   DALI_TEST_EQUALS( strikethroughMapGet.Count(), strikethroughMapSet.Count(), TEST_LOCATION );
1072   DALI_TEST_EQUALS( DaliTestCheckMaps( strikethroughMapSet, strikethroughMapGet ), true,  TEST_LOCATION );
1073
1074   // Check the input strikethrough property
1075   editor.SetProperty( DevelTextEditor::Property::INPUT_STRIKETHROUGH, "Strikethrough input properties" );
1076   DALI_TEST_EQUALS( editor.GetProperty<std::string>( DevelTextEditor::Property::INPUT_STRIKETHROUGH ), std::string("Strikethrough input properties"), TEST_LOCATION );
1077
1078   application.SendNotification();
1079   application.Render();
1080
1081   // Check the line size property
1082   DALI_TEST_EQUALS( editor.GetProperty<float>( DevelTextEditor::Property::MIN_LINE_SIZE ), 0.0f, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
1083   editor.SetProperty( DevelTextEditor::Property::MIN_LINE_SIZE, 50.f );
1084   DALI_TEST_EQUALS( editor.GetProperty<float>( DevelTextEditor::Property::MIN_LINE_SIZE ), 50.0f, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
1085
1086   END_TEST;
1087 }
1088
1089 // Positive Atlas Text Renderer test
1090 int utcDaliTextEditorAtlasRenderP(void)
1091 {
1092   ToolkitTestApplication application;
1093   tet_infoline(" UtcDaliToolkitTextEditorAtlasRenderP");
1094   StyleManager styleManager = StyleManager::Get();
1095   styleManager.ApplyDefaultTheme();
1096   TextEditor editor = TextEditor::New();
1097   DALI_TEST_CHECK( editor );
1098
1099   editor.SetProperty( TextEditor::Property::HORIZONTAL_ALIGNMENT, "CENTER" );
1100
1101   application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
1102
1103   application.GetScene().Add( editor );
1104
1105   try
1106   {
1107     // Render some text with the shared atlas backend
1108     editor.SetProperty( DevelTextEditor::Property::RENDERING_BACKEND, DevelText::RENDERING_SHARED_ATLAS );
1109     application.SendNotification();
1110     application.Render();
1111   }
1112   catch( ... )
1113   {
1114     tet_result(TET_FAIL);
1115   }
1116   END_TEST;
1117 }
1118
1119 // Positive test for the anchorClicked signal.
1120 int utcDaliTextEditorAnchorClickedP(void)
1121 {
1122   ToolkitTestApplication application;
1123   tet_infoline(" utcDaliTextEditorAnchorClickedP");
1124   TextEditor editor = TextEditor::New();
1125   DALI_TEST_CHECK(editor);
1126
1127   application.GetScene().Add(editor);
1128
1129   // connect to the anchor clicked signal.
1130   ConnectionTracker* testTracker = new ConnectionTracker();
1131   DevelTextEditor::AnchorClickedSignal(editor).Connect(&TestAnchorClickedCallback);
1132   bool anchorClickedSignal = false;
1133   editor.ConnectSignal(testTracker, "anchorClicked", CallbackFunctor(&anchorClickedSignal));
1134
1135   gAnchorClickedCallBackCalled = false;
1136   editor.SetProperty(TextEditor::Property::TEXT, "<a href='https://www.tizen.org'>TIZEN</a>");
1137   editor.SetProperty(TextEditor::Property::ENABLE_MARKUP, true);
1138   editor.SetProperty(Actor::Property::SIZE, Vector2(100.f, 50.f));
1139   editor.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT);
1140   editor.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
1141
1142   application.SendNotification();
1143   application.Render();
1144   editor.SetKeyInputFocus();
1145
1146   // Create a tap event to touch the text editor.
1147   TestGenerateTap(application, 5.0f, 5.0f);
1148   application.SendNotification();
1149   application.Render();
1150
1151   DALI_TEST_CHECK(gAnchorClickedCallBackCalled);
1152   DALI_TEST_CHECK(anchorClickedSignal);
1153
1154   gAnchorClickedCallBackNotCalled = true;
1155   // Tap the outside of anchor, callback should not be called.
1156   TestGenerateTap(application, 150.f, 100.f);
1157   application.SendNotification();
1158   application.Render();
1159
1160   DALI_TEST_CHECK(gAnchorClickedCallBackNotCalled);
1161
1162   END_TEST;
1163 }
1164
1165 // Positive test for the textChanged signal.
1166 int utcDaliTextEditorTextChangedP(void)
1167 {
1168   ToolkitTestApplication application;
1169   tet_infoline(" utcDaliTextEditorTextChangedP");
1170   TextEditor editor = TextEditor::New();
1171   DALI_TEST_CHECK( editor );
1172
1173   application.GetScene().Add( editor );
1174
1175   // connect to the text changed signal.
1176   ConnectionTracker* testTracker = new ConnectionTracker();
1177   editor.TextChangedSignal().Connect( &TestTextChangedCallback );
1178   bool textChangedSignal = false;
1179   editor.ConnectSignal( testTracker, "textChanged",   CallbackFunctor(&textChangedSignal) );
1180
1181   gTextChangedCallBackCalled = false;
1182   editor.SetProperty( TextEditor::Property::TEXT, "ABC" );
1183   DALI_TEST_CHECK( gTextChangedCallBackCalled );
1184   DALI_TEST_CHECK( textChangedSignal );
1185
1186   application.SendNotification();
1187   editor.SetKeyInputFocus();
1188
1189   gTextChangedCallBackCalled = false;
1190   application.ProcessEvent( GenerateKey( "D", "", "D", KEY_D_CODE, 0, 0, Integration::KeyEvent::DOWN, "D", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
1191   DALI_TEST_CHECK( gTextChangedCallBackCalled );
1192
1193   // Remove all text
1194   editor.SetProperty( TextField::Property::TEXT, "" );
1195
1196   // Pressing backspace key: TextChangedCallback should not be called when there is no text in texteditor.
1197   gTextChangedCallBackCalled = false;
1198   application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_BACKSPACE, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
1199   DALI_TEST_CHECK( !gTextChangedCallBackCalled );
1200
1201   // Pressing delete key: TextChangedCallback should not be called when there is no text in texteditor.
1202   gTextChangedCallBackCalled = false;
1203   application.ProcessEvent( GenerateKey( "", "", "", Dali::DevelKey::DALI_KEY_DELETE, 0, 0, Integration::KeyEvent::DOWN, "Delete", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
1204   DALI_TEST_CHECK( !gTextChangedCallBackCalled );
1205
1206   END_TEST;
1207 }
1208
1209 int utcDaliTextEditorTextChangedWithInputMethodContext(void)
1210 {
1211   ToolkitTestApplication application;
1212   tet_infoline(" utcDaliTextEditorTextChangedWithInputMethodContext");
1213   TextEditor editor = TextEditor::New();
1214   DALI_TEST_CHECK( editor );
1215
1216
1217   application.GetScene().Add( editor );
1218
1219   // connect to the text changed signal.
1220   ConnectionTracker* testTracker = new ConnectionTracker();
1221   editor.TextChangedSignal().Connect(&TestTextChangedCallback);
1222   bool textChangedSignal = false;
1223   editor.ConnectSignal( testTracker, "textChanged",   CallbackFunctor(&textChangedSignal) );
1224
1225
1226   // get InputMethodContext
1227   std::string text;
1228   InputMethodContext::EventData imfEvent;
1229   InputMethodContext inputMethodContext = DevelTextEditor::GetInputMethodContext( editor );
1230
1231   editor.SetKeyInputFocus();
1232   editor.SetProperty( DevelTextEditor::Property::ENABLE_EDITING, true );
1233
1234   // input text
1235   gTextChangedCallBackCalled = false;
1236   imfEvent = InputMethodContext::EventData( InputMethodContext::PRE_EDIT, "ㅎ", 0, 1 );
1237   inputMethodContext.EventReceivedSignal().Emit(inputMethodContext, imfEvent);
1238   application.SendNotification();
1239   application.Render();
1240   DALI_TEST_CHECK( gTextChangedCallBackCalled );
1241   DALI_TEST_EQUALS( editor.GetProperty<std::string>( TextEditor::Property::TEXT ), std::string("ㅎ"), TEST_LOCATION );
1242
1243   gTextChangedCallBackCalled = false;
1244   imfEvent = InputMethodContext::EventData( InputMethodContext::PRE_EDIT, "호", 0, 1 );
1245   inputMethodContext.EventReceivedSignal().Emit(inputMethodContext, imfEvent);
1246   application.SendNotification();
1247   application.Render();
1248   DALI_TEST_CHECK( gTextChangedCallBackCalled );
1249   DALI_TEST_EQUALS( editor.GetProperty<std::string>( TextEditor::Property::TEXT ), std::string("호"), TEST_LOCATION );
1250
1251   gTextChangedCallBackCalled = false;
1252   imfEvent = InputMethodContext::EventData( InputMethodContext::PRE_EDIT, "혿", 0, 1 );
1253   inputMethodContext.EventReceivedSignal().Emit(inputMethodContext, imfEvent);
1254   application.SendNotification();
1255   application.Render();
1256   DALI_TEST_CHECK( gTextChangedCallBackCalled );
1257   DALI_TEST_EQUALS( editor.GetProperty<std::string>( TextEditor::Property::TEXT ), std::string("혿"), TEST_LOCATION );
1258
1259   gTextChangedCallBackCalled = false;
1260   imfEvent = InputMethodContext::EventData( InputMethodContext::PRE_EDIT, "", 0, 1 );
1261   inputMethodContext.EventReceivedSignal().Emit(inputMethodContext, imfEvent);
1262   DALI_TEST_CHECK( !gTextChangedCallBackCalled );
1263
1264   imfEvent = InputMethodContext::EventData( InputMethodContext::COMMIT, "호", 0, 1 );
1265   inputMethodContext.EventReceivedSignal().Emit(inputMethodContext, imfEvent);
1266   DALI_TEST_CHECK( !gTextChangedCallBackCalled );
1267
1268   imfEvent = InputMethodContext::EventData( InputMethodContext::PRE_EDIT, "두", 1, 2 );
1269   inputMethodContext.EventReceivedSignal().Emit(inputMethodContext, imfEvent);
1270   DALI_TEST_CHECK( !gTextChangedCallBackCalled );
1271
1272   application.SendNotification();
1273   application.Render();
1274   DALI_TEST_CHECK( gTextChangedCallBackCalled );
1275   DALI_TEST_EQUALS( editor.GetProperty<std::string>( TextEditor::Property::TEXT ), std::string("호두"), TEST_LOCATION );
1276
1277   END_TEST;
1278 }
1279
1280
1281 int utcDaliTextEditorInputStyleChanged01(void)
1282 {
1283   // The text-editor emits signals when the input style changes. These changes of style are
1284   // detected during the relayout process (size negotiation), i.e after the cursor has been moved. Signals
1285   // can't be emitted during the size negotiation as the callbacks may update the UI.
1286   // The text-editor adds an idle callback to the adaptor to emit the signals after the size negotiation.
1287   // The ToolkitTestApplication creates an implementation of the adaptor stub and a queue of idle callbacks.
1288   ToolkitTestApplication application;
1289   tet_infoline(" utcDaliTextEditorInputStyleChanged01");
1290
1291   // Load some fonts.
1292
1293   char* pathNamePtr = get_current_dir_name();
1294   const std::string pathName( pathNamePtr );
1295   free( pathNamePtr );
1296
1297   TextAbstraction::FontClient fontClient = TextAbstraction::FontClient::Get();
1298   fontClient.SetDpi( 93u, 93u );
1299
1300   fontClient.GetFontId( pathName + DEFAULT_FONT_DIR + "/dejavu/DejaVuSerif.ttf", DEFAULT_FONT_SIZE );
1301   fontClient.GetFontId( pathName + DEFAULT_FONT_DIR + "/dejavu/DejaVuSerif-Bold.ttf", DEFAULT_FONT_SIZE );
1302
1303   TextEditor editor = TextEditor::New();
1304   DALI_TEST_CHECK( editor );
1305
1306
1307   editor.SetProperty( Actor::Property::SIZE, Vector2( 300.f, 50.f ) );
1308   editor.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT );
1309   editor.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT );
1310
1311   editor.SetProperty( TextEditor::Property::ENABLE_MARKUP, true );
1312   editor.SetProperty( TextEditor::Property::TEXT, "<font family='DejaVuSerif' size='18'>He<color value='green'>llo</color> <font weight='bold'>world</font> demo</font>" );
1313
1314   // connect to the text changed signal.
1315   ConnectionTracker* testTracker = new ConnectionTracker();
1316   editor.InputStyleChangedSignal().Connect( &TestInputStyleChangedCallback );
1317   bool inputStyleChangedSignal = false;
1318   editor.ConnectSignal( testTracker, "inputStyleChanged",   CallbackFunctor(&inputStyleChangedSignal) );
1319
1320   application.GetScene().Add( editor );
1321
1322   // Render and notify
1323   application.SendNotification();
1324   application.Render();
1325
1326   // Executes the idle callbacks added by the text control on the change of input style.
1327   application.RunIdles();
1328
1329   gInputStyleChangedCallbackCalled = false;
1330   gInputStyleMask = TextEditor::InputStyle::NONE;
1331   inputStyleChangedSignal = false;
1332
1333   // Create a tap event to touch the text editor.
1334   TestGenerateTap( application, 18.0f, 25.0f );
1335
1336   // Render and notify
1337   application.SendNotification();
1338   application.Render();
1339
1340   // Executes the idle callbacks added by the text control on the change of input style.
1341   application.RunIdles();
1342
1343   DALI_TEST_CHECK( gInputStyleChangedCallbackCalled );
1344   if( gInputStyleChangedCallbackCalled )
1345   {
1346     DALI_TEST_EQUALS( static_cast<unsigned int>( gInputStyleMask ), static_cast<unsigned int>( TextEditor::InputStyle::FONT_FAMILY | TextEditor::InputStyle::POINT_SIZE ), TEST_LOCATION );
1347
1348     const std::string fontFamily = editor.GetProperty( TextEditor::Property::INPUT_FONT_FAMILY ).Get<std::string>();
1349     DALI_TEST_EQUALS( fontFamily, "DejaVuSerif", TEST_LOCATION );
1350
1351     const float pointSize = editor.GetProperty( TextEditor::Property::INPUT_POINT_SIZE ).Get<float>();
1352     DALI_TEST_EQUALS( pointSize, 18.f, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
1353   }
1354   DALI_TEST_CHECK( inputStyleChangedSignal );
1355
1356   gInputStyleChangedCallbackCalled = false;
1357   gInputStyleMask = TextEditor::InputStyle::NONE;
1358   inputStyleChangedSignal = false;
1359
1360   // Create a tap event to touch the text editor.
1361   TestGenerateTap( application, 30.0f, 25.0f );
1362
1363   // Render and notify
1364   application.SendNotification();
1365   application.Render();
1366
1367   // Executes the idle callbacks added by the text control on the change of input style.
1368   application.RunIdles();
1369
1370   DALI_TEST_CHECK( !gInputStyleChangedCallbackCalled );
1371   DALI_TEST_CHECK( !inputStyleChangedSignal );
1372
1373   gInputStyleChangedCallbackCalled = false;
1374   gInputStyleMask = TextEditor::InputStyle::NONE;
1375   inputStyleChangedSignal = false;
1376
1377   // Create a tap event to touch the text editor.
1378   TestGenerateTap( application, 43.0f, 25.0f );
1379
1380   // Render and notify
1381   application.SendNotification();
1382   application.Render();
1383
1384   // Executes the idle callbacks added by the text control on the change of input style.
1385   application.RunIdles();
1386
1387   DALI_TEST_CHECK( gInputStyleChangedCallbackCalled );
1388   if( gInputStyleChangedCallbackCalled )
1389   {
1390     DALI_TEST_EQUALS( static_cast<unsigned int>( gInputStyleMask ), static_cast<unsigned int>( TextEditor::InputStyle::COLOR ), TEST_LOCATION );
1391
1392     const Vector4 color = editor.GetProperty( TextEditor::Property::INPUT_COLOR ).Get<Vector4>();
1393     DALI_TEST_EQUALS( color, Color::GREEN, TEST_LOCATION );
1394   }
1395   DALI_TEST_CHECK( inputStyleChangedSignal );
1396
1397   gInputStyleChangedCallbackCalled = false;
1398   gInputStyleMask = TextEditor::InputStyle::NONE;
1399   inputStyleChangedSignal = false;
1400
1401   // Create a tap event to touch the text editor.
1402   TestGenerateTap( application, 88.0f, 25.0f );
1403
1404   // Render and notify
1405   application.SendNotification();
1406   application.Render();
1407
1408   // Executes the idle callbacks added by the text control on the change of input style.
1409   application.RunIdles();
1410
1411   DALI_TEST_CHECK( gInputStyleChangedCallbackCalled );
1412   if( gInputStyleChangedCallbackCalled )
1413   {
1414     DALI_TEST_EQUALS( static_cast<unsigned int>( gInputStyleMask ), static_cast<unsigned int>( TextEditor::InputStyle::COLOR | TextEditor::InputStyle::FONT_STYLE ), TEST_LOCATION );
1415
1416     const Vector4 color = editor.GetProperty( TextEditor::Property::INPUT_COLOR ).Get<Vector4>();
1417     DALI_TEST_EQUALS( color, Color::BLACK, TEST_LOCATION );
1418
1419     Property::Map fontStyleMapSet;
1420     Property::Map fontStyleMapGet;
1421
1422     fontStyleMapSet.Insert( "weight", "bold" );
1423
1424     fontStyleMapGet = editor.GetProperty<Property::Map>( TextEditor::Property::INPUT_FONT_STYLE );
1425     DALI_TEST_EQUALS( fontStyleMapGet.Count(), fontStyleMapSet.Count(), TEST_LOCATION );
1426     DALI_TEST_EQUALS( DaliTestCheckMaps( fontStyleMapGet, fontStyleMapSet ), true, TEST_LOCATION );
1427   }
1428   DALI_TEST_CHECK( inputStyleChangedSignal );
1429
1430   gInputStyleChangedCallbackCalled = false;
1431   gInputStyleMask = TextEditor::InputStyle::NONE;
1432   inputStyleChangedSignal = false;
1433
1434   // Create a tap event to touch the text editor.
1435   TestGenerateTap( application, 115.0f, 25.0f );
1436
1437   // Render and notify
1438   application.SendNotification();
1439   application.Render();
1440
1441   // Executes the idle callbacks added by the text control on the change of input style.
1442   application.RunIdles();
1443
1444   DALI_TEST_CHECK( !gInputStyleChangedCallbackCalled );
1445   DALI_TEST_CHECK( !inputStyleChangedSignal );
1446
1447   gInputStyleChangedCallbackCalled = false;
1448   gInputStyleMask = TextEditor::InputStyle::NONE;
1449   inputStyleChangedSignal = false;
1450
1451   // Create a tap event to touch the text editor.
1452   TestGenerateTap( application, 164.0f, 25.0f );
1453
1454   // Render and notify
1455   application.SendNotification();
1456   application.Render();
1457
1458   // Executes the idle callbacks added by the text control on the change of input style.
1459   application.RunIdles();
1460
1461   DALI_TEST_CHECK( gInputStyleChangedCallbackCalled );
1462   if( gInputStyleChangedCallbackCalled )
1463   {
1464     DALI_TEST_EQUALS( static_cast<unsigned int>( gInputStyleMask ), static_cast<unsigned int>( TextEditor::InputStyle::FONT_STYLE ), TEST_LOCATION );
1465
1466     Property::Map fontStyleMapSet;
1467     Property::Map fontStyleMapGet;
1468
1469     fontStyleMapGet = editor.GetProperty<Property::Map>( TextEditor::Property::INPUT_FONT_STYLE );
1470     DALI_TEST_EQUALS( fontStyleMapGet.Count(), fontStyleMapSet.Count(), TEST_LOCATION );
1471     DALI_TEST_EQUALS( DaliTestCheckMaps( fontStyleMapGet, fontStyleMapSet ), true, TEST_LOCATION );
1472   }
1473   DALI_TEST_CHECK( inputStyleChangedSignal );
1474
1475   gInputStyleChangedCallbackCalled = false;
1476   gInputStyleMask = TextEditor::InputStyle::NONE;
1477   inputStyleChangedSignal = false;
1478
1479   // Create a tap event to touch the text editor.
1480   TestGenerateTap( application, 191.0f, 25.0f );
1481
1482   // Render and notify
1483   application.SendNotification();
1484   application.Render();
1485
1486   // Executes the idle callbacks added by the text control on the change of input style.
1487   application.RunIdles();
1488
1489   DALI_TEST_CHECK( !gInputStyleChangedCallbackCalled );
1490   DALI_TEST_CHECK( !inputStyleChangedSignal );
1491
1492   END_TEST;
1493 }
1494
1495 int utcDaliTextEditorInputStyleChanged02(void)
1496 {
1497   // The text-editor emits signals when the input style changes. These changes of style are
1498   // detected during the relayout process (size negotiation), i.e after the cursor has been moved. Signals
1499   // can't be emitted during the size negotiation as the callbacks may update the UI.
1500   // The text-editor adds an idle callback to the adaptor to emit the signals after the size negotiation.
1501   // The ToolkitTestApplication creates an implementation of the adaptor stub and a queue of idle callbacks.
1502   ToolkitTestApplication application;
1503   tet_infoline(" utcDaliTextEditorInputStyleChanged02");
1504
1505   // Load some fonts.
1506
1507   char* pathNamePtr = get_current_dir_name();
1508   const std::string pathName( pathNamePtr );
1509   free( pathNamePtr );
1510
1511   TextAbstraction::FontClient fontClient = TextAbstraction::FontClient::Get();
1512   fontClient.SetDpi( 93u, 93u );
1513
1514   fontClient.GetFontId( pathName + DEFAULT_FONT_DIR + "/dejavu/DejaVuSerif.ttf", DEFAULT_FONT_SIZE );
1515   fontClient.GetFontId( pathName + DEFAULT_FONT_DIR + "/dejavu/DejaVuSerif-Bold.ttf", DEFAULT_FONT_SIZE );
1516
1517   TextEditor editor = TextEditor::New();
1518   DALI_TEST_CHECK( editor );
1519
1520
1521   editor.SetProperty( Actor::Property::SIZE, Vector2( 300.f, 50.f ) );
1522   editor.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT );
1523   editor.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT );
1524
1525   editor.SetProperty( TextEditor::Property::ENABLE_MARKUP, true );
1526   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>" );
1527
1528   // connect to the text changed signal.
1529   ConnectionTracker* testTracker = new ConnectionTracker();
1530   editor.InputStyleChangedSignal().Connect( &TestInputStyleChangedCallback );
1531   bool inputStyleChangedSignal = false;
1532   editor.ConnectSignal( testTracker, "inputStyleChanged",   CallbackFunctor(&inputStyleChangedSignal) );
1533
1534   application.GetScene().Add( editor );
1535
1536   // Render and notify
1537   application.SendNotification();
1538   application.Render();
1539
1540   // Executes the idle callbacks added by the text control on the change of input style.
1541   application.RunIdles();
1542
1543   gInputStyleChangedCallbackCalled = false;
1544   gInputStyleMask = TextEditor::InputStyle::NONE;
1545   inputStyleChangedSignal = false;
1546
1547   // Create a tap event to touch the text editor.
1548   TestGenerateTap( application, 53.0f, 25.0f, 100 );
1549   TestGenerateTap( application, 53.0f, 25.0f, 200 );
1550
1551   // Render and notify
1552   application.SendNotification();
1553   application.Render();
1554
1555   // Executes the idle callbacks added by the text control on the change of input style.
1556   application.RunIdles();
1557
1558   DALI_TEST_CHECK( gInputStyleChangedCallbackCalled );
1559   if( gInputStyleChangedCallbackCalled )
1560   {
1561     DALI_TEST_EQUALS( static_cast<unsigned int>( gInputStyleMask ),
1562                       static_cast<unsigned int>( TextEditor::InputStyle::FONT_FAMILY |
1563                                                  TextEditor::InputStyle::POINT_SIZE  |
1564                                                  TextEditor::InputStyle::COLOR ),
1565                       TEST_LOCATION );
1566
1567     const Vector4 color = editor.GetProperty( TextEditor::Property::INPUT_COLOR ).Get<Vector4>();
1568     DALI_TEST_EQUALS( color, Color::GREEN, TEST_LOCATION );
1569
1570     const std::string fontFamily = editor.GetProperty( TextEditor::Property::INPUT_FONT_FAMILY ).Get<std::string>();
1571     DALI_TEST_EQUALS( fontFamily, "DejaVuSerif", TEST_LOCATION );
1572
1573     const float pointSize = editor.GetProperty( TextEditor::Property::INPUT_POINT_SIZE ).Get<float>();
1574     DALI_TEST_EQUALS( pointSize, 18.f, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
1575   }
1576   DALI_TEST_CHECK( inputStyleChangedSignal );
1577
1578   gInputStyleChangedCallbackCalled = false;
1579   gInputStyleMask = TextEditor::InputStyle::NONE;
1580   inputStyleChangedSignal = false;
1581
1582   application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_BACKSPACE, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
1583
1584   // Render and notify
1585   application.SendNotification();
1586   application.Render();
1587
1588   // Executes the idle callbacks added by the text control on the change of input style.
1589   application.RunIdles();
1590
1591   DALI_TEST_CHECK( gInputStyleChangedCallbackCalled );
1592   if( gInputStyleChangedCallbackCalled )
1593   {
1594     DALI_TEST_EQUALS( static_cast<unsigned int>( gInputStyleMask ),
1595                       static_cast<unsigned int>( TextEditor::InputStyle::COLOR ),
1596                       TEST_LOCATION );
1597
1598     const Vector4 color = editor.GetProperty( TextEditor::Property::INPUT_COLOR ).Get<Vector4>();
1599     DALI_TEST_EQUALS( color, Color::BLUE, TEST_LOCATION );
1600   }
1601   DALI_TEST_CHECK( inputStyleChangedSignal );
1602
1603   gInputStyleChangedCallbackCalled = false;
1604   gInputStyleMask = TextEditor::InputStyle::NONE;
1605   inputStyleChangedSignal = false;
1606
1607   application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_BACKSPACE, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
1608
1609   // Render and notify
1610   application.SendNotification();
1611   application.Render();
1612
1613   // Executes the idle callbacks added by the text control on the change of input style.
1614   application.RunIdles();
1615
1616   DALI_TEST_CHECK( !gInputStyleChangedCallbackCalled );
1617   DALI_TEST_CHECK( !inputStyleChangedSignal );
1618
1619   gInputStyleChangedCallbackCalled = false;
1620   gInputStyleMask = TextEditor::InputStyle::NONE;
1621   inputStyleChangedSignal = false;
1622
1623   application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_BACKSPACE, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
1624
1625   // Render and notify
1626   application.SendNotification();
1627   application.Render();
1628
1629   // Executes the idle callbacks added by the text control on the change of input style.
1630   application.RunIdles();
1631
1632   DALI_TEST_CHECK( gInputStyleChangedCallbackCalled );
1633   if( gInputStyleChangedCallbackCalled )
1634   {
1635     DALI_TEST_EQUALS( static_cast<unsigned int>( gInputStyleMask ),
1636                       static_cast<unsigned int>( TextEditor::InputStyle::COLOR ),
1637                       TEST_LOCATION );
1638
1639     const Vector4 color = editor.GetProperty( TextEditor::Property::INPUT_COLOR ).Get<Vector4>();
1640     DALI_TEST_EQUALS( color, Color::BLACK, TEST_LOCATION );
1641   }
1642   DALI_TEST_CHECK( inputStyleChangedSignal );
1643
1644   gInputStyleChangedCallbackCalled = false;
1645   gInputStyleMask = TextEditor::InputStyle::NONE;
1646   inputStyleChangedSignal = false;
1647
1648   editor.SetProperty( TextEditor::Property::INPUT_COLOR, Color::YELLOW );
1649
1650   Property::Map fontStyleMapSet;
1651   fontStyleMapSet.Insert( "weight", "thin" );
1652   fontStyleMapSet.Insert( "width", "condensed" );
1653   fontStyleMapSet.Insert( "slant", "italic" );
1654
1655   editor.SetProperty( TextEditor::Property::INPUT_FONT_STYLE, fontStyleMapSet );
1656   editor.SetProperty( TextEditor::Property::INPUT_POINT_SIZE, 20.f );
1657   editor.SetProperty( TextEditor::Property::INPUT_LINE_SPACING, 5.f );
1658
1659   editor.SetProperty( TextEditor::Property::INPUT_UNDERLINE, "underline" );
1660   editor.SetProperty( TextEditor::Property::INPUT_SHADOW, "shadow" );
1661   editor.SetProperty( TextEditor::Property::INPUT_EMBOSS, "emboss" );
1662   editor.SetProperty( TextEditor::Property::INPUT_OUTLINE, "outline" );
1663   editor.SetProperty( DevelTextEditor::Property::INPUT_STRIKETHROUGH, "strikethrough" );
1664
1665   application.ProcessEvent( GenerateKey( "a", "", "a", KEY_A_CODE, 0, 0, Integration::KeyEvent::DOWN, "a", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
1666
1667   // Render and notify
1668   application.SendNotification();
1669   application.Render();
1670
1671   // Executes the idle callbacks added by the text control on the change of input style.
1672   application.RunIdles();
1673
1674   DALI_TEST_CHECK( !gInputStyleChangedCallbackCalled );
1675   DALI_TEST_CHECK( !inputStyleChangedSignal );
1676
1677   // Create a tap event to touch the text editor.
1678   TestGenerateTap( application, 63.0f, 25.0f, 900 );
1679
1680   // Render and notify
1681   application.SendNotification();
1682   application.Render();
1683
1684   // Executes the idle callbacks added by the text control on the change of input style.
1685   application.RunIdles();
1686
1687   DALI_TEST_CHECK( gInputStyleChangedCallbackCalled );
1688   if( gInputStyleChangedCallbackCalled )
1689   {
1690     DALI_TEST_EQUALS( static_cast<unsigned int>( gInputStyleMask ),
1691                       static_cast<unsigned int>( TextEditor::InputStyle::COLOR |
1692                                                  TextEditor::InputStyle::POINT_SIZE |
1693                                                  TextEditor::InputStyle::FONT_STYLE |
1694                                                  TextEditor::InputStyle::LINE_SPACING |
1695                                                  TextEditor::InputStyle::UNDERLINE |
1696                                                  TextEditor::InputStyle::SHADOW |
1697                                                  TextEditor::InputStyle::EMBOSS |
1698                                                  TextEditor::InputStyle::OUTLINE ),
1699                       TEST_LOCATION );
1700
1701     const Vector4 color = editor.GetProperty( TextEditor::Property::INPUT_COLOR ).Get<Vector4>();
1702     DALI_TEST_EQUALS( color, Color::BLACK, TEST_LOCATION );
1703   }
1704   DALI_TEST_CHECK( inputStyleChangedSignal );
1705
1706   gInputStyleChangedCallbackCalled = false;
1707   gInputStyleMask = TextEditor::InputStyle::NONE;
1708   inputStyleChangedSignal = false;
1709
1710   editor.SetProperty( TextEditor::Property::FONT_FAMILY, "DejaVuSerif" );
1711
1712   fontStyleMapSet.Clear();
1713   fontStyleMapSet.Insert( "weight", "black" );
1714   fontStyleMapSet.Insert( "width", "expanded" );
1715   fontStyleMapSet.Insert( "slant", "oblique" );
1716
1717   editor.SetProperty( TextEditor::Property::FONT_STYLE, fontStyleMapSet );
1718
1719   // Create a tap event to touch the text editor.
1720   TestGenerateTap( application, 30.0f, 25.0f, 1500 );
1721
1722   // Render and notify
1723   application.SendNotification();
1724   application.Render();
1725
1726   // Executes the idle callbacks added by the text control on the change of input style.
1727   application.RunIdles();
1728
1729   DALI_TEST_CHECK( gInputStyleChangedCallbackCalled );
1730   if( gInputStyleChangedCallbackCalled )
1731   {
1732     DALI_TEST_EQUALS( static_cast<unsigned int>( gInputStyleMask ),
1733                       static_cast<unsigned int>( TextEditor::InputStyle::COLOR |
1734                                                  TextEditor::InputStyle::POINT_SIZE |
1735                                                  TextEditor::InputStyle::FONT_STYLE ),
1736                       TEST_LOCATION );
1737
1738     const Vector4 color = editor.GetProperty( TextEditor::Property::INPUT_COLOR ).Get<Vector4>();
1739     DALI_TEST_EQUALS( color, Color::YELLOW, TEST_LOCATION );
1740   }
1741   DALI_TEST_CHECK( inputStyleChangedSignal );
1742
1743   END_TEST;
1744 }
1745
1746 int utcDaliTextEditorEvent01(void)
1747 {
1748   ToolkitTestApplication application;
1749   tet_infoline(" utcDaliTextEditorEvent01");
1750
1751   // Creates a tap event. After creating a tap event the text editor should
1752   // have the focus and add text with key events should be possible.
1753
1754   TextEditor editor = TextEditor::New();
1755   DALI_TEST_CHECK( editor );
1756
1757   application.GetScene().Add( editor );
1758
1759   editor.SetProperty( Actor::Property::SIZE, Vector2( 300.f, 50.f ) );
1760   editor.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT );
1761   editor.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT );
1762
1763   // Avoid a crash when core load gl resources.
1764   application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
1765
1766   // Render and notify
1767   application.SendNotification();
1768   application.Render();
1769
1770   // Add a key event but as the text editor has not the focus it should do nothing.
1771   application.ProcessEvent( GenerateKey( "a", "", "a", KEY_A_CODE, 0, 0, Integration::KeyEvent::DOWN, "a", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
1772
1773   // Render and notify
1774   application.SendNotification();
1775   application.Render();
1776
1777   DALI_TEST_EQUALS( editor.GetProperty<std::string>( TextEditor::Property::TEXT ), std::string(""), TEST_LOCATION );
1778
1779   // Create a tap event to touch the text editor.
1780   TestGenerateTap( application, 150.0f, 25.0f );
1781
1782   // Render and notify
1783   application.SendNotification();
1784   application.Render();
1785
1786   // Now the text editor has the focus, so it can handle the key events.
1787   application.ProcessEvent( GenerateKey( "a", "", "a", KEY_A_CODE, 0, 0, Integration::KeyEvent::DOWN, "a", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
1788   application.ProcessEvent( GenerateKey( "a", "", "a", KEY_A_CODE, 0, 0, Integration::KeyEvent::DOWN, "a", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
1789
1790   // Render and notify
1791   application.SendNotification();
1792   application.Render();
1793
1794   DALI_TEST_EQUALS( editor.GetProperty<std::string>( TextEditor::Property::TEXT ), std::string("aa"), TEST_LOCATION );
1795
1796   // Create a second text editor and send key events to it.
1797   TextEditor editor2 = TextEditor::New();
1798
1799   editor2.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT );
1800   editor2.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT );
1801   editor2.SetProperty( Actor::Property::SIZE, Vector2( 100.f, 100.f ) );
1802   editor2.SetProperty( Actor::Property::POSITION, Vector2( 100.f, 100.f ));
1803
1804   application.GetScene().Add( editor2 );
1805
1806   // Render and notify
1807   application.SendNotification();
1808   application.Render();
1809
1810   // Create a tap event on the second text editor.
1811   TestGenerateTap( application, 150.0f, 125.0f );
1812
1813   // Render and notify
1814   application.SendNotification();
1815   application.Render();
1816
1817   // The second text editor has the focus. It should handle the key events.
1818   application.ProcessEvent( GenerateKey( "a", "", "a", KEY_A_CODE, 0, 0, Integration::KeyEvent::DOWN, "a", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
1819   application.ProcessEvent( GenerateKey( "a", "", "a", KEY_A_CODE, 0, 0, Integration::KeyEvent::DOWN, "a", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
1820
1821   // Render and notify
1822   application.SendNotification();
1823   application.Render();
1824
1825   // Check the text has been added to the second text editor.
1826   DALI_TEST_EQUALS( editor2.GetProperty<std::string>( TextEditor::Property::TEXT ), std::string("aa"), TEST_LOCATION );
1827
1828   END_TEST;
1829 }
1830
1831 int utcDaliTextEditorEvent02(void)
1832 {
1833   ToolkitTestApplication application;
1834   tet_infoline(" utcDaliTextEditorEvent02");
1835
1836   // Checks if the right number of actors are created.
1837
1838   TextEditor editor = TextEditor::New();
1839   editor.SetProperty( TextEditor::Property::POINT_SIZE, 10.f );
1840   DALI_TEST_CHECK( editor );
1841
1842   application.GetScene().Add( editor );
1843
1844   editor.SetProperty( Actor::Property::SIZE, Vector2( 300.f, 50.f ) );
1845   editor.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT );
1846   editor.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT );
1847
1848   // Avoid a crash when core load gl resources.
1849   application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
1850
1851   // Render and notify
1852   application.SendNotification();
1853   application.Render();
1854
1855   // Check there are the expected number of children (the stencil).
1856   DALI_TEST_EQUALS( editor.GetChildCount(), 1u, TEST_LOCATION );
1857
1858   Actor stencil = editor.GetChildAt( 0u );
1859
1860   // Create a tap event to touch the text editor.
1861   TestGenerateTap( application, 150.0f, 25.0f, 100 );
1862
1863   // Render and notify
1864   application.SendNotification();
1865   application.Render();
1866
1867   Actor layer = editor.GetChildAt( 1u );
1868   DALI_TEST_EQUALS( layer.GetChildCount(), 1u, TEST_LOCATION ); // The cursor.
1869   DALI_TEST_EQUALS( stencil.GetChildCount(), 0u, TEST_LOCATION );
1870
1871   // Now the text editor has the focus, so it can handle the key events.
1872   application.ProcessEvent( GenerateKey( "a", "", "a", KEY_A_CODE, 0, 0, Integration::KeyEvent::DOWN, "a", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
1873   application.ProcessEvent( GenerateKey( "a", "", "a", KEY_A_CODE, 0, 0, Integration::KeyEvent::DOWN, "a", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
1874
1875   // Render and notify
1876   application.SendNotification();
1877   application.Render();
1878
1879   // Checks the cursor and the renderer have been created.
1880   DALI_TEST_EQUALS( layer.GetChildCount(), 1u, TEST_LOCATION ); // The cursor.
1881   DALI_TEST_EQUALS( stencil.GetChildCount(), 1u, TEST_LOCATION ); // The renderer
1882
1883   Control cursor = Control::DownCast( layer.GetChildAt( 0u ) );
1884   DALI_TEST_CHECK( cursor );
1885
1886   // The stencil actor has a container with all the actors which contain the text renderers.
1887   Actor container = stencil.GetChildAt( 0u );
1888   for( unsigned int index = 0; index < container.GetChildCount(); ++index )
1889   {
1890     Renderer renderer = container.GetChildAt( index ).GetRendererAt( 0u );
1891     DALI_TEST_CHECK( renderer );
1892   }
1893
1894   // Move the cursor and check the position changes.
1895   Vector3 position1 = cursor.GetCurrentProperty< Vector3 >( Actor::Property::POSITION );
1896
1897   application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_LEFT, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
1898   application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_LEFT, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
1899
1900   // Render and notify
1901   application.SendNotification();
1902   application.Render();
1903
1904   Vector3 position2 = cursor.GetCurrentProperty< Vector3 >( Actor::Property::POSITION );
1905
1906   DALI_TEST_CHECK( position2.x < position1.x );
1907
1908   application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_RIGHT, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
1909   application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_RIGHT, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
1910
1911   // Render and notify
1912   application.SendNotification();
1913   application.Render();
1914
1915   Vector3 position3 = cursor.GetCurrentProperty< Vector3 >( Actor::Property::POSITION );
1916
1917   DALI_TEST_EQUALS( position1, position3, TEST_LOCATION ); // Should be in the same position1.
1918
1919   // Send some taps and check the cursor positions.
1920
1921   // Try to tap at the beginning.
1922   TestGenerateTap( application, 1.0f, 25.0f, 700 );
1923
1924   // Render and notify
1925   application.SendNotification();
1926   application.Render();
1927
1928   // Cursor position should be the same than position1.
1929   Vector3 position4 = cursor.GetCurrentProperty< Vector3 >( Actor::Property::POSITION );
1930
1931   DALI_TEST_EQUALS( position2, position4, TEST_LOCATION ); // Should be in the same position2.
1932
1933   // Tap away from the start position.
1934   TestGenerateTap( application, 16.0f, 25.0f, 1400 );
1935
1936   // Render and notify
1937   application.SendNotification();
1938   application.Render();
1939
1940   Vector3 position5 = cursor.GetCurrentProperty< Vector3 >( Actor::Property::POSITION );
1941
1942   DALI_TEST_CHECK( position5.x > position4.x );
1943
1944   // Remove all the text.
1945   application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_BACKSPACE, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
1946   application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_BACKSPACE, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
1947   editor.SetProperty( TextEditor::Property::TEXT, "" );
1948
1949   // Render and notify
1950   application.SendNotification();
1951   application.Render();
1952
1953   // Cursor position should be the same than position2.
1954   Vector3 position6 = cursor.GetCurrentProperty< Vector3 >( Actor::Property::POSITION );
1955
1956   DALI_TEST_EQUALS( position2, position6, TEST_LOCATION );// Should be in the same position2.
1957
1958   // Should not be a renderer.
1959   DALI_TEST_EQUALS( stencil.GetChildCount(), 0u, TEST_LOCATION );
1960
1961   END_TEST;
1962 }
1963
1964 int utcDaliTextEditorEvent03(void)
1965 {
1966   ToolkitTestApplication application;
1967   tet_infoline(" utcDaliTextEditorEvent03");
1968
1969   // Checks if the highlight actor is created.
1970
1971   TextEditor editor = TextEditor::New();
1972   DALI_TEST_CHECK( editor );
1973
1974   application.GetScene().Add( editor );
1975
1976   editor.SetProperty( TextEditor::Property::TEXT, "This is a long text for the size of the text-editor." );
1977   editor.SetProperty( TextEditor::Property::POINT_SIZE, 10.f );
1978   editor.SetProperty( Actor::Property::SIZE, Vector2( 30.f, 50.f ) );
1979   editor.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT );
1980   editor.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT );
1981
1982   // Avoid a crash when core load gl resources.
1983   application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
1984
1985   // Render and notify
1986   application.SendNotification();
1987   application.Render();
1988
1989   // Send some taps and check text controller with clipboard window
1990   Dali::Clipboard clipboard = Clipboard::Get();
1991   clipboard.ShowClipboard();
1992   TestGenerateTap( application, 3.0f, 25.0f, 100 );
1993   clipboard.HideClipboard();
1994
1995   // Render and notify
1996   application.SendNotification();
1997   application.Render();
1998
1999   // Tap first to get the focus.
2000   TestGenerateTap( application, 3.0f, 25.0f, 1000 );
2001
2002   // Render and notify
2003   application.SendNotification();
2004   application.Render();
2005
2006   // Double tap to select a word.
2007   TestGenerateTap( application, 3.0f, 25.0f, 1100 );
2008
2009   // Render and notify
2010   application.SendNotification();
2011   application.Render();
2012
2013   // The stencil actor should have two actors: the renderer and the highlight actor.
2014   Actor stencil = editor.GetChildAt( 0u );
2015
2016   // Highlight needs to be drawn before text, so should come first in child order
2017   Renderer highlight = stencil.GetChildAt( 0u ).GetRendererAt( 0u );
2018   DALI_TEST_CHECK( highlight );
2019
2020   // The stencil actor has a container with all the actors which contain the text renderers.
2021   Actor container = stencil.GetChildAt( 1u );
2022   for( unsigned int index = 0; index < container.GetChildCount(); ++index )
2023   {
2024     Renderer renderer = container.GetChildAt( index ).GetRendererAt( 0u );
2025     DALI_TEST_CHECK( renderer );
2026   }
2027
2028   // Double tap out of bounds
2029   TestGenerateTap( application, 29.0f, 25.0f, 1700 );
2030   TestGenerateTap( application, 29.0f, 25.0f, 1800 );
2031
2032   // Render and notify
2033   application.SendNotification();
2034   application.Render();
2035
2036   // The stencil actor should have one actors: the renderer actor.
2037   stencil = editor.GetChildAt( 0u );
2038
2039   // The stencil actor has a container with all the actors which contain the text renderers.
2040   container = stencil.GetChildAt( 0u );
2041   for( unsigned int index = 0; index < container.GetChildCount(); ++index )
2042   {
2043     Renderer renderer = container.GetChildAt( index ).GetRendererAt( 0u );
2044     DALI_TEST_CHECK( renderer );
2045   }
2046
2047   // Long Press
2048   TestGenerateLongPress(application, 1.0f, 25.0f);
2049
2050   // Render and notify
2051   application.SendNotification();
2052   application.Render();
2053
2054   // Pan Press
2055   TestGenerateMiniPan(application);
2056
2057   // Render and notify
2058   application.SendNotification();
2059   application.Render();
2060
2061   END_TEST;
2062 }
2063
2064 int utcDaliTextEditorEvent04(void)
2065 {
2066   ToolkitTestApplication application;
2067   tet_infoline(" utcDaliTextEditorEvent04");
2068
2069   // Checks if the highlight actor is created.
2070
2071   TextEditor editor = TextEditor::New();
2072   DALI_TEST_CHECK( editor );
2073
2074   application.GetScene().Add( editor );
2075
2076   editor.SetProperty( TextEditor::Property::TEXT, "Hello\nworl" );
2077   editor.SetProperty( TextEditor::Property::POINT_SIZE, 10.f );
2078   editor.SetProperty( Actor::Property::SIZE, Vector2( 100.f, 50.f ) );
2079   editor.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT );
2080   editor.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT );
2081
2082   // Avoid a crash when core load gl resources.
2083   application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
2084
2085   // Render and notify
2086   application.SendNotification();
2087   application.Render();
2088
2089   // Tap on the text editor
2090   TestGenerateTap( application, 3.0f, 25.0f );
2091
2092   // Render and notify
2093   application.SendNotification();
2094   application.Render();
2095
2096   // Move at the end of the text.
2097   application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_DOWN, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2098   application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_DOWN, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2099
2100   // Render and notify
2101   application.SendNotification();
2102   application.Render();
2103
2104   for( unsigned int index = 0u; index < 10u; ++index )
2105   {
2106     application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_RIGHT, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2107     application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_RIGHT, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2108
2109     // Render and notify
2110     application.SendNotification();
2111     application.Render();
2112   }
2113
2114   // Add a character
2115   application.ProcessEvent( GenerateKey( "d", "", "d", KEY_D_CODE, 0, 0, Integration::KeyEvent::DOWN, "d", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2116
2117   // Render and notify
2118   application.SendNotification();
2119   application.Render();
2120
2121   DALI_TEST_EQUALS( "Hello\nworld", editor.GetProperty<std::string>( TextEditor::Property::TEXT ), TEST_LOCATION );
2122
2123   // Add some key events
2124   application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_UP, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2125   application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_UP, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2126
2127   // Render and notify
2128   application.SendNotification();
2129   application.Render();
2130
2131   for( unsigned int index = 0u; index < 10u; ++index )
2132   {
2133     application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_LEFT, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2134     application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_LEFT, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2135
2136     // Render and notify
2137     application.SendNotification();
2138     application.Render();
2139   }
2140
2141   // Add a character
2142   application.ProcessEvent( GenerateKey( " ", "", " ", KEY_WHITE_SPACE_CODE, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2143
2144   // Render and notify
2145   application.SendNotification();
2146   application.Render();
2147
2148   DALI_TEST_EQUALS( " Hello\nworld", editor.GetProperty<std::string>( TextEditor::Property::TEXT ), TEST_LOCATION );
2149
2150   END_TEST;
2151 }
2152
2153 int utcDaliTextEditorEvent05(void)
2154 {
2155   ToolkitTestApplication application;
2156   tet_infoline(" utcDaliTextEditorEvent05");
2157
2158   // Checks if the highlight actor is created.
2159
2160   TextEditor editor = TextEditor::New();
2161   DALI_TEST_CHECK( editor );
2162
2163   application.GetScene().Add( editor );
2164
2165   editor.SetProperty( TextEditor::Property::TEXT, "Hello\nworl" );
2166   editor.SetProperty( TextEditor::Property::POINT_SIZE, 10.f );
2167   editor.SetProperty( Actor::Property::SIZE, Vector2( 50.f, 50.f ) );
2168   editor.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT );
2169   editor.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT );
2170   editor.SetProperty( TextEditor::Property::SMOOTH_SCROLL, true );
2171   editor.SetProperty( TextEditor::Property::SMOOTH_SCROLL_DURATION, 0.2f );
2172   editor.SetProperty( TextEditor::Property::ENABLE_SCROLL_BAR, true );
2173   editor.SetProperty( TextEditor::Property::SCROLL_BAR_SHOW_DURATION, 0.3f );
2174   editor.SetProperty( TextEditor::Property::SCROLL_BAR_FADE_DURATION, 0.2f );
2175
2176   // Avoid a crash when core load gl resources.
2177   application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
2178
2179   // Render and notify
2180   application.SendNotification();
2181   application.Render();
2182
2183   // Tap on the text editor
2184   TestGenerateTap( application, 3.0f, 25.0f );
2185
2186   // Render and notify
2187   application.SendNotification();
2188   application.Render();
2189
2190   // Move at the end of the text.
2191   application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_DOWN, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2192   application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_DOWN, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2193
2194   // Render and notify
2195   application.SendNotification();
2196   application.Render();
2197
2198   for( unsigned int index = 0u; index < 10u; ++index )
2199   {
2200     // Add a character
2201     application.ProcessEvent( GenerateKey( "d", "", "d", KEY_D_CODE, 0, 0, Integration::KeyEvent::DOWN, "d", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2202
2203     // Render and notify
2204     application.SendNotification();
2205     application.Render();
2206   }
2207   // Modify duration after scroll is enabled
2208   editor.SetProperty( TextEditor::Property::SMOOTH_SCROLL_DURATION, 0.1f );
2209
2210   // Continuous scroll left to increase coverage
2211   for( unsigned int index = 0u; index < 10u; ++index )
2212   {
2213     application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_LEFT, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2214
2215     // Render and notify
2216     application.SendNotification();
2217     application.Render();
2218   }
2219   DALI_TEST_EQUALS( editor.GetProperty<float>( TextEditor::Property::SMOOTH_SCROLL_DURATION ), 0.1f, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
2220   DALI_TEST_EQUALS( editor.GetProperty<bool>( TextEditor::Property::SMOOTH_SCROLL ), true, TEST_LOCATION );
2221   DALI_TEST_EQUALS( editor.GetProperty<bool>( TextEditor::Property::ENABLE_SCROLL_BAR ), true, TEST_LOCATION );
2222   DALI_TEST_EQUALS( editor.GetProperty<float>( TextEditor::Property::SCROLL_BAR_SHOW_DURATION ), 0.3f, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
2223   DALI_TEST_EQUALS( editor.GetProperty<float>( TextEditor::Property::SCROLL_BAR_FADE_DURATION ), 0.2f, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
2224
2225   // Press Escape to increase coverage
2226   application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_ESCAPE, 0, 0, Integration::KeyEvent::UP, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2227   application.SendNotification();
2228   application.Render();
2229
2230   DALI_TEST_CHECK( !editor.HasKeyInputFocus() );
2231
2232   END_TEST;
2233 }
2234
2235 int utcDaliTextEditorEvent06(void)
2236 {
2237   ToolkitTestApplication application;
2238   tet_infoline(" utcDaliTextEditorEvent06");
2239
2240   // Checks if the highlight actor is created.
2241
2242   TextEditor editor = TextEditor::New();
2243   DALI_TEST_CHECK( editor );
2244
2245   application.GetScene().Add( editor );
2246
2247   editor.SetProperty( TextEditor::Property::TEXT, "Hello\nworld\nHello world" );
2248   editor.SetProperty( TextEditor::Property::POINT_SIZE, 10.f );
2249   editor.SetProperty( Actor::Property::SIZE, Vector2( 100.f, 50.f ) );
2250   editor.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT );
2251   editor.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT );
2252
2253   // Avoid a crash when core load gl resources.
2254   application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
2255
2256   // Render and notify
2257   application.SendNotification();
2258   application.Render();
2259
2260   // Tap on the text editor
2261   TestGenerateTap( application, 3.0f, 25.0f );
2262
2263   // Render and notify
2264   application.SendNotification();
2265   application.Render();
2266
2267   // Move to seconds line of the text.
2268   application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_DOWN, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2269
2270   // Render and notify
2271   application.SendNotification();
2272   application.Render();
2273
2274   float layoutHeight = editor.GetHeightForWidth( 100.f );
2275
2276
2277   // Add  another script characters ( glyph height is defferent )
2278   application.ProcessEvent( GenerateKey( "d", "", "ㅁ", KEY_D_CODE, 0, 0, Integration::KeyEvent::DOWN, "ㅁ", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2279   application.ProcessEvent( GenerateKey( "d", "", "ኢ", KEY_D_CODE, 0, 0, Integration::KeyEvent::DOWN, "ኢ", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2280
2281   // Delete characters
2282   application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_BACKSPACE, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2283   application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_BACKSPACE, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2284
2285   DALI_TEST_EQUALS( layoutHeight, editor.GetHeightForWidth( 100.f ), TEST_LOCATION );
2286
2287   // Render and notify
2288   application.SendNotification();
2289   application.Render();
2290
2291   DALI_TEST_EQUALS( "Hello\nworld\nHello world", editor.GetProperty<std::string>( TextEditor::Property::TEXT ), TEST_LOCATION );
2292
2293   // For coverage
2294   application.ProcessEvent( GenerateKey( "", "", "", 0, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2295   application.SendNotification();
2296   application.Render();
2297
2298   application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_SHIFT_LEFT, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2299   application.SendNotification();
2300   application.Render();
2301
2302   application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_VOLUME_UP, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2303   application.SendNotification();
2304   application.Render();
2305
2306   application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_VOLUME_DOWN, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2307   application.SendNotification();
2308   application.Render();
2309
2310   application.ProcessEvent( GenerateKey( "", "", "", Dali::DevelKey::DALI_KEY_DELETE, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2311   application.SendNotification();
2312   application.Render();
2313
2314   application.ProcessEvent( GenerateKey( "", "", "", Dali::DevelKey::DALI_KEY_CONTROL_LEFT, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2315   application.SendNotification();
2316   application.Render();
2317
2318   application.ProcessEvent( GenerateKey( "", "", "", Dali::DevelKey::DALI_KEY_CONTROL_RIGHT, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2319   application.SendNotification();
2320   application.Render();
2321
2322   END_TEST;
2323 }
2324
2325 int utcDaliTextEditorEvent07(void)
2326 {
2327   ToolkitTestApplication application;
2328   tet_infoline(" utcDaliTextEditorEvent07");
2329
2330   // Checks if the highlight actor is created.
2331
2332   TextEditor editor = TextEditor::New();
2333   DALI_TEST_CHECK( editor );
2334
2335   application.GetScene().Add( editor );
2336
2337   editor.SetProperty( TextEditor::Property::TEXT, "Hello\nworld\nHello world" );
2338   editor.SetProperty( TextEditor::Property::POINT_SIZE, 10.f );
2339   editor.SetProperty( Actor::Property::SIZE, Vector2( 100.f, 50.f ) );
2340   editor.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT );
2341   editor.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT );
2342
2343   // Avoid a crash when core load gl resources.
2344   application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
2345
2346   // Render and notify
2347   application.SendNotification();
2348   application.Render();
2349
2350   // Tap on the text editor
2351   TestGenerateTap( application, 3.0f, 25.0f );
2352
2353   // Render and notify
2354   application.SendNotification();
2355   application.Render();
2356
2357   // Move to second line of the text.
2358   application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_DOWN, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2359
2360   // Render and notify
2361   application.SendNotification();
2362   application.Render();
2363
2364   // Select some text in the right of the current cursor position
2365   application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_SHIFT_LEFT, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2366   application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_RIGHT, KEY_SHIFT_MODIFIER, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2367   application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_RIGHT, KEY_SHIFT_MODIFIER, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2368   application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_RIGHT, KEY_SHIFT_MODIFIER, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2369
2370   // Render and notify
2371   application.SendNotification();
2372   application.Render();
2373
2374   // Cut the selected text
2375   application.ProcessEvent( GenerateKey( "", "", "", Dali::DevelKey::DALI_KEY_CONTROL_LEFT, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2376   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 ) );
2377
2378   // Render and notify
2379   application.SendNotification();
2380   application.Render();
2381
2382   DALI_TEST_EQUALS( "Hello\nld\nHello world", editor.GetProperty<std::string>( TextEditor::Property::TEXT ), TEST_LOCATION );
2383
2384   // Select some text in the left of the current cursor position
2385   application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_SHIFT_LEFT, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2386   application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_LEFT, KEY_SHIFT_MODIFIER, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2387   application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_LEFT, KEY_SHIFT_MODIFIER, 0, Integration::KeyEvent::DOWN,  "",DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2388   application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_LEFT, KEY_SHIFT_MODIFIER, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2389
2390   // Render and notify
2391   application.SendNotification();
2392   application.Render();
2393
2394   // Copy the selected text
2395   application.ProcessEvent( GenerateKey( "", "", "", Dali::DevelKey::DALI_KEY_CONTROL_LEFT, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2396   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 ) );
2397
2398   // Render and notify
2399   application.SendNotification();
2400   application.Render();
2401
2402   // Move the cursor to the third line
2403   application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_DOWN, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2404   application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_DOWN, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2405
2406   // Render and notify
2407   application.SendNotification();
2408   application.Render();
2409
2410   // Paste the selected text at the current cursor position
2411   application.ProcessEvent( GenerateKey( "", "", "", Dali::DevelKey::DALI_KEY_CONTROL_LEFT, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2412   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 ) );
2413
2414   // Render and notify
2415   application.SendNotification();
2416   application.Render();
2417
2418   DALI_TEST_EQUALS( "Hello\nld\nHello lo\nworld", editor.GetProperty<std::string>( TextEditor::Property::TEXT ), TEST_LOCATION );
2419
2420
2421   // Disable Shift Selection
2422   editor.SetProperty( DevelTextEditor::Property::ENABLE_SHIFT_SELECTION, false );
2423
2424   // Test to select some text in the right of the current cursor position
2425   application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_SHIFT_LEFT, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2426   application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_RIGHT, KEY_SHIFT_MODIFIER, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2427   application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_RIGHT, KEY_SHIFT_MODIFIER, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2428   application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_RIGHT, KEY_SHIFT_MODIFIER, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2429
2430   // Render and notify
2431   application.SendNotification();
2432   application.Render();
2433
2434   // Cut the selected text
2435   application.ProcessEvent( GenerateKey( "", "", "", Dali::DevelKey::DALI_KEY_CONTROL_LEFT, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2436   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 ) );
2437
2438   // Render and notify
2439   application.SendNotification();
2440   application.Render();
2441
2442   // The text isn't selected and not changed because of 'SetProperty( DevelTextEditor::Property::ENABLE_SHIFT_SELECTION, false )'
2443   DALI_TEST_EQUALS( "Hello\nld\nHello lo\nworld", editor.GetProperty<std::string>( TextEditor::Property::TEXT ), TEST_LOCATION );
2444
2445   // Test to select some text in the left of the current cursor position
2446   application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_SHIFT_LEFT, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2447   application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_LEFT, KEY_SHIFT_MODIFIER, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2448   application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_LEFT, KEY_SHIFT_MODIFIER, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2449   application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_LEFT, KEY_SHIFT_MODIFIER, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2450
2451   // Render and notify
2452   application.SendNotification();
2453   application.Render();
2454
2455   // Copy the selected text
2456   application.ProcessEvent( GenerateKey( "", "", "", Dali::DevelKey::DALI_KEY_CONTROL_LEFT, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2457   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 ) );
2458
2459   // Render and notify
2460   application.SendNotification();
2461   application.Render();
2462
2463   // The text is not selected and not changed because of 'SetProperty( DevelTextEditor::Property::ENABLE_SHIFT_SELECTION, false )'
2464   DALI_TEST_EQUALS( "Hello\nld\nHello lo\nworld", editor.GetProperty<std::string>( TextEditor::Property::TEXT ), TEST_LOCATION );
2465
2466   // Select all Text
2467   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 ) );
2468
2469   // Render and notify
2470   application.SendNotification();
2471   application.Render();
2472
2473   // replace text with "c"
2474   application.ProcessEvent( GenerateKey( "c", "", "c", KEY_C_CODE, 0, 0, Integration::KeyEvent::DOWN, "c", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2475
2476   // Render and notify
2477   application.SendNotification();
2478   application.Render();
2479
2480   //text is "c"
2481   DALI_TEST_EQUALS( "c", editor.GetProperty<std::string>( TextEditor::Property::TEXT ), TEST_LOCATION );
2482
2483   // select all text
2484   DevelTextEditor::SelectWholeText(editor);
2485
2486   // Render and notify
2487   application.SendNotification();
2488   application.Render();
2489
2490   // Copy the selected text using logical keys
2491   application.ProcessEvent( GenerateKey( "", "", "", Dali::DevelKey::DALI_KEY_CONTROL_LEFT, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2492   application.ProcessEvent( GenerateKey( "ؤ", "c", "ؤ", KEY_C_CODE, KEY_CONTROL_MODIFIER, 0, Integration::KeyEvent::DOWN, "c", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2493
2494   // Render and notify
2495   application.SendNotification();
2496   application.Render();
2497
2498   // select none
2499   DevelTextEditor::SelectNone(editor);
2500
2501   // Render and notify
2502   application.SendNotification();
2503   application.Render();
2504
2505   // Paste the selected using logical keys
2506   application.ProcessEvent( GenerateKey( "", "", "", Dali::DevelKey::DALI_KEY_CONTROL_LEFT, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2507   application.ProcessEvent( GenerateKey( "ر", "v", "ر", KEY_V_CODE, KEY_CONTROL_MODIFIER, 0, Integration::KeyEvent::DOWN, "v", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2508
2509   //text is "cc"
2510   DALI_TEST_EQUALS( "cc", editor.GetProperty<std::string>( TextEditor::Property::TEXT ), TEST_LOCATION );
2511
2512   // select all using logical keys
2513   application.ProcessEvent( GenerateKey( "", "", "", Dali::DevelKey::DALI_KEY_CONTROL_LEFT, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2514   application.ProcessEvent( GenerateKey( "ش", "a", "ش", KEY_A_CODE, KEY_CONTROL_MODIFIER, 0, Integration::KeyEvent::DOWN, "a", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2515
2516   // Render and notify
2517   application.SendNotification();
2518   application.Render();
2519
2520   // cut text using logical keys
2521   application.ProcessEvent( GenerateKey( "", "", "", Dali::DevelKey::DALI_KEY_CONTROL_LEFT, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2522   application.ProcessEvent( GenerateKey( "ء", "x", "ء", KEY_X_CODE, KEY_CONTROL_MODIFIER, 0, Integration::KeyEvent::DOWN, "x", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2523
2524   // Render and notify
2525   application.SendNotification();
2526   application.Render();
2527
2528   //text is ""
2529   DALI_TEST_EQUALS( "", editor.GetProperty<std::string>( TextEditor::Property::TEXT ), TEST_LOCATION );
2530
2531   END_TEST;
2532 }
2533
2534 int utcDaliTextEditorEvent08(void)
2535 {
2536   ToolkitTestApplication application;
2537   tet_infoline(" utcDaliTextEditorEvent08");
2538
2539   // Checks if the highlight actor is released correctly.
2540
2541   TextEditor editor = TextEditor::New();
2542   DALI_TEST_CHECK( editor );
2543
2544   application.GetScene().Add( editor );
2545
2546   editor.SetProperty( TextEditor::Property::TEXT, "DALi" );
2547   editor.SetProperty( TextEditor::Property::POINT_SIZE, 10.f );
2548   editor.SetProperty( Actor::Property::SIZE, Vector2( 100.f, 50.f ) );
2549   editor.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT );
2550   editor.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT );
2551
2552   // Avoid a crash when core load gl resources.
2553   application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
2554
2555   // Render and notify
2556   application.SendNotification();
2557   application.Render();
2558
2559   // Tap on the text editor
2560   TestGenerateTap( application, 3.0f, 25.0f );
2561
2562   // Render and notify
2563   application.SendNotification();
2564   application.Render();
2565
2566   // When the left selection handle and the right selection handle are at the same position, the highlight box should be deactivated.
2567   // Test to select some text in the left of the current cursor position
2568   application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_SHIFT_LEFT, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2569   application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_LEFT, KEY_SHIFT_MODIFIER, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2570   application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_LEFT, KEY_SHIFT_MODIFIER, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2571   application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_LEFT, KEY_SHIFT_MODIFIER, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2572
2573   // Render and notify
2574   application.SendNotification();
2575   application.Render();
2576
2577   // Test to the left selection handle position and the right selection handle position
2578   application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_SHIFT_LEFT, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2579   application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_RIGHT, KEY_SHIFT_MODIFIER, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2580   application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_RIGHT, KEY_SHIFT_MODIFIER, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2581   application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_RIGHT, KEY_SHIFT_MODIFIER, 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   // Test to select full text in the left of the current cursor position
2588   application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_SHIFT_LEFT, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2589   application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_LEFT, KEY_SHIFT_MODIFIER, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2590   application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_LEFT, KEY_SHIFT_MODIFIER, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2591   application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_LEFT, KEY_SHIFT_MODIFIER, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2592   application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_LEFT, KEY_SHIFT_MODIFIER, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2593   application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_LEFT, KEY_SHIFT_MODIFIER, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2594
2595   // Render and notify
2596   application.SendNotification();
2597   application.Render();
2598
2599   // Test to release the current full text selection
2600   application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_LEFT, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2601   application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_LEFT, 0, 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 to move the current cursor position correctly
2608   application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_RIGHT, 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( "d", "", "d", KEY_D_CODE, 0, 0, Integration::KeyEvent::DOWN, "d", 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( "DdALi", 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
2628   // Render and notify
2629   application.SendNotification();
2630   application.Render();
2631
2632   // Test the cursor position with right arrow key
2633   application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_RIGHT, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2634
2635   // Render and notify
2636   application.SendNotification();
2637   application.Render();
2638
2639   // Add a character
2640   application.ProcessEvent( GenerateKey( "c", "", "c", KEY_C_CODE, 0, 0, Integration::KeyEvent::DOWN, "c", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2641
2642   // Render and notify
2643   application.SendNotification();
2644   application.Render();
2645
2646   DALI_TEST_EQUALS( "DdALci", editor.GetProperty<std::string>( TextEditor::Property::TEXT ), TEST_LOCATION );
2647
2648   // Test to select some text in the left of the current cursor position
2649   application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_SHIFT_LEFT, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2650   application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_LEFT, KEY_SHIFT_MODIFIER, 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 left arrow key
2660   application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_LEFT, 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( "DcdALci", editor.GetProperty<std::string>( TextEditor::Property::TEXT ), TEST_LOCATION );
2674
2675   // Test to select some text in the right of the current cursor position
2676   application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_SHIFT_LEFT, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2677   application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_RIGHT, KEY_SHIFT_MODIFIER, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2678   application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_RIGHT, KEY_SHIFT_MODIFIER, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2679   application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_RIGHT, KEY_SHIFT_MODIFIER, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2680
2681   // Render and notify
2682   application.SendNotification();
2683   application.Render();
2684
2685   // Test the cursor position with left arrow key
2686   application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_LEFT, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2687
2688   // Render and notify
2689   application.SendNotification();
2690   application.Render();
2691
2692   // Add a character
2693   application.ProcessEvent( GenerateKey( "x", "", "x", KEY_X_CODE, 0, 0, Integration::KeyEvent::DOWN, "x", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2694
2695   // Render and notify
2696   application.SendNotification();
2697   application.Render();
2698
2699   DALI_TEST_EQUALS( "DcxdALci", editor.GetProperty<std::string>( TextEditor::Property::TEXT ), TEST_LOCATION );
2700
2701   // Test to select some text in the left of the current cursor position
2702   application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_SHIFT_LEFT, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2703   application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_LEFT, KEY_SHIFT_MODIFIER, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2704   application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_LEFT, KEY_SHIFT_MODIFIER, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2705   application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_LEFT, KEY_SHIFT_MODIFIER, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2706
2707   // Render and notify
2708   application.SendNotification();
2709   application.Render();
2710
2711   // Test the cursor position with right arrow key
2712   application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_RIGHT, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2713
2714   // Render and notify
2715   application.SendNotification();
2716   application.Render();
2717
2718   // Add a character
2719   application.ProcessEvent( GenerateKey( "c", "", "c", KEY_C_CODE, 0, 0, Integration::KeyEvent::DOWN, "c", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2720
2721   // Render and notify
2722   application.SendNotification();
2723   application.Render();
2724
2725   DALI_TEST_EQUALS( "DcxcdALci", editor.GetProperty<std::string>( TextEditor::Property::TEXT ), TEST_LOCATION );
2726
2727   END_TEST;
2728 }
2729
2730 int utcDaliTextEditorHandles(void)
2731 {
2732   ToolkitTestApplication application;
2733   tet_infoline(" utcDaliTextEditorHandles");
2734
2735   TextEditor editor = TextEditor::New();
2736   DALI_TEST_CHECK( editor );
2737
2738   application.GetScene().Add( editor );
2739
2740   editor.SetProperty( TextEditor::Property::TEXT, "This is a long text for the size of the text-editor." );
2741   editor.SetProperty( TextEditor::Property::POINT_SIZE, 10.f );
2742   editor.SetProperty( TextEditor::Property::GRAB_HANDLE_IMAGE, HANDLE_IMAGE_FILE_NAME );
2743   editor.SetProperty( TextEditor::Property::SMOOTH_SCROLL, true );
2744
2745   editor.SetProperty( TextEditor::Property::SELECTION_HANDLE_IMAGE_LEFT, Property::Map{ {"filename", HANDLE_LEFT_SELECTION_FILE_NAME } } );
2746   editor.SetProperty( TextEditor::Property::SELECTION_HANDLE_IMAGE_RIGHT, Property::Map{ {"filename", HANDLE_LEFT_SELECTION_FILE_NAME } } );
2747   editor.SetProperty( TextEditor::Property::SELECTION_HANDLE_PRESSED_IMAGE_LEFT, Property::Map{ {"filename", HANDLE_RIGHT_SELECTION_FILE_NAME } } );
2748   editor.SetProperty( TextEditor::Property::SELECTION_HANDLE_PRESSED_IMAGE_RIGHT, Property::Map{ {"filename", HANDLE_RIGHT_SELECTION_FILE_NAME } } );
2749
2750   editor.SetProperty( Actor::Property::SIZE, Vector2( 30.f, 500.f ) );
2751   editor.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT );
2752   editor.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT );
2753
2754   // Avoid a crash when core load gl resources.
2755   application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
2756
2757   // Render and notify
2758   application.SendNotification();
2759   application.Render();
2760
2761   // Tap first to get the focus.
2762   TestGenerateTap( application, 3.0f, 25.0f, 100 );
2763
2764   // Render and notify
2765   application.SendNotification();
2766   application.Render();
2767
2768   // Tap to create the grab handle.
2769   TestGenerateTap( application, 3.0f, 25.0f, 700 );
2770
2771   // Render and notify
2772   application.SendNotification();
2773   application.Render();
2774
2775   // Get the active layer where the text's decoration is added.
2776   Actor activeLayer = editor.GetChildAt( 1u );
2777
2778   // Get the handle's actor.
2779   Actor handle = activeLayer.GetChildAt( 1u );
2780   handle.SetProperty( Actor::Property::SIZE, Vector2( 100.f, 100.f ) );
2781
2782   // Render and notify
2783   application.SendNotification();
2784   application.Render();
2785
2786   // Touch the grab handle to set it as pressed.
2787   Vector2 touchPos( 10.0f, 50.0f );
2788   Dali::Integration::TouchEvent event;
2789   event = Dali::Integration::TouchEvent();
2790   event.AddPoint( GetPointDownInside( touchPos ) );
2791   application.ProcessEvent( event );
2792
2793   // Render and notify
2794   application.SendNotification();
2795   application.Render();
2796
2797   // Pan the grab handle
2798   uint32_t time = 100;
2799   TestStartPan( application, Vector2(10.0f, 50.0f), Vector2(10.0f, 50.0f), time );
2800   TestMovePan( application, Vector2(10.0f, 30.0f), time );
2801   TestEndPan( application, Vector2(10.0f, 50.0f), time);
2802   application.SendNotification();
2803   application.Render();
2804
2805
2806   // Release the grab handle.
2807   event = Dali::Integration::TouchEvent();
2808   event.AddPoint( GetPointUpInside( touchPos ) );
2809   application.ProcessEvent( event );
2810
2811   // Render and notify
2812   application.SendNotification();
2813   application.Render();
2814
2815   // Tap first to get the focus.
2816   TestGenerateTap( application, 3.0f, 25.0f, 1400 );
2817
2818   // Render and notify
2819   application.SendNotification();
2820   application.Render();
2821
2822   // Double tap to select a word and create the selection handles.
2823   TestGenerateTap( application, 3.0f, 25.0f, 1500 );
2824
2825   // Render and notify
2826   application.SendNotification();
2827   application.Render();
2828
2829   touchPos = Vector2( 10.0f, 50.0f );
2830
2831   // Touch the left selection handle to set it as pressed.
2832   event = Dali::Integration::TouchEvent();
2833   event.AddPoint( GetPointDownInside( touchPos ) );
2834   application.ProcessEvent( event );
2835
2836   // Render and notify
2837   application.SendNotification();
2838   application.Render();
2839
2840   // Release the left selection handle.
2841   event = Dali::Integration::TouchEvent();
2842   event.AddPoint( GetPointUpInside( touchPos ) );
2843   application.ProcessEvent( event );
2844
2845   // Render and notify
2846   application.SendNotification();
2847   application.Render();
2848
2849   END_TEST;
2850 }
2851
2852 int utcDaliTextEditorUnderPropertyStringP(void)
2853 {
2854   ToolkitTestApplication application;
2855   tet_infoline(" utcDaliTextEditorUnderPropertyStringP");
2856   TextEditor editor = TextEditor::New();
2857   DALI_TEST_CHECK( editor );
2858
2859   std::string underlineSettings1( "{\"enable\":\"true\",\"color\":\"red\",\"height\":\"1\"}" );
2860
2861   application.GetScene().Add( editor );
2862
2863   editor.SetProperty( TextEditor::Property::UNDERLINE, underlineSettings1 );
2864   DALI_TEST_EQUALS( editor.GetProperty<std::string>( TextEditor::Property::UNDERLINE ), underlineSettings1, TEST_LOCATION );
2865
2866   tet_infoline("Set underline settings with a map");
2867   // Check the input underline property
2868   Property::Map underlineMapSet;
2869   Property::Map underlineMapGet;
2870   underlineMapSet.Insert( "enable", true );
2871   underlineMapSet.Insert( "color", Color::BLUE );
2872   underlineMapSet.Insert( "height", 2 );
2873
2874   editor.SetProperty( TextEditor::Property::UNDERLINE, underlineMapSet );
2875   underlineMapGet = editor.GetProperty<Property::Map>( TextEditor::Property::UNDERLINE );
2876   DALI_TEST_EQUALS( underlineMapGet.Count(), underlineMapSet.Count(), TEST_LOCATION );
2877   DALI_TEST_EQUALS( DaliTestCheckMaps( underlineMapSet, underlineMapGet ), true,  TEST_LOCATION );
2878
2879   tet_infoline("Set underline settings with a string");
2880   editor.SetProperty( TextEditor::Property::UNDERLINE, underlineSettings1 );
2881   Property::Value value = editor.GetProperty( TextEditor::Property::UNDERLINE );
2882   std::string result;
2883   value.Get(result);
2884   DALI_TEST_EQUALS( result , underlineSettings1, TEST_LOCATION  );
2885
2886   tet_infoline("Trying to set invalid underline settings, should not update and stay at previous settings");
2887   std::string underlineSettingsVoid( "{\"enable\":\"true\",\"coooolor\":\"blue\",\"heeeight\":\"4\"}" );
2888   editor.SetProperty( TextEditor::Property::UNDERLINE, underlineSettingsVoid );
2889   value = editor.GetProperty( TextEditor::Property::UNDERLINE );
2890   value.Get(result);
2891   DALI_TEST_EQUALS( result , underlineSettings1, TEST_LOCATION  );
2892
2893   END_TEST;
2894 }
2895
2896 int utcDaliTextEditorStrikethroughPropertyStringP(void)
2897 {
2898   ToolkitTestApplication application;
2899   tet_infoline(" utcDaliTextEditorStrikethroughPropertyStringP");
2900   TextEditor editor = TextEditor::New();
2901   DALI_TEST_CHECK( editor );
2902
2903   std::string strikethroughSettings1( "{\"enable\":\"true\",\"color\":\"red\",\"height\":\"2\"}" );
2904
2905   application.GetScene().Add( editor );
2906
2907   editor.SetProperty( DevelTextEditor::Property::STRIKETHROUGH, strikethroughSettings1 );
2908   DALI_TEST_EQUALS( editor.GetProperty<std::string>( DevelTextEditor::Property::STRIKETHROUGH ), strikethroughSettings1, TEST_LOCATION );
2909
2910   tet_infoline("Set strikethrough settings with a map");
2911   // Check the input strikethrough property
2912   Property::Map strikethroughMapSet;
2913   Property::Map strikethroughMapGet;
2914   strikethroughMapSet.Insert( "enable", true );
2915   strikethroughMapSet.Insert( "color", Color::BLUE );
2916   strikethroughMapSet.Insert( "height", 2.0f );
2917
2918   editor.SetProperty( DevelTextEditor::Property::STRIKETHROUGH, strikethroughMapSet );
2919   strikethroughMapGet = editor.GetProperty<Property::Map>( DevelTextEditor::Property::STRIKETHROUGH );
2920   DALI_TEST_EQUALS( strikethroughMapGet.Count(), strikethroughMapSet.Count(), TEST_LOCATION );
2921   DALI_TEST_EQUALS( DaliTestCheckMaps( strikethroughMapSet, strikethroughMapGet ), true,  TEST_LOCATION );
2922
2923   tet_infoline("Set strikethrough settings with a string");
2924   editor.SetProperty( DevelTextEditor::Property::STRIKETHROUGH, strikethroughSettings1 );
2925   Property::Value value = editor.GetProperty( DevelTextEditor::Property::STRIKETHROUGH );
2926   std::string result;
2927   value.Get(result);
2928   DALI_TEST_EQUALS( result , strikethroughSettings1, TEST_LOCATION  );
2929
2930   tet_infoline("Trying to set invalid strikethrough settings, should not update and stay at previous settings");
2931   std::string strikethroughSettingsVoid( "{\"enable\":\"true\",\"coooolor\":\"blue\",\"height\":\"2\"}" );
2932   editor.SetProperty( DevelTextEditor::Property::STRIKETHROUGH, strikethroughSettingsVoid );
2933   value = editor.GetProperty( TextEditor::Property::UNDERLINE );
2934   value.Get(result);
2935   DALI_TEST_EQUALS( result , strikethroughSettings1, TEST_LOCATION  );
2936
2937   END_TEST;
2938 }
2939
2940 int utcDaliTextEditorShadowPropertyStringP(void)
2941 {
2942   ToolkitTestApplication application;
2943   tet_infoline(" utcDaliTextEditorUnderPropertyStringP Setting Shadow propeties by string");
2944
2945   TextEditor editor = TextEditor::New();
2946
2947   std::string shadowSettings( "{\"color\":\"green\",\"offset\":\"2 2\",\"blurRadius\":\"0\"}" );
2948
2949   application.GetScene().Add( editor );
2950
2951   editor.SetProperty( TextEditor::Property::SHADOW, "{\"color\":\"green\",\"offset\":\"2 2\",\"blurRadius\":\"0\"}" );
2952
2953   Property::Value value = editor.GetProperty<std::string>( TextEditor::Property::SHADOW );
2954   std::string result;
2955   value.Get(result);
2956
2957   DALI_TEST_EQUALS( result, shadowSettings, TEST_LOCATION );
2958
2959   END_TEST;
2960 }
2961
2962 int utcDaliTextEditorFontStylePropertyStringP(void)
2963 {
2964   ToolkitTestApplication application;
2965   tet_infoline(" utcDaliTextEditorFontStylePropertyStringP Setting FontStyle propeties by string");
2966
2967   TextEditor editor = TextEditor::New();
2968
2969   std::string fontStyleSettings( "{\"weight\":\"bold\",\"width\":\"condensed\",\"slant\":\"italic\"}" );
2970
2971   application.GetScene().Add( editor );
2972
2973   editor.SetProperty( TextEditor::Property::FONT_STYLE, "{\"weight\":\"bold\",\"width\":\"condensed\",\"slant\":\"italic\"}" );
2974
2975   Property::Value value = editor.GetProperty<std::string>( TextEditor::Property::FONT_STYLE );
2976   std::string result;
2977   value.Get(result);
2978
2979   DALI_TEST_EQUALS( result, fontStyleSettings, TEST_LOCATION );
2980
2981   END_TEST;
2982 }
2983
2984 int utcDaliTextEditorGetPropertyLinecountP(void)
2985 {
2986   ToolkitTestApplication application;
2987
2988   tet_infoline(" utcDaliTextEditorGetPropertyLinecount getting line count property");
2989
2990   int lineCount =0 ;
2991
2992   TextEditor editor = TextEditor::New();
2993   editor.SetProperty( TextEditor::Property::POINT_SIZE, 10) ;
2994   editor.SetProperty( TextEditor::Property::TEXT,
2995                        "TEST TEST TEST TEST TEST TEST TEST TEST TEST TEST TEST TEST TEST TEST ");
2996
2997   application.GetScene().Add( editor );
2998
2999   editor.SetProperty( Actor::Property::SIZE, Vector2( 100.f, 100.f ) );
3000   lineCount =  editor.GetProperty<int>( TextEditor::Property::LINE_COUNT );
3001   DALI_TEST_EQUALS( lineCount, 14, TEST_LOCATION );
3002
3003   editor.SetProperty( Actor::Property::SIZE, Vector2( 50.f, 100.f ) );
3004   lineCount =  editor.GetProperty<int>( TextEditor::Property::LINE_COUNT );
3005   DALI_TEST_EQUALS( lineCount, 28, TEST_LOCATION );
3006
3007   END_TEST;
3008 }
3009
3010 int utcDaliTextEditorScrollStateChangedSignalTest(void)
3011 {
3012
3013   ToolkitTestApplication application;
3014   tet_infoline(" UtcDaliTextEditorScrollStateChangedSignalTest");
3015
3016   TextEditor editor = TextEditor::New();
3017   DALI_TEST_CHECK( editor );
3018
3019   application.GetScene().Add( editor );
3020
3021   editor.SetProperty( TextEditor::Property::POINT_SIZE, 10.f );
3022   editor.SetProperty( Actor::Property::SIZE, Vector2( 50.f, 50.f ) );
3023   editor.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT );
3024   editor.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT );
3025   editor.SetProperty( TextEditor::Property::ENABLE_SCROLL_BAR, true );
3026   editor.SetProperty( Actor::Property::KEYBOARD_FOCUSABLE,true);
3027
3028   bool startedCalled = false;
3029   bool finishedCalled = false;
3030
3031   ScrollStateChangeCallback callback( startedCalled, finishedCalled );
3032   editor.ScrollStateChangedSignal().Connect( &callback, &ScrollStateChangeCallback::Callback );
3033
3034   KeyboardFocusManager::Get().SetCurrentFocusActor( editor );
3035
3036   // Render and notify
3037   application.SendNotification();
3038   application.Render();
3039
3040   editor.SetProperty( TextEditor::Property::TEXT, "Long enough message for TextEditor!");
3041   application.SendNotification();
3042   application.Render(6000);
3043
3044   application.SendNotification();
3045   DALI_TEST_EQUALS( startedCalled, true, TEST_LOCATION );
3046   DALI_TEST_EQUALS( finishedCalled, true, TEST_LOCATION );
3047
3048   END_TEST;
3049 }
3050
3051 int UtcDaliToolkitTextEditorTextWrapMode(void)
3052 {
3053   ToolkitTestApplication application;
3054   tet_infoline(" UtcDaliToolkitTextEditorTextWarpMode");
3055
3056   int lineCount =0 ;
3057
3058   TextEditor editor = TextEditor::New();
3059   editor.SetProperty( Actor::Property::SIZE, Vector2( 150.0f, 300.f ) );
3060   editor.SetProperty( TextEditor::Property::TEXT, "Hello world Hello world" );
3061
3062   application.GetScene().Add( editor );
3063
3064   editor.SetProperty( TextEditor::Property::LINE_WRAP_MODE, "WORD" );
3065   DALI_TEST_EQUALS( editor.GetProperty< int >( TextEditor::Property::LINE_WRAP_MODE ), static_cast< int >( Text::LineWrap::WORD ), TEST_LOCATION );
3066
3067   application.SendNotification();
3068   application.Render();
3069
3070   lineCount =  editor.GetProperty<int>( TextEditor::Property::LINE_COUNT );
3071   DALI_TEST_EQUALS( lineCount, 4, TEST_LOCATION );
3072
3073   editor.SetProperty( TextEditor::Property::LINE_WRAP_MODE, "CHARACTER" );
3074   DALI_TEST_EQUALS( editor.GetProperty< int >( TextEditor::Property::LINE_WRAP_MODE ), static_cast< int >( Text::LineWrap::CHARACTER ), TEST_LOCATION );
3075
3076   application.SendNotification();
3077   application.Render();
3078
3079   lineCount =  editor.GetProperty<int>( TextEditor::Property::LINE_COUNT );
3080   DALI_TEST_EQUALS( lineCount, 3, TEST_LOCATION );
3081
3082   editor.SetProperty( TextEditor::Property::LINE_WRAP_MODE, Text::LineWrap::WORD );
3083   DALI_TEST_EQUALS( editor.GetProperty< int >( TextEditor::Property::LINE_WRAP_MODE ), static_cast< int >( Text::LineWrap::WORD ), TEST_LOCATION );
3084
3085   application.SendNotification();
3086   application.Render();
3087
3088   lineCount =  editor.GetProperty<int>( TextEditor::Property::LINE_COUNT );
3089   DALI_TEST_EQUALS( lineCount, 4, TEST_LOCATION );
3090
3091   editor.SetProperty( TextEditor::Property::LINE_WRAP_MODE, Text::LineWrap::CHARACTER );
3092   DALI_TEST_EQUALS( editor.GetProperty< int >( TextEditor::Property::LINE_WRAP_MODE ), static_cast< int >( Text::LineWrap::CHARACTER ), TEST_LOCATION );
3093
3094   application.SendNotification();
3095   application.Render();
3096
3097   lineCount =  editor.GetProperty<int>( TextEditor::Property::LINE_COUNT );
3098   DALI_TEST_EQUALS( lineCount, 3, TEST_LOCATION );
3099
3100   END_TEST;
3101 }
3102
3103 int UtcDaliTextEditorSetPaddingProperty(void)
3104 {
3105   ToolkitTestApplication application;
3106   tet_infoline("UtcDaliTextEditorSetPaddingProperty\n");
3107
3108   TextEditor editor = TextEditor::New();
3109   DALI_TEST_CHECK( editor );
3110   editor.SetProperty( Actor::Property::SIZE, Vector2( 300.f, 50.f ) );
3111   editor.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT );
3112   editor.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT );
3113   application.GetScene().Add( editor );
3114
3115   application.SendNotification();
3116   application.Render();
3117
3118   Vector3 originalSize = editor.GetNaturalSize();
3119
3120   editor.SetProperty( Toolkit::Control::Property::PADDING, Extents( 10, 10, 10, 10 ) );
3121
3122   application.SendNotification();
3123   application.Render();
3124
3125   DALI_TEST_EQUALS( editor.GetProperty<Extents>( Toolkit::Control::Property::PADDING ), Extents( 10, 10, 10, 10 ), TEST_LOCATION );
3126
3127   Vector3 paddingAddedSize = editor.GetNaturalSize();
3128
3129   DALI_TEST_EQUALS( originalSize.width + 10 + 10 , paddingAddedSize.width, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
3130
3131   DALI_TEST_EQUALS( originalSize.height + 10 + 10 , paddingAddedSize.height, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
3132
3133   END_TEST;
3134 }
3135
3136 int UtcDaliTextEditorEnableShiftSelectionProperty(void)
3137 {
3138   ToolkitTestApplication application;
3139   tet_infoline("UtcDaliTextEditorEnableShiftSelectionProperty");
3140
3141   TextEditor editor = TextEditor::New();
3142   DALI_TEST_CHECK( editor );
3143   editor.SetProperty( Actor::Property::SIZE, Vector2( 300.f, 50.f ) );
3144   editor.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT );
3145   editor.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT );
3146   application.GetScene().Add( editor );
3147
3148   application.SendNotification();
3149   application.Render();
3150
3151   // The default value of ENABLE_SHIFT_SELECTION is 'true'.
3152   DALI_TEST_EQUALS( editor.GetProperty<bool>( DevelTextEditor::Property::ENABLE_SHIFT_SELECTION ), true, TEST_LOCATION );
3153
3154   // Check the enable shift selection property
3155   editor.SetProperty( DevelTextEditor::Property::ENABLE_SHIFT_SELECTION, false );
3156   DALI_TEST_EQUALS( editor.GetProperty<bool>( DevelTextEditor::Property::ENABLE_SHIFT_SELECTION ), false, TEST_LOCATION );
3157
3158   application.SendNotification();
3159   application.Render();
3160
3161   END_TEST;
3162 }
3163
3164 int UtcDaliTextEditorEnableGrabHandleProperty(void)
3165 {
3166   ToolkitTestApplication application;
3167   tet_infoline("UtcDaliTextEditorEnableGrabHandleProperty");
3168
3169   TextEditor editor = TextEditor::New();
3170   DALI_TEST_CHECK( editor );
3171   editor.SetProperty( Actor::Property::SIZE, Vector2( 300.f, 50.f ) );
3172   editor.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT );
3173   editor.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT );
3174   application.GetScene().Add( editor );
3175
3176   application.SendNotification();
3177   application.Render();
3178
3179   // The default value of ENABLE_GRAB_HANDLE is 'true'.
3180   DALI_TEST_EQUALS( editor.GetProperty<bool>( DevelTextEditor::Property::ENABLE_GRAB_HANDLE ), true, TEST_LOCATION );
3181
3182   // Check the enable grab handle property
3183   editor.SetProperty( DevelTextEditor::Property::ENABLE_GRAB_HANDLE, false );
3184   DALI_TEST_EQUALS( editor.GetProperty<bool>( DevelTextEditor::Property::ENABLE_GRAB_HANDLE ), false, TEST_LOCATION );
3185
3186   application.SendNotification();
3187   application.Render();
3188
3189   END_TEST;
3190 }
3191
3192 int UtcDaliTextEditorMatchSystemLanguageDirectionProperty(void)
3193 {
3194   ToolkitTestApplication application;
3195   tet_infoline("UtcDaliTextEditorMatchSystemLanguageDirectionProperty");
3196
3197   TextEditor editor = TextEditor::New();
3198   DALI_TEST_CHECK( editor );
3199   editor.SetProperty( Actor::Property::SIZE, Vector2( 300.f, 50.f ) );
3200   editor.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT );
3201   editor.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT );
3202   application.GetScene().Add( editor );
3203
3204   application.SendNotification();
3205   application.Render();
3206
3207   // The default value of MATCH_SYSTEM_LANGUAGE_DIRECTION is 'true'.
3208   DALI_TEST_EQUALS( editor.GetProperty<bool>( DevelTextEditor::Property::MATCH_SYSTEM_LANGUAGE_DIRECTION ), true, TEST_LOCATION );
3209
3210   // Check the disable match system language direction property
3211   editor.SetProperty( DevelTextEditor::Property::MATCH_SYSTEM_LANGUAGE_DIRECTION, false );
3212   DALI_TEST_EQUALS( editor.GetProperty<bool>( DevelTextEditor::Property::MATCH_SYSTEM_LANGUAGE_DIRECTION ), false, TEST_LOCATION );
3213
3214   application.SendNotification();
3215   application.Render();
3216
3217   END_TEST;
3218 }
3219
3220 int UtcDaliTextEditorGetInputMethodContext(void)
3221 {
3222   ToolkitTestApplication application;
3223   tet_infoline("UtcDaliTextEditorGetInputMethodContext");
3224
3225   TextEditor editor = TextEditor::New();
3226   DALI_TEST_CHECK( DevelTextEditor::GetInputMethodContext( editor ) );
3227
3228   END_TEST;
3229 }
3230
3231 int utcDaliTextEditorMaxCharactersReached(void)
3232 {
3233   ToolkitTestApplication application;
3234   tet_infoline("utcDaliTextEditorMaxCharactersReached");
3235
3236   TextEditor editor = TextEditor::New();
3237   DALI_TEST_CHECK( editor );
3238
3239   application.GetScene().Add( editor );
3240
3241   const int maxNumberOfCharacters = 1;
3242   editor.SetProperty( DevelTextEditor::Property::MAX_LENGTH, maxNumberOfCharacters );
3243   DALI_TEST_EQUALS( editor.GetProperty<int>( DevelTextEditor::Property::MAX_LENGTH ), maxNumberOfCharacters, TEST_LOCATION );
3244
3245   editor.SetKeyInputFocus();
3246
3247   // connect to the text changed signal.
3248   ConnectionTracker* testTracker = new ConnectionTracker();
3249   DevelTextEditor::MaxLengthReachedSignal( editor ).Connect(&TestMaxLengthReachedCallback);
3250   bool maxLengthReachedSignal = false;
3251   editor.ConnectSignal( testTracker, "maxLengthReached", CallbackFunctor(&maxLengthReachedSignal) );
3252
3253   gMaxCharactersCallBackCalled = false;
3254
3255   application.ProcessEvent( GenerateKey( "a", "", "a", KEY_A_CODE, 0, 0, Integration::KeyEvent::DOWN, "a", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
3256   application.ProcessEvent( GenerateKey( "a", "", "a", KEY_A_CODE, 0, 0, Integration::KeyEvent::DOWN, "a", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
3257
3258   DALI_TEST_CHECK( gMaxCharactersCallBackCalled );
3259   DALI_TEST_CHECK( maxLengthReachedSignal );
3260
3261   END_TEST;
3262 }
3263
3264 int utcDaliTextEditorInputFiltered(void)
3265 {
3266   ToolkitTestApplication application;
3267   tet_infoline(" utcDaliTextEditorInputFiltered");
3268   TextEditor editor = TextEditor::New();
3269   DALI_TEST_CHECK(editor);
3270
3271   application.GetScene().Add(editor);
3272
3273   Property::Map inputFilter;
3274
3275   // Only digit is accepted.
3276   inputFilter[InputFilter::Property::ACCEPTED] = "[\\d]";
3277
3278   // Set input filter to TextEditor.
3279   editor.SetProperty(DevelTextEditor::Property::INPUT_FILTER, inputFilter);
3280
3281   editor.SetKeyInputFocus();
3282
3283   // connect to the input filtered signal.
3284   ConnectionTracker* testTracker = new ConnectionTracker();
3285   DevelTextEditor::InputFilteredSignal(editor).Connect(&TestInputFilteredCallback);
3286   bool inputFilteredSignal = false;
3287   editor.ConnectSignal(testTracker, "inputFiltered", CallbackFunctor(&inputFilteredSignal));
3288
3289   gInputFilteredAcceptedCallbackCalled = false;
3290
3291   application.ProcessEvent(GenerateKey( "a", "", "a", KEY_A_CODE, 0, 0, Integration::KeyEvent::DOWN, "a", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ));
3292
3293   DALI_TEST_CHECK(gInputFilteredAcceptedCallbackCalled);
3294   DALI_TEST_CHECK(inputFilteredSignal);
3295
3296   // Word is rejected.
3297   inputFilter[InputFilter::Property::ACCEPTED] = "";
3298   inputFilter[InputFilter::Property::REJECTED] = "[\\w]";
3299
3300   // Set input filter to TextEditor.
3301   editor.SetProperty(DevelTextEditor::Property::INPUT_FILTER, inputFilter);
3302
3303   editor.SetKeyInputFocus();
3304
3305   inputFilteredSignal = false;
3306   gInputFilteredRejectedCallbackCalled = false;
3307
3308   application.ProcessEvent(GenerateKey( "a", "", "a", KEY_A_CODE, 0, 0, Integration::KeyEvent::DOWN, "a", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
3309
3310   DALI_TEST_CHECK(gInputFilteredAcceptedCallbackCalled);
3311   DALI_TEST_CHECK(inputFilteredSignal);
3312
3313   END_TEST;
3314 }
3315
3316 int UtcDaliTextEditorSelectWholeText(void)
3317 {
3318   ToolkitTestApplication application;
3319   tet_infoline(" UtcDaliTextEditorSelectWholeText ");
3320
3321   TextEditor textEditor = TextEditor::New();
3322
3323   application.GetScene().Add( textEditor );
3324
3325   textEditor.SetProperty( Actor::Property::SIZE, Vector2( 300.f, 50.f ) );
3326   textEditor.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT );
3327   textEditor.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT );
3328
3329   // Avoid a crash when core load gl resources.
3330   application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
3331
3332   application.SendNotification();
3333   application.Render();
3334
3335   DALI_TEST_EQUALS( 1u, textEditor.GetChildCount(), TEST_LOCATION );
3336
3337   DevelTextEditor::SelectWholeText( textEditor );
3338
3339   application.SendNotification();
3340   application.Render();
3341
3342   // Nothing should have been selected. The number of children is still 1
3343   DALI_TEST_EQUALS( 1u, textEditor.GetChildCount(), TEST_LOCATION );
3344
3345   textEditor.SetProperty( TextEditor::Property::TEXT, "Hello world" );
3346
3347   application.SendNotification();
3348   application.Render();
3349
3350   DevelTextEditor::SelectWholeText( textEditor );
3351
3352   application.SendNotification();
3353   application.Render();
3354
3355   // Should be 2 children, the stencil and the layer
3356   DALI_TEST_EQUALS( 2u, textEditor.GetChildCount(), TEST_LOCATION );
3357
3358   // The offscreen root actor should have two actors: the renderer and the highlight actor.
3359   Actor stencil = textEditor.GetChildAt( 0u );
3360
3361   // The highlight actor is drawn first, so is the first actor in the list
3362   Renderer highlight = stencil.GetChildAt( 0u ).GetRendererAt( 0u );
3363   DALI_TEST_CHECK( highlight );
3364
3365   END_TEST;
3366 }
3367
3368 int UtcDaliTextEditorSelectText(void)
3369 {
3370   ToolkitTestApplication application;
3371   tet_infoline(" UtcDaliTextEditorSelectText ");
3372
3373   TextEditor textEditor = TextEditor::New();
3374
3375   application.GetScene().Add( textEditor );
3376
3377   textEditor.SetProperty( Actor::Property::SIZE, Vector2( 300.f, 50.f ) );
3378   textEditor.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT );
3379   textEditor.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT );
3380
3381   // Avoid a crash when core load gl resources.
3382   application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
3383
3384   application.SendNotification();
3385   application.Render();
3386
3387   DevelTextEditor::SelectText( textEditor ,0, 5 );
3388
3389   application.SendNotification();
3390   application.Render();
3391
3392   // Nothing is selected
3393   std::string selectedText = textEditor.GetProperty( DevelTextEditor::Property::SELECTED_TEXT ).Get<std::string>();
3394   DALI_TEST_EQUALS( "", selectedText, TEST_LOCATION );
3395
3396   textEditor.SetProperty( TextEditor::Property::TEXT, "Hello world" );
3397
3398   application.SendNotification();
3399   application.Render();
3400
3401   DevelTextEditor::SelectText( textEditor, 0, 5 );
3402
3403   application.SendNotification();
3404   application.Render();
3405
3406   selectedText = textEditor.GetProperty( DevelTextEditor::Property::SELECTED_TEXT ).Get<std::string>();
3407   DALI_TEST_EQUALS( "Hello", selectedText, TEST_LOCATION );
3408
3409   DALI_TEST_EQUALS( textEditor.GetProperty( DevelTextEditor::Property::SELECTED_TEXT_START ).Get<int>(), 0, TEST_LOCATION );
3410   DALI_TEST_EQUALS( textEditor.GetProperty( DevelTextEditor::Property::SELECTED_TEXT_END ).Get<int>(), 5, TEST_LOCATION );
3411
3412   // world is selected
3413   DevelTextEditor::SelectText( textEditor, 6, 11 );
3414
3415   application.SendNotification();
3416   application.Render();
3417
3418   selectedText = textEditor.GetProperty( DevelTextEditor::Property::SELECTED_TEXT ).Get<std::string>();
3419   DALI_TEST_EQUALS( "world", selectedText, TEST_LOCATION );
3420
3421   DALI_TEST_EQUALS( textEditor.GetProperty( DevelTextEditor::Property::SELECTED_TEXT_START ).Get<int>(), 6, TEST_LOCATION );
3422   DALI_TEST_EQUALS( textEditor.GetProperty( DevelTextEditor::Property::SELECTED_TEXT_END ).Get<int>(), 11, TEST_LOCATION );
3423
3424   END_TEST;
3425 }
3426
3427 int UtcDaliTextEditorSelectNone(void)
3428 {
3429   ToolkitTestApplication application;
3430   tet_infoline(" UtcDaliTextEditorSelectWholeText ");
3431
3432   TextEditor textEditor = TextEditor::New();
3433
3434   application.GetScene().Add( textEditor );
3435
3436   textEditor.SetProperty( Actor::Property::SIZE, Vector2( 300.f, 50.f ) );
3437   textEditor.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT );
3438   textEditor.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT );
3439
3440   // Avoid a crash when core load gl resources.
3441   application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
3442
3443   application.SendNotification();
3444   application.Render();
3445
3446   textEditor.SetProperty( TextEditor::Property::TEXT, "Hello world" );
3447
3448   application.SendNotification();
3449   application.Render();
3450
3451   // Nothing is selected
3452   std::string selectedText = textEditor.GetProperty( DevelTextEditor::Property::SELECTED_TEXT ).Get<std::string>();
3453   DALI_TEST_EQUALS( "", selectedText, TEST_LOCATION );
3454
3455   DevelTextEditor::SelectWholeText( textEditor );
3456
3457   application.SendNotification();
3458   application.Render();
3459
3460   // whole text is selected
3461   selectedText = textEditor.GetProperty( DevelTextEditor::Property::SELECTED_TEXT ).Get<std::string>();
3462   DALI_TEST_EQUALS( "Hello world", selectedText, TEST_LOCATION );
3463
3464   DevelTextEditor::SelectNone( textEditor );
3465
3466   application.SendNotification();
3467   application.Render();
3468
3469   // Nothing is selected
3470   selectedText = textEditor.GetProperty( DevelTextEditor::Property::SELECTED_TEXT ).Get<std::string>();
3471   DALI_TEST_EQUALS( "", selectedText, TEST_LOCATION );
3472
3473   END_TEST;
3474 }
3475
3476 int UtcDaliTextEditorSelectRange(void)
3477 {
3478   ToolkitTestApplication application;
3479   tet_infoline("utcDaliTextEditorSelectRange");
3480
3481   TextEditor textEditor = TextEditor::New();
3482   DALI_TEST_CHECK( textEditor );
3483
3484   application.GetScene().Add( textEditor );
3485
3486   // Avoid a crash when core load gl resources.
3487   application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
3488
3489   application.SendNotification();
3490   application.Render();
3491
3492   textEditor.SetProperty( TextEditor::Property::TEXT, "Hello world" );
3493
3494   textEditor.SetProperty( DevelTextEditor::Property::SELECTED_TEXT_START, 0 );
3495   textEditor.SetProperty( DevelTextEditor::Property::SELECTED_TEXT_END, 5 );
3496
3497   // Hello is selected
3498   std::string selectedText = textEditor.GetProperty( DevelTextEditor::Property::SELECTED_TEXT ).Get<std::string>();
3499   DALI_TEST_EQUALS( "Hello", selectedText, TEST_LOCATION );
3500
3501   DALI_TEST_EQUALS( textEditor.GetProperty( DevelTextEditor::Property::SELECTED_TEXT_START ).Get<int>(), 0, TEST_LOCATION );
3502   DALI_TEST_EQUALS( textEditor.GetProperty( DevelTextEditor::Property::SELECTED_TEXT_END ).Get<int>(), 5, TEST_LOCATION );
3503
3504   END_TEST;
3505 }
3506
3507 int UtcDaliTextEditorEnableEditing(void)
3508 {
3509   ToolkitTestApplication application;
3510   tet_infoline(" UtcDaliTextEditorEnableEditing ");
3511
3512   TextEditor textEditor = TextEditor::New();
3513
3514   application.GetScene().Add( textEditor );
3515
3516   textEditor.SetProperty( Actor::Property::SIZE, Vector2( 300.f, 50.f ) );
3517   textEditor.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT );
3518   textEditor.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT );
3519
3520   // Avoid a crash when core load gl resources.
3521   application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
3522
3523   application.SendNotification();
3524   application.Render();
3525
3526   textEditor.SetKeyInputFocus();
3527   textEditor.SetProperty( DevelTextEditor::Property::ENABLE_EDITING, false );
3528   application.ProcessEvent( GenerateKey( "D", "", "D", KEY_D_CODE, 0, 0, Integration::KeyEvent::DOWN, "D", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
3529
3530   // Render and notify
3531   application.SendNotification();
3532   application.Render();
3533
3534   DALI_TEST_EQUALS( textEditor.GetProperty( TextEditor::Property::TEXT ).Get<std::string>(), "", TEST_LOCATION );
3535   DALI_TEST_EQUALS( textEditor.GetProperty( DevelTextEditor::Property::ENABLE_EDITING ).Get<bool>(), false, TEST_LOCATION );
3536
3537   textEditor.SetKeyInputFocus();
3538   textEditor.SetProperty( DevelTextEditor::Property::ENABLE_EDITING, true );
3539   application.ProcessEvent( GenerateKey( "D", "", "D", KEY_D_CODE, 0, 0, Integration::KeyEvent::DOWN, "D", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
3540
3541   // Render and notify
3542   application.SendNotification();
3543   application.Render();
3544
3545   DALI_TEST_EQUALS( textEditor.GetProperty( TextEditor::Property::TEXT ).Get<std::string>(), "D", TEST_LOCATION );
3546   DALI_TEST_EQUALS( textEditor.GetProperty( DevelTextEditor::Property::ENABLE_EDITING ).Get<bool>(), true, TEST_LOCATION );
3547
3548   END_TEST;
3549 }
3550
3551 int UtcDaliTextEditorScrolling(void)
3552 {
3553   ToolkitTestApplication application;
3554   tet_infoline(" UtcDaliTextEditorScrolling ");
3555
3556   TextEditor textEditor = TextEditor::New();
3557   DALI_TEST_CHECK( textEditor );
3558
3559   application.GetScene().Add( textEditor );
3560
3561   // Avoid a crash when core load gl resources.
3562   application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
3563
3564   application.SendNotification();
3565   application.Render();
3566
3567   textEditor.SetProperty(TextEditor::Property::TEXT, "Tex1\nTex2\nTex3\nTex4\nTex5\nTex6\nTex7\nTex8");
3568   textEditor.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_CENTER);
3569   textEditor.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_CENTER);
3570   textEditor.SetProperty(Actor::Property::SIZE, Vector2(60.0f, 160.0f));
3571
3572   application.SendNotification();
3573   application.Render();
3574
3575   DALI_TEST_EQUALS( textEditor.GetProperty( DevelTextEditor::Property::VERTICAL_SCROLL_POSITION ).Get<float>(), 0.0f, TEST_LOCATION );
3576   DALI_TEST_EQUALS( textEditor.GetProperty( DevelTextEditor::Property::HORIZONTAL_SCROLL_POSITION ).Get<float>(), 0.0f, TEST_LOCATION );
3577
3578
3579   DevelTextEditor::ScrollBy(textEditor, Vector2(1.0f, 1.0f));
3580
3581   DALI_TEST_EQUALS( textEditor.GetProperty( DevelTextEditor::Property::VERTICAL_SCROLL_POSITION ).Get<float>(), 1.0f, TEST_LOCATION );
3582   DALI_TEST_EQUALS( textEditor.GetProperty( DevelTextEditor::Property::HORIZONTAL_SCROLL_POSITION ).Get<float>(), 0.0f, TEST_LOCATION );
3583
3584   DevelTextEditor::ScrollBy(textEditor, Vector2(0.0f, 1000.0f));
3585
3586   DALI_TEST_NOT_EQUALS( textEditor.GetProperty( DevelTextEditor::Property::VERTICAL_SCROLL_POSITION ).Get<float>(), 1.0f, 0.1f, TEST_LOCATION );
3587   DALI_TEST_EQUALS( textEditor.GetProperty( DevelTextEditor::Property::HORIZONTAL_SCROLL_POSITION ).Get<float>(), 0.0f, TEST_LOCATION );
3588
3589   textEditor.SetProperty(DevelTextEditor::Property::VERTICAL_SCROLL_POSITION , 0.0f);
3590   textEditor.SetProperty(DevelTextEditor::Property::HORIZONTAL_SCROLL_POSITION , 0.0f);
3591
3592   DALI_TEST_EQUALS( textEditor.GetProperty( DevelTextEditor::Property::VERTICAL_SCROLL_POSITION ).Get<float>(), 0.0f, TEST_LOCATION );
3593   DALI_TEST_EQUALS( textEditor.GetProperty( DevelTextEditor::Property::HORIZONTAL_SCROLL_POSITION ).Get<float>(), 0.0f, TEST_LOCATION );
3594
3595   END_TEST;
3596 }
3597
3598 int UtcDaliToolkitTextEditorFontSizeScale(void)
3599 {
3600   ToolkitTestApplication application;
3601   tet_infoline(" UtcDaliToolkitTextEditorFontSizeScale");
3602
3603   TextEditor textEditor = TextEditor::New();
3604   textEditor.SetProperty( TextEditor::Property::POINT_SIZE, 30.f );
3605   textEditor.SetProperty( TextEditor::Property::TEXT, "Test" );
3606   Vector3 nonScaledSize = textEditor.GetNaturalSize();
3607
3608   TextEditor textEditorScaled = TextEditor::New();
3609   textEditorScaled.SetProperty( TextEditor::Property::POINT_SIZE, 15.f );
3610   textEditorScaled.SetProperty( Toolkit::DevelTextEditor::Property::FONT_SIZE_SCALE, 2.f );
3611   textEditorScaled.SetProperty( TextEditor::Property::TEXT, "Test" );
3612   Vector3 scaledSize = textEditorScaled.GetNaturalSize();
3613
3614   DALI_TEST_EQUALS( nonScaledSize, scaledSize, TEST_LOCATION );
3615
3616   textEditor.SetProperty( TextEditor::Property::PIXEL_SIZE, 30.f );
3617   textEditor.SetProperty( TextEditor::Property::TEXT, "Test" );
3618   nonScaledSize = textEditor.GetNaturalSize();
3619
3620   textEditorScaled.SetProperty( TextEditor::Property::PIXEL_SIZE, 15.f );
3621   textEditorScaled.SetProperty( Toolkit::DevelTextEditor::Property::FONT_SIZE_SCALE, 2.f );
3622   textEditorScaled.SetProperty( TextEditor::Property::TEXT, "Test" );
3623   scaledSize = textEditorScaled.GetNaturalSize();
3624
3625   DALI_TEST_EQUALS( nonScaledSize, scaledSize, TEST_LOCATION );
3626
3627   END_TEST;
3628 }
3629
3630 int UtcDaliTextEditorPrimaryCursorPosition(void)
3631 {
3632   ToolkitTestApplication application;
3633   tet_infoline(" UtcDaliTextPrimaryCursorPosition ");
3634
3635   TextEditor textEditor = TextEditor::New();
3636
3637   application.GetScene().Add( textEditor );
3638
3639   textEditor.SetProperty( TextEditor::Property::TEXT, "ABCEF");
3640   textEditor.SetProperty( Actor::Property::SIZE, Vector2( 300.f, 50.f ) );
3641   textEditor.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT );
3642   textEditor.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT );
3643
3644   // Avoid a crash when core load gl resources.
3645   application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
3646
3647   textEditor.SetProperty( DevelTextEditor::Property::PRIMARY_CURSOR_POSITION, 3);
3648   application.SendNotification();
3649   application.Render();
3650   textEditor.SetKeyInputFocus();
3651
3652   application.ProcessEvent( GenerateKey( "D", "", "D", KEY_D_CODE, 0, 0, Integration::KeyEvent::DOWN, "D", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
3653
3654   // Render and notify
3655   application.SendNotification();
3656   application.Render();
3657
3658   DALI_TEST_EQUALS( textEditor.GetProperty( TextEditor::Property::TEXT ).Get<std::string>(), "ABCDEF", TEST_LOCATION );
3659   DALI_TEST_EQUALS( textEditor.GetProperty( DevelTextEditor::Property::PRIMARY_CURSOR_POSITION ).Get<int>(), 4, TEST_LOCATION );
3660
3661   END_TEST;
3662 }
3663
3664 int UtcDaliTextEditorLineCountAfterGetNaturalSize(void)
3665 {
3666   ToolkitTestApplication application;
3667   tet_infoline(" UtcDaliTextEditorLineCountAfterGetNaturalSize ");
3668
3669   TextEditor textEditor = TextEditor::New();
3670   textEditor.SetProperty(TextEditor::Property::TEXT, "A\nB\nC\nD\nE\nF\n");
3671   textEditor.SetProperty( Actor::Property::SIZE, Vector2( 300.f, 50.f ) );
3672   textEditor.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT );
3673   textEditor.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT );
3674   application.GetScene().Add( textEditor );
3675
3676   application.SendNotification();
3677   application.Render();
3678
3679   int lineCount = 0;
3680   lineCount =  textEditor.GetProperty<int>( TextEditor::Property::LINE_COUNT );
3681   DALI_TEST_EQUALS( lineCount, 7, TEST_LOCATION );
3682
3683   textEditor.GetNaturalSize();
3684
3685   // Create a tap event to touch the text editor.
3686   TestGenerateTap( application, 18.0f, 25.0f );
3687
3688   application.SendNotification();
3689   application.Render();
3690
3691   lineCount =  textEditor.GetProperty<int>( TextEditor::Property::LINE_COUNT );
3692   DALI_TEST_EQUALS( lineCount, 7, TEST_LOCATION );
3693
3694   END_TEST;
3695 }
3696
3697
3698 int utcDaliTextEditorGetHeightForWidthDoesNotChangeLineCountScrollingCase(void)
3699 {
3700   ToolkitTestApplication application;
3701
3702   tet_infoline(" utcDaliTextEditorGetHeightForWidthDoesNotChangeLineCountScrollingCase ");
3703
3704   int lineCountBefore =0 ;
3705   int lineCountAfter =0 ;
3706
3707   // Create a text editor
3708   TextEditor textEditor = TextEditor::New();
3709   //Set very large font-size using point-size
3710   textEditor.SetProperty( TextEditor::Property::POINT_SIZE, 10) ;
3711   //Specify font-family
3712   textEditor.SetProperty( TextEditor::Property::FONT_FAMILY, "DejaVu Sans");
3713   //Specify size
3714   textEditor.SetProperty( Actor::Property::SIZE, Vector2( 100.f, 100.f ) );
3715   //Set text longer than width of textEditor
3716   textEditor.SetProperty( TextEditor::Property::TEXT, "TEST TEST TEST TEST TEST TEST TEST TEST TEST TEST TEST TEST TEST TEST ");
3717
3718   application.GetScene().Add( textEditor );
3719
3720   application.SendNotification();
3721   application.Render();
3722
3723   //Failed case is the GetHeightForWidth change LineCount then the scrollor will not arrive to latest line
3724   //GetHeightForWidth is a retrieval method which should not modify object
3725   lineCountBefore =  textEditor.GetProperty<int>( TextEditor::Property::LINE_COUNT );
3726   textEditor.GetHeightForWidth(200.f);
3727
3728   //This is to simulate focus into text editor after calling GetHeightForWidth
3729   //Create a tap event to touch the text editor.
3730   TestGenerateTap( application, 18.0f, 25.0f );
3731
3732   application.SendNotification();
3733   application.Render();
3734
3735   lineCountAfter =  textEditor.GetProperty<int>( TextEditor::Property::LINE_COUNT );
3736
3737   //The LineCount must not be changed when calling GetHeightForWidth.
3738   DALI_TEST_EQUALS( lineCountAfter , lineCountBefore, TEST_LOCATION );
3739
3740   END_TEST;
3741 }
3742
3743 int utcDaliTextEditorGetHeightForWidthDoesNotChangeLineCountLineWrapCharCase(void)
3744 {
3745   ToolkitTestApplication application;
3746
3747   tet_infoline(" utcDaliTextEditorGetHeightForWidthDoesNotChangeLineCountLineWrapCharCase ");
3748
3749   int lineCountBefore =0 ;
3750   int lineCountAfter =0 ;
3751
3752   // Create a text editor
3753   TextEditor textEditor = TextEditor::New();
3754   //Set very large font-size using point-size
3755   textEditor.SetProperty( TextEditor::Property::POINT_SIZE, 10) ;
3756   //Specify font-family
3757   textEditor.SetProperty( TextEditor::Property::FONT_FAMILY, "DejaVu Sans");
3758   //Specify size
3759   textEditor.SetProperty( Actor::Property::SIZE, Vector2( 50.f, 100.f ) );
3760   //Set text longer than width of textEditor
3761   textEditor.SetProperty( TextEditor::Property::TEXT, "qwertyuiopasdfghjklzxcvbnm\n");
3762   //Set line wrap mode Character
3763   textEditor.SetProperty(TextEditor::Property::LINE_WRAP_MODE, "CHARACTER");
3764
3765   application.GetScene().Add( textEditor );
3766
3767   application.SendNotification();
3768   application.Render();
3769
3770   //Failed case is the GetHeightForWidth change LineCount which make position of cursor invalid in TextEditor
3771   //GetHeightForWidth is a retrieval method which should not modify object
3772   lineCountBefore =  textEditor.GetProperty<int>( TextEditor::Property::LINE_COUNT );
3773   textEditor.GetHeightForWidth(200.f);
3774
3775   //This is to simulate focus into text editor after calling GetHeightForWidth
3776   //Create a tap event to touch the text editor.
3777   TestGenerateTap( application, 18.0f, 25.0f );
3778
3779   application.SendNotification();
3780   application.Render();
3781
3782   lineCountAfter =  textEditor.GetProperty<int>( TextEditor::Property::LINE_COUNT );
3783
3784   //The LineCount must not be changed when calling GetHeightForWidth.
3785   DALI_TEST_EQUALS( lineCountAfter , lineCountBefore, TEST_LOCATION );
3786
3787   END_TEST;
3788 }
3789
3790 int utcDaliTextEditorGetHeightForWidthChangeLineCountWhenTextChanged(void)
3791 {
3792   ToolkitTestApplication application;
3793
3794   tet_infoline(" utcDaliTextEditorGetHeightForWidthChangeLineCountWhenTextChanged ");
3795
3796   int lineCountBefore =0 ;
3797   int lineCountAfter =0 ;
3798
3799   // Create a text editor
3800   TextEditor textEditor = TextEditor::New();
3801   //Set very large font-size using point-size
3802   textEditor.SetProperty( TextEditor::Property::POINT_SIZE, 10) ;
3803   //Specify font-family
3804   textEditor.SetProperty( TextEditor::Property::FONT_FAMILY, "DejaVu Sans");
3805   //Specify size
3806   textEditor.SetProperty( Actor::Property::SIZE, Vector2( 200.f, 100.f ) );
3807   //Set text longer than width of textEditor
3808   textEditor.SetProperty( TextEditor::Property::TEXT, "Short text");
3809   //Set line wrap mode Character
3810   textEditor.SetProperty(TextEditor::Property::LINE_WRAP_MODE, "CHARACTER");
3811
3812   application.GetScene().Add( textEditor );
3813
3814   application.SendNotification();
3815   application.Render();
3816
3817
3818   lineCountBefore =  textEditor.GetProperty<int>( TextEditor::Property::LINE_COUNT );
3819
3820   textEditor.SetProperty( TextEditor::Property::TEXT, "This is very loooooooooooooooooooooooooooooooooooong text for test");
3821   lineCountAfter =  textEditor.GetProperty<int>( TextEditor::Property::LINE_COUNT );
3822
3823   // When the text changed, the Line-count should be updated according to new text.
3824   // Because the GetHeightForWidth is called in Controller::GetLineCount(float width)
3825   DALI_TEST_EQUALS( lineCountBefore ,1, TEST_LOCATION );
3826   DALI_TEST_GREATER( lineCountAfter,1, TEST_LOCATION );
3827
3828
3829   END_TEST;
3830 }
3831
3832
3833 int utcDaliTextEditorGetNaturalSizeDoesNotChangeLineCountScrollingCase(void)
3834 {
3835   ToolkitTestApplication application;
3836
3837   tet_infoline(" utcDaliTextEditorGetNaturalSizeDoesNotChangeLineCountScrollingCase ");
3838
3839   int lineCountBefore =0 ;
3840   int lineCountAfter =0 ;
3841
3842   // Create a text editor
3843   TextEditor textEditor = TextEditor::New();
3844   //Set very large font-size using point-size
3845   textEditor.SetProperty( TextEditor::Property::POINT_SIZE, 10) ;
3846   //Specify font-family
3847   textEditor.SetProperty( TextEditor::Property::FONT_FAMILY, "DejaVu Sans");
3848   //Specify size
3849   textEditor.SetProperty( Actor::Property::SIZE, Vector2( 100.f, 100.f ) );
3850   //Set text longer than width of textEditor
3851   textEditor.SetProperty( TextEditor::Property::TEXT, "TEST TEST TEST TEST TEST TEST TEST TEST TEST TEST TEST TEST TEST TEST ");
3852
3853   application.GetScene().Add( textEditor );
3854
3855   application.SendNotification();
3856   application.Render();
3857
3858   //Failed case is the GetNaturalSize change LineCount then the scrollor will not arrive to latest line
3859   //GetNaturalSize is a retrieval method which should not modify object
3860   lineCountBefore =  textEditor.GetProperty<int>( TextEditor::Property::LINE_COUNT );
3861   textEditor.GetNaturalSize();
3862
3863   //This is to simulate focus into text editor after calling GetNaturalSize
3864   //Create a tap event to touch the text editor.
3865   TestGenerateTap( application, 18.0f, 25.0f );
3866
3867   application.SendNotification();
3868   application.Render();
3869
3870   lineCountAfter =  textEditor.GetProperty<int>( TextEditor::Property::LINE_COUNT );
3871
3872   //The LineCount must not be changed when calling GetNaturalSize.
3873   DALI_TEST_EQUALS( lineCountAfter , lineCountBefore, TEST_LOCATION );
3874
3875   END_TEST;
3876 }
3877
3878 int utcDaliTextEditorGetNaturalSizeDoesNotChangeLineCountLineWrapCharCase(void)
3879 {
3880   ToolkitTestApplication application;
3881
3882   tet_infoline(" utcDaliTextEditorGetNaturalSizeDoesNotChangeLineCountLineWrapCharCase ");
3883
3884   int lineCountBefore =0 ;
3885   int lineCountAfter =0 ;
3886
3887   // Create a text editor
3888   TextEditor textEditor = TextEditor::New();
3889   //Set very large font-size using point-size
3890   textEditor.SetProperty( TextEditor::Property::POINT_SIZE, 10) ;
3891   //Specify font-family
3892   textEditor.SetProperty( TextEditor::Property::FONT_FAMILY, "DejaVu Sans");
3893   //Specify size
3894   textEditor.SetProperty( Actor::Property::SIZE, Vector2( 50.f, 100.f ) );
3895   //Set text longer than width of textEditor
3896   textEditor.SetProperty( TextEditor::Property::TEXT, "qwertyuiopasdfghjklzxcvbnm\n");
3897   //Set line wrap mode Character
3898   textEditor.SetProperty(TextEditor::Property::LINE_WRAP_MODE, "CHARACTER");
3899
3900   application.GetScene().Add( textEditor );
3901
3902   application.SendNotification();
3903   application.Render();
3904
3905   //Failed case is the GetNaturalSize change LineCount which make position of cursor invalid in TextEditor
3906   //GetNaturalSize is a retrieval method which should not modify object
3907   lineCountBefore =  textEditor.GetProperty<int>( TextEditor::Property::LINE_COUNT );
3908   textEditor.GetNaturalSize( );
3909
3910   //This is to simulate focus into text editor after calling GetNaturalSize
3911   //Create a tap event to touch the text editor.
3912   TestGenerateTap( application, 18.0f, 25.0f );
3913
3914   application.SendNotification();
3915   application.Render();
3916
3917   lineCountAfter =  textEditor.GetProperty<int>( TextEditor::Property::LINE_COUNT );
3918
3919   //The LineCount must not be changed when calling GetNaturalSize.
3920   DALI_TEST_EQUALS( lineCountAfter , lineCountBefore, TEST_LOCATION );
3921
3922   END_TEST;
3923 }
3924
3925 int UtcDaliTextEditorAtlasLimitationIsEnabledForLargeFontPointSize(void)
3926 {
3927   ToolkitTestApplication application;
3928   tet_infoline(" UtcDaliTextEditorAtlasLimitationIsEnabledForLargeFontPointSize ");
3929
3930   // +2: First one to handle the equal case. Second one to handle odd to even case of GetNaturalSize
3931   const uint32_t lessThanWidth = TextAbstraction::FontClient::MAX_TEXT_ATLAS_WIDTH - TextAbstraction::FontClient::PADDING_TEXT_ATLAS_BLOCK + 2;
3932   const uint32_t lessThanHeight = TextAbstraction::FontClient::MAX_TEXT_ATLAS_HEIGHT - TextAbstraction::FontClient::PADDING_TEXT_ATLAS_BLOCK + 2;
3933
3934   // Create a text editor
3935   TextEditor textEditor = TextEditor::New();
3936
3937   //Set size to avoid automatic eliding
3938   textEditor.SetProperty( Actor::Property::SIZE, Vector2(1025, 1025));
3939   //Set very large font-size using point-size
3940   textEditor.SetProperty( TextEditor::Property::POINT_SIZE, 1000) ;
3941   //Specify font-family
3942   textEditor.SetProperty( TextEditor::Property::FONT_FAMILY, "DejaVu Sans");
3943   //Set text to check if appear or not
3944   textEditor.SetProperty( TextEditor::Property::TEXT, "A");
3945
3946   application.GetScene().Add( textEditor );
3947
3948   application.SendNotification();
3949   application.Render();
3950   //Use GetNaturalSize to verify that size of block does not exceed Atlas size
3951   Vector3 naturalSize = textEditor.GetNaturalSize();
3952
3953   DALI_TEST_GREATER( lessThanWidth, static_cast<uint32_t>(naturalSize.width), TEST_LOCATION );
3954   DALI_TEST_GREATER( lessThanHeight, static_cast<uint32_t>(naturalSize.height), TEST_LOCATION );
3955
3956   END_TEST;
3957 }
3958
3959 int UtcDaliTextEditorAtlasLimitationIsEnabledPerformanceCases(void)
3960 {
3961   ToolkitTestApplication application;
3962   tet_infoline(" UtcDaliTextEditorAtlasLimitationIsEnabledPerformanceCases ");
3963
3964   // +2: First one to handle the equal case. Second one to handle odd to even case of GetNaturalSize
3965   const uint32_t lessThanWidth = TextAbstraction::FontClient::MAX_TEXT_ATLAS_WIDTH - TextAbstraction::FontClient::PADDING_TEXT_ATLAS_BLOCK + 2;
3966   const uint32_t lessThanHeight = TextAbstraction::FontClient::MAX_TEXT_ATLAS_HEIGHT - TextAbstraction::FontClient::PADDING_TEXT_ATLAS_BLOCK + 2;
3967
3968   Vector3 naturalSize; //Use GetNaturalSize to verify that size of block does not exceed Atlas size
3969   // Create a text editor
3970   TextEditor textEditor = TextEditor::New();
3971   //Set size to avoid automatic eliding
3972   textEditor.SetProperty( Actor::Property::SIZE, Vector2(1025, 1025));
3973   textEditor.SetProperty( TextEditor::Property::FONT_FAMILY, "DejaVu Sans");
3974   textEditor.SetProperty( TextEditor::Property::TEXT, "A");
3975
3976   const int numberOfCases = 6;
3977   int arrayCases[numberOfCases] = {323, 326, 330, 600, 1630, 2500};
3978
3979   for (int index=0; index < numberOfCases; index++)
3980   {
3981     tet_printf(" UtcDaliTextEditorAtlasLimitationIsEnabledPerformanceCases point-size= %d \n", arrayCases[index]);
3982     textEditor.SetProperty( TextEditor::Property::POINT_SIZE, arrayCases[index]) ;
3983     application.GetScene().Add( textEditor );
3984     application.SendNotification();
3985     application.Render();
3986     naturalSize = textEditor.GetNaturalSize();
3987     DALI_TEST_GREATER( lessThanWidth, static_cast<uint32_t>(naturalSize.width), TEST_LOCATION );
3988     DALI_TEST_GREATER( lessThanHeight, static_cast<uint32_t>(naturalSize.height), TEST_LOCATION );
3989
3990   }
3991
3992   END_TEST;
3993 }
3994
3995 int UtcDaliTextEditorHyphenWrapMode(void)
3996 {
3997   ToolkitTestApplication application;
3998   tet_infoline(" UtcDaliTextEditorHyphenWrapMode ");
3999
4000   int lineCount =0;
4001   TextEditor textEditor = TextEditor::New();
4002
4003   textEditor.SetProperty( Actor::Property::SIZE, Vector2( 150.0f, 300.f ) );
4004
4005   application.GetScene().Add( textEditor );
4006   application.SendNotification();
4007   application.Render();
4008
4009   textEditor.SetProperty( TextEditor::Property::TEXT, "Hi Experimen" );
4010   textEditor.SetProperty(TextEditor::Property::LINE_WRAP_MODE, DevelText::LineWrap::HYPHENATION);
4011   DALI_TEST_EQUALS( textEditor.GetProperty< int >( TextEditor::Property::LINE_WRAP_MODE ), static_cast< int >( DevelText::LineWrap::HYPHENATION ), TEST_LOCATION );
4012
4013   application.SendNotification();
4014   application.Render();
4015
4016   lineCount = textEditor.GetProperty<int>( TextEditor::Property::LINE_COUNT );
4017   /*
4018     text will be :
4019     Hi Exp-
4020     erimen
4021   */
4022   DALI_TEST_EQUALS( lineCount, 2, TEST_LOCATION );
4023
4024   textEditor.SetProperty( TextEditor::Property::TEXT, "Hi Experimen" );
4025   textEditor.SetProperty(TextEditor::Property::LINE_WRAP_MODE, DevelText::LineWrap::MIXED);
4026   DALI_TEST_EQUALS( textEditor.GetProperty< int >( TextEditor::Property::LINE_WRAP_MODE ), static_cast< int >( DevelText::LineWrap::MIXED ), TEST_LOCATION );
4027
4028   application.SendNotification();
4029   application.Render();
4030
4031   lineCount = textEditor.GetProperty<int>( TextEditor::Property::LINE_COUNT );
4032   /*
4033     text will be :
4034     Hi
4035     Experi-
4036     men
4037   */
4038   DALI_TEST_EQUALS( lineCount, 3, TEST_LOCATION );
4039
4040   END_TEST;
4041 }
4042
4043 int UtcDaliToolkitTextEditorEllipsisPositionProperty(void)
4044 {
4045   ToolkitTestApplication application;
4046   tet_infoline(" UtcDaliToolkitTextEditorEllipsisPositionProperty ");
4047   TextEditor textEditor = TextEditor::New();
4048
4049   tet_infoline(" UtcDaliToolkitTextEditorEllipsisPositionProperty - Default is END");
4050   DALI_TEST_EQUALS( textEditor.GetProperty< int >( DevelTextEditor::Property::ELLIPSIS_POSITION ), static_cast< int >( Toolkit::DevelText::EllipsisPosition::END ), TEST_LOCATION );
4051
4052   tet_infoline(" UtcDaliToolkitTextEditorEllipsisPositionProperty - Change to START");
4053   textEditor.SetProperty(DevelTextEditor::Property::ELLIPSIS_POSITION, DevelText::EllipsisPosition::START);
4054   DALI_TEST_EQUALS( textEditor.GetProperty< int >( DevelTextEditor::Property::ELLIPSIS_POSITION ), static_cast< int >( Toolkit::DevelText::EllipsisPosition::START ), TEST_LOCATION );
4055
4056   tet_infoline(" UtcDaliToolkitTextEditorEllipsisPositionProperty - Change to MIDDLE");
4057   textEditor.SetProperty(DevelTextEditor::Property::ELLIPSIS_POSITION, DevelText::EllipsisPosition::MIDDLE);
4058   DALI_TEST_EQUALS( textEditor.GetProperty< int >( DevelTextEditor::Property::ELLIPSIS_POSITION ), static_cast< int >( Toolkit::DevelText::EllipsisPosition::MIDDLE ), TEST_LOCATION );
4059
4060   tet_infoline(" UtcDaliToolkitTextEditorEllipsisPositionProperty - Change to END");
4061   textEditor.SetProperty(DevelTextEditor::Property::ELLIPSIS_POSITION, DevelText::EllipsisPosition::END);
4062   DALI_TEST_EQUALS( textEditor.GetProperty< int >( DevelTextEditor::Property::ELLIPSIS_POSITION ), static_cast< int >( Toolkit::DevelText::EllipsisPosition::END ), TEST_LOCATION );
4063
4064   tet_infoline(" UtcDaliToolkitTextEditorEllipsisPositionProperty - Change to START using integer");
4065   textEditor.SetProperty(DevelTextEditor::Property::ELLIPSIS_POSITION, 1);
4066   DALI_TEST_EQUALS( textEditor.GetProperty< int >( DevelTextEditor::Property::ELLIPSIS_POSITION ), static_cast< int >( Toolkit::DevelText::EllipsisPosition::START ), TEST_LOCATION );
4067
4068   tet_infoline(" UtcDaliToolkitTextEditorEllipsisPositionProperty - Change to MIDDLE using integer");
4069   textEditor.SetProperty(DevelTextEditor::Property::ELLIPSIS_POSITION, 2);
4070   DALI_TEST_EQUALS( textEditor.GetProperty< int >( DevelTextEditor::Property::ELLIPSIS_POSITION ), static_cast< int >( Toolkit::DevelText::EllipsisPosition::MIDDLE ), TEST_LOCATION );
4071
4072   tet_infoline(" UtcDaliToolkitTextEditorEllipsisPositionProperty - Change to END using integer");
4073   textEditor.SetProperty(DevelTextEditor::Property::ELLIPSIS_POSITION, 0);
4074   DALI_TEST_EQUALS( textEditor.GetProperty< int >( DevelTextEditor::Property::ELLIPSIS_POSITION ), static_cast< int >( Toolkit::DevelText::EllipsisPosition::END ), TEST_LOCATION );
4075
4076   tet_infoline(" UtcDaliToolkitTextlabelEllipsisPositionProperty - Change to START using string - uppercase");
4077   textEditor.SetProperty(DevelTextEditor::Property::ELLIPSIS_POSITION, "START");
4078   DALI_TEST_EQUALS( textEditor.GetProperty< int >( DevelTextEditor::Property::ELLIPSIS_POSITION ), static_cast< int >( Toolkit::DevelText::EllipsisPosition::START ), TEST_LOCATION );
4079
4080   tet_infoline(" UtcDaliToolkitTextlabelEllipsisPositionProperty - Change to MIDDLE using string - uppercase");
4081   textEditor.SetProperty(DevelTextEditor::Property::ELLIPSIS_POSITION, "MIDDLE");
4082   DALI_TEST_EQUALS( textEditor.GetProperty< int >( DevelTextEditor::Property::ELLIPSIS_POSITION ), static_cast< int >( Toolkit::DevelText::EllipsisPosition::MIDDLE ), TEST_LOCATION );
4083
4084   tet_infoline(" UtcDaliToolkitTextlabelEllipsisPositionProperty - Change to END using string - uppercase");
4085   textEditor.SetProperty(DevelTextEditor::Property::ELLIPSIS_POSITION, "END");
4086   DALI_TEST_EQUALS( textEditor.GetProperty< int >( DevelTextEditor::Property::ELLIPSIS_POSITION ), static_cast< int >( Toolkit::DevelText::EllipsisPosition::END ), TEST_LOCATION );
4087
4088   tet_infoline(" UtcDaliToolkitTextlabelEllipsisPositionProperty - Change to START using string - lowercase");
4089   textEditor.SetProperty(DevelTextEditor::Property::ELLIPSIS_POSITION, "start");
4090   DALI_TEST_EQUALS( textEditor.GetProperty< int >( DevelTextEditor::Property::ELLIPSIS_POSITION ), static_cast< int >( Toolkit::DevelText::EllipsisPosition::START ), TEST_LOCATION );
4091
4092   tet_infoline(" UtcDaliToolkitTextlabelEllipsisPositionProperty - Change to MIDDLE using string - lowercase");
4093   textEditor.SetProperty(DevelTextEditor::Property::ELLIPSIS_POSITION, "middle");
4094   DALI_TEST_EQUALS( textEditor.GetProperty< int >( DevelTextEditor::Property::ELLIPSIS_POSITION ), static_cast< int >( Toolkit::DevelText::EllipsisPosition::MIDDLE ), TEST_LOCATION );
4095
4096   tet_infoline(" UtcDaliToolkitTextlabelEllipsisPositionProperty - Change to END using string - lowercase");
4097   textEditor.SetProperty(DevelTextEditor::Property::ELLIPSIS_POSITION, "end");
4098   DALI_TEST_EQUALS( textEditor.GetProperty< int >( DevelTextEditor::Property::ELLIPSIS_POSITION ), static_cast< int >( Toolkit::DevelText::EllipsisPosition::END ), TEST_LOCATION );
4099
4100   END_TEST;
4101 }
4102
4103 int UtcDaliTextEditorCopyText(void)
4104 {
4105   ToolkitTestApplication application;
4106   tet_infoline(" UtcDaliTextEditorCopyText ");
4107
4108   TextEditor textEditor = TextEditor::New();
4109
4110   std::string selectedText = "";
4111   std::string copiedText = "";
4112
4113   application.GetScene().Add( textEditor );
4114
4115   textEditor.SetProperty( Actor::Property::SIZE, Vector2( 300.f, 50.f ) );
4116   textEditor.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT );
4117   textEditor.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT );
4118
4119   // Avoid a crash when core load gl resources.
4120   application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
4121
4122   application.SendNotification();
4123   application.Render();
4124
4125   textEditor.SetProperty( TextEditor::Property::TEXT, "Hello world" );
4126
4127   application.SendNotification();
4128   application.Render();
4129
4130   // Hello is selected
4131   DevelTextEditor::SelectText( textEditor, 0, 5 );
4132
4133   application.SendNotification();
4134   application.Render();
4135
4136   selectedText = textEditor.GetProperty( DevelTextEditor::Property::SELECTED_TEXT ).Get<std::string>();
4137   DALI_TEST_EQUALS( "Hello", selectedText, TEST_LOCATION );
4138
4139   DALI_TEST_EQUALS( textEditor.GetProperty( DevelTextEditor::Property::SELECTED_TEXT_START ).Get<int>(), 0, TEST_LOCATION );
4140   DALI_TEST_EQUALS( textEditor.GetProperty( DevelTextEditor::Property::SELECTED_TEXT_END ).Get<int>(), 5, TEST_LOCATION );
4141
4142   // Hello is copied
4143   copiedText = DevelTextEditor::CopyText( textEditor );
4144   DALI_TEST_EQUALS( "Hello", copiedText, TEST_LOCATION );
4145
4146   // world is selected
4147   DevelTextEditor::SelectText( textEditor, 6, 11 );
4148
4149   application.SendNotification();
4150   application.Render();
4151
4152   selectedText = textEditor.GetProperty( DevelTextEditor::Property::SELECTED_TEXT ).Get<std::string>();
4153   DALI_TEST_EQUALS( "world", selectedText, TEST_LOCATION );
4154
4155   DALI_TEST_EQUALS( textEditor.GetProperty( DevelTextEditor::Property::SELECTED_TEXT_START ).Get<int>(), 6, TEST_LOCATION );
4156   DALI_TEST_EQUALS( textEditor.GetProperty( DevelTextEditor::Property::SELECTED_TEXT_END ).Get<int>(), 11, TEST_LOCATION );
4157
4158   // world is copied
4159   copiedText = DevelTextEditor::CopyText( textEditor );
4160   DALI_TEST_EQUALS( "world", copiedText, TEST_LOCATION );
4161
4162   // "lo wo" is selected
4163   DevelTextEditor::SelectText( textEditor, 3, 8 );
4164
4165   application.SendNotification();
4166   application.Render();
4167
4168   selectedText = textEditor.GetProperty( DevelTextEditor::Property::SELECTED_TEXT ).Get<std::string>();
4169   DALI_TEST_EQUALS( "lo wo", selectedText, TEST_LOCATION );
4170
4171   DALI_TEST_EQUALS( textEditor.GetProperty( DevelTextEditor::Property::SELECTED_TEXT_START ).Get<int>(), 3, TEST_LOCATION );
4172   DALI_TEST_EQUALS( textEditor.GetProperty( DevelTextEditor::Property::SELECTED_TEXT_END ).Get<int>(), 8, TEST_LOCATION );
4173
4174   // "lo wo" is copied
4175   copiedText = DevelTextEditor::CopyText( textEditor );
4176   DALI_TEST_EQUALS( "lo wo", copiedText, TEST_LOCATION );
4177
4178   END_TEST;
4179 }
4180
4181 int UtcDaliTextEditorCutText(void)
4182 {
4183   ToolkitTestApplication application;
4184   tet_infoline(" UtcDaliTextEditorCutText ");
4185
4186   TextEditor textEditor = TextEditor::New();
4187
4188   std::string selectedText = "";
4189
4190   application.GetScene().Add( textEditor );
4191
4192   textEditor.SetProperty( Actor::Property::SIZE, Vector2( 300.f, 50.f ) );
4193   textEditor.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT );
4194   textEditor.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT );
4195
4196   // Avoid a crash when core load gl resources.
4197   application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
4198
4199   application.SendNotification();
4200   application.Render();
4201
4202   textEditor.SetProperty( TextEditor::Property::TEXT, "Hello world" );
4203
4204   application.SendNotification();
4205   application.Render();
4206
4207   // Hello is selected
4208   DevelTextEditor::SelectText( textEditor, 0, 5 );
4209
4210   application.SendNotification();
4211   application.Render();
4212
4213   selectedText = textEditor.GetProperty( DevelTextEditor::Property::SELECTED_TEXT ).Get<std::string>();
4214   DALI_TEST_EQUALS( "Hello", selectedText, TEST_LOCATION );
4215
4216   DALI_TEST_EQUALS( textEditor.GetProperty( DevelTextEditor::Property::SELECTED_TEXT_START ).Get<int>(), 0, TEST_LOCATION );
4217   DALI_TEST_EQUALS( textEditor.GetProperty( DevelTextEditor::Property::SELECTED_TEXT_END ).Get<int>(), 5, TEST_LOCATION );
4218
4219   // Hello is cut
4220   DALI_TEST_EQUALS( "Hello", DevelTextEditor::CutText( textEditor ), TEST_LOCATION );
4221
4222   application.SendNotification();
4223   application.Render();
4224
4225   DALI_TEST_EQUALS( textEditor.GetProperty( TextEditor::Property::TEXT ).Get<std::string>(), " world", TEST_LOCATION );
4226
4227   // " w" is selected
4228   DevelTextEditor::SelectText( textEditor, 0, 2 );
4229
4230   application.SendNotification();
4231   application.Render();
4232
4233   selectedText = textEditor.GetProperty( DevelTextEditor::Property::SELECTED_TEXT ).Get<std::string>();
4234   DALI_TEST_EQUALS( " w", selectedText, TEST_LOCATION );
4235
4236   DALI_TEST_EQUALS( textEditor.GetProperty( DevelTextEditor::Property::SELECTED_TEXT_START ).Get<int>(), 0, TEST_LOCATION );
4237   DALI_TEST_EQUALS( textEditor.GetProperty( DevelTextEditor::Property::SELECTED_TEXT_END ).Get<int>(), 2, TEST_LOCATION );
4238
4239   // " w" is cut
4240   DALI_TEST_EQUALS( " w", DevelTextEditor::CutText( textEditor ), TEST_LOCATION );
4241
4242   application.SendNotification();
4243   application.Render();
4244
4245   DALI_TEST_EQUALS( textEditor.GetProperty( TextEditor::Property::TEXT ).Get<std::string>(), "orld", TEST_LOCATION );
4246
4247   // Test Cut from the middle
4248
4249   // "rl" is selected
4250   DevelTextEditor::SelectText( textEditor, 1, 3 );
4251
4252   application.SendNotification();
4253   application.Render();
4254
4255   selectedText = textEditor.GetProperty( DevelTextEditor::Property::SELECTED_TEXT ).Get<std::string>();
4256   DALI_TEST_EQUALS( "rl", selectedText, TEST_LOCATION );
4257
4258   DALI_TEST_EQUALS( textEditor.GetProperty( DevelTextEditor::Property::SELECTED_TEXT_START ).Get<int>(), 1, TEST_LOCATION );
4259   DALI_TEST_EQUALS( textEditor.GetProperty( DevelTextEditor::Property::SELECTED_TEXT_END ).Get<int>(), 3, TEST_LOCATION );
4260
4261   // "rl" is cut
4262   DALI_TEST_EQUALS( "rl", DevelTextEditor::CutText( textEditor ), TEST_LOCATION );
4263
4264   application.SendNotification();
4265   application.Render();
4266
4267   DALI_TEST_EQUALS( textEditor.GetProperty( TextEditor::Property::TEXT ).Get<std::string>(), "od", TEST_LOCATION );
4268
4269   // Test Cut from the end
4270
4271   // "d" is selected
4272   DevelTextEditor::SelectText( textEditor, 1, 2 );
4273
4274   application.SendNotification();
4275   application.Render();
4276
4277   selectedText = textEditor.GetProperty( DevelTextEditor::Property::SELECTED_TEXT ).Get<std::string>();
4278   DALI_TEST_EQUALS( "d", selectedText, TEST_LOCATION );
4279
4280   DALI_TEST_EQUALS( textEditor.GetProperty( DevelTextEditor::Property::SELECTED_TEXT_START ).Get<int>(), 1, TEST_LOCATION );
4281   DALI_TEST_EQUALS( textEditor.GetProperty( DevelTextEditor::Property::SELECTED_TEXT_END ).Get<int>(), 2, TEST_LOCATION );
4282
4283   // "d" is cut
4284   DALI_TEST_EQUALS( "d", DevelTextEditor::CutText( textEditor ), TEST_LOCATION );
4285
4286   application.SendNotification();
4287   application.Render();
4288
4289   DALI_TEST_EQUALS( textEditor.GetProperty( TextEditor::Property::TEXT ).Get<std::string>(), "o", TEST_LOCATION );
4290
4291   END_TEST;
4292 }
4293
4294 int UtcDaliTextEditorPasteText(void)
4295 {
4296   ToolkitTestApplication application;
4297   tet_infoline(" UtcDaliTextEditorPasteText ");
4298
4299   TextEditor editor = TextEditor::New();
4300   DALI_TEST_CHECK( editor );
4301
4302   application.GetScene().Add( editor );
4303
4304   std::string cutText = "";
4305   std::string copiedText = "";
4306
4307   editor.SetProperty( TextEditor::Property::TEXT, "Hello\nworld\nHello world" );
4308   editor.SetProperty( TextEditor::Property::POINT_SIZE, 10.f );
4309   editor.SetProperty( Actor::Property::SIZE, Vector2( 100.f, 50.f ) );
4310   editor.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT );
4311   editor.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT );
4312
4313   // Avoid a crash when core load gl resources.
4314   application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
4315
4316   // Render and notify
4317   application.SendNotification();
4318   application.Render();
4319
4320   // Tap on the text editor
4321   TestGenerateTap( application, 3.0f, 25.0f );
4322
4323   // Render and notify
4324   application.SendNotification();
4325   application.Render();
4326
4327   // Move to second line of the text.
4328   application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_DOWN, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
4329
4330   // Render and notify
4331   application.SendNotification();
4332   application.Render();
4333
4334   // Select some text in the right of the current cursor position
4335   application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_SHIFT_LEFT, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
4336   application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_RIGHT, KEY_SHIFT_MODIFIER, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
4337   application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_RIGHT, KEY_SHIFT_MODIFIER, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
4338   application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_RIGHT, KEY_SHIFT_MODIFIER, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
4339
4340   // Render and notify
4341   application.SendNotification();
4342   application.Render();
4343
4344   // Cut the selected text
4345   cutText = DevelTextEditor::CutText(editor);
4346
4347   // Render and notify
4348   application.SendNotification();
4349   application.Render();
4350
4351   DALI_TEST_EQUALS( "wor", cutText, TEST_LOCATION );
4352   DALI_TEST_EQUALS( "Hello\nld\nHello world", editor.GetProperty<std::string>( TextEditor::Property::TEXT ), TEST_LOCATION );
4353
4354   // Select some text in the left of the current cursor position
4355   application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_SHIFT_LEFT, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
4356   application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_LEFT, KEY_SHIFT_MODIFIER, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
4357   application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_LEFT, KEY_SHIFT_MODIFIER, 0, Integration::KeyEvent::DOWN,  "",DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
4358   application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_LEFT, KEY_SHIFT_MODIFIER, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
4359
4360   // Render and notify
4361   application.SendNotification();
4362   application.Render();
4363
4364   // Copy the selected text
4365   copiedText = DevelTextEditor::CopyText(editor);
4366
4367   // Render and notify
4368   application.SendNotification();
4369   application.Render();
4370
4371   DALI_TEST_EQUALS( "lo\n", copiedText, TEST_LOCATION );
4372   DALI_TEST_EQUALS( "Hello\nld\nHello world", editor.GetProperty<std::string>( TextEditor::Property::TEXT ), TEST_LOCATION );
4373
4374
4375   // Move the cursor to the third line
4376   application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_DOWN, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
4377   application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_DOWN, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
4378
4379   // Render and notify
4380   application.SendNotification();
4381   application.Render();
4382
4383   // Paste the selected text at the current cursor position
4384   DevelTextEditor::PasteText(editor);
4385
4386   // Render and notify
4387   application.SendNotification();
4388   application.Render();
4389
4390   DALI_TEST_EQUALS( "Hello\nld\nHello lo\nworld", editor.GetProperty<std::string>( TextEditor::Property::TEXT ), TEST_LOCATION );
4391
4392   END_TEST;
4393 }
4394 int UtcDaliTextEditorLineSpacing(void)
4395 {
4396   ToolkitTestApplication application;
4397   tet_infoline(" UtcDaliTextEditorLineSpacing ");
4398
4399   TextEditor textEditor = TextEditor::New();
4400   textEditor.SetProperty( Actor::Property::SIZE, Vector2( 400.0f, 400.f ) );
4401   application.GetScene().Add( textEditor );
4402   application.SendNotification();
4403   application.Render();
4404
4405   textEditor.SetProperty( TextEditor::Property::TEXT, "Line #1\nLine #2\nLine #3" );
4406   textEditor.SetProperty( DevelTextEditor::Property::LINE_SPACING, 0 );
4407
4408   Vector3 sizeBefore = textEditor.GetNaturalSize();
4409
4410   textEditor.SetProperty( DevelTextEditor::Property::LINE_SPACING, 20 );
4411
4412   //add 20 for each line  20 * 3
4413   DALI_TEST_EQUALS(sizeBefore.height + 60.0f, textEditor.GetNaturalSize().height, TEST_LOCATION);
4414
4415   END_TEST;
4416 }
4417
4418 int UtcDaliTextEditorMinLineSize(void)
4419 {
4420   ToolkitTestApplication application;
4421   tet_infoline(" UtcDaliTextEditorMinLineSize ");
4422
4423   TextEditor textEditor = TextEditor::New();
4424   textEditor.SetProperty( Actor::Property::SIZE, Vector2( 400.0f, 400.f ) );
4425   application.GetScene().Add( textEditor );
4426   application.SendNotification();
4427   application.Render();
4428
4429   textEditor.SetProperty( TextEditor::Property::TEXT, "Line #1\nLine #2\nLine #3" );
4430   textEditor.SetProperty( DevelTextEditor::Property::MIN_LINE_SIZE, 0 );
4431
4432   Vector3 sizeBefore = textEditor.GetNaturalSize();
4433
4434   textEditor.SetProperty( DevelTextEditor::Property::MIN_LINE_SIZE, 60 );
4435
4436   DALI_TEST_NOT_EQUALS( sizeBefore, textEditor.GetNaturalSize(), 0.0f, TEST_LOCATION);
4437
4438   //60 * 3 lines
4439   DALI_TEST_EQUALS(180.0f, textEditor.GetNaturalSize().height, TEST_LOCATION);
4440
4441   END_TEST;
4442 }
4443
4444 int utcDaliTextEditorCursorPositionChangedSignal(void)
4445 {
4446   ToolkitTestApplication application;
4447   tet_infoline(" utcDaliTextEditorCursorPositionChangedSignal");
4448
4449   TextEditor editor = TextEditor::New();
4450   DALI_TEST_CHECK( editor );
4451
4452   application.GetScene().Add( editor );
4453
4454   // connect to the selection changed signal.
4455   ConnectionTracker* testTracker = new ConnectionTracker();
4456   DevelTextEditor::CursorPositionChangedSignal(editor).Connect(&TestCursorPositionChangedCallback);
4457   bool cursorPositionChangedSignal = false;
4458   editor.ConnectSignal( testTracker, "cursorPositionChanged",   CallbackFunctor(&cursorPositionChangedSignal) );
4459
4460   editor.SetProperty( TextEditor::Property::TEXT, "Hello\nworld\nHello world" );
4461   editor.SetProperty( TextEditor::Property::POINT_SIZE, 10.f );
4462   editor.SetProperty( Actor::Property::SIZE, Vector2( 100.f, 50.f ) );
4463   editor.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT );
4464   editor.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT );
4465
4466   // Avoid a crash when core load gl resources.
4467   application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
4468
4469   // Render and notify
4470   application.SendNotification();
4471   application.Render();
4472
4473   editor.SetKeyInputFocus();
4474
4475   // Tap on the text editor
4476   TestGenerateTap( application, 3.0f, 25.0f );
4477
4478   // Render and notify
4479   application.SendNotification();
4480   application.Render();
4481
4482   DALI_TEST_CHECK(gCursorPositionChangedCallbackCalled);
4483   DALI_TEST_EQUALS(oldCursorPos, 23, TEST_LOCATION);
4484
4485   gCursorPositionChangedCallbackCalled = false;
4486
4487   // Move to left.
4488   application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_LEFT, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
4489
4490   // Render and notify
4491   application.SendNotification();
4492   application.Render();
4493
4494   DALI_TEST_CHECK(gCursorPositionChangedCallbackCalled);
4495   DALI_TEST_EQUALS(oldCursorPos, 18, TEST_LOCATION);
4496
4497   gCursorPositionChangedCallbackCalled = false;
4498
4499   // Insert C
4500   application.ProcessEvent( GenerateKey( "c", "", "c", KEY_C_CODE, 0, 0, Integration::KeyEvent::DOWN, "c", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
4501
4502   // Render and notify
4503   application.SendNotification();
4504   application.Render();
4505
4506   DALI_TEST_CHECK(gCursorPositionChangedCallbackCalled);
4507   DALI_TEST_EQUALS(oldCursorPos, 17, TEST_LOCATION);
4508
4509   gCursorPositionChangedCallbackCalled = false;
4510
4511   //delete one character
4512   application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_BACKSPACE, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
4513
4514   // Render and notify
4515   application.SendNotification();
4516   application.Render();
4517
4518   DALI_TEST_CHECK(gCursorPositionChangedCallbackCalled);
4519   DALI_TEST_EQUALS(oldCursorPos, 18, TEST_LOCATION);
4520
4521   gCursorPositionChangedCallbackCalled = false;
4522
4523   editor.SetProperty( TextEditor::Property::TEXT, "Hello" );
4524
4525   // Render and notify
4526   application.SendNotification();
4527   application.Render();
4528
4529   DALI_TEST_CHECK(gCursorPositionChangedCallbackCalled);
4530   DALI_TEST_EQUALS(oldCursorPos, 17, TEST_LOCATION);
4531
4532   gCursorPositionChangedCallbackCalled = false;
4533
4534   editor.SetProperty( DevelTextEditor::Property::PRIMARY_CURSOR_POSITION, 3);
4535
4536   // Render and notify
4537   application.SendNotification();
4538   application.Render();
4539
4540   DALI_TEST_CHECK(gCursorPositionChangedCallbackCalled);
4541   DALI_TEST_EQUALS(oldCursorPos, 5, TEST_LOCATION);
4542
4543   END_TEST;
4544 }
4545
4546 int utcDaliTextEditorGeometryEllipsisStart(void)
4547 {
4548   ToolkitTestApplication application;
4549   tet_infoline(" utcDaliTextEditorGeometryEllipsisStart");
4550
4551   TextEditor editor = TextEditor::New();
4552   DALI_TEST_CHECK( editor );
4553
4554   application.GetScene().Add( editor );
4555
4556   editor.SetProperty( TextEditor::Property::POINT_SIZE, 7.f );
4557   editor.SetProperty( Actor::Property::SIZE, Vector2( 100.f, 50.f ) );
4558   editor.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT );
4559   editor.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT );
4560   editor.SetProperty( TextEditor::Property::ENABLE_MARKUP, true );
4561   editor.SetProperty( DevelTextEditor::Property::ENABLE_SCROLL_BAR, false );
4562   editor.SetProperty( DevelTextEditor::Property::ELLIPSIS, true );
4563   editor.SetProperty( DevelTextEditor::Property::ELLIPSIS_POSITION, DevelText::EllipsisPosition::START );
4564   editor.SetProperty( TextEditor::Property::TEXT, "line1 \nline2\nline 3\nline4" );
4565
4566   // Avoid a crash when core load gl resources.
4567   application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
4568
4569   // Render and notify
4570   application.SendNotification();
4571   application.Render();
4572
4573   unsigned int expectedCount = 2;
4574   unsigned int startIndex = 0;
4575   unsigned int endIndex = 24;
4576
4577   Vector<Vector2> positionsList = DevelTextEditor::GetTextPosition(editor, startIndex, endIndex);
4578   Vector<Vector2> sizeList = DevelTextEditor::GetTextSize(editor, startIndex, endIndex);
4579
4580   DALI_TEST_EQUALS(positionsList.Size(), expectedCount, TEST_LOCATION);
4581   DALI_TEST_EQUALS(sizeList.Size(), expectedCount, TEST_LOCATION);
4582
4583   Vector<Vector2> expectedSizes;
4584   Vector<Vector2> expectedPositions;
4585
4586   expectedPositions.PushBack(Vector2(37, 0));
4587   expectedSizes.PushBack(Vector2(20, 25));
4588
4589   expectedPositions.PushBack(Vector2(-1, 25));
4590   expectedSizes.PushBack(Vector2(52, 25));
4591
4592   TestTextGeometryUtils::CheckGeometryResult(positionsList, sizeList, expectedPositions, expectedSizes);
4593
4594   END_TEST;
4595 }
4596
4597 int utcDaliTextEditorGeometryEllipsisMiddle(void)
4598 {
4599   ToolkitTestApplication application;
4600   tet_infoline(" utcDaliTextEditorGeometryEllipsisMiddle");
4601
4602   TextEditor editor = TextEditor::New();
4603   DALI_TEST_CHECK( editor );
4604
4605   application.GetScene().Add( editor );
4606
4607   editor.SetProperty( TextEditor::Property::POINT_SIZE, 7.f );
4608   editor.SetProperty( Actor::Property::SIZE, Vector2( 100.f, 50.f ) );
4609   editor.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT );
4610   editor.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT );
4611   editor.SetProperty( TextEditor::Property::ENABLE_MARKUP, true );
4612   editor.SetProperty( DevelTextEditor::Property::ENABLE_SCROLL_BAR, false );
4613   editor.SetProperty( DevelTextEditor::Property::ELLIPSIS, true );
4614   editor.SetProperty( DevelTextEditor::Property::ELLIPSIS_POSITION, DevelText::EllipsisPosition::MIDDLE );
4615   editor.SetProperty( TextEditor::Property::TEXT, "line1 \nline2\nline 3\nline4" );
4616
4617   // Avoid a crash when core load gl resources.
4618   application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
4619
4620   // Render and notify
4621   application.SendNotification();
4622   application.Render();
4623
4624   unsigned int expectedCount = 2;
4625   unsigned int startIndex = 0;
4626   unsigned int endIndex = 24;
4627
4628   Vector<Vector2> positionsList = DevelTextEditor::GetTextPosition(editor, startIndex, endIndex);
4629   Vector<Vector2> sizeList = DevelTextEditor::GetTextSize(editor, startIndex, endIndex);
4630
4631   DALI_TEST_EQUALS(positionsList.Size(), expectedCount, TEST_LOCATION);
4632   DALI_TEST_EQUALS(sizeList.Size(), expectedCount, TEST_LOCATION);
4633
4634   Vector<Vector2> expectedSizes;
4635   Vector<Vector2> expectedPositions;
4636
4637   expectedPositions.PushBack(Vector2(-1, 0));
4638   expectedSizes.PushBack(Vector2(25, 25));
4639
4640   expectedPositions.PushBack(Vector2(-1, 25));
4641   expectedSizes.PushBack(Vector2(52, 25));
4642
4643   TestTextGeometryUtils::CheckGeometryResult(positionsList, sizeList, expectedPositions, expectedSizes);
4644
4645   END_TEST;
4646 }
4647
4648 int utcDaliTextEditorGeometryEllipsisEnd(void)
4649 {
4650   ToolkitTestApplication application;
4651   tet_infoline(" utcDaliTextEditorGeometryEllipsisEnd");
4652
4653   TextEditor editor = TextEditor::New();
4654   DALI_TEST_CHECK( editor );
4655
4656   application.GetScene().Add( editor );
4657
4658   editor.SetProperty( TextEditor::Property::POINT_SIZE, 7.f );
4659   editor.SetProperty( Actor::Property::SIZE, Vector2( 100.f, 50.f ) );
4660   editor.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT );
4661   editor.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT );
4662   editor.SetProperty( TextEditor::Property::ENABLE_MARKUP, true );
4663   editor.SetProperty( DevelTextEditor::Property::ENABLE_SCROLL_BAR, false );
4664   editor.SetProperty( DevelTextEditor::Property::ELLIPSIS, true );
4665   editor.SetProperty( DevelTextEditor::Property::ELLIPSIS_POSITION, DevelText::EllipsisPosition::END );
4666   editor.SetProperty( TextEditor::Property::TEXT, "line1 \nline2\nline 3\nline4" );
4667
4668   // Avoid a crash when core load gl resources.
4669   application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
4670
4671   // Render and notify
4672   application.SendNotification();
4673   application.Render();
4674
4675   unsigned int expectedCount = 2;
4676   unsigned int startIndex = 0;
4677   unsigned int endIndex = 24;
4678
4679   Vector<Vector2> positionsList = DevelTextEditor::GetTextPosition(editor, startIndex, endIndex);
4680   Vector<Vector2> sizeList = DevelTextEditor::GetTextSize(editor, startIndex, endIndex);
4681
4682   DALI_TEST_EQUALS(positionsList.Size(), expectedCount, TEST_LOCATION);
4683   DALI_TEST_EQUALS(sizeList.Size(), expectedCount, TEST_LOCATION);
4684
4685   Vector<Vector2> expectedSizes;
4686   Vector<Vector2> expectedPositions;
4687
4688   expectedPositions.PushBack(Vector2(-1, 0));
4689   expectedSizes.PushBack(Vector2(59, 25));
4690
4691   expectedPositions.PushBack(Vector2(-1, 25));
4692   expectedSizes.PushBack(Vector2(25, 25));
4693
4694   TestTextGeometryUtils::CheckGeometryResult(positionsList, sizeList, expectedPositions, expectedSizes);
4695
4696   END_TEST;
4697 }
4698
4699 int utcDaliTextEditorGeometryRTL(void)
4700 {
4701   ToolkitTestApplication application;
4702   tet_infoline(" utcDaliTextEditorGeometryRTL");
4703
4704   TextEditor editor = TextEditor::New();
4705   DALI_TEST_CHECK( editor );
4706
4707   application.GetScene().Add( editor );
4708
4709   editor.SetProperty( TextEditor::Property::POINT_SIZE, 7.f );
4710   editor.SetProperty( Actor::Property::SIZE, Vector2( 100.f, 50.f ) );
4711   editor.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT );
4712   editor.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT );
4713   editor.SetProperty( TextEditor::Property::ENABLE_MARKUP, true );
4714   editor.SetProperty( TextEditor::Property::TEXT, "line1 \nline2\nline 3\nالاخيرالسطر" );
4715
4716   // Avoid a crash when core load gl resources.
4717   application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
4718
4719   // Render and notify
4720   application.SendNotification();
4721   application.Render();
4722
4723   unsigned int expectedCount = 4;
4724   unsigned int startIndex = 3;
4725   unsigned int endIndex = 24;
4726
4727   Vector<Vector2> positionsList = DevelTextEditor::GetTextPosition(editor, startIndex, endIndex);
4728   Vector<Vector2> sizeList = DevelTextEditor::GetTextSize(editor, startIndex, endIndex);
4729
4730   DALI_TEST_EQUALS(positionsList.Size(), expectedCount, TEST_LOCATION);
4731   DALI_TEST_EQUALS(sizeList.Size(), expectedCount, TEST_LOCATION);
4732
4733   Vector<Vector2> expectedSizes;
4734   Vector<Vector2> expectedPositions;
4735
4736   expectedPositions.PushBack(Vector2(24, 0));
4737   expectedSizes.PushBack(Vector2(33, 25));
4738
4739   expectedPositions.PushBack(Vector2(-1, 25));
4740   expectedSizes.PushBack(Vector2(52, 25));
4741
4742   expectedPositions.PushBack(Vector2(-1, 50));
4743   expectedSizes.PushBack(Vector2(59, 25));
4744
4745   expectedPositions.PushBack(Vector2(61, 75));
4746   expectedSizes.PushBack(Vector2(37, 25));
4747
4748   TestTextGeometryUtils::CheckGeometryResult(positionsList, sizeList, expectedPositions, expectedSizes);
4749
4750   END_TEST;
4751 }
4752
4753 int utcDaliTextEditorGeometryGlyphMiddle(void)
4754 {
4755   ToolkitTestApplication application;
4756   tet_infoline(" utcDaliTextEditorGeometryGlyphMiddle");
4757
4758   TextEditor editor = TextEditor::New();
4759   DALI_TEST_CHECK( editor );
4760
4761   application.GetScene().Add( editor );
4762
4763   editor.SetProperty( TextEditor::Property::POINT_SIZE, 7.f );
4764   editor.SetProperty( Actor::Property::SIZE, Vector2( 150.f, 200.f ) );
4765   editor.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT );
4766   editor.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT );
4767   editor.SetProperty( TextEditor::Property::ENABLE_MARKUP, true );
4768   editor.SetProperty( TextEditor::Property::TEXT, "لا تحتوي على لا" );
4769
4770   // Avoid a crash when core load gl resources.
4771   application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
4772
4773   // Render and notify
4774   application.SendNotification();
4775   application.Render();
4776
4777   unsigned int expectedCount = 1;
4778   unsigned int startIndex = 1;
4779   unsigned int endIndex = 13;
4780
4781   Vector<Vector2> positionsList = DevelTextEditor::GetTextPosition(editor, startIndex, endIndex);
4782   Vector<Vector2> sizeList = DevelTextEditor::GetTextSize(editor, startIndex, endIndex);
4783
4784   DALI_TEST_EQUALS(positionsList.Size(), expectedCount, TEST_LOCATION);
4785   DALI_TEST_EQUALS(sizeList.Size(), expectedCount, TEST_LOCATION);
4786
4787   Vector<Vector2> expectedSizes;
4788   Vector<Vector2> expectedPositions;
4789
4790   expectedPositions.PushBack(Vector2(6, 0));
4791   expectedSizes.PushBack(Vector2(124, 25));
4792
4793   TestTextGeometryUtils::CheckGeometryResult(positionsList, sizeList, expectedPositions, expectedSizes);
4794
4795   END_TEST;
4796 }
4797
4798 int utcDaliTextEditorSelectionClearedSignal(void)
4799 {
4800   ToolkitTestApplication application;
4801   tet_infoline(" utcDaliTextEditorSelectionClearedSignal");
4802
4803   TextEditor editor = TextEditor::New();
4804   DALI_TEST_CHECK( editor );
4805
4806   application.GetScene().Add( editor );
4807
4808   // connect to the selection changed signal.
4809   ConnectionTracker* testTracker = new ConnectionTracker();
4810   DevelTextEditor::SelectionClearedSignal(editor).Connect(&TestSelectionClearedCallback);
4811   bool selectionClearedSignal = false;
4812   editor.ConnectSignal( testTracker, "selectionCleared",   CallbackFunctor(&selectionClearedSignal) );
4813
4814   editor.SetProperty( TextEditor::Property::TEXT, "Hello\nworld\nHello world" );
4815   editor.SetProperty( TextEditor::Property::POINT_SIZE, 10.f );
4816   editor.SetProperty( Actor::Property::SIZE, Vector2( 100.f, 50.f ) );
4817   editor.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT );
4818   editor.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT );
4819
4820   // Avoid a crash when core load gl resources.
4821   application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
4822
4823   // Render and notify
4824   application.SendNotification();
4825   application.Render();
4826
4827   // Tap on the text editor
4828   TestGenerateTap( application, 3.0f, 25.0f );
4829
4830   // Render and notify
4831   application.SendNotification();
4832   application.Render();
4833
4834   // Move to second line of the text & Select some text in the right of the current cursor position
4835   application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_DOWN, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
4836   application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_RIGHT, KEY_SHIFT_MODIFIER, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
4837
4838   // remove selection
4839   application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_ESCAPE, 0, 0, Integration::KeyEvent::UP, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
4840
4841   // Render and notify
4842   application.SendNotification();
4843   application.Render();
4844
4845   DALI_TEST_CHECK(gSelectionClearedCallbackCalled);
4846
4847   // Render and notify
4848   application.SendNotification();
4849   application.Render();
4850
4851   // Tap on the text editor
4852   TestGenerateTap( application, 3.0f, 25.0f );
4853
4854   // Render and notify
4855   application.SendNotification();
4856   application.Render();
4857
4858   gSelectionClearedCallbackCalled = false;
4859
4860   // Move to second line of the text & select.
4861   application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_DOWN, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
4862   application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_RIGHT, KEY_SHIFT_MODIFIER, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
4863
4864   //remove selection
4865   application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_RIGHT, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
4866
4867   // Render and notify
4868   application.SendNotification();
4869   application.Render();
4870
4871   DALI_TEST_CHECK(gSelectionClearedCallbackCalled);
4872
4873   gSelectionClearedCallbackCalled = false;
4874
4875   // Render and notify
4876   application.SendNotification();
4877   application.Render();
4878
4879   // Move to second line of the text & select.
4880   application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_DOWN, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
4881   application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_RIGHT, KEY_SHIFT_MODIFIER, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
4882
4883   // replace C with selected text
4884   application.ProcessEvent( GenerateKey( "c", "", "c", KEY_C_CODE, 0, 0, Integration::KeyEvent::DOWN, "c", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
4885
4886   // Render and notify
4887   application.SendNotification();
4888   application.Render();
4889
4890   DALI_TEST_CHECK(gSelectionClearedCallbackCalled);
4891
4892   gSelectionClearedCallbackCalled = false;
4893
4894   // Render and notify
4895   application.SendNotification();
4896   application.Render();
4897
4898   DevelTextEditor::SelectText( editor ,1, 3 );
4899
4900   // Render and notify
4901   application.SendNotification();
4902   application.Render();
4903
4904   editor.SetProperty( DevelTextEditor::Property::PRIMARY_CURSOR_POSITION, 3);
4905
4906   // Render and notify
4907   application.SendNotification();
4908   application.Render();
4909
4910   DALI_TEST_CHECK(gSelectionClearedCallbackCalled);
4911
4912   gSelectionClearedCallbackCalled = false;
4913
4914   DevelTextEditor::SelectText( editor ,1, 3 );
4915
4916   // Render and notify
4917   application.SendNotification();
4918   application.Render();
4919
4920   // select none
4921   DevelTextEditor::SelectNone(editor);
4922
4923   // Render and notify
4924   application.SendNotification();
4925   application.Render();
4926
4927   DALI_TEST_CHECK(gSelectionClearedCallbackCalled);
4928
4929   END_TEST;
4930 }
4931
4932 int utcDaliTextEditorSelectionWithSecondaryCursor(void)
4933 {
4934   ToolkitTestApplication application;
4935   tet_infoline(" utcDaliTextEditorSelectionWithSecondaryCursor");
4936
4937   // Checks if the actor is created.
4938
4939   TextEditor editor = TextEditor::New();
4940   DALI_TEST_CHECK( editor );
4941
4942   application.GetScene().Add( editor );
4943
4944   editor.SetProperty( TextEditor::Property::ENABLE_MARKUP, true );
4945   editor.SetProperty( TextEditor::Property::TEXT, "اللغة العربية\nمرحبا بالجميع\nالسلام عليكم <span font-size='12' font-family='DejaVu Sans' >Hello world</span>" );
4946   editor.SetProperty( TextEditor::Property::POINT_SIZE, 12.f );
4947   editor.SetProperty( Actor::Property::SIZE, Vector2( 100.f, 50.f ) );
4948   editor.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT );
4949   editor.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT );
4950   editor.SetProperty( DevelTextEditor::Property::MIN_LINE_SIZE, 50.f );
4951   editor.SetProperty( DevelTextEditor::Property::MATCH_SYSTEM_LANGUAGE_DIRECTION, false );
4952
4953   // Avoid a crash when core load gl resources.
4954   application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
4955
4956   // Render and notify
4957   application.SendNotification();
4958   application.Render();
4959
4960   // Tap on the text editor
4961   TestGenerateTap( application, 3.0f, 25.0f );
4962
4963   // Render and notify
4964   application.SendNotification();
4965   application.Render();
4966
4967   //Select the last Arabic word (RTL) & some the space before the English (LTR) letters.
4968   DevelTextEditor::SelectText( editor, 35, 41 );// This will activate the alternative cursor position and thus 'cursorInfo.isSecondaryCursor' will be true.
4969
4970   application.SendNotification();
4971   application.Render();
4972
4973   std::string selectedText = editor.GetProperty( DevelTextEditor::Property::SELECTED_TEXT ).Get<std::string>();
4974   DALI_TEST_EQUALS( "عليكم ", selectedText, TEST_LOCATION );
4975
4976   END_TEST;
4977 }
4978
4979 int utcDaliTextEditorSelectionChangedSignal(void)
4980 {
4981   ToolkitTestApplication application;
4982   tet_infoline(" utcDaliTextEditorSelectionChangedSignal");
4983
4984   TextEditor editor = TextEditor::New();
4985   DALI_TEST_CHECK( editor );
4986
4987   application.GetScene().Add( editor );
4988
4989   // connect to the selection changed signal.
4990   ConnectionTracker* testTracker = new ConnectionTracker();
4991   DevelTextEditor::SelectionChangedSignal(editor).Connect(&TestSelectionChangedCallback);
4992   bool selectionChangedSignal = false;
4993   editor.ConnectSignal( testTracker, "selectionChanged",   CallbackFunctor(&selectionChangedSignal) );
4994
4995   editor.SetProperty( TextEditor::Property::TEXT, "Hello\nworld\nHello world" );
4996   editor.SetProperty( TextEditor::Property::POINT_SIZE, 10.f );
4997   editor.SetProperty( Actor::Property::SIZE, Vector2( 100.f, 50.f ) );
4998   editor.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT );
4999   editor.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT );
5000
5001   // Avoid a crash when core load gl resources.
5002   application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
5003
5004   // Render and notify
5005   application.SendNotification();
5006   application.Render();
5007
5008   // Tap on the text editor
5009   TestGenerateTap( application, 3.0f, 25.0f );
5010
5011   // Render and notify
5012   application.SendNotification();
5013   application.Render();
5014
5015   // Move to second line of the text.
5016   application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_DOWN, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
5017
5018   // Render and notify
5019   application.SendNotification();
5020   application.Render();
5021
5022   // Select some text in the right of the current cursor position
5023   application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_SHIFT_LEFT, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
5024   application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_RIGHT, KEY_SHIFT_MODIFIER, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
5025
5026   // Render and notify
5027   application.SendNotification();
5028   application.Render();
5029
5030   DALI_TEST_CHECK(gSelectionChangedCallbackCalled);
5031   DALI_TEST_EQUALS(oldSelectionStart, oldSelectionEnd, TEST_LOCATION);
5032
5033   gSelectionChangedCallbackCalled = false;
5034
5035   application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_RIGHT, KEY_SHIFT_MODIFIER, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
5036
5037   // Render and notify
5038   application.SendNotification();
5039   application.Render();
5040
5041   DALI_TEST_CHECK(gSelectionChangedCallbackCalled);
5042   DALI_TEST_EQUALS(oldSelectionStart, 6, TEST_LOCATION);
5043   DALI_TEST_EQUALS(oldSelectionEnd, 7, TEST_LOCATION);
5044
5045   gSelectionChangedCallbackCalled = false;
5046
5047   application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_ESCAPE, 0, 0, Integration::KeyEvent::UP, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
5048
5049   // Render and notify
5050   application.SendNotification();
5051   application.Render();
5052
5053   DALI_TEST_CHECK(gSelectionChangedCallbackCalled);
5054   DALI_TEST_EQUALS(oldSelectionStart, 6, TEST_LOCATION);
5055   DALI_TEST_EQUALS(oldSelectionEnd, 8, TEST_LOCATION);
5056
5057   gSelectionChangedCallbackCalled = false;
5058   editor.SetKeyInputFocus();
5059
5060   // Render and notify
5061   application.SendNotification();
5062   application.Render();
5063
5064   DevelTextEditor::SelectText( editor ,0, 5 );
5065
5066   application.SendNotification();
5067   application.Render();
5068
5069   DALI_TEST_CHECK(gSelectionChangedCallbackCalled);
5070   DALI_TEST_EQUALS(oldSelectionStart, oldSelectionEnd, TEST_LOCATION);
5071
5072   gSelectionChangedCallbackCalled = false;
5073
5074   editor.SetProperty( DevelTextEditor::Property::PRIMARY_CURSOR_POSITION, 3);
5075
5076   // Render and notify
5077   application.SendNotification();
5078   application.Render();
5079
5080   DALI_TEST_CHECK(gSelectionChangedCallbackCalled);
5081   DALI_TEST_EQUALS(oldSelectionStart, 0, TEST_LOCATION);
5082   DALI_TEST_EQUALS(oldSelectionEnd, 5, TEST_LOCATION);
5083
5084   gSelectionChangedCallbackCalled = false;
5085
5086   // select all text
5087   DevelTextEditor::SelectWholeText(editor);
5088
5089   // Render and notify
5090   application.SendNotification();
5091   application.Render();
5092
5093   DALI_TEST_CHECK(gSelectionChangedCallbackCalled);
5094   DALI_TEST_EQUALS(oldSelectionStart, oldSelectionEnd, TEST_LOCATION);
5095
5096   gSelectionChangedCallbackCalled = false;
5097
5098   // select none
5099   DevelTextEditor::SelectNone(editor);
5100
5101   // Render and notify
5102   application.SendNotification();
5103   application.Render();
5104
5105   DALI_TEST_CHECK(gSelectionChangedCallbackCalled);
5106   DALI_TEST_EQUALS(oldSelectionStart, 0, TEST_LOCATION);
5107   DALI_TEST_EQUALS(oldSelectionEnd, 23, TEST_LOCATION);
5108
5109   END_TEST;
5110 }
5111
5112 int UtcDaliToolkitTextEditorStrikethroughGeneration(void)
5113 {
5114   ToolkitTestApplication application;
5115   tet_infoline(" UtcDaliToolkitTextEditorStrikethroughGeneration");
5116
5117   TextEditor textEditor = TextEditor::New();
5118   textEditor.SetProperty( TextEditor::Property::TEXT, "Test" );
5119   textEditor.SetProperty( Actor::Property::SIZE, Vector2( 200.0f, 100.f ) );
5120   textEditor.SetProperty( TextEditor::Property::POINT_SIZE, 10) ;
5121   textEditor.SetProperty( TextEditor::Property::FONT_FAMILY, "DejaVu Sans");
5122
5123   application.GetScene().Add( textEditor );
5124   application.SendNotification();
5125   application.Render();
5126
5127   Property::Map strikethroughMapSet;
5128   Property::Map strikethroughMapGet;
5129
5130   strikethroughMapSet.Insert( "enable", true );
5131   strikethroughMapSet.Insert( "color", Color::RED );
5132   strikethroughMapSet.Insert( "height", 2.0f );
5133
5134   // Check the strikethrough property
5135   textEditor.SetProperty( DevelTextEditor::Property::STRIKETHROUGH, strikethroughMapSet );
5136   strikethroughMapGet = textEditor.GetProperty<Property::Map>( DevelTextEditor::Property::STRIKETHROUGH );
5137   textEditor.SetProperty( TextEditor::Property::TEXT, "Test1" );
5138   DALI_TEST_EQUALS( strikethroughMapGet.Count(), strikethroughMapSet.Count(), TEST_LOCATION );
5139   DALI_TEST_EQUALS( DaliTestCheckMaps( strikethroughMapGet, strikethroughMapSet ), true, TEST_LOCATION );
5140
5141   // Render and notify
5142   application.SendNotification();
5143   application.Render();
5144
5145   strikethroughMapSet.Clear();
5146   strikethroughMapGet.Clear();
5147
5148   END_TEST;
5149 }
5150
5151 int utcDaliTextEditorInsertCharacterAfterInitWithResizePolicyNaturalSize(void)
5152 {
5153
5154   //This is to test a crash when used Resize Policy equals USE_NATURAL_SIZE
5155   //DaliException on vector: "Iterator not inside vector"
5156
5157   ToolkitTestApplication application;
5158   tet_infoline(" utcDaliTextEditorInsertCharacterAfterInitWithResizePolicyNaturalSize");
5159
5160   TextEditor editor = TextEditor::New();
5161   DALI_TEST_CHECK( editor );
5162
5163   application.GetScene().Add( editor );
5164
5165   // Avoid a crash when core load gl resources.
5166   application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
5167
5168   //Set multilines text
5169   editor.SetProperty(Dali::Toolkit::TextEditor::Property::TEXT, "Hello \n World");
5170   editor.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT );
5171   editor.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT );
5172
5173   //Set ResizePolicy to NaturalSize
5174   editor.SetProperty(Dali::Actor::Property::WIDTH_RESIZE_POLICY, ResizePolicy::USE_NATURAL_SIZE);
5175
5176   // Render and notify
5177   application.SendNotification();
5178   application.Render();
5179
5180   // Create a tap event to touch the text editor.
5181   TestGenerateTap( application, 5.0f, 5.0f );
5182
5183   // Render and notify
5184   application.SendNotification();
5185   application.Render();
5186
5187   // Set currsor and add character (in first line)
5188   editor.SetProperty( DevelTextEditor::Property::PRIMARY_CURSOR_POSITION, 5);
5189   application.ProcessEvent( GenerateKey( "d", "", "d", KEY_D_CODE, 0, 0, Integration::KeyEvent::DOWN, "d", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
5190   application.ProcessEvent( GenerateKey( "d", "", "d", KEY_D_CODE, 0, 0, Integration::KeyEvent::UP, "d", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
5191
5192   // Render and notify
5193   application.SendNotification();
5194   application.Render();
5195
5196   //Check the changed text and cursor position
5197   DALI_TEST_EQUALS( editor.GetProperty( TextEditor::Property::TEXT ).Get<std::string>(), "Hellod \n World", TEST_LOCATION );
5198   DALI_TEST_EQUALS( editor.GetProperty( DevelTextEditor::Property::PRIMARY_CURSOR_POSITION ).Get<int>(), 6, TEST_LOCATION );
5199
5200   // Render and notify
5201   application.SendNotification();
5202   application.Render();
5203
5204   END_TEST;
5205 }
5206
5207 int utcDaliTextEditorRemoveCharacterAfterInitWithResizePolicyNaturalSize(void)
5208 {
5209
5210   //This is to test a crash when used Resize Policy equals USE_NATURAL_SIZE
5211   //DaliException on vector: "Iterator not inside vector"
5212
5213   ToolkitTestApplication application;
5214   tet_infoline(" utcDaliTextEditorRemoveCharacterAfterInitWithResizePolicyNaturalSize");
5215
5216   TextEditor editor = TextEditor::New();
5217   DALI_TEST_CHECK( editor );
5218
5219   application.GetScene().Add( editor );
5220
5221   // Avoid a crash when core load gl resources.
5222   application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
5223
5224   //Set multilines text
5225   editor.SetProperty(Dali::Toolkit::TextEditor::Property::TEXT, "Hello \n World");
5226   editor.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT );
5227   editor.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT );
5228
5229   //Set ResizePolicy to NaturalSize
5230   editor.SetProperty(Dali::Actor::Property::WIDTH_RESIZE_POLICY, ResizePolicy::USE_NATURAL_SIZE);
5231
5232   // Set currsor
5233   editor.SetProperty( DevelTextEditor::Property::PRIMARY_CURSOR_POSITION, 5);
5234   application.SendNotification();
5235   application.Render();
5236
5237   // Set focus and remove character
5238   editor.SetKeyInputFocus();
5239   application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_BACKSPACE, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
5240
5241   // Render and notify
5242   application.SendNotification();
5243   application.Render();
5244
5245   //Check the changed text and cursor position
5246   DALI_TEST_EQUALS( editor.GetProperty( TextEditor::Property::TEXT ).Get<std::string>(), "Hell \n World", TEST_LOCATION );
5247   DALI_TEST_EQUALS( editor.GetProperty( DevelTextEditor::Property::PRIMARY_CURSOR_POSITION ).Get<int>(), 4, TEST_LOCATION );
5248
5249   // Render and notify
5250   application.SendNotification();
5251   application.Render();
5252
5253   END_TEST;
5254 }
5255
5256 int utcDaliTextEditorCutSelectedTextAfterInitWithResizePolicyNaturalSize(void)
5257 {
5258
5259   //This is to test a crash when used Resize Policy equals USE_NATURAL_SIZE
5260   //DaliException on vector: "Iterator not inside vector"
5261
5262   ToolkitTestApplication application;
5263   tet_infoline(" utcDaliTextEditorCutSelectedTextAfterInitWithResizePolicyNaturalSize");
5264
5265   TextEditor editor = TextEditor::New();
5266   DALI_TEST_CHECK( editor );
5267
5268   application.GetScene().Add( editor );
5269
5270   // Avoid a crash when core load gl resources.
5271   application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
5272
5273   //Set multilines text
5274   editor.SetProperty(Dali::Toolkit::TextEditor::Property::TEXT, "Hello \n World");
5275   editor.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT );
5276   editor.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT );
5277
5278   //Set ResizePolicy to NaturalSize
5279   editor.SetProperty(Dali::Actor::Property::WIDTH_RESIZE_POLICY, ResizePolicy::USE_NATURAL_SIZE);
5280
5281   //Select text at initialization (before the first render)
5282   DevelTextEditor::SelectText( editor ,3, 5 );
5283
5284   // Render and notify
5285   application.SendNotification();
5286   application.Render();
5287
5288   //Cut text
5289   application.ProcessEvent( GenerateKey( "", "", "", Dali::DevelKey::DALI_KEY_CONTROL_LEFT, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
5290   application.ProcessEvent( GenerateKey( "x", "x", "x", KEY_X_CODE, KEY_CONTROL_MODIFIER, 0, Integration::KeyEvent::DOWN, "x", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
5291
5292   // Render and notify
5293   application.SendNotification();
5294   application.Render();
5295
5296   //Check the changed text and cursor position
5297   DALI_TEST_EQUALS( editor.GetProperty( TextEditor::Property::TEXT ).Get<std::string>(), "Hel \n World", TEST_LOCATION );
5298   DALI_TEST_EQUALS( editor.GetProperty( DevelTextEditor::Property::PRIMARY_CURSOR_POSITION ).Get<int>(), 3, TEST_LOCATION );
5299
5300   // Render and notify
5301   application.SendNotification();
5302   application.Render();
5303
5304   END_TEST;
5305 }
5306
5307
5308 int utcDaliTextEditorDoubleEnterAfterInitWithResizePolicyNaturalSize(void)
5309 {
5310
5311   //This is to test a crash when used Resize Policy equals USE_NATURAL_SIZE
5312   //DaliException on vector: "Iterator not inside vector"
5313
5314   ToolkitTestApplication application;
5315   tet_infoline(" utcDaliTextEditorDoubleEnterAfterInitWithResizePolicyNaturalSize");
5316
5317   TextEditor editor = TextEditor::New();
5318   DALI_TEST_CHECK( editor );
5319
5320   application.GetScene().Add( editor );
5321
5322   // Avoid a crash when core load gl resources.
5323   application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
5324
5325   //Set multilines text
5326   editor.SetProperty(Dali::Toolkit::TextEditor::Property::TEXT, "Hello \n World");
5327   editor.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT );
5328   editor.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT );
5329
5330   //Set ResizePolicy to NaturalSize
5331   editor.SetProperty(Dali::Actor::Property::WIDTH_RESIZE_POLICY, ResizePolicy::USE_NATURAL_SIZE);
5332
5333   // Set currsor
5334   editor.SetProperty( DevelTextEditor::Property::PRIMARY_CURSOR_POSITION, 5);
5335   application.SendNotification();
5336   application.Render();
5337
5338   // Set focus and double enter (new line)
5339   editor.SetKeyInputFocus();
5340   application.ProcessEvent(GenerateKey("Enter", "", "\n", 13, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
5341   application.ProcessEvent(GenerateKey("Enter", "", "\n", 13, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
5342
5343   // Render and notify
5344   application.SendNotification();
5345   application.Render();
5346
5347   //Check the changed text and cursor position
5348   DALI_TEST_EQUALS( editor.GetProperty( TextEditor::Property::TEXT ).Get<std::string>(), "Hello\n\n \n World", TEST_LOCATION );
5349   DALI_TEST_EQUALS( editor.GetProperty( DevelTextEditor::Property::PRIMARY_CURSOR_POSITION ).Get<int>(), 7, TEST_LOCATION );
5350
5351   // Render and notify
5352   application.SendNotification();
5353   application.Render();
5354
5355   END_TEST;
5356 }