Merge "Add ValueChanged Event for C# ProgressBar and sample" into devel/master
[platform/core/uifw/dali-toolkit.git] / automated-tests / src / dali-toolkit / utc-Dali-TextField.cpp
1 /*
2  * Copyright (c) 2016 Samsung Electronics Co., Ltd.
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  * http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  *
16  */
17
18 #include <iostream>
19 #include <stdlib.h>
20 #include <unistd.h>
21
22 #include <dali/public-api/rendering/renderer.h>
23 #include <dali/integration-api/events/key-event-integ.h>
24 #include <dali/integration-api/events/tap-gesture-event.h>
25 #include <dali/integration-api/events/touch-event-integ.h>
26 #include <dali/integration-api/events/pan-gesture-event.h>
27 #include <dali/integration-api/events/long-press-gesture-event.h>
28 #include <dali-toolkit-test-suite-utils.h>
29 #include <dali-toolkit/dali-toolkit.h>
30 #include "toolkit-clipboard.h"
31
32 using namespace Dali;
33 using namespace Toolkit;
34
35 void dali_textfield_startup(void)
36 {
37   test_return_value = TET_UNDEF;
38 }
39
40 void dali_textfield_cleanup(void)
41 {
42   test_return_value = TET_PASS;
43 }
44
45 namespace
46 {
47
48 const char* const PROPERTY_NAME_RENDERING_BACKEND                    = "renderingBackend";
49 const char* const PROPERTY_NAME_TEXT                                 = "text";
50 const char* const PROPERTY_NAME_PLACEHOLDER_TEXT                     = "placeholderText";
51 const char* const PROPERTY_NAME_PLACEHOLDER_TEXT_FOCUSED             = "placeholderTextFocused";
52 const char* const PROPERTY_NAME_FONT_FAMILY                          = "fontFamily";
53 const char* const PROPERTY_NAME_FONT_STYLE                           = "fontStyle";
54 const char* const PROPERTY_NAME_POINT_SIZE                           = "pointSize";
55 const char* const PROPERTY_NAME_MAX_LENGTH                           = "maxLength";
56 const char* const PROPERTY_NAME_EXCEED_POLICY                        = "exceedPolicy";
57 const char* const PROPERTY_NAME_HORIZONTAL_ALIGNMENT                 = "horizontalAlignment";
58 const char* const PROPERTY_NAME_VERTICAL_ALIGNMENT                   = "verticalAlignment";
59 const char* const PROPERTY_NAME_TEXT_COLOR                           = "textColor";
60 const char* const PROPERTY_NAME_PLACEHOLDER_TEXT_COLOR               = "placeholderTextColor";
61 const char* const PROPERTY_NAME_SHADOW_OFFSET                        = "shadowOffset";
62 const char* const PROPERTY_NAME_SHADOW_COLOR                         = "shadowColor";
63 const char* const PROPERTY_NAME_PRIMARY_CURSOR_COLOR                 = "primaryCursorColor";
64 const char* const PROPERTY_NAME_SECONDARY_CURSOR_COLOR               = "secondaryCursorColor";
65 const char* const PROPERTY_NAME_ENABLE_CURSOR_BLINK                  = "enableCursorBlink";
66 const char* const PROPERTY_NAME_CURSOR_BLINK_INTERVAL                = "cursorBlinkInterval";
67 const char* const PROPERTY_NAME_CURSOR_BLINK_DURATION                = "cursorBlinkDuration";
68 const char* const PROPERTY_NAME_CURSOR_WIDTH                         = "cursorWidth";
69 const char* const PROPERTY_NAME_GRAB_HANDLE_IMAGE                    = "grabHandleImage";
70 const char* const PROPERTY_NAME_GRAB_HANDLE_PRESSED_IMAGE            = "grabHandlePressedImage";
71 const char* const PROPERTY_NAME_SCROLL_THRESHOLD                     = "scrollThreshold";
72 const char* const PROPERTY_NAME_SCROLL_SPEED                         = "scrollSpeed";
73 const char* const PROPERTY_NAME_SELECTION_HANDLE_IMAGE_LEFT          = "selectionHandleImageLeft";
74 const char* const PROPERTY_NAME_SELECTION_HANDLE_IMAGE_RIGHT         = "selectionHandleImageRight";
75 const char* const PROPERTY_NAME_SELECTION_HANDLE_PRESSED_IMAGE_LEFT  = "selectionHandlePressedImageLeft";
76 const char* const PROPERTY_NAME_SELECTION_HANDLE_PRESSED_IMAGE_RIGHT = "selectionHandlePressedImageRight";
77 const char* const PROPERTY_NAME_SELECTION_HANDLE_MARKER_IMAGE_LEFT   = "selectionHandleMarkerImageLeft";
78 const char* const PROPERTY_NAME_SELECTION_HANDLE_MARKER_IMAGE_RIGHT  = "selectionHandleMarkerImageRight";
79 const char* const PROPERTY_NAME_SELECTION_HIGHLIGHT_COLOR            = "selectionHighlightColor";
80 const char* const PROPERTY_NAME_DECORATION_BOUNDING_BOX              = "decorationBoundingBox";
81 const char* const PROPERTY_NAME_INPUT_METHOD_SETTINGS                = "inputMethodSettings";
82 const char* const PROPERTY_NAME_INPUT_COLOR                          = "inputColor";
83 const char* const PROPERTY_NAME_ENABLE_MARKUP                        = "enableMarkup";
84 const char* const PROPERTY_NAME_INPUT_FONT_FAMILY                    = "inputFontFamily";
85 const char* const PROPERTY_NAME_INPUT_FONT_STYLE                     = "inputFontStyle";
86 const char* const PROPERTY_NAME_INPUT_POINT_SIZE                     = "inputPointSize";
87
88 const char* const PROPERTY_NAME_UNDERLINE                            = "underline";
89 const char* const PROPERTY_NAME_INPUT_UNDERLINE                      = "inputUnderline";
90 const char* const PROPERTY_NAME_SHADOW                               = "shadow";
91 const char* const PROPERTY_NAME_INPUT_SHADOW                         = "inputShadow";
92 const char* const PROPERTY_NAME_EMBOSS                               = "emboss";
93 const char* const PROPERTY_NAME_INPUT_EMBOSS                         = "inputEmboss";
94 const char* const PROPERTY_NAME_OUTLINE                              = "outline";
95 const char* const PROPERTY_NAME_INPUT_OUTLINE                        = "inputOutline";
96
97 const int DEFAULT_RENDERING_BACKEND = Dali::Toolkit::Text::DEFAULT_RENDERING_BACKEND;
98
99 const Vector4 PLACEHOLDER_TEXT_COLOR( 0.8f, 0.8f, 0.8f, 0.8f );
100 const Dali::Vector4 LIGHT_BLUE( 0.75f, 0.96f, 1.f, 1.f ); // The text highlight color.
101
102 const unsigned int CURSOR_BLINK_INTERVAL = 500u; // Cursor blink interval
103 const float RENDER_FRAME_INTERVAL = 16.66f;
104
105 const float TO_MILLISECONDS = 1000.f;
106 const float TO_SECONDS = 1.f / TO_MILLISECONDS;
107
108 const float SCROLL_THRESHOLD = 10.f;
109 const float SCROLL_SPEED = 300.f;
110
111 const unsigned int DEFAULT_FONT_SIZE = 1152u;
112 const std::string DEFAULT_FONT_DIR( "/resources/fonts" );
113
114 static bool gTextChangedCallBackCalled;
115 static bool gMaxCharactersCallBackCalled;
116 static bool gInputStyleChangedCallbackCalled;
117 static Dali::Toolkit::TextField::InputStyle::Mask gInputStyleMask;
118
119 static void LoadBitmapResource(TestPlatformAbstraction& platform, int width, int height)
120 {
121   Integration::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 input color property.
652   field.SetProperty( TextField::Property::INPUT_COLOR, Color::YELLOW );
653   DALI_TEST_EQUALS( field.GetProperty<Vector4>( TextField::Property::INPUT_COLOR ), Color::YELLOW, TEST_LOCATION );
654
655   // Check the enable markup property.
656   DALI_TEST_CHECK( !field.GetProperty<bool>( TextField::Property::ENABLE_MARKUP ) );
657   field.SetProperty( TextField::Property::ENABLE_MARKUP, true );
658   DALI_TEST_CHECK( field.GetProperty<bool>( TextField::Property::ENABLE_MARKUP ) );
659
660   // Check input font properties.
661   field.SetProperty( TextField::Property::INPUT_FONT_FAMILY, "Setting input font family" );
662   DALI_TEST_EQUALS( field.GetProperty<std::string>( TextField::Property::INPUT_FONT_FAMILY ), "Setting input font family", TEST_LOCATION );
663
664   fontStyleMapSet.Clear();
665   fontStyleMapSet.Insert( "weight", "bold" );
666   fontStyleMapSet.Insert( "width", "condensed" );
667   fontStyleMapSet.Insert( "slant", "italic" );
668
669   field.SetProperty( TextField::Property::INPUT_FONT_STYLE, fontStyleMapSet );
670   fontStyleMapGet = field.GetProperty<Property::Map>( TextField::Property::INPUT_FONT_STYLE );
671   DALI_TEST_EQUALS( fontStyleMapGet.Count(), fontStyleMapSet.Count(), TEST_LOCATION );
672   DALI_TEST_EQUALS( DaliTestCheckMaps( fontStyleMapGet, fontStyleMapSet ), true, TEST_LOCATION );
673
674   field.SetProperty( TextField::Property::INPUT_POINT_SIZE, 12.f );
675   DALI_TEST_EQUALS( field.GetProperty<float>( TextField::Property::INPUT_POINT_SIZE ), 12.f, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
676
677   // Reset input font style.
678   fontStyleMapSet.Clear();
679   fontStyleMapSet.Insert( "weight", "normal" );
680   fontStyleMapSet.Insert( "slant", "oblique" );
681
682   field.SetProperty( TextField::Property::INPUT_FONT_STYLE, fontStyleMapSet );
683   fontStyleMapGet = field.GetProperty<Property::Map>( TextField::Property::INPUT_FONT_STYLE );
684   DALI_TEST_EQUALS( fontStyleMapGet.Count(), fontStyleMapSet.Count(), TEST_LOCATION );
685   DALI_TEST_EQUALS( DaliTestCheckMaps( fontStyleMapGet, fontStyleMapSet ), true, TEST_LOCATION );
686
687   fontStyleMapSet.Clear();
688   fontStyleMapSet.Insert( "slant", "roman" );
689
690   field.SetProperty( TextField::Property::INPUT_FONT_STYLE, fontStyleMapSet );
691   fontStyleMapGet = field.GetProperty<Property::Map>( TextField::Property::INPUT_FONT_STYLE );
692
693   // Replace 'roman' for 'normal'.
694   slantValue = fontStyleMapGet.Find( "slant" );
695   if( NULL != slantValue )
696   {
697     if( "normal" == slantValue->Get<std::string>() )
698     {
699       fontStyleMapGet["slant"] = "roman";
700     }
701   }
702   DALI_TEST_EQUALS( fontStyleMapGet.Count(), fontStyleMapSet.Count(), TEST_LOCATION );
703   DALI_TEST_EQUALS( DaliTestCheckMaps( fontStyleMapGet, fontStyleMapSet ), true, TEST_LOCATION );
704
705   fontStyleMapSet.Clear();
706
707   field.SetProperty( TextField::Property::INPUT_FONT_STYLE, fontStyleMapSet );
708   fontStyleMapGet = field.GetProperty<Property::Map>( TextField::Property::INPUT_FONT_STYLE );
709   DALI_TEST_EQUALS( fontStyleMapGet.Count(), fontStyleMapSet.Count(), TEST_LOCATION );
710   DALI_TEST_EQUALS( DaliTestCheckMaps( fontStyleMapGet, fontStyleMapSet ), true, TEST_LOCATION );
711
712   Property::Map underlineMapSet;
713   Property::Map underlineMapGet;
714
715   underlineMapSet.Insert( "enable", "true" );
716   underlineMapSet.Insert( "color", "red" );
717   underlineMapSet.Insert( "height", "1" );
718
719   // Check the underline property
720   field.SetProperty( TextField::Property::UNDERLINE, underlineMapSet );
721
722   underlineMapGet = field.GetProperty<Property::Map>( TextField::Property::UNDERLINE );
723   DALI_TEST_EQUALS( underlineMapGet.Count(), underlineMapSet.Count(), TEST_LOCATION );
724   DALI_TEST_EQUALS( DaliTestCheckMaps( underlineMapGet, underlineMapSet ), true, TEST_LOCATION );
725
726   // Check the input underline property
727   field.SetProperty( TextField::Property::INPUT_UNDERLINE, "Underline input properties" );
728   DALI_TEST_EQUALS( field.GetProperty<std::string>( TextField::Property::INPUT_UNDERLINE ), std::string("Underline input properties"), TEST_LOCATION );
729
730   // Check the shadow property
731   Property::Map shadowMapSet;
732   Property::Map shadowMapGet;
733
734   shadowMapSet.Insert( "color", "green" );
735   shadowMapSet.Insert( "offset", "2 2" );
736
737   field.SetProperty( TextField::Property::SHADOW, shadowMapSet );
738
739   shadowMapGet = field.GetProperty<Property::Map>( TextField::Property::SHADOW );
740   DALI_TEST_EQUALS( shadowMapGet.Count(), shadowMapSet.Count(), TEST_LOCATION );
741   DALI_TEST_EQUALS( DaliTestCheckMaps( shadowMapGet, shadowMapSet ), true, TEST_LOCATION );
742
743   // Check the input shadow property
744   field.SetProperty( TextField::Property::INPUT_SHADOW, "Shadow input properties" );
745   DALI_TEST_EQUALS( field.GetProperty<std::string>( TextField::Property::INPUT_SHADOW ), std::string("Shadow input properties"), TEST_LOCATION );
746
747   // Check the emboss property
748   field.SetProperty( TextField::Property::EMBOSS, "Emboss properties" );
749   DALI_TEST_EQUALS( field.GetProperty<std::string>( TextField::Property::EMBOSS ), std::string("Emboss properties"), TEST_LOCATION );
750
751   // Check the input emboss property
752   field.SetProperty( TextField::Property::INPUT_EMBOSS, "Emboss input properties" );
753   DALI_TEST_EQUALS( field.GetProperty<std::string>( TextField::Property::INPUT_EMBOSS ), std::string("Emboss input properties"), TEST_LOCATION );
754
755   // Check the outline property
756   field.SetProperty( TextField::Property::OUTLINE, "Outline properties" );
757   DALI_TEST_EQUALS( field.GetProperty<std::string>( TextField::Property::OUTLINE ), std::string("Outline properties"), TEST_LOCATION );
758
759   // Check the input outline property
760   field.SetProperty( TextField::Property::INPUT_OUTLINE, "Outline input properties" );
761   DALI_TEST_EQUALS( field.GetProperty<std::string>( TextField::Property::INPUT_OUTLINE ), std::string("Outline input properties"), TEST_LOCATION );
762
763   END_TEST;
764 }
765
766 // Positive Atlas Text Renderer test
767 int utcDaliTextFieldAtlasRenderP(void)
768 {
769   ToolkitTestApplication application;
770   tet_infoline(" UtcDaliToolkitTextFieldAtlasRenderP");
771   StyleManager styleManager = StyleManager::Get();
772   styleManager.ApplyDefaultTheme();
773   TextField field = TextField::New();
774   DALI_TEST_CHECK( field );
775
776   field.SetProperty( TextField::Property::HORIZONTAL_ALIGNMENT, "CENTER" );
777
778   application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
779
780   Stage::GetCurrent().Add( field );
781
782   try
783   {
784     // Render some text with the shared atlas backend
785     field.SetProperty( TextField::Property::RENDERING_BACKEND, Text::RENDERING_SHARED_ATLAS );
786     application.SendNotification();
787     application.Render();
788   }
789   catch( ... )
790   {
791     tet_result(TET_FAIL);
792   }
793   END_TEST;
794 }
795
796 // Positive test for the textChanged signal.
797 int utcDaliTextFieldTextChangedP(void)
798 {
799   ToolkitTestApplication application;
800   tet_infoline(" utcDaliTextFieldTextChangedP");
801   TextField field = TextField::New();
802   DALI_TEST_CHECK( field );
803
804   Stage::GetCurrent().Add( field );
805
806   // connect to the text changed signal.
807   ConnectionTracker* testTracker = new ConnectionTracker();
808   field.TextChangedSignal().Connect(&TestTextChangedCallback);
809   bool textChangedSignal = false;
810   field.ConnectSignal( testTracker, "textChanged",   CallbackFunctor(&textChangedSignal) );
811
812   gTextChangedCallBackCalled = false;
813   field.SetProperty( TextField::Property::TEXT, "ABC" );
814   DALI_TEST_CHECK( gTextChangedCallBackCalled );
815   DALI_TEST_CHECK( textChangedSignal );
816
817   application.SendNotification();
818
819   field.SetKeyInputFocus();
820
821   gTextChangedCallBackCalled = false;
822   application.ProcessEvent( GenerateKey( "D", "D", 0, 0, 0, Integration::KeyEvent::Down ) );
823   DALI_TEST_CHECK( gTextChangedCallBackCalled );
824
825   END_TEST;
826 }
827
828 // Negative test for the textChanged signal.
829 int utcDaliTextFieldTextChangedN(void)
830 {
831   ToolkitTestApplication application;
832   tet_infoline(" utcDaliTextFieldTextChangedN");
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::PLACEHOLDER_TEXT, "ABC" ); // Setting placeholder, not TEXT
846   DALI_TEST_CHECK( !gTextChangedCallBackCalled );
847   DALI_TEST_CHECK( !textChangedSignal );
848
849   END_TEST;
850 }
851
852 // Positive test for Max Characters reached signal.
853 int utcDaliTextFieldMaxCharactersReachedP(void)
854 {
855   ToolkitTestApplication application;
856   tet_infoline(" utcDaliTextFieldMaxCharactersReachedP");
857   TextField field = TextField::New();
858   DALI_TEST_CHECK( field );
859
860   Stage::GetCurrent().Add( field );
861
862   const int maxNumberOfCharacters = 1;
863   field.SetProperty( TextField::Property::MAX_LENGTH, maxNumberOfCharacters );
864
865   field.SetKeyInputFocus();
866
867   // connect to the text changed signal.
868   ConnectionTracker* testTracker = new ConnectionTracker();
869   field.MaxLengthReachedSignal().Connect(&TestMaxLengthReachedCallback);
870   bool maxLengthReachedSignal = false;
871   field.ConnectSignal( testTracker, "maxLengthReached",   CallbackFunctor(&maxLengthReachedSignal) );
872
873   gMaxCharactersCallBackCalled = false;
874
875   application.ProcessEvent( GenerateKey( "a", "a", 0, 0, 0, Integration::KeyEvent::Down ) );
876   application.ProcessEvent( GenerateKey( "a", "a", 0, 0, 0, Integration::KeyEvent::Down ) );
877
878   DALI_TEST_CHECK( gMaxCharactersCallBackCalled );
879   DALI_TEST_CHECK( maxLengthReachedSignal );
880
881   END_TEST;
882 }
883
884 // Negative test for Max Characters reached signal.
885 int utcDaliTextFieldMaxCharactersReachedN(void)
886 {
887   ToolkitTestApplication application;
888   tet_infoline(" utcDaliTextFieldMaxCharactersReachedN");
889   TextField field = TextField::New();
890   DALI_TEST_CHECK( field );
891
892   Stage::GetCurrent().Add( field );
893
894   const int maxNumberOfCharacters = 3;
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 int utcDaliTextFieldInputStyleChanged01(void)
917 {
918   ToolkitTestApplication application;
919   tet_infoline(" utcDaliTextFieldInputStyleChanged01");
920
921   // The text-field emits signals when the input style changes. These changes of style are
922   // detected during the relayout process (size negotiation), i.e after the cursor has been moved. Signals
923   // can't be emitted during the size negotiation as the callbacks may update the UI.
924   // The text-field adds an idle callback to the adaptor to emit the signals after the size negotiation.
925   // This creates an implementation of the adaptor stub and a queue of idle callbacks.
926   application.CreateAdaptor();
927
928   // Load some fonts.
929
930   char* pathNamePtr = get_current_dir_name();
931   const std::string pathName( pathNamePtr );
932   free( pathNamePtr );
933
934   TextAbstraction::FontClient fontClient = TextAbstraction::FontClient::Get();
935   fontClient.SetDpi( 93u, 93u );
936
937   fontClient.GetFontId( pathName + DEFAULT_FONT_DIR + "/dejavu/DejaVuSerif.ttf", DEFAULT_FONT_SIZE );
938   fontClient.GetFontId( pathName + DEFAULT_FONT_DIR + "/dejavu/DejaVuSerif-Bold.ttf", DEFAULT_FONT_SIZE );
939
940   TextField field = TextField::New();
941   DALI_TEST_CHECK( field );
942
943
944   field.SetSize( 300.f, 50.f );
945   field.SetParentOrigin( ParentOrigin::TOP_LEFT );
946   field.SetAnchorPoint( AnchorPoint::TOP_LEFT );
947
948   field.SetProperty( TextField::Property::ENABLE_MARKUP, true );
949   field.SetProperty( TextField::Property::TEXT, "<font family='DejaVuSerif' size='18'>He<color value='green'>llo</color> <font weight='bold'>world</font> demo</font>" );
950
951   // connect to the text changed signal.
952   ConnectionTracker* testTracker = new ConnectionTracker();
953   field.InputStyleChangedSignal().Connect( &TestInputStyleChangedCallback );
954   bool inputStyleChangedSignal = false;
955   field.ConnectSignal( testTracker, "inputStyleChanged",   CallbackFunctor(&inputStyleChangedSignal) );
956
957   Stage::GetCurrent().Add( field );
958
959   // Render and notify
960   application.SendNotification();
961   application.Render();
962
963   // Executes the idle callbacks added by the text control on the change of input style.
964   application.RunIdles();
965
966   gInputStyleChangedCallbackCalled = false;
967   gInputStyleMask = TextField::InputStyle::NONE;
968   inputStyleChangedSignal = false;
969
970   // Create a tap event to touch the text field.
971   application.ProcessEvent( GenerateTap( Gesture::Possible, 1u, 1u, Vector2( 18.f, 25.f ) ) );
972   application.ProcessEvent( GenerateTap( Gesture::Started, 1u, 1u, Vector2( 18.f, 25.f ) ) );
973
974   // Render and notify
975   application.SendNotification();
976   application.Render();
977
978   // Executes the idle callbacks added by the text control on the change of input style.
979   application.RunIdles();
980
981   DALI_TEST_CHECK( gInputStyleChangedCallbackCalled );
982   if( gInputStyleChangedCallbackCalled )
983   {
984     DALI_TEST_EQUALS( static_cast<unsigned int>( gInputStyleMask ), static_cast<unsigned int>( TextField::InputStyle::FONT_FAMILY | TextField::InputStyle::POINT_SIZE ), TEST_LOCATION );
985
986     const std::string fontFamily = field.GetProperty( TextField::Property::INPUT_FONT_FAMILY ).Get<std::string>();
987     DALI_TEST_EQUALS( fontFamily, "DejaVuSerif", TEST_LOCATION );
988
989     const float pointSize = field.GetProperty( TextField::Property::INPUT_POINT_SIZE ).Get<float>();
990     DALI_TEST_EQUALS( pointSize, 18.f, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
991   }
992   DALI_TEST_CHECK( inputStyleChangedSignal );
993
994   gInputStyleChangedCallbackCalled = false;
995   gInputStyleMask = TextField::InputStyle::NONE;
996   inputStyleChangedSignal = false;
997
998   // Create a tap event to touch the text field.
999   application.ProcessEvent( GenerateTap( Gesture::Possible, 1u, 1u, Vector2( 30.f, 25.f ) ) );
1000   application.ProcessEvent( GenerateTap( Gesture::Started, 1u, 1u, Vector2( 30.f, 25.f ) ) );
1001
1002   // Render and notify
1003   application.SendNotification();
1004   application.Render();
1005
1006   // Executes the idle callbacks added by the text control on the change of input style.
1007   application.RunIdles();
1008
1009   DALI_TEST_CHECK( !gInputStyleChangedCallbackCalled );
1010   DALI_TEST_CHECK( !inputStyleChangedSignal );
1011
1012   gInputStyleChangedCallbackCalled = false;
1013   gInputStyleMask = TextField::InputStyle::NONE;
1014   inputStyleChangedSignal = false;
1015
1016   // Create a tap event to touch the text field.
1017   application.ProcessEvent( GenerateTap( Gesture::Possible, 1u, 1u, Vector2( 43.f, 25.f ) ) );
1018   application.ProcessEvent( GenerateTap( Gesture::Started, 1u, 1u, Vector2( 43.f, 25.f ) ) );
1019
1020   // Render and notify
1021   application.SendNotification();
1022   application.Render();
1023
1024   // Executes the idle callbacks added by the text control on the change of input style.
1025   application.RunIdles();
1026
1027   DALI_TEST_CHECK( gInputStyleChangedCallbackCalled );
1028   if( gInputStyleChangedCallbackCalled )
1029   {
1030     DALI_TEST_EQUALS( static_cast<unsigned int>( gInputStyleMask ), static_cast<unsigned int>( TextField::InputStyle::COLOR ), TEST_LOCATION );
1031
1032     const Vector4 color = field.GetProperty( TextField::Property::INPUT_COLOR ).Get<Vector4>();
1033     DALI_TEST_EQUALS( color, Color::GREEN, TEST_LOCATION );
1034   }
1035   DALI_TEST_CHECK( inputStyleChangedSignal );
1036
1037   gInputStyleChangedCallbackCalled = false;
1038   gInputStyleMask = TextField::InputStyle::NONE;
1039   inputStyleChangedSignal = false;
1040
1041   // Create a tap event to touch the text field.
1042   application.ProcessEvent( GenerateTap( Gesture::Possible, 1u, 1u, Vector2( 88.f, 25.f ) ) );
1043   application.ProcessEvent( GenerateTap( Gesture::Started, 1u, 1u, Vector2( 88.f, 25.f ) ) );
1044
1045   // Render and notify
1046   application.SendNotification();
1047   application.Render();
1048
1049   // Executes the idle callbacks added by the text control on the change of input style.
1050   application.RunIdles();
1051
1052   DALI_TEST_CHECK( gInputStyleChangedCallbackCalled );
1053   if( gInputStyleChangedCallbackCalled )
1054   {
1055     DALI_TEST_EQUALS( static_cast<unsigned int>( gInputStyleMask ), static_cast<unsigned int>( TextField::InputStyle::COLOR | TextField::InputStyle::FONT_STYLE ), TEST_LOCATION );
1056
1057     const Vector4 color = field.GetProperty( TextField::Property::INPUT_COLOR ).Get<Vector4>();
1058     DALI_TEST_EQUALS( color, Color::BLACK, TEST_LOCATION );
1059
1060     const Property::Map fontStyleMapGet = field.GetProperty( TextField::Property::INPUT_FONT_STYLE ).Get<Property::Map>();
1061
1062     Property::Map fontStyleMapSet;
1063     fontStyleMapSet.Insert( "weight", "bold" );
1064
1065     DALI_TEST_EQUALS( fontStyleMapGet.Count(), fontStyleMapSet.Count(), TEST_LOCATION );
1066     DALI_TEST_EQUALS( DaliTestCheckMaps( fontStyleMapGet, fontStyleMapSet ), true, TEST_LOCATION );
1067   }
1068   DALI_TEST_CHECK( inputStyleChangedSignal );
1069
1070   gInputStyleChangedCallbackCalled = false;
1071   gInputStyleMask = TextField::InputStyle::NONE;
1072   inputStyleChangedSignal = false;
1073
1074   // Create a tap event to touch the text field.
1075   application.ProcessEvent( GenerateTap( Gesture::Possible, 1u, 1u, Vector2( 115.f, 25.f ) ) );
1076   application.ProcessEvent( GenerateTap( Gesture::Started, 1u, 1u, Vector2( 115.f, 25.f ) ) );
1077
1078   // Render and notify
1079   application.SendNotification();
1080   application.Render();
1081
1082   // Executes the idle callbacks added by the text control on the change of input style.
1083   application.RunIdles();
1084
1085   DALI_TEST_CHECK( !gInputStyleChangedCallbackCalled );
1086   DALI_TEST_CHECK( !inputStyleChangedSignal );
1087
1088   gInputStyleChangedCallbackCalled = false;
1089   gInputStyleMask = TextField::InputStyle::NONE;
1090   inputStyleChangedSignal = false;
1091
1092   // Create a tap event to touch the text field.
1093   application.ProcessEvent( GenerateTap( Gesture::Possible, 1u, 1u, Vector2( 164.f, 25.f ) ) );
1094   application.ProcessEvent( GenerateTap( Gesture::Started, 1u, 1u, Vector2( 164.f, 25.f ) ) );
1095
1096   // Render and notify
1097   application.SendNotification();
1098   application.Render();
1099
1100   // Executes the idle callbacks added by the text control on the change of input style.
1101   application.RunIdles();
1102
1103   DALI_TEST_CHECK( gInputStyleChangedCallbackCalled );
1104   if( gInputStyleChangedCallbackCalled )
1105   {
1106     DALI_TEST_EQUALS( static_cast<unsigned int>( gInputStyleMask ), static_cast<unsigned int>( TextField::InputStyle::FONT_STYLE ), TEST_LOCATION );
1107
1108     const std::string style = field.GetProperty( TextField::Property::INPUT_FONT_STYLE ).Get<std::string>();
1109     DALI_TEST_CHECK( style.empty() );
1110   }
1111   DALI_TEST_CHECK( inputStyleChangedSignal );
1112
1113   gInputStyleChangedCallbackCalled = false;
1114   gInputStyleMask = TextField::InputStyle::NONE;
1115   inputStyleChangedSignal = false;
1116
1117   // Create a tap event to touch the text field.
1118   application.ProcessEvent( GenerateTap( Gesture::Possible, 1u, 1u, Vector2( 191.f, 25.f ) ) );
1119   application.ProcessEvent( GenerateTap( Gesture::Started, 1u, 1u, Vector2( 191.f, 25.f ) ) );
1120
1121   // Render and notify
1122   application.SendNotification();
1123   application.Render();
1124
1125   // Executes the idle callbacks added by the text control on the change of input style.
1126   application.RunIdles();
1127
1128   DALI_TEST_CHECK( !gInputStyleChangedCallbackCalled );
1129   DALI_TEST_CHECK( !inputStyleChangedSignal );
1130
1131   END_TEST;
1132 }
1133
1134 int utcDaliTextFieldInputStyleChanged02(void)
1135 {
1136   ToolkitTestApplication application;
1137   tet_infoline(" utcDaliTextFieldInputStyleChanged02");
1138
1139   // The text-field emits signals when the input style changes. These changes of style are
1140   // detected during the relayout process (size negotiation), i.e after the cursor has been moved. Signals
1141   // can't be emitted during the size negotiation as the callbacks may update the UI.
1142   // The text-field adds an idle callback to the adaptor to emit the signals after the size negotiation.
1143   // This creates an implementation of the adaptor stub and a queue of idle callbacks.
1144   application.CreateAdaptor();
1145
1146   // Load some fonts.
1147
1148   char* pathNamePtr = get_current_dir_name();
1149   const std::string pathName( pathNamePtr );
1150   free( pathNamePtr );
1151
1152   TextAbstraction::FontClient fontClient = TextAbstraction::FontClient::Get();
1153   fontClient.SetDpi( 93u, 93u );
1154
1155   fontClient.GetFontId( pathName + DEFAULT_FONT_DIR + "/dejavu/DejaVuSerif.ttf", DEFAULT_FONT_SIZE );
1156   fontClient.GetFontId( pathName + DEFAULT_FONT_DIR + "/dejavu/DejaVuSerif-Bold.ttf", DEFAULT_FONT_SIZE );
1157
1158   TextField field = TextField::New();
1159   DALI_TEST_CHECK( field );
1160
1161
1162   field.SetSize( 300.f, 50.f );
1163   field.SetParentOrigin( ParentOrigin::TOP_LEFT );
1164   field.SetAnchorPoint( AnchorPoint::TOP_LEFT );
1165
1166   field.SetProperty( TextField::Property::ENABLE_MARKUP, true );
1167   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>" );
1168
1169   // connect to the text changed signal.
1170   ConnectionTracker* testTracker = new ConnectionTracker();
1171   field.InputStyleChangedSignal().Connect( &TestInputStyleChangedCallback );
1172   bool inputStyleChangedSignal = false;
1173   field.ConnectSignal( testTracker, "inputStyleChanged",   CallbackFunctor(&inputStyleChangedSignal) );
1174
1175   Stage::GetCurrent().Add( field );
1176
1177   // Render and notify
1178   application.SendNotification();
1179   application.Render();
1180
1181   // Executes the idle callbacks added by the text control on the change of input style.
1182   application.RunIdles();
1183
1184   gInputStyleChangedCallbackCalled = false;
1185   gInputStyleMask = TextField::InputStyle::NONE;
1186   inputStyleChangedSignal = false;
1187
1188   // Create a tap event to touch the text field.
1189   application.ProcessEvent( GenerateTap( Gesture::Possible, 1u, 1u, Vector2( 53.f, 25.f ) ) );
1190   application.ProcessEvent( GenerateTap( Gesture::Started, 1u, 1u, Vector2( 53.f, 25.f ) ) );
1191   application.ProcessEvent( GenerateTap( Gesture::Possible, 2u, 1u, Vector2( 53.f, 25.f ) ) );
1192   application.ProcessEvent( GenerateTap( Gesture::Started, 2u, 1u, Vector2( 53.f, 25.f ) ) );
1193
1194   // Render and notify
1195   application.SendNotification();
1196   application.Render();
1197
1198   // Executes the idle callbacks added by the text control on the change of input style.
1199   application.RunIdles();
1200
1201   DALI_TEST_CHECK( gInputStyleChangedCallbackCalled );
1202   if( gInputStyleChangedCallbackCalled )
1203   {
1204     DALI_TEST_EQUALS( static_cast<unsigned int>( gInputStyleMask ),
1205                       static_cast<unsigned int>( TextField::InputStyle::FONT_FAMILY |
1206                                                  TextField::InputStyle::POINT_SIZE  |
1207                                                  TextField::InputStyle::COLOR ),
1208                       TEST_LOCATION );
1209
1210     const Vector4 color = field.GetProperty( TextField::Property::INPUT_COLOR ).Get<Vector4>();
1211     DALI_TEST_EQUALS( color, Color::GREEN, TEST_LOCATION );
1212
1213     const std::string fontFamily = field.GetProperty( TextField::Property::INPUT_FONT_FAMILY ).Get<std::string>();
1214     DALI_TEST_EQUALS( fontFamily, "DejaVuSerif", TEST_LOCATION );
1215
1216     const float pointSize = field.GetProperty( TextField::Property::INPUT_POINT_SIZE ).Get<float>();
1217     DALI_TEST_EQUALS( pointSize, 18.f, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
1218   }
1219   DALI_TEST_CHECK( inputStyleChangedSignal );
1220
1221   gInputStyleChangedCallbackCalled = false;
1222   gInputStyleMask = TextField::InputStyle::NONE;
1223   inputStyleChangedSignal = false;
1224
1225   application.ProcessEvent( GenerateKey( "", "", DALI_KEY_BACKSPACE, 0, 0, Integration::KeyEvent::Down ) );
1226
1227   // Render and notify
1228   application.SendNotification();
1229   application.Render();
1230
1231   // Executes the idle callbacks added by the text control on the change of input style.
1232   application.RunIdles();
1233
1234   DALI_TEST_CHECK( gInputStyleChangedCallbackCalled );
1235   if( gInputStyleChangedCallbackCalled )
1236   {
1237     DALI_TEST_EQUALS( static_cast<unsigned int>( gInputStyleMask ),
1238                       static_cast<unsigned int>( TextField::InputStyle::COLOR ),
1239                       TEST_LOCATION );
1240
1241     const Vector4 color = field.GetProperty( TextField::Property::INPUT_COLOR ).Get<Vector4>();
1242     DALI_TEST_EQUALS( color, Color::BLUE, TEST_LOCATION );
1243   }
1244   DALI_TEST_CHECK( inputStyleChangedSignal );
1245
1246   gInputStyleChangedCallbackCalled = false;
1247   gInputStyleMask = TextField::InputStyle::NONE;
1248   inputStyleChangedSignal = false;
1249
1250   application.ProcessEvent( GenerateKey( "", "", DALI_KEY_BACKSPACE, 0, 0, Integration::KeyEvent::Down ) );
1251
1252   // Render and notify
1253   application.SendNotification();
1254   application.Render();
1255
1256   // Executes the idle callbacks added by the text control on the change of input style.
1257   application.RunIdles();
1258
1259   DALI_TEST_CHECK( !gInputStyleChangedCallbackCalled );
1260   DALI_TEST_CHECK( !inputStyleChangedSignal );
1261
1262   gInputStyleChangedCallbackCalled = false;
1263   gInputStyleMask = TextField::InputStyle::NONE;
1264   inputStyleChangedSignal = false;
1265
1266   application.ProcessEvent( GenerateKey( "", "", DALI_KEY_BACKSPACE, 0, 0, Integration::KeyEvent::Down ) );
1267
1268   // Render and notify
1269   application.SendNotification();
1270   application.Render();
1271
1272   // Executes the idle callbacks added by the text control on the change of input style.
1273   application.RunIdles();
1274
1275   DALI_TEST_CHECK( gInputStyleChangedCallbackCalled );
1276   if( gInputStyleChangedCallbackCalled )
1277   {
1278     DALI_TEST_EQUALS( static_cast<unsigned int>( gInputStyleMask ),
1279                       static_cast<unsigned int>( TextField::InputStyle::COLOR ),
1280                       TEST_LOCATION );
1281
1282     const Vector4 color = field.GetProperty( TextField::Property::INPUT_COLOR ).Get<Vector4>();
1283     DALI_TEST_EQUALS( color, Color::BLACK, TEST_LOCATION );
1284   }
1285   DALI_TEST_CHECK( inputStyleChangedSignal );
1286
1287   gInputStyleChangedCallbackCalled = false;
1288   gInputStyleMask = TextField::InputStyle::NONE;
1289   inputStyleChangedSignal = false;
1290
1291   field.SetProperty( TextField::Property::INPUT_COLOR, Color::YELLOW );
1292
1293   Property::Map fontStyleMapSet;
1294   fontStyleMapSet.Insert( "weight", "thin" );
1295   fontStyleMapSet.Insert( "width", "condensed" );
1296   fontStyleMapSet.Insert( "slant", "italic" );
1297
1298   field.SetProperty( TextField::Property::INPUT_FONT_STYLE, fontStyleMapSet );
1299   field.SetProperty( TextField::Property::INPUT_POINT_SIZE, 20.f );
1300
1301   field.SetProperty( TextField::Property::INPUT_UNDERLINE, "underline" );
1302   field.SetProperty( TextField::Property::INPUT_SHADOW, "shadow" );
1303   field.SetProperty( TextField::Property::INPUT_EMBOSS, "emboss" );
1304   field.SetProperty( TextField::Property::INPUT_OUTLINE, "outline" );
1305
1306   // Render and notify
1307   application.SendNotification();
1308   application.Render();
1309
1310   // Executes the idle callbacks added by the text control on the change of input style.
1311   application.RunIdles();
1312
1313   DALI_TEST_CHECK( !gInputStyleChangedCallbackCalled );
1314   DALI_TEST_CHECK( !inputStyleChangedSignal );
1315
1316   // Create a tap event to touch the text field.
1317   application.ProcessEvent( GenerateTap( Gesture::Possible, 1u, 1u, Vector2( 63.f, 25.f ) ) );
1318   application.ProcessEvent( GenerateTap( Gesture::Started, 1u, 1u, Vector2( 63.f, 25.f ) ) );
1319
1320   // Render and notify
1321   application.SendNotification();
1322   application.Render();
1323
1324   // Executes the idle callbacks added by the text control on the change of input style.
1325   application.RunIdles();
1326
1327   DALI_TEST_CHECK( gInputStyleChangedCallbackCalled );
1328   if( gInputStyleChangedCallbackCalled )
1329   {
1330     DALI_TEST_EQUALS( static_cast<unsigned int>( gInputStyleMask ),
1331                       static_cast<unsigned int>( TextField::InputStyle::COLOR |
1332                                                  TextField::InputStyle::POINT_SIZE |
1333                                                  TextField::InputStyle::FONT_STYLE |
1334                                                  TextField::InputStyle::UNDERLINE |
1335                                                  TextField::InputStyle::SHADOW |
1336                                                  TextField::InputStyle::EMBOSS |
1337                                                  TextField::InputStyle::OUTLINE ),
1338                       TEST_LOCATION );
1339
1340     const Vector4 color = field.GetProperty( TextField::Property::INPUT_COLOR ).Get<Vector4>();
1341     DALI_TEST_EQUALS( color, Color::BLACK, TEST_LOCATION );
1342   }
1343   DALI_TEST_CHECK( inputStyleChangedSignal );
1344
1345   END_TEST;
1346 }
1347
1348 int utcDaliTextFieldEvent01(void)
1349 {
1350   ToolkitTestApplication application;
1351   tet_infoline(" utcDaliTextFieldEvent01");
1352
1353   // Creates a tap event. After creating a tap event the text field should
1354   // have the focus and add text with key events should be possible.
1355
1356   TextField field = TextField::New();
1357   DALI_TEST_CHECK( field );
1358
1359   Stage::GetCurrent().Add( field );
1360
1361   field.SetSize( 300.f, 50.f );
1362   field.SetParentOrigin( ParentOrigin::TOP_LEFT );
1363   field.SetAnchorPoint( AnchorPoint::TOP_LEFT );
1364
1365   // Avoid a crash when core load gl resources.
1366   application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
1367
1368   // Render and notify
1369   application.SendNotification();
1370   application.Render();
1371
1372   // Add a key event but as the text field has not the focus it should do nothing.
1373   application.ProcessEvent( GenerateKey( "a", "a", 0, 0, 0, Integration::KeyEvent::Down ) );
1374
1375   // Render and notify
1376   application.SendNotification();
1377   application.Render();
1378
1379   DALI_TEST_EQUALS( field.GetProperty<std::string>( TextField::Property::TEXT ), std::string(""), TEST_LOCATION );
1380
1381   // Create a tap event to touch the text field.
1382   application.ProcessEvent( GenerateTap( Gesture::Possible, 1u, 1u, Vector2( 150.0f, 25.0f ) ) );
1383   application.ProcessEvent( GenerateTap( Gesture::Started, 1u, 1u, Vector2( 150.0f, 25.0f ) ) );
1384
1385   // Render and notify
1386   application.SendNotification();
1387   application.Render();
1388
1389   // Now the text field has the focus, so it can handle the key events.
1390   application.ProcessEvent( GenerateKey( "a", "a", 0, 0, 0, Integration::KeyEvent::Down ) );
1391   application.ProcessEvent( GenerateKey( "a", "a", 0, 0, 0, Integration::KeyEvent::Down ) );
1392
1393   // Render and notify
1394   application.SendNotification();
1395   application.Render();
1396
1397   DALI_TEST_EQUALS( field.GetProperty<std::string>( TextField::Property::TEXT ), std::string("aa"), TEST_LOCATION );
1398
1399   // Create a second text field and send key events to it.
1400   TextField field2 = TextField::New();
1401
1402   field2.SetParentOrigin( ParentOrigin::TOP_LEFT );
1403   field2.SetAnchorPoint( AnchorPoint::TOP_LEFT );
1404   field2.SetSize( 100.f, 100.f );
1405   field2.SetPosition( 100.f, 100.f );
1406
1407   Stage::GetCurrent().Add( field2 );
1408
1409   // Render and notify
1410   application.SendNotification();
1411   application.Render();
1412
1413   // Create a tap event on the second text field.
1414   application.ProcessEvent( GenerateTap( Gesture::Possible, 1u, 1u, Vector2( 150.0f, 125.0f ) ) );
1415   application.ProcessEvent( GenerateTap( Gesture::Started, 1u, 1u, Vector2( 150.0f, 125.0f ) ) );
1416
1417   // Render and notify
1418   application.SendNotification();
1419   application.Render();
1420
1421   // The second text field has the focus. It should 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   // Check the text has been added to the second text field.
1430   DALI_TEST_EQUALS( field2.GetProperty<std::string>( TextField::Property::TEXT ), std::string("aa"), TEST_LOCATION );
1431
1432   END_TEST;
1433 }
1434
1435 int utcDaliTextFieldEvent02(void)
1436 {
1437   ToolkitTestApplication application;
1438   tet_infoline(" utcDaliTextFieldEvent02");
1439
1440   // Checks if the right number of actors are created.
1441
1442   TextField field = TextField::New();
1443   field.SetProperty( TextField::Property::POINT_SIZE, 10.f );
1444   DALI_TEST_CHECK( field );
1445   LoadMarkerImages(application, field);
1446
1447   Stage::GetCurrent().Add( field );
1448
1449   field.SetSize( 300.f, 50.f );
1450   field.SetParentOrigin( ParentOrigin::TOP_LEFT );
1451   field.SetAnchorPoint( AnchorPoint::TOP_LEFT );
1452
1453   // Avoid a crash when core load gl resources.
1454   application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
1455
1456   // Render and notify
1457   application.SendNotification();
1458   application.Render();
1459
1460   // Check there are the expected number of children ( stencil ).
1461   DALI_TEST_EQUALS( field.GetChildCount(), 1u, TEST_LOCATION );
1462
1463   Actor stencil = field.GetChildAt( 0u );
1464   DALI_TEST_EQUALS( stencil.GetChildCount(), 0u, TEST_LOCATION );
1465
1466   // Create a tap event to touch the text field.
1467   application.ProcessEvent( GenerateTap( Gesture::Possible, 1u, 1u, Vector2( 150.0f, 25.0f ) ) );
1468   application.ProcessEvent( GenerateTap( Gesture::Started, 1u, 1u, Vector2( 150.0f, 25.0f ) ) );
1469
1470   // Render and notify
1471   application.SendNotification();
1472   application.Render();
1473
1474   Actor layer = field.GetChildAt( 1u );
1475   DALI_TEST_CHECK( layer.IsLayer() );
1476
1477   DALI_TEST_EQUALS( layer.GetChildCount(), 1u, TEST_LOCATION ); // The cursor.
1478   DALI_TEST_EQUALS( stencil.GetChildCount(), 0u, TEST_LOCATION );
1479
1480   // Now the text field has the focus, so it can handle the key events.
1481   application.ProcessEvent( GenerateKey( "a", "a", 0, 0, 0, Integration::KeyEvent::Down ) );
1482   application.ProcessEvent( GenerateKey( "a", "a", 0, 0, 0, Integration::KeyEvent::Down ) );
1483
1484   // Render and notify
1485   application.SendNotification();
1486   application.Render();
1487
1488   // Checks the cursor and the renderer have been created.
1489   DALI_TEST_EQUALS( layer.GetChildCount(), 1u, TEST_LOCATION ); // The cursor.
1490   DALI_TEST_EQUALS( stencil.GetChildCount(), 1u, TEST_LOCATION ); // The renderer
1491
1492   Control cursor = Control::DownCast( layer.GetChildAt( 0u ) );
1493   DALI_TEST_CHECK( cursor );
1494
1495   // The offscreen root actor has a container with all the actors which contain the text renderers.
1496   Actor container = stencil.GetChildAt( 0u );
1497   for( unsigned int index = 0; index < container.GetChildCount(); ++index )
1498   {
1499     Renderer renderer = container.GetChildAt( index ).GetRendererAt( 0u );
1500     DALI_TEST_CHECK( renderer );
1501   }
1502
1503   // Move the cursor and check the position changes.
1504   Vector3 position1 = cursor.GetCurrentPosition();
1505
1506   application.ProcessEvent( GenerateKey( "", "", DALI_KEY_CURSOR_LEFT, 0, 0, Integration::KeyEvent::Down ) );
1507   application.ProcessEvent( GenerateKey( "", "", DALI_KEY_CURSOR_LEFT, 0, 0, Integration::KeyEvent::Down ) );
1508
1509   // Render and notify
1510   application.SendNotification();
1511   application.Render();
1512
1513   Vector3 position2 = cursor.GetCurrentPosition();
1514
1515   DALI_TEST_CHECK( position2.x < position1.x );
1516
1517   application.ProcessEvent( GenerateKey( "", "", DALI_KEY_CURSOR_RIGHT, 0, 0, Integration::KeyEvent::Down ) );
1518   application.ProcessEvent( GenerateKey( "", "", DALI_KEY_CURSOR_RIGHT, 0, 0, Integration::KeyEvent::Down ) );
1519
1520   // Render and notify
1521   application.SendNotification();
1522   application.Render();
1523
1524   Vector3 position3 = cursor.GetCurrentPosition();
1525
1526   DALI_TEST_EQUALS( position1, position3, TEST_LOCATION ); // Should be in the same position1.
1527
1528   // Send some taps and check the cursor positions.
1529
1530   // Try to tap at the beginning.
1531   application.ProcessEvent( GenerateTap( Gesture::Possible, 1u, 1u, Vector2( 1.f, 25.0f ) ) );
1532   application.ProcessEvent( GenerateTap( Gesture::Started, 1u, 1u, Vector2( 1.f, 25.0f ) ) );
1533
1534   // Render and notify
1535   application.SendNotification();
1536   application.Render();
1537
1538   // Cursor position should be the same than position1.
1539   Vector3 position4 = cursor.GetCurrentPosition();
1540
1541   DALI_TEST_EQUALS( position2, position4, TEST_LOCATION ); // Should be in the same position2.
1542
1543   // Tap away from the start position.
1544   application.ProcessEvent( GenerateTap( Gesture::Possible, 1u, 1u, Vector2( 16.f, 25.0f ) ) );
1545   application.ProcessEvent( GenerateTap( Gesture::Started, 1u, 1u, Vector2( 16.0f, 25.0f ) ) );
1546
1547   // Render and notify
1548   application.SendNotification();
1549   application.Render();
1550
1551   Vector3 position5 = cursor.GetCurrentPosition();
1552
1553   DALI_TEST_CHECK( position5.x > position4.x );
1554
1555   // Remove all the text.
1556   application.ProcessEvent( GenerateKey( "", "", DALI_KEY_BACKSPACE, 0, 0, Integration::KeyEvent::Down ) );
1557   application.ProcessEvent( GenerateKey( "", "", DALI_KEY_BACKSPACE, 0, 0, Integration::KeyEvent::Down ) );
1558   field.SetProperty( TextField::Property::TEXT, "" );
1559
1560   // Render and notify
1561   application.SendNotification();
1562   application.Render();
1563
1564   // Cursor position should be the same than position2.
1565   Vector3 position6 = cursor.GetCurrentPosition();
1566
1567   DALI_TEST_EQUALS( position2, position6, TEST_LOCATION );// Should be in the same position2.
1568
1569   // Should not be a renderer.
1570   DALI_TEST_EQUALS( stencil.GetChildCount(), 0u, TEST_LOCATION );
1571
1572   END_TEST;
1573 }
1574
1575 int utcDaliTextFieldEvent03(void)
1576 {
1577   ToolkitTestApplication application;
1578   tet_infoline(" utcDaliTextFieldEvent03");
1579
1580   // Checks if the highlight actor is created.
1581
1582   TextField field = TextField::New();
1583   DALI_TEST_CHECK( field );
1584
1585   Stage::GetCurrent().Add( field );
1586
1587   field.SetProperty( TextField::Property::TEXT, "This is a long text for the size of the text-field." );
1588   field.SetProperty( TextField::Property::POINT_SIZE, 10.f );
1589   field.SetSize( 30.f, 50.f );
1590   field.SetParentOrigin( ParentOrigin::TOP_LEFT );
1591   field.SetAnchorPoint( AnchorPoint::TOP_LEFT );
1592
1593   // Avoid a crash when core load gl resources.
1594   application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
1595   LoadMarkerImages(application, field);
1596
1597   // Render and notify
1598   application.SendNotification();
1599   application.Render();
1600
1601   // Tap first to get the focus.
1602   application.ProcessEvent( GenerateTap( Gesture::Possible, 1u, 1u, Vector2( 3.f, 25.0f ) ) );
1603   application.ProcessEvent( GenerateTap( Gesture::Started, 1u, 1u, Vector2( 3.f, 25.0f ) ) );
1604
1605   // Render and notify
1606   application.SendNotification();
1607   application.Render();
1608
1609   // Double tap to select a word.
1610   application.ProcessEvent( GenerateTap( Gesture::Possible, 2u, 1u, Vector2( 3.f, 25.0f ) ) );
1611   application.ProcessEvent( GenerateTap( Gesture::Started, 2u, 1u, Vector2( 3.f, 25.0f ) ) );
1612
1613   // Render and notify
1614   application.SendNotification();
1615   application.Render();
1616
1617   // The offscreen root actor should have two actors: the renderer and the highlight actor.
1618   Actor stencil = field.GetChildAt( 0u );
1619
1620   // The offscreen root actor has a container with all the actors which contain the text renderers.
1621   Actor container = stencil.GetChildAt( 0u );
1622   for( unsigned int index = 0; index < container.GetChildCount(); ++index )
1623   {
1624     Renderer renderer = container.GetChildAt( index ).GetRendererAt( 0u );
1625     DALI_TEST_CHECK( renderer );
1626   }
1627
1628   Renderer highlight = stencil.GetChildAt( 1u ).GetRendererAt( 0u );
1629   DALI_TEST_CHECK( highlight );
1630
1631   END_TEST;
1632 }
1633
1634 int utcDaliTextFieldEvent04(void)
1635 {
1636   ToolkitTestApplication application;
1637   tet_infoline(" utcDaliTextFieldEvent04");
1638
1639   // Checks if the highlight actor is created.
1640
1641   TextField field = TextField::New();
1642   DALI_TEST_CHECK( field );
1643   Stage::GetCurrent().Add( field );
1644   LoadMarkerImages(application, field);
1645   // Render and notify
1646   application.SendNotification();
1647   application.Render();
1648
1649   field.SetProperty( TextField::Property::TEXT, "This is a long text for the size of the text-field." );
1650   field.SetProperty( TextField::Property::POINT_SIZE, 10.f );
1651   field.SetSize( 300.f, 50.f );
1652   field.SetParentOrigin( ParentOrigin::TOP_LEFT );
1653   field.SetAnchorPoint( AnchorPoint::TOP_LEFT );
1654
1655   // Avoid a crash when core load gl resources.
1656   application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
1657   // Render and notify
1658   application.SendNotification();
1659   application.Render();
1660
1661   // Create a tap event to touch the text field.
1662   application.ProcessEvent( GenerateTap( Gesture::Possible, 1u, 1u, Vector2( 150.0f, 25.0f ) ) );
1663   application.ProcessEvent( GenerateTap( Gesture::Started, 1u, 1u, Vector2( 150.0f, 25.0f ) ) );
1664   // Render and notify
1665   application.SendNotification();
1666   application.Render();
1667
1668
1669   // Tap first to get the focus.
1670   application.ProcessEvent( GenerateTap( Gesture::Possible, 1u, 1u, Vector2( 1.f, 25.0f ) ) );
1671   application.ProcessEvent( GenerateTap( Gesture::Started, 1u, 1u, Vector2( 1.f, 25.0f ) ) );
1672
1673   // Render and notify
1674   application.SendNotification();
1675   application.Render();
1676
1677   // Double tap to select a word.
1678   application.ProcessEvent( GenerateTap( Gesture::Possible, 2u, 1u, Vector2( 1.f, 25.0f ) ) );
1679   application.ProcessEvent( GenerateTap( Gesture::Started, 2u, 1u, Vector2( 1.f, 25.0f ) ) );
1680
1681   // Render and notify
1682   application.SendNotification();
1683   application.Render();
1684
1685   // Tap grab handle
1686   application.ProcessEvent( GenerateTap( Gesture::Possible, 1u, 1u, Vector2( 0.f, 40.0f ) ) );
1687   application.ProcessEvent( GenerateTap( Gesture::Started, 1u, 1u, Vector2( 0.f, 40.0f ) ) );
1688   END_TEST;
1689 }
1690
1691 int utcDaliTextFieldEvent05(void)
1692 {
1693   ToolkitTestApplication application;
1694   tet_infoline(" utcDaliTextFieldEvent05");
1695
1696   // Checks dragging of cursor/grab handle
1697
1698   TextField field = TextField::New();
1699   DALI_TEST_CHECK( field );
1700   Stage::GetCurrent().Add( field );
1701   LoadMarkerImages(application, field);
1702   // Render and notify
1703   application.SendNotification();
1704   application.Render();
1705
1706   field.SetProperty( TextField::Property::TEXT, "This is a long text for the size of the text-field." );
1707   field.SetProperty( TextField::Property::POINT_SIZE, 10.f );
1708   field.SetSize( 300.f, 50.f );
1709   field.SetParentOrigin( ParentOrigin::TOP_LEFT );
1710   field.SetAnchorPoint( AnchorPoint::TOP_LEFT );
1711
1712   // Avoid a crash when core load gl resources.
1713   application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
1714   // Render and notify
1715   application.SendNotification();
1716   application.Render();
1717
1718   // Create a tap event to touch the text field.
1719   application.ProcessEvent( GenerateTap( Gesture::Possible, 1u, 1u, Vector2( 150.0f, 25.0f ) ) );
1720   application.ProcessEvent( GenerateTap( Gesture::Started, 1u, 1u, Vector2( 150.0f, 25.0f ) ) );
1721   // Render and notify
1722   application.SendNotification();
1723   application.Render();
1724
1725
1726   // Tap first to get the focus.
1727   application.ProcessEvent( GenerateTap( Gesture::Possible, 1u, 1u, Vector2( 1.f, 25.0f ) ) );
1728   application.ProcessEvent( GenerateTap( Gesture::Started, 1u, 1u, Vector2( 1.f, 25.0f ) ) );
1729
1730   // Render and notify
1731   application.SendNotification();
1732   application.Render();
1733
1734   // Double tap to select a word.
1735   application.ProcessEvent( GenerateTap( Gesture::Possible, 2u, 1u, Vector2( 1.f, 25.0f ) ) );
1736   application.ProcessEvent( GenerateTap( Gesture::Started, 2u, 1u, Vector2( 1.f, 25.0f ) ) );
1737
1738   // Render and notify
1739   application.SendNotification();
1740   application.Render();
1741
1742   // drag grab handle right
1743   Vector2 pos(0.0f, 40.0f);
1744   SendPan(application, Gesture::Possible, pos);
1745   SendPan(application, Gesture::Started, pos);
1746   pos.x += 5.0f;
1747   Wait(application, 100);
1748
1749   for(int i = 0;i<20;i++)
1750   {
1751     SendPan(application, Gesture::Continuing, pos);
1752     pos.x += 5.0f;
1753     Wait(application);
1754   }
1755
1756   SendPan(application, Gesture::Finished, pos);
1757   Wait(application, RENDER_FRAME_INTERVAL);
1758
1759   Actor stencil = field.GetChildAt( 1u );
1760   END_TEST;
1761 }
1762
1763 int utcDaliTextFieldEvent06(void)
1764 {
1765   ToolkitTestApplication application;
1766   tet_infoline(" utcDaliTextFieldEvent06");
1767
1768   // Checks Longpress when in edit mode
1769
1770   TextField field = TextField::New();
1771   DALI_TEST_CHECK( field );
1772   Stage::GetCurrent().Add( field );
1773   LoadMarkerImages(application, field);
1774   // Render and notify
1775   application.SendNotification();
1776   application.Render();
1777
1778   field.SetProperty( TextField::Property::TEXT, "Thisisalongtextforthesizeofthetextfield." );
1779   field.SetProperty( TextField::Property::POINT_SIZE, 10.f );
1780   field.SetSize( 300.f, 50.f );
1781   field.SetParentOrigin( ParentOrigin::TOP_LEFT );
1782   field.SetAnchorPoint( AnchorPoint::TOP_LEFT );
1783
1784   // Avoid a crash when core load gl resources.
1785   application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
1786   // Render and notify
1787   application.SendNotification();
1788   application.Render();
1789
1790   // Create a tap event to touch the text field.
1791   application.ProcessEvent( GenerateTap( Gesture::Possible, 1u, 1u, Vector2( 150.0f, 25.0f ) ) );
1792   application.ProcessEvent( GenerateTap( Gesture::Started, 1u, 1u, Vector2( 150.0f, 25.0f ) ) );
1793   // Render and notify
1794   application.SendNotification();
1795   application.Render();
1796
1797
1798   // Tap first to get the focus.
1799   application.ProcessEvent( GenerateTap( Gesture::Possible, 1u, 1u, Vector2( 1.f, 25.0f ) ) );
1800   application.ProcessEvent( GenerateTap( Gesture::Started, 1u, 1u, Vector2( 1.f, 25.0f ) ) );
1801
1802   // Render and notify
1803   application.SendNotification();
1804   application.Render();
1805
1806   // Long Press
1807   application.ProcessEvent( GenerateLongPress( Gesture::Possible, 1u, Vector2( 1.f, 25.0f ) ) );
1808   application.ProcessEvent( GenerateLongPress( Gesture::Started,  1u, Vector2( 1.f, 25.0f ) ) );
1809
1810   // Render and notify
1811   application.SendNotification();
1812   application.Render();
1813
1814   END_TEST;
1815 }
1816
1817 int utcDaliTextFieldEvent07(void)
1818 {
1819   ToolkitTestApplication application;
1820   tet_infoline(" utcDaliTextFieldEvent07");
1821
1822   // Checks Longpress to start edit mode
1823
1824   TextField field = TextField::New();
1825   DALI_TEST_CHECK( field );
1826   Stage::GetCurrent().Add( field );
1827   LoadMarkerImages(application, field);
1828   // Render and notify
1829   application.SendNotification();
1830   application.Render();
1831
1832   field.SetProperty( TextField::Property::TEXT, "Thisisalongtextforthesizeofthetextfield." );
1833   field.SetProperty( TextField::Property::POINT_SIZE, 10.f );
1834   field.SetSize( 300.f, 50.f );
1835   field.SetParentOrigin( ParentOrigin::TOP_LEFT );
1836   field.SetAnchorPoint( AnchorPoint::TOP_LEFT );
1837
1838   // Avoid a crash when core load gl resources.
1839   application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
1840   // Render and notify
1841   application.SendNotification();
1842   application.Render();
1843
1844   // Long Press
1845   application.ProcessEvent( GenerateLongPress( Gesture::Possible, 1u, Vector2( 1.f, 25.0f ) ) );
1846   application.ProcessEvent( GenerateLongPress( Gesture::Started,  1u, Vector2( 1.f, 25.0f ) ) );
1847
1848   // Render and notify
1849   application.SendNotification();
1850   application.Render();
1851
1852   END_TEST;
1853 }
1854
1855 int utcDaliTextFieldEvent08(void)
1856 {
1857   ToolkitTestApplication application;
1858   tet_infoline(" utcDaliTextFieldEvent08");
1859
1860   Dali::Clipboard clipboard = Clipboard::Get();
1861   clipboard.SetItem("testTextFieldEvent");
1862
1863   // Checks Longpress when only place holder text
1864
1865   TextField field = TextField::New();
1866   DALI_TEST_CHECK( field );
1867   Stage::GetCurrent().Add( field );
1868   LoadMarkerImages(application, field);
1869   // Render and notify
1870   application.SendNotification();
1871   application.Render();
1872
1873   field.SetProperty( TextField::Property::PLACEHOLDER_TEXT, "Setting Placeholder Text" );
1874   field.SetProperty( TextField::Property::POINT_SIZE, 10.f );
1875   field.SetSize( 300.f, 50.f );
1876   field.SetParentOrigin( ParentOrigin::TOP_LEFT );
1877   field.SetAnchorPoint( AnchorPoint::TOP_LEFT );
1878
1879   // Avoid a crash when core load gl resources.
1880   application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
1881   // Render and notify
1882   application.SendNotification();
1883   application.Render();
1884
1885   // Long Press
1886   application.ProcessEvent( GenerateLongPress( Gesture::Possible, 1u, Vector2( 1.f, 25.0f ) ) );
1887   application.ProcessEvent( GenerateLongPress( Gesture::Started,  1u, Vector2( 1.f, 25.0f ) ) );
1888
1889   // Render and notify
1890   application.SendNotification();
1891   application.Render();
1892
1893   Wait(application, 500);
1894
1895   Stage stage = Stage::GetCurrent();
1896   Layer layer = stage.GetRootLayer();
1897   Actor actor = layer.FindChildByName("optionPaste");
1898
1899   if (actor)
1900   {
1901     Vector3 worldPosition = actor.GetCurrentWorldPosition();
1902     Vector2 halfStageSize = stage.GetSize() / 2.0f;
1903     Vector2 position(worldPosition.x + halfStageSize.width, worldPosition.y + halfStageSize.height);
1904
1905     Dali::Integration::TouchEvent event;
1906     event = Dali::Integration::TouchEvent();
1907     event.AddPoint( GetPointDownInside( position ) );
1908     application.ProcessEvent( event );
1909
1910     event = Dali::Integration::TouchEvent();
1911     event.AddPoint( GetPointUpInside( position ) );
1912     application.ProcessEvent( event );
1913   }
1914   DALI_TEST_EQUALS( field.GetProperty<std::string>( TextEditor::Property::TEXT ), std::string("testTextFieldEvent"), TEST_LOCATION );
1915   END_TEST;
1916 }
1917
1918 int utcDaliTextFieldStyleWhilstSelected(void)
1919 {
1920   ToolkitTestApplication application;
1921   tet_infoline(" utcDaliTextFieldStyleWhilstSelected");
1922
1923   // Change font and styles whilst text is selected whilst word selected
1924
1925   TextField field = TextField::New();
1926   DALI_TEST_CHECK( field );
1927   Stage::GetCurrent().Add( field );
1928   LoadMarkerImages(application, field);
1929   // Render and notify
1930   application.SendNotification();
1931   application.Render();
1932
1933   field.SetProperty( TextField::Property::TEXT, "This is a long text for the size of the text-field." );
1934   field.SetProperty( TextField::Property::POINT_SIZE, 10.f );
1935   field.SetSize( 300.f, 50.f );
1936   field.SetParentOrigin( ParentOrigin::TOP_LEFT );
1937   field.SetAnchorPoint( AnchorPoint::TOP_LEFT );
1938
1939   // Avoid a crash when core load gl resources.
1940   application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
1941   // Render and notify
1942   application.SendNotification();
1943   application.Render();
1944
1945   // Create a tap event to touch the text field.
1946   application.ProcessEvent( GenerateTap( Gesture::Possible, 1u, 1u, Vector2( 150.0f, 25.0f ) ) );
1947   application.ProcessEvent( GenerateTap( Gesture::Started, 1u, 1u, Vector2( 150.0f, 25.0f ) ) );
1948   // Render and notify
1949   application.SendNotification();
1950   application.Render();
1951
1952
1953   // Tap first to get the focus.
1954   application.ProcessEvent( GenerateTap( Gesture::Possible, 1u, 1u, Vector2( 1.f, 25.0f ) ) );
1955   application.ProcessEvent( GenerateTap( Gesture::Started, 1u, 1u, Vector2( 1.f, 25.0f ) ) );
1956
1957   // Render and notify
1958   application.SendNotification();
1959   application.Render();
1960
1961   // Double tap to select a word.
1962   application.ProcessEvent( GenerateTap( Gesture::Possible, 2u, 1u, Vector2( 1.f, 25.0f ) ) );
1963   application.ProcessEvent( GenerateTap( Gesture::Started, 2u, 1u, Vector2( 1.f, 25.0f ) ) );
1964
1965   // Render and notify
1966   application.SendNotification();
1967   application.Render();
1968
1969   field.SetProperty( TextField::Property::INPUT_FONT_FAMILY, "Setting input font family" );
1970   DALI_TEST_EQUALS( field.GetProperty<std::string>( TextField::Property::INPUT_FONT_FAMILY ), "Setting input font family", TEST_LOCATION );
1971
1972   Property::Map fontStyleMapSet;
1973   Property::Map fontStyleMapGet;
1974
1975   fontStyleMapSet.Insert( "weight", "bold" );
1976   fontStyleMapSet.Insert( "slant", "italic" );
1977   field.SetProperty( TextField::Property::INPUT_FONT_STYLE, fontStyleMapSet );
1978
1979   fontStyleMapGet = field.GetProperty<Property::Map>( TextField::Property::INPUT_FONT_STYLE );
1980   DALI_TEST_EQUALS( fontStyleMapGet.Count(), fontStyleMapSet.Count(), TEST_LOCATION );
1981   DALI_TEST_EQUALS( DaliTestCheckMaps( fontStyleMapGet, fontStyleMapSet ), true, TEST_LOCATION );
1982
1983   fontStyleMapSet.Clear();
1984   fontStyleMapSet.Insert( "width", "expanded" );
1985   fontStyleMapSet.Insert( "slant", "italic" );
1986   field.SetProperty( TextField::Property::INPUT_FONT_STYLE, fontStyleMapSet );
1987
1988   fontStyleMapGet = field.GetProperty<Property::Map>( TextField::Property::INPUT_FONT_STYLE );
1989   DALI_TEST_EQUALS( fontStyleMapGet.Count(), fontStyleMapSet.Count(), TEST_LOCATION );
1990   DALI_TEST_EQUALS( DaliTestCheckMaps( fontStyleMapGet, fontStyleMapSet ), true, TEST_LOCATION );
1991
1992   field.SetProperty( TextField::Property::INPUT_POINT_SIZE, 12.f );
1993   DALI_TEST_EQUALS( field.GetProperty<float>( TextField::Property::INPUT_POINT_SIZE ), 12.f, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
1994
1995   field.SetProperty( TextField::Property::TEXT_COLOR, Color::RED );
1996   DALI_TEST_EQUALS( field.GetProperty<Vector4>( TextField::Property::TEXT_COLOR ), Color::RED, TEST_LOCATION );
1997
1998   fontStyleMapSet.Clear();
1999   fontStyleMapSet.Insert( "weight", "bold" );
2000   fontStyleMapSet.Insert( "slant", "italic" );
2001
2002   field.SetProperty( TextField::Property::FONT_STYLE, fontStyleMapSet );
2003
2004   fontStyleMapGet = field.GetProperty<Property::Map>( TextField::Property::FONT_STYLE );
2005   DALI_TEST_EQUALS( fontStyleMapGet.Count(), fontStyleMapSet.Count(), TEST_LOCATION );
2006   DALI_TEST_EQUALS( DaliTestCheckMaps( fontStyleMapGet, fontStyleMapSet ), true, TEST_LOCATION );
2007
2008   fontStyleMapSet.Clear();
2009   fontStyleMapSet.Insert( "width", "expanded" );
2010
2011   field.SetProperty( TextField::Property::FONT_STYLE, fontStyleMapSet );
2012
2013   fontStyleMapGet = field.GetProperty<Property::Map>( TextField::Property::FONT_STYLE );
2014   DALI_TEST_EQUALS( fontStyleMapGet.Count(), fontStyleMapSet.Count(), TEST_LOCATION );
2015   DALI_TEST_EQUALS( DaliTestCheckMaps( fontStyleMapGet, fontStyleMapSet ), true, TEST_LOCATION );
2016
2017   // Press Escape to increase coverage
2018   application.ProcessEvent( GenerateKey( "", "", DALI_KEY_ESCAPE, 0, 0, Integration::KeyEvent::Up ) );
2019   application.SendNotification();
2020   application.Render();
2021
2022   DALI_TEST_CHECK( !field.HasKeyInputFocus() );
2023
2024   END_TEST;
2025 }