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