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