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