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