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