Merge "propagate unhandled key( DALI_KEY_SEARCH )" into devel/master
[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   END_TEST;
976 }
977
978 // Positive Atlas Text Renderer test
979 int utcDaliTextFieldAtlasRenderP(void)
980 {
981   ToolkitTestApplication application;
982   tet_infoline(" UtcDaliToolkitTextFieldAtlasRenderP");
983   StyleManager styleManager = StyleManager::Get();
984   styleManager.ApplyDefaultTheme();
985   TextField field = TextField::New();
986   DALI_TEST_CHECK( field );
987
988   field.SetProperty( TextField::Property::HORIZONTAL_ALIGNMENT, "CENTER" );
989
990   application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
991
992   Stage::GetCurrent().Add( field );
993
994   try
995   {
996     // Render some text with the shared atlas backend
997     field.SetProperty( TextField::Property::RENDERING_BACKEND, Text::RENDERING_SHARED_ATLAS );
998     application.SendNotification();
999     application.Render();
1000   }
1001   catch( ... )
1002   {
1003     tet_result(TET_FAIL);
1004   }
1005   END_TEST;
1006 }
1007
1008 // Positive test for the textChanged signal.
1009 int utcDaliTextFieldTextChangedP(void)
1010 {
1011   ToolkitTestApplication application;
1012   tet_infoline(" utcDaliTextFieldTextChangedP");
1013   TextField field = TextField::New();
1014   DALI_TEST_CHECK( field );
1015
1016   Stage::GetCurrent().Add( field );
1017
1018   // connect to the text changed signal.
1019   ConnectionTracker* testTracker = new ConnectionTracker();
1020   field.TextChangedSignal().Connect(&TestTextChangedCallback);
1021   bool textChangedSignal = false;
1022   field.ConnectSignal( testTracker, "textChanged",   CallbackFunctor(&textChangedSignal) );
1023
1024   gTextChangedCallBackCalled = false;
1025   field.SetProperty( TextField::Property::TEXT, "ABC" );
1026   DALI_TEST_CHECK( gTextChangedCallBackCalled );
1027   DALI_TEST_CHECK( textChangedSignal );
1028
1029   application.SendNotification();
1030
1031   field.SetKeyInputFocus();
1032
1033   gTextChangedCallBackCalled = false;
1034   application.ProcessEvent( GenerateKey( "D", "D", KEY_D_CODE, 0, 0, Integration::KeyEvent::Down, DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
1035   DALI_TEST_CHECK( gTextChangedCallBackCalled );
1036
1037   END_TEST;
1038 }
1039
1040 // Negative test for the textChanged signal.
1041 int utcDaliTextFieldTextChangedN(void)
1042 {
1043   ToolkitTestApplication application;
1044   tet_infoline(" utcDaliTextFieldTextChangedN");
1045   TextField field = TextField::New();
1046   DALI_TEST_CHECK( field );
1047
1048   Stage::GetCurrent().Add( field );
1049
1050   // connect to the text changed signal.
1051   ConnectionTracker* testTracker = new ConnectionTracker();
1052   field.TextChangedSignal().Connect(&TestTextChangedCallback);
1053   bool textChangedSignal = false;
1054   field.ConnectSignal( testTracker, "textChanged",   CallbackFunctor(&textChangedSignal) );
1055
1056   gTextChangedCallBackCalled = false;
1057   field.SetProperty( TextField::Property::PLACEHOLDER_TEXT, "ABC" ); // Setting placeholder, not TEXT
1058   DALI_TEST_CHECK( !gTextChangedCallBackCalled );
1059   DALI_TEST_CHECK( !textChangedSignal );
1060
1061   END_TEST;
1062 }
1063
1064 // Positive test for Max Characters reached signal.
1065 int utcDaliTextFieldMaxCharactersReachedP(void)
1066 {
1067   ToolkitTestApplication application;
1068   tet_infoline(" utcDaliTextFieldMaxCharactersReachedP");
1069   TextField field = TextField::New();
1070   DALI_TEST_CHECK( field );
1071
1072   Stage::GetCurrent().Add( field );
1073
1074   const int maxNumberOfCharacters = 1;
1075   field.SetProperty( TextField::Property::MAX_LENGTH, maxNumberOfCharacters );
1076
1077   field.SetKeyInputFocus();
1078
1079   // connect to the text changed signal.
1080   ConnectionTracker* testTracker = new ConnectionTracker();
1081   field.MaxLengthReachedSignal().Connect(&TestMaxLengthReachedCallback);
1082   bool maxLengthReachedSignal = false;
1083   field.ConnectSignal( testTracker, "maxLengthReached",   CallbackFunctor(&maxLengthReachedSignal) );
1084
1085   gMaxCharactersCallBackCalled = false;
1086
1087   application.ProcessEvent( GenerateKey( "a", "a", KEY_A_CODE, 0, 0, Integration::KeyEvent::Down, DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
1088   application.ProcessEvent( GenerateKey( "a", "a", KEY_A_CODE, 0, 0, Integration::KeyEvent::Down, DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
1089
1090   DALI_TEST_CHECK( gMaxCharactersCallBackCalled );
1091   DALI_TEST_CHECK( maxLengthReachedSignal );
1092
1093   END_TEST;
1094 }
1095
1096 // Negative test for Max Characters reached signal.
1097 int utcDaliTextFieldMaxCharactersReachedN(void)
1098 {
1099   ToolkitTestApplication application;
1100   tet_infoline(" utcDaliTextFieldMaxCharactersReachedN");
1101   TextField field = TextField::New();
1102   DALI_TEST_CHECK( field );
1103
1104   Stage::GetCurrent().Add( field );
1105
1106   const int maxNumberOfCharacters = 3;
1107   field.SetProperty( TextField::Property::MAX_LENGTH, maxNumberOfCharacters );
1108
1109   field.SetKeyInputFocus();
1110
1111   // connect to the text changed signal.
1112   ConnectionTracker* testTracker = new ConnectionTracker();
1113   field.MaxLengthReachedSignal().Connect(&TestMaxLengthReachedCallback);
1114   bool maxLengthReachedSignal = false;
1115   field.ConnectSignal( testTracker, "maxLengthReached",   CallbackFunctor(&maxLengthReachedSignal) );
1116
1117   gMaxCharactersCallBackCalled = false;
1118
1119   application.ProcessEvent( GenerateKey( "a", "a", KEY_A_CODE, 0, 0, Integration::KeyEvent::Down, DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
1120   application.ProcessEvent( GenerateKey( "a", "a", KEY_A_CODE, 0, 0, Integration::KeyEvent::Down, DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
1121
1122   DALI_TEST_CHECK( !gMaxCharactersCallBackCalled );
1123   DALI_TEST_CHECK( !maxLengthReachedSignal );
1124
1125   END_TEST;
1126 }
1127
1128 int utcDaliTextFieldInputStyleChanged01(void)
1129 {
1130   ToolkitTestApplication application;
1131   tet_infoline(" utcDaliTextFieldInputStyleChanged01");
1132
1133   // The text-field emits signals when the input style changes. These changes of style are
1134   // detected during the relayout process (size negotiation), i.e after the cursor has been moved. Signals
1135   // can't be emitted during the size negotiation as the callbacks may update the UI.
1136   // The text-field adds an idle callback to the adaptor to emit the signals after the size negotiation.
1137   // This creates an implementation of the adaptor stub and a queue of idle callbacks.
1138   application.CreateAdaptor();
1139
1140   // Load some fonts.
1141
1142   char* pathNamePtr = get_current_dir_name();
1143   const std::string pathName( pathNamePtr );
1144   free( pathNamePtr );
1145
1146   TextAbstraction::FontClient fontClient = TextAbstraction::FontClient::Get();
1147   fontClient.SetDpi( 93u, 93u );
1148
1149   fontClient.GetFontId( pathName + DEFAULT_FONT_DIR + "/dejavu/DejaVuSerif.ttf", DEFAULT_FONT_SIZE );
1150   fontClient.GetFontId( pathName + DEFAULT_FONT_DIR + "/dejavu/DejaVuSerif-Bold.ttf", DEFAULT_FONT_SIZE );
1151
1152   TextField field = TextField::New();
1153   DALI_TEST_CHECK( field );
1154
1155
1156   field.SetSize( 300.f, 50.f );
1157   field.SetParentOrigin( ParentOrigin::TOP_LEFT );
1158   field.SetAnchorPoint( AnchorPoint::TOP_LEFT );
1159
1160   field.SetProperty( TextField::Property::ENABLE_MARKUP, true );
1161   field.SetProperty( TextField::Property::TEXT, "<font family='DejaVuSerif' size='18'>He<color value='green'>llo</color> <font weight='bold'>world</font> demo</font>" );
1162
1163   // connect to the text changed signal.
1164   ConnectionTracker* testTracker = new ConnectionTracker();
1165   field.InputStyleChangedSignal().Connect( &TestInputStyleChangedCallback );
1166   bool inputStyleChangedSignal = false;
1167   field.ConnectSignal( testTracker, "inputStyleChanged",   CallbackFunctor(&inputStyleChangedSignal) );
1168
1169   Stage::GetCurrent().Add( field );
1170
1171   // Render and notify
1172   application.SendNotification();
1173   application.Render();
1174
1175   // Executes the idle callbacks added by the text control on the change of input style.
1176   application.RunIdles();
1177
1178   gInputStyleChangedCallbackCalled = false;
1179   gInputStyleMask = TextField::InputStyle::NONE;
1180   inputStyleChangedSignal = false;
1181
1182   // Create a tap event to touch the text field.
1183   application.ProcessEvent( GenerateTap( Gesture::Possible, 1u, 1u, Vector2( 18.f, 25.f ) ) );
1184   application.ProcessEvent( GenerateTap( Gesture::Started, 1u, 1u, Vector2( 18.f, 25.f ) ) );
1185
1186   // Render and notify
1187   application.SendNotification();
1188   application.Render();
1189
1190   // Executes the idle callbacks added by the text control on the change of input style.
1191   application.RunIdles();
1192
1193   DALI_TEST_CHECK( gInputStyleChangedCallbackCalled );
1194   if( gInputStyleChangedCallbackCalled )
1195   {
1196     DALI_TEST_EQUALS( static_cast<unsigned int>( gInputStyleMask ), static_cast<unsigned int>( TextField::InputStyle::FONT_FAMILY | TextField::InputStyle::POINT_SIZE ), TEST_LOCATION );
1197
1198     const std::string fontFamily = field.GetProperty( TextField::Property::INPUT_FONT_FAMILY ).Get<std::string>();
1199     DALI_TEST_EQUALS( fontFamily, "DejaVuSerif", TEST_LOCATION );
1200
1201     const float pointSize = field.GetProperty( TextField::Property::INPUT_POINT_SIZE ).Get<float>();
1202     DALI_TEST_EQUALS( pointSize, 18.f, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
1203   }
1204   DALI_TEST_CHECK( inputStyleChangedSignal );
1205
1206   gInputStyleChangedCallbackCalled = false;
1207   gInputStyleMask = TextField::InputStyle::NONE;
1208   inputStyleChangedSignal = false;
1209
1210   // Create a tap event to touch the text field.
1211   application.ProcessEvent( GenerateTap( Gesture::Possible, 1u, 1u, Vector2( 30.f, 25.f ) ) );
1212   application.ProcessEvent( GenerateTap( Gesture::Started, 1u, 1u, Vector2( 30.f, 25.f ) ) );
1213
1214   // Render and notify
1215   application.SendNotification();
1216   application.Render();
1217
1218   // Executes the idle callbacks added by the text control on the change of input style.
1219   application.RunIdles();
1220
1221   DALI_TEST_CHECK( !gInputStyleChangedCallbackCalled );
1222   DALI_TEST_CHECK( !inputStyleChangedSignal );
1223
1224   gInputStyleChangedCallbackCalled = false;
1225   gInputStyleMask = TextField::InputStyle::NONE;
1226   inputStyleChangedSignal = false;
1227
1228   // Create a tap event to touch the text field.
1229   application.ProcessEvent( GenerateTap( Gesture::Possible, 1u, 1u, Vector2( 43.f, 25.f ) ) );
1230   application.ProcessEvent( GenerateTap( Gesture::Started, 1u, 1u, Vector2( 43.f, 25.f ) ) );
1231
1232   // Render and notify
1233   application.SendNotification();
1234   application.Render();
1235
1236   // Executes the idle callbacks added by the text control on the change of input style.
1237   application.RunIdles();
1238
1239   DALI_TEST_CHECK( gInputStyleChangedCallbackCalled );
1240   if( gInputStyleChangedCallbackCalled )
1241   {
1242     DALI_TEST_EQUALS( static_cast<unsigned int>( gInputStyleMask ), static_cast<unsigned int>( TextField::InputStyle::COLOR ), TEST_LOCATION );
1243
1244     const Vector4 color = field.GetProperty( TextField::Property::INPUT_COLOR ).Get<Vector4>();
1245     DALI_TEST_EQUALS( color, Color::GREEN, TEST_LOCATION );
1246   }
1247   DALI_TEST_CHECK( inputStyleChangedSignal );
1248
1249   gInputStyleChangedCallbackCalled = false;
1250   gInputStyleMask = TextField::InputStyle::NONE;
1251   inputStyleChangedSignal = false;
1252
1253   // Create a tap event to touch the text field.
1254   application.ProcessEvent( GenerateTap( Gesture::Possible, 1u, 1u, Vector2( 88.f, 25.f ) ) );
1255   application.ProcessEvent( GenerateTap( Gesture::Started, 1u, 1u, Vector2( 88.f, 25.f ) ) );
1256
1257   // Render and notify
1258   application.SendNotification();
1259   application.Render();
1260
1261   // Executes the idle callbacks added by the text control on the change of input style.
1262   application.RunIdles();
1263
1264   DALI_TEST_CHECK( gInputStyleChangedCallbackCalled );
1265   if( gInputStyleChangedCallbackCalled )
1266   {
1267     DALI_TEST_EQUALS( static_cast<unsigned int>( gInputStyleMask ), static_cast<unsigned int>( TextField::InputStyle::COLOR | TextField::InputStyle::FONT_STYLE ), TEST_LOCATION );
1268
1269     const Vector4 color = field.GetProperty( TextField::Property::INPUT_COLOR ).Get<Vector4>();
1270     DALI_TEST_EQUALS( color, Color::BLACK, TEST_LOCATION );
1271
1272     const Property::Map fontStyleMapGet = field.GetProperty( TextField::Property::INPUT_FONT_STYLE ).Get<Property::Map>();
1273
1274     Property::Map fontStyleMapSet;
1275     fontStyleMapSet.Insert( "weight", "bold" );
1276
1277     DALI_TEST_EQUALS( fontStyleMapGet.Count(), fontStyleMapSet.Count(), TEST_LOCATION );
1278     DALI_TEST_EQUALS( DaliTestCheckMaps( fontStyleMapGet, fontStyleMapSet ), true, TEST_LOCATION );
1279   }
1280   DALI_TEST_CHECK( inputStyleChangedSignal );
1281
1282   gInputStyleChangedCallbackCalled = false;
1283   gInputStyleMask = TextField::InputStyle::NONE;
1284   inputStyleChangedSignal = false;
1285
1286   // Create a tap event to touch the text field.
1287   application.ProcessEvent( GenerateTap( Gesture::Possible, 1u, 1u, Vector2( 115.f, 25.f ) ) );
1288   application.ProcessEvent( GenerateTap( Gesture::Started, 1u, 1u, Vector2( 115.f, 25.f ) ) );
1289
1290   // Render and notify
1291   application.SendNotification();
1292   application.Render();
1293
1294   // Executes the idle callbacks added by the text control on the change of input style.
1295   application.RunIdles();
1296
1297   DALI_TEST_CHECK( !gInputStyleChangedCallbackCalled );
1298   DALI_TEST_CHECK( !inputStyleChangedSignal );
1299
1300   gInputStyleChangedCallbackCalled = false;
1301   gInputStyleMask = TextField::InputStyle::NONE;
1302   inputStyleChangedSignal = false;
1303
1304   // Create a tap event to touch the text field.
1305   application.ProcessEvent( GenerateTap( Gesture::Possible, 1u, 1u, Vector2( 164.f, 25.f ) ) );
1306   application.ProcessEvent( GenerateTap( Gesture::Started, 1u, 1u, Vector2( 164.f, 25.f ) ) );
1307
1308   // Render and notify
1309   application.SendNotification();
1310   application.Render();
1311
1312   // Executes the idle callbacks added by the text control on the change of input style.
1313   application.RunIdles();
1314
1315   DALI_TEST_CHECK( gInputStyleChangedCallbackCalled );
1316   if( gInputStyleChangedCallbackCalled )
1317   {
1318     DALI_TEST_EQUALS( static_cast<unsigned int>( gInputStyleMask ), static_cast<unsigned int>( TextField::InputStyle::FONT_STYLE ), TEST_LOCATION );
1319
1320     const std::string style = field.GetProperty( TextField::Property::INPUT_FONT_STYLE ).Get<std::string>();
1321     DALI_TEST_CHECK( style.empty() );
1322   }
1323   DALI_TEST_CHECK( inputStyleChangedSignal );
1324
1325   gInputStyleChangedCallbackCalled = false;
1326   gInputStyleMask = TextField::InputStyle::NONE;
1327   inputStyleChangedSignal = false;
1328
1329   // Create a tap event to touch the text field.
1330   application.ProcessEvent( GenerateTap( Gesture::Possible, 1u, 1u, Vector2( 191.f, 25.f ) ) );
1331   application.ProcessEvent( GenerateTap( Gesture::Started, 1u, 1u, Vector2( 191.f, 25.f ) ) );
1332
1333   // Render and notify
1334   application.SendNotification();
1335   application.Render();
1336
1337   // Executes the idle callbacks added by the text control on the change of input style.
1338   application.RunIdles();
1339
1340   DALI_TEST_CHECK( !gInputStyleChangedCallbackCalled );
1341   DALI_TEST_CHECK( !inputStyleChangedSignal );
1342
1343   END_TEST;
1344 }
1345
1346 int utcDaliTextFieldInputStyleChanged02(void)
1347 {
1348   ToolkitTestApplication application;
1349   tet_infoline(" utcDaliTextFieldInputStyleChanged02");
1350
1351   // The text-field emits signals when the input style changes. These changes of style are
1352   // detected during the relayout process (size negotiation), i.e after the cursor has been moved. Signals
1353   // can't be emitted during the size negotiation as the callbacks may update the UI.
1354   // The text-field adds an idle callback to the adaptor to emit the signals after the size negotiation.
1355   // This creates an implementation of the adaptor stub and a queue of idle callbacks.
1356   application.CreateAdaptor();
1357
1358   // Load some fonts.
1359
1360   char* pathNamePtr = get_current_dir_name();
1361   const std::string pathName( pathNamePtr );
1362   free( pathNamePtr );
1363
1364   TextAbstraction::FontClient fontClient = TextAbstraction::FontClient::Get();
1365   fontClient.SetDpi( 93u, 93u );
1366
1367   fontClient.GetFontId( pathName + DEFAULT_FONT_DIR + "/dejavu/DejaVuSerif.ttf", DEFAULT_FONT_SIZE );
1368   fontClient.GetFontId( pathName + DEFAULT_FONT_DIR + "/dejavu/DejaVuSerif-Bold.ttf", DEFAULT_FONT_SIZE );
1369
1370   TextField field = TextField::New();
1371   DALI_TEST_CHECK( field );
1372
1373
1374   field.SetSize( 300.f, 50.f );
1375   field.SetParentOrigin( ParentOrigin::TOP_LEFT );
1376   field.SetAnchorPoint( AnchorPoint::TOP_LEFT );
1377
1378   field.SetProperty( TextField::Property::ENABLE_MARKUP, true );
1379   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>" );
1380
1381   // connect to the text changed signal.
1382   ConnectionTracker* testTracker = new ConnectionTracker();
1383   field.InputStyleChangedSignal().Connect( &TestInputStyleChangedCallback );
1384   bool inputStyleChangedSignal = false;
1385   field.ConnectSignal( testTracker, "inputStyleChanged",   CallbackFunctor(&inputStyleChangedSignal) );
1386
1387   Stage::GetCurrent().Add( field );
1388
1389   // Render and notify
1390   application.SendNotification();
1391   application.Render();
1392
1393   // Executes the idle callbacks added by the text control on the change of input style.
1394   application.RunIdles();
1395
1396   gInputStyleChangedCallbackCalled = false;
1397   gInputStyleMask = TextField::InputStyle::NONE;
1398   inputStyleChangedSignal = false;
1399
1400   // Create a tap event to touch the text field.
1401   application.ProcessEvent( GenerateTap( Gesture::Possible, 1u, 1u, Vector2( 53.f, 25.f ) ) );
1402   application.ProcessEvent( GenerateTap( Gesture::Started, 1u, 1u, Vector2( 53.f, 25.f ) ) );
1403   application.ProcessEvent( GenerateTap( Gesture::Possible, 2u, 1u, Vector2( 53.f, 25.f ) ) );
1404   application.ProcessEvent( GenerateTap( Gesture::Started, 2u, 1u, Vector2( 53.f, 25.f ) ) );
1405
1406   // Render and notify
1407   application.SendNotification();
1408   application.Render();
1409
1410   // Executes the idle callbacks added by the text control on the change of input style.
1411   application.RunIdles();
1412
1413   DALI_TEST_CHECK( gInputStyleChangedCallbackCalled );
1414   if( gInputStyleChangedCallbackCalled )
1415   {
1416     DALI_TEST_EQUALS( static_cast<unsigned int>( gInputStyleMask ),
1417                       static_cast<unsigned int>( TextField::InputStyle::FONT_FAMILY |
1418                                                  TextField::InputStyle::POINT_SIZE  |
1419                                                  TextField::InputStyle::COLOR ),
1420                       TEST_LOCATION );
1421
1422     const Vector4 color = field.GetProperty( TextField::Property::INPUT_COLOR ).Get<Vector4>();
1423     DALI_TEST_EQUALS( color, Color::GREEN, TEST_LOCATION );
1424
1425     const std::string fontFamily = field.GetProperty( TextField::Property::INPUT_FONT_FAMILY ).Get<std::string>();
1426     DALI_TEST_EQUALS( fontFamily, "DejaVuSerif", TEST_LOCATION );
1427
1428     const float pointSize = field.GetProperty( TextField::Property::INPUT_POINT_SIZE ).Get<float>();
1429     DALI_TEST_EQUALS( pointSize, 18.f, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
1430   }
1431   DALI_TEST_CHECK( inputStyleChangedSignal );
1432
1433   gInputStyleChangedCallbackCalled = false;
1434   gInputStyleMask = TextField::InputStyle::NONE;
1435   inputStyleChangedSignal = false;
1436
1437   application.ProcessEvent( GenerateKey( "", "", DALI_KEY_BACKSPACE, 0, 0, Integration::KeyEvent::Down, DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
1438
1439   // Render and notify
1440   application.SendNotification();
1441   application.Render();
1442
1443   // Executes the idle callbacks added by the text control on the change of input style.
1444   application.RunIdles();
1445
1446   DALI_TEST_CHECK( gInputStyleChangedCallbackCalled );
1447   if( gInputStyleChangedCallbackCalled )
1448   {
1449     DALI_TEST_EQUALS( static_cast<unsigned int>( gInputStyleMask ),
1450                       static_cast<unsigned int>( TextField::InputStyle::COLOR ),
1451                       TEST_LOCATION );
1452
1453     const Vector4 color = field.GetProperty( TextField::Property::INPUT_COLOR ).Get<Vector4>();
1454     DALI_TEST_EQUALS( color, Color::BLUE, TEST_LOCATION );
1455   }
1456   DALI_TEST_CHECK( inputStyleChangedSignal );
1457
1458   gInputStyleChangedCallbackCalled = false;
1459   gInputStyleMask = TextField::InputStyle::NONE;
1460   inputStyleChangedSignal = false;
1461
1462   application.ProcessEvent( GenerateKey( "", "", DALI_KEY_BACKSPACE, 0, 0, Integration::KeyEvent::Down, DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
1463
1464   // Render and notify
1465   application.SendNotification();
1466   application.Render();
1467
1468   // Executes the idle callbacks added by the text control on the change of input style.
1469   application.RunIdles();
1470
1471   DALI_TEST_CHECK( !gInputStyleChangedCallbackCalled );
1472   DALI_TEST_CHECK( !inputStyleChangedSignal );
1473
1474   gInputStyleChangedCallbackCalled = false;
1475   gInputStyleMask = TextField::InputStyle::NONE;
1476   inputStyleChangedSignal = false;
1477
1478   application.ProcessEvent( GenerateKey( "", "", DALI_KEY_BACKSPACE, 0, 0, Integration::KeyEvent::Down, DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
1479
1480   // Render and notify
1481   application.SendNotification();
1482   application.Render();
1483
1484   // Executes the idle callbacks added by the text control on the change of input style.
1485   application.RunIdles();
1486
1487   DALI_TEST_CHECK( gInputStyleChangedCallbackCalled );
1488   if( gInputStyleChangedCallbackCalled )
1489   {
1490     DALI_TEST_EQUALS( static_cast<unsigned int>( gInputStyleMask ),
1491                       static_cast<unsigned int>( TextField::InputStyle::COLOR ),
1492                       TEST_LOCATION );
1493
1494     const Vector4 color = field.GetProperty( TextField::Property::INPUT_COLOR ).Get<Vector4>();
1495     DALI_TEST_EQUALS( color, Color::BLACK, TEST_LOCATION );
1496   }
1497   DALI_TEST_CHECK( inputStyleChangedSignal );
1498
1499   gInputStyleChangedCallbackCalled = false;
1500   gInputStyleMask = TextField::InputStyle::NONE;
1501   inputStyleChangedSignal = false;
1502
1503   field.SetProperty( TextField::Property::INPUT_COLOR, Color::YELLOW );
1504
1505   Property::Map fontStyleMapSet;
1506   fontStyleMapSet.Insert( "weight", "thin" );
1507   fontStyleMapSet.Insert( "width", "condensed" );
1508   fontStyleMapSet.Insert( "slant", "italic" );
1509
1510   field.SetProperty( TextField::Property::INPUT_FONT_STYLE, fontStyleMapSet );
1511   field.SetProperty( TextField::Property::INPUT_POINT_SIZE, 20.f );
1512
1513   field.SetProperty( TextField::Property::INPUT_UNDERLINE, "underline" );
1514   field.SetProperty( TextField::Property::INPUT_SHADOW, "shadow" );
1515   field.SetProperty( TextField::Property::INPUT_EMBOSS, "emboss" );
1516   field.SetProperty( TextField::Property::INPUT_OUTLINE, "outline" );
1517
1518   // Render and notify
1519   application.SendNotification();
1520   application.Render();
1521
1522   // Executes the idle callbacks added by the text control on the change of input style.
1523   application.RunIdles();
1524
1525   DALI_TEST_CHECK( !gInputStyleChangedCallbackCalled );
1526   DALI_TEST_CHECK( !inputStyleChangedSignal );
1527
1528   // Create a tap event to touch the text field.
1529   application.ProcessEvent( GenerateTap( Gesture::Possible, 1u, 1u, Vector2( 63.f, 25.f ) ) );
1530   application.ProcessEvent( GenerateTap( Gesture::Started, 1u, 1u, Vector2( 63.f, 25.f ) ) );
1531
1532   // Render and notify
1533   application.SendNotification();
1534   application.Render();
1535
1536   // Executes the idle callbacks added by the text control on the change of input style.
1537   application.RunIdles();
1538
1539   DALI_TEST_CHECK( gInputStyleChangedCallbackCalled );
1540   if( gInputStyleChangedCallbackCalled )
1541   {
1542     DALI_TEST_EQUALS( static_cast<unsigned int>( gInputStyleMask ),
1543                       static_cast<unsigned int>( TextField::InputStyle::COLOR |
1544                                                  TextField::InputStyle::POINT_SIZE |
1545                                                  TextField::InputStyle::FONT_STYLE |
1546                                                  TextField::InputStyle::UNDERLINE |
1547                                                  TextField::InputStyle::SHADOW |
1548                                                  TextField::InputStyle::EMBOSS |
1549                                                  TextField::InputStyle::OUTLINE ),
1550                       TEST_LOCATION );
1551
1552     const Vector4 color = field.GetProperty( TextField::Property::INPUT_COLOR ).Get<Vector4>();
1553     DALI_TEST_EQUALS( color, Color::BLACK, TEST_LOCATION );
1554   }
1555   DALI_TEST_CHECK( inputStyleChangedSignal );
1556
1557   END_TEST;
1558 }
1559
1560 int utcDaliTextFieldEvent01(void)
1561 {
1562   ToolkitTestApplication application;
1563   tet_infoline(" utcDaliTextFieldEvent01");
1564
1565   // Creates a tap event. After creating a tap event the text field should
1566   // have the focus and add text with key events should be possible.
1567
1568   TextField field = TextField::New();
1569   DALI_TEST_CHECK( field );
1570
1571   Stage::GetCurrent().Add( field );
1572
1573   field.SetSize( 300.f, 50.f );
1574   field.SetParentOrigin( ParentOrigin::TOP_LEFT );
1575   field.SetAnchorPoint( AnchorPoint::TOP_LEFT );
1576
1577   // Avoid a crash when core load gl resources.
1578   application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
1579
1580   // Render and notify
1581   application.SendNotification();
1582   application.Render();
1583
1584   // Add a key event but as the text field has not the focus it should do nothing.
1585   application.ProcessEvent( GenerateKey( "a", "a", KEY_A_CODE, 0, 0, Integration::KeyEvent::Down, DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
1586
1587   // Render and notify
1588   application.SendNotification();
1589   application.Render();
1590
1591   DALI_TEST_EQUALS( field.GetProperty<std::string>( TextField::Property::TEXT ), std::string(""), TEST_LOCATION );
1592
1593   // Create a tap event to touch the text field.
1594   application.ProcessEvent( GenerateTap( Gesture::Possible, 1u, 1u, Vector2( 150.0f, 25.0f ) ) );
1595   application.ProcessEvent( GenerateTap( Gesture::Started, 1u, 1u, Vector2( 150.0f, 25.0f ) ) );
1596
1597   // Render and notify
1598   application.SendNotification();
1599   application.Render();
1600
1601   // Now the text field has the focus, so it can handle the key events.
1602   application.ProcessEvent( GenerateKey( "a", "a", KEY_A_CODE, 0, 0, Integration::KeyEvent::Down, DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
1603   application.ProcessEvent( GenerateKey( "a", "a", KEY_A_CODE, 0, 0, Integration::KeyEvent::Down, DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
1604
1605   // Render and notify
1606   application.SendNotification();
1607   application.Render();
1608
1609   DALI_TEST_EQUALS( field.GetProperty<std::string>( TextField::Property::TEXT ), std::string("aa"), TEST_LOCATION );
1610
1611   // Create a second text field and send key events to it.
1612   TextField field2 = TextField::New();
1613
1614   field2.SetParentOrigin( ParentOrigin::TOP_LEFT );
1615   field2.SetAnchorPoint( AnchorPoint::TOP_LEFT );
1616   field2.SetSize( 100.f, 100.f );
1617   field2.SetPosition( 100.f, 100.f );
1618
1619   Stage::GetCurrent().Add( field2 );
1620
1621   // Render and notify
1622   application.SendNotification();
1623   application.Render();
1624
1625   // Create a tap event on the second text field.
1626   application.ProcessEvent( GenerateTap( Gesture::Possible, 1u, 1u, Vector2( 150.0f, 125.0f ) ) );
1627   application.ProcessEvent( GenerateTap( Gesture::Started, 1u, 1u, Vector2( 150.0f, 125.0f ) ) );
1628
1629   // Render and notify
1630   application.SendNotification();
1631   application.Render();
1632
1633   // The second text field has the focus. It should handle the key events.
1634   application.ProcessEvent( GenerateKey( "a", "a", KEY_A_CODE, 0, 0, Integration::KeyEvent::Down, DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
1635   application.ProcessEvent( GenerateKey( "a", "a", KEY_A_CODE, 0, 0, Integration::KeyEvent::Down, DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
1636
1637   // Render and notify
1638   application.SendNotification();
1639   application.Render();
1640
1641   // Check the text has been added to the second text field.
1642   DALI_TEST_EQUALS( field2.GetProperty<std::string>( TextField::Property::TEXT ), std::string("aa"), TEST_LOCATION );
1643
1644   END_TEST;
1645 }
1646
1647 int utcDaliTextFieldEvent02(void)
1648 {
1649   ToolkitTestApplication application;
1650   tet_infoline(" utcDaliTextFieldEvent02");
1651
1652   // Checks if the right number of actors are created.
1653
1654   TextField field = TextField::New();
1655   field.SetProperty( TextField::Property::POINT_SIZE, 10.f );
1656   DALI_TEST_CHECK( field );
1657   LoadMarkerImages(application, field);
1658
1659   Stage::GetCurrent().Add( field );
1660
1661   field.SetSize( 300.f, 50.f );
1662   field.SetParentOrigin( ParentOrigin::TOP_LEFT );
1663   field.SetAnchorPoint( AnchorPoint::TOP_LEFT );
1664
1665   // Avoid a crash when core load gl resources.
1666   application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
1667
1668   // Render and notify
1669   application.SendNotification();
1670   application.Render();
1671
1672   // Check there are the expected number of children ( stencil ).
1673   DALI_TEST_EQUALS( field.GetChildCount(), 1u, TEST_LOCATION );
1674
1675   Actor stencil = field.GetChildAt( 0u );
1676   DALI_TEST_EQUALS( stencil.GetChildCount(), 0u, TEST_LOCATION );
1677
1678   // Create a tap event to touch the text field.
1679   application.ProcessEvent( GenerateTap( Gesture::Possible, 1u, 1u, Vector2( 150.0f, 25.0f ) ) );
1680   application.ProcessEvent( GenerateTap( Gesture::Started, 1u, 1u, Vector2( 150.0f, 25.0f ) ) );
1681
1682   // Render and notify
1683   application.SendNotification();
1684   application.Render();
1685
1686   Actor layer = field.GetChildAt( 1u );
1687   DALI_TEST_CHECK( layer.IsLayer() );
1688
1689   DALI_TEST_EQUALS( layer.GetChildCount(), 1u, TEST_LOCATION ); // The cursor.
1690   DALI_TEST_EQUALS( stencil.GetChildCount(), 0u, TEST_LOCATION );
1691
1692   // Now the text field has the focus, so it can handle the key events.
1693   application.ProcessEvent( GenerateKey( "a", "a", KEY_A_CODE, 0, 0, Integration::KeyEvent::Down, DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
1694   application.ProcessEvent( GenerateKey( "a", "a", KEY_A_CODE, 0, 0, Integration::KeyEvent::Down, DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
1695
1696   // Render and notify
1697   application.SendNotification();
1698   application.Render();
1699
1700   // Checks the cursor and the renderer have been created.
1701   DALI_TEST_EQUALS( layer.GetChildCount(), 1u, TEST_LOCATION ); // The cursor.
1702   DALI_TEST_EQUALS( stencil.GetChildCount(), 1u, TEST_LOCATION ); // The renderer
1703
1704   Control cursor = Control::DownCast( layer.GetChildAt( 0u ) );
1705   DALI_TEST_CHECK( cursor );
1706
1707   // The offscreen root actor has a container with all the actors which contain the text renderers.
1708   Actor container = stencil.GetChildAt( 0u );
1709   for( unsigned int index = 0; index < container.GetChildCount(); ++index )
1710   {
1711     Renderer renderer = container.GetChildAt( index ).GetRendererAt( 0u );
1712     DALI_TEST_CHECK( renderer );
1713   }
1714
1715   // Move the cursor and check the position changes.
1716   Vector3 position1 = cursor.GetCurrentPosition();
1717
1718   application.ProcessEvent( GenerateKey( "", "", DALI_KEY_CURSOR_LEFT, 0, 0, Integration::KeyEvent::Down, DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
1719   application.ProcessEvent( GenerateKey( "", "", DALI_KEY_CURSOR_LEFT, 0, 0, Integration::KeyEvent::Down, DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
1720
1721   // Render and notify
1722   application.SendNotification();
1723   application.Render();
1724
1725   Vector3 position2 = cursor.GetCurrentPosition();
1726
1727   DALI_TEST_CHECK( position2.x < position1.x );
1728
1729   application.ProcessEvent( GenerateKey( "", "", DALI_KEY_CURSOR_RIGHT, 0, 0, Integration::KeyEvent::Down, DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
1730   application.ProcessEvent( GenerateKey( "", "", DALI_KEY_CURSOR_RIGHT, 0, 0, Integration::KeyEvent::Down, DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
1731
1732   // Render and notify
1733   application.SendNotification();
1734   application.Render();
1735
1736   Vector3 position3 = cursor.GetCurrentPosition();
1737
1738   DALI_TEST_EQUALS( position1, position3, TEST_LOCATION ); // Should be in the same position1.
1739
1740   // Send some taps and check the cursor positions.
1741
1742   // Try to tap at the beginning.
1743   application.ProcessEvent( GenerateTap( Gesture::Possible, 1u, 1u, Vector2( 1.f, 25.0f ) ) );
1744   application.ProcessEvent( GenerateTap( Gesture::Started, 1u, 1u, Vector2( 1.f, 25.0f ) ) );
1745
1746   // Render and notify
1747   application.SendNotification();
1748   application.Render();
1749
1750   // Cursor position should be the same than position1.
1751   Vector3 position4 = cursor.GetCurrentPosition();
1752
1753   DALI_TEST_EQUALS( position2, position4, TEST_LOCATION ); // Should be in the same position2.
1754
1755   // Tap away from the start position.
1756   application.ProcessEvent( GenerateTap( Gesture::Possible, 1u, 1u, Vector2( 16.f, 25.0f ) ) );
1757   application.ProcessEvent( GenerateTap( Gesture::Started, 1u, 1u, Vector2( 16.0f, 25.0f ) ) );
1758
1759   // Render and notify
1760   application.SendNotification();
1761   application.Render();
1762
1763   Vector3 position5 = cursor.GetCurrentPosition();
1764
1765   DALI_TEST_CHECK( position5.x > position4.x );
1766
1767   // Remove all the text.
1768   application.ProcessEvent( GenerateKey( "", "", DALI_KEY_BACKSPACE, 0, 0, Integration::KeyEvent::Down, DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
1769   application.ProcessEvent( GenerateKey( "", "", DALI_KEY_BACKSPACE, 0, 0, Integration::KeyEvent::Down, DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
1770   field.SetProperty( TextField::Property::TEXT, "" );
1771
1772   // Render and notify
1773   application.SendNotification();
1774   application.Render();
1775
1776   // Cursor position should be the same than position2.
1777   Vector3 position6 = cursor.GetCurrentPosition();
1778
1779   DALI_TEST_EQUALS( position2, position6, TEST_LOCATION );// Should be in the same position2.
1780
1781   // Should not be a renderer.
1782   DALI_TEST_EQUALS( stencil.GetChildCount(), 0u, TEST_LOCATION );
1783
1784   // Chanege exceed policy (EXCEED_POLICY_ORIGINAL doesn't use stencil )
1785   field.SetProperty( TextField::Property::TEXT, "This is a long text for the size of the text-field." );
1786   field.SetProperty( TextField::Property::EXCEED_POLICY, Dali::Toolkit::TextField::EXCEED_POLICY_ORIGINAL );
1787
1788   application.SendNotification();
1789   application.Render();
1790
1791   // There are renderer and decorator layer
1792   DALI_TEST_EQUALS( field.GetChildCount(), 2u, TEST_LOCATION );
1793
1794   END_TEST;
1795 }
1796
1797 int utcDaliTextFieldEvent03(void)
1798 {
1799   ToolkitTestApplication application;
1800   tet_infoline(" utcDaliTextFieldEvent03");
1801
1802   // Checks if the highlight actor is created.
1803
1804   TextField field = TextField::New();
1805   DALI_TEST_CHECK( field );
1806
1807   Stage::GetCurrent().Add( field );
1808
1809   field.SetProperty( TextField::Property::TEXT, "This is a long text for the size of the text-field." );
1810   field.SetProperty( TextField::Property::POINT_SIZE, 10.f );
1811   field.SetSize( 30.f, 50.f );
1812   field.SetParentOrigin( ParentOrigin::TOP_LEFT );
1813   field.SetAnchorPoint( AnchorPoint::TOP_LEFT );
1814
1815   // Avoid a crash when core load gl resources.
1816   application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
1817   LoadMarkerImages(application, field);
1818
1819   // Render and notify
1820   application.SendNotification();
1821   application.Render();
1822
1823   // Tap first to get the focus.
1824   application.ProcessEvent( GenerateTap( Gesture::Possible, 1u, 1u, Vector2( 3.f, 25.0f ) ) );
1825   application.ProcessEvent( GenerateTap( Gesture::Started, 1u, 1u, Vector2( 3.f, 25.0f ) ) );
1826
1827   // Render and notify
1828   application.SendNotification();
1829   application.Render();
1830
1831   // Double tap to select a word.
1832   application.ProcessEvent( GenerateTap( Gesture::Possible, 2u, 1u, Vector2( 3.f, 25.0f ) ) );
1833   application.ProcessEvent( GenerateTap( Gesture::Started, 2u, 1u, Vector2( 3.f, 25.0f ) ) );
1834
1835   // Render and notify
1836   application.SendNotification();
1837   application.Render();
1838
1839   // The offscreen root actor should have two actors: the renderer and the highlight actor.
1840   Actor stencil = field.GetChildAt( 0u );
1841
1842   // The highlight actor is drawn first, so is the first actor in the list
1843   Renderer highlight = stencil.GetChildAt( 0u ).GetRendererAt( 0u );
1844   DALI_TEST_CHECK( highlight );
1845
1846   // The offscreen root actor has a container with all the actors which contain the text renderers.
1847   Actor container = stencil.GetChildAt( 1u );
1848   for( unsigned int index = 0; index < container.GetChildCount(); ++index )
1849   {
1850     Renderer renderer = container.GetChildAt( index ).GetRendererAt( 0u );
1851     DALI_TEST_CHECK( renderer );
1852   }
1853
1854   END_TEST;
1855 }
1856
1857 int utcDaliTextFieldEvent04(void)
1858 {
1859   ToolkitTestApplication application;
1860   tet_infoline(" utcDaliTextFieldEvent04");
1861
1862   // Checks if the highlight actor is created.
1863
1864   TextField field = TextField::New();
1865   DALI_TEST_CHECK( field );
1866   Stage::GetCurrent().Add( field );
1867   LoadMarkerImages(application, field);
1868   // Render and notify
1869   application.SendNotification();
1870   application.Render();
1871
1872   field.SetProperty( TextField::Property::TEXT, "This is a long text for the size of the text-field." );
1873   field.SetProperty( TextField::Property::POINT_SIZE, 10.f );
1874   field.SetSize( 300.f, 50.f );
1875   field.SetParentOrigin( ParentOrigin::TOP_LEFT );
1876   field.SetAnchorPoint( AnchorPoint::TOP_LEFT );
1877
1878   // Avoid a crash when core load gl resources.
1879   application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
1880   // Render and notify
1881   application.SendNotification();
1882   application.Render();
1883
1884   // Create a tap event to touch the text field.
1885   application.ProcessEvent( GenerateTap( Gesture::Possible, 1u, 1u, Vector2( 150.0f, 25.0f ) ) );
1886   application.ProcessEvent( GenerateTap( Gesture::Started, 1u, 1u, Vector2( 150.0f, 25.0f ) ) );
1887   // Render and notify
1888   application.SendNotification();
1889   application.Render();
1890
1891
1892   // Tap first to get the focus.
1893   application.ProcessEvent( GenerateTap( Gesture::Possible, 1u, 1u, Vector2( 1.f, 25.0f ) ) );
1894   application.ProcessEvent( GenerateTap( Gesture::Started, 1u, 1u, Vector2( 1.f, 25.0f ) ) );
1895
1896   // Render and notify
1897   application.SendNotification();
1898   application.Render();
1899
1900   // Double tap to select a word.
1901   application.ProcessEvent( GenerateTap( Gesture::Possible, 2u, 1u, Vector2( 1.f, 25.0f ) ) );
1902   application.ProcessEvent( GenerateTap( Gesture::Started, 2u, 1u, Vector2( 1.f, 25.0f ) ) );
1903
1904   // Render and notify
1905   application.SendNotification();
1906   application.Render();
1907
1908   // Tap grab handle
1909   application.ProcessEvent( GenerateTap( Gesture::Possible, 1u, 1u, Vector2( 0.f, 40.0f ) ) );
1910   application.ProcessEvent( GenerateTap( Gesture::Started, 1u, 1u, Vector2( 0.f, 40.0f ) ) );
1911   END_TEST;
1912 }
1913
1914 int utcDaliTextFieldEvent05(void)
1915 {
1916   ToolkitTestApplication application;
1917   tet_infoline(" utcDaliTextFieldEvent05");
1918
1919   // Checks dragging of cursor/grab handle
1920
1921   TextField field = TextField::New();
1922   DALI_TEST_CHECK( field );
1923   Stage::GetCurrent().Add( field );
1924   LoadMarkerImages(application, field);
1925   // Render and notify
1926   application.SendNotification();
1927   application.Render();
1928
1929   field.SetProperty( TextField::Property::TEXT, "This is a long text for the size of the text-field." );
1930   field.SetProperty( TextField::Property::POINT_SIZE, 10.f );
1931   field.SetSize( 300.f, 50.f );
1932   field.SetParentOrigin( ParentOrigin::TOP_LEFT );
1933   field.SetAnchorPoint( AnchorPoint::TOP_LEFT );
1934
1935   // Avoid a crash when core load gl resources.
1936   application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
1937   // Render and notify
1938   application.SendNotification();
1939   application.Render();
1940
1941   // Create a tap event to touch the text field.
1942   application.ProcessEvent( GenerateTap( Gesture::Possible, 1u, 1u, Vector2( 150.0f, 25.0f ) ) );
1943   application.ProcessEvent( GenerateTap( Gesture::Started, 1u, 1u, Vector2( 150.0f, 25.0f ) ) );
1944   // Render and notify
1945   application.SendNotification();
1946   application.Render();
1947
1948
1949   // Tap first to get the focus.
1950   application.ProcessEvent( GenerateTap( Gesture::Possible, 1u, 1u, Vector2( 1.f, 25.0f ) ) );
1951   application.ProcessEvent( GenerateTap( Gesture::Started, 1u, 1u, Vector2( 1.f, 25.0f ) ) );
1952
1953   // Render and notify
1954   application.SendNotification();
1955   application.Render();
1956
1957   // Double tap to select a word.
1958   application.ProcessEvent( GenerateTap( Gesture::Possible, 2u, 1u, Vector2( 1.f, 25.0f ) ) );
1959   application.ProcessEvent( GenerateTap( Gesture::Started, 2u, 1u, Vector2( 1.f, 25.0f ) ) );
1960
1961   // Render and notify
1962   application.SendNotification();
1963   application.Render();
1964
1965   // drag grab handle right
1966   Vector2 pos(0.0f, 40.0f);
1967   SendPan(application, Gesture::Possible, pos);
1968   SendPan(application, Gesture::Started, pos);
1969   pos.x += 5.0f;
1970   Wait(application, 100);
1971
1972   for(int i = 0;i<20;i++)
1973   {
1974     SendPan(application, Gesture::Continuing, pos);
1975     pos.x += 5.0f;
1976     Wait(application);
1977   }
1978
1979   SendPan(application, Gesture::Finished, pos);
1980   Wait(application, RENDER_FRAME_INTERVAL);
1981
1982   Actor stencil = field.GetChildAt( 1u );
1983   END_TEST;
1984 }
1985
1986 int utcDaliTextFieldEvent06(void)
1987 {
1988   ToolkitTestApplication application;
1989   tet_infoline(" utcDaliTextFieldEvent06");
1990
1991   // Checks Longpress when in edit mode
1992
1993   TextField field = TextField::New();
1994   DALI_TEST_CHECK( field );
1995   Stage::GetCurrent().Add( field );
1996   LoadMarkerImages(application, field);
1997   // Render and notify
1998   application.SendNotification();
1999   application.Render();
2000
2001   field.SetProperty( TextField::Property::TEXT, "Thisisalongtextforthesizeofthetextfield." );
2002   field.SetProperty( TextField::Property::POINT_SIZE, 10.f );
2003   field.SetSize( 300.f, 50.f );
2004   field.SetParentOrigin( ParentOrigin::TOP_LEFT );
2005   field.SetAnchorPoint( AnchorPoint::TOP_LEFT );
2006
2007   // Avoid a crash when core load gl resources.
2008   application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
2009   // Render and notify
2010   application.SendNotification();
2011   application.Render();
2012
2013   // Create a tap event to touch the text field.
2014   application.ProcessEvent( GenerateTap( Gesture::Possible, 1u, 1u, Vector2( 150.0f, 25.0f ) ) );
2015   application.ProcessEvent( GenerateTap( Gesture::Started, 1u, 1u, Vector2( 150.0f, 25.0f ) ) );
2016   // Render and notify
2017   application.SendNotification();
2018   application.Render();
2019
2020
2021   // Tap first to get the focus.
2022   application.ProcessEvent( GenerateTap( Gesture::Possible, 1u, 1u, Vector2( 1.f, 25.0f ) ) );
2023   application.ProcessEvent( GenerateTap( Gesture::Started, 1u, 1u, Vector2( 1.f, 25.0f ) ) );
2024
2025   // Render and notify
2026   application.SendNotification();
2027   application.Render();
2028
2029   // Long Press
2030   application.ProcessEvent( GenerateLongPress( Gesture::Possible, 1u, Vector2( 1.f, 25.0f ) ) );
2031   application.ProcessEvent( GenerateLongPress( Gesture::Started,  1u, Vector2( 1.f, 25.0f ) ) );
2032
2033   // Render and notify
2034   application.SendNotification();
2035   application.Render();
2036
2037   END_TEST;
2038 }
2039
2040 int utcDaliTextFieldEvent07(void)
2041 {
2042   ToolkitTestApplication application;
2043   tet_infoline(" utcDaliTextFieldEvent07");
2044
2045   // Checks Longpress to start edit mode
2046
2047   TextField field = TextField::New();
2048   DALI_TEST_CHECK( field );
2049   Stage::GetCurrent().Add( field );
2050   LoadMarkerImages(application, field);
2051   // Render and notify
2052   application.SendNotification();
2053   application.Render();
2054
2055   field.SetProperty( TextField::Property::TEXT, "Thisisalongtextforthesizeofthetextfield." );
2056   field.SetProperty( TextField::Property::POINT_SIZE, 10.f );
2057   field.SetSize( 300.f, 50.f );
2058   field.SetParentOrigin( ParentOrigin::TOP_LEFT );
2059   field.SetAnchorPoint( AnchorPoint::TOP_LEFT );
2060   Property::Map propertyMap;
2061   propertyMap["PANEL_LAYOUT"] = InputMethod::PanelLayout::PASSWORD;
2062   field.SetProperty( TextField::Property::INPUT_METHOD_SETTINGS, propertyMap );
2063
2064   // Avoid a crash when core load gl resources.
2065   application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
2066   // Render and notify
2067   application.SendNotification();
2068   application.Render();
2069
2070   // Long Press
2071   application.ProcessEvent( GenerateLongPress( Gesture::Possible, 1u, Vector2( 1.f, 25.0f ) ) );
2072   application.ProcessEvent( GenerateLongPress( Gesture::Started,  1u, Vector2( 1.f, 25.0f ) ) );
2073
2074   // Render and notify
2075   application.SendNotification();
2076   application.Render();
2077
2078   END_TEST;
2079 }
2080
2081 int utcDaliTextFieldEvent08(void)
2082 {
2083   ToolkitTestApplication application;
2084   tet_infoline(" utcDaliTextFieldEvent08");
2085
2086   Dali::Clipboard clipboard = Clipboard::Get();
2087   clipboard.SetItem("testTextFieldEvent");
2088
2089   // Checks Longpress when only place holder text
2090
2091   TextField field = TextField::New();
2092   DALI_TEST_CHECK( field );
2093   Stage::GetCurrent().Add( field );
2094   LoadMarkerImages(application, field);
2095   // Render and notify
2096   application.SendNotification();
2097   application.Render();
2098
2099   field.SetProperty( TextField::Property::PLACEHOLDER_TEXT, "Setting Placeholder Text" );
2100   field.SetProperty( TextField::Property::POINT_SIZE, 10.f );
2101   field.SetSize( 300.f, 50.f );
2102   field.SetParentOrigin( ParentOrigin::TOP_LEFT );
2103   field.SetAnchorPoint( AnchorPoint::TOP_LEFT );
2104
2105   // Avoid a crash when core load gl resources.
2106   application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
2107   // Render and notify
2108   application.SendNotification();
2109   application.Render();
2110
2111   // Long Press
2112   application.ProcessEvent( GenerateLongPress( Gesture::Possible, 1u, Vector2( 1.f, 25.0f ) ) );
2113   application.ProcessEvent( GenerateLongPress( Gesture::Started,  1u, Vector2( 1.f, 25.0f ) ) );
2114
2115   // Render and notify
2116   application.SendNotification();
2117   application.Render();
2118
2119   Wait(application, 500);
2120
2121   // Long Press
2122   application.ProcessEvent( GenerateLongPress( Gesture::Possible, 1u, Vector2( 1.f, 25.0f ) ) );
2123   application.ProcessEvent( GenerateLongPress( Gesture::Started,  1u, Vector2( 1.f, 25.0f ) ) );
2124
2125   // Render and notify
2126   application.SendNotification();
2127   application.Render();
2128
2129   Wait(application, 500);
2130
2131   Stage stage = Stage::GetCurrent();
2132   Layer layer = stage.GetRootLayer();
2133   Actor actor = layer.FindChildByName("optionPaste");
2134
2135   if (actor)
2136   {
2137     Vector3 worldPosition = actor.GetCurrentWorldPosition();
2138     Vector2 halfStageSize = stage.GetSize() / 2.0f;
2139     Vector2 position(worldPosition.x + halfStageSize.width, worldPosition.y + halfStageSize.height);
2140
2141     Dali::Integration::TouchEvent event;
2142     event = Dali::Integration::TouchEvent();
2143     event.AddPoint( GetPointDownInside( position ) );
2144     application.ProcessEvent( event );
2145
2146     event = Dali::Integration::TouchEvent();
2147     event.AddPoint( GetPointUpInside( position ) );
2148     application.ProcessEvent( event );
2149   }
2150   DALI_TEST_EQUALS( field.GetProperty<std::string>( TextEditor::Property::TEXT ), std::string("testTextFieldEvent"), TEST_LOCATION );
2151
2152   END_TEST;
2153 }
2154
2155 int utcDaliTextFieldEvent09(void)
2156 {
2157   ToolkitTestApplication application;
2158   tet_infoline(" utcDaliTextFieldEvent09");
2159
2160   TextField field = TextField::New();
2161   DALI_TEST_CHECK( field );
2162   Stage::GetCurrent().Add( field );
2163   LoadMarkerImages(application, field);
2164   // Render and notify
2165   application.SendNotification();
2166   application.Render();
2167
2168   field.SetProperty( TextField::Property::TEXT, "Hello" );
2169   field.SetProperty( TextField::Property::POINT_SIZE, 10.f );
2170   field.SetSize( 300.f, 50.f );
2171   field.SetParentOrigin( ParentOrigin::TOP_LEFT );
2172   field.SetAnchorPoint( AnchorPoint::TOP_LEFT );
2173
2174   // Avoid a crash when core load gl resources.
2175   application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
2176
2177   // Create a tap event to touch the text field.
2178   application.ProcessEvent( GenerateTap( Gesture::Possible, 1u, 1u, Vector2( 150.0f, 25.0f ) ) );
2179   application.ProcessEvent( GenerateTap( Gesture::Started, 1u, 1u, Vector2( 150.0f, 25.0f ) ) );
2180   application.SendNotification();
2181   application.Render();
2182
2183   Property::Map map;
2184   map[ HiddenInput::Property::MODE ] = HiddenInput::Mode::HIDE_NONE;
2185   field.SetProperty( TextField::Property::HIDDEN_INPUT_SETTINGS, map );
2186   application.ProcessEvent( GenerateKey( "d", "d", 0, 0, 0, Integration::KeyEvent::Down, DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2187   application.SendNotification();
2188   application.Render();
2189
2190   map[ HiddenInput::Property::MODE ] = HiddenInput::Mode::HIDE_ALL;
2191   map[ HiddenInput::Property::SUBSTITUTE_CHARACTER ] = 0x23;
2192   field.SetProperty( TextField::Property::HIDDEN_INPUT_SETTINGS, map );
2193   application.ProcessEvent( GenerateKey( "d", "d", 0, 0, 0, Integration::KeyEvent::Down, DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2194   application.SendNotification();
2195   application.Render();
2196
2197   map[ HiddenInput::Property::MODE ] = HiddenInput::Mode::HIDE_COUNT;
2198   map[ HiddenInput::Property::SUBSTITUTE_COUNT ] = 2;
2199   field.SetProperty( TextField::Property::HIDDEN_INPUT_SETTINGS, map );
2200   for( unsigned int index = 0u; index < 5u; ++index )
2201   {
2202     application.ProcessEvent( GenerateKey( "d", "d", 0, 0, 0, Integration::KeyEvent::Down, DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2203     application.SendNotification();
2204     application.Render();
2205   }
2206
2207   map[ HiddenInput::Property::MODE ] = HiddenInput::Mode::SHOW_COUNT;
2208   map[ HiddenInput::Property::SUBSTITUTE_COUNT ] = 2;
2209   field.SetProperty( TextField::Property::HIDDEN_INPUT_SETTINGS, map );
2210   for( unsigned int index = 0u; index < 5u; ++index )
2211   {
2212     application.ProcessEvent( GenerateKey( "d", "d", 0, 0, 0, Integration::KeyEvent::Down, DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2213     application.SendNotification();
2214     application.Render();
2215   }
2216
2217   map[ HiddenInput::Property::MODE ] = HiddenInput::Mode::SHOW_LAST_CHARACTER;
2218   map[ HiddenInput::Property::SHOW_LAST_CHARACTER_DURATION ] = 0;
2219   field.SetProperty( TextField::Property::HIDDEN_INPUT_SETTINGS, map );
2220   application.ProcessEvent( GenerateKey( "", "", DALI_KEY_BACKSPACE, 0, 0, Integration::KeyEvent::Down, DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2221   application.SendNotification();
2222   application.Render();
2223   application.ProcessEvent( GenerateKey( "d", "d", 0, 0, 0, Integration::KeyEvent::Down, DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2224   application.SendNotification();
2225   application.Render();
2226
2227   map[ HiddenInput::Property::SHOW_LAST_CHARACTER_DURATION ] = 100;
2228   field.SetProperty( TextField::Property::HIDDEN_INPUT_SETTINGS, map );
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   Property::Map mapGet;
2234   mapGet = field.GetProperty<Property::Map>( TextField::Property::HIDDEN_INPUT_SETTINGS );
2235   DALI_TEST_EQUALS( map.Count(), mapGet.Count(), TEST_LOCATION );
2236   DALI_TEST_EQUALS( DaliTestCheckMaps( map, mapGet ), true, TEST_LOCATION );
2237   END_TEST;
2238 }
2239
2240
2241 int utcDaliTextFieldStyleWhilstSelected(void)
2242 {
2243   ToolkitTestApplication application;
2244   tet_infoline(" utcDaliTextFieldStyleWhilstSelected");
2245
2246   // Change font and styles whilst text is selected whilst word selected
2247
2248   TextField field = TextField::New();
2249   DALI_TEST_CHECK( field );
2250   Stage::GetCurrent().Add( field );
2251   LoadMarkerImages(application, field);
2252   // Render and notify
2253   application.SendNotification();
2254   application.Render();
2255
2256   field.SetProperty( TextField::Property::TEXT, "This is a long text for the size of the text-field." );
2257   field.SetProperty( TextField::Property::POINT_SIZE, 10.f );
2258   field.SetSize( 300.f, 50.f );
2259   field.SetParentOrigin( ParentOrigin::TOP_LEFT );
2260   field.SetAnchorPoint( AnchorPoint::TOP_LEFT );
2261
2262   // Avoid a crash when core load gl resources.
2263   application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
2264   // Render and notify
2265   application.SendNotification();
2266   application.Render();
2267
2268   // Create a tap event to touch the text field.
2269   application.ProcessEvent( GenerateTap( Gesture::Possible, 1u, 1u, Vector2( 150.0f, 25.0f ) ) );
2270   application.ProcessEvent( GenerateTap( Gesture::Started, 1u, 1u, Vector2( 150.0f, 25.0f ) ) );
2271   // Render and notify
2272   application.SendNotification();
2273   application.Render();
2274
2275
2276   // Tap first to get the focus.
2277   application.ProcessEvent( GenerateTap( Gesture::Possible, 1u, 1u, Vector2( 1.f, 25.0f ) ) );
2278   application.ProcessEvent( GenerateTap( Gesture::Started, 1u, 1u, Vector2( 1.f, 25.0f ) ) );
2279
2280   // Render and notify
2281   application.SendNotification();
2282   application.Render();
2283
2284   // Double tap to select a word.
2285   application.ProcessEvent( GenerateTap( Gesture::Possible, 2u, 1u, Vector2( 1.f, 25.0f ) ) );
2286   application.ProcessEvent( GenerateTap( Gesture::Started, 2u, 1u, Vector2( 1.f, 25.0f ) ) );
2287
2288   // Render and notify
2289   application.SendNotification();
2290   application.Render();
2291
2292   field.SetProperty( TextField::Property::INPUT_FONT_FAMILY, "Setting input font family" );
2293   DALI_TEST_EQUALS( field.GetProperty<std::string>( TextField::Property::INPUT_FONT_FAMILY ), "Setting input font family", TEST_LOCATION );
2294
2295   Property::Map fontStyleMapSet;
2296   Property::Map fontStyleMapGet;
2297
2298   fontStyleMapSet.Insert( "weight", "bold" );
2299   fontStyleMapSet.Insert( "slant", "italic" );
2300   field.SetProperty( TextField::Property::INPUT_FONT_STYLE, fontStyleMapSet );
2301
2302   fontStyleMapGet = field.GetProperty<Property::Map>( TextField::Property::INPUT_FONT_STYLE );
2303   DALI_TEST_EQUALS( fontStyleMapGet.Count(), fontStyleMapSet.Count(), TEST_LOCATION );
2304   DALI_TEST_EQUALS( DaliTestCheckMaps( fontStyleMapGet, fontStyleMapSet ), true, TEST_LOCATION );
2305
2306   fontStyleMapSet.Clear();
2307   fontStyleMapSet.Insert( "width", "expanded" );
2308   fontStyleMapSet.Insert( "slant", "italic" );
2309   field.SetProperty( TextField::Property::INPUT_FONT_STYLE, fontStyleMapSet );
2310
2311   fontStyleMapGet = field.GetProperty<Property::Map>( TextField::Property::INPUT_FONT_STYLE );
2312   DALI_TEST_EQUALS( fontStyleMapGet.Count(), fontStyleMapSet.Count(), TEST_LOCATION );
2313   DALI_TEST_EQUALS( DaliTestCheckMaps( fontStyleMapGet, fontStyleMapSet ), true, TEST_LOCATION );
2314
2315   field.SetProperty( TextField::Property::INPUT_POINT_SIZE, 12.f );
2316   DALI_TEST_EQUALS( field.GetProperty<float>( TextField::Property::INPUT_POINT_SIZE ), 12.f, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
2317
2318   field.SetProperty( TextField::Property::TEXT_COLOR, Color::RED );
2319   DALI_TEST_EQUALS( field.GetProperty<Vector4>( TextField::Property::TEXT_COLOR ), Color::RED, TEST_LOCATION );
2320
2321   fontStyleMapSet.Clear();
2322   fontStyleMapSet.Insert( "weight", "bold" );
2323   fontStyleMapSet.Insert( "slant", "italic" );
2324
2325   field.SetProperty( TextField::Property::FONT_STYLE, fontStyleMapSet );
2326
2327   fontStyleMapGet = field.GetProperty<Property::Map>( TextField::Property::FONT_STYLE );
2328   DALI_TEST_EQUALS( fontStyleMapGet.Count(), fontStyleMapSet.Count(), TEST_LOCATION );
2329   DALI_TEST_EQUALS( DaliTestCheckMaps( fontStyleMapGet, fontStyleMapSet ), true, TEST_LOCATION );
2330
2331   fontStyleMapSet.Clear();
2332   fontStyleMapSet.Insert( "width", "expanded" );
2333
2334   field.SetProperty( TextField::Property::FONT_STYLE, fontStyleMapSet );
2335
2336   fontStyleMapGet = field.GetProperty<Property::Map>( TextField::Property::FONT_STYLE );
2337   DALI_TEST_EQUALS( fontStyleMapGet.Count(), fontStyleMapSet.Count(), TEST_LOCATION );
2338   DALI_TEST_EQUALS( DaliTestCheckMaps( fontStyleMapGet, fontStyleMapSet ), true, TEST_LOCATION );
2339
2340   // Press Escape to increase coverage
2341   application.ProcessEvent( GenerateKey( "", "", DALI_KEY_ESCAPE, 0, 0, Integration::KeyEvent::Up, DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2342   application.SendNotification();
2343   application.Render();
2344
2345   DALI_TEST_CHECK( !field.HasKeyInputFocus() );
2346
2347   END_TEST;
2348 }
2349
2350 int utcDaliTextFieldEscKeyLoseFocus(void)
2351 {
2352   ToolkitTestApplication application;
2353   tet_infoline(" utcDaliTextFieldEscKeyLoseFocus");
2354
2355   // Creates a tap event. After creating a tap event the text field should
2356   // have the focus and add text with key events should be possible.
2357
2358   TextField field = TextField::New();
2359   DALI_TEST_CHECK( field );
2360
2361   Stage::GetCurrent().Add( field );
2362
2363   field.SetSize( 300.f, 50.f );
2364   field.SetParentOrigin( ParentOrigin::TOP_LEFT );
2365   field.SetAnchorPoint( AnchorPoint::TOP_LEFT );
2366
2367   // Avoid a crash when core load gl resources.
2368   application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
2369
2370   // Render and notify
2371   application.SendNotification();
2372   application.Render();
2373
2374   // Add a key event but as the text field has not the focus it should do nothing.
2375   application.ProcessEvent( GenerateKey( "a", "a", KEY_A_CODE, 0, 0, Integration::KeyEvent::Down, DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2376   application.ProcessEvent( GenerateKey( "a", "a", KEY_A_CODE, 0, 0, Integration::KeyEvent::Up, DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2377
2378   // Render and notify
2379   application.SendNotification();
2380   application.Render();
2381
2382   DALI_TEST_EQUALS( field.GetProperty<std::string>( TextField::Property::TEXT ), std::string(""), TEST_LOCATION );
2383
2384   // Create a tap event to touch the text field.
2385   application.ProcessEvent( GenerateTap( Gesture::Possible, 1u, 1u, Vector2( 150.0f, 25.0f ) ) );
2386   application.ProcessEvent( GenerateTap( Gesture::Started, 1u, 1u, Vector2( 150.0f, 25.0f ) ) );
2387
2388   // Render and notify
2389   application.SendNotification();
2390   application.Render();
2391
2392   // Now the text field has the focus, so it can handle the key events.
2393   application.ProcessEvent( GenerateKey( "a", "a", KEY_A_CODE, 0, 0, Integration::KeyEvent::Down, DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2394   application.ProcessEvent( GenerateKey( "a", "a", KEY_A_CODE, 0, 0, Integration::KeyEvent::Up, DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2395   application.ProcessEvent( GenerateKey( "d", "d", KEY_D_CODE, 0, 0, Integration::KeyEvent::Down, DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2396   application.ProcessEvent( GenerateKey( "d", "d", KEY_D_CODE, 0, 0, Integration::KeyEvent::Up, DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2397
2398   // Render and notify
2399   application.SendNotification();
2400   application.Render();
2401
2402   DALI_TEST_EQUALS( field.GetProperty<std::string>( TextField::Property::TEXT ), std::string("ad"), TEST_LOCATION );
2403
2404   // Generate a Esc key event. The text field should lose the focus.
2405   application.ProcessEvent( GenerateKey( "", "", DALI_KEY_ESCAPE, 0, 0, Integration::KeyEvent::Down, DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2406   application.ProcessEvent( GenerateKey( "", "", DALI_KEY_ESCAPE, 0, 0, Integration::KeyEvent::Up, DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2407
2408   // Render and notify
2409   application.SendNotification();
2410   application.Render();
2411
2412   DALI_TEST_EQUALS( false, field.HasKeyInputFocus(), TEST_LOCATION );
2413
2414   // No more text should be introduced
2415   application.ProcessEvent( GenerateKey( "a", "a", KEY_A_CODE, 0, 0, Integration::KeyEvent::Down, DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2416   application.ProcessEvent( GenerateKey( "a", "a", KEY_A_CODE, 0, 0, Integration::KeyEvent::Up, DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2417
2418   // Render and notify
2419   application.SendNotification();
2420   application.Render();
2421
2422   DALI_TEST_EQUALS( field.GetProperty<std::string>( TextField::Property::TEXT ), std::string("ad"), TEST_LOCATION );
2423
2424   END_TEST;
2425 }
2426
2427 int utcDaliTextFieldSomeSpecialKeys(void)
2428 {
2429   ToolkitTestApplication application;
2430   tet_infoline(" utcDaliTextFieldSomeSpecialKeys");
2431
2432   // Checks some special keys when the text is selected.
2433
2434   TextField field = TextField::New();
2435   DALI_TEST_CHECK( field );
2436   Stage::GetCurrent().Add( field );
2437   LoadMarkerImages(application, field);
2438   // Render and notify
2439   application.SendNotification();
2440   application.Render();
2441
2442   const std::string longText( "This is a long text for the size of the text-field." );
2443
2444   field.SetProperty( TextField::Property::TEXT, longText );
2445   field.SetProperty( TextField::Property::POINT_SIZE, 10.f );
2446   field.SetSize( 300.f, 50.f );
2447   field.SetParentOrigin( ParentOrigin::TOP_LEFT );
2448   field.SetAnchorPoint( AnchorPoint::TOP_LEFT );
2449
2450   // Avoid a crash when core load gl resources.
2451   application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
2452   // Render and notify
2453   application.SendNotification();
2454   application.Render();
2455
2456   // Create a tap event to touch the text field.
2457   application.ProcessEvent( GenerateTap( Gesture::Possible, 1u, 1u, Vector2( 150.0f, 25.0f ) ) );
2458   application.ProcessEvent( GenerateTap( Gesture::Started, 1u, 1u, Vector2( 150.0f, 25.0f ) ) );
2459
2460   // Render and notify
2461   application.SendNotification();
2462   application.Render();
2463
2464   // Tap first to get the focus.
2465   application.ProcessEvent( GenerateTap( Gesture::Possible, 1u, 1u, Vector2( 1.f, 25.0f ) ) );
2466   application.ProcessEvent( GenerateTap( Gesture::Started, 1u, 1u, Vector2( 1.f, 25.0f ) ) );
2467
2468   // Render and notify
2469   application.SendNotification();
2470   application.Render();
2471
2472   // Double tap to select a word.
2473   application.ProcessEvent( GenerateTap( Gesture::Possible, 2u, 1u, Vector2( 1.f, 25.0f ) ) );
2474   application.ProcessEvent( GenerateTap( Gesture::Started, 2u, 1u, Vector2( 1.f, 25.0f ) ) );
2475
2476   // Render and notify
2477   application.SendNotification();
2478   application.Render();
2479
2480   // Generate a Esc key event. The text field should lose the focus.
2481   application.ProcessEvent( GenerateKey( "XF86PowerOff", "XF86PowerOff", DALI_KEY_POWER, 0, 0, Integration::KeyEvent::Down, DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2482   application.ProcessEvent( GenerateKey( "XF86PowerOff", "XF86PowerOff", DALI_KEY_POWER, 0, 0, Integration::KeyEvent::Up, DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2483
2484   // Render and notify
2485   application.SendNotification();
2486   application.Render();
2487
2488   // Generate a Esc key event. The text field should lose the focus.
2489   application.ProcessEvent( GenerateKey( "XF86Menu", "XF86Menu", DALI_KEY_MENU, 0, 0, Integration::KeyEvent::Down, DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2490   application.ProcessEvent( GenerateKey( "XF86Menu", "XF86Menu", DALI_KEY_MENU, 0, 0, Integration::KeyEvent::Up, DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2491
2492   // Render and notify
2493   application.SendNotification();
2494   application.Render();
2495
2496   // Generate a Esc key event. The text field should lose the focus.
2497   application.ProcessEvent( GenerateKey( "XF86Home", "XF86Home", DALI_KEY_HOME, 0, 0, Integration::KeyEvent::Down, DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2498   application.ProcessEvent( GenerateKey( "XF86Home", "XF86Home", DALI_KEY_HOME, 0, 0, Integration::KeyEvent::Up, DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2499
2500   // Render and notify
2501   application.SendNotification();
2502   application.Render();
2503
2504   // The text shouldn't be deleted.
2505   DALI_TEST_EQUALS( field.GetProperty<std::string>( TextField::Property::TEXT ), longText, TEST_LOCATION );
2506
2507   END_TEST;
2508 }
2509
2510 int utcDaliTextFieldSizeUpdate(void)
2511 {
2512   ToolkitTestApplication application;
2513   tet_infoline("utcDaliTextFieldSizeUpdate");
2514
2515   // Checks some special keys when the text is selected.
2516   TextField field = TextField::New();
2517   DALI_TEST_CHECK( field );
2518   Stage::GetCurrent().Add( field );
2519
2520   float previousHeight = 0.0f;
2521   float currentHeight = 0.0f;
2522   const float fieldWidth = 1920.0f;
2523
2524
2525   // "ㅁ" is bigger then "ኢ"
2526   field.SetSize( Vector2( fieldWidth ,10.0f ) );
2527   field.SetResizePolicy( ResizePolicy::FIXED , Dimension::WIDTH );
2528   field.SetResizePolicy( ResizePolicy::DIMENSION_DEPENDENCY , Dimension::HEIGHT );
2529
2530   field.SetProperty( TextField::Property::TEXT, "ኢ");
2531   field.SetParentOrigin( ParentOrigin::TOP_LEFT );
2532   field.SetAnchorPoint( AnchorPoint::TOP_LEFT );
2533
2534   field.SetKeyboardFocusable(true);
2535   KeyboardFocusManager::Get().SetCurrentFocusActor( field );
2536
2537   application.SendNotification();
2538   application.Render();
2539
2540   previousHeight = field.GetHeightForWidth( fieldWidth );
2541   DALI_TEST_EQUALS( previousHeight, field.GetProperty<float>( Actor::Property::SIZE_HEIGHT ) , TEST_LOCATION );
2542
2543   // Add  another script characters ( glyph height is defferent )
2544   application.ProcessEvent( GenerateKey( "ㅁ", "ㅁ", KEY_A_CODE, 0, 0, Integration::KeyEvent::Down, DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2545   application.ProcessEvent( GenerateKey( "ㅁ", "ㅁ", KEY_A_CODE, 0, 0, Integration::KeyEvent::Up, DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2546
2547   application.SendNotification();
2548   application.Render();
2549
2550   currentHeight = field.GetHeightForWidth( fieldWidth );
2551   DALI_TEST_EQUALS( currentHeight, field.GetProperty<float>( Actor::Property::SIZE_HEIGHT ), TEST_LOCATION );
2552   DALI_TEST_EQUALS( (previousHeight < currentHeight), true , TEST_LOCATION );
2553
2554   END_TEST;
2555 }
2556
2557 int utcDaliTextFieldExtremlyLargePointSize(void)
2558 {
2559   ToolkitTestApplication application;
2560   tet_infoline(" utcDaliTextFieldExtremlyLargePointSize");
2561
2562   TextField field = TextField::New();
2563
2564   field.SetProperty( TextField::Property::TEXT, "Text" );
2565   field.SetSize( 300.f, 50.f );
2566   field.SetParentOrigin( ParentOrigin::TOP_LEFT );
2567   field.SetAnchorPoint( AnchorPoint::TOP_LEFT );
2568   Stage::GetCurrent().Add( field );
2569
2570   try
2571   {
2572     field.SetProperty( TextField::Property::POINT_SIZE, 160.0f );
2573     application.SendNotification();
2574     DALI_TEST_CHECK( field );
2575   }
2576   catch (...)
2577   {
2578     tet_result(TET_FAIL);
2579   }
2580   END_TEST;
2581 }
2582
2583 int UtcDaliTextFieldDefaultFontStylePropertyCoverage(void)
2584 {
2585   ToolkitTestApplication application;
2586   tet_infoline("UtcDaliTextFieldFontStylePorpertyCoverage");
2587   TextField field = TextField::New();
2588   DALI_TEST_CHECK( field );
2589   Stage::GetCurrent().Add( field );
2590
2591   Property::Map fontStyleMapGet;
2592
2593   fontStyleMapGet = field.GetProperty<Property::Map>( TextField::Property::FONT_STYLE );
2594
2595   Property::Value* weightValue = NULL;
2596   Property::Value* widthValue = NULL;
2597   Property::Value* slantValue = NULL;
2598   weightValue = fontStyleMapGet.Find( "weight" );
2599   widthValue = fontStyleMapGet.Find( "width" );
2600   slantValue = fontStyleMapGet.Find( "slant" );
2601   DALI_TEST_CHECK( !weightValue );
2602   DALI_TEST_CHECK( !widthValue );
2603   DALI_TEST_CHECK( !slantValue );
2604
2605   END_TEST;
2606 }
2607
2608 int UtcDaliTextFieldSettingPlaceholder(void)
2609 {
2610   ToolkitTestApplication application;
2611   tet_infoline("UtcDaliTextFieldSettingPlaceholder");
2612
2613   TextField field = TextField::New();
2614   DALI_TEST_CHECK( field );
2615   Stage::GetCurrent().Add( field );
2616
2617   // Check the placeholder property with pixel size
2618   Property::Map placeholderPixelSizeMapSet;
2619   Property::Map placeholderPixelSizeMapGet;
2620   Property::Map placeholderFontstyleMap;
2621   placeholderPixelSizeMapSet[ Text::PlaceHolder::Property::TEXT ] = "Setting Placeholder Text";
2622   placeholderPixelSizeMapSet[ Text::PlaceHolder::Property::TEXT_FOCUSED ] = "Setting Placeholder Text Focused";
2623   placeholderPixelSizeMapSet[ Text::PlaceHolder::Property::COLOR ] = Color::BLUE;
2624   placeholderPixelSizeMapSet[ Text::PlaceHolder::Property::FONT_FAMILY ] = "Arial";
2625   placeholderPixelSizeMapSet[ Text::PlaceHolder::Property::PIXEL_SIZE ] = 15.0f;
2626   placeholderPixelSizeMapSet[ Text::PlaceHolder::Property::ELLIPSIS ] = true;
2627
2628   placeholderFontstyleMap.Insert( "weight", "bold" );
2629   placeholderPixelSizeMapSet[ Text::PlaceHolder::Property::FONT_STYLE ] = placeholderFontstyleMap;
2630   field.SetProperty( TextField::Property::PLACEHOLDER, placeholderPixelSizeMapSet );
2631
2632   placeholderPixelSizeMapGet = field.GetProperty<Property::Map>( TextField::Property::PLACEHOLDER );
2633   DALI_TEST_EQUALS( placeholderPixelSizeMapGet.Count(), placeholderPixelSizeMapSet.Count(), TEST_LOCATION );
2634   DALI_TEST_EQUALS( DaliTestCheckMaps( placeholderPixelSizeMapGet, placeholderPixelSizeMapSet ), true, TEST_LOCATION );
2635
2636   // Check the placeholder property with point size
2637   Property::Map placeholderMapSet;
2638   Property::Map placeholderMapGet;
2639   placeholderMapSet[ Text::PlaceHolder::Property::TEXT ] = "Setting Placeholder Text";
2640   placeholderMapSet[ Text::PlaceHolder::Property::TEXT_FOCUSED ] = "Setting Placeholder Text Focused";
2641   placeholderMapSet[ Text::PlaceHolder::Property::COLOR ] = Color::RED;
2642   placeholderMapSet[ Text::PlaceHolder::Property::FONT_FAMILY ] = "Arial";
2643   placeholderMapSet[ Text::PlaceHolder::Property::POINT_SIZE ] = 12.0f;
2644   placeholderMapSet[ Text::PlaceHolder::Property::ELLIPSIS ] = false;
2645
2646   // Check the placeholder font style property
2647   placeholderFontstyleMap.Clear();
2648
2649   placeholderFontstyleMap.Insert( "weight", "bold" );
2650   placeholderFontstyleMap.Insert( "width", "condensed" );
2651   placeholderFontstyleMap.Insert( "slant", "italic" );
2652   placeholderMapSet[ Text::PlaceHolder::Property::FONT_STYLE ] = placeholderFontstyleMap;
2653   field.SetProperty( TextField::Property::PLACEHOLDER, placeholderMapSet );
2654
2655   placeholderMapGet = field.GetProperty<Property::Map>( TextField::Property::PLACEHOLDER );
2656   DALI_TEST_EQUALS( placeholderMapGet.Count(), placeholderMapSet.Count(), TEST_LOCATION );
2657   DALI_TEST_EQUALS( DaliTestCheckMaps( placeholderMapGet, placeholderMapSet ), true, TEST_LOCATION );
2658
2659   // Reset font style.
2660   placeholderFontstyleMap.Clear();
2661   placeholderFontstyleMap.Insert( "weight", "normal" );
2662   placeholderFontstyleMap.Insert( "slant", "oblique" );
2663   placeholderMapSet[ Text::PlaceHolder::Property::FONT_STYLE ] = placeholderFontstyleMap;
2664   field.SetProperty( TextField::Property::PLACEHOLDER, placeholderMapSet );
2665
2666   placeholderMapGet = field.GetProperty<Property::Map>( TextField::Property::PLACEHOLDER );
2667   DALI_TEST_EQUALS( placeholderMapGet.Count(), placeholderMapSet.Count(), TEST_LOCATION );
2668   DALI_TEST_EQUALS( DaliTestCheckMaps( placeholderMapGet, placeholderMapSet ), true, TEST_LOCATION );
2669
2670   placeholderFontstyleMap.Clear();
2671   placeholderFontstyleMap.Insert( "slant", "roman" );
2672   placeholderMapSet[ Text::PlaceHolder::Property::FONT_STYLE ] = placeholderFontstyleMap;
2673   field.SetProperty( TextField::Property::PLACEHOLDER, placeholderMapSet );
2674
2675   placeholderMapGet = field.GetProperty<Property::Map>( TextField::Property::PLACEHOLDER );
2676
2677   placeholderFontstyleMap.Clear();
2678   placeholderMapSet[ Text::PlaceHolder::Property::FONT_STYLE ] = placeholderFontstyleMap;
2679
2680   field.SetProperty( TextField::Property::PLACEHOLDER, placeholderMapSet );
2681   placeholderMapGet = field.GetProperty<Property::Map>( TextField::Property::PLACEHOLDER );
2682   DALI_TEST_EQUALS( placeholderMapGet.Count(), placeholderMapSet.Count(), TEST_LOCATION );
2683   DALI_TEST_EQUALS( DaliTestCheckMaps( placeholderMapGet, placeholderMapSet ), true, TEST_LOCATION );
2684
2685   END_TEST;
2686 }