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