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