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