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