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