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