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