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