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