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