[3.0] Text - TextClipper replaced by an Actor with the CLIPPING_MODE enabled.
[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   field.SetProperty( TextField::Property::EXCEED_POLICY, Dali::Toolkit::TextField::EXCEED_POLICY_CLIP );
524   DALI_TEST_EQUALS( field.GetProperty<int>( TextField::Property::EXCEED_POLICY ), static_cast<int>( Dali::Toolkit::TextField::EXCEED_POLICY_CLIP ), TEST_LOCATION );
525   field.SetProperty( TextField::Property::EXCEED_POLICY, Dali::Toolkit::TextField::EXCEED_POLICY_ORIGINAL );
526   DALI_TEST_EQUALS( field.GetProperty<int>( TextField::Property::EXCEED_POLICY ), static_cast<int>( Dali::Toolkit::TextField::EXCEED_POLICY_ORIGINAL ), TEST_LOCATION );
527
528   // Check that the Alignment properties can be correctly set
529   field.SetProperty( TextField::Property::HORIZONTAL_ALIGNMENT, "END" );
530   DALI_TEST_EQUALS( field.GetProperty<std::string>( TextField::Property::HORIZONTAL_ALIGNMENT ), "END", TEST_LOCATION );
531   field.SetProperty( TextField::Property::VERTICAL_ALIGNMENT, "CENTER" );
532   DALI_TEST_EQUALS( field.GetProperty<std::string>( TextField::Property::VERTICAL_ALIGNMENT ), "CENTER", TEST_LOCATION );
533
534   // Check text's color property
535   field.SetProperty( TextField::Property::TEXT_COLOR, Color::WHITE );
536   DALI_TEST_EQUALS( field.GetProperty<Vector4>( TextField::Property::TEXT_COLOR ), Color::WHITE, TEST_LOCATION );
537
538   // Check placeholder text's color property.
539   field.SetProperty( TextField::Property::PLACEHOLDER_TEXT_COLOR, Color::RED );
540   DALI_TEST_EQUALS( field.GetProperty<Vector4>( TextField::Property::PLACEHOLDER_TEXT_COLOR ), Color::RED, TEST_LOCATION );
541
542   // Check shadow properties.
543   field.SetProperty( TextField::Property::SHADOW_OFFSET, Vector2( 1.f, 1.f ) );
544   DALI_TEST_EQUALS( field.GetProperty<Vector2>( TextField::Property::SHADOW_OFFSET ), Vector2( 1.f, 1.f ), TEST_LOCATION );
545   field.SetProperty( TextField::Property::SHADOW_COLOR, Color::GREEN );
546   DALI_TEST_EQUALS( field.GetProperty<Vector4>( TextField::Property::SHADOW_COLOR ), Color::GREEN, TEST_LOCATION );
547
548   // Check cursor properties
549   field.SetProperty( TextField::Property::PRIMARY_CURSOR_COLOR, Color::RED );
550   DALI_TEST_EQUALS( field.GetProperty<Vector4>( TextField::Property::PRIMARY_CURSOR_COLOR ), Color::RED, TEST_LOCATION );
551   field.SetProperty( TextField::Property::SECONDARY_CURSOR_COLOR, Color::BLUE );
552   DALI_TEST_EQUALS( field.GetProperty<Vector4>( TextField::Property::SECONDARY_CURSOR_COLOR ), Color::BLUE, TEST_LOCATION );
553
554   field.SetProperty( TextField::Property::ENABLE_CURSOR_BLINK, false );
555   DALI_TEST_EQUALS( field.GetProperty<bool>( TextField::Property::ENABLE_CURSOR_BLINK ), false, TEST_LOCATION );
556   field.SetProperty( TextField::Property::CURSOR_BLINK_INTERVAL, 1.f );
557   DALI_TEST_EQUALS( field.GetProperty<float>( TextField::Property::CURSOR_BLINK_INTERVAL ), 1.f, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
558   field.SetProperty( TextField::Property::CURSOR_BLINK_DURATION, 10.f );
559   DALI_TEST_EQUALS( field.GetProperty<float>( TextField::Property::CURSOR_BLINK_DURATION ), 10.f, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
560   field.SetProperty( TextField::Property::CURSOR_WIDTH, 1 );
561   DALI_TEST_EQUALS( field.GetProperty<int>( TextField::Property::CURSOR_WIDTH ), 1, TEST_LOCATION );
562
563   // Check scroll properties.
564   field.SetProperty( TextField::Property::SCROLL_THRESHOLD, 1.f );
565   DALI_TEST_EQUALS( field.GetProperty<float>( TextField::Property::SCROLL_THRESHOLD ), 1.f, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
566   field.SetProperty( TextField::Property::SCROLL_SPEED, 100.f );
567   DALI_TEST_EQUALS( field.GetProperty<float>( TextField::Property::SCROLL_SPEED ), 100.f, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
568
569   // Check handle images
570   field.SetProperty( TextField::Property::GRAB_HANDLE_IMAGE, "image1" );
571   DALI_TEST_EQUALS( field.GetProperty<std::string>( TextField::Property::GRAB_HANDLE_IMAGE ), "image1", TEST_LOCATION );
572   field.SetProperty( TextField::Property::GRAB_HANDLE_PRESSED_IMAGE, "image2" );
573   DALI_TEST_EQUALS( field.GetProperty<std::string>( TextField::Property::GRAB_HANDLE_PRESSED_IMAGE ), "image2", TEST_LOCATION );
574   field.SetProperty( TextField::Property::SELECTION_HANDLE_IMAGE_LEFT, "image3" );
575
576   // Check handle images
577   DALI_TEST_CHECK( SetPropertyMapRetrieved( field, TextField::Property::SELECTION_HANDLE_IMAGE_LEFT, "filename", "leftHandleImage" )  );
578   DALI_TEST_CHECK( SetPropertyMapRetrieved( field, TextField::Property::SELECTION_HANDLE_IMAGE_RIGHT, "filename", "rightHandleImage" )  );
579   DALI_TEST_CHECK( SetPropertyMapRetrieved( field, TextField::Property::SELECTION_HANDLE_PRESSED_IMAGE_LEFT, "filename", "leftHandleImagePressed" )  );
580   DALI_TEST_CHECK( SetPropertyMapRetrieved( field, TextField::Property::SELECTION_HANDLE_PRESSED_IMAGE_RIGHT, "filename", "rightHandleImagePressed" )  );
581   DALI_TEST_CHECK( SetPropertyMapRetrieved( field, TextField::Property::SELECTION_HANDLE_MARKER_IMAGE_LEFT, "filename", "leftHandleMarkerImage" )  );
582   DALI_TEST_CHECK( SetPropertyMapRetrieved( field, TextField::Property::SELECTION_HANDLE_MARKER_IMAGE_RIGHT, "filename", "rightHandleMarkerImage" )  );
583
584   // Check the highlight color
585   field.SetProperty( TextField::Property::SELECTION_HIGHLIGHT_COLOR, Color::GREEN );
586   DALI_TEST_EQUALS( field.GetProperty<Vector4>( TextField::Property::SELECTION_HIGHLIGHT_COLOR ), Color::GREEN, TEST_LOCATION );
587
588   // Decoration bounding box
589   field.SetProperty( TextField::Property::DECORATION_BOUNDING_BOX, Rect<int>( 0, 0, 1, 1 ) );
590   DALI_TEST_EQUALS( field.GetProperty<Rect <int > >( TextField::Property::DECORATION_BOUNDING_BOX ), Rect<int>( 0, 0, 1, 1 ), TEST_LOCATION );
591
592   // Check input color property.
593   field.SetProperty( TextField::Property::INPUT_COLOR, Color::YELLOW );
594   DALI_TEST_EQUALS( field.GetProperty<Vector4>( TextField::Property::INPUT_COLOR ), Color::YELLOW, TEST_LOCATION );
595
596   // Check the enable markup property.
597   DALI_TEST_CHECK( !field.GetProperty<bool>( TextField::Property::ENABLE_MARKUP ) );
598   field.SetProperty( TextField::Property::ENABLE_MARKUP, true );
599   DALI_TEST_CHECK( field.GetProperty<bool>( TextField::Property::ENABLE_MARKUP ) );
600
601   // Check input font properties.
602   field.SetProperty( TextField::Property::INPUT_FONT_FAMILY, "Setting input font family" );
603   DALI_TEST_EQUALS( field.GetProperty<std::string>( TextField::Property::INPUT_FONT_FAMILY ), "Setting input font family", TEST_LOCATION );
604   field.SetProperty( TextField::Property::INPUT_FONT_STYLE, "{\"weight\":\"bold\",\"width\":\"condensed\",\"slant\":\"italic\"}" );
605   DALI_TEST_EQUALS( field.GetProperty<std::string>( TextField::Property::INPUT_FONT_STYLE ), "{\"weight\":\"bold\",\"width\":\"condensed\",\"slant\":\"italic\"}", TEST_LOCATION );
606   field.SetProperty( TextField::Property::INPUT_POINT_SIZE, 12.f );
607   DALI_TEST_EQUALS( field.GetProperty<float>( TextField::Property::INPUT_POINT_SIZE ), 12.f, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
608
609   // Reset input font style.
610   field.SetProperty( TextField::Property::INPUT_FONT_STYLE, "{\"weight\":\"normal\",\"slant\":\"oblique\"}" );
611   DALI_TEST_EQUALS( field.GetProperty<std::string>( TextField::Property::INPUT_FONT_STYLE ), std::string("{\"weight\":\"normal\",\"slant\":\"oblique\"}"), TEST_LOCATION );
612   field.SetProperty( TextField::Property::INPUT_FONT_STYLE, "{\"slant\":\"roman\"}" );
613   DALI_TEST_EQUALS( field.GetProperty<std::string>( TextField::Property::INPUT_FONT_STYLE ), std::string("{\"slant\":\"normal\"}"), TEST_LOCATION );
614   field.SetProperty( TextField::Property::INPUT_FONT_STYLE, "" );
615   DALI_TEST_EQUALS( field.GetProperty<std::string>( TextField::Property::INPUT_FONT_STYLE ), std::string(""), TEST_LOCATION );
616
617   // Check the underline property
618   field.SetProperty( TextField::Property::UNDERLINE, "Underline properties" );
619   DALI_TEST_EQUALS( field.GetProperty<std::string>( TextField::Property::UNDERLINE ), std::string("Underline properties"), TEST_LOCATION );
620
621   // Check the input underline property
622   field.SetProperty( TextField::Property::INPUT_UNDERLINE, "Underline input properties" );
623   DALI_TEST_EQUALS( field.GetProperty<std::string>( TextField::Property::INPUT_UNDERLINE ), std::string("Underline input properties"), TEST_LOCATION );
624
625   // Check the shadow property
626   field.SetProperty( TextField::Property::SHADOW, "Shadow properties" );
627   DALI_TEST_EQUALS( field.GetProperty<std::string>( TextField::Property::SHADOW ), std::string("Shadow properties"), TEST_LOCATION );
628
629   // Check the input shadow property
630   field.SetProperty( TextField::Property::INPUT_SHADOW, "Shadow input properties" );
631   DALI_TEST_EQUALS( field.GetProperty<std::string>( TextField::Property::INPUT_SHADOW ), std::string("Shadow input properties"), TEST_LOCATION );
632
633   // Check the emboss property
634   field.SetProperty( TextField::Property::EMBOSS, "Emboss properties" );
635   DALI_TEST_EQUALS( field.GetProperty<std::string>( TextField::Property::EMBOSS ), std::string("Emboss properties"), TEST_LOCATION );
636
637   // Check the input emboss property
638   field.SetProperty( TextField::Property::INPUT_EMBOSS, "Emboss input properties" );
639   DALI_TEST_EQUALS( field.GetProperty<std::string>( TextField::Property::INPUT_EMBOSS ), std::string("Emboss input properties"), TEST_LOCATION );
640
641   // Check the outline property
642   field.SetProperty( TextField::Property::OUTLINE, "Outline properties" );
643   DALI_TEST_EQUALS( field.GetProperty<std::string>( TextField::Property::OUTLINE ), std::string("Outline properties"), TEST_LOCATION );
644
645   // Check the input outline property
646   field.SetProperty( TextField::Property::INPUT_OUTLINE, "Outline input properties" );
647   DALI_TEST_EQUALS( field.GetProperty<std::string>( TextField::Property::INPUT_OUTLINE ), std::string("Outline input properties"), TEST_LOCATION );
648
649   END_TEST;
650 }
651
652 // Positive Atlas Text Renderer test
653 int utcDaliTextFieldAtlasRenderP(void)
654 {
655   ToolkitTestApplication application;
656   tet_infoline(" UtcDaliToolkitTextFieldAtlasRenderP");
657   StyleManager styleManager = StyleManager::Get();
658   styleManager.ApplyDefaultTheme();
659   TextField field = TextField::New();
660   DALI_TEST_CHECK( field );
661
662   field.SetProperty( TextField::Property::HORIZONTAL_ALIGNMENT, "CENTER" );
663
664   application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
665
666   Stage::GetCurrent().Add( field );
667
668   try
669   {
670     // Render some text with the shared atlas backend
671     field.SetProperty( TextField::Property::RENDERING_BACKEND, Text::RENDERING_SHARED_ATLAS );
672     application.SendNotification();
673     application.Render();
674   }
675   catch( ... )
676   {
677     tet_result(TET_FAIL);
678   }
679   END_TEST;
680 }
681
682 // Positive test for the textChanged signal.
683 int utcDaliTextFieldTextChangedP(void)
684 {
685   ToolkitTestApplication application;
686   tet_infoline(" utcDaliTextFieldTextChangedP");
687   TextField field = TextField::New();
688   DALI_TEST_CHECK( field );
689
690   Stage::GetCurrent().Add( field );
691
692   // connect to the text changed signal.
693   ConnectionTracker* testTracker = new ConnectionTracker();
694   field.TextChangedSignal().Connect(&TestTextChangedCallback);
695   bool textChangedSignal = false;
696   field.ConnectSignal( testTracker, "textChanged",   CallbackFunctor(&textChangedSignal) );
697
698   gTextChangedCallBackCalled = false;
699   field.SetProperty( TextField::Property::TEXT, "ABC" );
700   DALI_TEST_CHECK( gTextChangedCallBackCalled );
701   DALI_TEST_CHECK( textChangedSignal );
702
703   application.SendNotification();
704
705   field.SetKeyInputFocus();
706
707   gTextChangedCallBackCalled = false;
708   application.ProcessEvent( GenerateKey( "D", "D", 0, 0, 0, Integration::KeyEvent::Down ) );
709   DALI_TEST_CHECK( gTextChangedCallBackCalled );
710
711   END_TEST;
712 }
713
714 // Negative test for the textChanged signal.
715 int utcDaliTextFieldTextChangedN(void)
716 {
717   ToolkitTestApplication application;
718   tet_infoline(" utcDaliTextFieldTextChangedN");
719   TextField field = TextField::New();
720   DALI_TEST_CHECK( field );
721
722   Stage::GetCurrent().Add( field );
723
724   // connect to the text changed signal.
725   ConnectionTracker* testTracker = new ConnectionTracker();
726   field.TextChangedSignal().Connect(&TestTextChangedCallback);
727   bool textChangedSignal = false;
728   field.ConnectSignal( testTracker, "textChanged",   CallbackFunctor(&textChangedSignal) );
729
730   gTextChangedCallBackCalled = false;
731   field.SetProperty( TextField::Property::PLACEHOLDER_TEXT, "ABC" ); // Setting placeholder, not TEXT
732   DALI_TEST_CHECK( !gTextChangedCallBackCalled );
733   DALI_TEST_CHECK( !textChangedSignal );
734
735   END_TEST;
736 }
737
738 // Positive test for Max Characters reached signal.
739 int utcDaliTextFieldMaxCharactersReachedP(void)
740 {
741   ToolkitTestApplication application;
742   tet_infoline(" utcDaliTextFieldMaxCharactersReachedP");
743   TextField field = TextField::New();
744   DALI_TEST_CHECK( field );
745
746   Stage::GetCurrent().Add( field );
747
748   const int maxNumberOfCharacters = 1;
749   field.SetProperty( TextField::Property::MAX_LENGTH, maxNumberOfCharacters );
750
751   field.SetKeyInputFocus();
752
753   // connect to the text changed signal.
754   ConnectionTracker* testTracker = new ConnectionTracker();
755   field.MaxLengthReachedSignal().Connect(&TestMaxLengthReachedCallback);
756   bool maxLengthReachedSignal = false;
757   field.ConnectSignal( testTracker, "maxLengthReached",   CallbackFunctor(&maxLengthReachedSignal) );
758
759   gMaxCharactersCallBackCalled = false;
760
761   application.ProcessEvent( GenerateKey( "a", "a", 0, 0, 0, Integration::KeyEvent::Down ) );
762   application.ProcessEvent( GenerateKey( "a", "a", 0, 0, 0, Integration::KeyEvent::Down ) );
763
764   DALI_TEST_CHECK( gMaxCharactersCallBackCalled );
765   DALI_TEST_CHECK( maxLengthReachedSignal );
766
767   END_TEST;
768 }
769
770 // Negative test for Max Characters reached signal.
771 int utcDaliTextFieldMaxCharactersReachedN(void)
772 {
773   ToolkitTestApplication application;
774   tet_infoline(" utcDaliTextFieldMaxCharactersReachedN");
775   TextField field = TextField::New();
776   DALI_TEST_CHECK( field );
777
778   Stage::GetCurrent().Add( field );
779
780   const int maxNumberOfCharacters = 3;
781   field.SetProperty( TextField::Property::MAX_LENGTH, maxNumberOfCharacters );
782
783   field.SetKeyInputFocus();
784
785   // connect to the text changed signal.
786   ConnectionTracker* testTracker = new ConnectionTracker();
787   field.MaxLengthReachedSignal().Connect(&TestMaxLengthReachedCallback);
788   bool maxLengthReachedSignal = false;
789   field.ConnectSignal( testTracker, "maxLengthReached",   CallbackFunctor(&maxLengthReachedSignal) );
790
791   gMaxCharactersCallBackCalled = false;
792
793   application.ProcessEvent( GenerateKey( "a", "a", 0, 0, 0, Integration::KeyEvent::Down ) );
794   application.ProcessEvent( GenerateKey( "a", "a", 0, 0, 0, Integration::KeyEvent::Down ) );
795
796   DALI_TEST_CHECK( !gMaxCharactersCallBackCalled );
797   DALI_TEST_CHECK( !maxLengthReachedSignal );
798
799   END_TEST;
800 }
801
802 int utcDaliTextFieldInputStyleChanged01(void)
803 {
804   ToolkitTestApplication application;
805   tet_infoline(" utcDaliTextFieldInputStyleChanged01");
806
807   // The text-field emits signals when the input style changes. These changes of style are
808   // detected during the relayout process (size negotiation), i.e after the cursor has been moved. Signals
809   // can't be emitted during the size negotiation as the callbacks may update the UI.
810   // The text-field adds an idle callback to the adaptor to emit the signals after the size negotiation.
811   // This creates an implementation of the adaptor stub and a queue of idle callbacks.
812   application.CreateAdaptor();
813
814   // Load some fonts.
815
816   char* pathNamePtr = get_current_dir_name();
817   const std::string pathName( pathNamePtr );
818   free( pathNamePtr );
819
820   TextAbstraction::FontClient fontClient = TextAbstraction::FontClient::Get();
821   fontClient.SetDpi( 93u, 93u );
822
823   fontClient.GetFontId( pathName + DEFAULT_FONT_DIR + "/dejavu/DejaVuSerif.ttf", DEFAULT_FONT_SIZE );
824   fontClient.GetFontId( pathName + DEFAULT_FONT_DIR + "/dejavu/DejaVuSerif-Bold.ttf", DEFAULT_FONT_SIZE );
825
826   TextField field = TextField::New();
827   DALI_TEST_CHECK( field );
828
829
830   field.SetSize( 300.f, 50.f );
831   field.SetParentOrigin( ParentOrigin::TOP_LEFT );
832   field.SetAnchorPoint( AnchorPoint::TOP_LEFT );
833
834   field.SetProperty( TextField::Property::ENABLE_MARKUP, true );
835   field.SetProperty( TextField::Property::TEXT, "<font family='DejaVuSerif' size='18'>He<color value='green'>llo</color> <font weight='bold'>world</font> demo</font>" );
836
837   // connect to the text changed signal.
838   ConnectionTracker* testTracker = new ConnectionTracker();
839   field.InputStyleChangedSignal().Connect( &TestInputStyleChangedCallback );
840   bool inputStyleChangedSignal = false;
841   field.ConnectSignal( testTracker, "inputStyleChanged",   CallbackFunctor(&inputStyleChangedSignal) );
842
843   Stage::GetCurrent().Add( field );
844
845   // Render and notify
846   application.SendNotification();
847   application.Render();
848
849   // Executes the idle callbacks added by the text control on the change of input style.
850   application.RunIdles();
851
852   gInputStyleChangedCallbackCalled = false;
853   gInputStyleMask = TextField::InputStyle::NONE;
854   inputStyleChangedSignal = false;
855
856   // Create a tap event to touch the text field.
857   application.ProcessEvent( GenerateTap( Gesture::Possible, 1u, 1u, Vector2( 18.f, 25.f ) ) );
858   application.ProcessEvent( GenerateTap( Gesture::Started, 1u, 1u, Vector2( 18.f, 25.f ) ) );
859
860   // Render and notify
861   application.SendNotification();
862   application.Render();
863
864   // Executes the idle callbacks added by the text control on the change of input style.
865   application.RunIdles();
866
867   DALI_TEST_CHECK( gInputStyleChangedCallbackCalled );
868   if( gInputStyleChangedCallbackCalled )
869   {
870     DALI_TEST_EQUALS( static_cast<unsigned int>( gInputStyleMask ), static_cast<unsigned int>( TextField::InputStyle::FONT_FAMILY | TextField::InputStyle::POINT_SIZE ), TEST_LOCATION );
871
872     const std::string fontFamily = field.GetProperty( TextField::Property::INPUT_FONT_FAMILY ).Get<std::string>();
873     DALI_TEST_EQUALS( fontFamily, "DejaVuSerif", TEST_LOCATION );
874
875     const float pointSize = field.GetProperty( TextField::Property::INPUT_POINT_SIZE ).Get<float>();
876     DALI_TEST_EQUALS( pointSize, 18.f, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
877   }
878   DALI_TEST_CHECK( inputStyleChangedSignal );
879
880   gInputStyleChangedCallbackCalled = false;
881   gInputStyleMask = TextField::InputStyle::NONE;
882   inputStyleChangedSignal = false;
883
884   // Create a tap event to touch the text field.
885   application.ProcessEvent( GenerateTap( Gesture::Possible, 1u, 1u, Vector2( 30.f, 25.f ) ) );
886   application.ProcessEvent( GenerateTap( Gesture::Started, 1u, 1u, Vector2( 30.f, 25.f ) ) );
887
888   // Render and notify
889   application.SendNotification();
890   application.Render();
891
892   // Executes the idle callbacks added by the text control on the change of input style.
893   application.RunIdles();
894
895   DALI_TEST_CHECK( !gInputStyleChangedCallbackCalled );
896   DALI_TEST_CHECK( !inputStyleChangedSignal );
897
898   gInputStyleChangedCallbackCalled = false;
899   gInputStyleMask = TextField::InputStyle::NONE;
900   inputStyleChangedSignal = false;
901
902   // Create a tap event to touch the text field.
903   application.ProcessEvent( GenerateTap( Gesture::Possible, 1u, 1u, Vector2( 43.f, 25.f ) ) );
904   application.ProcessEvent( GenerateTap( Gesture::Started, 1u, 1u, Vector2( 43.f, 25.f ) ) );
905
906   // Render and notify
907   application.SendNotification();
908   application.Render();
909
910   // Executes the idle callbacks added by the text control on the change of input style.
911   application.RunIdles();
912
913   DALI_TEST_CHECK( gInputStyleChangedCallbackCalled );
914   if( gInputStyleChangedCallbackCalled )
915   {
916     DALI_TEST_EQUALS( static_cast<unsigned int>( gInputStyleMask ), static_cast<unsigned int>( TextField::InputStyle::COLOR ), TEST_LOCATION );
917
918     const Vector4 color = field.GetProperty( TextField::Property::INPUT_COLOR ).Get<Vector4>();
919     DALI_TEST_EQUALS( color, Color::GREEN, TEST_LOCATION );
920   }
921   DALI_TEST_CHECK( inputStyleChangedSignal );
922
923   gInputStyleChangedCallbackCalled = false;
924   gInputStyleMask = TextField::InputStyle::NONE;
925   inputStyleChangedSignal = false;
926
927   // Create a tap event to touch the text field.
928   application.ProcessEvent( GenerateTap( Gesture::Possible, 1u, 1u, Vector2( 88.f, 25.f ) ) );
929   application.ProcessEvent( GenerateTap( Gesture::Started, 1u, 1u, Vector2( 88.f, 25.f ) ) );
930
931   // Render and notify
932   application.SendNotification();
933   application.Render();
934
935   // Executes the idle callbacks added by the text control on the change of input style.
936   application.RunIdles();
937
938   DALI_TEST_CHECK( gInputStyleChangedCallbackCalled );
939   if( gInputStyleChangedCallbackCalled )
940   {
941     DALI_TEST_EQUALS( static_cast<unsigned int>( gInputStyleMask ), static_cast<unsigned int>( TextField::InputStyle::COLOR | TextField::InputStyle::FONT_STYLE ), TEST_LOCATION );
942
943     const Vector4 color = field.GetProperty( TextField::Property::INPUT_COLOR ).Get<Vector4>();
944     DALI_TEST_EQUALS( color, Color::BLACK, TEST_LOCATION );
945
946     const std::string style = field.GetProperty( TextField::Property::INPUT_FONT_STYLE ).Get<std::string>();
947     DALI_TEST_EQUALS( style, "{\"weight\":\"bold\"}", TEST_LOCATION );
948   }
949   DALI_TEST_CHECK( inputStyleChangedSignal );
950
951   gInputStyleChangedCallbackCalled = false;
952   gInputStyleMask = TextField::InputStyle::NONE;
953   inputStyleChangedSignal = false;
954
955   // Create a tap event to touch the text field.
956   application.ProcessEvent( GenerateTap( Gesture::Possible, 1u, 1u, Vector2( 115.f, 25.f ) ) );
957   application.ProcessEvent( GenerateTap( Gesture::Started, 1u, 1u, Vector2( 115.f, 25.f ) ) );
958
959   // Render and notify
960   application.SendNotification();
961   application.Render();
962
963   // Executes the idle callbacks added by the text control on the change of input style.
964   application.RunIdles();
965
966   DALI_TEST_CHECK( !gInputStyleChangedCallbackCalled );
967   DALI_TEST_CHECK( !inputStyleChangedSignal );
968
969   gInputStyleChangedCallbackCalled = false;
970   gInputStyleMask = TextField::InputStyle::NONE;
971   inputStyleChangedSignal = false;
972
973   // Create a tap event to touch the text field.
974   application.ProcessEvent( GenerateTap( Gesture::Possible, 1u, 1u, Vector2( 164.f, 25.f ) ) );
975   application.ProcessEvent( GenerateTap( Gesture::Started, 1u, 1u, Vector2( 164.f, 25.f ) ) );
976
977   // Render and notify
978   application.SendNotification();
979   application.Render();
980
981   // Executes the idle callbacks added by the text control on the change of input style.
982   application.RunIdles();
983
984   DALI_TEST_CHECK( gInputStyleChangedCallbackCalled );
985   if( gInputStyleChangedCallbackCalled )
986   {
987     DALI_TEST_EQUALS( static_cast<unsigned int>( gInputStyleMask ), static_cast<unsigned int>( TextField::InputStyle::FONT_STYLE ), TEST_LOCATION );
988
989     const std::string style = field.GetProperty( TextField::Property::INPUT_FONT_STYLE ).Get<std::string>();
990     DALI_TEST_CHECK( style.empty() );
991   }
992   DALI_TEST_CHECK( inputStyleChangedSignal );
993
994   gInputStyleChangedCallbackCalled = false;
995   gInputStyleMask = TextField::InputStyle::NONE;
996   inputStyleChangedSignal = false;
997
998   // Create a tap event to touch the text field.
999   application.ProcessEvent( GenerateTap( Gesture::Possible, 1u, 1u, Vector2( 191.f, 25.f ) ) );
1000   application.ProcessEvent( GenerateTap( Gesture::Started, 1u, 1u, Vector2( 191.f, 25.f ) ) );
1001
1002   // Render and notify
1003   application.SendNotification();
1004   application.Render();
1005
1006   // Executes the idle callbacks added by the text control on the change of input style.
1007   application.RunIdles();
1008
1009   DALI_TEST_CHECK( !gInputStyleChangedCallbackCalled );
1010   DALI_TEST_CHECK( !inputStyleChangedSignal );
1011
1012   END_TEST;
1013 }
1014
1015 int utcDaliTextFieldInputStyleChanged02(void)
1016 {
1017   ToolkitTestApplication application;
1018   tet_infoline(" utcDaliTextFieldInputStyleChanged02");
1019
1020   // The text-field emits signals when the input style changes. These changes of style are
1021   // detected during the relayout process (size negotiation), i.e after the cursor has been moved. Signals
1022   // can't be emitted during the size negotiation as the callbacks may update the UI.
1023   // The text-field adds an idle callback to the adaptor to emit the signals after the size negotiation.
1024   // This creates an implementation of the adaptor stub and a queue of idle callbacks.
1025   application.CreateAdaptor();
1026
1027   // Load some fonts.
1028
1029   char* pathNamePtr = get_current_dir_name();
1030   const std::string pathName( pathNamePtr );
1031   free( pathNamePtr );
1032
1033   TextAbstraction::FontClient fontClient = TextAbstraction::FontClient::Get();
1034   fontClient.SetDpi( 93u, 93u );
1035
1036   fontClient.GetFontId( pathName + DEFAULT_FONT_DIR + "/dejavu/DejaVuSerif.ttf", DEFAULT_FONT_SIZE );
1037   fontClient.GetFontId( pathName + DEFAULT_FONT_DIR + "/dejavu/DejaVuSerif-Bold.ttf", DEFAULT_FONT_SIZE );
1038
1039   TextField field = TextField::New();
1040   DALI_TEST_CHECK( field );
1041
1042
1043   field.SetSize( 300.f, 50.f );
1044   field.SetParentOrigin( ParentOrigin::TOP_LEFT );
1045   field.SetAnchorPoint( AnchorPoint::TOP_LEFT );
1046
1047   field.SetProperty( TextField::Property::ENABLE_MARKUP, true );
1048   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>" );
1049
1050   // connect to the text changed signal.
1051   ConnectionTracker* testTracker = new ConnectionTracker();
1052   field.InputStyleChangedSignal().Connect( &TestInputStyleChangedCallback );
1053   bool inputStyleChangedSignal = false;
1054   field.ConnectSignal( testTracker, "inputStyleChanged",   CallbackFunctor(&inputStyleChangedSignal) );
1055
1056   Stage::GetCurrent().Add( field );
1057
1058   // Render and notify
1059   application.SendNotification();
1060   application.Render();
1061
1062   // Executes the idle callbacks added by the text control on the change of input style.
1063   application.RunIdles();
1064
1065   gInputStyleChangedCallbackCalled = false;
1066   gInputStyleMask = TextField::InputStyle::NONE;
1067   inputStyleChangedSignal = false;
1068
1069   // Create a tap event to touch the text field.
1070   application.ProcessEvent( GenerateTap( Gesture::Possible, 1u, 1u, Vector2( 53.f, 25.f ) ) );
1071   application.ProcessEvent( GenerateTap( Gesture::Started, 1u, 1u, Vector2( 53.f, 25.f ) ) );
1072   application.ProcessEvent( GenerateTap( Gesture::Possible, 2u, 1u, Vector2( 53.f, 25.f ) ) );
1073   application.ProcessEvent( GenerateTap( Gesture::Started, 2u, 1u, Vector2( 53.f, 25.f ) ) );
1074
1075   // Render and notify
1076   application.SendNotification();
1077   application.Render();
1078
1079   // Executes the idle callbacks added by the text control on the change of input style.
1080   application.RunIdles();
1081
1082   DALI_TEST_CHECK( gInputStyleChangedCallbackCalled );
1083   if( gInputStyleChangedCallbackCalled )
1084   {
1085     DALI_TEST_EQUALS( static_cast<unsigned int>( gInputStyleMask ),
1086                       static_cast<unsigned int>( TextField::InputStyle::FONT_FAMILY |
1087                                                  TextField::InputStyle::POINT_SIZE  |
1088                                                  TextField::InputStyle::COLOR ),
1089                       TEST_LOCATION );
1090
1091     const Vector4 color = field.GetProperty( TextField::Property::INPUT_COLOR ).Get<Vector4>();
1092     DALI_TEST_EQUALS( color, Color::GREEN, TEST_LOCATION );
1093
1094     const std::string fontFamily = field.GetProperty( TextField::Property::INPUT_FONT_FAMILY ).Get<std::string>();
1095     DALI_TEST_EQUALS( fontFamily, "DejaVuSerif", TEST_LOCATION );
1096
1097     const float pointSize = field.GetProperty( TextField::Property::INPUT_POINT_SIZE ).Get<float>();
1098     DALI_TEST_EQUALS( pointSize, 18.f, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
1099   }
1100   DALI_TEST_CHECK( inputStyleChangedSignal );
1101
1102   gInputStyleChangedCallbackCalled = false;
1103   gInputStyleMask = TextField::InputStyle::NONE;
1104   inputStyleChangedSignal = false;
1105
1106   application.ProcessEvent( GenerateKey( "", "", DALI_KEY_BACKSPACE, 0, 0, Integration::KeyEvent::Down ) );
1107
1108   // Render and notify
1109   application.SendNotification();
1110   application.Render();
1111
1112   // Executes the idle callbacks added by the text control on the change of input style.
1113   application.RunIdles();
1114
1115   DALI_TEST_CHECK( gInputStyleChangedCallbackCalled );
1116   if( gInputStyleChangedCallbackCalled )
1117   {
1118     DALI_TEST_EQUALS( static_cast<unsigned int>( gInputStyleMask ),
1119                       static_cast<unsigned int>( TextField::InputStyle::COLOR ),
1120                       TEST_LOCATION );
1121
1122     const Vector4 color = field.GetProperty( TextField::Property::INPUT_COLOR ).Get<Vector4>();
1123     DALI_TEST_EQUALS( color, Color::BLUE, TEST_LOCATION );
1124   }
1125   DALI_TEST_CHECK( inputStyleChangedSignal );
1126
1127   gInputStyleChangedCallbackCalled = false;
1128   gInputStyleMask = TextField::InputStyle::NONE;
1129   inputStyleChangedSignal = false;
1130
1131   application.ProcessEvent( GenerateKey( "", "", DALI_KEY_BACKSPACE, 0, 0, Integration::KeyEvent::Down ) );
1132
1133   // Render and notify
1134   application.SendNotification();
1135   application.Render();
1136
1137   // Executes the idle callbacks added by the text control on the change of input style.
1138   application.RunIdles();
1139
1140   DALI_TEST_CHECK( !gInputStyleChangedCallbackCalled );
1141   DALI_TEST_CHECK( !inputStyleChangedSignal );
1142
1143   gInputStyleChangedCallbackCalled = false;
1144   gInputStyleMask = TextField::InputStyle::NONE;
1145   inputStyleChangedSignal = false;
1146
1147   application.ProcessEvent( GenerateKey( "", "", DALI_KEY_BACKSPACE, 0, 0, Integration::KeyEvent::Down ) );
1148
1149   // Render and notify
1150   application.SendNotification();
1151   application.Render();
1152
1153   // Executes the idle callbacks added by the text control on the change of input style.
1154   application.RunIdles();
1155
1156   DALI_TEST_CHECK( gInputStyleChangedCallbackCalled );
1157   if( gInputStyleChangedCallbackCalled )
1158   {
1159     DALI_TEST_EQUALS( static_cast<unsigned int>( gInputStyleMask ),
1160                       static_cast<unsigned int>( TextField::InputStyle::COLOR ),
1161                       TEST_LOCATION );
1162
1163     const Vector4 color = field.GetProperty( TextField::Property::INPUT_COLOR ).Get<Vector4>();
1164     DALI_TEST_EQUALS( color, Color::BLACK, TEST_LOCATION );
1165   }
1166   DALI_TEST_CHECK( inputStyleChangedSignal );
1167
1168   gInputStyleChangedCallbackCalled = false;
1169   gInputStyleMask = TextField::InputStyle::NONE;
1170   inputStyleChangedSignal = false;
1171
1172   field.SetProperty( TextField::Property::INPUT_COLOR, Color::YELLOW );
1173
1174   field.SetProperty( TextField::Property::INPUT_FONT_STYLE, "{\"weight\":\"thin\",\"width\":\"condensed\",\"slant\":\"italic\"}" );
1175   field.SetProperty( TextField::Property::INPUT_POINT_SIZE, 20.f );
1176
1177   field.SetProperty( TextField::Property::INPUT_UNDERLINE, "underline" );
1178   field.SetProperty( TextField::Property::INPUT_SHADOW, "shadow" );
1179   field.SetProperty( TextField::Property::INPUT_EMBOSS, "emboss" );
1180   field.SetProperty( TextField::Property::INPUT_OUTLINE, "outline" );
1181
1182   // Render and notify
1183   application.SendNotification();
1184   application.Render();
1185
1186   // Executes the idle callbacks added by the text control on the change of input style.
1187   application.RunIdles();
1188
1189   DALI_TEST_CHECK( !gInputStyleChangedCallbackCalled );
1190   DALI_TEST_CHECK( !inputStyleChangedSignal );
1191
1192   // Create a tap event to touch the text field.
1193   application.ProcessEvent( GenerateTap( Gesture::Possible, 1u, 1u, Vector2( 63.f, 25.f ) ) );
1194   application.ProcessEvent( GenerateTap( Gesture::Started, 1u, 1u, Vector2( 63.f, 25.f ) ) );
1195
1196   // Render and notify
1197   application.SendNotification();
1198   application.Render();
1199
1200   // Executes the idle callbacks added by the text control on the change of input style.
1201   application.RunIdles();
1202
1203   DALI_TEST_CHECK( gInputStyleChangedCallbackCalled );
1204   if( gInputStyleChangedCallbackCalled )
1205   {
1206     DALI_TEST_EQUALS( static_cast<unsigned int>( gInputStyleMask ),
1207                       static_cast<unsigned int>( TextField::InputStyle::COLOR |
1208                                                  TextField::InputStyle::POINT_SIZE |
1209                                                  TextField::InputStyle::FONT_STYLE |
1210                                                  TextField::InputStyle::UNDERLINE |
1211                                                  TextField::InputStyle::SHADOW |
1212                                                  TextField::InputStyle::EMBOSS |
1213                                                  TextField::InputStyle::OUTLINE ),
1214                       TEST_LOCATION );
1215
1216     const Vector4 color = field.GetProperty( TextField::Property::INPUT_COLOR ).Get<Vector4>();
1217     DALI_TEST_EQUALS( color, Color::BLACK, TEST_LOCATION );
1218   }
1219   DALI_TEST_CHECK( inputStyleChangedSignal );
1220
1221   END_TEST;
1222 }
1223
1224 int utcDaliTextFieldEvent01(void)
1225 {
1226   ToolkitTestApplication application;
1227   tet_infoline(" utcDaliTextFieldEvent01");
1228
1229   // Creates a tap event. After creating a tap event the text field should
1230   // have the focus and add text with key events should be possible.
1231
1232   TextField field = TextField::New();
1233   DALI_TEST_CHECK( field );
1234
1235   Stage::GetCurrent().Add( field );
1236
1237   field.SetSize( 300.f, 50.f );
1238   field.SetParentOrigin( ParentOrigin::TOP_LEFT );
1239   field.SetAnchorPoint( AnchorPoint::TOP_LEFT );
1240
1241   // Avoid a crash when core load gl resources.
1242   application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
1243
1244   // Render and notify
1245   application.SendNotification();
1246   application.Render();
1247
1248   // Add a key event but as the text field has not the focus it should do nothing.
1249   application.ProcessEvent( GenerateKey( "a", "a", 0, 0, 0, Integration::KeyEvent::Down ) );
1250
1251   // Render and notify
1252   application.SendNotification();
1253   application.Render();
1254
1255   DALI_TEST_EQUALS( field.GetProperty<std::string>( TextField::Property::TEXT ), std::string(""), TEST_LOCATION );
1256
1257   // Create a tap event to touch the text field.
1258   application.ProcessEvent( GenerateTap( Gesture::Possible, 1u, 1u, Vector2( 150.0f, 25.0f ) ) );
1259   application.ProcessEvent( GenerateTap( Gesture::Started, 1u, 1u, Vector2( 150.0f, 25.0f ) ) );
1260
1261   // Render and notify
1262   application.SendNotification();
1263   application.Render();
1264
1265   // Now the text field has the focus, so it can handle the key events.
1266   application.ProcessEvent( GenerateKey( "a", "a", 0, 0, 0, Integration::KeyEvent::Down ) );
1267   application.ProcessEvent( GenerateKey( "a", "a", 0, 0, 0, Integration::KeyEvent::Down ) );
1268
1269   // Render and notify
1270   application.SendNotification();
1271   application.Render();
1272
1273   DALI_TEST_EQUALS( field.GetProperty<std::string>( TextField::Property::TEXT ), std::string("aa"), TEST_LOCATION );
1274
1275   // Create a second text field and send key events to it.
1276   TextField field2 = TextField::New();
1277
1278   field2.SetParentOrigin( ParentOrigin::TOP_LEFT );
1279   field2.SetAnchorPoint( AnchorPoint::TOP_LEFT );
1280   field2.SetSize( 100.f, 100.f );
1281   field2.SetPosition( 100.f, 100.f );
1282
1283   Stage::GetCurrent().Add( field2 );
1284
1285   // Render and notify
1286   application.SendNotification();
1287   application.Render();
1288
1289   // Create a tap event on the second text field.
1290   application.ProcessEvent( GenerateTap( Gesture::Possible, 1u, 1u, Vector2( 150.0f, 125.0f ) ) );
1291   application.ProcessEvent( GenerateTap( Gesture::Started, 1u, 1u, Vector2( 150.0f, 125.0f ) ) );
1292
1293   // Render and notify
1294   application.SendNotification();
1295   application.Render();
1296
1297   // The second text field has the focus. It should handle the key events.
1298   application.ProcessEvent( GenerateKey( "a", "a", 0, 0, 0, Integration::KeyEvent::Down ) );
1299   application.ProcessEvent( GenerateKey( "a", "a", 0, 0, 0, Integration::KeyEvent::Down ) );
1300
1301   // Render and notify
1302   application.SendNotification();
1303   application.Render();
1304
1305   // Check the text has been added to the second text field.
1306   DALI_TEST_EQUALS( field2.GetProperty<std::string>( TextField::Property::TEXT ), std::string("aa"), TEST_LOCATION );
1307
1308   END_TEST;
1309 }
1310
1311 int utcDaliTextFieldEvent02(void)
1312 {
1313   ToolkitTestApplication application;
1314   tet_infoline(" utcDaliTextFieldEvent02");
1315
1316   // Checks if the right number of actors are created.
1317
1318   TextField field = TextField::New();
1319   field.SetProperty( TextField::Property::POINT_SIZE, 10.f );
1320   DALI_TEST_CHECK( field );
1321   LoadMarkerImages(application, field);
1322
1323   Stage::GetCurrent().Add( field );
1324
1325   field.SetSize( 300.f, 50.f );
1326   field.SetParentOrigin( ParentOrigin::TOP_LEFT );
1327   field.SetAnchorPoint( AnchorPoint::TOP_LEFT );
1328
1329   // Avoid a crash when core load gl resources.
1330   application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
1331
1332   // Render and notify
1333   application.SendNotification();
1334   application.Render();
1335
1336   // Check there are the expected number of children ( stencil ).
1337   DALI_TEST_EQUALS( field.GetChildCount(), 1u, TEST_LOCATION );
1338
1339   Actor stencil = field.GetChildAt( 0u );
1340   DALI_TEST_EQUALS( stencil.GetChildCount(), 0u, TEST_LOCATION );
1341
1342   // Create a tap event to touch the text field.
1343   application.ProcessEvent( GenerateTap( Gesture::Possible, 1u, 1u, Vector2( 150.0f, 25.0f ) ) );
1344   application.ProcessEvent( GenerateTap( Gesture::Started, 1u, 1u, Vector2( 150.0f, 25.0f ) ) );
1345
1346   // Render and notify
1347   application.SendNotification();
1348   application.Render();
1349
1350   Actor layer = field.GetChildAt( 1u );
1351   DALI_TEST_CHECK( layer.IsLayer() );
1352
1353   DALI_TEST_EQUALS( layer.GetChildCount(), 1u, TEST_LOCATION ); // The cursor.
1354   DALI_TEST_EQUALS( stencil.GetChildCount(), 0u, TEST_LOCATION );
1355
1356   // Now the text field has the focus, so it can handle the key events.
1357   application.ProcessEvent( GenerateKey( "a", "a", 0, 0, 0, Integration::KeyEvent::Down ) );
1358   application.ProcessEvent( GenerateKey( "a", "a", 0, 0, 0, Integration::KeyEvent::Down ) );
1359
1360   // Render and notify
1361   application.SendNotification();
1362   application.Render();
1363
1364   // Checks the cursor and the renderer have been created.
1365   DALI_TEST_EQUALS( layer.GetChildCount(), 1u, TEST_LOCATION ); // The cursor.
1366   DALI_TEST_EQUALS( stencil.GetChildCount(), 1u, TEST_LOCATION ); // The renderer
1367
1368   Control cursor = Control::DownCast( layer.GetChildAt( 0u ) );
1369   DALI_TEST_CHECK( cursor );
1370
1371   // The offscreen root actor has a container with all the actors which contain the text renderers.
1372   Actor container = stencil.GetChildAt( 0u );
1373   for( unsigned int index = 0; index < container.GetChildCount(); ++index )
1374   {
1375     Renderer renderer = container.GetChildAt( index ).GetRendererAt( 0u );
1376     DALI_TEST_CHECK( renderer );
1377   }
1378
1379   // Move the cursor and check the position changes.
1380   Vector3 position1 = cursor.GetCurrentPosition();
1381
1382   application.ProcessEvent( GenerateKey( "", "", DALI_KEY_CURSOR_LEFT, 0, 0, Integration::KeyEvent::Down ) );
1383   application.ProcessEvent( GenerateKey( "", "", DALI_KEY_CURSOR_LEFT, 0, 0, Integration::KeyEvent::Down ) );
1384
1385   // Render and notify
1386   application.SendNotification();
1387   application.Render();
1388
1389   Vector3 position2 = cursor.GetCurrentPosition();
1390
1391   DALI_TEST_CHECK( position2.x < position1.x );
1392
1393   application.ProcessEvent( GenerateKey( "", "", DALI_KEY_CURSOR_RIGHT, 0, 0, Integration::KeyEvent::Down ) );
1394   application.ProcessEvent( GenerateKey( "", "", DALI_KEY_CURSOR_RIGHT, 0, 0, Integration::KeyEvent::Down ) );
1395
1396   // Render and notify
1397   application.SendNotification();
1398   application.Render();
1399
1400   Vector3 position3 = cursor.GetCurrentPosition();
1401
1402   DALI_TEST_EQUALS( position1, position3, TEST_LOCATION ); // Should be in the same position1.
1403
1404   // Send some taps and check the cursor positions.
1405
1406   // Try to tap at the beginning.
1407   application.ProcessEvent( GenerateTap( Gesture::Possible, 1u, 1u, Vector2( 1.f, 25.0f ) ) );
1408   application.ProcessEvent( GenerateTap( Gesture::Started, 1u, 1u, Vector2( 1.f, 25.0f ) ) );
1409
1410   // Render and notify
1411   application.SendNotification();
1412   application.Render();
1413
1414   // Cursor position should be the same than position1.
1415   Vector3 position4 = cursor.GetCurrentPosition();
1416
1417   DALI_TEST_EQUALS( position2, position4, TEST_LOCATION ); // Should be in the same position2.
1418
1419   // Tap away from the start position.
1420   application.ProcessEvent( GenerateTap( Gesture::Possible, 1u, 1u, Vector2( 16.f, 25.0f ) ) );
1421   application.ProcessEvent( GenerateTap( Gesture::Started, 1u, 1u, Vector2( 16.0f, 25.0f ) ) );
1422
1423   // Render and notify
1424   application.SendNotification();
1425   application.Render();
1426
1427   Vector3 position5 = cursor.GetCurrentPosition();
1428
1429   DALI_TEST_CHECK( position5.x > position4.x );
1430
1431   // Remove all the text.
1432   application.ProcessEvent( GenerateKey( "", "", DALI_KEY_BACKSPACE, 0, 0, Integration::KeyEvent::Down ) );
1433   application.ProcessEvent( GenerateKey( "", "", DALI_KEY_BACKSPACE, 0, 0, Integration::KeyEvent::Down ) );
1434   field.SetProperty( TextField::Property::TEXT, "" );
1435
1436   // Render and notify
1437   application.SendNotification();
1438   application.Render();
1439
1440   // Cursor position should be the same than position2.
1441   Vector3 position6 = cursor.GetCurrentPosition();
1442
1443   DALI_TEST_EQUALS( position2, position6, TEST_LOCATION );// Should be in the same position2.
1444
1445   // Should not be a renderer.
1446   DALI_TEST_EQUALS( stencil.GetChildCount(), 0u, TEST_LOCATION );
1447
1448   END_TEST;
1449 }
1450
1451 int utcDaliTextFieldEvent03(void)
1452 {
1453   ToolkitTestApplication application;
1454   tet_infoline(" utcDaliTextFieldEvent03");
1455
1456   // Checks if the highlight actor is created.
1457
1458   TextField field = TextField::New();
1459   DALI_TEST_CHECK( field );
1460
1461   Stage::GetCurrent().Add( field );
1462
1463   field.SetProperty( TextField::Property::TEXT, "This is a long text for the size of the text-field." );
1464   field.SetProperty( TextField::Property::POINT_SIZE, 10.f );
1465   field.SetSize( 30.f, 50.f );
1466   field.SetParentOrigin( ParentOrigin::TOP_LEFT );
1467   field.SetAnchorPoint( AnchorPoint::TOP_LEFT );
1468
1469   // Avoid a crash when core load gl resources.
1470   application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
1471   LoadMarkerImages(application, field);
1472
1473   // Render and notify
1474   application.SendNotification();
1475   application.Render();
1476
1477   // Tap first to get the focus.
1478   application.ProcessEvent( GenerateTap( Gesture::Possible, 1u, 1u, Vector2( 3.f, 25.0f ) ) );
1479   application.ProcessEvent( GenerateTap( Gesture::Started, 1u, 1u, Vector2( 3.f, 25.0f ) ) );
1480
1481   // Render and notify
1482   application.SendNotification();
1483   application.Render();
1484
1485   // Double tap to select a word.
1486   application.ProcessEvent( GenerateTap( Gesture::Possible, 2u, 1u, Vector2( 3.f, 25.0f ) ) );
1487   application.ProcessEvent( GenerateTap( Gesture::Started, 2u, 1u, Vector2( 3.f, 25.0f ) ) );
1488
1489   // Render and notify
1490   application.SendNotification();
1491   application.Render();
1492
1493   // The offscreen root actor should have two actors: the renderer and the highlight actor.
1494   Actor stencil = field.GetChildAt( 0u );
1495
1496   // The offscreen root actor has a container with all the actors which contain the text renderers.
1497   Actor container = stencil.GetChildAt( 0u );
1498   for( unsigned int index = 0; index < container.GetChildCount(); ++index )
1499   {
1500     Renderer renderer = container.GetChildAt( index ).GetRendererAt( 0u );
1501     DALI_TEST_CHECK( renderer );
1502   }
1503
1504   Renderer highlight = stencil.GetChildAt( 1u ).GetRendererAt( 0u );
1505   DALI_TEST_CHECK( highlight );
1506
1507   END_TEST;
1508 }
1509
1510 int utcDaliTextFieldEvent04(void)
1511 {
1512   ToolkitTestApplication application;
1513   tet_infoline(" utcDaliTextFieldEvent04");
1514
1515   // Checks if the highlight actor is created.
1516
1517   TextField field = TextField::New();
1518   DALI_TEST_CHECK( field );
1519   Stage::GetCurrent().Add( field );
1520   LoadMarkerImages(application, field);
1521   // Render and notify
1522   application.SendNotification();
1523   application.Render();
1524
1525   field.SetProperty( TextField::Property::TEXT, "This is a long text for the size of the text-field." );
1526   field.SetProperty( TextField::Property::POINT_SIZE, 10.f );
1527   field.SetSize( 300.f, 50.f );
1528   field.SetParentOrigin( ParentOrigin::TOP_LEFT );
1529   field.SetAnchorPoint( AnchorPoint::TOP_LEFT );
1530
1531   // Avoid a crash when core load gl resources.
1532   application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
1533   // Render and notify
1534   application.SendNotification();
1535   application.Render();
1536
1537   // Create a tap event to touch the text field.
1538   application.ProcessEvent( GenerateTap( Gesture::Possible, 1u, 1u, Vector2( 150.0f, 25.0f ) ) );
1539   application.ProcessEvent( GenerateTap( Gesture::Started, 1u, 1u, Vector2( 150.0f, 25.0f ) ) );
1540   // Render and notify
1541   application.SendNotification();
1542   application.Render();
1543
1544
1545   // Tap first to get the focus.
1546   application.ProcessEvent( GenerateTap( Gesture::Possible, 1u, 1u, Vector2( 1.f, 25.0f ) ) );
1547   application.ProcessEvent( GenerateTap( Gesture::Started, 1u, 1u, Vector2( 1.f, 25.0f ) ) );
1548
1549   // Render and notify
1550   application.SendNotification();
1551   application.Render();
1552
1553   // Double tap to select a word.
1554   application.ProcessEvent( GenerateTap( Gesture::Possible, 2u, 1u, Vector2( 1.f, 25.0f ) ) );
1555   application.ProcessEvent( GenerateTap( Gesture::Started, 2u, 1u, Vector2( 1.f, 25.0f ) ) );
1556
1557   // Render and notify
1558   application.SendNotification();
1559   application.Render();
1560
1561   // Tap grab handle
1562   application.ProcessEvent( GenerateTap( Gesture::Possible, 1u, 1u, Vector2( 0.f, 40.0f ) ) );
1563   application.ProcessEvent( GenerateTap( Gesture::Started, 1u, 1u, Vector2( 0.f, 40.0f ) ) );
1564   END_TEST;
1565 }
1566
1567 int utcDaliTextFieldEvent05(void)
1568 {
1569   ToolkitTestApplication application;
1570   tet_infoline(" utcDaliTextFieldEvent05");
1571
1572   // Checks dragging of cursor/grab handle
1573
1574   TextField field = TextField::New();
1575   DALI_TEST_CHECK( field );
1576   Stage::GetCurrent().Add( field );
1577   LoadMarkerImages(application, field);
1578   // Render and notify
1579   application.SendNotification();
1580   application.Render();
1581
1582   field.SetProperty( TextField::Property::TEXT, "This is a long text for the size of the text-field." );
1583   field.SetProperty( TextField::Property::POINT_SIZE, 10.f );
1584   field.SetSize( 300.f, 50.f );
1585   field.SetParentOrigin( ParentOrigin::TOP_LEFT );
1586   field.SetAnchorPoint( AnchorPoint::TOP_LEFT );
1587
1588   // Avoid a crash when core load gl resources.
1589   application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
1590   // Render and notify
1591   application.SendNotification();
1592   application.Render();
1593
1594   // Create a tap event to touch the text field.
1595   application.ProcessEvent( GenerateTap( Gesture::Possible, 1u, 1u, Vector2( 150.0f, 25.0f ) ) );
1596   application.ProcessEvent( GenerateTap( Gesture::Started, 1u, 1u, Vector2( 150.0f, 25.0f ) ) );
1597   // Render and notify
1598   application.SendNotification();
1599   application.Render();
1600
1601
1602   // Tap first to get the focus.
1603   application.ProcessEvent( GenerateTap( Gesture::Possible, 1u, 1u, Vector2( 1.f, 25.0f ) ) );
1604   application.ProcessEvent( GenerateTap( Gesture::Started, 1u, 1u, Vector2( 1.f, 25.0f ) ) );
1605
1606   // Render and notify
1607   application.SendNotification();
1608   application.Render();
1609
1610   // Double tap to select a word.
1611   application.ProcessEvent( GenerateTap( Gesture::Possible, 2u, 1u, Vector2( 1.f, 25.0f ) ) );
1612   application.ProcessEvent( GenerateTap( Gesture::Started, 2u, 1u, Vector2( 1.f, 25.0f ) ) );
1613
1614   // Render and notify
1615   application.SendNotification();
1616   application.Render();
1617
1618   // drag grab handle right
1619   Vector2 pos(0.0f, 40.0f);
1620   SendPan(application, Gesture::Possible, pos);
1621   SendPan(application, Gesture::Started, pos);
1622   pos.x += 5.0f;
1623   Wait(application, 100);
1624
1625   for(int i = 0;i<20;i++)
1626   {
1627     SendPan(application, Gesture::Continuing, pos);
1628     pos.x += 5.0f;
1629     Wait(application);
1630   }
1631
1632   SendPan(application, Gesture::Finished, pos);
1633   Wait(application, RENDER_FRAME_INTERVAL);
1634
1635   Actor stencil = field.GetChildAt( 1u );
1636   END_TEST;
1637 }
1638
1639 int utcDaliTextFieldEvent06(void)
1640 {
1641   ToolkitTestApplication application;
1642   tet_infoline(" utcDaliTextFieldEvent06");
1643
1644   // Checks Longpress when in edit mode
1645
1646   TextField field = TextField::New();
1647   DALI_TEST_CHECK( field );
1648   Stage::GetCurrent().Add( field );
1649   LoadMarkerImages(application, field);
1650   // Render and notify
1651   application.SendNotification();
1652   application.Render();
1653
1654   field.SetProperty( TextField::Property::TEXT, "Thisisalongtextforthesizeofthetextfield." );
1655   field.SetProperty( TextField::Property::POINT_SIZE, 10.f );
1656   field.SetSize( 300.f, 50.f );
1657   field.SetParentOrigin( ParentOrigin::TOP_LEFT );
1658   field.SetAnchorPoint( AnchorPoint::TOP_LEFT );
1659
1660   // Avoid a crash when core load gl resources.
1661   application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
1662   // Render and notify
1663   application.SendNotification();
1664   application.Render();
1665
1666   // Create a tap event to touch the text field.
1667   application.ProcessEvent( GenerateTap( Gesture::Possible, 1u, 1u, Vector2( 150.0f, 25.0f ) ) );
1668   application.ProcessEvent( GenerateTap( Gesture::Started, 1u, 1u, Vector2( 150.0f, 25.0f ) ) );
1669   // Render and notify
1670   application.SendNotification();
1671   application.Render();
1672
1673
1674   // Tap first to get the focus.
1675   application.ProcessEvent( GenerateTap( Gesture::Possible, 1u, 1u, Vector2( 1.f, 25.0f ) ) );
1676   application.ProcessEvent( GenerateTap( Gesture::Started, 1u, 1u, Vector2( 1.f, 25.0f ) ) );
1677
1678   // Render and notify
1679   application.SendNotification();
1680   application.Render();
1681
1682   // Long Press
1683   application.ProcessEvent( GenerateLongPress( Gesture::Possible, 1u, Vector2( 1.f, 25.0f ) ) );
1684   application.ProcessEvent( GenerateLongPress( Gesture::Started,  1u, Vector2( 1.f, 25.0f ) ) );
1685
1686   // Render and notify
1687   application.SendNotification();
1688   application.Render();
1689
1690   END_TEST;
1691 }
1692
1693 int utcDaliTextFieldEvent07(void)
1694 {
1695   ToolkitTestApplication application;
1696   tet_infoline(" utcDaliTextFieldEvent07");
1697
1698   // Checks Longpress to start edit mode
1699
1700   TextField field = TextField::New();
1701   DALI_TEST_CHECK( field );
1702   Stage::GetCurrent().Add( field );
1703   LoadMarkerImages(application, field);
1704   // Render and notify
1705   application.SendNotification();
1706   application.Render();
1707
1708   field.SetProperty( TextField::Property::TEXT, "Thisisalongtextforthesizeofthetextfield." );
1709   field.SetProperty( TextField::Property::POINT_SIZE, 10.f );
1710   field.SetSize( 300.f, 50.f );
1711   field.SetParentOrigin( ParentOrigin::TOP_LEFT );
1712   field.SetAnchorPoint( AnchorPoint::TOP_LEFT );
1713
1714   // Avoid a crash when core load gl resources.
1715   application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
1716   // Render and notify
1717   application.SendNotification();
1718   application.Render();
1719
1720   // Long Press
1721   application.ProcessEvent( GenerateLongPress( Gesture::Possible, 1u, Vector2( 1.f, 25.0f ) ) );
1722   application.ProcessEvent( GenerateLongPress( Gesture::Started,  1u, Vector2( 1.f, 25.0f ) ) );
1723
1724   // Render and notify
1725   application.SendNotification();
1726   application.Render();
1727
1728   END_TEST;
1729 }
1730
1731 int utcDaliTextFieldEvent08(void)
1732 {
1733   ToolkitTestApplication application;
1734   tet_infoline(" utcDaliTextFieldEvent08");
1735
1736   Dali::Clipboard clipboard = Clipboard::Get();
1737   clipboard.SetItem("testTextFieldEvent");
1738
1739   // Checks Longpress when only place holder text
1740
1741   TextField field = TextField::New();
1742   DALI_TEST_CHECK( field );
1743   Stage::GetCurrent().Add( field );
1744   LoadMarkerImages(application, field);
1745   // Render and notify
1746   application.SendNotification();
1747   application.Render();
1748
1749   field.SetProperty( TextField::Property::PLACEHOLDER_TEXT, "Setting Placeholder Text" );
1750   field.SetProperty( TextField::Property::POINT_SIZE, 10.f );
1751   field.SetSize( 300.f, 50.f );
1752   field.SetParentOrigin( ParentOrigin::TOP_LEFT );
1753   field.SetAnchorPoint( AnchorPoint::TOP_LEFT );
1754
1755   // Avoid a crash when core load gl resources.
1756   application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
1757   // Render and notify
1758   application.SendNotification();
1759   application.Render();
1760
1761   // Long Press
1762   application.ProcessEvent( GenerateLongPress( Gesture::Possible, 1u, Vector2( 1.f, 25.0f ) ) );
1763   application.ProcessEvent( GenerateLongPress( Gesture::Started,  1u, Vector2( 1.f, 25.0f ) ) );
1764
1765   // Render and notify
1766   application.SendNotification();
1767   application.Render();
1768
1769   Wait(application, 500);
1770
1771   Stage stage = Stage::GetCurrent();
1772   Layer layer = stage.GetRootLayer();
1773   Actor actor = layer.FindChildByName("optionPaste");
1774
1775   if (actor)
1776   {
1777     Vector3 worldPosition = actor.GetCurrentWorldPosition();
1778     Vector2 halfStageSize = stage.GetSize() / 2.0f;
1779     Vector2 position(worldPosition.x + halfStageSize.width, worldPosition.y + halfStageSize.height);
1780
1781     Dali::Integration::TouchEvent event;
1782     event = Dali::Integration::TouchEvent();
1783     event.AddPoint( GetPointDownInside( position ) );
1784     application.ProcessEvent( event );
1785
1786     event = Dali::Integration::TouchEvent();
1787     event.AddPoint( GetPointUpInside( position ) );
1788     application.ProcessEvent( event );
1789   }
1790   DALI_TEST_EQUALS( field.GetProperty<std::string>( TextEditor::Property::TEXT ), std::string("testTextFieldEvent"), TEST_LOCATION );
1791   END_TEST;
1792 }
1793
1794 int utcDaliTextFieldStyleWhilstSelected(void)
1795 {
1796   ToolkitTestApplication application;
1797   tet_infoline(" utcDaliTextFieldStyleWhilstSelected");
1798
1799   // Change font and styles whilst text is selected whilst word selected
1800
1801   TextField field = TextField::New();
1802   DALI_TEST_CHECK( field );
1803   Stage::GetCurrent().Add( field );
1804   LoadMarkerImages(application, field);
1805   // Render and notify
1806   application.SendNotification();
1807   application.Render();
1808
1809   field.SetProperty( TextField::Property::TEXT, "This is a long text for the size of the text-field." );
1810   field.SetProperty( TextField::Property::POINT_SIZE, 10.f );
1811   field.SetSize( 300.f, 50.f );
1812   field.SetParentOrigin( ParentOrigin::TOP_LEFT );
1813   field.SetAnchorPoint( AnchorPoint::TOP_LEFT );
1814
1815   // Avoid a crash when core load gl resources.
1816   application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
1817   // Render and notify
1818   application.SendNotification();
1819   application.Render();
1820
1821   // Create a tap event to touch the text field.
1822   application.ProcessEvent( GenerateTap( Gesture::Possible, 1u, 1u, Vector2( 150.0f, 25.0f ) ) );
1823   application.ProcessEvent( GenerateTap( Gesture::Started, 1u, 1u, Vector2( 150.0f, 25.0f ) ) );
1824   // Render and notify
1825   application.SendNotification();
1826   application.Render();
1827
1828
1829   // Tap first to get the focus.
1830   application.ProcessEvent( GenerateTap( Gesture::Possible, 1u, 1u, Vector2( 1.f, 25.0f ) ) );
1831   application.ProcessEvent( GenerateTap( Gesture::Started, 1u, 1u, Vector2( 1.f, 25.0f ) ) );
1832
1833   // Render and notify
1834   application.SendNotification();
1835   application.Render();
1836
1837   // Double tap to select a word.
1838   application.ProcessEvent( GenerateTap( Gesture::Possible, 2u, 1u, Vector2( 1.f, 25.0f ) ) );
1839   application.ProcessEvent( GenerateTap( Gesture::Started, 2u, 1u, Vector2( 1.f, 25.0f ) ) );
1840
1841   // Render and notify
1842   application.SendNotification();
1843   application.Render();
1844
1845   field.SetProperty( TextField::Property::INPUT_FONT_FAMILY, "Setting input font family" );
1846   DALI_TEST_EQUALS( field.GetProperty<std::string>( TextField::Property::INPUT_FONT_FAMILY ), "Setting input font family", TEST_LOCATION );
1847
1848   field.SetProperty( TextField::Property::INPUT_FONT_STYLE, "{\"weight\":\"bold\",\"slant\":\"italic\"}" );
1849   DALI_TEST_EQUALS( field.GetProperty<std::string>( TextField::Property::INPUT_FONT_STYLE ), "{\"weight\":\"bold\",\"slant\":\"italic\"}", TEST_LOCATION );
1850
1851   field.SetProperty( TextField::Property::INPUT_FONT_STYLE, "{\"width\":\"expanded\",\"slant\":\"italic\"}" );
1852   DALI_TEST_EQUALS( field.GetProperty<std::string>( TextField::Property::INPUT_FONT_STYLE ), "{\"width\":\"expanded\",\"slant\":\"italic\"}", TEST_LOCATION );
1853
1854   field.SetProperty( TextField::Property::INPUT_POINT_SIZE, 12.f );
1855   DALI_TEST_EQUALS( field.GetProperty<float>( TextField::Property::INPUT_POINT_SIZE ), 12.f, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
1856
1857   field.SetProperty( TextField::Property::TEXT_COLOR, Color::RED );
1858   DALI_TEST_EQUALS( field.GetProperty<Vector4>( TextField::Property::TEXT_COLOR ), Color::RED, TEST_LOCATION );
1859
1860   field.SetProperty( TextField::Property::FONT_STYLE, "{\"weight\":\"bold\",\"slant\":\"italic\"}" );
1861   DALI_TEST_EQUALS( field.GetProperty<std::string>( TextField::Property::FONT_STYLE ), "{\"weight\":\"bold\",\"slant\":\"italic\"}", TEST_LOCATION );
1862
1863   field.SetProperty( TextField::Property::FONT_STYLE, "{\"width\":\"expanded\"}" );
1864   DALI_TEST_EQUALS( field.GetProperty<std::string>( TextField::Property::FONT_STYLE ), "{\"width\":\"expanded\"}", TEST_LOCATION );
1865
1866   END_TEST;
1867 }