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