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