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