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