3cc605c565ecda624b3de5a1f5985153a8e5127c
[platform/core/uifw/dali-toolkit.git] / automated-tests / src / dali-toolkit / utc-Dali-TextField.cpp
1 /*
2  * Copyright (c) 2016 Samsung Electronics Co., Ltd.
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  * http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  *
16  */
17
18 #include <iostream>
19 #include <stdlib.h>
20 #include <unistd.h>
21
22 #include <dali/public-api/rendering/renderer.h>
23 #include <dali/integration-api/events/key-event-integ.h>
24 #include <dali/integration-api/events/tap-gesture-event.h>
25 #include <dali/integration-api/events/touch-event-integ.h>
26 #include <dali/integration-api/events/pan-gesture-event.h>
27 #include <dali/integration-api/events/long-press-gesture-event.h>
28 #include <dali-toolkit-test-suite-utils.h>
29 #include <dali-toolkit/dali-toolkit.h>
30
31 using namespace Dali;
32 using namespace Toolkit;
33
34 void dali_textfield_startup(void)
35 {
36   test_return_value = TET_UNDEF;
37 }
38
39 void dali_textfield_cleanup(void)
40 {
41   test_return_value = TET_PASS;
42 }
43
44 namespace
45 {
46
47 const char* const PROPERTY_NAME_RENDERING_BACKEND                    = "renderingBackend";
48 const char* const PROPERTY_NAME_TEXT                                 = "text";
49 const char* const PROPERTY_NAME_PLACEHOLDER_TEXT                     = "placeholderText";
50 const char* const PROPERTY_NAME_PLACEHOLDER_TEXT_FOCUSED             = "placeholderTextFocused";
51 const char* const PROPERTY_NAME_FONT_FAMILY                          = "fontFamily";
52 const char* const PROPERTY_NAME_FONT_STYLE                           = "fontStyle";
53 const char* const PROPERTY_NAME_POINT_SIZE                           = "pointSize";
54 const char* const PROPERTY_NAME_MAX_LENGTH                           = "maxLength";
55 const char* const PROPERTY_NAME_EXCEED_POLICY                        = "exceedPolicy";
56 const char* const PROPERTY_NAME_HORIZONTAL_ALIGNMENT                 = "horizontalAlignment";
57 const char* const PROPERTY_NAME_VERTICAL_ALIGNMENT                   = "verticalAlignment";
58 const char* const PROPERTY_NAME_TEXT_COLOR                           = "textColor";
59 const char* const PROPERTY_NAME_PLACEHOLDER_TEXT_COLOR               = "placeholderTextColor";
60 const char* const PROPERTY_NAME_SHADOW_OFFSET                        = "shadowOffset";
61 const char* const PROPERTY_NAME_SHADOW_COLOR                         = "shadowColor";
62 const char* const PROPERTY_NAME_PRIMARY_CURSOR_COLOR                 = "primaryCursorColor";
63 const char* const PROPERTY_NAME_SECONDARY_CURSOR_COLOR               = "secondaryCursorColor";
64 const char* const PROPERTY_NAME_ENABLE_CURSOR_BLINK                  = "enableCursorBlink";
65 const char* const PROPERTY_NAME_CURSOR_BLINK_INTERVAL                = "cursorBlinkInterval";
66 const char* const PROPERTY_NAME_CURSOR_BLINK_DURATION                = "cursorBlinkDuration";
67 const char* const PROPERTY_NAME_CURSOR_WIDTH                         = "cursorWidth";
68 const char* const PROPERTY_NAME_GRAB_HANDLE_IMAGE                    = "grabHandleImage";
69 const char* const PROPERTY_NAME_GRAB_HANDLE_PRESSED_IMAGE            = "grabHandlePressedImage";
70 const char* const PROPERTY_NAME_SCROLL_THRESHOLD                     = "scrollThreshold";
71 const char* const PROPERTY_NAME_SCROLL_SPEED                         = "scrollSpeed";
72 const char* const PROPERTY_NAME_SELECTION_HANDLE_IMAGE_LEFT          = "selectionHandleImageLeft";
73 const char* const PROPERTY_NAME_SELECTION_HANDLE_IMAGE_RIGHT         = "selectionHandleImageRight";
74 const char* const PROPERTY_NAME_SELECTION_HANDLE_PRESSED_IMAGE_LEFT  = "selectionHandlePressedImageLeft";
75 const char* const PROPERTY_NAME_SELECTION_HANDLE_PRESSED_IMAGE_RIGHT = "selectionHandlePressedImageRight";
76 const char* const PROPERTY_NAME_SELECTION_HANDLE_MARKER_IMAGE_LEFT   = "selectionHandleMarkerImageLeft";
77 const char* const PROPERTY_NAME_SELECTION_HANDLE_MARKER_IMAGE_RIGHT  = "selectionHandleMarkerImageRight";
78 const char* const PROPERTY_NAME_SELECTION_HIGHLIGHT_COLOR            = "selectionHighlightColor";
79 const char* const PROPERTY_NAME_DECORATION_BOUNDING_BOX              = "decorationBoundingBox";
80 const char* const PROPERTY_NAME_INPUT_METHOD_SETTINGS                = "inputMethodSettings";
81 const char* const PROPERTY_NAME_INPUT_COLOR                          = "inputColor";
82 const char* const PROPERTY_NAME_ENABLE_MARKUP                        = "enableMarkup";
83 const char* const PROPERTY_NAME_INPUT_FONT_FAMILY                    = "inputFontFamily";
84 const char* const PROPERTY_NAME_INPUT_FONT_STYLE                     = "inputFontStyle";
85 const char* const PROPERTY_NAME_INPUT_POINT_SIZE                     = "inputPointSize";
86
87 const char* const PROPERTY_NAME_UNDERLINE                            = "underline";
88 const char* const PROPERTY_NAME_INPUT_UNDERLINE                      = "inputUnderline";
89 const char* const PROPERTY_NAME_SHADOW                               = "shadow";
90 const char* const PROPERTY_NAME_INPUT_SHADOW                         = "inputShadow";
91 const char* const PROPERTY_NAME_EMBOSS                               = "emboss";
92 const char* const PROPERTY_NAME_INPUT_EMBOSS                         = "inputEmboss";
93 const char* const PROPERTY_NAME_OUTLINE                              = "outline";
94 const char* const PROPERTY_NAME_INPUT_OUTLINE                        = "inputOutline";
95
96 const int DEFAULT_RENDERING_BACKEND = Dali::Toolkit::Text::DEFAULT_RENDERING_BACKEND;
97
98 const Vector4 PLACEHOLDER_TEXT_COLOR( 0.8f, 0.8f, 0.8f, 0.8f );
99 const Dali::Vector4 LIGHT_BLUE( 0.75f, 0.96f, 1.f, 1.f ); // The text highlight color.
100
101 const unsigned int CURSOR_BLINK_INTERVAL = 500u; // Cursor blink interval
102 const float RENDER_FRAME_INTERVAL = 16.66f;
103
104 const float TO_MILLISECONDS = 1000.f;
105 const float TO_SECONDS = 1.f / TO_MILLISECONDS;
106
107 const float SCROLL_THRESHOLD = 10.f;
108 const float SCROLL_SPEED = 300.f;
109
110 const unsigned int DEFAULT_FONT_SIZE = 1152u;
111 const std::string DEFAULT_FONT_DIR( "/resources/fonts" );
112
113 static bool gTextChangedCallBackCalled;
114 static bool gMaxCharactersCallBackCalled;
115 static bool gInputStyleChangedCallbackCalled;
116 static Dali::Toolkit::TextField::InputStyle::Mask gInputStyleMask;
117
118 static void LoadBitmapResource(TestPlatformAbstraction& platform, int width, int height)
119 {
120   Integration::ResourceRequest* request = platform.GetRequest();
121   Integration::Bitmap* bitmap = Integration::Bitmap::New( Integration::Bitmap::BITMAP_2D_PACKED_PIXELS, ResourcePolicy::OWNED_DISCARD );
122   Integration::ResourcePointer resource(bitmap);
123   bitmap->GetPackedPixelsProfile()->ReserveBuffer(Pixel::RGBA8888, width, height, width, height);
124
125   if(request)
126   {
127     platform.SetResourceLoaded(request->GetId(), request->GetType()->id, resource);
128   }
129 }
130
131 static void LoadMarkerImages(ToolkitTestApplication& app, TextField textField)
132 {
133   int width(40);
134   int height(40);
135   LoadBitmapResource( app.GetPlatform(), width, height );
136
137   Property::Map propertyMap;
138   propertyMap["filename"] = "image.png";
139   propertyMap["width"] = width;
140   propertyMap["height"] = height;
141   textField.SetProperty( Toolkit::TextField::Property::SELECTION_HANDLE_IMAGE_LEFT, propertyMap );
142   textField.SetProperty( Toolkit::TextField::Property::SELECTION_HANDLE_IMAGE_RIGHT, propertyMap );
143   textField.SetProperty( Toolkit::TextField::Property::SELECTION_HANDLE_PRESSED_IMAGE_LEFT, propertyMap );
144   textField.SetProperty( Toolkit::TextField::Property::SELECTION_HANDLE_PRESSED_IMAGE_RIGHT, propertyMap );
145   textField.SetProperty( Toolkit::TextField::Property::SELECTION_HANDLE_MARKER_IMAGE_LEFT, propertyMap );
146   textField.SetProperty( Toolkit::TextField::Property::SELECTION_HANDLE_MARKER_IMAGE_RIGHT, propertyMap );
147   textField.SetProperty( Toolkit::TextField::Property::GRAB_HANDLE_IMAGE, propertyMap );
148   textField.SetProperty( Toolkit::TextField::Property::GRAB_HANDLE_PRESSED_IMAGE, propertyMap );
149 }
150
151 // Generate a PanGestureEvent to send to Core
152 static Integration::PanGestureEvent GeneratePan(
153     Gesture::State state,
154     const Vector2& previousPosition,
155     const Vector2& currentPosition,
156     unsigned long timeDelta,
157     unsigned int numberOfTouches = 1)
158 {
159   Integration::PanGestureEvent pan(state);
160
161   pan.previousPosition = previousPosition;
162   pan.currentPosition = currentPosition;
163   pan.timeDelta = timeDelta;
164   pan.numberOfTouches = numberOfTouches;
165
166   return pan;
167 }
168
169 /**
170  * Helper to generate PanGestureEvent
171  *
172  * @param[in] application Application instance
173  * @param[in] state The Gesture State
174  * @param[in] pos The current position of touch.
175  */
176 static void SendPan(ToolkitTestApplication& application, Gesture::State state, const Vector2& pos)
177 {
178   static Vector2 last;
179
180   if( (state == Gesture::Started) ||
181       (state == Gesture::Possible) )
182   {
183     last.x = pos.x;
184     last.y = pos.y;
185   }
186
187   application.ProcessEvent(GeneratePan(state, last, pos, 16));
188
189   last.x = pos.x;
190   last.y = pos.y;
191 }
192
193 /*
194  * Simulate time passed by.
195  *
196  * @note this will always process at least 1 frame (1/60 sec)
197  *
198  * @param application Test application instance
199  * @param duration Time to pass in milliseconds.
200  * @return The actual time passed in milliseconds
201  */
202 static int Wait(ToolkitTestApplication& application, int duration = 0)
203 {
204   int time = 0;
205
206   for(int i = 0; i <= ( duration / RENDER_FRAME_INTERVAL); i++)
207   {
208     application.SendNotification();
209     application.Render(RENDER_FRAME_INTERVAL);
210     time += RENDER_FRAME_INTERVAL;
211   }
212
213   return time;
214 }
215
216 struct CallbackFunctor
217 {
218   CallbackFunctor(bool* callbackFlag)
219   : mCallbackFlag( callbackFlag )
220   {
221   }
222
223   void operator()()
224   {
225     *mCallbackFlag = true;
226   }
227   bool* mCallbackFlag;
228 };
229
230 static void TestTextChangedCallback( TextField control )
231 {
232   tet_infoline(" TestTextChangedCallback");
233
234   gTextChangedCallBackCalled = true;
235 }
236
237 static void TestMaxLengthReachedCallback( TextField control )
238 {
239   tet_infoline(" TestMaxLengthReachedCallback");
240
241   gMaxCharactersCallBackCalled = true;
242 }
243
244 static void TestInputStyleChangedCallback( TextField control, TextField::InputStyle::Mask mask )
245 {
246   tet_infoline(" TestInputStyleChangedCallback");
247
248   gInputStyleChangedCallbackCalled = true;
249   gInputStyleMask = mask;
250 }
251
252 // Generate a TapGestureEvent to send to Core.
253 Integration::TapGestureEvent GenerateTap(
254     Gesture::State state,
255     unsigned int numberOfTaps,
256     unsigned int numberOfTouches,
257     Vector2 point)
258 {
259   Integration::TapGestureEvent tap( state );
260
261   tap.numberOfTaps = numberOfTaps;
262   tap.numberOfTouches = numberOfTouches;
263   tap.point = point;
264
265   return tap;
266 }
267
268
269 Integration::LongPressGestureEvent GenerateLongPress(
270     Gesture::State state,
271     unsigned int numberOfTouches,
272     Vector2 point)
273 {
274   Integration::LongPressGestureEvent longPress( state );
275
276   longPress.numberOfTouches = numberOfTouches;
277   longPress.point = point;
278   return longPress;
279 }
280
281 // Generate a KeyEvent to send to Core.
282 Integration::KeyEvent GenerateKey( const std::string& keyName,
283                                    const std::string& keyString,
284                                    int keyCode,
285                                    int keyModifier,
286                                    unsigned long timeStamp,
287                                    const Integration::KeyEvent::State& keyState )
288 {
289   return Integration::KeyEvent( keyName,
290                                 keyString,
291                                 keyCode,
292                                 keyModifier,
293                                 timeStamp,
294                                 keyState );
295 }
296
297 } // namespace
298
299 int UtcDaliToolkitTextFieldConstructorP(void)
300 {
301   ToolkitTestApplication application;
302   tet_infoline(" UtcDaliToolkitTextFieldConstructorP");
303   TextField textField;
304   DALI_TEST_CHECK( !textField );
305   END_TEST;
306 }
307
308 int UtcDaliToolkitTextFieldNewP(void)
309 {
310   ToolkitTestApplication application;
311   tet_infoline(" UtcDaliToolkitTextFieldNewP");
312   TextField textField = TextField::New();
313   DALI_TEST_CHECK( textField );
314   END_TEST;
315 }
316
317 int UtcDaliToolkitTextFieldDownCastP(void)
318 {
319   ToolkitTestApplication application;
320   tet_infoline(" UtcDaliToolkitTextFieldDownCastP");
321   TextField textField1 = TextField::New();
322   BaseHandle object( textField1 );
323
324   TextField textField2 = TextField::DownCast( object );
325   DALI_TEST_CHECK( textField2 );
326
327   TextField textField3 = DownCast< TextField >( object );
328   DALI_TEST_CHECK( textField3 );
329   END_TEST;
330 }
331
332 int UtcDaliToolkitTextFieldDownCastN(void)
333 {
334   ToolkitTestApplication application;
335   tet_infoline(" UtcDaliToolkitTextFieldDownCastN");
336   BaseHandle uninitializedObject;
337   TextField textField1 = TextField::DownCast( uninitializedObject );
338   DALI_TEST_CHECK( !textField1 );
339
340   TextField textField2 = DownCast< TextField >( uninitializedObject );
341   DALI_TEST_CHECK( !textField2 );
342   END_TEST;
343 }
344
345 int UtcDaliToolkitTextFieldCopyConstructorP(void)
346 {
347   ToolkitTestApplication application;
348   tet_infoline(" UtcDaliToolkitTextFieldCopyConstructorP");
349   TextField textField = TextField::New();
350   textField.SetProperty( TextField::Property::TEXT, "Test" );
351
352   TextField copy( textField );
353   DALI_TEST_CHECK( copy );
354   DALI_TEST_CHECK( copy.GetProperty<std::string>( TextLabel::Property::TEXT ) == textField.GetProperty<std::string>( TextLabel::Property::TEXT ) );
355   END_TEST;
356 }
357
358 int UtcDaliToolkitTextFieldAssignmentOperatorP(void)
359 {
360   ToolkitTestApplication application;
361   tet_infoline(" UtcDaliToolkitTextFieldAssignmentOperatorP");
362   TextField textField = TextField::New();
363   textField.SetProperty( TextField::Property::TEXT, "Test" );
364
365   TextField copy = textField;
366   DALI_TEST_CHECK( copy );
367   DALI_TEST_CHECK( copy.GetProperty<std::string>( TextField::Property::TEXT ) == textField.GetProperty<std::string>( TextField::Property::TEXT ) );
368   END_TEST;
369 }
370
371 int UtcDaliTextFieldNewP(void)
372 {
373   ToolkitTestApplication application;
374   tet_infoline(" UtcDaliToolkitTextFieldNewP");
375   TextField textField = TextField::New();
376   DALI_TEST_CHECK( textField );
377   END_TEST;
378 }
379
380 // Positive test case for a method
381 int UtcDaliTextFieldGetPropertyP(void)
382 {
383   ToolkitTestApplication application;
384   tet_infoline(" UtcDaliToolkitTextFieldGetPropertyP");
385   TextField field = TextField::New();
386   DALI_TEST_CHECK( field );
387
388   // Check Property Indices are correct
389   DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_RENDERING_BACKEND ) == TextField::Property::RENDERING_BACKEND );
390   DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_TEXT ) == TextField::Property::TEXT );
391   DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_PLACEHOLDER_TEXT ) == TextField::Property::PLACEHOLDER_TEXT );
392   DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_PLACEHOLDER_TEXT_FOCUSED ) == TextField::Property::PLACEHOLDER_TEXT_FOCUSED );
393   DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_FONT_FAMILY ) == TextField::Property::FONT_FAMILY );
394   DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_FONT_STYLE ) == TextField::Property::FONT_STYLE );
395   DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_POINT_SIZE ) == TextField::Property::POINT_SIZE );
396   DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_MAX_LENGTH ) == TextField::Property::MAX_LENGTH );
397   DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_EXCEED_POLICY ) == TextField::Property::EXCEED_POLICY );
398   DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_HORIZONTAL_ALIGNMENT ) == TextField::Property::HORIZONTAL_ALIGNMENT );
399   DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_VERTICAL_ALIGNMENT ) == TextField::Property::VERTICAL_ALIGNMENT );
400   DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_TEXT_COLOR ) == TextField::Property::TEXT_COLOR );
401   DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_PLACEHOLDER_TEXT_COLOR ) == TextField::Property::PLACEHOLDER_TEXT_COLOR );
402   DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_SHADOW_OFFSET ) == TextField::Property::SHADOW_OFFSET );
403   DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_SHADOW_COLOR ) == TextField::Property::SHADOW_COLOR );
404   DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_PRIMARY_CURSOR_COLOR ) == TextField::Property::PRIMARY_CURSOR_COLOR );
405   DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_SECONDARY_CURSOR_COLOR ) == TextField::Property::SECONDARY_CURSOR_COLOR );
406   DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_ENABLE_CURSOR_BLINK ) == TextField::Property::ENABLE_CURSOR_BLINK );
407   DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_CURSOR_BLINK_INTERVAL ) == TextField::Property::CURSOR_BLINK_INTERVAL );
408   DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_CURSOR_BLINK_DURATION ) == TextField::Property::CURSOR_BLINK_DURATION );
409   DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_CURSOR_WIDTH ) == TextField::Property::CURSOR_WIDTH );
410   DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_GRAB_HANDLE_IMAGE ) == TextField::Property::GRAB_HANDLE_IMAGE );
411   DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_GRAB_HANDLE_PRESSED_IMAGE ) == TextField::Property::GRAB_HANDLE_PRESSED_IMAGE );
412   DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_SCROLL_THRESHOLD ) == TextField::Property::SCROLL_THRESHOLD );
413   DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_SCROLL_SPEED ) == TextField::Property::SCROLL_SPEED );
414   DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_SELECTION_HANDLE_IMAGE_LEFT ) == TextField::Property::SELECTION_HANDLE_IMAGE_LEFT );
415   DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_SELECTION_HANDLE_IMAGE_RIGHT ) == TextField::Property::SELECTION_HANDLE_IMAGE_RIGHT );
416   DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_SELECTION_HANDLE_PRESSED_IMAGE_LEFT ) == TextField::Property::SELECTION_HANDLE_PRESSED_IMAGE_LEFT );
417   DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_SELECTION_HANDLE_PRESSED_IMAGE_RIGHT ) == TextField::Property::SELECTION_HANDLE_PRESSED_IMAGE_RIGHT );
418   DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_SELECTION_HANDLE_MARKER_IMAGE_LEFT ) == TextField::Property::SELECTION_HANDLE_MARKER_IMAGE_LEFT );
419   DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_SELECTION_HANDLE_MARKER_IMAGE_RIGHT ) == TextField::Property::SELECTION_HANDLE_MARKER_IMAGE_RIGHT );
420   DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_SELECTION_HIGHLIGHT_COLOR ) == TextField::Property::SELECTION_HIGHLIGHT_COLOR );
421   DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_DECORATION_BOUNDING_BOX ) == TextField::Property::DECORATION_BOUNDING_BOX );
422   DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_INPUT_METHOD_SETTINGS ) == TextField::Property::INPUT_METHOD_SETTINGS );
423   DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_INPUT_COLOR ) == TextField::Property::INPUT_COLOR );
424   DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_ENABLE_MARKUP ) == TextField::Property::ENABLE_MARKUP );
425   DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_INPUT_FONT_FAMILY ) == TextField::Property::INPUT_FONT_FAMILY );
426   DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_INPUT_FONT_STYLE ) == TextField::Property::INPUT_FONT_STYLE );
427   DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_INPUT_POINT_SIZE ) == TextField::Property::INPUT_POINT_SIZE );
428   DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_UNDERLINE ) == TextField::Property::UNDERLINE );
429   DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_INPUT_UNDERLINE ) == TextField::Property::INPUT_UNDERLINE );
430   DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_SHADOW ) == TextField::Property::SHADOW );
431   DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_INPUT_SHADOW ) == TextField::Property::INPUT_SHADOW );
432   DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_EMBOSS ) == TextField::Property::EMBOSS );
433   DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_INPUT_EMBOSS ) == TextField::Property::INPUT_EMBOSS );
434   DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_OUTLINE ) == TextField::Property::OUTLINE );
435   DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_INPUT_OUTLINE ) == TextField::Property::INPUT_OUTLINE );
436
437   END_TEST;
438 }
439
440 bool SetPropertyMapRetrieved( TextField& field, const Property::Index property, const std::string mapKey, const std::string mapValue )
441 {
442   bool result = false;
443   Property::Map imageMap;
444   imageMap[mapKey] =mapValue;
445
446   field.SetProperty( property , imageMap );
447   Property::Value propValue = field.GetProperty( property );
448   Property::Map* resultMap = propValue.GetMap();
449
450   if ( resultMap->Find( mapKey )->Get< std::string>() == mapValue )
451   {
452     result = true;
453   }
454
455   return result;
456 }
457
458 // Positive test case for a method
459 int UtcDaliTextFieldSetPropertyP(void)
460 {
461   ToolkitTestApplication application;
462   tet_infoline(" UtcDaliToolkitTextFieldSetPropertyP");
463   TextField field = TextField::New();
464   DALI_TEST_CHECK( field );
465   Stage::GetCurrent().Add( field );
466
467   // Note - we can't check the defaults since the stylesheets are platform-specific
468
469   // Check the render backend property.
470   field.SetProperty( TextField::Property::RENDERING_BACKEND, Text::RENDERING_SHARED_ATLAS );
471   DALI_TEST_EQUALS( (Text::RenderingType)field.GetProperty<int>( TextField::Property::RENDERING_BACKEND ), Text::RENDERING_SHARED_ATLAS, TEST_LOCATION );
472
473   // Check text property.
474   field.SetProperty( TextField::Property::TEXT, "Setting Text" );
475   DALI_TEST_EQUALS( field.GetProperty<std::string>( TextField::Property::TEXT ), std::string("Setting Text"), TEST_LOCATION );
476
477   // Check placeholder text properties.
478   field.SetProperty( TextField::Property::PLACEHOLDER_TEXT, "Setting Placeholder Text" );
479   DALI_TEST_EQUALS( field.GetProperty<std::string>( TextField::Property::PLACEHOLDER_TEXT ), std::string("Setting Placeholder Text"), TEST_LOCATION );
480
481   field.SetProperty( TextField::Property::PLACEHOLDER_TEXT_FOCUSED, "Setting Placeholder Text Focused" );
482   DALI_TEST_EQUALS( field.GetProperty<std::string>( TextField::Property::PLACEHOLDER_TEXT_FOCUSED ), std::string("Setting Placeholder Text Focused"), TEST_LOCATION );
483
484   // Check font properties.
485   field.SetProperty( TextField::Property::FONT_FAMILY, "Setting font family" );
486   DALI_TEST_EQUALS( field.GetProperty<std::string>( TextField::Property::FONT_FAMILY ), std::string("Setting font family"), TEST_LOCATION );
487   field.SetProperty( TextField::Property::FONT_STYLE, "{\"weight\":\"bold\",\"width\":\"condensed\",\"slant\":\"italic\"}" );
488   DALI_TEST_EQUALS( field.GetProperty<std::string>( TextField::Property::FONT_STYLE ), std::string("{\"weight\":\"bold\",\"width\":\"condensed\",\"slant\":\"italic\"}"), TEST_LOCATION );
489   field.SetProperty( TextField::Property::POINT_SIZE, 10.f );
490   DALI_TEST_EQUALS( field.GetProperty<float>( TextField::Property::POINT_SIZE ), 10.f, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
491
492   // Reset font style.
493   field.SetProperty( TextField::Property::FONT_STYLE, "{\"weight\":\"normal\",\"slant\":\"oblique\"}" );
494   DALI_TEST_EQUALS( field.GetProperty<std::string>( TextField::Property::FONT_STYLE ), std::string("{\"weight\":\"normal\",\"slant\":\"oblique\"}"), TEST_LOCATION );
495   field.SetProperty( TextField::Property::FONT_STYLE, "{\"slant\":\"roman\"}" );
496   DALI_TEST_EQUALS( field.GetProperty<std::string>( TextField::Property::FONT_STYLE ), std::string("{\"slant\":\"normal\"}"), TEST_LOCATION );
497   field.SetProperty( TextField::Property::FONT_STYLE, "" );
498   DALI_TEST_EQUALS( field.GetProperty<std::string>( TextField::Property::FONT_STYLE ), std::string(""), TEST_LOCATION );
499
500   // Check that the MAX_LENGTH property can be correctly set
501   const int maxNumberOfCharacters = 20;
502   field.SetProperty( TextField::Property::MAX_LENGTH, maxNumberOfCharacters );
503   DALI_TEST_EQUALS( field.GetProperty<int>( TextField::Property::MAX_LENGTH ), maxNumberOfCharacters, TEST_LOCATION );
504
505   // Check exceed policy
506   // Set a different exceed policy is not implemented.
507
508   // Check that the Alignment properties can be correctly set
509   field.SetProperty( TextField::Property::HORIZONTAL_ALIGNMENT, "END" );
510   DALI_TEST_EQUALS( field.GetProperty<std::string>( TextField::Property::HORIZONTAL_ALIGNMENT ), "END", TEST_LOCATION );
511   field.SetProperty( TextField::Property::VERTICAL_ALIGNMENT, "CENTER" );
512   DALI_TEST_EQUALS( field.GetProperty<std::string>( TextField::Property::VERTICAL_ALIGNMENT ), "CENTER", TEST_LOCATION );
513
514   // Check text's color property
515   field.SetProperty( TextField::Property::TEXT_COLOR, Color::WHITE );
516   DALI_TEST_EQUALS( field.GetProperty<Vector4>( TextField::Property::TEXT_COLOR ), Color::WHITE, TEST_LOCATION );
517
518   // Check placeholder text's color property.
519   field.SetProperty( TextField::Property::PLACEHOLDER_TEXT_COLOR, Color::RED );
520   DALI_TEST_EQUALS( field.GetProperty<Vector4>( TextField::Property::PLACEHOLDER_TEXT_COLOR ), Color::RED, TEST_LOCATION );
521
522   // Check shadow properties.
523   field.SetProperty( TextField::Property::SHADOW_OFFSET, Vector2( 1.f, 1.f ) );
524   DALI_TEST_EQUALS( field.GetProperty<Vector2>( TextField::Property::SHADOW_OFFSET ), Vector2( 1.f, 1.f ), TEST_LOCATION );
525   field.SetProperty( TextField::Property::SHADOW_COLOR, Color::GREEN );
526   DALI_TEST_EQUALS( field.GetProperty<Vector4>( TextField::Property::SHADOW_COLOR ), Color::GREEN, TEST_LOCATION );
527
528   // Check cursor properties
529   field.SetProperty( TextField::Property::PRIMARY_CURSOR_COLOR, Color::RED );
530   DALI_TEST_EQUALS( field.GetProperty<Vector4>( TextField::Property::PRIMARY_CURSOR_COLOR ), Color::RED, TEST_LOCATION );
531   field.SetProperty( TextField::Property::SECONDARY_CURSOR_COLOR, Color::BLUE );
532   DALI_TEST_EQUALS( field.GetProperty<Vector4>( TextField::Property::SECONDARY_CURSOR_COLOR ), Color::BLUE, TEST_LOCATION );
533
534   field.SetProperty( TextField::Property::ENABLE_CURSOR_BLINK, false );
535   DALI_TEST_EQUALS( field.GetProperty<bool>( TextField::Property::ENABLE_CURSOR_BLINK ), false, TEST_LOCATION );
536   field.SetProperty( TextField::Property::CURSOR_BLINK_INTERVAL, 1.f );
537   DALI_TEST_EQUALS( field.GetProperty<float>( TextField::Property::CURSOR_BLINK_INTERVAL ), 1.f, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
538   field.SetProperty( TextField::Property::CURSOR_BLINK_DURATION, 10.f );
539   DALI_TEST_EQUALS( field.GetProperty<float>( TextField::Property::CURSOR_BLINK_DURATION ), 10.f, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
540   field.SetProperty( TextField::Property::CURSOR_WIDTH, 1 );
541   DALI_TEST_EQUALS( field.GetProperty<int>( TextField::Property::CURSOR_WIDTH ), 1, TEST_LOCATION );
542
543   // Check scroll properties.
544   field.SetProperty( TextField::Property::SCROLL_THRESHOLD, 1.f );
545   DALI_TEST_EQUALS( field.GetProperty<float>( TextField::Property::SCROLL_THRESHOLD ), 1.f, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
546   field.SetProperty( TextField::Property::SCROLL_SPEED, 100.f );
547   DALI_TEST_EQUALS( field.GetProperty<float>( TextField::Property::SCROLL_SPEED ), 100.f, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
548
549   // Check handle images
550   field.SetProperty( TextField::Property::GRAB_HANDLE_IMAGE, "image1" );
551   DALI_TEST_EQUALS( field.GetProperty<std::string>( TextField::Property::GRAB_HANDLE_IMAGE ), "image1", TEST_LOCATION );
552   field.SetProperty( TextField::Property::GRAB_HANDLE_PRESSED_IMAGE, "image2" );
553   DALI_TEST_EQUALS( field.GetProperty<std::string>( TextField::Property::GRAB_HANDLE_PRESSED_IMAGE ), "image2", TEST_LOCATION );
554   field.SetProperty( TextField::Property::SELECTION_HANDLE_IMAGE_LEFT, "image3" );
555
556   // Check handle images
557   DALI_TEST_CHECK( SetPropertyMapRetrieved( field, TextField::Property::SELECTION_HANDLE_IMAGE_LEFT, "filename", "leftHandleImage" )  );
558   DALI_TEST_CHECK( SetPropertyMapRetrieved( field, TextField::Property::SELECTION_HANDLE_IMAGE_RIGHT, "filename", "rightHandleImage" )  );
559   DALI_TEST_CHECK( SetPropertyMapRetrieved( field, TextField::Property::SELECTION_HANDLE_PRESSED_IMAGE_LEFT, "filename", "leftHandleImagePressed" )  );
560   DALI_TEST_CHECK( SetPropertyMapRetrieved( field, TextField::Property::SELECTION_HANDLE_PRESSED_IMAGE_RIGHT, "filename", "rightHandleImagePressed" )  );
561   DALI_TEST_CHECK( SetPropertyMapRetrieved( field, TextField::Property::SELECTION_HANDLE_MARKER_IMAGE_LEFT, "filename", "leftHandleMarkerImage" )  );
562   DALI_TEST_CHECK( SetPropertyMapRetrieved( field, TextField::Property::SELECTION_HANDLE_MARKER_IMAGE_RIGHT, "filename", "rightHandleMarkerImage" )  );
563
564   // Check the highlight color
565   field.SetProperty( TextField::Property::SELECTION_HIGHLIGHT_COLOR, Color::GREEN );
566   DALI_TEST_EQUALS( field.GetProperty<Vector4>( TextField::Property::SELECTION_HIGHLIGHT_COLOR ), Color::GREEN, TEST_LOCATION );
567
568   // Decoration bounding box
569   field.SetProperty( TextField::Property::DECORATION_BOUNDING_BOX, Rect<int>( 0, 0, 1, 1 ) );
570   DALI_TEST_EQUALS( field.GetProperty<Rect <int > >( TextField::Property::DECORATION_BOUNDING_BOX ), Rect<int>( 0, 0, 1, 1 ), TEST_LOCATION );
571
572   // Check input color property.
573   field.SetProperty( TextField::Property::INPUT_COLOR, Color::YELLOW );
574   DALI_TEST_EQUALS( field.GetProperty<Vector4>( TextField::Property::INPUT_COLOR ), Color::YELLOW, TEST_LOCATION );
575
576   // Check the enable markup property.
577   DALI_TEST_CHECK( !field.GetProperty<bool>( TextField::Property::ENABLE_MARKUP ) );
578   field.SetProperty( TextField::Property::ENABLE_MARKUP, true );
579   DALI_TEST_CHECK( field.GetProperty<bool>( TextField::Property::ENABLE_MARKUP ) );
580
581   // Check input font properties.
582   field.SetProperty( TextField::Property::INPUT_FONT_FAMILY, "Setting input font family" );
583   DALI_TEST_EQUALS( field.GetProperty<std::string>( TextField::Property::INPUT_FONT_FAMILY ), "Setting input font family", TEST_LOCATION );
584   field.SetProperty( TextField::Property::INPUT_FONT_STYLE, "{\"weight\":\"bold\",\"width\":\"condensed\",\"slant\":\"italic\"}" );
585   DALI_TEST_EQUALS( field.GetProperty<std::string>( TextField::Property::INPUT_FONT_STYLE ), "{\"weight\":\"bold\",\"width\":\"condensed\",\"slant\":\"italic\"}", TEST_LOCATION );
586   field.SetProperty( TextField::Property::INPUT_POINT_SIZE, 12.f );
587   DALI_TEST_EQUALS( field.GetProperty<float>( TextField::Property::INPUT_POINT_SIZE ), 12.f, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
588
589   // Reset input font style.
590   field.SetProperty( TextField::Property::INPUT_FONT_STYLE, "{\"weight\":\"normal\",\"slant\":\"oblique\"}" );
591   DALI_TEST_EQUALS( field.GetProperty<std::string>( TextField::Property::INPUT_FONT_STYLE ), std::string("{\"weight\":\"normal\",\"slant\":\"oblique\"}"), TEST_LOCATION );
592   field.SetProperty( TextField::Property::INPUT_FONT_STYLE, "{\"slant\":\"roman\"}" );
593   DALI_TEST_EQUALS( field.GetProperty<std::string>( TextField::Property::INPUT_FONT_STYLE ), std::string("{\"slant\":\"normal\"}"), TEST_LOCATION );
594   field.SetProperty( TextField::Property::INPUT_FONT_STYLE, "" );
595   DALI_TEST_EQUALS( field.GetProperty<std::string>( TextField::Property::INPUT_FONT_STYLE ), std::string(""), TEST_LOCATION );
596
597   // Check the underline property
598   field.SetProperty( TextField::Property::UNDERLINE, "Underline properties" );
599   DALI_TEST_EQUALS( field.GetProperty<std::string>( TextField::Property::UNDERLINE ), std::string("Underline properties"), TEST_LOCATION );
600
601   // Check the input underline property
602   field.SetProperty( TextField::Property::INPUT_UNDERLINE, "Underline input properties" );
603   DALI_TEST_EQUALS( field.GetProperty<std::string>( TextField::Property::INPUT_UNDERLINE ), std::string("Underline input properties"), TEST_LOCATION );
604
605   // Check the shadow property
606   field.SetProperty( TextField::Property::SHADOW, "Shadow properties" );
607   DALI_TEST_EQUALS( field.GetProperty<std::string>( TextField::Property::SHADOW ), std::string("Shadow properties"), TEST_LOCATION );
608
609   // Check the input shadow property
610   field.SetProperty( TextField::Property::INPUT_SHADOW, "Shadow input properties" );
611   DALI_TEST_EQUALS( field.GetProperty<std::string>( TextField::Property::INPUT_SHADOW ), std::string("Shadow input properties"), TEST_LOCATION );
612
613   // Check the emboss property
614   field.SetProperty( TextField::Property::EMBOSS, "Emboss properties" );
615   DALI_TEST_EQUALS( field.GetProperty<std::string>( TextField::Property::EMBOSS ), std::string("Emboss properties"), TEST_LOCATION );
616
617   // Check the input emboss property
618   field.SetProperty( TextField::Property::INPUT_EMBOSS, "Emboss input properties" );
619   DALI_TEST_EQUALS( field.GetProperty<std::string>( TextField::Property::INPUT_EMBOSS ), std::string("Emboss input properties"), TEST_LOCATION );
620
621   // Check the outline property
622   field.SetProperty( TextField::Property::OUTLINE, "Outline properties" );
623   DALI_TEST_EQUALS( field.GetProperty<std::string>( TextField::Property::OUTLINE ), std::string("Outline properties"), TEST_LOCATION );
624
625   // Check the input outline property
626   field.SetProperty( TextField::Property::INPUT_OUTLINE, "Outline input properties" );
627   DALI_TEST_EQUALS( field.GetProperty<std::string>( TextField::Property::INPUT_OUTLINE ), std::string("Outline input properties"), TEST_LOCATION );
628
629   END_TEST;
630 }
631
632 // Positive Atlas Text Renderer test
633 int utcDaliTextFieldAtlasRenderP(void)
634 {
635   ToolkitTestApplication application;
636   tet_infoline(" UtcDaliToolkitTextFieldAtlasRenderP");
637   StyleManager styleManager = StyleManager::Get();
638   styleManager.ApplyDefaultTheme();
639   TextField field = TextField::New();
640   DALI_TEST_CHECK( field );
641
642   field.SetProperty( TextField::Property::HORIZONTAL_ALIGNMENT, "CENTER" );
643
644   application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
645
646   Stage::GetCurrent().Add( field );
647
648   try
649   {
650     // Render some text with the shared atlas backend
651     field.SetProperty( TextField::Property::RENDERING_BACKEND, Text::RENDERING_SHARED_ATLAS );
652     application.SendNotification();
653     application.Render();
654   }
655   catch( ... )
656   {
657     tet_result(TET_FAIL);
658   }
659   END_TEST;
660 }
661
662 // Positive test for the textChanged signal.
663 int utcDaliTextFieldTextChangedP(void)
664 {
665   ToolkitTestApplication application;
666   tet_infoline(" utcDaliTextFieldTextChangedP");
667   TextField field = TextField::New();
668   DALI_TEST_CHECK( field );
669
670   Stage::GetCurrent().Add( field );
671
672   // connect to the text changed signal.
673   ConnectionTracker* testTracker = new ConnectionTracker();
674   field.TextChangedSignal().Connect(&TestTextChangedCallback);
675   bool textChangedSignal = false;
676   field.ConnectSignal( testTracker, "textChanged",   CallbackFunctor(&textChangedSignal) );
677
678   gTextChangedCallBackCalled = false;
679   field.SetProperty( TextField::Property::TEXT, "ABC" );
680   DALI_TEST_CHECK( gTextChangedCallBackCalled );
681   DALI_TEST_CHECK( textChangedSignal );
682
683   application.SendNotification();
684
685   field.SetKeyInputFocus();
686
687   gTextChangedCallBackCalled = false;
688   application.ProcessEvent( GenerateKey( "D", "D", 0, 0, 0, Integration::KeyEvent::Down ) );
689   DALI_TEST_CHECK( gTextChangedCallBackCalled );
690
691   END_TEST;
692 }
693
694 // Negative test for the textChanged signal.
695 int utcDaliTextFieldTextChangedN(void)
696 {
697   ToolkitTestApplication application;
698   tet_infoline(" utcDaliTextFieldTextChangedN");
699   TextField field = TextField::New();
700   DALI_TEST_CHECK( field );
701
702   Stage::GetCurrent().Add( field );
703
704   // connect to the text changed signal.
705   ConnectionTracker* testTracker = new ConnectionTracker();
706   field.TextChangedSignal().Connect(&TestTextChangedCallback);
707   bool textChangedSignal = false;
708   field.ConnectSignal( testTracker, "textChanged",   CallbackFunctor(&textChangedSignal) );
709
710   gTextChangedCallBackCalled = false;
711   field.SetProperty( TextField::Property::PLACEHOLDER_TEXT, "ABC" ); // Setting placeholder, not TEXT
712   DALI_TEST_CHECK( !gTextChangedCallBackCalled );
713   DALI_TEST_CHECK( !textChangedSignal );
714
715   END_TEST;
716 }
717
718 // Positive test for Max Characters reached signal.
719 int utcDaliTextFieldMaxCharactersReachedP(void)
720 {
721   ToolkitTestApplication application;
722   tet_infoline(" utcDaliTextFieldMaxCharactersReachedP");
723   TextField field = TextField::New();
724   DALI_TEST_CHECK( field );
725
726   Stage::GetCurrent().Add( field );
727
728   const int maxNumberOfCharacters = 1;
729   field.SetProperty( TextField::Property::MAX_LENGTH, maxNumberOfCharacters );
730
731   field.SetKeyInputFocus();
732
733   // connect to the text changed signal.
734   ConnectionTracker* testTracker = new ConnectionTracker();
735   field.MaxLengthReachedSignal().Connect(&TestMaxLengthReachedCallback);
736   bool maxLengthReachedSignal = false;
737   field.ConnectSignal( testTracker, "maxLengthReached",   CallbackFunctor(&maxLengthReachedSignal) );
738
739   gMaxCharactersCallBackCalled = false;
740
741   application.ProcessEvent( GenerateKey( "a", "a", 0, 0, 0, Integration::KeyEvent::Down ) );
742   application.ProcessEvent( GenerateKey( "a", "a", 0, 0, 0, Integration::KeyEvent::Down ) );
743
744   DALI_TEST_CHECK( gMaxCharactersCallBackCalled );
745   DALI_TEST_CHECK( maxLengthReachedSignal );
746
747   END_TEST;
748 }
749
750 // Negative test for Max Characters reached signal.
751 int utcDaliTextFieldMaxCharactersReachedN(void)
752 {
753   ToolkitTestApplication application;
754   tet_infoline(" utcDaliTextFieldMaxCharactersReachedN");
755   TextField field = TextField::New();
756   DALI_TEST_CHECK( field );
757
758   Stage::GetCurrent().Add( field );
759
760   const int maxNumberOfCharacters = 3;
761   field.SetProperty( TextField::Property::MAX_LENGTH, maxNumberOfCharacters );
762
763   field.SetKeyInputFocus();
764
765   // connect to the text changed signal.
766   ConnectionTracker* testTracker = new ConnectionTracker();
767   field.MaxLengthReachedSignal().Connect(&TestMaxLengthReachedCallback);
768   bool maxLengthReachedSignal = false;
769   field.ConnectSignal( testTracker, "maxLengthReached",   CallbackFunctor(&maxLengthReachedSignal) );
770
771   gMaxCharactersCallBackCalled = false;
772
773   application.ProcessEvent( GenerateKey( "a", "a", 0, 0, 0, Integration::KeyEvent::Down ) );
774   application.ProcessEvent( GenerateKey( "a", "a", 0, 0, 0, Integration::KeyEvent::Down ) );
775
776   DALI_TEST_CHECK( !gMaxCharactersCallBackCalled );
777   DALI_TEST_CHECK( !maxLengthReachedSignal );
778
779   END_TEST;
780 }
781
782 int utcDaliTextFieldInputStyleChanged01(void)
783 {
784   ToolkitTestApplication application;
785   tet_infoline(" utcDaliTextFieldInputStyleChanged01");
786
787   // The text-field emits signals when the input style changes. These changes of style are
788   // detected during the relayout process (size negotiation), i.e after the cursor has been moved. Signals
789   // can't be emitted during the size negotiation as the callbacks may update the UI.
790   // The text-field adds an idle callback to the adaptor to emit the signals after the size negotiation.
791   // This creates an implementation of the adaptor stub and a queue of idle callbacks.
792   application.CreateAdaptor();
793
794   // Load some fonts.
795
796   char* pathNamePtr = get_current_dir_name();
797   const std::string pathName( pathNamePtr );
798   free( pathNamePtr );
799
800   TextAbstraction::FontClient fontClient = TextAbstraction::FontClient::Get();
801   fontClient.SetDpi( 93u, 93u );
802
803   fontClient.GetFontId( pathName + DEFAULT_FONT_DIR + "/dejavu/DejaVuSerif.ttf", DEFAULT_FONT_SIZE );
804   fontClient.GetFontId( pathName + DEFAULT_FONT_DIR + "/dejavu/DejaVuSerif-Bold.ttf", DEFAULT_FONT_SIZE );
805
806   TextField field = TextField::New();
807   DALI_TEST_CHECK( field );
808
809
810   field.SetSize( 300.f, 50.f );
811   field.SetParentOrigin( ParentOrigin::TOP_LEFT );
812   field.SetAnchorPoint( AnchorPoint::TOP_LEFT );
813
814   field.SetProperty( TextField::Property::ENABLE_MARKUP, true );
815   field.SetProperty( TextField::Property::TEXT, "<font family='DejaVuSerif' size='18'>He<color value='green'>llo</color> <font weight='bold'>world</font> demo</font>" );
816
817   // connect to the text changed signal.
818   ConnectionTracker* testTracker = new ConnectionTracker();
819   field.InputStyleChangedSignal().Connect( &TestInputStyleChangedCallback );
820   bool inputStyleChangedSignal = false;
821   field.ConnectSignal( testTracker, "inputStyleChanged",   CallbackFunctor(&inputStyleChangedSignal) );
822
823   Stage::GetCurrent().Add( field );
824
825   // Render and notify
826   application.SendNotification();
827   application.Render();
828
829   // Executes the idle callbacks added by the text control on the change of input style.
830   application.RunIdles();
831
832   gInputStyleChangedCallbackCalled = false;
833   gInputStyleMask = TextField::InputStyle::NONE;
834   inputStyleChangedSignal = false;
835
836   // Create a tap event to touch the text field.
837   application.ProcessEvent( GenerateTap( Gesture::Possible, 1u, 1u, Vector2( 18.f, 25.f ) ) );
838   application.ProcessEvent( GenerateTap( Gesture::Started, 1u, 1u, Vector2( 18.f, 25.f ) ) );
839
840   // Render and notify
841   application.SendNotification();
842   application.Render();
843
844   // Executes the idle callbacks added by the text control on the change of input style.
845   application.RunIdles();
846
847   DALI_TEST_CHECK( gInputStyleChangedCallbackCalled );
848   if( gInputStyleChangedCallbackCalled )
849   {
850     DALI_TEST_EQUALS( static_cast<unsigned int>( gInputStyleMask ), static_cast<unsigned int>( TextField::InputStyle::FONT_FAMILY | TextField::InputStyle::POINT_SIZE ), TEST_LOCATION );
851
852     const std::string fontFamily = field.GetProperty( TextField::Property::INPUT_FONT_FAMILY ).Get<std::string>();
853     DALI_TEST_EQUALS( fontFamily, "DejaVuSerif", TEST_LOCATION );
854
855     const float pointSize = field.GetProperty( TextField::Property::INPUT_POINT_SIZE ).Get<float>();
856     DALI_TEST_EQUALS( pointSize, 18.f, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
857   }
858   DALI_TEST_CHECK( inputStyleChangedSignal );
859
860   gInputStyleChangedCallbackCalled = false;
861   gInputStyleMask = TextField::InputStyle::NONE;
862   inputStyleChangedSignal = false;
863
864   // Create a tap event to touch the text field.
865   application.ProcessEvent( GenerateTap( Gesture::Possible, 1u, 1u, Vector2( 30.f, 25.f ) ) );
866   application.ProcessEvent( GenerateTap( Gesture::Started, 1u, 1u, Vector2( 30.f, 25.f ) ) );
867
868   // Render and notify
869   application.SendNotification();
870   application.Render();
871
872   // Executes the idle callbacks added by the text control on the change of input style.
873   application.RunIdles();
874
875   DALI_TEST_CHECK( !gInputStyleChangedCallbackCalled );
876   DALI_TEST_CHECK( !inputStyleChangedSignal );
877
878   gInputStyleChangedCallbackCalled = false;
879   gInputStyleMask = TextField::InputStyle::NONE;
880   inputStyleChangedSignal = false;
881
882   // Create a tap event to touch the text field.
883   application.ProcessEvent( GenerateTap( Gesture::Possible, 1u, 1u, Vector2( 43.f, 25.f ) ) );
884   application.ProcessEvent( GenerateTap( Gesture::Started, 1u, 1u, Vector2( 43.f, 25.f ) ) );
885
886   // Render and notify
887   application.SendNotification();
888   application.Render();
889
890   // Executes the idle callbacks added by the text control on the change of input style.
891   application.RunIdles();
892
893   DALI_TEST_CHECK( gInputStyleChangedCallbackCalled );
894   if( gInputStyleChangedCallbackCalled )
895   {
896     DALI_TEST_EQUALS( static_cast<unsigned int>( gInputStyleMask ), static_cast<unsigned int>( TextField::InputStyle::COLOR ), TEST_LOCATION );
897
898     const Vector4 color = field.GetProperty( TextField::Property::INPUT_COLOR ).Get<Vector4>();
899     DALI_TEST_EQUALS( color, Color::GREEN, TEST_LOCATION );
900   }
901   DALI_TEST_CHECK( inputStyleChangedSignal );
902
903   gInputStyleChangedCallbackCalled = false;
904   gInputStyleMask = TextField::InputStyle::NONE;
905   inputStyleChangedSignal = false;
906
907   // Create a tap event to touch the text field.
908   application.ProcessEvent( GenerateTap( Gesture::Possible, 1u, 1u, Vector2( 88.f, 25.f ) ) );
909   application.ProcessEvent( GenerateTap( Gesture::Started, 1u, 1u, Vector2( 88.f, 25.f ) ) );
910
911   // Render and notify
912   application.SendNotification();
913   application.Render();
914
915   // Executes the idle callbacks added by the text control on the change of input style.
916   application.RunIdles();
917
918   DALI_TEST_CHECK( gInputStyleChangedCallbackCalled );
919   if( gInputStyleChangedCallbackCalled )
920   {
921     DALI_TEST_EQUALS( static_cast<unsigned int>( gInputStyleMask ), static_cast<unsigned int>( TextField::InputStyle::COLOR | TextField::InputStyle::FONT_STYLE ), TEST_LOCATION );
922
923     const Vector4 color = field.GetProperty( TextField::Property::INPUT_COLOR ).Get<Vector4>();
924     DALI_TEST_EQUALS( color, Color::BLACK, TEST_LOCATION );
925
926     const std::string style = field.GetProperty( TextField::Property::INPUT_FONT_STYLE ).Get<std::string>();
927     DALI_TEST_EQUALS( style, "{\"weight\":\"bold\"}", TEST_LOCATION );
928   }
929   DALI_TEST_CHECK( inputStyleChangedSignal );
930
931   gInputStyleChangedCallbackCalled = false;
932   gInputStyleMask = TextField::InputStyle::NONE;
933   inputStyleChangedSignal = false;
934
935   // Create a tap event to touch the text field.
936   application.ProcessEvent( GenerateTap( Gesture::Possible, 1u, 1u, Vector2( 115.f, 25.f ) ) );
937   application.ProcessEvent( GenerateTap( Gesture::Started, 1u, 1u, Vector2( 115.f, 25.f ) ) );
938
939   // Render and notify
940   application.SendNotification();
941   application.Render();
942
943   // Executes the idle callbacks added by the text control on the change of input style.
944   application.RunIdles();
945
946   DALI_TEST_CHECK( !gInputStyleChangedCallbackCalled );
947   DALI_TEST_CHECK( !inputStyleChangedSignal );
948
949   gInputStyleChangedCallbackCalled = false;
950   gInputStyleMask = TextField::InputStyle::NONE;
951   inputStyleChangedSignal = false;
952
953   // Create a tap event to touch the text field.
954   application.ProcessEvent( GenerateTap( Gesture::Possible, 1u, 1u, Vector2( 164.f, 25.f ) ) );
955   application.ProcessEvent( GenerateTap( Gesture::Started, 1u, 1u, Vector2( 164.f, 25.f ) ) );
956
957   // Render and notify
958   application.SendNotification();
959   application.Render();
960
961   // Executes the idle callbacks added by the text control on the change of input style.
962   application.RunIdles();
963
964   DALI_TEST_CHECK( gInputStyleChangedCallbackCalled );
965   if( gInputStyleChangedCallbackCalled )
966   {
967     DALI_TEST_EQUALS( static_cast<unsigned int>( gInputStyleMask ), static_cast<unsigned int>( TextField::InputStyle::FONT_STYLE ), TEST_LOCATION );
968
969     const std::string style = field.GetProperty( TextField::Property::INPUT_FONT_STYLE ).Get<std::string>();
970     DALI_TEST_CHECK( style.empty() );
971   }
972   DALI_TEST_CHECK( inputStyleChangedSignal );
973
974   gInputStyleChangedCallbackCalled = false;
975   gInputStyleMask = TextField::InputStyle::NONE;
976   inputStyleChangedSignal = false;
977
978   // Create a tap event to touch the text field.
979   application.ProcessEvent( GenerateTap( Gesture::Possible, 1u, 1u, Vector2( 191.f, 25.f ) ) );
980   application.ProcessEvent( GenerateTap( Gesture::Started, 1u, 1u, Vector2( 191.f, 25.f ) ) );
981
982   // Render and notify
983   application.SendNotification();
984   application.Render();
985
986   // Executes the idle callbacks added by the text control on the change of input style.
987   application.RunIdles();
988
989   DALI_TEST_CHECK( !gInputStyleChangedCallbackCalled );
990   DALI_TEST_CHECK( !inputStyleChangedSignal );
991
992   END_TEST;
993 }
994
995 int utcDaliTextFieldInputStyleChanged02(void)
996 {
997   ToolkitTestApplication application;
998   tet_infoline(" utcDaliTextFieldInputStyleChanged02");
999
1000   // The text-field emits signals when the input style changes. These changes of style are
1001   // detected during the relayout process (size negotiation), i.e after the cursor has been moved. Signals
1002   // can't be emitted during the size negotiation as the callbacks may update the UI.
1003   // The text-field adds an idle callback to the adaptor to emit the signals after the size negotiation.
1004   // This creates an implementation of the adaptor stub and a queue of idle callbacks.
1005   application.CreateAdaptor();
1006
1007   // Load some fonts.
1008
1009   char* pathNamePtr = get_current_dir_name();
1010   const std::string pathName( pathNamePtr );
1011   free( pathNamePtr );
1012
1013   TextAbstraction::FontClient fontClient = TextAbstraction::FontClient::Get();
1014   fontClient.SetDpi( 93u, 93u );
1015
1016   fontClient.GetFontId( pathName + DEFAULT_FONT_DIR + "/dejavu/DejaVuSerif.ttf", DEFAULT_FONT_SIZE );
1017   fontClient.GetFontId( pathName + DEFAULT_FONT_DIR + "/dejavu/DejaVuSerif-Bold.ttf", DEFAULT_FONT_SIZE );
1018
1019   TextField field = TextField::New();
1020   DALI_TEST_CHECK( field );
1021
1022
1023   field.SetSize( 300.f, 50.f );
1024   field.SetParentOrigin( ParentOrigin::TOP_LEFT );
1025   field.SetAnchorPoint( AnchorPoint::TOP_LEFT );
1026
1027   field.SetProperty( TextField::Property::ENABLE_MARKUP, true );
1028   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>" );
1029
1030   // connect to the text changed signal.
1031   ConnectionTracker* testTracker = new ConnectionTracker();
1032   field.InputStyleChangedSignal().Connect( &TestInputStyleChangedCallback );
1033   bool inputStyleChangedSignal = false;
1034   field.ConnectSignal( testTracker, "inputStyleChanged",   CallbackFunctor(&inputStyleChangedSignal) );
1035
1036   Stage::GetCurrent().Add( field );
1037
1038   // Render and notify
1039   application.SendNotification();
1040   application.Render();
1041
1042   // Executes the idle callbacks added by the text control on the change of input style.
1043   application.RunIdles();
1044
1045   gInputStyleChangedCallbackCalled = false;
1046   gInputStyleMask = TextField::InputStyle::NONE;
1047   inputStyleChangedSignal = false;
1048
1049   // Create a tap event to touch the text field.
1050   application.ProcessEvent( GenerateTap( Gesture::Possible, 1u, 1u, Vector2( 53.f, 25.f ) ) );
1051   application.ProcessEvent( GenerateTap( Gesture::Started, 1u, 1u, Vector2( 53.f, 25.f ) ) );
1052   application.ProcessEvent( GenerateTap( Gesture::Possible, 2u, 1u, Vector2( 53.f, 25.f ) ) );
1053   application.ProcessEvent( GenerateTap( Gesture::Started, 2u, 1u, Vector2( 53.f, 25.f ) ) );
1054
1055   // Render and notify
1056   application.SendNotification();
1057   application.Render();
1058
1059   // Executes the idle callbacks added by the text control on the change of input style.
1060   application.RunIdles();
1061
1062   DALI_TEST_CHECK( gInputStyleChangedCallbackCalled );
1063   if( gInputStyleChangedCallbackCalled )
1064   {
1065     DALI_TEST_EQUALS( static_cast<unsigned int>( gInputStyleMask ),
1066                       static_cast<unsigned int>( TextField::InputStyle::FONT_FAMILY |
1067                                                  TextField::InputStyle::POINT_SIZE  |
1068                                                  TextField::InputStyle::COLOR ),
1069                       TEST_LOCATION );
1070
1071     const Vector4 color = field.GetProperty( TextField::Property::INPUT_COLOR ).Get<Vector4>();
1072     DALI_TEST_EQUALS( color, Color::GREEN, TEST_LOCATION );
1073
1074     const std::string fontFamily = field.GetProperty( TextField::Property::INPUT_FONT_FAMILY ).Get<std::string>();
1075     DALI_TEST_EQUALS( fontFamily, "DejaVuSerif", TEST_LOCATION );
1076
1077     const float pointSize = field.GetProperty( TextField::Property::INPUT_POINT_SIZE ).Get<float>();
1078     DALI_TEST_EQUALS( pointSize, 18.f, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
1079   }
1080   DALI_TEST_CHECK( inputStyleChangedSignal );
1081
1082   gInputStyleChangedCallbackCalled = false;
1083   gInputStyleMask = TextField::InputStyle::NONE;
1084   inputStyleChangedSignal = false;
1085
1086   application.ProcessEvent( GenerateKey( "", "", DALI_KEY_BACKSPACE, 0, 0, Integration::KeyEvent::Down ) );
1087
1088   // Render and notify
1089   application.SendNotification();
1090   application.Render();
1091
1092   // Executes the idle callbacks added by the text control on the change of input style.
1093   application.RunIdles();
1094
1095   DALI_TEST_CHECK( gInputStyleChangedCallbackCalled );
1096   if( gInputStyleChangedCallbackCalled )
1097   {
1098     DALI_TEST_EQUALS( static_cast<unsigned int>( gInputStyleMask ),
1099                       static_cast<unsigned int>( TextField::InputStyle::COLOR ),
1100                       TEST_LOCATION );
1101
1102     const Vector4 color = field.GetProperty( TextField::Property::INPUT_COLOR ).Get<Vector4>();
1103     DALI_TEST_EQUALS( color, Color::BLUE, TEST_LOCATION );
1104   }
1105   DALI_TEST_CHECK( inputStyleChangedSignal );
1106
1107   gInputStyleChangedCallbackCalled = false;
1108   gInputStyleMask = TextField::InputStyle::NONE;
1109   inputStyleChangedSignal = false;
1110
1111   application.ProcessEvent( GenerateKey( "", "", DALI_KEY_BACKSPACE, 0, 0, Integration::KeyEvent::Down ) );
1112
1113   // Render and notify
1114   application.SendNotification();
1115   application.Render();
1116
1117   // Executes the idle callbacks added by the text control on the change of input style.
1118   application.RunIdles();
1119
1120   DALI_TEST_CHECK( !gInputStyleChangedCallbackCalled );
1121   DALI_TEST_CHECK( !inputStyleChangedSignal );
1122
1123   gInputStyleChangedCallbackCalled = false;
1124   gInputStyleMask = TextField::InputStyle::NONE;
1125   inputStyleChangedSignal = false;
1126
1127   application.ProcessEvent( GenerateKey( "", "", DALI_KEY_BACKSPACE, 0, 0, Integration::KeyEvent::Down ) );
1128
1129   // Render and notify
1130   application.SendNotification();
1131   application.Render();
1132
1133   // Executes the idle callbacks added by the text control on the change of input style.
1134   application.RunIdles();
1135
1136   DALI_TEST_CHECK( gInputStyleChangedCallbackCalled );
1137   if( gInputStyleChangedCallbackCalled )
1138   {
1139     DALI_TEST_EQUALS( static_cast<unsigned int>( gInputStyleMask ),
1140                       static_cast<unsigned int>( TextField::InputStyle::COLOR ),
1141                       TEST_LOCATION );
1142
1143     const Vector4 color = field.GetProperty( TextField::Property::INPUT_COLOR ).Get<Vector4>();
1144     DALI_TEST_EQUALS( color, Color::BLACK, TEST_LOCATION );
1145   }
1146   DALI_TEST_CHECK( inputStyleChangedSignal );
1147
1148   gInputStyleChangedCallbackCalled = false;
1149   gInputStyleMask = TextField::InputStyle::NONE;
1150   inputStyleChangedSignal = false;
1151
1152   field.SetProperty( TextField::Property::INPUT_COLOR, Color::YELLOW );
1153
1154   field.SetProperty( TextField::Property::INPUT_FONT_STYLE, "{\"weight\":\"thin\",\"width\":\"condensed\",\"slant\":\"italic\"}" );
1155   field.SetProperty( TextField::Property::INPUT_POINT_SIZE, 20.f );
1156
1157   field.SetProperty( TextField::Property::INPUT_UNDERLINE, "underline" );
1158   field.SetProperty( TextField::Property::INPUT_SHADOW, "shadow" );
1159   field.SetProperty( TextField::Property::INPUT_EMBOSS, "emboss" );
1160   field.SetProperty( TextField::Property::INPUT_OUTLINE, "outline" );
1161
1162   // Render and notify
1163   application.SendNotification();
1164   application.Render();
1165
1166   // Executes the idle callbacks added by the text control on the change of input style.
1167   application.RunIdles();
1168
1169   DALI_TEST_CHECK( !gInputStyleChangedCallbackCalled );
1170   DALI_TEST_CHECK( !inputStyleChangedSignal );
1171
1172   // Create a tap event to touch the text field.
1173   application.ProcessEvent( GenerateTap( Gesture::Possible, 1u, 1u, Vector2( 63.f, 25.f ) ) );
1174   application.ProcessEvent( GenerateTap( Gesture::Started, 1u, 1u, Vector2( 63.f, 25.f ) ) );
1175
1176   // Render and notify
1177   application.SendNotification();
1178   application.Render();
1179
1180   // Executes the idle callbacks added by the text control on the change of input style.
1181   application.RunIdles();
1182
1183   DALI_TEST_CHECK( gInputStyleChangedCallbackCalled );
1184   if( gInputStyleChangedCallbackCalled )
1185   {
1186     DALI_TEST_EQUALS( static_cast<unsigned int>( gInputStyleMask ),
1187                       static_cast<unsigned int>( TextField::InputStyle::COLOR |
1188                                                  TextField::InputStyle::POINT_SIZE |
1189                                                  TextField::InputStyle::FONT_STYLE |
1190                                                  TextField::InputStyle::UNDERLINE |
1191                                                  TextField::InputStyle::SHADOW |
1192                                                  TextField::InputStyle::EMBOSS |
1193                                                  TextField::InputStyle::OUTLINE ),
1194                       TEST_LOCATION );
1195
1196     const Vector4 color = field.GetProperty( TextField::Property::INPUT_COLOR ).Get<Vector4>();
1197     DALI_TEST_EQUALS( color, Color::BLACK, TEST_LOCATION );
1198   }
1199   DALI_TEST_CHECK( inputStyleChangedSignal );
1200
1201   END_TEST;
1202 }
1203
1204 int utcDaliTextFieldEvent01(void)
1205 {
1206   ToolkitTestApplication application;
1207   tet_infoline(" utcDaliTextFieldEvent01");
1208
1209   // Creates a tap event. After creating a tap event the text field should
1210   // have the focus and add text with key events should be possible.
1211
1212   TextField field = TextField::New();
1213   DALI_TEST_CHECK( field );
1214
1215   Stage::GetCurrent().Add( field );
1216
1217   field.SetSize( 300.f, 50.f );
1218   field.SetParentOrigin( ParentOrigin::TOP_LEFT );
1219   field.SetAnchorPoint( AnchorPoint::TOP_LEFT );
1220
1221   // Avoid a crash when core load gl resources.
1222   application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
1223
1224   // Render and notify
1225   application.SendNotification();
1226   application.Render();
1227
1228   // Add a key event but as the text field has not the focus it should do nothing.
1229   application.ProcessEvent( GenerateKey( "a", "a", 0, 0, 0, Integration::KeyEvent::Down ) );
1230
1231   // Render and notify
1232   application.SendNotification();
1233   application.Render();
1234
1235   DALI_TEST_EQUALS( field.GetProperty<std::string>( TextField::Property::TEXT ), std::string(""), TEST_LOCATION );
1236
1237   // Create a tap event to touch the text field.
1238   application.ProcessEvent( GenerateTap( Gesture::Possible, 1u, 1u, Vector2( 150.0f, 25.0f ) ) );
1239   application.ProcessEvent( GenerateTap( Gesture::Started, 1u, 1u, Vector2( 150.0f, 25.0f ) ) );
1240
1241   // Render and notify
1242   application.SendNotification();
1243   application.Render();
1244
1245   // Now the text field has the focus, so it can handle the key events.
1246   application.ProcessEvent( GenerateKey( "a", "a", 0, 0, 0, Integration::KeyEvent::Down ) );
1247   application.ProcessEvent( GenerateKey( "a", "a", 0, 0, 0, Integration::KeyEvent::Down ) );
1248
1249   // Render and notify
1250   application.SendNotification();
1251   application.Render();
1252
1253   DALI_TEST_EQUALS( field.GetProperty<std::string>( TextField::Property::TEXT ), std::string("aa"), TEST_LOCATION );
1254
1255   // Create a second text field and send key events to it.
1256   TextField field2 = TextField::New();
1257
1258   field2.SetParentOrigin( ParentOrigin::TOP_LEFT );
1259   field2.SetAnchorPoint( AnchorPoint::TOP_LEFT );
1260   field2.SetSize( 100.f, 100.f );
1261   field2.SetPosition( 100.f, 100.f );
1262
1263   Stage::GetCurrent().Add( field2 );
1264
1265   // Render and notify
1266   application.SendNotification();
1267   application.Render();
1268
1269   // Create a tap event on the second text field.
1270   application.ProcessEvent( GenerateTap( Gesture::Possible, 1u, 1u, Vector2( 150.0f, 125.0f ) ) );
1271   application.ProcessEvent( GenerateTap( Gesture::Started, 1u, 1u, Vector2( 150.0f, 125.0f ) ) );
1272
1273   // Render and notify
1274   application.SendNotification();
1275   application.Render();
1276
1277   // The second text field has the focus. It should handle the key events.
1278   application.ProcessEvent( GenerateKey( "a", "a", 0, 0, 0, Integration::KeyEvent::Down ) );
1279   application.ProcessEvent( GenerateKey( "a", "a", 0, 0, 0, Integration::KeyEvent::Down ) );
1280
1281   // Render and notify
1282   application.SendNotification();
1283   application.Render();
1284
1285   // Check the text has been added to the second text field.
1286   DALI_TEST_EQUALS( field2.GetProperty<std::string>( TextField::Property::TEXT ), std::string("aa"), TEST_LOCATION );
1287
1288   END_TEST;
1289 }
1290
1291 int utcDaliTextFieldEvent02(void)
1292 {
1293   ToolkitTestApplication application;
1294   tet_infoline(" utcDaliTextFieldEvent02");
1295
1296   // Checks if the right number of actors are created.
1297
1298   TextField field = TextField::New();
1299   field.SetProperty( TextField::Property::POINT_SIZE, 10.f );
1300   DALI_TEST_CHECK( field );
1301   LoadMarkerImages(application, field);
1302
1303   Stage::GetCurrent().Add( field );
1304
1305   field.SetSize( 300.f, 50.f );
1306   field.SetParentOrigin( ParentOrigin::TOP_LEFT );
1307   field.SetAnchorPoint( AnchorPoint::TOP_LEFT );
1308
1309   // Avoid a crash when core load gl resources.
1310   application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
1311
1312   // Render and notify
1313   application.SendNotification();
1314   application.Render();
1315
1316   // Check there are the expected number of children ( offscreen root actor, and the offscreen image view
1317   DALI_TEST_EQUALS( field.GetChildCount(), 2u, TEST_LOCATION );
1318
1319   Actor offscreenRoot = field.GetChildAt( 0u );
1320   DALI_TEST_CHECK( offscreenRoot.IsLayer() );
1321   DALI_TEST_EQUALS( offscreenRoot.GetChildCount(), 1u, TEST_LOCATION ); // The camera actor.
1322
1323   Actor offscreenImage = field.GetChildAt( 1u );
1324   DALI_TEST_CHECK( offscreenImage );
1325
1326   // Create a tap event to touch the text field.
1327   application.ProcessEvent( GenerateTap( Gesture::Possible, 1u, 1u, Vector2( 150.0f, 25.0f ) ) );
1328   application.ProcessEvent( GenerateTap( Gesture::Started, 1u, 1u, Vector2( 150.0f, 25.0f ) ) );
1329
1330   // Render and notify
1331   application.SendNotification();
1332   application.Render();
1333
1334   Actor layer = field.GetChildAt( 2u );
1335   DALI_TEST_CHECK( layer.IsLayer() );
1336
1337   DALI_TEST_EQUALS( layer.GetChildCount(), 1u, TEST_LOCATION ); // The cursor.
1338   DALI_TEST_EQUALS( offscreenRoot.GetChildCount(), 1u, TEST_LOCATION ); // The camera actor.
1339
1340   // Now the text field has the focus, so it can handle the key events.
1341   application.ProcessEvent( GenerateKey( "a", "a", 0, 0, 0, Integration::KeyEvent::Down ) );
1342   application.ProcessEvent( GenerateKey( "a", "a", 0, 0, 0, Integration::KeyEvent::Down ) );
1343
1344   // Render and notify
1345   application.SendNotification();
1346   application.Render();
1347
1348   // Checks the cursor and the renderer have been created.
1349   DALI_TEST_EQUALS( layer.GetChildCount(), 1u, TEST_LOCATION ); // The cursor.
1350   DALI_TEST_EQUALS( offscreenRoot.GetChildCount(), 2u, TEST_LOCATION ); // The camera actor and the renderer
1351
1352   Control cursor = Control::DownCast( layer.GetChildAt( 0u ) );
1353   DALI_TEST_CHECK( cursor );
1354
1355   CameraActor camera = CameraActor::DownCast( offscreenRoot.GetChildAt( 0u ) );
1356   DALI_TEST_CHECK( camera );
1357
1358   // The offscreen root actor has a container with all the actors which contain the text renderers.
1359   Actor container = offscreenRoot.GetChildAt( 1u );
1360   for( unsigned int index = 0; index < container.GetChildCount(); ++index )
1361   {
1362     Renderer renderer = container.GetChildAt( index ).GetRendererAt( 0u );
1363     DALI_TEST_CHECK( renderer );
1364   }
1365
1366   // Move the cursor and check the position changes.
1367   Vector3 position1 = cursor.GetCurrentPosition();
1368
1369   application.ProcessEvent( GenerateKey( "", "", DALI_KEY_CURSOR_LEFT, 0, 0, Integration::KeyEvent::Down ) );
1370   application.ProcessEvent( GenerateKey( "", "", DALI_KEY_CURSOR_LEFT, 0, 0, Integration::KeyEvent::Down ) );
1371
1372   // Render and notify
1373   application.SendNotification();
1374   application.Render();
1375
1376   Vector3 position2 = cursor.GetCurrentPosition();
1377
1378   DALI_TEST_CHECK( position2.x < position1.x );
1379
1380   application.ProcessEvent( GenerateKey( "", "", DALI_KEY_CURSOR_RIGHT, 0, 0, Integration::KeyEvent::Down ) );
1381   application.ProcessEvent( GenerateKey( "", "", DALI_KEY_CURSOR_RIGHT, 0, 0, Integration::KeyEvent::Down ) );
1382
1383   // Render and notify
1384   application.SendNotification();
1385   application.Render();
1386
1387   Vector3 position3 = cursor.GetCurrentPosition();
1388
1389   DALI_TEST_EQUALS( position1, position3, TEST_LOCATION ); // Should be in the same position1.
1390
1391   // Send some taps and check the cursor positions.
1392
1393   // Try to tap at the beginning.
1394   application.ProcessEvent( GenerateTap( Gesture::Possible, 1u, 1u, Vector2( 1.f, 25.0f ) ) );
1395   application.ProcessEvent( GenerateTap( Gesture::Started, 1u, 1u, Vector2( 1.f, 25.0f ) ) );
1396
1397   // Render and notify
1398   application.SendNotification();
1399   application.Render();
1400
1401   // Cursor position should be the same than position1.
1402   Vector3 position4 = cursor.GetCurrentPosition();
1403
1404   DALI_TEST_EQUALS( position2, position4, TEST_LOCATION ); // Should be in the same position2.
1405
1406   // Tap away from the start position.
1407   application.ProcessEvent( GenerateTap( Gesture::Possible, 1u, 1u, Vector2( 16.f, 25.0f ) ) );
1408   application.ProcessEvent( GenerateTap( Gesture::Started, 1u, 1u, Vector2( 16.0f, 25.0f ) ) );
1409
1410   // Render and notify
1411   application.SendNotification();
1412   application.Render();
1413
1414   Vector3 position5 = cursor.GetCurrentPosition();
1415
1416   DALI_TEST_CHECK( position5.x > position4.x );
1417
1418   // Remove all the text.
1419   application.ProcessEvent( GenerateKey( "", "", DALI_KEY_BACKSPACE, 0, 0, Integration::KeyEvent::Down ) );
1420   application.ProcessEvent( GenerateKey( "", "", DALI_KEY_BACKSPACE, 0, 0, Integration::KeyEvent::Down ) );
1421   field.SetProperty( TextField::Property::TEXT, "" );
1422
1423   // Render and notify
1424   application.SendNotification();
1425   application.Render();
1426
1427   // Cursor position should be the same than position2.
1428   Vector3 position6 = cursor.GetCurrentPosition();
1429
1430   DALI_TEST_EQUALS( position2, position6, TEST_LOCATION );// Should be in the same position2.
1431
1432   // Should not be a renderer.
1433   DALI_TEST_EQUALS( offscreenRoot.GetChildCount(), 1u, TEST_LOCATION ); // The camera actor only.
1434
1435   END_TEST;
1436 }
1437
1438 int utcDaliTextFieldEvent03(void)
1439 {
1440   ToolkitTestApplication application;
1441   tet_infoline(" utcDaliTextFieldEvent03");
1442
1443   // Checks if the highlight actor is created.
1444
1445   TextField field = TextField::New();
1446   DALI_TEST_CHECK( field );
1447
1448   Stage::GetCurrent().Add( field );
1449
1450   field.SetProperty( TextField::Property::TEXT, "This is a long text for the size of the text-field." );
1451   field.SetProperty( TextField::Property::POINT_SIZE, 10.f );
1452   field.SetSize( 30.f, 50.f );
1453   field.SetParentOrigin( ParentOrigin::TOP_LEFT );
1454   field.SetAnchorPoint( AnchorPoint::TOP_LEFT );
1455
1456   // Avoid a crash when core load gl resources.
1457   application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
1458   LoadMarkerImages(application, field);
1459
1460   // Render and notify
1461   application.SendNotification();
1462   application.Render();
1463
1464   // Tap first to get the focus.
1465   application.ProcessEvent( GenerateTap( Gesture::Possible, 1u, 1u, Vector2( 3.f, 25.0f ) ) );
1466   application.ProcessEvent( GenerateTap( Gesture::Started, 1u, 1u, Vector2( 3.f, 25.0f ) ) );
1467
1468   // Render and notify
1469   application.SendNotification();
1470   application.Render();
1471
1472   // Double tap to select a word.
1473   application.ProcessEvent( GenerateTap( Gesture::Possible, 2u, 1u, Vector2( 3.f, 25.0f ) ) );
1474   application.ProcessEvent( GenerateTap( Gesture::Started, 2u, 1u, Vector2( 3.f, 25.0f ) ) );
1475
1476   // Render and notify
1477   application.SendNotification();
1478   application.Render();
1479
1480   // The offscreen root actor should have three actors: the camera, a renderer and the highlight actor.
1481   Actor offscreenRoot = field.GetChildAt( 1u );
1482   DALI_TEST_CHECK( offscreenRoot.IsLayer() );
1483
1484   CameraActor camera = CameraActor::DownCast( offscreenRoot.GetChildAt( 0u ) );
1485   DALI_TEST_CHECK( camera );
1486
1487   // The offscreen root actor has a container with all the actors which contain the text renderers.
1488   Actor container = offscreenRoot.GetChildAt( 1u );
1489   for( unsigned int index = 0; index < container.GetChildCount(); ++index )
1490   {
1491     Renderer renderer = container.GetChildAt( index ).GetRendererAt( 0u );
1492     DALI_TEST_CHECK( renderer );
1493   }
1494
1495   Renderer highlight = offscreenRoot.GetChildAt( 2u ).GetRendererAt( 0u );
1496   DALI_TEST_CHECK( highlight );
1497
1498   END_TEST;
1499 }
1500
1501 int utcDaliTextFieldEvent04(void)
1502 {
1503   ToolkitTestApplication application;
1504   tet_infoline(" utcDaliTextFieldEvent04");
1505
1506   // Checks if the highlight actor is created.
1507
1508   TextField field = TextField::New();
1509   DALI_TEST_CHECK( field );
1510   Stage::GetCurrent().Add( field );
1511   LoadMarkerImages(application, field);
1512   // Render and notify
1513   application.SendNotification();
1514   application.Render();
1515
1516   field.SetProperty( TextField::Property::TEXT, "This is a long text for the size of the text-field." );
1517   field.SetProperty( TextField::Property::POINT_SIZE, 10.f );
1518   field.SetSize( 300.f, 50.f );
1519   field.SetParentOrigin( ParentOrigin::TOP_LEFT );
1520   field.SetAnchorPoint( AnchorPoint::TOP_LEFT );
1521
1522   // Avoid a crash when core load gl resources.
1523   application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
1524   // Render and notify
1525   application.SendNotification();
1526   application.Render();
1527
1528   // Create a tap event to touch the text field.
1529   application.ProcessEvent( GenerateTap( Gesture::Possible, 1u, 1u, Vector2( 150.0f, 25.0f ) ) );
1530   application.ProcessEvent( GenerateTap( Gesture::Started, 1u, 1u, Vector2( 150.0f, 25.0f ) ) );
1531   // Render and notify
1532   application.SendNotification();
1533   application.Render();
1534
1535
1536   // Tap first to get the focus.
1537   application.ProcessEvent( GenerateTap( Gesture::Possible, 1u, 1u, Vector2( 1.f, 25.0f ) ) );
1538   application.ProcessEvent( GenerateTap( Gesture::Started, 1u, 1u, Vector2( 1.f, 25.0f ) ) );
1539
1540   // Render and notify
1541   application.SendNotification();
1542   application.Render();
1543
1544   // Double tap to select a word.
1545   application.ProcessEvent( GenerateTap( Gesture::Possible, 2u, 1u, Vector2( 1.f, 25.0f ) ) );
1546   application.ProcessEvent( GenerateTap( Gesture::Started, 2u, 1u, Vector2( 1.f, 25.0f ) ) );
1547
1548   // Render and notify
1549   application.SendNotification();
1550   application.Render();
1551
1552   // Tap grab handle
1553   application.ProcessEvent( GenerateTap( Gesture::Possible, 1u, 1u, Vector2( 0.f, 40.0f ) ) );
1554   application.ProcessEvent( GenerateTap( Gesture::Started, 1u, 1u, Vector2( 0.f, 40.0f ) ) );
1555   END_TEST;
1556 }
1557
1558 int utcDaliTextFieldEvent05(void)
1559 {
1560   ToolkitTestApplication application;
1561   tet_infoline(" utcDaliTextFieldEvent05");
1562
1563   // Checks dragging of cursor/grab handle
1564
1565   TextField field = TextField::New();
1566   DALI_TEST_CHECK( field );
1567   Stage::GetCurrent().Add( field );
1568   LoadMarkerImages(application, field);
1569   // Render and notify
1570   application.SendNotification();
1571   application.Render();
1572
1573   field.SetProperty( TextField::Property::TEXT, "This is a long text for the size of the text-field." );
1574   field.SetProperty( TextField::Property::POINT_SIZE, 10.f );
1575   field.SetSize( 300.f, 50.f );
1576   field.SetParentOrigin( ParentOrigin::TOP_LEFT );
1577   field.SetAnchorPoint( AnchorPoint::TOP_LEFT );
1578
1579   // Avoid a crash when core load gl resources.
1580   application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
1581   // Render and notify
1582   application.SendNotification();
1583   application.Render();
1584
1585   // Create a tap event to touch the text field.
1586   application.ProcessEvent( GenerateTap( Gesture::Possible, 1u, 1u, Vector2( 150.0f, 25.0f ) ) );
1587   application.ProcessEvent( GenerateTap( Gesture::Started, 1u, 1u, Vector2( 150.0f, 25.0f ) ) );
1588   // Render and notify
1589   application.SendNotification();
1590   application.Render();
1591
1592
1593   // Tap first to get the focus.
1594   application.ProcessEvent( GenerateTap( Gesture::Possible, 1u, 1u, Vector2( 1.f, 25.0f ) ) );
1595   application.ProcessEvent( GenerateTap( Gesture::Started, 1u, 1u, Vector2( 1.f, 25.0f ) ) );
1596
1597   // Render and notify
1598   application.SendNotification();
1599   application.Render();
1600
1601   // Double tap to select a word.
1602   application.ProcessEvent( GenerateTap( Gesture::Possible, 2u, 1u, Vector2( 1.f, 25.0f ) ) );
1603   application.ProcessEvent( GenerateTap( Gesture::Started, 2u, 1u, Vector2( 1.f, 25.0f ) ) );
1604
1605   // Render and notify
1606   application.SendNotification();
1607   application.Render();
1608
1609   // drag grab handle right
1610   Vector2 pos(0.0f, 40.0f);
1611   SendPan(application, Gesture::Possible, pos);
1612   SendPan(application, Gesture::Started, pos);
1613   pos.x += 5.0f;
1614   Wait(application, 100);
1615
1616   for(int i = 0;i<20;i++)
1617   {
1618     SendPan(application, Gesture::Continuing, pos);
1619     pos.x += 5.0f;
1620     Wait(application);
1621   }
1622
1623   SendPan(application, Gesture::Finished, pos);
1624   Wait(application, RENDER_FRAME_INTERVAL);
1625
1626   Actor offscreenRoot = field.GetChildAt( 1u );
1627   END_TEST;
1628 }
1629
1630 int utcDaliTextFieldEvent06(void)
1631 {
1632   ToolkitTestApplication application;
1633   tet_infoline(" utcDaliTextFieldEvent06");
1634
1635   // Checks Longpress when in edit mode
1636
1637   TextField field = TextField::New();
1638   DALI_TEST_CHECK( field );
1639   Stage::GetCurrent().Add( field );
1640   LoadMarkerImages(application, field);
1641   // Render and notify
1642   application.SendNotification();
1643   application.Render();
1644
1645   field.SetProperty( TextField::Property::TEXT, "Thisisalongtextforthesizeofthetextfield." );
1646   field.SetProperty( TextField::Property::POINT_SIZE, 10.f );
1647   field.SetSize( 300.f, 50.f );
1648   field.SetParentOrigin( ParentOrigin::TOP_LEFT );
1649   field.SetAnchorPoint( AnchorPoint::TOP_LEFT );
1650
1651   // Avoid a crash when core load gl resources.
1652   application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
1653   // Render and notify
1654   application.SendNotification();
1655   application.Render();
1656
1657   // Create a tap event to touch the text field.
1658   application.ProcessEvent( GenerateTap( Gesture::Possible, 1u, 1u, Vector2( 150.0f, 25.0f ) ) );
1659   application.ProcessEvent( GenerateTap( Gesture::Started, 1u, 1u, Vector2( 150.0f, 25.0f ) ) );
1660   // Render and notify
1661   application.SendNotification();
1662   application.Render();
1663
1664
1665   // Tap first to get the focus.
1666   application.ProcessEvent( GenerateTap( Gesture::Possible, 1u, 1u, Vector2( 1.f, 25.0f ) ) );
1667   application.ProcessEvent( GenerateTap( Gesture::Started, 1u, 1u, Vector2( 1.f, 25.0f ) ) );
1668
1669   // Render and notify
1670   application.SendNotification();
1671   application.Render();
1672
1673   // Long Press
1674   application.ProcessEvent( GenerateLongPress( Gesture::Possible, 1u, Vector2( 1.f, 25.0f ) ) );
1675   application.ProcessEvent( GenerateLongPress( Gesture::Started,  1u, Vector2( 1.f, 25.0f ) ) );
1676
1677   // Render and notify
1678   application.SendNotification();
1679   application.Render();
1680
1681   END_TEST;
1682 }
1683
1684 int utcDaliTextFieldEvent07(void)
1685 {
1686   ToolkitTestApplication application;
1687   tet_infoline(" utcDaliTextFieldEvent07");
1688
1689   // Checks Longpress to start edit mode
1690
1691   TextField field = TextField::New();
1692   DALI_TEST_CHECK( field );
1693   Stage::GetCurrent().Add( field );
1694   LoadMarkerImages(application, field);
1695   // Render and notify
1696   application.SendNotification();
1697   application.Render();
1698
1699   field.SetProperty( TextField::Property::TEXT, "Thisisalongtextforthesizeofthetextfield." );
1700   field.SetProperty( TextField::Property::POINT_SIZE, 10.f );
1701   field.SetSize( 300.f, 50.f );
1702   field.SetParentOrigin( ParentOrigin::TOP_LEFT );
1703   field.SetAnchorPoint( AnchorPoint::TOP_LEFT );
1704
1705   // Avoid a crash when core load gl resources.
1706   application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
1707   // Render and notify
1708   application.SendNotification();
1709   application.Render();
1710
1711   // Long Press
1712   application.ProcessEvent( GenerateLongPress( Gesture::Possible, 1u, Vector2( 1.f, 25.0f ) ) );
1713   application.ProcessEvent( GenerateLongPress( Gesture::Started,  1u, Vector2( 1.f, 25.0f ) ) );
1714
1715   // Render and notify
1716   application.SendNotification();
1717   application.Render();
1718
1719   END_TEST;
1720 }
1721
1722 int utcDaliTextFieldEvent08(void)
1723 {
1724   ToolkitTestApplication application;
1725   tet_infoline(" utcDaliTextFieldEvent08");
1726
1727   // Checks Longpress when only place holder text
1728
1729   TextField field = TextField::New();
1730   DALI_TEST_CHECK( field );
1731   Stage::GetCurrent().Add( field );
1732   LoadMarkerImages(application, field);
1733   // Render and notify
1734   application.SendNotification();
1735   application.Render();
1736
1737   field.SetProperty( TextField::Property::PLACEHOLDER_TEXT, "Setting Placeholder Text" );
1738   field.SetProperty( TextField::Property::POINT_SIZE, 10.f );
1739   field.SetSize( 300.f, 50.f );
1740   field.SetParentOrigin( ParentOrigin::TOP_LEFT );
1741   field.SetAnchorPoint( AnchorPoint::TOP_LEFT );
1742
1743   // Avoid a crash when core load gl resources.
1744   application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
1745   // Render and notify
1746   application.SendNotification();
1747   application.Render();
1748
1749   // Long Press
1750   application.ProcessEvent( GenerateLongPress( Gesture::Possible, 1u, Vector2( 1.f, 25.0f ) ) );
1751   application.ProcessEvent( GenerateLongPress( Gesture::Started,  1u, Vector2( 1.f, 25.0f ) ) );
1752
1753   // Render and notify
1754   application.SendNotification();
1755   application.Render();
1756
1757   END_TEST;
1758 }
1759
1760 int utcDaliTextFieldStyleWhilstSelected(void)
1761 {
1762   ToolkitTestApplication application;
1763   tet_infoline(" utcDaliTextFieldStyleWhilstSelected");
1764
1765   // Change font and styles whilst text is selected whilst word selected
1766
1767   TextField field = TextField::New();
1768   DALI_TEST_CHECK( field );
1769   Stage::GetCurrent().Add( field );
1770   LoadMarkerImages(application, field);
1771   // Render and notify
1772   application.SendNotification();
1773   application.Render();
1774
1775   field.SetProperty( TextField::Property::TEXT, "This is a long text for the size of the text-field." );
1776   field.SetProperty( TextField::Property::POINT_SIZE, 10.f );
1777   field.SetSize( 300.f, 50.f );
1778   field.SetParentOrigin( ParentOrigin::TOP_LEFT );
1779   field.SetAnchorPoint( AnchorPoint::TOP_LEFT );
1780
1781   // Avoid a crash when core load gl resources.
1782   application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
1783   // Render and notify
1784   application.SendNotification();
1785   application.Render();
1786
1787   // Create a tap event to touch the text field.
1788   application.ProcessEvent( GenerateTap( Gesture::Possible, 1u, 1u, Vector2( 150.0f, 25.0f ) ) );
1789   application.ProcessEvent( GenerateTap( Gesture::Started, 1u, 1u, Vector2( 150.0f, 25.0f ) ) );
1790   // Render and notify
1791   application.SendNotification();
1792   application.Render();
1793
1794
1795   // Tap first to get the focus.
1796   application.ProcessEvent( GenerateTap( Gesture::Possible, 1u, 1u, Vector2( 1.f, 25.0f ) ) );
1797   application.ProcessEvent( GenerateTap( Gesture::Started, 1u, 1u, Vector2( 1.f, 25.0f ) ) );
1798
1799   // Render and notify
1800   application.SendNotification();
1801   application.Render();
1802
1803   // Double tap to select a word.
1804   application.ProcessEvent( GenerateTap( Gesture::Possible, 2u, 1u, Vector2( 1.f, 25.0f ) ) );
1805   application.ProcessEvent( GenerateTap( Gesture::Started, 2u, 1u, Vector2( 1.f, 25.0f ) ) );
1806
1807   // Render and notify
1808   application.SendNotification();
1809   application.Render();
1810
1811   field.SetProperty( TextField::Property::INPUT_FONT_FAMILY, "Setting input font family" );
1812   DALI_TEST_EQUALS( field.GetProperty<std::string>( TextField::Property::INPUT_FONT_FAMILY ), "Setting input font family", TEST_LOCATION );
1813
1814   field.SetProperty( TextField::Property::INPUT_FONT_STYLE, "{\"weight\":\"bold\",\"slant\":\"italic\"}" );
1815   DALI_TEST_EQUALS( field.GetProperty<std::string>( TextField::Property::INPUT_FONT_STYLE ), "{\"weight\":\"bold\",\"slant\":\"italic\"}", TEST_LOCATION );
1816
1817   field.SetProperty( TextField::Property::INPUT_FONT_STYLE, "{\"width\":\"expanded\",\"slant\":\"italic\"}" );
1818   DALI_TEST_EQUALS( field.GetProperty<std::string>( TextField::Property::INPUT_FONT_STYLE ), "{\"width\":\"expanded\",\"slant\":\"italic\"}", TEST_LOCATION );
1819
1820   field.SetProperty( TextField::Property::INPUT_POINT_SIZE, 12.f );
1821   DALI_TEST_EQUALS( field.GetProperty<float>( TextField::Property::INPUT_POINT_SIZE ), 12.f, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
1822
1823   field.SetProperty( TextField::Property::TEXT_COLOR, Color::RED );
1824   DALI_TEST_EQUALS( field.GetProperty<Vector4>( TextField::Property::TEXT_COLOR ), Color::RED, TEST_LOCATION );
1825
1826   field.SetProperty( TextField::Property::FONT_STYLE, "{\"weight\":\"bold\",\"slant\":\"italic\"}" );
1827   DALI_TEST_EQUALS( field.GetProperty<std::string>( TextField::Property::FONT_STYLE ), "{\"weight\":\"bold\",\"slant\":\"italic\"}", TEST_LOCATION );
1828
1829   field.SetProperty( TextField::Property::FONT_STYLE, "{\"width\":\"expanded\"}" );
1830   DALI_TEST_EQUALS( field.GetProperty<std::string>( TextField::Property::FONT_STYLE ), "{\"width\":\"expanded\"}", TEST_LOCATION );
1831
1832   END_TEST;
1833 }