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