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