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