Add SelectionCleared signal
[platform/core/uifw/dali-toolkit.git] / automated-tests / src / dali-toolkit / utc-Dali-TextEditor.cpp
1 /*
2  * Copyright (c) 2021 Samsung Electronics Co., Ltd.
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  * http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  *
16  */
17
18 #include <iostream>
19 #include <stdlib.h>
20 #include <unistd.h>
21 #include <dali/public-api/rendering/renderer.h>
22 #include <dali/devel-api/adaptor-framework/clipboard.h>
23 #include <dali/devel-api/adaptor-framework/key-devel.h>
24 #include <dali/devel-api/text-abstraction/font-client.h>
25 #include <dali/integration-api/events/key-event-integ.h>
26 #include <dali/integration-api/events/touch-event-integ.h>
27 #include <dali-toolkit-test-suite-utils.h>
28 #include <dali-toolkit/dali-toolkit.h>
29 #include <dali-toolkit/devel-api/controls/text-controls/text-editor-devel.h>
30 #include <dali-toolkit/devel-api/text/rendering-backend.h>
31 #include <dali-toolkit/devel-api/text/text-enumerations-devel.h>
32
33 using namespace Dali;
34 using namespace Toolkit;
35
36 void dali_texteditor_startup(void)
37 {
38   test_return_value = TET_UNDEF;
39 }
40
41 void dali_texteditor_cleanup(void)
42 {
43   test_return_value = TET_PASS;
44 }
45
46 namespace
47 {
48
49 const char* const PROPERTY_NAME_RENDERING_BACKEND                    = "renderingBackend";
50 const char* const PROPERTY_NAME_TEXT                                 = "text";
51 const char* const PROPERTY_NAME_TEXT_COLOR                           = "textColor";
52 const char* const PROPERTY_NAME_FONT_FAMILY                          = "fontFamily";
53 const char* const PROPERTY_NAME_FONT_STYLE                           = "fontStyle";
54 const char* const PROPERTY_NAME_POINT_SIZE                           = "pointSize";
55 const char* const PROPERTY_NAME_HORIZONTAL_ALIGNMENT                 = "horizontalAlignment";
56 const char* const PROPERTY_NAME_SCROLL_THRESHOLD                     = "scrollThreshold";
57 const char* const PROPERTY_NAME_SCROLL_SPEED                         = "scrollSpeed";
58 const char* const PROPERTY_NAME_PRIMARY_CURSOR_COLOR                 = "primaryCursorColor";
59 const char* const PROPERTY_NAME_SECONDARY_CURSOR_COLOR               = "secondaryCursorColor";
60 const char* const PROPERTY_NAME_ENABLE_CURSOR_BLINK                  = "enableCursorBlink";
61 const char* const PROPERTY_NAME_CURSOR_BLINK_INTERVAL                = "cursorBlinkInterval";
62 const char* const PROPERTY_NAME_CURSOR_BLINK_DURATION                = "cursorBlinkDuration";
63 const char* const PROPERTY_NAME_CURSOR_WIDTH                         = "cursorWidth";
64 const char* const PROPERTY_NAME_GRAB_HANDLE_IMAGE                    = "grabHandleImage";
65 const char* const PROPERTY_NAME_GRAB_HANDLE_PRESSED_IMAGE            = "grabHandlePressedImage";
66 const char* const PROPERTY_NAME_SELECTION_HANDLE_IMAGE_LEFT          = "selectionHandleImageLeft";
67 const char* const PROPERTY_NAME_SELECTION_HANDLE_IMAGE_RIGHT         = "selectionHandleImageRight";
68 const char* const PROPERTY_NAME_SELECTION_HANDLE_PRESSED_IMAGE_LEFT  = "selectionHandlePressedImageLeft";
69 const char* const PROPERTY_NAME_SELECTION_HANDLE_PRESSED_IMAGE_RIGHT = "selectionHandlePressedImageRight";
70 const char* const PROPERTY_NAME_SELECTION_HANDLE_MARKER_IMAGE_LEFT   = "selectionHandleMarkerImageLeft";
71 const char* const PROPERTY_NAME_SELECTION_HANDLE_MARKER_IMAGE_RIGHT  = "selectionHandleMarkerImageRight";
72 const char* const PROPERTY_NAME_SELECTION_HIGHLIGHT_COLOR            = "selectionHighlightColor";
73 const char* const PROPERTY_NAME_DECORATION_BOUNDING_BOX              = "decorationBoundingBox";
74 const char* const PROPERTY_NAME_ENABLE_MARKUP                        = "enableMarkup";
75 const char* const PROPERTY_NAME_INPUT_COLOR                          = "inputColor";
76 const char* const PROPERTY_NAME_INPUT_FONT_FAMILY                    = "inputFontFamily";
77 const char* const PROPERTY_NAME_INPUT_FONT_STYLE                     = "inputFontStyle";
78 const char* const PROPERTY_NAME_INPUT_POINT_SIZE                     = "inputPointSize";
79
80 const char* const PROPERTY_NAME_LINE_SPACING                         = "lineSpacing";
81 const char* const PROPERTY_NAME_INPUT_LINE_SPACING                   = "inputLineSpacing";
82 const char* const PROPERTY_NAME_UNDERLINE                            = "underline";
83 const char* const PROPERTY_NAME_INPUT_UNDERLINE                      = "inputUnderline";
84 const char* const PROPERTY_NAME_SHADOW                               = "shadow";
85 const char* const PROPERTY_NAME_INPUT_SHADOW                         = "inputShadow";
86 const char* const PROPERTY_NAME_EMBOSS                               = "emboss";
87 const char* const PROPERTY_NAME_INPUT_EMBOSS                         = "inputEmboss";
88 const char* const PROPERTY_NAME_OUTLINE                              = "outline";
89 const char* const PROPERTY_NAME_INPUT_OUTLINE                        = "inputOutline";
90
91 const char* const PROPERTY_NAME_SMOOTH_SCROLL                        = "smoothScroll";
92 const char* const PROPERTY_NAME_SMOOTH_SCROLL_DURATION               = "smoothScrollDuration";
93 const char* const PROPERTY_NAME_ENABLE_SCROLL_BAR                    = "enableScrollBar";
94 const char* const PROPERTY_NAME_SCROLL_BAR_SHOW_DURATION             = "scrollBarShowDuration";
95 const char* const PROPERTY_NAME_SCROLL_BAR_FADE_DURATION             = "scrollBarFadeDuration";
96 const char* const PROPERTY_NAME_PIXEL_SIZE                           = "pixelSize";
97 const char* const PROPERTY_NAME_LINE_COUNT                           = "lineCount";
98 const char* const PROPERTY_NAME_PLACEHOLDER_TEXT                     = "placeholderText";
99 const char* const PROPERTY_NAME_PLACEHOLDER_TEXT_COLOR               = "placeholderTextColor";
100 const char* const PROPERTY_NAME_ENABLE_SELECTION                     = "enableSelection";
101 const char* const PROPERTY_NAME_PLACEHOLDER                          = "placeholder";
102 const char* const PROPERTY_NAME_ENABLE_SHIFT_SELECTION               = "enableShiftSelection";
103 const char* const PROPERTY_NAME_ENABLE_GRAB_HANDLE                   = "enableGrabHandle";
104 const char* const PROPERTY_NAME_MATCH_SYSTEM_LANGUAGE_DIRECTION      = "matchSystemLanguageDirection";
105 const char* const PROPERTY_NAME_MAX_LENGTH                           = "maxLength";
106 const char* const PROPERTY_NAME_FONT_SIZE_SCALE                      = "fontSizeScale";
107 const char* const PROPERTY_NAME_GRAB_HANDLE_COLOR                    = "grabHandleColor";
108 const char* const PROPERTY_NAME_ENABLE_GRAB_HANDLE_POPUP             = "enableGrabHandlePopup";
109 const char* const PROPERTY_NAME_INPUT_METHOD_SETTINGS                = "inputMethodSettings";
110 const char* const PROPERTY_NAME_INPUT_FILTER                         = "inputFilter";
111
112 const Vector4 PLACEHOLDER_TEXT_COLOR( 0.8f, 0.8f, 0.8f, 0.8f );
113 const Dali::Vector4 LIGHT_BLUE( 0.75f, 0.96f, 1.f, 1.f ); // The text highlight color.
114
115 const float RENDER_FRAME_INTERVAL = 16.66f;
116
117 const unsigned int DEFAULT_FONT_SIZE = 1152u;
118 const std::string DEFAULT_FONT_DIR( "/resources/fonts" );
119
120 const int KEY_A_CODE = 38;
121 const int KEY_D_CODE = 40;
122 const int KEY_C_CODE = 54;
123 const int KEY_V_CODE = 55;
124 const int KEY_X_CODE = 53;
125 const int KEY_WHITE_SPACE_CODE = 65;
126
127 const int KEY_SHIFT_MODIFIER = 257;
128 const int KEY_CONTROL_MODIFIER = 258;
129
130 const char* HANDLE_IMAGE_FILE_NAME = TEST_RESOURCE_DIR "/insertpoint-icon.png";
131 const char* HANDLE_LEFT_SELECTION_FILE_NAME = TEST_RESOURCE_DIR "/selection_handle_drop_left.png";
132 const char* HANDLE_RIGHT_SELECTION_FILE_NAME = TEST_RESOURCE_DIR "/selection_handle_drop_right.png";
133
134 const std::string DEFAULT_DEVICE_NAME("hwKeyboard");
135
136 static bool gSelectionChangedCallbackCalled;
137 static uint32_t oldSelectionStart;
138 static uint32_t oldSelectionEnd;
139 static bool gSelectionClearedCallbackCalled;
140 static bool gAnchorClickedCallBackCalled;
141 static bool gAnchorClickedCallBackNotCalled;
142 static bool gTextChangedCallBackCalled;
143 static bool gInputFilteredAcceptedCallbackCalled;
144 static bool gInputFilteredRejectedCallbackCalled;
145 static bool gInputStyleChangedCallbackCalled;
146 static bool gMaxCharactersCallBackCalled;
147 static bool gCursorPositionChangedCallbackCalled;
148 static uint32_t oldCursorPos;
149 static Dali::Toolkit::TextEditor::InputStyle::Mask gInputStyleMask;
150
151 struct CallbackFunctor
152 {
153   CallbackFunctor(bool* callbackFlag)
154   : mCallbackFlag( callbackFlag )
155   {
156   }
157
158   void operator()()
159   {
160     *mCallbackFlag = true;
161   }
162   bool* mCallbackFlag;
163 };
164
165 static void TestSelectionClearedCallback(TextEditor control)
166 {
167   tet_infoline(" TestSelectionClearedCallback");
168
169   gSelectionClearedCallbackCalled = true;
170 }
171
172 static void TestSelectionChangedCallback(TextEditor control, uint32_t oldStart, uint32_t oldEnd)
173 {
174   tet_infoline(" TestSelectionChangedCallback");
175
176   gSelectionChangedCallbackCalled = true;
177   oldSelectionStart = oldStart;
178   oldSelectionEnd   = oldEnd;
179 }
180
181 static void TestAnchorClickedCallback(TextEditor control, const char* href, unsigned int hrefLength)
182 {
183   tet_infoline(" TestAnchorClickedCallback");
184
185   gAnchorClickedCallBackNotCalled = false;
186
187   if (!strcmp(href, "https://www.tizen.org") && hrefLength == strlen(href))
188   {
189     gAnchorClickedCallBackCalled = true;
190   }
191 }
192
193 static void TestCursorPositionChangedCallback( TextEditor control, unsigned int oldPos )
194 {
195   tet_infoline(" TestCursorPositionChangedCallback");
196
197   gCursorPositionChangedCallbackCalled = true;
198   oldCursorPos = oldPos;
199 }
200
201 static void TestTextChangedCallback( TextEditor control )
202 {
203   tet_infoline(" TestTextChangedCallback");
204
205   gTextChangedCallBackCalled = true;
206 }
207
208 static void TestInputStyleChangedCallback( TextEditor control, TextEditor::InputStyle::Mask mask )
209 {
210   tet_infoline(" TestInputStyleChangedCallback");
211
212   gInputStyleChangedCallbackCalled = true;
213   gInputStyleMask = mask;
214 }
215
216 static void TestMaxLengthReachedCallback( TextEditor control )
217 {
218   tet_infoline(" TestMaxLengthReachedCallback");
219
220   gMaxCharactersCallBackCalled = true;
221 }
222
223 static void TestInputFilteredCallback(TextEditor control, Toolkit::InputFilter::Property::Type type)
224 {
225   tet_infoline(" TestInputFilteredCallback");
226
227   if(type == Toolkit::InputFilter::Property::ACCEPTED)
228   {
229     gInputFilteredAcceptedCallbackCalled = true;
230   }
231   else if(type == Toolkit::InputFilter::Property::REJECTED)
232   {
233     gInputFilteredRejectedCallbackCalled = true;
234   }
235 }
236
237 // Generate a KeyEvent to send to Core.
238 Integration::KeyEvent GenerateKey( const std::string& keyName,
239                                    const std::string& logicalKey,
240                                    const std::string& keyString,
241                                    int keyCode,
242                                    int keyModifier,
243                                    unsigned long timeStamp,
244                                    const Integration::KeyEvent::State& keyState,
245                                    const std::string& compose = "",
246                                    const std::string& deviceName = DEFAULT_DEVICE_NAME,
247                                    const Device::Class::Type& deviceClass = Device::Class::NONE,
248                                    const Device::Subclass::Type& deviceSubclass = Device::Subclass::NONE )
249 {
250   return Integration::KeyEvent( keyName,
251                                 logicalKey,
252                                 keyString,
253                                 keyCode,
254                                 keyModifier,
255                                 timeStamp,
256                                 keyState,
257                                 compose,
258                                 deviceName,
259                                 deviceClass,
260                                 deviceSubclass );
261 }
262
263 Dali::Integration::Point GetPointDownInside( Vector2& pos )
264 {
265   Dali::Integration::Point point;
266   point.SetState( PointState::DOWN );
267   point.SetScreenPosition( pos );
268   return point;
269 }
270
271 Dali::Integration::Point GetPointUpInside( Vector2& pos )
272 {
273   Dali::Integration::Point point;
274   point.SetState( PointState::UP );
275   point.SetScreenPosition( pos );
276   return point;
277 }
278
279 bool DaliTestCheckMaps( const Property::Map& fontStyleMapGet, const Property::Map& fontStyleMapSet )
280 {
281   if( fontStyleMapGet.Count() == fontStyleMapSet.Count() )
282   {
283     for( unsigned int index = 0u; index < fontStyleMapGet.Count(); ++index )
284     {
285       const KeyValuePair& valueGet = fontStyleMapGet.GetKeyValue( index );
286
287       Property::Value* valueSet = NULL;
288       if ( valueGet.first.type == Property::Key::INDEX )
289       {
290         valueSet = fontStyleMapSet.Find( valueGet.first.indexKey );
291       }
292       else
293       {
294         // Get Key is a string so searching Set Map for a string key
295         valueSet = fontStyleMapSet.Find( valueGet.first.stringKey );
296       }
297
298       if( NULL != valueSet )
299       {
300         if( valueSet->GetType() == Dali::Property::STRING && ( valueGet.second.Get<std::string>() != valueSet->Get<std::string>() ) )
301         {
302           tet_printf( "Value got : [%s], expected : [%s]", valueGet.second.Get<std::string>().c_str(), valueSet->Get<std::string>().c_str() );
303           return false;
304         }
305         else if( valueSet->GetType() == Dali::Property::BOOLEAN && ( valueGet.second.Get<bool>() != valueSet->Get<bool>() ) )
306         {
307           tet_printf( "Value got : [%d], expected : [%d]", valueGet.second.Get<bool>(), valueSet->Get<bool>() );
308           return false;
309         }
310         else if( valueSet->GetType() == Dali::Property::INTEGER && ( valueGet.second.Get<int>() != valueSet->Get<int>() ) )
311         {
312           tet_printf( "Value got : [%d], expected : [%d]", valueGet.second.Get<int>(), valueSet->Get<int>() );
313           return false;
314         }
315         else if( valueSet->GetType() == Dali::Property::FLOAT && ( valueGet.second.Get<float>() != valueSet->Get<float>() ) )
316         {
317           tet_printf( "Value got : [%f], expected : [%f]", valueGet.second.Get<float>(), valueSet->Get<float>() );
318           return false;
319         }
320         else if( valueSet->GetType() == Dali::Property::VECTOR2 && ( valueGet.second.Get<Vector2>() != valueSet->Get<Vector2>() ) )
321         {
322           Vector2 vector2Get = valueGet.second.Get<Vector2>();
323           Vector2 vector2Set = valueSet->Get<Vector2>();
324           tet_printf( "Value got : [%f, %f], expected : [%f, %f]", vector2Get.x, vector2Get.y, vector2Set.x, vector2Set.y );
325           return false;
326         }
327         else if( valueSet->GetType() == Dali::Property::VECTOR4 && ( valueGet.second.Get<Vector4>() != valueSet->Get<Vector4>() ) )
328         {
329           Vector4 vector4Get = valueGet.second.Get<Vector4>();
330           Vector4 vector4Set = valueSet->Get<Vector4>();
331           tet_printf( "Value got : [%f, %f, %f, %f], expected : [%f, %f, %f, %f]", vector4Get.r, vector4Get.g, vector4Get.b, vector4Get.a, vector4Set.r, vector4Set.g, vector4Set.b, vector4Set.a );
332           return false;
333         }
334       }
335       else
336       {
337         if ( valueGet.first.type == Property::Key::INDEX )
338         {
339           tet_printf( "  The key %d doesn't exist.", valueGet.first.indexKey );
340         }
341         else
342         {
343           tet_printf( "  The key %s doesn't exist.", valueGet.first.stringKey.c_str() );
344         }
345         return false;
346       }
347     }
348   }
349
350   return true;
351 }
352
353 class ScrollStateChangeCallback : public Dali::ConnectionTracker
354 {
355 public:
356   ScrollStateChangeCallback(bool& startedCalled, bool& finishedCalled)
357   : mStartedCalled( startedCalled ),
358     mFinishedCalled( finishedCalled )
359   {
360   }
361
362   void Callback( TextEditor editor, TextEditor::Scroll::Type type )
363   {
364     if( type == TextEditor::Scroll::STARTED )
365     {
366       mStartedCalled = true;
367     }
368     else if( type == TextEditor::Scroll::FINISHED )
369     {
370       mFinishedCalled = true;
371     }
372   }
373
374   bool& mStartedCalled;
375   bool& mFinishedCalled;
376 };
377
378 } // namespace
379
380 int UtcDaliToolkitTextEditorConstructorP(void)
381 {
382   ToolkitTestApplication application;
383   tet_infoline(" UtcDaliToolkitTextEditorConstructorP");
384   TextEditor textEditor;
385   DALI_TEST_CHECK( !textEditor );
386   END_TEST;
387 }
388
389 int UtcDaliToolkitTextEditorNewP(void)
390 {
391   ToolkitTestApplication application;
392   tet_infoline(" UtcDaliToolkitTextEditorNewP");
393   TextEditor textEditor = TextEditor::New();
394   DALI_TEST_CHECK( textEditor );
395   END_TEST;
396 }
397
398 int UtcDaliToolkitTextEditorDownCastP(void)
399 {
400   ToolkitTestApplication application;
401   tet_infoline(" UtcDaliToolkitTextEditorDownCastP");
402   TextEditor textEditor1 = TextEditor::New();
403   BaseHandle object( textEditor1 );
404
405   TextEditor textEditor2 = TextEditor::DownCast( object );
406   DALI_TEST_CHECK( textEditor2 );
407
408   TextEditor textEditor3 = DownCast< TextEditor >( object );
409   DALI_TEST_CHECK( textEditor3 );
410   END_TEST;
411 }
412
413 int UtcDaliToolkitTextEditorDownCastN(void)
414 {
415   ToolkitTestApplication application;
416   tet_infoline(" UtcDaliToolkitTextEditorDownCastN");
417   BaseHandle uninitializedObject;
418   TextEditor textEditor1 = TextEditor::DownCast( uninitializedObject );
419   DALI_TEST_CHECK( !textEditor1 );
420
421   TextEditor textEditor2 = DownCast< TextEditor >( uninitializedObject );
422   DALI_TEST_CHECK( !textEditor2 );
423   END_TEST;
424 }
425
426 int UtcDaliToolkitTextEditorCopyConstructorP(void)
427 {
428   ToolkitTestApplication application;
429   tet_infoline(" UtcDaliToolkitTextEditorCopyConstructorP");
430   TextEditor textEditor = TextEditor::New();
431   textEditor.SetProperty( TextEditor::Property::TEXT, "Test" );
432
433   TextEditor copy( textEditor );
434   DALI_TEST_CHECK( copy );
435   DALI_TEST_CHECK( copy.GetProperty<std::string>( TextEditor::Property::TEXT ) == textEditor.GetProperty<std::string>( TextEditor::Property::TEXT ) );
436   END_TEST;
437 }
438
439 int UtcDaliTextEditorMoveConstructor(void)
440 {
441   ToolkitTestApplication application;
442
443   TextEditor textEditor = TextEditor::New();
444   textEditor.SetProperty( TextEditor::Property::TEXT, "Test" );
445   DALI_TEST_CHECK( textEditor.GetProperty<std::string>( TextEditor::Property::TEXT ) == "Test" );
446
447   TextEditor moved = std::move( textEditor );
448   DALI_TEST_CHECK( moved );
449   DALI_TEST_EQUALS( 1, moved.GetBaseObject().ReferenceCount(), TEST_LOCATION );
450   DALI_TEST_CHECK( moved.GetProperty<std::string>( TextEditor::Property::TEXT ) == "Test" );
451   DALI_TEST_CHECK( !textEditor );
452
453   END_TEST;
454 }
455
456 int UtcDaliToolkitTextEditorAssignmentOperatorP(void)
457 {
458   ToolkitTestApplication application;
459   tet_infoline(" UtcDaliToolkitTextEditorAssignmentOperatorP");
460   TextEditor textEditor = TextEditor::New();
461   textEditor.SetProperty( TextEditor::Property::TEXT, "Test" );
462
463   TextEditor copy = textEditor;
464   DALI_TEST_CHECK( copy );
465   DALI_TEST_CHECK( copy.GetProperty<std::string>( TextEditor::Property::TEXT ) == textEditor.GetProperty<std::string>( TextEditor::Property::TEXT ) );
466   END_TEST;
467 }
468
469 int UtcDaliTextEditorMoveAssignment(void)
470 {
471   ToolkitTestApplication application;
472
473   TextEditor textEditor = TextEditor::New();
474   textEditor.SetProperty( TextEditor::Property::TEXT, "Test" );
475   DALI_TEST_CHECK( textEditor.GetProperty<std::string>( TextEditor::Property::TEXT ) == "Test" );
476
477   TextEditor moved;
478   moved = std::move( textEditor );
479   DALI_TEST_CHECK( moved );
480   DALI_TEST_EQUALS( 1, moved.GetBaseObject().ReferenceCount(), TEST_LOCATION );
481   DALI_TEST_CHECK( moved.GetProperty<std::string>( TextEditor::Property::TEXT ) == "Test" );
482   DALI_TEST_CHECK( !textEditor );
483
484   END_TEST;
485 }
486
487 int UtcDaliTextEditorNewP(void)
488 {
489   ToolkitTestApplication application;
490   tet_infoline(" UtcDaliToolkitTextEditorNewP");
491   TextEditor textEditor = TextEditor::New();
492   DALI_TEST_CHECK( textEditor );
493   END_TEST;
494 }
495
496 // Positive test case for a method
497 int UtcDaliTextEditorGetPropertyP(void)
498 {
499   ToolkitTestApplication application;
500   tet_infoline(" UtcDaliToolkitTextEditorGetPropertyP");
501   TextEditor editor = TextEditor::New();
502   DALI_TEST_CHECK( editor );
503
504   // Check Property Indices are correct
505   DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_RENDERING_BACKEND ) == DevelTextEditor::Property::RENDERING_BACKEND );
506   DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_TEXT ) == TextEditor::Property::TEXT );
507   DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_TEXT_COLOR ) == TextEditor::Property::TEXT_COLOR );
508   DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_FONT_FAMILY ) == TextEditor::Property::FONT_FAMILY );
509   DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_FONT_STYLE ) == TextEditor::Property::FONT_STYLE );
510   DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_POINT_SIZE ) == TextEditor::Property::POINT_SIZE );
511   DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_HORIZONTAL_ALIGNMENT ) == TextEditor::Property::HORIZONTAL_ALIGNMENT );
512   DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_SCROLL_THRESHOLD ) == TextEditor::Property::SCROLL_THRESHOLD );
513   DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_SCROLL_SPEED ) == TextEditor::Property::SCROLL_SPEED );
514   DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_PRIMARY_CURSOR_COLOR ) == TextEditor::Property::PRIMARY_CURSOR_COLOR );
515   DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_SECONDARY_CURSOR_COLOR ) == TextEditor::Property::SECONDARY_CURSOR_COLOR );
516   DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_ENABLE_CURSOR_BLINK ) == TextEditor::Property::ENABLE_CURSOR_BLINK );
517   DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_CURSOR_BLINK_INTERVAL ) == TextEditor::Property::CURSOR_BLINK_INTERVAL );
518   DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_CURSOR_BLINK_DURATION ) == TextEditor::Property::CURSOR_BLINK_DURATION );
519   DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_CURSOR_WIDTH ) == TextEditor::Property::CURSOR_WIDTH );
520   DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_GRAB_HANDLE_IMAGE ) == TextEditor::Property::GRAB_HANDLE_IMAGE );
521   DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_GRAB_HANDLE_PRESSED_IMAGE ) == TextEditor::Property::GRAB_HANDLE_PRESSED_IMAGE );
522   DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_SELECTION_HANDLE_IMAGE_LEFT ) == TextEditor::Property::SELECTION_HANDLE_IMAGE_LEFT );
523   DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_SELECTION_HANDLE_IMAGE_RIGHT ) == TextEditor::Property::SELECTION_HANDLE_IMAGE_RIGHT );
524   DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_SELECTION_HANDLE_PRESSED_IMAGE_LEFT ) == TextEditor::Property::SELECTION_HANDLE_PRESSED_IMAGE_LEFT );
525   DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_SELECTION_HANDLE_PRESSED_IMAGE_RIGHT ) == TextEditor::Property::SELECTION_HANDLE_PRESSED_IMAGE_RIGHT );
526   DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_SELECTION_HANDLE_MARKER_IMAGE_LEFT ) == TextEditor::Property::SELECTION_HANDLE_MARKER_IMAGE_LEFT );
527   DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_SELECTION_HANDLE_MARKER_IMAGE_RIGHT ) == TextEditor::Property::SELECTION_HANDLE_MARKER_IMAGE_RIGHT );
528   DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_SELECTION_HIGHLIGHT_COLOR ) == TextEditor::Property::SELECTION_HIGHLIGHT_COLOR );
529   DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_DECORATION_BOUNDING_BOX ) == TextEditor::Property::DECORATION_BOUNDING_BOX );
530   DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_ENABLE_MARKUP ) == TextEditor::Property::ENABLE_MARKUP );
531   DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_INPUT_COLOR ) == TextEditor::Property::INPUT_COLOR );
532   DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_INPUT_FONT_FAMILY ) == TextEditor::Property::INPUT_FONT_FAMILY );
533   DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_INPUT_FONT_STYLE ) == TextEditor::Property::INPUT_FONT_STYLE );
534   DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_INPUT_POINT_SIZE ) == TextEditor::Property::INPUT_POINT_SIZE );
535
536   DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_LINE_SPACING ) == TextEditor::Property::LINE_SPACING );
537   DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_INPUT_LINE_SPACING ) == TextEditor::Property::INPUT_LINE_SPACING );
538   DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_UNDERLINE ) == TextEditor::Property::UNDERLINE );
539   DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_INPUT_UNDERLINE ) == TextEditor::Property::INPUT_UNDERLINE );
540   DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_SHADOW ) == TextEditor::Property::SHADOW );
541   DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_INPUT_SHADOW ) == TextEditor::Property::INPUT_SHADOW );
542   DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_EMBOSS ) == TextEditor::Property::EMBOSS );
543   DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_INPUT_EMBOSS ) == TextEditor::Property::INPUT_EMBOSS );
544   DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_OUTLINE ) == TextEditor::Property::OUTLINE );
545   DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_INPUT_OUTLINE ) == TextEditor::Property::INPUT_OUTLINE );
546   DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_SMOOTH_SCROLL ) == TextEditor::Property::SMOOTH_SCROLL );
547   DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_SMOOTH_SCROLL_DURATION ) == TextEditor::Property::SMOOTH_SCROLL_DURATION );
548   DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_ENABLE_SCROLL_BAR ) == TextEditor::Property::ENABLE_SCROLL_BAR );
549   DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_SCROLL_BAR_SHOW_DURATION ) == TextEditor::Property::SCROLL_BAR_SHOW_DURATION );
550   DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_SCROLL_BAR_FADE_DURATION ) == TextEditor::Property::SCROLL_BAR_FADE_DURATION );
551   DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_PIXEL_SIZE ) == TextEditor::Property::PIXEL_SIZE );
552   DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_LINE_COUNT) == TextEditor::Property::LINE_COUNT );
553   DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_ENABLE_SELECTION ) == TextEditor::Property::ENABLE_SELECTION );
554   DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_PLACEHOLDER ) == TextEditor::Property::PLACEHOLDER );
555   DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_FONT_SIZE_SCALE ) == DevelTextEditor::Property::FONT_SIZE_SCALE );
556   DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_PLACEHOLDER_TEXT ) == DevelTextEditor::Property::PLACEHOLDER_TEXT );
557   DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_PLACEHOLDER_TEXT_COLOR ) == DevelTextEditor::Property::PLACEHOLDER_TEXT_COLOR );
558   DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_ENABLE_SHIFT_SELECTION ) == DevelTextEditor::Property::ENABLE_SHIFT_SELECTION );
559   DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_ENABLE_GRAB_HANDLE ) == DevelTextEditor::Property::ENABLE_GRAB_HANDLE );
560   DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_MATCH_SYSTEM_LANGUAGE_DIRECTION ) == DevelTextEditor::Property::MATCH_SYSTEM_LANGUAGE_DIRECTION );
561   DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_MAX_LENGTH ) == DevelTextEditor::Property::MAX_LENGTH );
562   DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_GRAB_HANDLE_COLOR ) == DevelTextEditor::Property::GRAB_HANDLE_COLOR );
563   DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_ENABLE_GRAB_HANDLE_POPUP ) == DevelTextEditor::Property::ENABLE_GRAB_HANDLE_POPUP );
564   DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_INPUT_METHOD_SETTINGS ) == DevelTextEditor::Property::INPUT_METHOD_SETTINGS );
565   DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_INPUT_FILTER ) == DevelTextEditor::Property::INPUT_FILTER );
566
567   END_TEST;
568 }
569
570 bool SetPropertyMapRetrieved( TextEditor& editor, const Property::Index property, const std::string mapKey, const std::string mapValue )
571 {
572   bool result = false;
573   Property::Map imageMap;
574   imageMap[mapKey] =mapValue;
575
576   editor.SetProperty( property , imageMap );
577   Property::Value propValue = editor.GetProperty( property );
578   Property::Map* resultMap = propValue.GetMap();
579
580   if ( resultMap->Find( mapKey )->Get< std::string>() == mapValue )
581   {
582     result = true;
583   }
584
585   return result;
586 }
587
588 // Positive test case for a method
589 int UtcDaliTextEditorSetPropertyP(void)
590 {
591   ToolkitTestApplication application;
592   tet_infoline(" UtcDaliToolkitTextEditorSetPropertyP");
593   TextEditor editor = TextEditor::New();
594   DALI_TEST_CHECK( editor );
595   application.GetScene().Add( editor );
596
597   // Note - we can't check the defaults since the stylesheets are platform-specific
598
599   // Check the render backend property.
600   editor.SetProperty( DevelTextEditor::Property::RENDERING_BACKEND, DevelText::RENDERING_SHARED_ATLAS );
601   DALI_TEST_EQUALS( (DevelText::RenderingType)editor.GetProperty<int>( DevelTextEditor::Property::RENDERING_BACKEND ), DevelText::RENDERING_SHARED_ATLAS, TEST_LOCATION );
602
603   // Check text property.
604   editor.SetProperty( TextEditor::Property::TEXT, "Setting Text" );
605   DALI_TEST_EQUALS( editor.GetProperty<std::string>( TextEditor::Property::TEXT ), std::string("Setting Text"), TEST_LOCATION );
606
607   // Check text's color property
608   editor.SetProperty( TextEditor::Property::TEXT_COLOR, Color::WHITE );
609   DALI_TEST_EQUALS( editor.GetProperty<Vector4>( TextEditor::Property::TEXT_COLOR ), Color::WHITE, TEST_LOCATION );
610
611   // Check font properties.
612   editor.SetProperty( TextEditor::Property::FONT_FAMILY, "Setting font family" );
613   DALI_TEST_EQUALS( editor.GetProperty<std::string>( TextEditor::Property::FONT_FAMILY ), std::string("Setting font family"), TEST_LOCATION );
614
615   Property::Map fontStyleMapSet;
616   Property::Map fontStyleMapGet;
617   Property::Value* slantValue = NULL;
618
619   fontStyleMapSet.Insert( "weight", "bold" );
620   fontStyleMapSet.Insert( "width", "condensed" );
621   fontStyleMapSet.Insert( "slant", "italic" );
622
623   editor.SetProperty( TextEditor::Property::FONT_STYLE, fontStyleMapSet );
624   fontStyleMapGet = editor.GetProperty<Property::Map>( TextEditor::Property::FONT_STYLE );
625   DALI_TEST_EQUALS( fontStyleMapGet.Count(), fontStyleMapSet.Count(), TEST_LOCATION );
626   DALI_TEST_EQUALS( DaliTestCheckMaps( fontStyleMapGet, fontStyleMapSet ), true, TEST_LOCATION );
627
628   editor.SetProperty( TextEditor::Property::POINT_SIZE, 10.f );
629   DALI_TEST_EQUALS( editor.GetProperty<float>( TextEditor::Property::POINT_SIZE ), 10.f, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
630
631   editor.SetProperty( DevelTextEditor::Property::FONT_SIZE_SCALE, 2.5f );
632   DALI_TEST_EQUALS( editor.GetProperty<float>( DevelTextEditor::Property::FONT_SIZE_SCALE ), 2.5f, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
633   editor.SetProperty( DevelTextEditor::Property::FONT_SIZE_SCALE, 1.0f );
634
635   // Reset font style.
636   fontStyleMapSet.Clear();
637   fontStyleMapSet.Insert( "weight", "normal" );
638   fontStyleMapSet.Insert( "slant", "oblique" );
639   editor.SetProperty( TextEditor::Property::FONT_STYLE, fontStyleMapSet );
640   fontStyleMapGet = editor.GetProperty<Property::Map>( TextEditor::Property::FONT_STYLE );
641   DALI_TEST_EQUALS( fontStyleMapGet.Count(), fontStyleMapSet.Count(), TEST_LOCATION );
642   DALI_TEST_EQUALS( DaliTestCheckMaps( fontStyleMapGet, fontStyleMapSet ), true, TEST_LOCATION );
643
644   fontStyleMapSet.Clear();
645   fontStyleMapSet.Insert( "slant", "roman" );
646   editor.SetProperty( TextEditor::Property::FONT_STYLE, fontStyleMapSet );
647   fontStyleMapGet = editor.GetProperty<Property::Map>( TextEditor::Property::FONT_STYLE );
648
649   // Replace 'roman' for 'normal'.
650   slantValue = fontStyleMapGet.Find( "slant" );
651   if( NULL != slantValue )
652   {
653     if( "normal" == slantValue->Get<std::string>() )
654     {
655       fontStyleMapGet["slant"] = "roman";
656     }
657   }
658   DALI_TEST_EQUALS( fontStyleMapGet.Count(), fontStyleMapSet.Count(), TEST_LOCATION );
659   DALI_TEST_EQUALS( DaliTestCheckMaps( fontStyleMapGet, fontStyleMapSet ), true, TEST_LOCATION );
660
661   fontStyleMapSet.Clear();
662
663   editor.SetProperty( TextEditor::Property::FONT_STYLE, fontStyleMapSet );
664   fontStyleMapGet = editor.GetProperty<Property::Map>( TextEditor::Property::FONT_STYLE );
665   DALI_TEST_EQUALS( fontStyleMapGet.Count(), fontStyleMapSet.Count(), TEST_LOCATION );
666   DALI_TEST_EQUALS( DaliTestCheckMaps( fontStyleMapGet, fontStyleMapSet ), true, TEST_LOCATION );
667
668   // Check that the Alignment properties can be correctly set
669   editor.SetProperty( TextEditor::Property::HORIZONTAL_ALIGNMENT, "END" );
670   DALI_TEST_EQUALS( editor.GetProperty<std::string>( TextEditor::Property::HORIZONTAL_ALIGNMENT ), "END", TEST_LOCATION );
671
672   // Check scroll properties.
673   editor.SetProperty( TextEditor::Property::SCROLL_THRESHOLD, 1.f );
674   DALI_TEST_EQUALS( editor.GetProperty<float>( TextEditor::Property::SCROLL_THRESHOLD ), 1.f, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
675   editor.SetProperty( TextEditor::Property::SCROLL_SPEED, 100.f );
676   DALI_TEST_EQUALS( editor.GetProperty<float>( TextEditor::Property::SCROLL_SPEED ), 100.f, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
677
678   // Check cursor properties
679   editor.SetProperty( TextEditor::Property::PRIMARY_CURSOR_COLOR, Color::RED );
680   DALI_TEST_EQUALS( editor.GetProperty<Vector4>( TextEditor::Property::PRIMARY_CURSOR_COLOR ), Color::RED, TEST_LOCATION );
681   editor.SetProperty( TextEditor::Property::SECONDARY_CURSOR_COLOR, Color::BLUE );
682   DALI_TEST_EQUALS( editor.GetProperty<Vector4>( TextEditor::Property::SECONDARY_CURSOR_COLOR ), Color::BLUE, TEST_LOCATION );
683
684   editor.SetProperty( TextEditor::Property::ENABLE_CURSOR_BLINK, false );
685   DALI_TEST_EQUALS( editor.GetProperty<bool>( TextEditor::Property::ENABLE_CURSOR_BLINK ), false, TEST_LOCATION );
686   editor.SetProperty( TextEditor::Property::CURSOR_BLINK_INTERVAL, 1.f );
687   DALI_TEST_EQUALS( editor.GetProperty<float>( TextEditor::Property::CURSOR_BLINK_INTERVAL ), 1.f, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
688   editor.SetProperty( TextEditor::Property::CURSOR_BLINK_DURATION, 10.f );
689   DALI_TEST_EQUALS( editor.GetProperty<float>( TextEditor::Property::CURSOR_BLINK_DURATION ), 10.f, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
690   editor.SetProperty( TextEditor::Property::CURSOR_WIDTH, 1 );
691   DALI_TEST_EQUALS( editor.GetProperty<int>( TextEditor::Property::CURSOR_WIDTH ), 1, TEST_LOCATION );
692
693   // Check handle images
694   editor.SetProperty( TextEditor::Property::GRAB_HANDLE_IMAGE, "image1" );
695   DALI_TEST_EQUALS( editor.GetProperty<std::string>( TextEditor::Property::GRAB_HANDLE_IMAGE ), "image1", TEST_LOCATION );
696   editor.SetProperty( TextEditor::Property::GRAB_HANDLE_PRESSED_IMAGE, "image2" );
697   DALI_TEST_EQUALS( editor.GetProperty<std::string>( TextEditor::Property::GRAB_HANDLE_PRESSED_IMAGE ), "image2", TEST_LOCATION );
698   editor.SetProperty( TextEditor::Property::SELECTION_HANDLE_IMAGE_LEFT, "image3" );
699
700   // Check handle images
701   DALI_TEST_CHECK( SetPropertyMapRetrieved( editor, TextEditor::Property::SELECTION_HANDLE_IMAGE_LEFT, "filename", "leftHandleImage" )  );
702   DALI_TEST_CHECK( SetPropertyMapRetrieved( editor, TextEditor::Property::SELECTION_HANDLE_IMAGE_RIGHT, "filename", "rightHandleImage" )  );
703   DALI_TEST_CHECK( SetPropertyMapRetrieved( editor, TextEditor::Property::SELECTION_HANDLE_PRESSED_IMAGE_LEFT, "filename", "leftHandleImagePressed" )  );
704   DALI_TEST_CHECK( SetPropertyMapRetrieved( editor, TextEditor::Property::SELECTION_HANDLE_PRESSED_IMAGE_RIGHT, "filename", "rightHandleImagePressed" )  );
705   DALI_TEST_CHECK( SetPropertyMapRetrieved( editor, TextEditor::Property::SELECTION_HANDLE_MARKER_IMAGE_LEFT, "filename", "leftHandleMarkerImage" )  );
706   DALI_TEST_CHECK( SetPropertyMapRetrieved( editor, TextEditor::Property::SELECTION_HANDLE_MARKER_IMAGE_RIGHT, "filename", "rightHandleMarkerImage" )  );
707
708   // Check the highlight color
709   editor.SetProperty( TextEditor::Property::SELECTION_HIGHLIGHT_COLOR, Color::GREEN );
710   DALI_TEST_EQUALS( editor.GetProperty<Vector4>( TextEditor::Property::SELECTION_HIGHLIGHT_COLOR ), Color::GREEN, TEST_LOCATION );
711
712   // Decoration bounding box
713   editor.SetProperty( TextEditor::Property::DECORATION_BOUNDING_BOX, Rect<int>( 0, 0, 1, 1 ) );
714   DALI_TEST_EQUALS( editor.GetProperty<Rect <int > >( TextEditor::Property::DECORATION_BOUNDING_BOX ), Rect<int>( 0, 0, 1, 1 ), TEST_LOCATION );
715
716   // Check the enable markup property.
717   DALI_TEST_CHECK( !editor.GetProperty<bool>( TextEditor::Property::ENABLE_MARKUP ) );
718   editor.SetProperty( TextEditor::Property::ENABLE_MARKUP, true );
719   DALI_TEST_CHECK( editor.GetProperty<bool>( TextEditor::Property::ENABLE_MARKUP ) );
720
721   // Check input color property.
722   editor.SetProperty( TextEditor::Property::INPUT_COLOR, Color::YELLOW );
723   DALI_TEST_EQUALS( editor.GetProperty<Vector4>( TextEditor::Property::INPUT_COLOR ), Color::YELLOW, TEST_LOCATION );
724
725   // Check input font properties.
726   editor.SetProperty( TextEditor::Property::INPUT_FONT_FAMILY, "Setting input font family" );
727   DALI_TEST_EQUALS( editor.GetProperty<std::string>( TextEditor::Property::INPUT_FONT_FAMILY ), "Setting input font family", TEST_LOCATION );
728
729   fontStyleMapSet.Clear();
730   fontStyleMapSet.Insert( "weight", "bold" );
731   fontStyleMapSet.Insert( "width", "condensed" );
732   fontStyleMapSet.Insert( "slant", "italic" );
733
734   editor.SetProperty( TextEditor::Property::INPUT_FONT_STYLE, fontStyleMapSet );
735   fontStyleMapGet = editor.GetProperty<Property::Map>( TextEditor::Property::INPUT_FONT_STYLE );
736   DALI_TEST_EQUALS( fontStyleMapGet.Count(), fontStyleMapSet.Count(), TEST_LOCATION );
737   DALI_TEST_EQUALS( DaliTestCheckMaps( fontStyleMapGet, fontStyleMapSet ), true, TEST_LOCATION );
738
739   editor.SetProperty( TextEditor::Property::INPUT_POINT_SIZE, 12.f );
740   DALI_TEST_EQUALS( editor.GetProperty<float>( TextEditor::Property::INPUT_POINT_SIZE ), 12.f, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
741
742   // Reset input font style.
743   fontStyleMapSet.Clear();
744   fontStyleMapSet.Insert( "weight", "normal" );
745   fontStyleMapSet.Insert( "slant", "oblique" );
746
747   editor.SetProperty( TextEditor::Property::INPUT_FONT_STYLE, fontStyleMapSet );
748   fontStyleMapGet = editor.GetProperty<Property::Map>( TextEditor::Property::INPUT_FONT_STYLE );
749   DALI_TEST_EQUALS( fontStyleMapGet.Count(), fontStyleMapSet.Count(), TEST_LOCATION );
750   DALI_TEST_EQUALS( DaliTestCheckMaps( fontStyleMapGet, fontStyleMapSet ), true, TEST_LOCATION );
751
752   fontStyleMapSet.Clear();
753   fontStyleMapSet.Insert( "slant", "roman" );
754
755   editor.SetProperty( TextEditor::Property::INPUT_FONT_STYLE, fontStyleMapSet );
756   fontStyleMapGet = editor.GetProperty<Property::Map>( TextEditor::Property::INPUT_FONT_STYLE );
757
758   // Replace 'roman' for 'normal'.
759   slantValue = fontStyleMapGet.Find( "slant" );
760   if( NULL != slantValue )
761   {
762     if( "normal" == slantValue->Get<std::string>() )
763     {
764       fontStyleMapGet["slant"] = "roman";
765     }
766   }
767   DALI_TEST_EQUALS( fontStyleMapGet.Count(), fontStyleMapSet.Count(), TEST_LOCATION );
768   DALI_TEST_EQUALS( DaliTestCheckMaps( fontStyleMapGet, fontStyleMapSet ), true, TEST_LOCATION );
769
770   fontStyleMapSet.Clear();
771
772   editor.SetProperty( TextEditor::Property::INPUT_FONT_STYLE, fontStyleMapSet );
773   fontStyleMapGet = editor.GetProperty<Property::Map>( TextEditor::Property::INPUT_FONT_STYLE );
774   DALI_TEST_EQUALS( fontStyleMapGet.Count(), fontStyleMapSet.Count(), TEST_LOCATION );
775   DALI_TEST_EQUALS( DaliTestCheckMaps( fontStyleMapGet, fontStyleMapSet ), true, TEST_LOCATION );
776
777   // Check the line spacing property
778   DALI_TEST_EQUALS( editor.GetProperty<float>( TextEditor::Property::LINE_SPACING ), 0.0f, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
779   editor.SetProperty( TextEditor::Property::LINE_SPACING, 10.f );
780   DALI_TEST_EQUALS( editor.GetProperty<float>( TextEditor::Property::LINE_SPACING ), 10.0f, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
781
782   // Check the input line spacing property
783   DALI_TEST_EQUALS( editor.GetProperty<float>( TextEditor::Property::INPUT_LINE_SPACING ), 0.0f, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
784   editor.SetProperty( TextEditor::Property::INPUT_LINE_SPACING, 20.f );
785   DALI_TEST_EQUALS( editor.GetProperty<float>( TextEditor::Property::INPUT_LINE_SPACING ), 20.0f, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
786
787   // Check the underline property
788
789   Property::Map underlineMapSet;
790   Property::Map underlineMapGet;
791
792   underlineMapSet.Insert( "enable", true );
793   underlineMapSet.Insert( "color", Color::RED );
794   underlineMapSet.Insert( "height", 1 );
795
796   editor.SetProperty( TextEditor::Property::UNDERLINE, underlineMapSet );
797
798   underlineMapGet = editor.GetProperty<Property::Map>( TextEditor::Property::UNDERLINE );
799   DALI_TEST_EQUALS( underlineMapGet.Count(), underlineMapSet.Count(), TEST_LOCATION );
800   DALI_TEST_EQUALS( DaliTestCheckMaps( underlineMapGet, underlineMapSet ), true, TEST_LOCATION );
801
802   // Check the input underline property
803   editor.SetProperty( TextEditor::Property::INPUT_UNDERLINE, "Underline input properties" );
804   DALI_TEST_EQUALS( editor.GetProperty<std::string>( TextEditor::Property::INPUT_UNDERLINE ), std::string("Underline input properties"), TEST_LOCATION );
805
806   // Check the shadow property
807   Property::Map shadowMapSet;
808   Property::Map shadowMapGet;
809
810   shadowMapSet.Insert( "color", Color::GREEN );
811   shadowMapSet.Insert( "offset", Vector2(2.0f, 2.0f) );
812   shadowMapSet.Insert( "blurRadius", 3.0f );
813
814   editor.SetProperty( TextEditor::Property::SHADOW, shadowMapSet );
815
816   shadowMapGet = editor.GetProperty<Property::Map>( TextEditor::Property::SHADOW );
817   DALI_TEST_EQUALS( shadowMapGet.Count(), shadowMapSet.Count(), TEST_LOCATION );
818   DALI_TEST_EQUALS( DaliTestCheckMaps( shadowMapGet, shadowMapSet ), true, TEST_LOCATION );
819
820   // Check the input shadow property
821   editor.SetProperty( TextEditor::Property::INPUT_SHADOW, "Shadow input properties" );
822   DALI_TEST_EQUALS( editor.GetProperty<std::string>( TextEditor::Property::INPUT_SHADOW ), std::string("Shadow input properties"), TEST_LOCATION );
823
824   // Check the emboss property
825   editor.SetProperty( TextEditor::Property::EMBOSS, "Emboss properties" );
826   DALI_TEST_EQUALS( editor.GetProperty<std::string>( TextEditor::Property::EMBOSS ), std::string("Emboss properties"), TEST_LOCATION );
827
828   // Check the input emboss property
829   editor.SetProperty( TextEditor::Property::INPUT_EMBOSS, "Emboss input properties" );
830   DALI_TEST_EQUALS( editor.GetProperty<std::string>( TextEditor::Property::INPUT_EMBOSS ), std::string("Emboss input properties"), TEST_LOCATION );
831
832   // Check the outline property
833
834   // Test string type first
835   // This is purely to maintain backward compatibility, but we don't support string as the outline property type.
836   editor.SetProperty( TextEditor::Property::OUTLINE, "Outline properties" );
837   DALI_TEST_EQUALS( editor.GetProperty<std::string>( TextEditor::Property::OUTLINE ), std::string("Outline properties"), TEST_LOCATION );
838
839   // Then test the property map type
840   Property::Map outlineMapSet;
841   Property::Map outlineMapGet;
842
843   outlineMapSet["color"] = Color::RED;
844   outlineMapSet["width"] = 2.0f;
845
846   editor.SetProperty( TextEditor::Property::OUTLINE, outlineMapSet );
847
848   outlineMapGet = editor.GetProperty<Property::Map>( TextEditor::Property::OUTLINE );
849   DALI_TEST_EQUALS( outlineMapGet.Count(), outlineMapSet.Count(), TEST_LOCATION );
850   DALI_TEST_EQUALS( DaliTestCheckMaps( outlineMapGet, outlineMapSet ), true, TEST_LOCATION );
851
852   // Check the input outline property
853   editor.SetProperty( TextEditor::Property::INPUT_OUTLINE, "Outline input properties" );
854   DALI_TEST_EQUALS( editor.GetProperty<std::string>( TextEditor::Property::INPUT_OUTLINE ), std::string("Outline input properties"), TEST_LOCATION );
855
856   // Check the smooth scroll property
857   DALI_TEST_EQUALS( editor.GetProperty<bool>( TextEditor::Property::SMOOTH_SCROLL ), false, TEST_LOCATION );
858   editor.SetProperty( TextEditor::Property::SMOOTH_SCROLL, true );
859   DALI_TEST_EQUALS( editor.GetProperty<bool>( TextEditor::Property::SMOOTH_SCROLL ), true, TEST_LOCATION );
860
861   // Check the smooth scroll duration property
862   editor.SetProperty( TextEditor::Property::SMOOTH_SCROLL_DURATION, 0.2f );
863   DALI_TEST_EQUALS( editor.GetProperty<float>( TextEditor::Property::SMOOTH_SCROLL_DURATION ), 0.2f, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
864
865   // Check the scroll bar property
866   DALI_TEST_EQUALS( editor.GetProperty<bool>( TextEditor::Property::ENABLE_SCROLL_BAR ), false, TEST_LOCATION );
867   editor.SetProperty( TextEditor::Property::ENABLE_SCROLL_BAR, true );
868   DALI_TEST_EQUALS( editor.GetProperty<bool>( TextEditor::Property::ENABLE_SCROLL_BAR ), true, TEST_LOCATION );
869
870   editor.SetProperty( TextEditor::Property::SCROLL_BAR_SHOW_DURATION, 0.3f );
871   DALI_TEST_EQUALS( editor.GetProperty<float>( TextEditor::Property::SCROLL_BAR_SHOW_DURATION ), 0.3f, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
872   editor.SetProperty( TextEditor::Property::SCROLL_BAR_FADE_DURATION, 0.2f );
873   DALI_TEST_EQUALS( editor.GetProperty<float>( TextEditor::Property::SCROLL_BAR_FADE_DURATION ), 0.2f, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
874
875   // Check the pixel size of font
876   editor.SetProperty( TextEditor::Property::PIXEL_SIZE, 20.f );
877   DALI_TEST_EQUALS( editor.GetProperty<float>( TextEditor::Property::PIXEL_SIZE ), 20.f, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
878
879   // Check placeholder text properties.
880   editor.SetProperty( DevelTextEditor::Property::PLACEHOLDER_TEXT, "Setting Placeholder Text" );
881   DALI_TEST_EQUALS( editor.GetProperty<std::string>( DevelTextEditor::Property::PLACEHOLDER_TEXT ), std::string("Setting Placeholder Text"), TEST_LOCATION );
882
883   // Check placeholder text's color property.
884   editor.SetProperty( DevelTextEditor::Property::PLACEHOLDER_TEXT_COLOR, Color::RED );
885   DALI_TEST_EQUALS( editor.GetProperty<Vector4>( DevelTextEditor::Property::PLACEHOLDER_TEXT_COLOR ), Color::RED, TEST_LOCATION );
886
887   // Check the enable selection property
888   editor.SetProperty( TextEditor::Property::ENABLE_SELECTION, false );
889   DALI_TEST_EQUALS( editor.GetProperty<bool>( TextEditor::Property::ENABLE_SELECTION ), false, TEST_LOCATION );
890
891   // Check the placeholder property with pixel size
892   Property::Map placeholderPixelSizeMapSet;
893   Property::Map placeholderPixelSizeMapGet;
894   Property::Map placeholderFontstyleMap;
895   placeholderPixelSizeMapSet["text"] = "Setting Placeholder Text";
896   placeholderPixelSizeMapSet["textFocused"] = "Setting Placeholder Text Focused";
897   placeholderPixelSizeMapSet["color"] = Color::BLUE;
898   placeholderPixelSizeMapSet["fontFamily"] = "Arial";
899   placeholderPixelSizeMapSet["pixelSize"] = 15.0f;
900
901   placeholderFontstyleMap.Insert( "weight", "bold" );
902   placeholderPixelSizeMapSet["fontStyle"] = placeholderFontstyleMap;
903   editor.SetProperty( TextEditor::Property::PLACEHOLDER, placeholderPixelSizeMapSet );
904
905   placeholderPixelSizeMapGet = editor.GetProperty<Property::Map>( TextEditor::Property::PLACEHOLDER );
906   DALI_TEST_EQUALS( placeholderPixelSizeMapGet.Count(), placeholderPixelSizeMapSet.Count(), TEST_LOCATION );
907
908   tet_infoline("Test Placeholder settings set as strings is converted correctly to Property Index key and holds set value");
909   Property::Map placeholderConversionMap;
910   placeholderConversionMap[ Text::PlaceHolder::Property::TEXT ] = placeholderPixelSizeMapSet["text"];
911   placeholderConversionMap[ Text::PlaceHolder::Property::TEXT_FOCUSED ] = placeholderPixelSizeMapSet["textFocused"] ;
912   placeholderConversionMap[ Text::PlaceHolder::Property::COLOR ] = placeholderPixelSizeMapSet["color"];
913   placeholderConversionMap[ Text::PlaceHolder::Property::FONT_STYLE ] = placeholderPixelSizeMapSet["fontStyle"];
914   placeholderConversionMap[ Text::PlaceHolder::Property::FONT_FAMILY ] = placeholderPixelSizeMapSet["fontFamily"];
915   placeholderConversionMap[ Text::PlaceHolder::Property::PIXEL_SIZE ] = placeholderPixelSizeMapSet["pixelSize"];
916
917   DALI_TEST_EQUALS( DaliTestCheckMaps( placeholderPixelSizeMapGet, placeholderConversionMap ), true, TEST_LOCATION );
918
919   // Check the placeholder property with point size
920   Property::Map placeholderMapSet;
921   Property::Map placeholderMapGet;
922   placeholderMapSet["text"] = "Setting Placeholder Text";
923   placeholderMapSet["textFocused"] = "Setting Placeholder Text Focused";
924   placeholderMapSet["color"] = Color::RED;
925   placeholderMapSet["fontFamily"] = "Arial";
926   placeholderMapSet["pointSize"] = 12.0f;
927   // Check the placeholder font style property
928   placeholderFontstyleMap.Clear();
929
930   placeholderFontstyleMap.Insert( "weight", "bold" );
931   placeholderFontstyleMap.Insert( "width", "condensed" );
932   placeholderFontstyleMap.Insert( "slant", "italic" );
933   placeholderMapSet["fontStyle"] = placeholderFontstyleMap;
934   editor.SetProperty( TextEditor::Property::PLACEHOLDER, placeholderMapSet );
935
936   placeholderMapGet = editor.GetProperty<Property::Map>( TextEditor::Property::PLACEHOLDER );
937   DALI_TEST_EQUALS( placeholderMapGet.Count(), placeholderMapSet.Count(), TEST_LOCATION );
938
939   tet_infoline("Test Placeholder settings set as strings is converted correctly to Property Index key and holds set value");
940   placeholderConversionMap.Clear();
941   placeholderConversionMap[ Text::PlaceHolder::Property::TEXT ] = placeholderMapSet["text"];
942   placeholderConversionMap[ Text::PlaceHolder::Property::TEXT_FOCUSED ] = placeholderMapSet["textFocused"] ;
943   placeholderConversionMap[ Text::PlaceHolder::Property::COLOR ] = placeholderMapSet["color"];
944   placeholderConversionMap[ Text::PlaceHolder::Property::FONT_STYLE ] = placeholderPixelSizeMapSet["fontStyle"];
945   placeholderConversionMap[ Text::PlaceHolder::Property::FONT_FAMILY ] = placeholderMapSet["fontFamily"];
946   placeholderConversionMap[ Text::PlaceHolder::Property::POINT_SIZE ] = placeholderMapSet["pointSize"];
947   DALI_TEST_EQUALS( DaliTestCheckMaps( placeholderMapGet, placeholderConversionMap ), true, TEST_LOCATION );
948
949   // Reset font style.
950   placeholderFontstyleMap.Clear();
951   placeholderFontstyleMap.Insert( "weight", "normal" );
952   placeholderFontstyleMap.Insert( "slant", "oblique" );
953   placeholderMapSet["fontStyle"] = placeholderFontstyleMap;
954   editor.SetProperty( TextEditor::Property::PLACEHOLDER, placeholderMapSet );
955
956   placeholderMapGet = editor.GetProperty<Property::Map>( TextEditor::Property::PLACEHOLDER );
957   DALI_TEST_EQUALS( placeholderMapGet.Count(), placeholderMapSet.Count(), TEST_LOCATION );
958   placeholderConversionMap[ Text::PlaceHolder::Property::FONT_STYLE ] = placeholderMapSet["fontStyle"];
959   DALI_TEST_EQUALS( DaliTestCheckMaps( placeholderMapGet, placeholderConversionMap ), true, TEST_LOCATION );
960
961   placeholderFontstyleMap.Clear();
962   placeholderFontstyleMap.Insert( "slant", "roman" );
963   placeholderMapSet["fontStyle"] = placeholderFontstyleMap;
964   editor.SetProperty( TextEditor::Property::PLACEHOLDER, placeholderMapSet );
965
966   placeholderMapGet = editor.GetProperty<Property::Map>( TextEditor::Property::PLACEHOLDER );
967
968   placeholderFontstyleMap.Clear();
969   placeholderMapSet["fontStyle"] = placeholderFontstyleMap;
970
971   editor.SetProperty( TextEditor::Property::PLACEHOLDER, placeholderMapSet );
972   placeholderMapGet = editor.GetProperty<Property::Map>( TextEditor::Property::PLACEHOLDER );
973   DALI_TEST_EQUALS( placeholderMapGet.Count(), placeholderMapSet.Count(), TEST_LOCATION );
974   placeholderConversionMap[ Text::PlaceHolder::Property::FONT_STYLE ] = placeholderMapSet["fontStyle"];
975   DALI_TEST_EQUALS( DaliTestCheckMaps( placeholderMapGet, placeholderConversionMap ), true, TEST_LOCATION );
976
977   editor.SetProperty( Actor::Property::LAYOUT_DIRECTION, LayoutDirection::RIGHT_TO_LEFT );
978   DALI_TEST_EQUALS( editor.GetProperty<int>( Actor::Property::LAYOUT_DIRECTION ), static_cast<int>( LayoutDirection::RIGHT_TO_LEFT ), TEST_LOCATION );
979
980   // Check handle color
981   editor.SetProperty( DevelTextEditor::Property::GRAB_HANDLE_COLOR, Color::GREEN );
982   DALI_TEST_EQUALS( editor.GetProperty<Vector4>( DevelTextEditor::Property::GRAB_HANDLE_COLOR ), Color::GREEN, TEST_LOCATION );
983
984   // Test the ENABLE_GRAB_HANDLE_POPUP property
985   editor.SetProperty( DevelTextEditor::Property::ENABLE_GRAB_HANDLE_POPUP, false );
986   DALI_TEST_EQUALS( editor.GetProperty<bool>( DevelTextEditor::Property::ENABLE_GRAB_HANDLE_POPUP ), false, TEST_LOCATION);
987
988   // Check the input method setting
989   Property::Map propertyMap;
990   InputMethod::PanelLayout::Type panelLayout = InputMethod::PanelLayout::NUMBER;
991   InputMethod::AutoCapital::Type autoCapital = InputMethod::AutoCapital::WORD;
992   InputMethod::ButtonAction::Type buttonAction = InputMethod::ButtonAction::GO;
993   int inputVariation = 1;
994   propertyMap["PANEL_LAYOUT"] = panelLayout;
995   propertyMap["AUTO_CAPITALIZE"] = autoCapital;
996   propertyMap["BUTTON_ACTION"] = buttonAction;
997   propertyMap["VARIATION"] = inputVariation;
998   editor.SetProperty( DevelTextEditor::Property::INPUT_METHOD_SETTINGS, propertyMap );
999
1000   Property::Value value = editor.GetProperty( DevelTextEditor::Property::INPUT_METHOD_SETTINGS );
1001   Property::Map map;
1002   DALI_TEST_CHECK( value.Get( map ) );
1003
1004   int layout = 0;
1005   DALI_TEST_CHECK( map[ "PANEL_LAYOUT" ].Get( layout ) );
1006   DALI_TEST_EQUALS( static_cast<int>(panelLayout), layout, TEST_LOCATION );
1007
1008   int capital = 0;
1009   DALI_TEST_CHECK( map[ "AUTO_CAPITALIZE" ].Get( capital ) );
1010   DALI_TEST_EQUALS( static_cast<int>(autoCapital), capital, TEST_LOCATION );
1011
1012   int action = 0;
1013   DALI_TEST_CHECK( map[ "BUTTON_ACTION" ].Get( action ) );
1014   DALI_TEST_EQUALS( static_cast<int>(buttonAction), action, TEST_LOCATION );
1015
1016   int variation = 0;
1017   DALI_TEST_CHECK( map[ "VARIATION" ].Get( variation ) );
1018   DALI_TEST_EQUALS( inputVariation, variation, TEST_LOCATION );
1019
1020   // Check the input filter property
1021   Property::Map inputFilterMapSet;
1022   Property::Map inputFilterMapGet;
1023   inputFilterMapSet[InputFilter::Property::ACCEPTED] = "[\\w]";
1024   inputFilterMapSet[InputFilter::Property::REJECTED] = "[\\d]";
1025
1026   editor.SetProperty(DevelTextEditor::Property::INPUT_FILTER, inputFilterMapSet);
1027
1028   inputFilterMapGet = editor.GetProperty<Property::Map>(DevelTextEditor::Property::INPUT_FILTER);
1029   DALI_TEST_EQUALS(inputFilterMapGet.Count(), inputFilterMapSet.Count(), TEST_LOCATION);
1030
1031   // Clear
1032   inputFilterMapSet.Clear();
1033   editor.SetProperty(DevelTextEditor::Property::INPUT_FILTER, inputFilterMapSet);
1034
1035   application.SendNotification();
1036   application.Render();
1037
1038   // Check the line size property
1039   DALI_TEST_EQUALS( editor.GetProperty<float>( DevelTextEditor::Property::MIN_LINE_SIZE ), 0.0f, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
1040   editor.SetProperty( DevelTextEditor::Property::MIN_LINE_SIZE, 50.f );
1041   DALI_TEST_EQUALS( editor.GetProperty<float>( DevelTextEditor::Property::MIN_LINE_SIZE ), 50.0f, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
1042
1043   END_TEST;
1044 }
1045
1046 // Positive Atlas Text Renderer test
1047 int utcDaliTextEditorAtlasRenderP(void)
1048 {
1049   ToolkitTestApplication application;
1050   tet_infoline(" UtcDaliToolkitTextEditorAtlasRenderP");
1051   StyleManager styleManager = StyleManager::Get();
1052   styleManager.ApplyDefaultTheme();
1053   TextEditor editor = TextEditor::New();
1054   DALI_TEST_CHECK( editor );
1055
1056   editor.SetProperty( TextEditor::Property::HORIZONTAL_ALIGNMENT, "CENTER" );
1057
1058   application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
1059
1060   application.GetScene().Add( editor );
1061
1062   try
1063   {
1064     // Render some text with the shared atlas backend
1065     editor.SetProperty( DevelTextEditor::Property::RENDERING_BACKEND, DevelText::RENDERING_SHARED_ATLAS );
1066     application.SendNotification();
1067     application.Render();
1068   }
1069   catch( ... )
1070   {
1071     tet_result(TET_FAIL);
1072   }
1073   END_TEST;
1074 }
1075
1076 // Positive test for the anchorClicked signal.
1077 int utcDaliTextEditorAnchorClickedP(void)
1078 {
1079   ToolkitTestApplication application;
1080   tet_infoline(" utcDaliTextEditorAnchorClickedP");
1081   TextEditor editor = TextEditor::New();
1082   DALI_TEST_CHECK(editor);
1083
1084   application.GetScene().Add(editor);
1085
1086   // connect to the anchor clicked signal.
1087   ConnectionTracker* testTracker = new ConnectionTracker();
1088   DevelTextEditor::AnchorClickedSignal(editor).Connect(&TestAnchorClickedCallback);
1089   bool anchorClickedSignal = false;
1090   editor.ConnectSignal(testTracker, "anchorClicked", CallbackFunctor(&anchorClickedSignal));
1091
1092   gAnchorClickedCallBackCalled = false;
1093   editor.SetProperty(TextEditor::Property::TEXT, "<a href='https://www.tizen.org'>TIZEN</a>");
1094   editor.SetProperty(TextEditor::Property::ENABLE_MARKUP, true);
1095   editor.SetProperty(Actor::Property::SIZE, Vector2(100.f, 50.f));
1096   editor.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT);
1097   editor.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
1098
1099   application.SendNotification();
1100   application.Render();
1101   editor.SetKeyInputFocus();
1102
1103   // Create a tap event to touch the text editor.
1104   TestGenerateTap(application, 5.0f, 5.0f);
1105   application.SendNotification();
1106   application.Render();
1107
1108   DALI_TEST_CHECK(gAnchorClickedCallBackCalled);
1109   DALI_TEST_CHECK(anchorClickedSignal);
1110
1111   gAnchorClickedCallBackNotCalled = true;
1112   // Tap the outside of anchor, callback should not be called.
1113   TestGenerateTap(application, 150.f, 100.f);
1114   application.SendNotification();
1115   application.Render();
1116
1117   DALI_TEST_CHECK(gAnchorClickedCallBackNotCalled);
1118
1119   END_TEST;
1120 }
1121
1122 // Positive test for the textChanged signal.
1123 int utcDaliTextEditorTextChangedP(void)
1124 {
1125   ToolkitTestApplication application;
1126   tet_infoline(" utcDaliTextEditorTextChangedP");
1127   TextEditor editor = TextEditor::New();
1128   DALI_TEST_CHECK( editor );
1129
1130   application.GetScene().Add( editor );
1131
1132   // connect to the text changed signal.
1133   ConnectionTracker* testTracker = new ConnectionTracker();
1134   editor.TextChangedSignal().Connect( &TestTextChangedCallback );
1135   bool textChangedSignal = false;
1136   editor.ConnectSignal( testTracker, "textChanged",   CallbackFunctor(&textChangedSignal) );
1137
1138   gTextChangedCallBackCalled = false;
1139   editor.SetProperty( TextEditor::Property::TEXT, "ABC" );
1140   DALI_TEST_CHECK( gTextChangedCallBackCalled );
1141   DALI_TEST_CHECK( textChangedSignal );
1142
1143   application.SendNotification();
1144   editor.SetKeyInputFocus();
1145
1146   gTextChangedCallBackCalled = false;
1147   application.ProcessEvent( GenerateKey( "D", "", "D", KEY_D_CODE, 0, 0, Integration::KeyEvent::DOWN, "D", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
1148   DALI_TEST_CHECK( gTextChangedCallBackCalled );
1149
1150   // Remove all text
1151   editor.SetProperty( TextField::Property::TEXT, "" );
1152
1153   // Pressing backspace key: TextChangedCallback should not be called when there is no text in texteditor.
1154   gTextChangedCallBackCalled = false;
1155   application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_BACKSPACE, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
1156   DALI_TEST_CHECK( !gTextChangedCallBackCalled );
1157
1158   // Pressing delete key: TextChangedCallback should not be called when there is no text in texteditor.
1159   gTextChangedCallBackCalled = false;
1160   application.ProcessEvent( GenerateKey( "", "", "", Dali::DevelKey::DALI_KEY_DELETE, 0, 0, Integration::KeyEvent::DOWN, "Delete", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
1161   DALI_TEST_CHECK( !gTextChangedCallBackCalled );
1162
1163   END_TEST;
1164 }
1165
1166 int utcDaliTextEditorTextChangedWithInputMethodContext(void)
1167 {
1168   ToolkitTestApplication application;
1169   tet_infoline(" utcDaliTextEditorTextChangedWithInputMethodContext");
1170   TextEditor editor = TextEditor::New();
1171   DALI_TEST_CHECK( editor );
1172
1173
1174   application.GetScene().Add( editor );
1175
1176   // connect to the text changed signal.
1177   ConnectionTracker* testTracker = new ConnectionTracker();
1178   editor.TextChangedSignal().Connect(&TestTextChangedCallback);
1179   bool textChangedSignal = false;
1180   editor.ConnectSignal( testTracker, "textChanged",   CallbackFunctor(&textChangedSignal) );
1181
1182
1183   // get InputMethodContext
1184   std::string text;
1185   InputMethodContext::EventData imfEvent;
1186   InputMethodContext inputMethodContext = DevelTextEditor::GetInputMethodContext( editor );
1187
1188   editor.SetKeyInputFocus();
1189   editor.SetProperty( DevelTextEditor::Property::ENABLE_EDITING, true );
1190
1191   // input text
1192   gTextChangedCallBackCalled = false;
1193   imfEvent = InputMethodContext::EventData( InputMethodContext::PRE_EDIT, "ㅎ", 0, 1 );
1194   inputMethodContext.EventReceivedSignal().Emit(inputMethodContext, imfEvent);
1195   application.SendNotification();
1196   application.Render();
1197   DALI_TEST_CHECK( gTextChangedCallBackCalled );
1198   DALI_TEST_EQUALS( editor.GetProperty<std::string>( TextEditor::Property::TEXT ), std::string("ㅎ"), TEST_LOCATION );
1199
1200   gTextChangedCallBackCalled = false;
1201   imfEvent = InputMethodContext::EventData( InputMethodContext::PRE_EDIT, "호", 0, 1 );
1202   inputMethodContext.EventReceivedSignal().Emit(inputMethodContext, imfEvent);
1203   application.SendNotification();
1204   application.Render();
1205   DALI_TEST_CHECK( gTextChangedCallBackCalled );
1206   DALI_TEST_EQUALS( editor.GetProperty<std::string>( TextEditor::Property::TEXT ), std::string("호"), TEST_LOCATION );
1207
1208   gTextChangedCallBackCalled = false;
1209   imfEvent = InputMethodContext::EventData( InputMethodContext::PRE_EDIT, "혿", 0, 1 );
1210   inputMethodContext.EventReceivedSignal().Emit(inputMethodContext, imfEvent);
1211   application.SendNotification();
1212   application.Render();
1213   DALI_TEST_CHECK( gTextChangedCallBackCalled );
1214   DALI_TEST_EQUALS( editor.GetProperty<std::string>( TextEditor::Property::TEXT ), std::string("혿"), TEST_LOCATION );
1215
1216   gTextChangedCallBackCalled = false;
1217   imfEvent = InputMethodContext::EventData( InputMethodContext::PRE_EDIT, "", 0, 1 );
1218   inputMethodContext.EventReceivedSignal().Emit(inputMethodContext, imfEvent);
1219   DALI_TEST_CHECK( !gTextChangedCallBackCalled );
1220
1221   imfEvent = InputMethodContext::EventData( InputMethodContext::COMMIT, "호", 0, 1 );
1222   inputMethodContext.EventReceivedSignal().Emit(inputMethodContext, imfEvent);
1223   DALI_TEST_CHECK( !gTextChangedCallBackCalled );
1224
1225   imfEvent = InputMethodContext::EventData( InputMethodContext::PRE_EDIT, "두", 1, 2 );
1226   inputMethodContext.EventReceivedSignal().Emit(inputMethodContext, imfEvent);
1227   DALI_TEST_CHECK( !gTextChangedCallBackCalled );
1228
1229   application.SendNotification();
1230   application.Render();
1231   DALI_TEST_CHECK( gTextChangedCallBackCalled );
1232   DALI_TEST_EQUALS( editor.GetProperty<std::string>( TextEditor::Property::TEXT ), std::string("호두"), TEST_LOCATION );
1233
1234   END_TEST;
1235 }
1236
1237
1238 int utcDaliTextEditorInputStyleChanged01(void)
1239 {
1240   // The text-editor emits signals when the input style changes. These changes of style are
1241   // detected during the relayout process (size negotiation), i.e after the cursor has been moved. Signals
1242   // can't be emitted during the size negotiation as the callbacks may update the UI.
1243   // The text-editor adds an idle callback to the adaptor to emit the signals after the size negotiation.
1244   // The ToolkitTestApplication creates an implementation of the adaptor stub and a queue of idle callbacks.
1245   ToolkitTestApplication application;
1246   tet_infoline(" utcDaliTextEditorInputStyleChanged01");
1247
1248   // Load some fonts.
1249
1250   char* pathNamePtr = get_current_dir_name();
1251   const std::string pathName( pathNamePtr );
1252   free( pathNamePtr );
1253
1254   TextAbstraction::FontClient fontClient = TextAbstraction::FontClient::Get();
1255   fontClient.SetDpi( 93u, 93u );
1256
1257   fontClient.GetFontId( pathName + DEFAULT_FONT_DIR + "/dejavu/DejaVuSerif.ttf", DEFAULT_FONT_SIZE );
1258   fontClient.GetFontId( pathName + DEFAULT_FONT_DIR + "/dejavu/DejaVuSerif-Bold.ttf", DEFAULT_FONT_SIZE );
1259
1260   TextEditor editor = TextEditor::New();
1261   DALI_TEST_CHECK( editor );
1262
1263
1264   editor.SetProperty( Actor::Property::SIZE, Vector2( 300.f, 50.f ) );
1265   editor.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT );
1266   editor.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT );
1267
1268   editor.SetProperty( TextEditor::Property::ENABLE_MARKUP, true );
1269   editor.SetProperty( TextEditor::Property::TEXT, "<font family='DejaVuSerif' size='18'>He<color value='green'>llo</color> <font weight='bold'>world</font> demo</font>" );
1270
1271   // connect to the text changed signal.
1272   ConnectionTracker* testTracker = new ConnectionTracker();
1273   editor.InputStyleChangedSignal().Connect( &TestInputStyleChangedCallback );
1274   bool inputStyleChangedSignal = false;
1275   editor.ConnectSignal( testTracker, "inputStyleChanged",   CallbackFunctor(&inputStyleChangedSignal) );
1276
1277   application.GetScene().Add( editor );
1278
1279   // Render and notify
1280   application.SendNotification();
1281   application.Render();
1282
1283   // Executes the idle callbacks added by the text control on the change of input style.
1284   application.RunIdles();
1285
1286   gInputStyleChangedCallbackCalled = false;
1287   gInputStyleMask = TextEditor::InputStyle::NONE;
1288   inputStyleChangedSignal = false;
1289
1290   // Create a tap event to touch the text editor.
1291   TestGenerateTap( application, 18.0f, 25.0f );
1292
1293   // Render and notify
1294   application.SendNotification();
1295   application.Render();
1296
1297   // Executes the idle callbacks added by the text control on the change of input style.
1298   application.RunIdles();
1299
1300   DALI_TEST_CHECK( gInputStyleChangedCallbackCalled );
1301   if( gInputStyleChangedCallbackCalled )
1302   {
1303     DALI_TEST_EQUALS( static_cast<unsigned int>( gInputStyleMask ), static_cast<unsigned int>( TextEditor::InputStyle::FONT_FAMILY | TextEditor::InputStyle::POINT_SIZE ), TEST_LOCATION );
1304
1305     const std::string fontFamily = editor.GetProperty( TextEditor::Property::INPUT_FONT_FAMILY ).Get<std::string>();
1306     DALI_TEST_EQUALS( fontFamily, "DejaVuSerif", TEST_LOCATION );
1307
1308     const float pointSize = editor.GetProperty( TextEditor::Property::INPUT_POINT_SIZE ).Get<float>();
1309     DALI_TEST_EQUALS( pointSize, 18.f, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
1310   }
1311   DALI_TEST_CHECK( inputStyleChangedSignal );
1312
1313   gInputStyleChangedCallbackCalled = false;
1314   gInputStyleMask = TextEditor::InputStyle::NONE;
1315   inputStyleChangedSignal = false;
1316
1317   // Create a tap event to touch the text editor.
1318   TestGenerateTap( application, 30.0f, 25.0f );
1319
1320   // Render and notify
1321   application.SendNotification();
1322   application.Render();
1323
1324   // Executes the idle callbacks added by the text control on the change of input style.
1325   application.RunIdles();
1326
1327   DALI_TEST_CHECK( !gInputStyleChangedCallbackCalled );
1328   DALI_TEST_CHECK( !inputStyleChangedSignal );
1329
1330   gInputStyleChangedCallbackCalled = false;
1331   gInputStyleMask = TextEditor::InputStyle::NONE;
1332   inputStyleChangedSignal = false;
1333
1334   // Create a tap event to touch the text editor.
1335   TestGenerateTap( application, 43.0f, 25.0f );
1336
1337   // Render and notify
1338   application.SendNotification();
1339   application.Render();
1340
1341   // Executes the idle callbacks added by the text control on the change of input style.
1342   application.RunIdles();
1343
1344   DALI_TEST_CHECK( gInputStyleChangedCallbackCalled );
1345   if( gInputStyleChangedCallbackCalled )
1346   {
1347     DALI_TEST_EQUALS( static_cast<unsigned int>( gInputStyleMask ), static_cast<unsigned int>( TextEditor::InputStyle::COLOR ), TEST_LOCATION );
1348
1349     const Vector4 color = editor.GetProperty( TextEditor::Property::INPUT_COLOR ).Get<Vector4>();
1350     DALI_TEST_EQUALS( color, Color::GREEN, TEST_LOCATION );
1351   }
1352   DALI_TEST_CHECK( inputStyleChangedSignal );
1353
1354   gInputStyleChangedCallbackCalled = false;
1355   gInputStyleMask = TextEditor::InputStyle::NONE;
1356   inputStyleChangedSignal = false;
1357
1358   // Create a tap event to touch the text editor.
1359   TestGenerateTap( application, 88.0f, 25.0f );
1360
1361   // Render and notify
1362   application.SendNotification();
1363   application.Render();
1364
1365   // Executes the idle callbacks added by the text control on the change of input style.
1366   application.RunIdles();
1367
1368   DALI_TEST_CHECK( gInputStyleChangedCallbackCalled );
1369   if( gInputStyleChangedCallbackCalled )
1370   {
1371     DALI_TEST_EQUALS( static_cast<unsigned int>( gInputStyleMask ), static_cast<unsigned int>( TextEditor::InputStyle::COLOR | TextEditor::InputStyle::FONT_STYLE ), TEST_LOCATION );
1372
1373     const Vector4 color = editor.GetProperty( TextEditor::Property::INPUT_COLOR ).Get<Vector4>();
1374     DALI_TEST_EQUALS( color, Color::BLACK, TEST_LOCATION );
1375
1376     Property::Map fontStyleMapSet;
1377     Property::Map fontStyleMapGet;
1378
1379     fontStyleMapSet.Insert( "weight", "bold" );
1380
1381     fontStyleMapGet = editor.GetProperty<Property::Map>( TextEditor::Property::INPUT_FONT_STYLE );
1382     DALI_TEST_EQUALS( fontStyleMapGet.Count(), fontStyleMapSet.Count(), TEST_LOCATION );
1383     DALI_TEST_EQUALS( DaliTestCheckMaps( fontStyleMapGet, fontStyleMapSet ), true, TEST_LOCATION );
1384   }
1385   DALI_TEST_CHECK( inputStyleChangedSignal );
1386
1387   gInputStyleChangedCallbackCalled = false;
1388   gInputStyleMask = TextEditor::InputStyle::NONE;
1389   inputStyleChangedSignal = false;
1390
1391   // Create a tap event to touch the text editor.
1392   TestGenerateTap( application, 115.0f, 25.0f );
1393
1394   // Render and notify
1395   application.SendNotification();
1396   application.Render();
1397
1398   // Executes the idle callbacks added by the text control on the change of input style.
1399   application.RunIdles();
1400
1401   DALI_TEST_CHECK( !gInputStyleChangedCallbackCalled );
1402   DALI_TEST_CHECK( !inputStyleChangedSignal );
1403
1404   gInputStyleChangedCallbackCalled = false;
1405   gInputStyleMask = TextEditor::InputStyle::NONE;
1406   inputStyleChangedSignal = false;
1407
1408   // Create a tap event to touch the text editor.
1409   TestGenerateTap( application, 164.0f, 25.0f );
1410
1411   // Render and notify
1412   application.SendNotification();
1413   application.Render();
1414
1415   // Executes the idle callbacks added by the text control on the change of input style.
1416   application.RunIdles();
1417
1418   DALI_TEST_CHECK( gInputStyleChangedCallbackCalled );
1419   if( gInputStyleChangedCallbackCalled )
1420   {
1421     DALI_TEST_EQUALS( static_cast<unsigned int>( gInputStyleMask ), static_cast<unsigned int>( TextEditor::InputStyle::FONT_STYLE ), TEST_LOCATION );
1422
1423     Property::Map fontStyleMapSet;
1424     Property::Map fontStyleMapGet;
1425
1426     fontStyleMapGet = editor.GetProperty<Property::Map>( TextEditor::Property::INPUT_FONT_STYLE );
1427     DALI_TEST_EQUALS( fontStyleMapGet.Count(), fontStyleMapSet.Count(), TEST_LOCATION );
1428     DALI_TEST_EQUALS( DaliTestCheckMaps( fontStyleMapGet, fontStyleMapSet ), true, TEST_LOCATION );
1429   }
1430   DALI_TEST_CHECK( inputStyleChangedSignal );
1431
1432   gInputStyleChangedCallbackCalled = false;
1433   gInputStyleMask = TextEditor::InputStyle::NONE;
1434   inputStyleChangedSignal = false;
1435
1436   // Create a tap event to touch the text editor.
1437   TestGenerateTap( application, 191.0f, 25.0f );
1438
1439   // Render and notify
1440   application.SendNotification();
1441   application.Render();
1442
1443   // Executes the idle callbacks added by the text control on the change of input style.
1444   application.RunIdles();
1445
1446   DALI_TEST_CHECK( !gInputStyleChangedCallbackCalled );
1447   DALI_TEST_CHECK( !inputStyleChangedSignal );
1448
1449   END_TEST;
1450 }
1451
1452 int utcDaliTextEditorInputStyleChanged02(void)
1453 {
1454   // The text-editor emits signals when the input style changes. These changes of style are
1455   // detected during the relayout process (size negotiation), i.e after the cursor has been moved. Signals
1456   // can't be emitted during the size negotiation as the callbacks may update the UI.
1457   // The text-editor adds an idle callback to the adaptor to emit the signals after the size negotiation.
1458   // The ToolkitTestApplication creates an implementation of the adaptor stub and a queue of idle callbacks.
1459   ToolkitTestApplication application;
1460   tet_infoline(" utcDaliTextEditorInputStyleChanged02");
1461
1462   // Load some fonts.
1463
1464   char* pathNamePtr = get_current_dir_name();
1465   const std::string pathName( pathNamePtr );
1466   free( pathNamePtr );
1467
1468   TextAbstraction::FontClient fontClient = TextAbstraction::FontClient::Get();
1469   fontClient.SetDpi( 93u, 93u );
1470
1471   fontClient.GetFontId( pathName + DEFAULT_FONT_DIR + "/dejavu/DejaVuSerif.ttf", DEFAULT_FONT_SIZE );
1472   fontClient.GetFontId( pathName + DEFAULT_FONT_DIR + "/dejavu/DejaVuSerif-Bold.ttf", DEFAULT_FONT_SIZE );
1473
1474   TextEditor editor = TextEditor::New();
1475   DALI_TEST_CHECK( editor );
1476
1477
1478   editor.SetProperty( Actor::Property::SIZE, Vector2( 300.f, 50.f ) );
1479   editor.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT );
1480   editor.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT );
1481
1482   editor.SetProperty( TextEditor::Property::ENABLE_MARKUP, true );
1483   editor.SetProperty( TextEditor::Property::TEXT, "<font family='DejaVuSerif' size='18'>He<color value='blue'> l</color><color value='green'>lo</color> <font weight='bold'>world</font> demo</font>" );
1484
1485   // connect to the text changed signal.
1486   ConnectionTracker* testTracker = new ConnectionTracker();
1487   editor.InputStyleChangedSignal().Connect( &TestInputStyleChangedCallback );
1488   bool inputStyleChangedSignal = false;
1489   editor.ConnectSignal( testTracker, "inputStyleChanged",   CallbackFunctor(&inputStyleChangedSignal) );
1490
1491   application.GetScene().Add( editor );
1492
1493   // Render and notify
1494   application.SendNotification();
1495   application.Render();
1496
1497   // Executes the idle callbacks added by the text control on the change of input style.
1498   application.RunIdles();
1499
1500   gInputStyleChangedCallbackCalled = false;
1501   gInputStyleMask = TextEditor::InputStyle::NONE;
1502   inputStyleChangedSignal = false;
1503
1504   // Create a tap event to touch the text editor.
1505   TestGenerateTap( application, 53.0f, 25.0f, 100 );
1506   TestGenerateTap( application, 53.0f, 25.0f, 200 );
1507
1508   // Render and notify
1509   application.SendNotification();
1510   application.Render();
1511
1512   // Executes the idle callbacks added by the text control on the change of input style.
1513   application.RunIdles();
1514
1515   DALI_TEST_CHECK( gInputStyleChangedCallbackCalled );
1516   if( gInputStyleChangedCallbackCalled )
1517   {
1518     DALI_TEST_EQUALS( static_cast<unsigned int>( gInputStyleMask ),
1519                       static_cast<unsigned int>( TextEditor::InputStyle::FONT_FAMILY |
1520                                                  TextEditor::InputStyle::POINT_SIZE  |
1521                                                  TextEditor::InputStyle::COLOR ),
1522                       TEST_LOCATION );
1523
1524     const Vector4 color = editor.GetProperty( TextEditor::Property::INPUT_COLOR ).Get<Vector4>();
1525     DALI_TEST_EQUALS( color, Color::GREEN, TEST_LOCATION );
1526
1527     const std::string fontFamily = editor.GetProperty( TextEditor::Property::INPUT_FONT_FAMILY ).Get<std::string>();
1528     DALI_TEST_EQUALS( fontFamily, "DejaVuSerif", TEST_LOCATION );
1529
1530     const float pointSize = editor.GetProperty( TextEditor::Property::INPUT_POINT_SIZE ).Get<float>();
1531     DALI_TEST_EQUALS( pointSize, 18.f, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
1532   }
1533   DALI_TEST_CHECK( inputStyleChangedSignal );
1534
1535   gInputStyleChangedCallbackCalled = false;
1536   gInputStyleMask = TextEditor::InputStyle::NONE;
1537   inputStyleChangedSignal = false;
1538
1539   application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_BACKSPACE, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
1540
1541   // Render and notify
1542   application.SendNotification();
1543   application.Render();
1544
1545   // Executes the idle callbacks added by the text control on the change of input style.
1546   application.RunIdles();
1547
1548   DALI_TEST_CHECK( gInputStyleChangedCallbackCalled );
1549   if( gInputStyleChangedCallbackCalled )
1550   {
1551     DALI_TEST_EQUALS( static_cast<unsigned int>( gInputStyleMask ),
1552                       static_cast<unsigned int>( TextEditor::InputStyle::COLOR ),
1553                       TEST_LOCATION );
1554
1555     const Vector4 color = editor.GetProperty( TextEditor::Property::INPUT_COLOR ).Get<Vector4>();
1556     DALI_TEST_EQUALS( color, Color::BLUE, TEST_LOCATION );
1557   }
1558   DALI_TEST_CHECK( inputStyleChangedSignal );
1559
1560   gInputStyleChangedCallbackCalled = false;
1561   gInputStyleMask = TextEditor::InputStyle::NONE;
1562   inputStyleChangedSignal = false;
1563
1564   application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_BACKSPACE, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
1565
1566   // Render and notify
1567   application.SendNotification();
1568   application.Render();
1569
1570   // Executes the idle callbacks added by the text control on the change of input style.
1571   application.RunIdles();
1572
1573   DALI_TEST_CHECK( !gInputStyleChangedCallbackCalled );
1574   DALI_TEST_CHECK( !inputStyleChangedSignal );
1575
1576   gInputStyleChangedCallbackCalled = false;
1577   gInputStyleMask = TextEditor::InputStyle::NONE;
1578   inputStyleChangedSignal = false;
1579
1580   application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_BACKSPACE, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
1581
1582   // Render and notify
1583   application.SendNotification();
1584   application.Render();
1585
1586   // Executes the idle callbacks added by the text control on the change of input style.
1587   application.RunIdles();
1588
1589   DALI_TEST_CHECK( gInputStyleChangedCallbackCalled );
1590   if( gInputStyleChangedCallbackCalled )
1591   {
1592     DALI_TEST_EQUALS( static_cast<unsigned int>( gInputStyleMask ),
1593                       static_cast<unsigned int>( TextEditor::InputStyle::COLOR ),
1594                       TEST_LOCATION );
1595
1596     const Vector4 color = editor.GetProperty( TextEditor::Property::INPUT_COLOR ).Get<Vector4>();
1597     DALI_TEST_EQUALS( color, Color::BLACK, TEST_LOCATION );
1598   }
1599   DALI_TEST_CHECK( inputStyleChangedSignal );
1600
1601   gInputStyleChangedCallbackCalled = false;
1602   gInputStyleMask = TextEditor::InputStyle::NONE;
1603   inputStyleChangedSignal = false;
1604
1605   editor.SetProperty( TextEditor::Property::INPUT_COLOR, Color::YELLOW );
1606
1607   Property::Map fontStyleMapSet;
1608   fontStyleMapSet.Insert( "weight", "thin" );
1609   fontStyleMapSet.Insert( "width", "condensed" );
1610   fontStyleMapSet.Insert( "slant", "italic" );
1611
1612   editor.SetProperty( TextEditor::Property::INPUT_FONT_STYLE, fontStyleMapSet );
1613   editor.SetProperty( TextEditor::Property::INPUT_POINT_SIZE, 20.f );
1614   editor.SetProperty( TextEditor::Property::INPUT_LINE_SPACING, 5.f );
1615
1616   editor.SetProperty( TextEditor::Property::INPUT_UNDERLINE, "underline" );
1617   editor.SetProperty( TextEditor::Property::INPUT_SHADOW, "shadow" );
1618   editor.SetProperty( TextEditor::Property::INPUT_EMBOSS, "emboss" );
1619   editor.SetProperty( TextEditor::Property::INPUT_OUTLINE, "outline" );
1620
1621   application.ProcessEvent( GenerateKey( "a", "", "a", KEY_A_CODE, 0, 0, Integration::KeyEvent::DOWN, "a", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
1622
1623   // Render and notify
1624   application.SendNotification();
1625   application.Render();
1626
1627   // Executes the idle callbacks added by the text control on the change of input style.
1628   application.RunIdles();
1629
1630   DALI_TEST_CHECK( !gInputStyleChangedCallbackCalled );
1631   DALI_TEST_CHECK( !inputStyleChangedSignal );
1632
1633   // Create a tap event to touch the text editor.
1634   TestGenerateTap( application, 63.0f, 25.0f, 900 );
1635
1636   // Render and notify
1637   application.SendNotification();
1638   application.Render();
1639
1640   // Executes the idle callbacks added by the text control on the change of input style.
1641   application.RunIdles();
1642
1643   DALI_TEST_CHECK( gInputStyleChangedCallbackCalled );
1644   if( gInputStyleChangedCallbackCalled )
1645   {
1646     DALI_TEST_EQUALS( static_cast<unsigned int>( gInputStyleMask ),
1647                       static_cast<unsigned int>( TextEditor::InputStyle::COLOR |
1648                                                  TextEditor::InputStyle::POINT_SIZE |
1649                                                  TextEditor::InputStyle::FONT_STYLE |
1650                                                  TextEditor::InputStyle::LINE_SPACING |
1651                                                  TextEditor::InputStyle::UNDERLINE |
1652                                                  TextEditor::InputStyle::SHADOW |
1653                                                  TextEditor::InputStyle::EMBOSS |
1654                                                  TextEditor::InputStyle::OUTLINE ),
1655                       TEST_LOCATION );
1656
1657     const Vector4 color = editor.GetProperty( TextEditor::Property::INPUT_COLOR ).Get<Vector4>();
1658     DALI_TEST_EQUALS( color, Color::BLACK, TEST_LOCATION );
1659   }
1660   DALI_TEST_CHECK( inputStyleChangedSignal );
1661
1662   gInputStyleChangedCallbackCalled = false;
1663   gInputStyleMask = TextEditor::InputStyle::NONE;
1664   inputStyleChangedSignal = false;
1665
1666   editor.SetProperty( TextEditor::Property::FONT_FAMILY, "DejaVuSerif" );
1667
1668   fontStyleMapSet.Clear();
1669   fontStyleMapSet.Insert( "weight", "black" );
1670   fontStyleMapSet.Insert( "width", "expanded" );
1671   fontStyleMapSet.Insert( "slant", "oblique" );
1672
1673   editor.SetProperty( TextEditor::Property::FONT_STYLE, fontStyleMapSet );
1674
1675   // Create a tap event to touch the text editor.
1676   TestGenerateTap( application, 30.0f, 25.0f, 1500 );
1677
1678   // Render and notify
1679   application.SendNotification();
1680   application.Render();
1681
1682   // Executes the idle callbacks added by the text control on the change of input style.
1683   application.RunIdles();
1684
1685   DALI_TEST_CHECK( gInputStyleChangedCallbackCalled );
1686   if( gInputStyleChangedCallbackCalled )
1687   {
1688     DALI_TEST_EQUALS( static_cast<unsigned int>( gInputStyleMask ),
1689                       static_cast<unsigned int>( TextEditor::InputStyle::COLOR |
1690                                                  TextEditor::InputStyle::POINT_SIZE |
1691                                                  TextEditor::InputStyle::FONT_STYLE ),
1692                       TEST_LOCATION );
1693
1694     const Vector4 color = editor.GetProperty( TextEditor::Property::INPUT_COLOR ).Get<Vector4>();
1695     DALI_TEST_EQUALS( color, Color::YELLOW, TEST_LOCATION );
1696   }
1697   DALI_TEST_CHECK( inputStyleChangedSignal );
1698
1699   END_TEST;
1700 }
1701
1702 int utcDaliTextEditorEvent01(void)
1703 {
1704   ToolkitTestApplication application;
1705   tet_infoline(" utcDaliTextEditorEvent01");
1706
1707   // Creates a tap event. After creating a tap event the text editor should
1708   // have the focus and add text with key events should be possible.
1709
1710   TextEditor editor = TextEditor::New();
1711   DALI_TEST_CHECK( editor );
1712
1713   application.GetScene().Add( editor );
1714
1715   editor.SetProperty( Actor::Property::SIZE, Vector2( 300.f, 50.f ) );
1716   editor.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT );
1717   editor.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT );
1718
1719   // Avoid a crash when core load gl resources.
1720   application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
1721
1722   // Render and notify
1723   application.SendNotification();
1724   application.Render();
1725
1726   // Add a key event but as the text editor has not the focus it should do nothing.
1727   application.ProcessEvent( GenerateKey( "a", "", "a", KEY_A_CODE, 0, 0, Integration::KeyEvent::DOWN, "a", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
1728
1729   // Render and notify
1730   application.SendNotification();
1731   application.Render();
1732
1733   DALI_TEST_EQUALS( editor.GetProperty<std::string>( TextEditor::Property::TEXT ), std::string(""), TEST_LOCATION );
1734
1735   // Create a tap event to touch the text editor.
1736   TestGenerateTap( application, 150.0f, 25.0f );
1737
1738   // Render and notify
1739   application.SendNotification();
1740   application.Render();
1741
1742   // Now the text editor has the focus, so it can handle the key events.
1743   application.ProcessEvent( GenerateKey( "a", "", "a", KEY_A_CODE, 0, 0, Integration::KeyEvent::DOWN, "a", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
1744   application.ProcessEvent( GenerateKey( "a", "", "a", KEY_A_CODE, 0, 0, Integration::KeyEvent::DOWN, "a", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
1745
1746   // Render and notify
1747   application.SendNotification();
1748   application.Render();
1749
1750   DALI_TEST_EQUALS( editor.GetProperty<std::string>( TextEditor::Property::TEXT ), std::string("aa"), TEST_LOCATION );
1751
1752   // Create a second text editor and send key events to it.
1753   TextEditor editor2 = TextEditor::New();
1754
1755   editor2.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT );
1756   editor2.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT );
1757   editor2.SetProperty( Actor::Property::SIZE, Vector2( 100.f, 100.f ) );
1758   editor2.SetProperty( Actor::Property::POSITION, Vector2( 100.f, 100.f ));
1759
1760   application.GetScene().Add( editor2 );
1761
1762   // Render and notify
1763   application.SendNotification();
1764   application.Render();
1765
1766   // Create a tap event on the second text editor.
1767   TestGenerateTap( application, 150.0f, 125.0f );
1768
1769   // Render and notify
1770   application.SendNotification();
1771   application.Render();
1772
1773   // The second text editor has the focus. It should handle the key events.
1774   application.ProcessEvent( GenerateKey( "a", "", "a", KEY_A_CODE, 0, 0, Integration::KeyEvent::DOWN, "a", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
1775   application.ProcessEvent( GenerateKey( "a", "", "a", KEY_A_CODE, 0, 0, Integration::KeyEvent::DOWN, "a", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
1776
1777   // Render and notify
1778   application.SendNotification();
1779   application.Render();
1780
1781   // Check the text has been added to the second text editor.
1782   DALI_TEST_EQUALS( editor2.GetProperty<std::string>( TextEditor::Property::TEXT ), std::string("aa"), TEST_LOCATION );
1783
1784   END_TEST;
1785 }
1786
1787 int utcDaliTextEditorEvent02(void)
1788 {
1789   ToolkitTestApplication application;
1790   tet_infoline(" utcDaliTextEditorEvent02");
1791
1792   // Checks if the right number of actors are created.
1793
1794   TextEditor editor = TextEditor::New();
1795   editor.SetProperty( TextEditor::Property::POINT_SIZE, 10.f );
1796   DALI_TEST_CHECK( editor );
1797
1798   application.GetScene().Add( editor );
1799
1800   editor.SetProperty( Actor::Property::SIZE, Vector2( 300.f, 50.f ) );
1801   editor.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT );
1802   editor.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT );
1803
1804   // Avoid a crash when core load gl resources.
1805   application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
1806
1807   // Render and notify
1808   application.SendNotification();
1809   application.Render();
1810
1811   // Check there are the expected number of children (the stencil).
1812   DALI_TEST_EQUALS( editor.GetChildCount(), 1u, TEST_LOCATION );
1813
1814   Actor stencil = editor.GetChildAt( 0u );
1815
1816   // Create a tap event to touch the text editor.
1817   TestGenerateTap( application, 150.0f, 25.0f, 100 );
1818
1819   // Render and notify
1820   application.SendNotification();
1821   application.Render();
1822
1823   Actor layer = editor.GetChildAt( 1u );
1824   DALI_TEST_EQUALS( layer.GetChildCount(), 1u, TEST_LOCATION ); // The cursor.
1825   DALI_TEST_EQUALS( stencil.GetChildCount(), 0u, TEST_LOCATION );
1826
1827   // Now the text editor has the focus, so it can handle the key events.
1828   application.ProcessEvent( GenerateKey( "a", "", "a", KEY_A_CODE, 0, 0, Integration::KeyEvent::DOWN, "a", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
1829   application.ProcessEvent( GenerateKey( "a", "", "a", KEY_A_CODE, 0, 0, Integration::KeyEvent::DOWN, "a", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
1830
1831   // Render and notify
1832   application.SendNotification();
1833   application.Render();
1834
1835   // Checks the cursor and the renderer have been created.
1836   DALI_TEST_EQUALS( layer.GetChildCount(), 1u, TEST_LOCATION ); // The cursor.
1837   DALI_TEST_EQUALS( stencil.GetChildCount(), 1u, TEST_LOCATION ); // The renderer
1838
1839   Control cursor = Control::DownCast( layer.GetChildAt( 0u ) );
1840   DALI_TEST_CHECK( cursor );
1841
1842   // The stencil actor has a container with all the actors which contain the text renderers.
1843   Actor container = stencil.GetChildAt( 0u );
1844   for( unsigned int index = 0; index < container.GetChildCount(); ++index )
1845   {
1846     Renderer renderer = container.GetChildAt( index ).GetRendererAt( 0u );
1847     DALI_TEST_CHECK( renderer );
1848   }
1849
1850   // Move the cursor and check the position changes.
1851   Vector3 position1 = cursor.GetCurrentProperty< Vector3 >( Actor::Property::POSITION );
1852
1853   application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_LEFT, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
1854   application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_LEFT, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
1855
1856   // Render and notify
1857   application.SendNotification();
1858   application.Render();
1859
1860   Vector3 position2 = cursor.GetCurrentProperty< Vector3 >( Actor::Property::POSITION );
1861
1862   DALI_TEST_CHECK( position2.x < position1.x );
1863
1864   application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_RIGHT, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
1865   application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_RIGHT, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
1866
1867   // Render and notify
1868   application.SendNotification();
1869   application.Render();
1870
1871   Vector3 position3 = cursor.GetCurrentProperty< Vector3 >( Actor::Property::POSITION );
1872
1873   DALI_TEST_EQUALS( position1, position3, TEST_LOCATION ); // Should be in the same position1.
1874
1875   // Send some taps and check the cursor positions.
1876
1877   // Try to tap at the beginning.
1878   TestGenerateTap( application, 1.0f, 25.0f, 700 );
1879
1880   // Render and notify
1881   application.SendNotification();
1882   application.Render();
1883
1884   // Cursor position should be the same than position1.
1885   Vector3 position4 = cursor.GetCurrentProperty< Vector3 >( Actor::Property::POSITION );
1886
1887   DALI_TEST_EQUALS( position2, position4, TEST_LOCATION ); // Should be in the same position2.
1888
1889   // Tap away from the start position.
1890   TestGenerateTap( application, 16.0f, 25.0f, 1400 );
1891
1892   // Render and notify
1893   application.SendNotification();
1894   application.Render();
1895
1896   Vector3 position5 = cursor.GetCurrentProperty< Vector3 >( Actor::Property::POSITION );
1897
1898   DALI_TEST_CHECK( position5.x > position4.x );
1899
1900   // Remove all the text.
1901   application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_BACKSPACE, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
1902   application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_BACKSPACE, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
1903   editor.SetProperty( TextEditor::Property::TEXT, "" );
1904
1905   // Render and notify
1906   application.SendNotification();
1907   application.Render();
1908
1909   // Cursor position should be the same than position2.
1910   Vector3 position6 = cursor.GetCurrentProperty< Vector3 >( Actor::Property::POSITION );
1911
1912   DALI_TEST_EQUALS( position2, position6, TEST_LOCATION );// Should be in the same position2.
1913
1914   // Should not be a renderer.
1915   DALI_TEST_EQUALS( stencil.GetChildCount(), 0u, TEST_LOCATION );
1916
1917   END_TEST;
1918 }
1919
1920 int utcDaliTextEditorEvent03(void)
1921 {
1922   ToolkitTestApplication application;
1923   tet_infoline(" utcDaliTextEditorEvent03");
1924
1925   // Checks if the highlight actor is created.
1926
1927   TextEditor editor = TextEditor::New();
1928   DALI_TEST_CHECK( editor );
1929
1930   application.GetScene().Add( editor );
1931
1932   editor.SetProperty( TextEditor::Property::TEXT, "This is a long text for the size of the text-editor." );
1933   editor.SetProperty( TextEditor::Property::POINT_SIZE, 10.f );
1934   editor.SetProperty( Actor::Property::SIZE, Vector2( 30.f, 50.f ) );
1935   editor.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT );
1936   editor.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT );
1937
1938   // Avoid a crash when core load gl resources.
1939   application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
1940
1941   // Render and notify
1942   application.SendNotification();
1943   application.Render();
1944
1945   // Send some taps and check text controller with clipboard window
1946   Dali::Clipboard clipboard = Clipboard::Get();
1947   clipboard.ShowClipboard();
1948   TestGenerateTap( application, 3.0f, 25.0f, 100 );
1949   clipboard.HideClipboard();
1950
1951   // Render and notify
1952   application.SendNotification();
1953   application.Render();
1954
1955   // Tap first to get the focus.
1956   TestGenerateTap( application, 3.0f, 25.0f, 1000 );
1957
1958   // Render and notify
1959   application.SendNotification();
1960   application.Render();
1961
1962   // Double tap to select a word.
1963   TestGenerateTap( application, 3.0f, 25.0f, 1100 );
1964
1965   // Render and notify
1966   application.SendNotification();
1967   application.Render();
1968
1969   // The stencil actor should have two actors: the renderer and the highlight actor.
1970   Actor stencil = editor.GetChildAt( 0u );
1971
1972   // Highlight needs to be drawn before text, so should come first in child order
1973   Renderer highlight = stencil.GetChildAt( 0u ).GetRendererAt( 0u );
1974   DALI_TEST_CHECK( highlight );
1975
1976   // The stencil actor has a container with all the actors which contain the text renderers.
1977   Actor container = stencil.GetChildAt( 1u );
1978   for( unsigned int index = 0; index < container.GetChildCount(); ++index )
1979   {
1980     Renderer renderer = container.GetChildAt( index ).GetRendererAt( 0u );
1981     DALI_TEST_CHECK( renderer );
1982   }
1983
1984   // Double tap out of bounds
1985   TestGenerateTap( application, 29.0f, 25.0f, 1700 );
1986   TestGenerateTap( application, 29.0f, 25.0f, 1800 );
1987
1988   // Render and notify
1989   application.SendNotification();
1990   application.Render();
1991
1992   // The stencil actor should have one actors: the renderer actor.
1993   stencil = editor.GetChildAt( 0u );
1994
1995   // The stencil actor has a container with all the actors which contain the text renderers.
1996   container = stencil.GetChildAt( 0u );
1997   for( unsigned int index = 0; index < container.GetChildCount(); ++index )
1998   {
1999     Renderer renderer = container.GetChildAt( index ).GetRendererAt( 0u );
2000     DALI_TEST_CHECK( renderer );
2001   }
2002
2003   // Long Press
2004   TestGenerateLongPress(application, 1.0f, 25.0f);
2005
2006   // Render and notify
2007   application.SendNotification();
2008   application.Render();
2009
2010   // Pan Press
2011   TestGenerateMiniPan(application);
2012
2013   // Render and notify
2014   application.SendNotification();
2015   application.Render();
2016
2017   END_TEST;
2018 }
2019
2020 int utcDaliTextEditorEvent04(void)
2021 {
2022   ToolkitTestApplication application;
2023   tet_infoline(" utcDaliTextEditorEvent04");
2024
2025   // Checks if the highlight actor is created.
2026
2027   TextEditor editor = TextEditor::New();
2028   DALI_TEST_CHECK( editor );
2029
2030   application.GetScene().Add( editor );
2031
2032   editor.SetProperty( TextEditor::Property::TEXT, "Hello\nworl" );
2033   editor.SetProperty( TextEditor::Property::POINT_SIZE, 10.f );
2034   editor.SetProperty( Actor::Property::SIZE, Vector2( 100.f, 50.f ) );
2035   editor.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT );
2036   editor.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT );
2037
2038   // Avoid a crash when core load gl resources.
2039   application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
2040
2041   // Render and notify
2042   application.SendNotification();
2043   application.Render();
2044
2045   // Tap on the text editor
2046   TestGenerateTap( application, 3.0f, 25.0f );
2047
2048   // Render and notify
2049   application.SendNotification();
2050   application.Render();
2051
2052   // Move at the end of the text.
2053   application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_DOWN, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2054   application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_DOWN, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2055
2056   // Render and notify
2057   application.SendNotification();
2058   application.Render();
2059
2060   for( unsigned int index = 0u; index < 10u; ++index )
2061   {
2062     application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_RIGHT, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2063     application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_RIGHT, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2064
2065     // Render and notify
2066     application.SendNotification();
2067     application.Render();
2068   }
2069
2070   // Add a character
2071   application.ProcessEvent( GenerateKey( "d", "", "d", KEY_D_CODE, 0, 0, Integration::KeyEvent::DOWN, "d", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2072
2073   // Render and notify
2074   application.SendNotification();
2075   application.Render();
2076
2077   DALI_TEST_EQUALS( "Hello\nworld", editor.GetProperty<std::string>( TextEditor::Property::TEXT ), TEST_LOCATION );
2078
2079   // Add some key events
2080   application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_UP, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2081   application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_UP, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2082
2083   // Render and notify
2084   application.SendNotification();
2085   application.Render();
2086
2087   for( unsigned int index = 0u; index < 10u; ++index )
2088   {
2089     application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_LEFT, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2090     application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_LEFT, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2091
2092     // Render and notify
2093     application.SendNotification();
2094     application.Render();
2095   }
2096
2097   // Add a character
2098   application.ProcessEvent( GenerateKey( " ", "", " ", KEY_WHITE_SPACE_CODE, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2099
2100   // Render and notify
2101   application.SendNotification();
2102   application.Render();
2103
2104   DALI_TEST_EQUALS( " Hello\nworld", editor.GetProperty<std::string>( TextEditor::Property::TEXT ), TEST_LOCATION );
2105
2106   END_TEST;
2107 }
2108
2109 int utcDaliTextEditorEvent05(void)
2110 {
2111   ToolkitTestApplication application;
2112   tet_infoline(" utcDaliTextEditorEvent05");
2113
2114   // Checks if the highlight actor is created.
2115
2116   TextEditor editor = TextEditor::New();
2117   DALI_TEST_CHECK( editor );
2118
2119   application.GetScene().Add( editor );
2120
2121   editor.SetProperty( TextEditor::Property::TEXT, "Hello\nworl" );
2122   editor.SetProperty( TextEditor::Property::POINT_SIZE, 10.f );
2123   editor.SetProperty( Actor::Property::SIZE, Vector2( 50.f, 50.f ) );
2124   editor.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT );
2125   editor.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT );
2126   editor.SetProperty( TextEditor::Property::SMOOTH_SCROLL, true );
2127   editor.SetProperty( TextEditor::Property::SMOOTH_SCROLL_DURATION, 0.2f );
2128   editor.SetProperty( TextEditor::Property::ENABLE_SCROLL_BAR, true );
2129   editor.SetProperty( TextEditor::Property::SCROLL_BAR_SHOW_DURATION, 0.3f );
2130   editor.SetProperty( TextEditor::Property::SCROLL_BAR_FADE_DURATION, 0.2f );
2131
2132   // Avoid a crash when core load gl resources.
2133   application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
2134
2135   // Render and notify
2136   application.SendNotification();
2137   application.Render();
2138
2139   // Tap on the text editor
2140   TestGenerateTap( application, 3.0f, 25.0f );
2141
2142   // Render and notify
2143   application.SendNotification();
2144   application.Render();
2145
2146   // Move at the end of the text.
2147   application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_DOWN, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2148   application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_DOWN, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2149
2150   // Render and notify
2151   application.SendNotification();
2152   application.Render();
2153
2154   for( unsigned int index = 0u; index < 10u; ++index )
2155   {
2156     // Add a character
2157     application.ProcessEvent( GenerateKey( "d", "", "d", KEY_D_CODE, 0, 0, Integration::KeyEvent::DOWN, "d", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2158
2159     // Render and notify
2160     application.SendNotification();
2161     application.Render();
2162   }
2163   // Modify duration after scroll is enabled
2164   editor.SetProperty( TextEditor::Property::SMOOTH_SCROLL_DURATION, 0.1f );
2165
2166   // Continuous scroll left to increase coverage
2167   for( unsigned int index = 0u; index < 10u; ++index )
2168   {
2169     application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_LEFT, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2170
2171     // Render and notify
2172     application.SendNotification();
2173     application.Render();
2174   }
2175   DALI_TEST_EQUALS( editor.GetProperty<float>( TextEditor::Property::SMOOTH_SCROLL_DURATION ), 0.1f, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
2176   DALI_TEST_EQUALS( editor.GetProperty<bool>( TextEditor::Property::SMOOTH_SCROLL ), true, TEST_LOCATION );
2177   DALI_TEST_EQUALS( editor.GetProperty<bool>( TextEditor::Property::ENABLE_SCROLL_BAR ), true, TEST_LOCATION );
2178   DALI_TEST_EQUALS( editor.GetProperty<float>( TextEditor::Property::SCROLL_BAR_SHOW_DURATION ), 0.3f, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
2179   DALI_TEST_EQUALS( editor.GetProperty<float>( TextEditor::Property::SCROLL_BAR_FADE_DURATION ), 0.2f, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
2180
2181   // Press Escape to increase coverage
2182   application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_ESCAPE, 0, 0, Integration::KeyEvent::UP, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2183   application.SendNotification();
2184   application.Render();
2185
2186   DALI_TEST_CHECK( !editor.HasKeyInputFocus() );
2187
2188   END_TEST;
2189 }
2190
2191 int utcDaliTextEditorEvent06(void)
2192 {
2193   ToolkitTestApplication application;
2194   tet_infoline(" utcDaliTextEditorEvent06");
2195
2196   // Checks if the highlight actor is created.
2197
2198   TextEditor editor = TextEditor::New();
2199   DALI_TEST_CHECK( editor );
2200
2201   application.GetScene().Add( editor );
2202
2203   editor.SetProperty( TextEditor::Property::TEXT, "Hello\nworld\nHello world" );
2204   editor.SetProperty( TextEditor::Property::POINT_SIZE, 10.f );
2205   editor.SetProperty( Actor::Property::SIZE, Vector2( 100.f, 50.f ) );
2206   editor.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT );
2207   editor.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT );
2208
2209   // Avoid a crash when core load gl resources.
2210   application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
2211
2212   // Render and notify
2213   application.SendNotification();
2214   application.Render();
2215
2216   // Tap on the text editor
2217   TestGenerateTap( application, 3.0f, 25.0f );
2218
2219   // Render and notify
2220   application.SendNotification();
2221   application.Render();
2222
2223   // Move to seconds line of the text.
2224   application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_DOWN, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2225
2226   // Render and notify
2227   application.SendNotification();
2228   application.Render();
2229
2230   float layoutHeight = editor.GetHeightForWidth( 100.f );
2231
2232
2233   // Add  another script characters ( glyph height is defferent )
2234   application.ProcessEvent( GenerateKey( "d", "", "ㅁ", KEY_D_CODE, 0, 0, Integration::KeyEvent::DOWN, "ㅁ", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2235   application.ProcessEvent( GenerateKey( "d", "", "ኢ", KEY_D_CODE, 0, 0, Integration::KeyEvent::DOWN, "ኢ", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2236
2237   // Delete characters
2238   application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_BACKSPACE, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2239   application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_BACKSPACE, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2240
2241   DALI_TEST_EQUALS( layoutHeight, editor.GetHeightForWidth( 100.f ), TEST_LOCATION );
2242
2243   // Render and notify
2244   application.SendNotification();
2245   application.Render();
2246
2247   DALI_TEST_EQUALS( "Hello\nworld\nHello world", editor.GetProperty<std::string>( TextEditor::Property::TEXT ), TEST_LOCATION );
2248
2249   // For coverage
2250   application.ProcessEvent( GenerateKey( "", "", "", 0, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2251   application.SendNotification();
2252   application.Render();
2253
2254   application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_SHIFT_LEFT, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2255   application.SendNotification();
2256   application.Render();
2257
2258   application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_VOLUME_UP, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2259   application.SendNotification();
2260   application.Render();
2261
2262   application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_VOLUME_DOWN, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2263   application.SendNotification();
2264   application.Render();
2265
2266   application.ProcessEvent( GenerateKey( "", "", "", Dali::DevelKey::DALI_KEY_DELETE, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2267   application.SendNotification();
2268   application.Render();
2269
2270   application.ProcessEvent( GenerateKey( "", "", "", Dali::DevelKey::DALI_KEY_CONTROL_LEFT, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2271   application.SendNotification();
2272   application.Render();
2273
2274   application.ProcessEvent( GenerateKey( "", "", "", Dali::DevelKey::DALI_KEY_CONTROL_RIGHT, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2275   application.SendNotification();
2276   application.Render();
2277
2278   END_TEST;
2279 }
2280
2281 int utcDaliTextEditorEvent07(void)
2282 {
2283   ToolkitTestApplication application;
2284   tet_infoline(" utcDaliTextEditorEvent07");
2285
2286   // Checks if the highlight actor is created.
2287
2288   TextEditor editor = TextEditor::New();
2289   DALI_TEST_CHECK( editor );
2290
2291   application.GetScene().Add( editor );
2292
2293   editor.SetProperty( TextEditor::Property::TEXT, "Hello\nworld\nHello world" );
2294   editor.SetProperty( TextEditor::Property::POINT_SIZE, 10.f );
2295   editor.SetProperty( Actor::Property::SIZE, Vector2( 100.f, 50.f ) );
2296   editor.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT );
2297   editor.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT );
2298
2299   // Avoid a crash when core load gl resources.
2300   application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
2301
2302   // Render and notify
2303   application.SendNotification();
2304   application.Render();
2305
2306   // Tap on the text editor
2307   TestGenerateTap( application, 3.0f, 25.0f );
2308
2309   // Render and notify
2310   application.SendNotification();
2311   application.Render();
2312
2313   // Move to second line of the text.
2314   application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_DOWN, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2315
2316   // Render and notify
2317   application.SendNotification();
2318   application.Render();
2319
2320   // Select some text in the right of the current cursor position
2321   application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_SHIFT_LEFT, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2322   application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_RIGHT, KEY_SHIFT_MODIFIER, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2323   application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_RIGHT, KEY_SHIFT_MODIFIER, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2324   application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_RIGHT, KEY_SHIFT_MODIFIER, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2325
2326   // Render and notify
2327   application.SendNotification();
2328   application.Render();
2329
2330   // Cut the selected text
2331   application.ProcessEvent( GenerateKey( "", "", "", Dali::DevelKey::DALI_KEY_CONTROL_LEFT, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2332   application.ProcessEvent( GenerateKey( "x", "", "x", KEY_X_CODE, KEY_CONTROL_MODIFIER, 0, Integration::KeyEvent::DOWN, "x", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2333
2334   // Render and notify
2335   application.SendNotification();
2336   application.Render();
2337
2338   DALI_TEST_EQUALS( "Hello\nld\nHello world", editor.GetProperty<std::string>( TextEditor::Property::TEXT ), TEST_LOCATION );
2339
2340   // Select some text in the left of the current cursor position
2341   application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_SHIFT_LEFT, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2342   application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_LEFT, KEY_SHIFT_MODIFIER, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2343   application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_LEFT, KEY_SHIFT_MODIFIER, 0, Integration::KeyEvent::DOWN,  "",DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2344   application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_LEFT, KEY_SHIFT_MODIFIER, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2345
2346   // Render and notify
2347   application.SendNotification();
2348   application.Render();
2349
2350   // Copy the selected text
2351   application.ProcessEvent( GenerateKey( "", "", "", Dali::DevelKey::DALI_KEY_CONTROL_LEFT, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2352   application.ProcessEvent( GenerateKey( "c", "", "c", KEY_C_CODE, KEY_CONTROL_MODIFIER, 0, Integration::KeyEvent::DOWN, "c", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2353
2354   // Render and notify
2355   application.SendNotification();
2356   application.Render();
2357
2358   // Move the cursor to the third line
2359   application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_DOWN, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2360   application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_DOWN, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2361
2362   // Render and notify
2363   application.SendNotification();
2364   application.Render();
2365
2366   // Paste the selected text at the current cursor position
2367   application.ProcessEvent( GenerateKey( "", "", "", Dali::DevelKey::DALI_KEY_CONTROL_LEFT, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2368   application.ProcessEvent( GenerateKey( "v", "", "v", KEY_V_CODE, KEY_CONTROL_MODIFIER, 0, Integration::KeyEvent::DOWN, "v", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2369
2370   // Render and notify
2371   application.SendNotification();
2372   application.Render();
2373
2374   DALI_TEST_EQUALS( "Hello\nld\nHello lo\nworld", editor.GetProperty<std::string>( TextEditor::Property::TEXT ), TEST_LOCATION );
2375
2376
2377   // Disable Shift Selection
2378   editor.SetProperty( DevelTextEditor::Property::ENABLE_SHIFT_SELECTION, false );
2379
2380   // Test to select some text in the right of the current cursor position
2381   application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_SHIFT_LEFT, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2382   application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_RIGHT, KEY_SHIFT_MODIFIER, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2383   application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_RIGHT, KEY_SHIFT_MODIFIER, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2384   application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_RIGHT, KEY_SHIFT_MODIFIER, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2385
2386   // Render and notify
2387   application.SendNotification();
2388   application.Render();
2389
2390   // Cut the selected text
2391   application.ProcessEvent( GenerateKey( "", "", "", Dali::DevelKey::DALI_KEY_CONTROL_LEFT, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2392   application.ProcessEvent( GenerateKey( "x", "", "x", KEY_X_CODE, KEY_CONTROL_MODIFIER, 0, Integration::KeyEvent::DOWN, "x", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2393
2394   // Render and notify
2395   application.SendNotification();
2396   application.Render();
2397
2398   // The text isn't selected and not changed because of 'SetProperty( DevelTextEditor::Property::ENABLE_SHIFT_SELECTION, false )'
2399   DALI_TEST_EQUALS( "Hello\nld\nHello lo\nworld", editor.GetProperty<std::string>( TextEditor::Property::TEXT ), TEST_LOCATION );
2400
2401   // Test to select some text in the left of the current cursor position
2402   application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_SHIFT_LEFT, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2403   application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_LEFT, KEY_SHIFT_MODIFIER, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2404   application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_LEFT, KEY_SHIFT_MODIFIER, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2405   application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_LEFT, KEY_SHIFT_MODIFIER, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2406
2407   // Render and notify
2408   application.SendNotification();
2409   application.Render();
2410
2411   // Copy the selected text
2412   application.ProcessEvent( GenerateKey( "", "", "", Dali::DevelKey::DALI_KEY_CONTROL_LEFT, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2413   application.ProcessEvent( GenerateKey( "c", "", "c", KEY_C_CODE, KEY_CONTROL_MODIFIER, 0, Integration::KeyEvent::DOWN, "c", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2414
2415   // Render and notify
2416   application.SendNotification();
2417   application.Render();
2418
2419   // The text is not selected and not changed because of 'SetProperty( DevelTextEditor::Property::ENABLE_SHIFT_SELECTION, false )'
2420   DALI_TEST_EQUALS( "Hello\nld\nHello lo\nworld", editor.GetProperty<std::string>( TextEditor::Property::TEXT ), TEST_LOCATION );
2421
2422   // Select all Text
2423   application.ProcessEvent( GenerateKey( "a", "", "a", KEY_A_CODE, KEY_CONTROL_MODIFIER, 0, Integration::KeyEvent::DOWN, "a", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2424
2425   // Render and notify
2426   application.SendNotification();
2427   application.Render();
2428
2429   // replace text with "c"
2430   application.ProcessEvent( GenerateKey( "c", "", "c", KEY_C_CODE, 0, 0, Integration::KeyEvent::DOWN, "c", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2431
2432   // Render and notify
2433   application.SendNotification();
2434   application.Render();
2435
2436   //text is "c"
2437   DALI_TEST_EQUALS( "c", editor.GetProperty<std::string>( TextEditor::Property::TEXT ), TEST_LOCATION );
2438
2439   // select all text
2440   DevelTextEditor::SelectWholeText(editor);
2441
2442   // Render and notify
2443   application.SendNotification();
2444   application.Render();
2445
2446   // Copy the selected text using logical keys
2447   application.ProcessEvent( GenerateKey( "", "", "", Dali::DevelKey::DALI_KEY_CONTROL_LEFT, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2448   application.ProcessEvent( GenerateKey( "ؤ", "c", "ؤ", KEY_C_CODE, KEY_CONTROL_MODIFIER, 0, Integration::KeyEvent::DOWN, "c", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2449
2450   // Render and notify
2451   application.SendNotification();
2452   application.Render();
2453
2454   // select none
2455   DevelTextEditor::SelectNone(editor);
2456
2457   // Render and notify
2458   application.SendNotification();
2459   application.Render();
2460
2461   // Paste the selected using logical keys
2462   application.ProcessEvent( GenerateKey( "", "", "", Dali::DevelKey::DALI_KEY_CONTROL_LEFT, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2463   application.ProcessEvent( GenerateKey( "ر", "v", "ر", KEY_V_CODE, KEY_CONTROL_MODIFIER, 0, Integration::KeyEvent::DOWN, "v", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2464
2465   //text is "cc"
2466   DALI_TEST_EQUALS( "cc", editor.GetProperty<std::string>( TextEditor::Property::TEXT ), TEST_LOCATION );
2467
2468   // select all using logical keys
2469   application.ProcessEvent( GenerateKey( "", "", "", Dali::DevelKey::DALI_KEY_CONTROL_LEFT, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2470   application.ProcessEvent( GenerateKey( "ش", "a", "ش", KEY_A_CODE, KEY_CONTROL_MODIFIER, 0, Integration::KeyEvent::DOWN, "a", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2471
2472   // Render and notify
2473   application.SendNotification();
2474   application.Render();
2475
2476   // cut text using logical keys
2477   application.ProcessEvent( GenerateKey( "", "", "", Dali::DevelKey::DALI_KEY_CONTROL_LEFT, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2478   application.ProcessEvent( GenerateKey( "ء", "x", "ء", KEY_X_CODE, KEY_CONTROL_MODIFIER, 0, Integration::KeyEvent::DOWN, "x", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2479
2480   // Render and notify
2481   application.SendNotification();
2482   application.Render();
2483
2484   //text is ""
2485   DALI_TEST_EQUALS( "", editor.GetProperty<std::string>( TextEditor::Property::TEXT ), TEST_LOCATION );
2486
2487   END_TEST;
2488 }
2489
2490 int utcDaliTextEditorEvent08(void)
2491 {
2492   ToolkitTestApplication application;
2493   tet_infoline(" utcDaliTextEditorEvent08");
2494
2495   // Checks if the highlight actor is released correctly.
2496
2497   TextEditor editor = TextEditor::New();
2498   DALI_TEST_CHECK( editor );
2499
2500   application.GetScene().Add( editor );
2501
2502   editor.SetProperty( TextEditor::Property::TEXT, "DALi" );
2503   editor.SetProperty( TextEditor::Property::POINT_SIZE, 10.f );
2504   editor.SetProperty( Actor::Property::SIZE, Vector2( 100.f, 50.f ) );
2505   editor.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT );
2506   editor.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT );
2507
2508   // Avoid a crash when core load gl resources.
2509   application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
2510
2511   // Render and notify
2512   application.SendNotification();
2513   application.Render();
2514
2515   // Tap on the text editor
2516   TestGenerateTap( application, 3.0f, 25.0f );
2517
2518   // Render and notify
2519   application.SendNotification();
2520   application.Render();
2521
2522   // When the left selection handle and the right selection handle are at the same position, the highlight box should be deactivated.
2523   // Test to select some text in the left of the current cursor position
2524   application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_SHIFT_LEFT, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2525   application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_LEFT, KEY_SHIFT_MODIFIER, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2526   application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_LEFT, KEY_SHIFT_MODIFIER, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2527   application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_LEFT, KEY_SHIFT_MODIFIER, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2528
2529   // Render and notify
2530   application.SendNotification();
2531   application.Render();
2532
2533   // Test to the left selection handle position and the right selection handle position
2534   application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_SHIFT_LEFT, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2535   application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_RIGHT, KEY_SHIFT_MODIFIER, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2536   application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_RIGHT, KEY_SHIFT_MODIFIER, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2537   application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_RIGHT, KEY_SHIFT_MODIFIER, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2538
2539   // Render and notify
2540   application.SendNotification();
2541   application.Render();
2542
2543   // Test to select full text in the left of the current cursor position
2544   application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_SHIFT_LEFT, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2545   application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_LEFT, KEY_SHIFT_MODIFIER, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2546   application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_LEFT, KEY_SHIFT_MODIFIER, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2547   application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_LEFT, KEY_SHIFT_MODIFIER, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2548   application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_LEFT, KEY_SHIFT_MODIFIER, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2549   application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_LEFT, KEY_SHIFT_MODIFIER, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2550
2551   // Render and notify
2552   application.SendNotification();
2553   application.Render();
2554
2555   // Test to release the current full text selection
2556   application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_LEFT, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2557   application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_LEFT, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2558
2559   // Render and notify
2560   application.SendNotification();
2561   application.Render();
2562
2563   // Test to move the current cursor position correctly
2564   application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_RIGHT, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2565
2566   // Render and notify
2567   application.SendNotification();
2568   application.Render();
2569
2570   // Add a character
2571   application.ProcessEvent( GenerateKey( "d", "", "d", KEY_D_CODE, 0, 0, Integration::KeyEvent::DOWN, "d", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2572
2573   // Render and notify
2574   application.SendNotification();
2575   application.Render();
2576
2577   DALI_TEST_EQUALS( "DdALi", editor.GetProperty<std::string>( TextEditor::Property::TEXT ), TEST_LOCATION );
2578
2579   // Test to select some text in the right of the current cursor position
2580   application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_SHIFT_LEFT, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2581   application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_RIGHT, KEY_SHIFT_MODIFIER, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2582   application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_RIGHT, KEY_SHIFT_MODIFIER, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2583
2584   // Render and notify
2585   application.SendNotification();
2586   application.Render();
2587
2588   // Test the cursor position with right arrow key
2589   application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_RIGHT, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2590
2591   // Render and notify
2592   application.SendNotification();
2593   application.Render();
2594
2595   // Add a character
2596   application.ProcessEvent( GenerateKey( "c", "", "c", KEY_C_CODE, 0, 0, Integration::KeyEvent::DOWN, "c", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2597
2598   // Render and notify
2599   application.SendNotification();
2600   application.Render();
2601
2602   DALI_TEST_EQUALS( "DdALci", editor.GetProperty<std::string>( TextEditor::Property::TEXT ), TEST_LOCATION );
2603
2604   // Test to select some text in the left of the current cursor position
2605   application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_SHIFT_LEFT, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2606   application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_LEFT, KEY_SHIFT_MODIFIER, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2607   application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_LEFT, KEY_SHIFT_MODIFIER, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2608   application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_LEFT, KEY_SHIFT_MODIFIER, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2609   application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_LEFT, KEY_SHIFT_MODIFIER, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2610
2611   // Render and notify
2612   application.SendNotification();
2613   application.Render();
2614
2615   // Test the cursor position with left arrow key
2616   application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_LEFT, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2617
2618   // Render and notify
2619   application.SendNotification();
2620   application.Render();
2621
2622   // Add a character
2623   application.ProcessEvent( GenerateKey( "c", "", "c", KEY_C_CODE, 0, 0, Integration::KeyEvent::DOWN, "c", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2624
2625   // Render and notify
2626   application.SendNotification();
2627   application.Render();
2628
2629   DALI_TEST_EQUALS( "DcdALci", editor.GetProperty<std::string>( TextEditor::Property::TEXT ), TEST_LOCATION );
2630
2631   // Test to select some text in the right of the current cursor position
2632   application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_SHIFT_LEFT, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2633   application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_RIGHT, KEY_SHIFT_MODIFIER, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2634   application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_RIGHT, KEY_SHIFT_MODIFIER, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2635   application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_RIGHT, KEY_SHIFT_MODIFIER, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2636
2637   // Render and notify
2638   application.SendNotification();
2639   application.Render();
2640
2641   // Test the cursor position with left arrow key
2642   application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_LEFT, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2643
2644   // Render and notify
2645   application.SendNotification();
2646   application.Render();
2647
2648   // Add a character
2649   application.ProcessEvent( GenerateKey( "x", "", "x", KEY_X_CODE, 0, 0, Integration::KeyEvent::DOWN, "x", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2650
2651   // Render and notify
2652   application.SendNotification();
2653   application.Render();
2654
2655   DALI_TEST_EQUALS( "DcxdALci", editor.GetProperty<std::string>( TextEditor::Property::TEXT ), TEST_LOCATION );
2656
2657   // Test to select some text in the left of the current cursor position
2658   application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_SHIFT_LEFT, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2659   application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_LEFT, KEY_SHIFT_MODIFIER, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2660   application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_LEFT, KEY_SHIFT_MODIFIER, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2661   application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_LEFT, KEY_SHIFT_MODIFIER, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2662
2663   // Render and notify
2664   application.SendNotification();
2665   application.Render();
2666
2667   // Test the cursor position with right arrow key
2668   application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_RIGHT, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2669
2670   // Render and notify
2671   application.SendNotification();
2672   application.Render();
2673
2674   // Add a character
2675   application.ProcessEvent( GenerateKey( "c", "", "c", KEY_C_CODE, 0, 0, Integration::KeyEvent::DOWN, "c", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2676
2677   // Render and notify
2678   application.SendNotification();
2679   application.Render();
2680
2681   DALI_TEST_EQUALS( "DcxcdALci", editor.GetProperty<std::string>( TextEditor::Property::TEXT ), TEST_LOCATION );
2682
2683   END_TEST;
2684 }
2685
2686 int utcDaliTextEditorHandles(void)
2687 {
2688   ToolkitTestApplication application;
2689   tet_infoline(" utcDaliTextEditorHandles");
2690
2691   TextEditor editor = TextEditor::New();
2692   DALI_TEST_CHECK( editor );
2693
2694   application.GetScene().Add( editor );
2695
2696   editor.SetProperty( TextEditor::Property::TEXT, "This is a long text for the size of the text-editor." );
2697   editor.SetProperty( TextEditor::Property::POINT_SIZE, 10.f );
2698   editor.SetProperty( TextEditor::Property::GRAB_HANDLE_IMAGE, HANDLE_IMAGE_FILE_NAME );
2699   editor.SetProperty( TextEditor::Property::SMOOTH_SCROLL, true );
2700
2701   editor.SetProperty( TextEditor::Property::SELECTION_HANDLE_IMAGE_LEFT, Property::Map{ {"filename", HANDLE_LEFT_SELECTION_FILE_NAME } } );
2702   editor.SetProperty( TextEditor::Property::SELECTION_HANDLE_IMAGE_RIGHT, Property::Map{ {"filename", HANDLE_LEFT_SELECTION_FILE_NAME } } );
2703   editor.SetProperty( TextEditor::Property::SELECTION_HANDLE_PRESSED_IMAGE_LEFT, Property::Map{ {"filename", HANDLE_RIGHT_SELECTION_FILE_NAME } } );
2704   editor.SetProperty( TextEditor::Property::SELECTION_HANDLE_PRESSED_IMAGE_RIGHT, Property::Map{ {"filename", HANDLE_RIGHT_SELECTION_FILE_NAME } } );
2705
2706   editor.SetProperty( Actor::Property::SIZE, Vector2( 30.f, 500.f ) );
2707   editor.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT );
2708   editor.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT );
2709
2710   // Avoid a crash when core load gl resources.
2711   application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
2712
2713   // Render and notify
2714   application.SendNotification();
2715   application.Render();
2716
2717   // Tap first to get the focus.
2718   TestGenerateTap( application, 3.0f, 25.0f, 100 );
2719
2720   // Render and notify
2721   application.SendNotification();
2722   application.Render();
2723
2724   // Tap to create the grab handle.
2725   TestGenerateTap( application, 3.0f, 25.0f, 700 );
2726
2727   // Render and notify
2728   application.SendNotification();
2729   application.Render();
2730
2731   // Get the active layer where the text's decoration is added.
2732   Actor activeLayer = editor.GetChildAt( 1u );
2733
2734   // Get the handle's actor.
2735   Actor handle = activeLayer.GetChildAt( 1u );
2736   handle.SetProperty( Actor::Property::SIZE, Vector2( 100.f, 100.f ) );
2737
2738   // Render and notify
2739   application.SendNotification();
2740   application.Render();
2741
2742   // Touch the grab handle to set it as pressed.
2743   Vector2 touchPos( 10.0f, 50.0f );
2744   Dali::Integration::TouchEvent event;
2745   event = Dali::Integration::TouchEvent();
2746   event.AddPoint( GetPointDownInside( touchPos ) );
2747   application.ProcessEvent( event );
2748
2749   // Render and notify
2750   application.SendNotification();
2751   application.Render();
2752
2753   // Pan the grab handle
2754   uint32_t time = 100;
2755   TestStartPan( application, Vector2(10.0f, 50.0f), Vector2(10.0f, 50.0f), time );
2756   TestMovePan( application, Vector2(10.0f, 30.0f), time );
2757   TestEndPan( application, Vector2(10.0f, 50.0f), time);
2758   application.SendNotification();
2759   application.Render();
2760
2761
2762   // Release the grab handle.
2763   event = Dali::Integration::TouchEvent();
2764   event.AddPoint( GetPointUpInside( touchPos ) );
2765   application.ProcessEvent( event );
2766
2767   // Render and notify
2768   application.SendNotification();
2769   application.Render();
2770
2771   // Tap first to get the focus.
2772   TestGenerateTap( application, 3.0f, 25.0f, 1400 );
2773
2774   // Render and notify
2775   application.SendNotification();
2776   application.Render();
2777
2778   // Double tap to select a word and create the selection handles.
2779   TestGenerateTap( application, 3.0f, 25.0f, 1500 );
2780
2781   // Render and notify
2782   application.SendNotification();
2783   application.Render();
2784
2785   touchPos = Vector2( 10.0f, 50.0f );
2786
2787   // Touch the left selection handle to set it as pressed.
2788   event = Dali::Integration::TouchEvent();
2789   event.AddPoint( GetPointDownInside( touchPos ) );
2790   application.ProcessEvent( event );
2791
2792   // Render and notify
2793   application.SendNotification();
2794   application.Render();
2795
2796   // Release the left selection handle.
2797   event = Dali::Integration::TouchEvent();
2798   event.AddPoint( GetPointUpInside( touchPos ) );
2799   application.ProcessEvent( event );
2800
2801   // Render and notify
2802   application.SendNotification();
2803   application.Render();
2804
2805   END_TEST;
2806 }
2807
2808 int utcDaliTextEditorUnderPropertyStringP(void)
2809 {
2810   ToolkitTestApplication application;
2811   tet_infoline(" utcDaliTextEditorUnderPropertyStringP");
2812   TextEditor editor = TextEditor::New();
2813   DALI_TEST_CHECK( editor );
2814
2815   std::string underlineSettings1( "{\"enable\":\"true\",\"color\":\"red\",\"height\":\"1\"}" );
2816
2817   application.GetScene().Add( editor );
2818
2819   editor.SetProperty( TextEditor::Property::UNDERLINE, underlineSettings1 );
2820   DALI_TEST_EQUALS( editor.GetProperty<std::string>( TextEditor::Property::UNDERLINE ), underlineSettings1, TEST_LOCATION );
2821
2822   tet_infoline("Set underline settings with a map");
2823   // Check the input underline property
2824   Property::Map underlineMapSet;
2825   Property::Map underlineMapGet;
2826   underlineMapSet.Insert( "enable", true );
2827   underlineMapSet.Insert( "color", Color::BLUE );
2828   underlineMapSet.Insert( "height", 2 );
2829
2830   editor.SetProperty( TextEditor::Property::UNDERLINE, underlineMapSet );
2831   underlineMapGet = editor.GetProperty<Property::Map>( TextEditor::Property::UNDERLINE );
2832   DALI_TEST_EQUALS( underlineMapGet.Count(), underlineMapSet.Count(), TEST_LOCATION );
2833   DALI_TEST_EQUALS( DaliTestCheckMaps( underlineMapSet, underlineMapGet ), true,  TEST_LOCATION );
2834
2835   tet_infoline("Set underline settings with a string");
2836   editor.SetProperty( TextEditor::Property::UNDERLINE, underlineSettings1 );
2837   Property::Value value = editor.GetProperty( TextEditor::Property::UNDERLINE );
2838   std::string result;
2839   value.Get(result);
2840   DALI_TEST_EQUALS( result , underlineSettings1, TEST_LOCATION  );
2841
2842   tet_infoline("Trying to set invalid underline settings, should not update and stay at previous settings");
2843   std::string underlineSettingsVoid( "{\"enable\":\"true\",\"coooolor\":\"blue\",\"heeeight\":\"4\"}" );
2844   editor.SetProperty( TextEditor::Property::UNDERLINE, underlineSettingsVoid );
2845   value = editor.GetProperty( TextEditor::Property::UNDERLINE );
2846   value.Get(result);
2847   DALI_TEST_EQUALS( result , underlineSettings1, TEST_LOCATION  );
2848
2849   END_TEST;
2850 }
2851
2852 int utcDaliTextEditorShadowPropertyStringP(void)
2853 {
2854   ToolkitTestApplication application;
2855   tet_infoline(" utcDaliTextEditorUnderPropertyStringP Setting Shadow propeties by string");
2856
2857   TextEditor editor = TextEditor::New();
2858
2859   std::string shadowSettings( "{\"color\":\"green\",\"offset\":\"2 2\",\"blurRadius\":\"0\"}" );
2860
2861   application.GetScene().Add( editor );
2862
2863   editor.SetProperty( TextEditor::Property::SHADOW, "{\"color\":\"green\",\"offset\":\"2 2\",\"blurRadius\":\"0\"}" );
2864
2865   Property::Value value = editor.GetProperty<std::string>( TextEditor::Property::SHADOW );
2866   std::string result;
2867   value.Get(result);
2868
2869   DALI_TEST_EQUALS( result, shadowSettings, TEST_LOCATION );
2870
2871   END_TEST;
2872 }
2873
2874 int utcDaliTextEditorFontStylePropertyStringP(void)
2875 {
2876   ToolkitTestApplication application;
2877   tet_infoline(" utcDaliTextEditorFontStylePropertyStringP Setting FontStyle propeties by string");
2878
2879   TextEditor editor = TextEditor::New();
2880
2881   std::string fontStyleSettings( "{\"weight\":\"bold\",\"width\":\"condensed\",\"slant\":\"italic\"}" );
2882
2883   application.GetScene().Add( editor );
2884
2885   editor.SetProperty( TextEditor::Property::FONT_STYLE, "{\"weight\":\"bold\",\"width\":\"condensed\",\"slant\":\"italic\"}" );
2886
2887   Property::Value value = editor.GetProperty<std::string>( TextEditor::Property::FONT_STYLE );
2888   std::string result;
2889   value.Get(result);
2890
2891   DALI_TEST_EQUALS( result, fontStyleSettings, TEST_LOCATION );
2892
2893   END_TEST;
2894 }
2895
2896 int utcDaliTextEditorGetPropertyLinecountP(void)
2897 {
2898   ToolkitTestApplication application;
2899
2900   tet_infoline(" utcDaliTextEditorGetPropertyLinecount getting line count property");
2901
2902   int lineCount =0 ;
2903
2904   TextEditor editor = TextEditor::New();
2905   editor.SetProperty( TextEditor::Property::POINT_SIZE, 10) ;
2906   editor.SetProperty( TextEditor::Property::TEXT,
2907                        "TEST TEST TEST TEST TEST TEST TEST TEST TEST TEST TEST TEST TEST TEST ");
2908
2909   application.GetScene().Add( editor );
2910
2911   editor.SetProperty( Actor::Property::SIZE, Vector2( 100.f, 100.f ) );
2912   lineCount =  editor.GetProperty<int>( TextEditor::Property::LINE_COUNT );
2913   DALI_TEST_EQUALS( lineCount, 14, TEST_LOCATION );
2914
2915   editor.SetProperty( Actor::Property::SIZE, Vector2( 50.f, 100.f ) );
2916   lineCount =  editor.GetProperty<int>( TextEditor::Property::LINE_COUNT );
2917   DALI_TEST_EQUALS( lineCount, 28, TEST_LOCATION );
2918
2919   END_TEST;
2920 }
2921
2922 int utcDaliTextEditorScrollStateChangedSignalTest(void)
2923 {
2924
2925   ToolkitTestApplication application;
2926   tet_infoline(" UtcDaliTextEditorScrollStateChangedSignalTest");
2927
2928   TextEditor editor = TextEditor::New();
2929   DALI_TEST_CHECK( editor );
2930
2931   application.GetScene().Add( editor );
2932
2933   editor.SetProperty( TextEditor::Property::POINT_SIZE, 10.f );
2934   editor.SetProperty( Actor::Property::SIZE, Vector2( 50.f, 50.f ) );
2935   editor.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT );
2936   editor.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT );
2937   editor.SetProperty( TextEditor::Property::ENABLE_SCROLL_BAR, true );
2938   editor.SetProperty( Actor::Property::KEYBOARD_FOCUSABLE,true);
2939
2940   bool startedCalled = false;
2941   bool finishedCalled = false;
2942
2943   ScrollStateChangeCallback callback( startedCalled, finishedCalled );
2944   editor.ScrollStateChangedSignal().Connect( &callback, &ScrollStateChangeCallback::Callback );
2945
2946   KeyboardFocusManager::Get().SetCurrentFocusActor( editor );
2947
2948   // Render and notify
2949   application.SendNotification();
2950   application.Render();
2951
2952   editor.SetProperty( TextEditor::Property::TEXT, "Long enough message for TextEditor!");
2953   application.SendNotification();
2954   application.Render(6000);
2955
2956   application.SendNotification();
2957   DALI_TEST_EQUALS( startedCalled, true, TEST_LOCATION );
2958   DALI_TEST_EQUALS( finishedCalled, true, TEST_LOCATION );
2959
2960   END_TEST;
2961 }
2962
2963 int UtcDaliToolkitTextEditorTextWrapMode(void)
2964 {
2965   ToolkitTestApplication application;
2966   tet_infoline(" UtcDaliToolkitTextEditorTextWarpMode");
2967
2968   int lineCount =0 ;
2969
2970   TextEditor editor = TextEditor::New();
2971   editor.SetProperty( Actor::Property::SIZE, Vector2( 150.0f, 300.f ) );
2972   editor.SetProperty( TextEditor::Property::TEXT, "Hello world Hello world" );
2973
2974   application.GetScene().Add( editor );
2975
2976   editor.SetProperty( TextEditor::Property::LINE_WRAP_MODE, "WORD" );
2977   DALI_TEST_EQUALS( editor.GetProperty< int >( TextEditor::Property::LINE_WRAP_MODE ), static_cast< int >( Text::LineWrap::WORD ), TEST_LOCATION );
2978
2979   application.SendNotification();
2980   application.Render();
2981
2982   lineCount =  editor.GetProperty<int>( TextEditor::Property::LINE_COUNT );
2983   DALI_TEST_EQUALS( lineCount, 4, TEST_LOCATION );
2984
2985   editor.SetProperty( TextEditor::Property::LINE_WRAP_MODE, "CHARACTER" );
2986   DALI_TEST_EQUALS( editor.GetProperty< int >( TextEditor::Property::LINE_WRAP_MODE ), static_cast< int >( Text::LineWrap::CHARACTER ), TEST_LOCATION );
2987
2988   application.SendNotification();
2989   application.Render();
2990
2991   lineCount =  editor.GetProperty<int>( TextEditor::Property::LINE_COUNT );
2992   DALI_TEST_EQUALS( lineCount, 3, TEST_LOCATION );
2993
2994   editor.SetProperty( TextEditor::Property::LINE_WRAP_MODE, Text::LineWrap::WORD );
2995   DALI_TEST_EQUALS( editor.GetProperty< int >( TextEditor::Property::LINE_WRAP_MODE ), static_cast< int >( Text::LineWrap::WORD ), TEST_LOCATION );
2996
2997   application.SendNotification();
2998   application.Render();
2999
3000   lineCount =  editor.GetProperty<int>( TextEditor::Property::LINE_COUNT );
3001   DALI_TEST_EQUALS( lineCount, 4, TEST_LOCATION );