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