Merge "Fix SVACE issue" into devel/master
[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 <dali-toolkit/devel-api/controls/text-controls/hidden-input-properties.h>
31 #include <dali-toolkit/devel-api/controls/text-controls/text-field-devel.h>
32 #include "toolkit-clipboard.h"
33
34 using namespace Dali;
35 using namespace Toolkit;
36
37 void dali_textfield_startup(void)
38 {
39   test_return_value = TET_UNDEF;
40 }
41
42 void dali_textfield_cleanup(void)
43 {
44   test_return_value = TET_PASS;
45 }
46
47 namespace
48 {
49
50 const char* const PROPERTY_NAME_RENDERING_BACKEND                    = "renderingBackend";
51 const char* const PROPERTY_NAME_TEXT                                 = "text";
52 const char* const PROPERTY_NAME_PLACEHOLDER_TEXT                     = "placeholderText";
53 const char* const PROPERTY_NAME_PLACEHOLDER_TEXT_FOCUSED             = "placeholderTextFocused";
54 const char* const PROPERTY_NAME_FONT_FAMILY                          = "fontFamily";
55 const char* const PROPERTY_NAME_FONT_STYLE                           = "fontStyle";
56 const char* const PROPERTY_NAME_POINT_SIZE                           = "pointSize";
57 const char* const PROPERTY_NAME_MAX_LENGTH                           = "maxLength";
58 const char* const PROPERTY_NAME_EXCEED_POLICY                        = "exceedPolicy";
59 const char* const PROPERTY_NAME_HORIZONTAL_ALIGNMENT                 = "horizontalAlignment";
60 const char* const PROPERTY_NAME_VERTICAL_ALIGNMENT                   = "verticalAlignment";
61 const char* const PROPERTY_NAME_TEXT_COLOR                           = "textColor";
62 const char* const PROPERTY_NAME_PLACEHOLDER_TEXT_COLOR               = "placeholderTextColor";
63 const char* const PROPERTY_NAME_SHADOW_OFFSET                        = "shadowOffset";
64 const char* const PROPERTY_NAME_SHADOW_COLOR                         = "shadowColor";
65 const char* const PROPERTY_NAME_PRIMARY_CURSOR_COLOR                 = "primaryCursorColor";
66 const char* const PROPERTY_NAME_SECONDARY_CURSOR_COLOR               = "secondaryCursorColor";
67 const char* const PROPERTY_NAME_ENABLE_CURSOR_BLINK                  = "enableCursorBlink";
68 const char* const PROPERTY_NAME_CURSOR_BLINK_INTERVAL                = "cursorBlinkInterval";
69 const char* const PROPERTY_NAME_CURSOR_BLINK_DURATION                = "cursorBlinkDuration";
70 const char* const PROPERTY_NAME_CURSOR_WIDTH                         = "cursorWidth";
71 const char* const PROPERTY_NAME_GRAB_HANDLE_IMAGE                    = "grabHandleImage";
72 const char* const PROPERTY_NAME_GRAB_HANDLE_PRESSED_IMAGE            = "grabHandlePressedImage";
73 const char* const PROPERTY_NAME_SCROLL_THRESHOLD                     = "scrollThreshold";
74 const char* const PROPERTY_NAME_SCROLL_SPEED                         = "scrollSpeed";
75 const char* const PROPERTY_NAME_SELECTION_HANDLE_IMAGE_LEFT          = "selectionHandleImageLeft";
76 const char* const PROPERTY_NAME_SELECTION_HANDLE_IMAGE_RIGHT         = "selectionHandleImageRight";
77 const char* const PROPERTY_NAME_SELECTION_HANDLE_PRESSED_IMAGE_LEFT  = "selectionHandlePressedImageLeft";
78 const char* const PROPERTY_NAME_SELECTION_HANDLE_PRESSED_IMAGE_RIGHT = "selectionHandlePressedImageRight";
79 const char* const PROPERTY_NAME_SELECTION_HANDLE_MARKER_IMAGE_LEFT   = "selectionHandleMarkerImageLeft";
80 const char* const PROPERTY_NAME_SELECTION_HANDLE_MARKER_IMAGE_RIGHT  = "selectionHandleMarkerImageRight";
81 const char* const PROPERTY_NAME_SELECTION_HIGHLIGHT_COLOR            = "selectionHighlightColor";
82 const char* const PROPERTY_NAME_DECORATION_BOUNDING_BOX              = "decorationBoundingBox";
83 const char* const PROPERTY_NAME_INPUT_METHOD_SETTINGS                = "inputMethodSettings";
84 const char* const PROPERTY_NAME_INPUT_COLOR                          = "inputColor";
85 const char* const PROPERTY_NAME_ENABLE_MARKUP                        = "enableMarkup";
86 const char* const PROPERTY_NAME_INPUT_FONT_FAMILY                    = "inputFontFamily";
87 const char* const PROPERTY_NAME_INPUT_FONT_STYLE                     = "inputFontStyle";
88 const char* const PROPERTY_NAME_INPUT_POINT_SIZE                     = "inputPointSize";
89
90 const char* const PROPERTY_NAME_UNDERLINE                            = "underline";
91 const char* const PROPERTY_NAME_INPUT_UNDERLINE                      = "inputUnderline";
92 const char* const PROPERTY_NAME_SHADOW                               = "shadow";
93 const char* const PROPERTY_NAME_INPUT_SHADOW                         = "inputShadow";
94 const char* const PROPERTY_NAME_EMBOSS                               = "emboss";
95 const char* const PROPERTY_NAME_INPUT_EMBOSS                         = "inputEmboss";
96 const char* const PROPERTY_NAME_OUTLINE                              = "outline";
97 const char* const PROPERTY_NAME_INPUT_OUTLINE                        = "inputOutline";
98
99 const char* const PROPERTY_NAME_HIDDEN_INPUT_SETTINGS                = "hiddenInputSettings";
100 const char* const PROPERTY_NAME_PIXEL_SIZE                           = "pixelSize";
101 const char* const PROPERTY_NAME_ENABLE_SELECTION                     = "enableSelection";
102 const char* const PROPERTY_NAME_PLACEHOLDER                          = "placeholder";
103 const char* const PROPERTY_NAME_ELLIPSIS                             = "ellipsis";
104
105 const int DEFAULT_RENDERING_BACKEND = Dali::Toolkit::Text::DEFAULT_RENDERING_BACKEND;
106
107 const Vector4 PLACEHOLDER_TEXT_COLOR( 0.8f, 0.8f, 0.8f, 0.8f );
108 const Dali::Vector4 LIGHT_BLUE( 0.75f, 0.96f, 1.f, 1.f ); // The text highlight color.
109
110 const unsigned int CURSOR_BLINK_INTERVAL = 500u; // Cursor blink interval
111 const float RENDER_FRAME_INTERVAL = 16.66f;
112
113 const float TO_MILLISECONDS = 1000.f;
114 const float TO_SECONDS = 1.f / TO_MILLISECONDS;
115
116 const float SCROLL_THRESHOLD = 10.f;
117 const float SCROLL_SPEED = 300.f;
118
119 const unsigned int DEFAULT_FONT_SIZE = 1152u;
120 const std::string DEFAULT_FONT_DIR( "/resources/fonts" );
121
122 const int KEY_A_CODE = 38;
123 const int KEY_D_CODE = 40;
124
125 const std::string DEFAULT_DEVICE_NAME("hwKeyboard");
126
127 static bool gTextChangedCallBackCalled;
128 static bool gMaxCharactersCallBackCalled;
129 static bool gInputStyleChangedCallbackCalled;
130 static Dali::Toolkit::TextField::InputStyle::Mask gInputStyleMask;
131
132 static void LoadBitmapResource(TestPlatformAbstraction& platform, int width, int height)
133 {
134   Integration::Bitmap* bitmap = Integration::Bitmap::New( Integration::Bitmap::BITMAP_2D_PACKED_PIXELS, ResourcePolicy::OWNED_DISCARD );
135   Integration::ResourcePointer resource(bitmap);
136   bitmap->GetPackedPixelsProfile()->ReserveBuffer(Pixel::RGBA8888, width, height, width, height);
137 }
138
139 static void LoadMarkerImages(ToolkitTestApplication& app, TextField textField)
140 {
141   int width(40);
142   int height(40);
143   LoadBitmapResource( app.GetPlatform(), width, height );
144
145   Property::Map propertyMap;
146   propertyMap["filename"] = "image.png";
147   propertyMap["width"] = width;
148   propertyMap["height"] = height;
149   textField.SetProperty( Toolkit::TextField::Property::SELECTION_HANDLE_IMAGE_LEFT, propertyMap );
150   textField.SetProperty( Toolkit::TextField::Property::SELECTION_HANDLE_IMAGE_RIGHT, propertyMap );
151   textField.SetProperty( Toolkit::TextField::Property::SELECTION_HANDLE_PRESSED_IMAGE_LEFT, propertyMap );
152   textField.SetProperty( Toolkit::TextField::Property::SELECTION_HANDLE_PRESSED_IMAGE_RIGHT, propertyMap );
153   textField.SetProperty( Toolkit::TextField::Property::SELECTION_HANDLE_MARKER_IMAGE_LEFT, propertyMap );
154   textField.SetProperty( Toolkit::TextField::Property::SELECTION_HANDLE_MARKER_IMAGE_RIGHT, propertyMap );
155   textField.SetProperty( Toolkit::TextField::Property::GRAB_HANDLE_IMAGE, propertyMap );
156   textField.SetProperty( Toolkit::TextField::Property::GRAB_HANDLE_PRESSED_IMAGE, propertyMap );
157 }
158
159 // Generate a PanGestureEvent to send to Core
160 static Integration::PanGestureEvent GeneratePan(
161     Gesture::State state,
162     const Vector2& previousPosition,
163     const Vector2& currentPosition,
164     unsigned long timeDelta,
165     unsigned int numberOfTouches = 1)
166 {
167   Integration::PanGestureEvent pan(state);
168
169   pan.previousPosition = previousPosition;
170   pan.currentPosition = currentPosition;
171   pan.timeDelta = timeDelta;
172   pan.numberOfTouches = numberOfTouches;
173
174   return pan;
175 }
176
177 /**
178  * Helper to generate PanGestureEvent
179  *
180  * @param[in] application Application instance
181  * @param[in] state The Gesture State
182  * @param[in] pos The current position of touch.
183  */
184 static void SendPan(ToolkitTestApplication& application, Gesture::State state, const Vector2& pos)
185 {
186   static Vector2 last;
187
188   if( (state == Gesture::Started) ||
189       (state == Gesture::Possible) )
190   {
191     last.x = pos.x;
192     last.y = pos.y;
193   }
194
195   application.ProcessEvent(GeneratePan(state, last, pos, 16));
196
197   last.x = pos.x;
198   last.y = pos.y;
199 }
200
201 /*
202  * Simulate time passed by.
203  *
204  * @note this will always process at least 1 frame (1/60 sec)
205  *
206  * @param application Test application instance
207  * @param duration Time to pass in milliseconds.
208  * @return The actual time passed in milliseconds
209  */
210 static int Wait(ToolkitTestApplication& application, int duration = 0)
211 {
212   int time = 0;
213
214   for(int i = 0; i <= ( duration / RENDER_FRAME_INTERVAL); i++)
215   {
216     application.SendNotification();
217     application.Render(RENDER_FRAME_INTERVAL);
218     time += RENDER_FRAME_INTERVAL;
219   }
220
221   return time;
222 }
223
224 Dali::Integration::Point GetPointDownInside( Vector2& pos )
225 {
226   Dali::Integration::Point point;
227   point.SetState( PointState::DOWN );
228   point.SetScreenPosition( pos );
229   return point;
230 }
231
232 Dali::Integration::Point GetPointUpInside( Vector2& pos )
233 {
234   Dali::Integration::Point point;
235   point.SetState( PointState::UP );
236   point.SetScreenPosition( pos );
237   return point;
238 }
239
240 struct CallbackFunctor
241 {
242   CallbackFunctor(bool* callbackFlag)
243   : mCallbackFlag( callbackFlag )
244   {
245   }
246
247   void operator()()
248   {
249     *mCallbackFlag = true;
250   }
251   bool* mCallbackFlag;
252 };
253
254 static void TestTextChangedCallback( TextField control )
255 {
256   tet_infoline(" TestTextChangedCallback");
257
258   gTextChangedCallBackCalled = true;
259 }
260
261 static void TestMaxLengthReachedCallback( TextField control )
262 {
263   tet_infoline(" TestMaxLengthReachedCallback");
264
265   gMaxCharactersCallBackCalled = true;
266 }
267
268 static void TestInputStyleChangedCallback( TextField control, TextField::InputStyle::Mask mask )
269 {
270   tet_infoline(" TestInputStyleChangedCallback");
271
272   gInputStyleChangedCallbackCalled = true;
273   gInputStyleMask = mask;
274 }
275
276 // Generate a TapGestureEvent to send to Core.
277 Integration::TapGestureEvent GenerateTap(
278     Gesture::State state,
279     unsigned int numberOfTaps,
280     unsigned int numberOfTouches,
281     Vector2 point)
282 {
283   Integration::TapGestureEvent tap( state );
284
285   tap.numberOfTaps = numberOfTaps;
286   tap.numberOfTouches = numberOfTouches;
287   tap.point = point;
288
289   return tap;
290 }
291
292 Integration::LongPressGestureEvent GenerateLongPress(
293     Gesture::State state,
294     unsigned int numberOfTouches,
295     Vector2 point)
296 {
297   Integration::LongPressGestureEvent longPress( state );
298
299   longPress.numberOfTouches = numberOfTouches;
300   longPress.point = point;
301   return longPress;
302 }
303
304 // Generate a KeyEvent to send to Core.
305 Integration::KeyEvent GenerateKey( const std::string& keyName,
306                                    const std::string& keyString,
307                                    int keyCode,
308                                    int keyModifier,
309                                    unsigned long timeStamp,
310                                    const Integration::KeyEvent::State& keyState,
311                                    const std::string& deviceName = DEFAULT_DEVICE_NAME,
312                                    const DevelDevice::Class::Type& deviceClass = DevelDevice::Class::NONE,
313                                    const DevelDevice::Subclass::Type& deviceSubclass = DevelDevice::Subclass::NONE )
314 {
315   return Integration::KeyEvent( keyName,
316                                 keyString,
317                                 keyCode,
318                                 keyModifier,
319                                 timeStamp,
320                                 keyState,
321                                 deviceName,
322                                 deviceClass,
323                                 deviceSubclass );
324 }
325
326 bool DaliTestCheckMaps( const Property::Map& fontStyleMapGet, const Property::Map& fontStyleMapSet )
327 {
328   if( fontStyleMapGet.Count() == fontStyleMapSet.Count() )
329   {
330     for( unsigned int index = 0u; index < fontStyleMapGet.Count(); ++index )
331     {
332       const KeyValuePair& valueGet = fontStyleMapGet.GetKeyValue( index );
333
334       if( valueGet.first.type == Property::Key::STRING )
335       {
336         Property::Value* valueSet = fontStyleMapSet.Find( valueGet.first.stringKey );
337         if( NULL != valueSet )
338         {
339           if( valueGet.second.Get<std::string>() != valueSet->Get<std::string>() )
340           {
341             tet_printf( "  Value got : [%s], expected : [%s]", valueGet.second.Get<std::string>().c_str(), valueSet->Get<std::string>().c_str() );
342             return false;
343           }
344         }
345         else
346         {
347           tet_printf( "  The key %s doesn't exist.", valueGet.first.stringKey.c_str() );
348           return false;
349         }
350       }
351       else
352       {
353         Property::Value* valueSet = fontStyleMapSet.Find( valueGet.first.indexKey );
354         if( NULL != valueSet )
355         {
356           if( valueGet.second.Get<int>() != valueSet->Get<int>() )
357           {
358             tet_printf( "  Integer Value got : [%d], expected : [%d]", valueGet.second.Get<int>(), valueSet->Get<int>() );
359             return false;
360           }
361         }
362         else
363         {
364           tet_printf( "  The Int key %d doesn't exist.", valueGet.first.indexKey );
365           return false;
366         }
367       }
368     }
369   }
370
371   return true;
372 }
373
374 } // namespace
375
376 int UtcDaliToolkitTextFieldConstructorP(void)
377 {
378   ToolkitTestApplication application;
379   tet_infoline(" UtcDaliToolkitTextFieldConstructorP");
380   TextField textField;
381   DALI_TEST_CHECK( !textField );
382   END_TEST;
383 }
384
385 int UtcDaliToolkitTextFieldNewP(void)
386 {
387   ToolkitTestApplication application;
388   tet_infoline(" UtcDaliToolkitTextFieldNewP");
389   TextField textField = TextField::New();
390   DALI_TEST_CHECK( textField );
391   END_TEST;
392 }
393
394 int UtcDaliToolkitTextFieldDownCastP(void)
395 {
396   ToolkitTestApplication application;
397   tet_infoline(" UtcDaliToolkitTextFieldDownCastP");
398   TextField textField1 = TextField::New();
399   BaseHandle object( textField1 );
400
401   TextField textField2 = TextField::DownCast( object );
402   DALI_TEST_CHECK( textField2 );
403
404   TextField textField3 = DownCast< TextField >( object );
405   DALI_TEST_CHECK( textField3 );
406   END_TEST;
407 }
408
409 int UtcDaliToolkitTextFieldDownCastN(void)
410 {
411   ToolkitTestApplication application;
412   tet_infoline(" UtcDaliToolkitTextFieldDownCastN");
413   BaseHandle uninitializedObject;
414   TextField textField1 = TextField::DownCast( uninitializedObject );
415   DALI_TEST_CHECK( !textField1 );
416
417   TextField textField2 = DownCast< TextField >( uninitializedObject );
418   DALI_TEST_CHECK( !textField2 );
419   END_TEST;
420 }
421
422 int UtcDaliToolkitTextFieldCopyConstructorP(void)
423 {
424   ToolkitTestApplication application;
425   tet_infoline(" UtcDaliToolkitTextFieldCopyConstructorP");
426   TextField textField = TextField::New();
427   textField.SetProperty( TextField::Property::TEXT, "Test" );
428
429   TextField copy( textField );
430   DALI_TEST_CHECK( copy );
431   DALI_TEST_CHECK( copy.GetProperty<std::string>( TextLabel::Property::TEXT ) == textField.GetProperty<std::string>( TextLabel::Property::TEXT ) );
432   END_TEST;
433 }
434
435 int UtcDaliToolkitTextFieldAssignmentOperatorP(void)
436 {
437   ToolkitTestApplication application;
438   tet_infoline(" UtcDaliToolkitTextFieldAssignmentOperatorP");
439   TextField textField = TextField::New();
440   textField.SetProperty( TextField::Property::TEXT, "Test" );
441
442   TextField copy = textField;
443   DALI_TEST_CHECK( copy );
444   DALI_TEST_CHECK( copy.GetProperty<std::string>( TextField::Property::TEXT ) == textField.GetProperty<std::string>( TextField::Property::TEXT ) );
445   END_TEST;
446 }
447
448 int UtcDaliTextFieldNewP(void)
449 {
450   ToolkitTestApplication application;
451   tet_infoline(" UtcDaliToolkitTextFieldNewP");
452   TextField textField = TextField::New();
453   DALI_TEST_CHECK( textField );
454   END_TEST;
455 }
456
457 // Positive test case for a method
458 int UtcDaliTextFieldGetPropertyP(void)
459 {
460   ToolkitTestApplication application;
461   tet_infoline(" UtcDaliToolkitTextFieldGetPropertyP");
462   TextField field = TextField::New();
463   DALI_TEST_CHECK( field );
464
465   // Check Property Indices are correct
466   DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_RENDERING_BACKEND ) == TextField::Property::RENDERING_BACKEND );
467   DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_TEXT ) == TextField::Property::TEXT );
468   DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_PLACEHOLDER_TEXT ) == TextField::Property::PLACEHOLDER_TEXT );
469   DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_PLACEHOLDER_TEXT_FOCUSED ) == TextField::Property::PLACEHOLDER_TEXT_FOCUSED );
470   DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_FONT_FAMILY ) == TextField::Property::FONT_FAMILY );
471   DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_FONT_STYLE ) == TextField::Property::FONT_STYLE );
472   DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_POINT_SIZE ) == TextField::Property::POINT_SIZE );
473   DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_MAX_LENGTH ) == TextField::Property::MAX_LENGTH );
474   DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_EXCEED_POLICY ) == TextField::Property::EXCEED_POLICY );
475   DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_HORIZONTAL_ALIGNMENT ) == TextField::Property::HORIZONTAL_ALIGNMENT );
476   DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_VERTICAL_ALIGNMENT ) == TextField::Property::VERTICAL_ALIGNMENT );
477   DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_TEXT_COLOR ) == TextField::Property::TEXT_COLOR );
478   DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_PLACEHOLDER_TEXT_COLOR ) == TextField::Property::PLACEHOLDER_TEXT_COLOR );
479   DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_SHADOW_OFFSET ) == TextField::Property::SHADOW_OFFSET );
480   DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_SHADOW_COLOR ) == TextField::Property::SHADOW_COLOR );
481   DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_PRIMARY_CURSOR_COLOR ) == TextField::Property::PRIMARY_CURSOR_COLOR );
482   DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_SECONDARY_CURSOR_COLOR ) == TextField::Property::SECONDARY_CURSOR_COLOR );
483   DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_ENABLE_CURSOR_BLINK ) == TextField::Property::ENABLE_CURSOR_BLINK );
484   DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_CURSOR_BLINK_INTERVAL ) == TextField::Property::CURSOR_BLINK_INTERVAL );
485   DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_CURSOR_BLINK_DURATION ) == TextField::Property::CURSOR_BLINK_DURATION );
486   DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_CURSOR_WIDTH ) == TextField::Property::CURSOR_WIDTH );
487   DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_GRAB_HANDLE_IMAGE ) == TextField::Property::GRAB_HANDLE_IMAGE );
488   DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_GRAB_HANDLE_PRESSED_IMAGE ) == TextField::Property::GRAB_HANDLE_PRESSED_IMAGE );
489   DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_SCROLL_THRESHOLD ) == TextField::Property::SCROLL_THRESHOLD );
490   DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_SCROLL_SPEED ) == TextField::Property::SCROLL_SPEED );
491   DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_SELECTION_HANDLE_IMAGE_LEFT ) == TextField::Property::SELECTION_HANDLE_IMAGE_LEFT );
492   DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_SELECTION_HANDLE_IMAGE_RIGHT ) == TextField::Property::SELECTION_HANDLE_IMAGE_RIGHT );
493   DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_SELECTION_HANDLE_PRESSED_IMAGE_LEFT ) == TextField::Property::SELECTION_HANDLE_PRESSED_IMAGE_LEFT );
494   DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_SELECTION_HANDLE_PRESSED_IMAGE_RIGHT ) == TextField::Property::SELECTION_HANDLE_PRESSED_IMAGE_RIGHT );
495   DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_SELECTION_HANDLE_MARKER_IMAGE_LEFT ) == TextField::Property::SELECTION_HANDLE_MARKER_IMAGE_LEFT );
496   DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_SELECTION_HANDLE_MARKER_IMAGE_RIGHT ) == TextField::Property::SELECTION_HANDLE_MARKER_IMAGE_RIGHT );
497   DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_SELECTION_HIGHLIGHT_COLOR ) == TextField::Property::SELECTION_HIGHLIGHT_COLOR );
498   DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_DECORATION_BOUNDING_BOX ) == TextField::Property::DECORATION_BOUNDING_BOX );
499   DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_INPUT_METHOD_SETTINGS ) == TextField::Property::INPUT_METHOD_SETTINGS );
500   DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_INPUT_COLOR ) == TextField::Property::INPUT_COLOR );
501   DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_ENABLE_MARKUP ) == TextField::Property::ENABLE_MARKUP );
502   DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_INPUT_FONT_FAMILY ) == TextField::Property::INPUT_FONT_FAMILY );
503   DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_INPUT_FONT_STYLE ) == TextField::Property::INPUT_FONT_STYLE );
504   DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_INPUT_POINT_SIZE ) == TextField::Property::INPUT_POINT_SIZE );
505   DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_UNDERLINE ) == TextField::Property::UNDERLINE );
506   DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_INPUT_UNDERLINE ) == TextField::Property::INPUT_UNDERLINE );
507   DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_SHADOW ) == TextField::Property::SHADOW );
508   DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_INPUT_SHADOW ) == TextField::Property::INPUT_SHADOW );
509   DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_EMBOSS ) == TextField::Property::EMBOSS );
510   DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_INPUT_EMBOSS ) == TextField::Property::INPUT_EMBOSS );
511   DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_OUTLINE ) == TextField::Property::OUTLINE );
512   DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_INPUT_OUTLINE ) == TextField::Property::INPUT_OUTLINE );
513   DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_HIDDEN_INPUT_SETTINGS ) == DevelTextField::Property::HIDDEN_INPUT_SETTINGS );
514   DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_PIXEL_SIZE ) == DevelTextField::Property::PIXEL_SIZE );
515   DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_ENABLE_SELECTION ) == DevelTextField::Property::ENABLE_SELECTION );
516   DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_PLACEHOLDER ) == DevelTextField::Property::PLACEHOLDER );
517   DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_ELLIPSIS ) == DevelTextField::Property::ELLIPSIS );
518
519   END_TEST;
520 }
521
522 bool SetPropertyMapRetrieved( TextField& field, const Property::Index property, const std::string mapKey, const std::string mapValue )
523 {
524   bool result = false;
525   Property::Map imageMap;
526   imageMap[mapKey] =mapValue;
527
528   field.SetProperty( property , imageMap );
529   Property::Value propValue = field.GetProperty( property );
530   Property::Map* resultMap = propValue.GetMap();
531
532   if ( resultMap->Find( mapKey )->Get< std::string>() == mapValue )
533   {
534     result = true;
535   }
536
537   return result;
538 }
539
540 // Positive test case for a method
541 int UtcDaliTextFieldSetPropertyP(void)
542 {
543   ToolkitTestApplication application;
544   tet_infoline(" UtcDaliToolkitTextFieldSetPropertyP");
545   TextField field = TextField::New();
546   DALI_TEST_CHECK( field );
547   Stage::GetCurrent().Add( field );
548
549   // Note - we can't check the defaults since the stylesheets are platform-specific
550
551   // Check the render backend property.
552   field.SetProperty( TextField::Property::RENDERING_BACKEND, Text::RENDERING_SHARED_ATLAS );
553   DALI_TEST_EQUALS( (Text::RenderingType)field.GetProperty<int>( TextField::Property::RENDERING_BACKEND ), Text::RENDERING_SHARED_ATLAS, TEST_LOCATION );
554
555   // Check text property.
556   field.SetProperty( TextField::Property::TEXT, "Setting Text" );
557   DALI_TEST_EQUALS( field.GetProperty<std::string>( TextField::Property::TEXT ), std::string("Setting Text"), TEST_LOCATION );
558
559   // Check placeholder text properties.
560   field.SetProperty( TextField::Property::PLACEHOLDER_TEXT, "Setting Placeholder Text" );
561   DALI_TEST_EQUALS( field.GetProperty<std::string>( TextField::Property::PLACEHOLDER_TEXT ), std::string("Setting Placeholder Text"), TEST_LOCATION );
562
563   field.SetProperty( TextField::Property::PLACEHOLDER_TEXT_FOCUSED, "Setting Placeholder Text Focused" );
564   DALI_TEST_EQUALS( field.GetProperty<std::string>( TextField::Property::PLACEHOLDER_TEXT_FOCUSED ), std::string("Setting Placeholder Text Focused"), TEST_LOCATION );
565
566   // Check font properties.
567   field.SetProperty( TextField::Property::FONT_FAMILY, "Setting font family" );
568   DALI_TEST_EQUALS( field.GetProperty<std::string>( TextField::Property::FONT_FAMILY ), std::string("Setting font family"), TEST_LOCATION );
569
570   Property::Map fontStyleMapSet;
571   Property::Map fontStyleMapGet;
572   Property::Value* slantValue = NULL;
573
574   fontStyleMapSet.Insert( "weight", "bold" );
575   fontStyleMapSet.Insert( "width", "condensed" );
576   fontStyleMapSet.Insert( "slant", "italic" );
577   field.SetProperty( TextField::Property::FONT_STYLE, fontStyleMapSet );
578
579   fontStyleMapGet = field.GetProperty<Property::Map>( TextField::Property::FONT_STYLE );
580   DALI_TEST_EQUALS( fontStyleMapGet.Count(), fontStyleMapSet.Count(), TEST_LOCATION );
581   DALI_TEST_EQUALS( DaliTestCheckMaps( fontStyleMapGet, fontStyleMapSet ), true, TEST_LOCATION );
582
583   field.SetProperty( TextField::Property::POINT_SIZE, 10.f );
584   DALI_TEST_EQUALS( field.GetProperty<float>( TextField::Property::POINT_SIZE ), 10.f, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
585
586   // Reset font style.
587   fontStyleMapSet.Clear();
588   fontStyleMapSet.Insert( "weight", "normal" );
589   fontStyleMapSet.Insert( "slant", "oblique" );
590   field.SetProperty( TextField::Property::FONT_STYLE, fontStyleMapSet );
591
592   fontStyleMapGet = field.GetProperty<Property::Map>( TextField::Property::FONT_STYLE );
593   DALI_TEST_EQUALS( fontStyleMapGet.Count(), fontStyleMapSet.Count(), TEST_LOCATION );
594   DALI_TEST_EQUALS( DaliTestCheckMaps( fontStyleMapGet, fontStyleMapSet ), true, TEST_LOCATION );
595
596   fontStyleMapSet.Clear();
597   fontStyleMapSet.Insert( "slant", "roman" );
598   field.SetProperty( TextField::Property::FONT_STYLE, fontStyleMapSet );
599   fontStyleMapGet = field.GetProperty<Property::Map>( TextField::Property::FONT_STYLE );
600
601   // Replace 'roman' for 'normal'.
602   slantValue = fontStyleMapGet.Find( "slant" );
603   if( NULL != slantValue )
604   {
605     if( "normal" == slantValue->Get<std::string>() )
606     {
607       fontStyleMapGet["slant"] = "roman";
608     }
609   }
610   DALI_TEST_EQUALS( fontStyleMapGet.Count(), fontStyleMapSet.Count(), TEST_LOCATION );
611   DALI_TEST_EQUALS( DaliTestCheckMaps( fontStyleMapGet, fontStyleMapSet ), true, TEST_LOCATION );
612
613   fontStyleMapSet.Clear();
614
615   field.SetProperty( TextField::Property::FONT_STYLE, fontStyleMapSet );
616   fontStyleMapGet = field.GetProperty<Property::Map>( TextField::Property::FONT_STYLE );
617   DALI_TEST_EQUALS( fontStyleMapGet.Count(), fontStyleMapSet.Count(), TEST_LOCATION );
618   DALI_TEST_EQUALS( DaliTestCheckMaps( fontStyleMapGet, fontStyleMapSet ), true, TEST_LOCATION );
619
620   // Check that the MAX_LENGTH property can be correctly set
621   const int maxNumberOfCharacters = 20;
622   field.SetProperty( TextField::Property::MAX_LENGTH, maxNumberOfCharacters );
623   DALI_TEST_EQUALS( field.GetProperty<int>( TextField::Property::MAX_LENGTH ), maxNumberOfCharacters, TEST_LOCATION );
624
625   // Check exceed policy
626   field.SetProperty( TextField::Property::EXCEED_POLICY, Dali::Toolkit::TextField::EXCEED_POLICY_CLIP );
627   DALI_TEST_EQUALS( field.GetProperty<int>( TextField::Property::EXCEED_POLICY ), static_cast<int>( Dali::Toolkit::TextField::EXCEED_POLICY_CLIP ), TEST_LOCATION );
628   field.SetProperty( TextField::Property::EXCEED_POLICY, Dali::Toolkit::TextField::EXCEED_POLICY_ORIGINAL );
629   DALI_TEST_EQUALS( field.GetProperty<int>( TextField::Property::EXCEED_POLICY ), static_cast<int>( Dali::Toolkit::TextField::EXCEED_POLICY_ORIGINAL ), TEST_LOCATION );
630
631   // Check that the Alignment properties can be correctly set
632   field.SetProperty( TextField::Property::HORIZONTAL_ALIGNMENT, "END" );
633   DALI_TEST_EQUALS( field.GetProperty<std::string>( TextField::Property::HORIZONTAL_ALIGNMENT ), "END", TEST_LOCATION );
634   field.SetProperty( TextField::Property::VERTICAL_ALIGNMENT, "CENTER" );
635   DALI_TEST_EQUALS( field.GetProperty<std::string>( TextField::Property::VERTICAL_ALIGNMENT ), "CENTER", TEST_LOCATION );
636
637   // Check text's color property
638   field.SetProperty( TextField::Property::TEXT_COLOR, Color::WHITE );
639   DALI_TEST_EQUALS( field.GetProperty<Vector4>( TextField::Property::TEXT_COLOR ), Color::WHITE, TEST_LOCATION );
640
641   // Check placeholder text's color property.
642   field.SetProperty( TextField::Property::PLACEHOLDER_TEXT_COLOR, Color::RED );
643   DALI_TEST_EQUALS( field.GetProperty<Vector4>( TextField::Property::PLACEHOLDER_TEXT_COLOR ), Color::RED, TEST_LOCATION );
644
645   // Check shadow properties.
646   field.SetProperty( TextField::Property::SHADOW_OFFSET, Vector2( 1.f, 1.f ) );
647   DALI_TEST_EQUALS( field.GetProperty<Vector2>( TextField::Property::SHADOW_OFFSET ), Vector2( 1.f, 1.f ), TEST_LOCATION );
648   field.SetProperty( TextField::Property::SHADOW_COLOR, Color::GREEN );
649   DALI_TEST_EQUALS( field.GetProperty<Vector4>( TextField::Property::SHADOW_COLOR ), Color::GREEN, TEST_LOCATION );
650
651   // Check cursor properties
652   field.SetProperty( TextField::Property::PRIMARY_CURSOR_COLOR, Color::RED );
653   DALI_TEST_EQUALS( field.GetProperty<Vector4>( TextField::Property::PRIMARY_CURSOR_COLOR ), Color::RED, TEST_LOCATION );
654   field.SetProperty( TextField::Property::SECONDARY_CURSOR_COLOR, Color::BLUE );
655   DALI_TEST_EQUALS( field.GetProperty<Vector4>( TextField::Property::SECONDARY_CURSOR_COLOR ), Color::BLUE, TEST_LOCATION );
656
657   field.SetProperty( TextField::Property::ENABLE_CURSOR_BLINK, false );
658   DALI_TEST_EQUALS( field.GetProperty<bool>( TextField::Property::ENABLE_CURSOR_BLINK ), false, TEST_LOCATION );
659   field.SetProperty( TextField::Property::CURSOR_BLINK_INTERVAL, 1.f );
660   DALI_TEST_EQUALS( field.GetProperty<float>( TextField::Property::CURSOR_BLINK_INTERVAL ), 1.f, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
661   field.SetProperty( TextField::Property::CURSOR_BLINK_DURATION, 10.f );
662   DALI_TEST_EQUALS( field.GetProperty<float>( TextField::Property::CURSOR_BLINK_DURATION ), 10.f, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
663   field.SetProperty( TextField::Property::CURSOR_WIDTH, 1 );
664   DALI_TEST_EQUALS( field.GetProperty<int>( TextField::Property::CURSOR_WIDTH ), 1, TEST_LOCATION );
665
666   // Check scroll properties.
667   field.SetProperty( TextField::Property::SCROLL_THRESHOLD, 1.f );
668   DALI_TEST_EQUALS( field.GetProperty<float>( TextField::Property::SCROLL_THRESHOLD ), 1.f, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
669   field.SetProperty( TextField::Property::SCROLL_SPEED, 100.f );
670   DALI_TEST_EQUALS( field.GetProperty<float>( TextField::Property::SCROLL_SPEED ), 100.f, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
671
672   // Check handle images
673   field.SetProperty( TextField::Property::GRAB_HANDLE_IMAGE, "image1" );
674   DALI_TEST_EQUALS( field.GetProperty<std::string>( TextField::Property::GRAB_HANDLE_IMAGE ), "image1", TEST_LOCATION );
675   field.SetProperty( TextField::Property::GRAB_HANDLE_PRESSED_IMAGE, "image2" );
676   DALI_TEST_EQUALS( field.GetProperty<std::string>( TextField::Property::GRAB_HANDLE_PRESSED_IMAGE ), "image2", TEST_LOCATION );
677   field.SetProperty( TextField::Property::SELECTION_HANDLE_IMAGE_LEFT, "image3" );
678
679   // Check handle images
680   DALI_TEST_CHECK( SetPropertyMapRetrieved( field, TextField::Property::SELECTION_HANDLE_IMAGE_LEFT, "filename", "leftHandleImage" )  );
681   DALI_TEST_CHECK( SetPropertyMapRetrieved( field, TextField::Property::SELECTION_HANDLE_IMAGE_RIGHT, "filename", "rightHandleImage" )  );
682   DALI_TEST_CHECK( SetPropertyMapRetrieved( field, TextField::Property::SELECTION_HANDLE_PRESSED_IMAGE_LEFT, "filename", "leftHandleImagePressed" )  );
683   DALI_TEST_CHECK( SetPropertyMapRetrieved( field, TextField::Property::SELECTION_HANDLE_PRESSED_IMAGE_RIGHT, "filename", "rightHandleImagePressed" )  );
684   DALI_TEST_CHECK( SetPropertyMapRetrieved( field, TextField::Property::SELECTION_HANDLE_MARKER_IMAGE_LEFT, "filename", "leftHandleMarkerImage" )  );
685   DALI_TEST_CHECK( SetPropertyMapRetrieved( field, TextField::Property::SELECTION_HANDLE_MARKER_IMAGE_RIGHT, "filename", "rightHandleMarkerImage" )  );
686
687   // Check the highlight color
688   field.SetProperty( TextField::Property::SELECTION_HIGHLIGHT_COLOR, Color::GREEN );
689   DALI_TEST_EQUALS( field.GetProperty<Vector4>( TextField::Property::SELECTION_HIGHLIGHT_COLOR ), Color::GREEN, TEST_LOCATION );
690
691   // Decoration bounding box
692   field.SetProperty( TextField::Property::DECORATION_BOUNDING_BOX, Rect<int>( 0, 0, 1, 1 ) );
693   DALI_TEST_EQUALS( field.GetProperty<Rect <int > >( TextField::Property::DECORATION_BOUNDING_BOX ), Rect<int>( 0, 0, 1, 1 ), TEST_LOCATION );
694
695   // Check the input method setting
696   Property::Map propertyMap;
697   InputMethod::PanelLayout::Type panelLayout = InputMethod::PanelLayout::NUMBER;
698   InputMethod::AutoCapital::Type autoCapital = InputMethod::AutoCapital::WORD;
699   InputMethod::ActionButtonTitle::Type actionButton = InputMethod::ActionButtonTitle::GO;
700   int inputVariation = 1;
701   propertyMap["PANEL_LAYOUT"] = panelLayout;
702   propertyMap["AUTO_CAPITALISE"] = autoCapital;
703   propertyMap["ACTION_BUTTON"] = actionButton;
704   propertyMap["VARIATION"] = inputVariation;
705   field.SetProperty( TextField::Property::INPUT_METHOD_SETTINGS, propertyMap );
706
707   Property::Value value = field.GetProperty( TextField::Property::INPUT_METHOD_SETTINGS );
708   Property::Map map;
709   DALI_TEST_CHECK( value.Get( map ) );
710
711   int layout = 0;
712   DALI_TEST_CHECK( map[ "PANEL_LAYOUT" ].Get( layout ) );
713   DALI_TEST_EQUALS( static_cast<int>(panelLayout), layout, TEST_LOCATION );
714
715   int capital = 0;
716   DALI_TEST_CHECK( map[ "AUTO_CAPITALISE" ].Get( capital ) );
717   DALI_TEST_EQUALS( static_cast<int>(autoCapital), capital, TEST_LOCATION );
718
719   int action = 0;
720   DALI_TEST_CHECK( map[ "ACTION_BUTTON" ].Get( action ) );
721   DALI_TEST_EQUALS( static_cast<int>(actionButton), action, TEST_LOCATION );
722
723   int variation = 0;
724   DALI_TEST_CHECK( map[ "VARIATION" ].Get( variation ) );
725   DALI_TEST_EQUALS( inputVariation, variation, TEST_LOCATION );
726
727   // Check input color property.
728   field.SetProperty( TextField::Property::INPUT_COLOR, Color::YELLOW );
729   DALI_TEST_EQUALS( field.GetProperty<Vector4>( TextField::Property::INPUT_COLOR ), Color::YELLOW, TEST_LOCATION );
730
731   // Check the enable markup property.
732   DALI_TEST_CHECK( !field.GetProperty<bool>( TextField::Property::ENABLE_MARKUP ) );
733   field.SetProperty( TextField::Property::ENABLE_MARKUP, true );
734   DALI_TEST_CHECK( field.GetProperty<bool>( TextField::Property::ENABLE_MARKUP ) );
735
736   // Check input font properties.
737   field.SetProperty( TextField::Property::INPUT_FONT_FAMILY, "Setting input font family" );
738   DALI_TEST_EQUALS( field.GetProperty<std::string>( TextField::Property::INPUT_FONT_FAMILY ), "Setting input font family", TEST_LOCATION );
739
740   fontStyleMapSet.Clear();
741   fontStyleMapSet.Insert( "weight", "bold" );
742   fontStyleMapSet.Insert( "width", "condensed" );
743   fontStyleMapSet.Insert( "slant", "italic" );
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   field.SetProperty( TextField::Property::INPUT_POINT_SIZE, 12.f );
751   DALI_TEST_EQUALS( field.GetProperty<float>( TextField::Property::INPUT_POINT_SIZE ), 12.f, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
752
753   // Reset input font style.
754   fontStyleMapSet.Clear();
755   fontStyleMapSet.Insert( "weight", "normal" );
756   fontStyleMapSet.Insert( "slant", "oblique" );
757
758   field.SetProperty( TextField::Property::INPUT_FONT_STYLE, fontStyleMapSet );
759   fontStyleMapGet = field.GetProperty<Property::Map>( TextField::Property::INPUT_FONT_STYLE );
760   DALI_TEST_EQUALS( fontStyleMapGet.Count(), fontStyleMapSet.Count(), TEST_LOCATION );
761   DALI_TEST_EQUALS( DaliTestCheckMaps( fontStyleMapGet, fontStyleMapSet ), true, TEST_LOCATION );
762
763   fontStyleMapSet.Clear();
764   fontStyleMapSet.Insert( "slant", "roman" );
765
766   field.SetProperty( TextField::Property::INPUT_FONT_STYLE, fontStyleMapSet );
767   fontStyleMapGet = field.GetProperty<Property::Map>( TextField::Property::INPUT_FONT_STYLE );
768
769   // Replace 'roman' for 'normal'.
770   slantValue = fontStyleMapGet.Find( "slant" );
771   if( NULL != slantValue )
772   {
773     if( "normal" == slantValue->Get<std::string>() )
774     {
775       fontStyleMapGet["slant"] = "roman";
776     }
777   }
778   DALI_TEST_EQUALS( fontStyleMapGet.Count(), fontStyleMapSet.Count(), TEST_LOCATION );
779   DALI_TEST_EQUALS( DaliTestCheckMaps( fontStyleMapGet, fontStyleMapSet ), true, TEST_LOCATION );
780
781   fontStyleMapSet.Clear();
782
783   field.SetProperty( TextField::Property::INPUT_FONT_STYLE, fontStyleMapSet );
784   fontStyleMapGet = field.GetProperty<Property::Map>( TextField::Property::INPUT_FONT_STYLE );
785   DALI_TEST_EQUALS( fontStyleMapGet.Count(), fontStyleMapSet.Count(), TEST_LOCATION );
786   DALI_TEST_EQUALS( DaliTestCheckMaps( fontStyleMapGet, fontStyleMapSet ), true, TEST_LOCATION );
787
788   Property::Map underlineMapSet;
789   Property::Map underlineMapGet;
790
791   underlineMapSet.Insert( "enable", "true" );
792   underlineMapSet.Insert( "color", "red" );
793   underlineMapSet.Insert( "height", "1" );
794
795   // Check the underline property
796   field.SetProperty( TextField::Property::UNDERLINE, underlineMapSet );
797
798   underlineMapGet = field.GetProperty<Property::Map>( TextField::Property::UNDERLINE );
799   DALI_TEST_EQUALS( underlineMapGet.Count(), underlineMapSet.Count(), TEST_LOCATION );
800   DALI_TEST_EQUALS( DaliTestCheckMaps( underlineMapGet, underlineMapSet ), true, TEST_LOCATION );
801
802   // Check the input underline property
803   field.SetProperty( TextField::Property::INPUT_UNDERLINE, "Underline input properties" );
804   DALI_TEST_EQUALS( field.GetProperty<std::string>( TextField::Property::INPUT_UNDERLINE ), std::string("Underline input properties"), TEST_LOCATION );
805
806   // Check the shadow property
807   Property::Map shadowMapSet;
808   Property::Map shadowMapGet;
809
810   shadowMapSet.Insert( "color", "green" );
811   shadowMapSet.Insert( "offset", "2 2" );
812
813   field.SetProperty( TextField::Property::SHADOW, shadowMapSet );
814
815   shadowMapGet = field.GetProperty<Property::Map>( TextField::Property::SHADOW );
816   DALI_TEST_EQUALS( shadowMapGet.Count(), shadowMapSet.Count(), TEST_LOCATION );
817   DALI_TEST_EQUALS( DaliTestCheckMaps( shadowMapGet, shadowMapSet ), true, TEST_LOCATION );
818
819   // Check the input shadow property
820   field.SetProperty( TextField::Property::INPUT_SHADOW, "Shadow input properties" );
821   DALI_TEST_EQUALS( field.GetProperty<std::string>( TextField::Property::INPUT_SHADOW ), std::string("Shadow input properties"), TEST_LOCATION );
822
823   // Check the emboss property
824   field.SetProperty( TextField::Property::EMBOSS, "Emboss properties" );
825   DALI_TEST_EQUALS( field.GetProperty<std::string>( TextField::Property::EMBOSS ), std::string("Emboss properties"), TEST_LOCATION );
826
827   // Check the input emboss property
828   field.SetProperty( TextField::Property::INPUT_EMBOSS, "Emboss input properties" );
829   DALI_TEST_EQUALS( field.GetProperty<std::string>( TextField::Property::INPUT_EMBOSS ), std::string("Emboss input properties"), TEST_LOCATION );
830
831   // Check the outline property
832   Property::Map outlineMapSet;
833   Property::Map outlineMapGet;
834
835   outlineMapSet["color"] = Color::RED;
836   outlineMapSet["width"] = 2.0f;
837
838   field.SetProperty( TextField::Property::OUTLINE, outlineMapSet );
839
840   outlineMapSet["color"] = "red";
841   outlineMapSet["width"] = "2";
842   outlineMapGet = field.GetProperty<Property::Map>( TextField::Property::OUTLINE );
843   DALI_TEST_EQUALS( outlineMapGet.Count(), outlineMapSet.Count(), TEST_LOCATION );
844   DALI_TEST_EQUALS( DaliTestCheckMaps( outlineMapGet, outlineMapSet ), true, TEST_LOCATION );
845
846   // Check the input outline property
847   field.SetProperty( TextField::Property::INPUT_OUTLINE, "Outline input properties" );
848   DALI_TEST_EQUALS( field.GetProperty<std::string>( TextField::Property::INPUT_OUTLINE ), std::string("Outline input properties"), TEST_LOCATION );
849
850   // Check the hidden input settings property
851   Property::Map hiddenMapSet;
852   Property::Map hiddenMapGet;
853   hiddenMapSet[ HiddenInput::Property::MODE ] = HiddenInput::Mode::HIDE_ALL;
854   hiddenMapSet[ HiddenInput::Property::SHOW_DURATION ] = 2;
855   hiddenMapSet[ HiddenInput::Property::SUBSTITUTE_COUNT ] = 4;
856   hiddenMapSet[ HiddenInput::Property::SUBSTITUTE_CHARACTER ] = 0x23;
857   field.SetProperty( DevelTextField::Property::HIDDEN_INPUT_SETTINGS, hiddenMapSet );
858
859   hiddenMapGet = field.GetProperty<Property::Map>( DevelTextField::Property::HIDDEN_INPUT_SETTINGS );
860   DALI_TEST_EQUALS( hiddenMapSet.Count(), hiddenMapGet.Count(), TEST_LOCATION );
861   DALI_TEST_EQUALS( DaliTestCheckMaps( hiddenMapSet, hiddenMapGet ), true, TEST_LOCATION );
862
863   // Check the pixel size of font
864   field.SetProperty( DevelTextField::Property::PIXEL_SIZE, 20.f );
865   DALI_TEST_EQUALS( field.GetProperty<float>( DevelTextField::Property::PIXEL_SIZE ), 20.f, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
866
867   // Check the enable selection property
868   field.SetProperty( DevelTextField::Property::ENABLE_SELECTION, false );
869   DALI_TEST_EQUALS( field.GetProperty<bool>( DevelTextField::Property::ENABLE_SELECTION ), false, TEST_LOCATION );
870
871   // Check the placeholder property with pixel size
872   Property::Map placeholderPixelSizeMapSet;
873   Property::Map placeholderPixelSizeMapGet;
874   Property::Map placeholderFontstyleMap;
875   placeholderPixelSizeMapSet["placeholderText"] = "Setting Placeholder Text";
876   placeholderPixelSizeMapSet["placeholderTextFocused"] = "Setting Placeholder Text Focused";
877   placeholderPixelSizeMapSet["placeholderColor"] = Color::BLUE;
878   placeholderPixelSizeMapSet["placeholderFontFamily"] = "Arial";
879   placeholderPixelSizeMapSet["placeholderPixelSize"] = 15.0f;
880   placeholderPixelSizeMapSet["placeholderEllipsis"] = true;
881
882   placeholderFontstyleMap.Insert( "weight", "bold" );
883   placeholderPixelSizeMapSet["placeholderFontStyle"] = placeholderFontstyleMap;
884   field.SetProperty( DevelTextField::Property::PLACEHOLDER, placeholderPixelSizeMapSet );
885
886   placeholderPixelSizeMapGet = field.GetProperty<Property::Map>( DevelTextField::Property::PLACEHOLDER );
887   DALI_TEST_EQUALS( placeholderPixelSizeMapGet.Count(), placeholderPixelSizeMapSet.Count(), TEST_LOCATION );
888   DALI_TEST_EQUALS( DaliTestCheckMaps( placeholderPixelSizeMapGet, placeholderPixelSizeMapSet ), true, TEST_LOCATION );
889
890   // Check the placeholder property with point size
891   Property::Map placeholderMapSet;
892   Property::Map placeholderMapGet;
893   placeholderMapSet["placeholderText"] = "Setting Placeholder Text";
894   placeholderMapSet["placeholderTextFocused"] = "Setting Placeholder Text Focused";
895   placeholderMapSet["placeholderColor"] = Color::RED;
896   placeholderMapSet["placeholderFontFamily"] = "Arial";
897   placeholderMapSet["placeholderPointSize"] = 12.0f;
898   placeholderMapSet["placeholderEllipsis"] = false;
899
900   // Check the placeholder font style property
901   placeholderFontstyleMap.Clear();
902
903   placeholderFontstyleMap.Insert( "weight", "bold" );
904   placeholderFontstyleMap.Insert( "width", "condensed" );
905   placeholderFontstyleMap.Insert( "slant", "italic" );
906   placeholderMapSet["placeholderFontStyle"] = placeholderFontstyleMap;
907   field.SetProperty( DevelTextField::Property::PLACEHOLDER, placeholderMapSet );
908
909   placeholderMapGet = field.GetProperty<Property::Map>( DevelTextField::Property::PLACEHOLDER );
910   DALI_TEST_EQUALS( placeholderMapGet.Count(), placeholderMapSet.Count(), TEST_LOCATION );
911   DALI_TEST_EQUALS( DaliTestCheckMaps( placeholderMapGet, placeholderMapSet ), true, TEST_LOCATION );
912
913   // Reset font style.
914   placeholderFontstyleMap.Clear();
915   placeholderFontstyleMap.Insert( "weight", "normal" );
916   placeholderFontstyleMap.Insert( "slant", "oblique" );
917   placeholderMapSet["placeholderFontStyle"] = placeholderFontstyleMap;
918   field.SetProperty( DevelTextField::Property::PLACEHOLDER, placeholderMapSet );
919
920   placeholderMapGet = field.GetProperty<Property::Map>( DevelTextField::Property::PLACEHOLDER );
921   DALI_TEST_EQUALS( placeholderMapGet.Count(), placeholderMapSet.Count(), TEST_LOCATION );
922   DALI_TEST_EQUALS( DaliTestCheckMaps( placeholderMapGet, placeholderMapSet ), true, TEST_LOCATION );
923
924   placeholderFontstyleMap.Clear();
925   placeholderFontstyleMap.Insert( "slant", "roman" );
926   placeholderMapSet["placeholderFontStyle"] = placeholderFontstyleMap;
927   field.SetProperty( DevelTextField::Property::PLACEHOLDER, placeholderMapSet );
928
929   placeholderMapGet = field.GetProperty<Property::Map>( DevelTextField::Property::PLACEHOLDER );
930
931   placeholderFontstyleMap.Clear();
932   placeholderMapSet["placeholderFontStyle"] = placeholderFontstyleMap;
933
934   field.SetProperty( DevelTextField::Property::PLACEHOLDER, placeholderMapSet );
935   placeholderMapGet = field.GetProperty<Property::Map>( DevelTextField::Property::PLACEHOLDER );
936   DALI_TEST_EQUALS( placeholderMapGet.Count(), placeholderMapSet.Count(), TEST_LOCATION );
937   DALI_TEST_EQUALS( DaliTestCheckMaps( placeholderMapGet, placeholderMapSet ), true, TEST_LOCATION );
938
939   // Check the ellipsis property
940   DALI_TEST_CHECK( !field.GetProperty<bool>( DevelTextField::Property::ELLIPSIS ) );
941   field.SetProperty( DevelTextField::Property::ELLIPSIS, true );
942   DALI_TEST_CHECK( field.GetProperty<bool>( DevelTextField::Property::ELLIPSIS ) );
943
944   END_TEST;
945 }
946
947 // Positive Atlas Text Renderer test
948 int utcDaliTextFieldAtlasRenderP(void)
949 {
950   ToolkitTestApplication application;
951   tet_infoline(" UtcDaliToolkitTextFieldAtlasRenderP");
952   StyleManager styleManager = StyleManager::Get();
953   styleManager.ApplyDefaultTheme();
954   TextField field = TextField::New();
955   DALI_TEST_CHECK( field );
956
957   field.SetProperty( TextField::Property::HORIZONTAL_ALIGNMENT, "CENTER" );
958
959   application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
960
961   Stage::GetCurrent().Add( field );
962
963   try
964   {
965     // Render some text with the shared atlas backend
966     field.SetProperty( TextField::Property::RENDERING_BACKEND, Text::RENDERING_SHARED_ATLAS );
967     application.SendNotification();
968     application.Render();
969   }
970   catch( ... )
971   {
972     tet_result(TET_FAIL);
973   }
974   END_TEST;
975 }
976
977 // Positive test for the textChanged signal.
978 int utcDaliTextFieldTextChangedP(void)
979 {
980   ToolkitTestApplication application;
981   tet_infoline(" utcDaliTextFieldTextChangedP");
982   TextField field = TextField::New();
983   DALI_TEST_CHECK( field );
984
985   Stage::GetCurrent().Add( field );
986
987   // connect to the text changed signal.
988   ConnectionTracker* testTracker = new ConnectionTracker();
989   field.TextChangedSignal().Connect(&TestTextChangedCallback);
990   bool textChangedSignal = false;
991   field.ConnectSignal( testTracker, "textChanged",   CallbackFunctor(&textChangedSignal) );
992
993   gTextChangedCallBackCalled = false;
994   field.SetProperty( TextField::Property::TEXT, "ABC" );
995   DALI_TEST_CHECK( gTextChangedCallBackCalled );
996   DALI_TEST_CHECK( textChangedSignal );
997
998   application.SendNotification();
999
1000   field.SetKeyInputFocus();
1001
1002   gTextChangedCallBackCalled = false;
1003   application.ProcessEvent( GenerateKey( "D", "D", KEY_D_CODE, 0, 0, Integration::KeyEvent::Down, DEFAULT_DEVICE_NAME, DevelDevice::Class::NONE, DevelDevice::Subclass::NONE ) );
1004   DALI_TEST_CHECK( gTextChangedCallBackCalled );
1005
1006   END_TEST;
1007 }
1008
1009 // Negative test for the textChanged signal.
1010 int utcDaliTextFieldTextChangedN(void)
1011 {
1012   ToolkitTestApplication application;
1013   tet_infoline(" utcDaliTextFieldTextChangedN");
1014   TextField field = TextField::New();
1015   DALI_TEST_CHECK( field );
1016
1017   Stage::GetCurrent().Add( field );
1018
1019   // connect to the text changed signal.
1020   ConnectionTracker* testTracker = new ConnectionTracker();
1021   field.TextChangedSignal().Connect(&TestTextChangedCallback);
1022   bool textChangedSignal = false;
1023   field.ConnectSignal( testTracker, "textChanged",   CallbackFunctor(&textChangedSignal) );
1024
1025   gTextChangedCallBackCalled = false;
1026   field.SetProperty( TextField::Property::PLACEHOLDER_TEXT, "ABC" ); // Setting placeholder, not TEXT
1027   DALI_TEST_CHECK( !gTextChangedCallBackCalled );
1028   DALI_TEST_CHECK( !textChangedSignal );
1029
1030   END_TEST;
1031 }
1032
1033 // Positive test for Max Characters reached signal.
1034 int utcDaliTextFieldMaxCharactersReachedP(void)
1035 {
1036   ToolkitTestApplication application;
1037   tet_infoline(" utcDaliTextFieldMaxCharactersReachedP");
1038   TextField field = TextField::New();
1039   DALI_TEST_CHECK( field );
1040
1041   Stage::GetCurrent().Add( field );
1042
1043   const int maxNumberOfCharacters = 1;
1044   field.SetProperty( TextField::Property::MAX_LENGTH, maxNumberOfCharacters );
1045
1046   field.SetKeyInputFocus();
1047
1048   // connect to the text changed signal.
1049   ConnectionTracker* testTracker = new ConnectionTracker();
1050   field.MaxLengthReachedSignal().Connect(&TestMaxLengthReachedCallback);
1051   bool maxLengthReachedSignal = false;
1052   field.ConnectSignal( testTracker, "maxLengthReached",   CallbackFunctor(&maxLengthReachedSignal) );
1053
1054   gMaxCharactersCallBackCalled = false;
1055
1056   application.ProcessEvent( GenerateKey( "a", "a", KEY_A_CODE, 0, 0, Integration::KeyEvent::Down, DEFAULT_DEVICE_NAME, DevelDevice::Class::NONE, DevelDevice::Subclass::NONE ) );
1057   application.ProcessEvent( GenerateKey( "a", "a", KEY_A_CODE, 0, 0, Integration::KeyEvent::Down, DEFAULT_DEVICE_NAME, DevelDevice::Class::NONE, DevelDevice::Subclass::NONE ) );
1058
1059   DALI_TEST_CHECK( gMaxCharactersCallBackCalled );
1060   DALI_TEST_CHECK( maxLengthReachedSignal );
1061
1062   END_TEST;
1063 }
1064
1065 // Negative test for Max Characters reached signal.
1066 int utcDaliTextFieldMaxCharactersReachedN(void)
1067 {
1068   ToolkitTestApplication application;
1069   tet_infoline(" utcDaliTextFieldMaxCharactersReachedN");
1070   TextField field = TextField::New();
1071   DALI_TEST_CHECK( field );
1072
1073   Stage::GetCurrent().Add( field );
1074
1075   const int maxNumberOfCharacters = 3;
1076   field.SetProperty( TextField::Property::MAX_LENGTH, maxNumberOfCharacters );
1077
1078   field.SetKeyInputFocus();
1079
1080   // connect to the text changed signal.
1081   ConnectionTracker* testTracker = new ConnectionTracker();
1082   field.MaxLengthReachedSignal().Connect(&TestMaxLengthReachedCallback);
1083   bool maxLengthReachedSignal = false;
1084   field.ConnectSignal( testTracker, "maxLengthReached",   CallbackFunctor(&maxLengthReachedSignal) );
1085
1086   gMaxCharactersCallBackCalled = false;
1087
1088   application.ProcessEvent( GenerateKey( "a", "a", KEY_A_CODE, 0, 0, Integration::KeyEvent::Down, DEFAULT_DEVICE_NAME, DevelDevice::Class::NONE, DevelDevice::Subclass::NONE ) );
1089   application.ProcessEvent( GenerateKey( "a", "a", KEY_A_CODE, 0, 0, Integration::KeyEvent::Down, DEFAULT_DEVICE_NAME, DevelDevice::Class::NONE, DevelDevice::Subclass::NONE ) );
1090
1091   DALI_TEST_CHECK( !gMaxCharactersCallBackCalled );
1092   DALI_TEST_CHECK( !maxLengthReachedSignal );
1093
1094   END_TEST;
1095 }
1096
1097 int utcDaliTextFieldInputStyleChanged01(void)
1098 {
1099   ToolkitTestApplication application;
1100   tet_infoline(" utcDaliTextFieldInputStyleChanged01");
1101
1102   // The text-field emits signals when the input style changes. These changes of style are
1103   // detected during the relayout process (size negotiation), i.e after the cursor has been moved. Signals
1104   // can't be emitted during the size negotiation as the callbacks may update the UI.
1105   // The text-field adds an idle callback to the adaptor to emit the signals after the size negotiation.
1106   // This creates an implementation of the adaptor stub and a queue of idle callbacks.
1107   application.CreateAdaptor();
1108
1109   // Load some fonts.
1110
1111   char* pathNamePtr = get_current_dir_name();
1112   const std::string pathName( pathNamePtr );
1113   free( pathNamePtr );
1114
1115   TextAbstraction::FontClient fontClient = TextAbstraction::FontClient::Get();
1116   fontClient.SetDpi( 93u, 93u );
1117
1118   fontClient.GetFontId( pathName + DEFAULT_FONT_DIR + "/dejavu/DejaVuSerif.ttf", DEFAULT_FONT_SIZE );
1119   fontClient.GetFontId( pathName + DEFAULT_FONT_DIR + "/dejavu/DejaVuSerif-Bold.ttf", DEFAULT_FONT_SIZE );
1120
1121   TextField field = TextField::New();
1122   DALI_TEST_CHECK( field );
1123
1124
1125   field.SetSize( 300.f, 50.f );
1126   field.SetParentOrigin( ParentOrigin::TOP_LEFT );
1127   field.SetAnchorPoint( AnchorPoint::TOP_LEFT );
1128
1129   field.SetProperty( TextField::Property::ENABLE_MARKUP, true );
1130   field.SetProperty( TextField::Property::TEXT, "<font family='DejaVuSerif' size='18'>He<color value='green'>llo</color> <font weight='bold'>world</font> demo</font>" );
1131
1132   // connect to the text changed signal.
1133   ConnectionTracker* testTracker = new ConnectionTracker();
1134   field.InputStyleChangedSignal().Connect( &TestInputStyleChangedCallback );
1135   bool inputStyleChangedSignal = false;
1136   field.ConnectSignal( testTracker, "inputStyleChanged",   CallbackFunctor(&inputStyleChangedSignal) );
1137
1138   Stage::GetCurrent().Add( field );
1139
1140   // Render and notify
1141   application.SendNotification();
1142   application.Render();
1143
1144   // Executes the idle callbacks added by the text control on the change of input style.
1145   application.RunIdles();
1146
1147   gInputStyleChangedCallbackCalled = false;
1148   gInputStyleMask = TextField::InputStyle::NONE;
1149   inputStyleChangedSignal = false;
1150
1151   // Create a tap event to touch the text field.
1152   application.ProcessEvent( GenerateTap( Gesture::Possible, 1u, 1u, Vector2( 18.f, 25.f ) ) );
1153   application.ProcessEvent( GenerateTap( Gesture::Started, 1u, 1u, Vector2( 18.f, 25.f ) ) );
1154
1155   // Render and notify
1156   application.SendNotification();
1157   application.Render();
1158
1159   // Executes the idle callbacks added by the text control on the change of input style.
1160   application.RunIdles();
1161
1162   DALI_TEST_CHECK( gInputStyleChangedCallbackCalled );
1163   if( gInputStyleChangedCallbackCalled )
1164   {
1165     DALI_TEST_EQUALS( static_cast<unsigned int>( gInputStyleMask ), static_cast<unsigned int>( TextField::InputStyle::FONT_FAMILY | TextField::InputStyle::POINT_SIZE ), TEST_LOCATION );
1166
1167     const std::string fontFamily = field.GetProperty( TextField::Property::INPUT_FONT_FAMILY ).Get<std::string>();
1168     DALI_TEST_EQUALS( fontFamily, "DejaVuSerif", TEST_LOCATION );
1169
1170     const float pointSize = field.GetProperty( TextField::Property::INPUT_POINT_SIZE ).Get<float>();
1171     DALI_TEST_EQUALS( pointSize, 18.f, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
1172   }
1173   DALI_TEST_CHECK( inputStyleChangedSignal );
1174
1175   gInputStyleChangedCallbackCalled = false;
1176   gInputStyleMask = TextField::InputStyle::NONE;
1177   inputStyleChangedSignal = false;
1178
1179   // Create a tap event to touch the text field.
1180   application.ProcessEvent( GenerateTap( Gesture::Possible, 1u, 1u, Vector2( 30.f, 25.f ) ) );
1181   application.ProcessEvent( GenerateTap( Gesture::Started, 1u, 1u, Vector2( 30.f, 25.f ) ) );
1182
1183   // Render and notify
1184   application.SendNotification();
1185   application.Render();
1186
1187   // Executes the idle callbacks added by the text control on the change of input style.
1188   application.RunIdles();
1189
1190   DALI_TEST_CHECK( !gInputStyleChangedCallbackCalled );
1191   DALI_TEST_CHECK( !inputStyleChangedSignal );
1192
1193   gInputStyleChangedCallbackCalled = false;
1194   gInputStyleMask = TextField::InputStyle::NONE;
1195   inputStyleChangedSignal = false;
1196
1197   // Create a tap event to touch the text field.
1198   application.ProcessEvent( GenerateTap( Gesture::Possible, 1u, 1u, Vector2( 43.f, 25.f ) ) );
1199   application.ProcessEvent( GenerateTap( Gesture::Started, 1u, 1u, Vector2( 43.f, 25.f ) ) );
1200
1201   // Render and notify
1202   application.SendNotification();
1203   application.Render();
1204
1205   // Executes the idle callbacks added by the text control on the change of input style.
1206   application.RunIdles();
1207
1208   DALI_TEST_CHECK( gInputStyleChangedCallbackCalled );
1209   if( gInputStyleChangedCallbackCalled )
1210   {
1211     DALI_TEST_EQUALS( static_cast<unsigned int>( gInputStyleMask ), static_cast<unsigned int>( TextField::InputStyle::COLOR ), TEST_LOCATION );
1212
1213     const Vector4 color = field.GetProperty( TextField::Property::INPUT_COLOR ).Get<Vector4>();
1214     DALI_TEST_EQUALS( color, Color::GREEN, TEST_LOCATION );
1215   }
1216   DALI_TEST_CHECK( inputStyleChangedSignal );
1217
1218   gInputStyleChangedCallbackCalled = false;
1219   gInputStyleMask = TextField::InputStyle::NONE;
1220   inputStyleChangedSignal = false;
1221
1222   // Create a tap event to touch the text field.
1223   application.ProcessEvent( GenerateTap( Gesture::Possible, 1u, 1u, Vector2( 88.f, 25.f ) ) );
1224   application.ProcessEvent( GenerateTap( Gesture::Started, 1u, 1u, Vector2( 88.f, 25.f ) ) );
1225
1226   // Render and notify
1227   application.SendNotification();
1228   application.Render();
1229
1230   // Executes the idle callbacks added by the text control on the change of input style.
1231   application.RunIdles();
1232
1233   DALI_TEST_CHECK( gInputStyleChangedCallbackCalled );
1234   if( gInputStyleChangedCallbackCalled )
1235   {
1236     DALI_TEST_EQUALS( static_cast<unsigned int>( gInputStyleMask ), static_cast<unsigned int>( TextField::InputStyle::COLOR | TextField::InputStyle::FONT_STYLE ), TEST_LOCATION );
1237
1238     const Vector4 color = field.GetProperty( TextField::Property::INPUT_COLOR ).Get<Vector4>();
1239     DALI_TEST_EQUALS( color, Color::BLACK, TEST_LOCATION );
1240
1241     const Property::Map fontStyleMapGet = field.GetProperty( TextField::Property::INPUT_FONT_STYLE ).Get<Property::Map>();
1242
1243     Property::Map fontStyleMapSet;
1244     fontStyleMapSet.Insert( "weight", "bold" );
1245
1246     DALI_TEST_EQUALS( fontStyleMapGet.Count(), fontStyleMapSet.Count(), TEST_LOCATION );
1247     DALI_TEST_EQUALS( DaliTestCheckMaps( fontStyleMapGet, fontStyleMapSet ), true, TEST_LOCATION );
1248   }
1249   DALI_TEST_CHECK( inputStyleChangedSignal );
1250
1251   gInputStyleChangedCallbackCalled = false;
1252   gInputStyleMask = TextField::InputStyle::NONE;
1253   inputStyleChangedSignal = false;
1254
1255   // Create a tap event to touch the text field.
1256   application.ProcessEvent( GenerateTap( Gesture::Possible, 1u, 1u, Vector2( 115.f, 25.f ) ) );
1257   application.ProcessEvent( GenerateTap( Gesture::Started, 1u, 1u, Vector2( 115.f, 25.f ) ) );
1258
1259   // Render and notify
1260   application.SendNotification();
1261   application.Render();
1262
1263   // Executes the idle callbacks added by the text control on the change of input style.
1264   application.RunIdles();
1265
1266   DALI_TEST_CHECK( !gInputStyleChangedCallbackCalled );
1267   DALI_TEST_CHECK( !inputStyleChangedSignal );
1268
1269   gInputStyleChangedCallbackCalled = false;
1270   gInputStyleMask = TextField::InputStyle::NONE;
1271   inputStyleChangedSignal = false;
1272
1273   // Create a tap event to touch the text field.
1274   application.ProcessEvent( GenerateTap( Gesture::Possible, 1u, 1u, Vector2( 164.f, 25.f ) ) );
1275   application.ProcessEvent( GenerateTap( Gesture::Started, 1u, 1u, Vector2( 164.f, 25.f ) ) );
1276
1277   // Render and notify
1278   application.SendNotification();
1279   application.Render();
1280
1281   // Executes the idle callbacks added by the text control on the change of input style.
1282   application.RunIdles();
1283
1284   DALI_TEST_CHECK( gInputStyleChangedCallbackCalled );
1285   if( gInputStyleChangedCallbackCalled )
1286   {
1287     DALI_TEST_EQUALS( static_cast<unsigned int>( gInputStyleMask ), static_cast<unsigned int>( TextField::InputStyle::FONT_STYLE ), TEST_LOCATION );
1288
1289     const std::string style = field.GetProperty( TextField::Property::INPUT_FONT_STYLE ).Get<std::string>();
1290     DALI_TEST_CHECK( style.empty() );
1291   }
1292   DALI_TEST_CHECK( inputStyleChangedSignal );
1293
1294   gInputStyleChangedCallbackCalled = false;
1295   gInputStyleMask = TextField::InputStyle::NONE;
1296   inputStyleChangedSignal = false;
1297
1298   // Create a tap event to touch the text field.
1299   application.ProcessEvent( GenerateTap( Gesture::Possible, 1u, 1u, Vector2( 191.f, 25.f ) ) );
1300   application.ProcessEvent( GenerateTap( Gesture::Started, 1u, 1u, Vector2( 191.f, 25.f ) ) );
1301
1302   // Render and notify
1303   application.SendNotification();
1304   application.Render();
1305
1306   // Executes the idle callbacks added by the text control on the change of input style.
1307   application.RunIdles();
1308
1309   DALI_TEST_CHECK( !gInputStyleChangedCallbackCalled );
1310   DALI_TEST_CHECK( !inputStyleChangedSignal );
1311
1312   END_TEST;
1313 }
1314
1315 int utcDaliTextFieldInputStyleChanged02(void)
1316 {
1317   ToolkitTestApplication application;
1318   tet_infoline(" utcDaliTextFieldInputStyleChanged02");
1319
1320   // The text-field emits signals when the input style changes. These changes of style are
1321   // detected during the relayout process (size negotiation), i.e after the cursor has been moved. Signals
1322   // can't be emitted during the size negotiation as the callbacks may update the UI.
1323   // The text-field adds an idle callback to the adaptor to emit the signals after the size negotiation.
1324   // This creates an implementation of the adaptor stub and a queue of idle callbacks.
1325   application.CreateAdaptor();
1326
1327   // Load some fonts.
1328
1329   char* pathNamePtr = get_current_dir_name();
1330   const std::string pathName( pathNamePtr );
1331   free( pathNamePtr );
1332
1333   TextAbstraction::FontClient fontClient = TextAbstraction::FontClient::Get();
1334   fontClient.SetDpi( 93u, 93u );
1335
1336   fontClient.GetFontId( pathName + DEFAULT_FONT_DIR + "/dejavu/DejaVuSerif.ttf", DEFAULT_FONT_SIZE );
1337   fontClient.GetFontId( pathName + DEFAULT_FONT_DIR + "/dejavu/DejaVuSerif-Bold.ttf", DEFAULT_FONT_SIZE );
1338
1339   TextField field = TextField::New();
1340   DALI_TEST_CHECK( field );
1341
1342
1343   field.SetSize( 300.f, 50.f );
1344   field.SetParentOrigin( ParentOrigin::TOP_LEFT );
1345   field.SetAnchorPoint( AnchorPoint::TOP_LEFT );
1346
1347   field.SetProperty( TextField::Property::ENABLE_MARKUP, true );
1348   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>" );
1349
1350   // connect to the text changed signal.
1351   ConnectionTracker* testTracker = new ConnectionTracker();
1352   field.InputStyleChangedSignal().Connect( &TestInputStyleChangedCallback );
1353   bool inputStyleChangedSignal = false;
1354   field.ConnectSignal( testTracker, "inputStyleChanged",   CallbackFunctor(&inputStyleChangedSignal) );
1355
1356   Stage::GetCurrent().Add( field );
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   gInputStyleChangedCallbackCalled = false;
1366   gInputStyleMask = TextField::InputStyle::NONE;
1367   inputStyleChangedSignal = false;
1368
1369   // Create a tap event to touch the text field.
1370   application.ProcessEvent( GenerateTap( Gesture::Possible, 1u, 1u, Vector2( 53.f, 25.f ) ) );
1371   application.ProcessEvent( GenerateTap( Gesture::Started, 1u, 1u, Vector2( 53.f, 25.f ) ) );
1372   application.ProcessEvent( GenerateTap( Gesture::Possible, 2u, 1u, Vector2( 53.f, 25.f ) ) );
1373   application.ProcessEvent( GenerateTap( Gesture::Started, 2u, 1u, Vector2( 53.f, 25.f ) ) );
1374
1375   // Render and notify
1376   application.SendNotification();
1377   application.Render();
1378
1379   // Executes the idle callbacks added by the text control on the change of input style.
1380   application.RunIdles();
1381
1382   DALI_TEST_CHECK( gInputStyleChangedCallbackCalled );
1383   if( gInputStyleChangedCallbackCalled )
1384   {
1385     DALI_TEST_EQUALS( static_cast<unsigned int>( gInputStyleMask ),
1386                       static_cast<unsigned int>( TextField::InputStyle::FONT_FAMILY |
1387                                                  TextField::InputStyle::POINT_SIZE  |
1388                                                  TextField::InputStyle::COLOR ),
1389                       TEST_LOCATION );
1390
1391     const Vector4 color = field.GetProperty( TextField::Property::INPUT_COLOR ).Get<Vector4>();
1392     DALI_TEST_EQUALS( color, Color::GREEN, TEST_LOCATION );
1393
1394     const std::string fontFamily = field.GetProperty( TextField::Property::INPUT_FONT_FAMILY ).Get<std::string>();
1395     DALI_TEST_EQUALS( fontFamily, "DejaVuSerif", TEST_LOCATION );
1396
1397     const float pointSize = field.GetProperty( TextField::Property::INPUT_POINT_SIZE ).Get<float>();
1398     DALI_TEST_EQUALS( pointSize, 18.f, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
1399   }
1400   DALI_TEST_CHECK( inputStyleChangedSignal );
1401
1402   gInputStyleChangedCallbackCalled = false;
1403   gInputStyleMask = TextField::InputStyle::NONE;
1404   inputStyleChangedSignal = false;
1405
1406   application.ProcessEvent( GenerateKey( "", "", DALI_KEY_BACKSPACE, 0, 0, Integration::KeyEvent::Down, DEFAULT_DEVICE_NAME, DevelDevice::Class::NONE, DevelDevice::Subclass::NONE ) );
1407
1408   // Render and notify
1409   application.SendNotification();
1410   application.Render();
1411
1412   // Executes the idle callbacks added by the text control on the change of input style.
1413   application.RunIdles();
1414
1415   DALI_TEST_CHECK( gInputStyleChangedCallbackCalled );
1416   if( gInputStyleChangedCallbackCalled )
1417   {
1418     DALI_TEST_EQUALS( static_cast<unsigned int>( gInputStyleMask ),
1419                       static_cast<unsigned int>( TextField::InputStyle::COLOR ),
1420                       TEST_LOCATION );
1421
1422     const Vector4 color = field.GetProperty( TextField::Property::INPUT_COLOR ).Get<Vector4>();
1423     DALI_TEST_EQUALS( color, Color::BLUE, TEST_LOCATION );
1424   }
1425   DALI_TEST_CHECK( inputStyleChangedSignal );
1426
1427   gInputStyleChangedCallbackCalled = false;
1428   gInputStyleMask = TextField::InputStyle::NONE;
1429   inputStyleChangedSignal = false;
1430
1431   application.ProcessEvent( GenerateKey( "", "", DALI_KEY_BACKSPACE, 0, 0, Integration::KeyEvent::Down, DEFAULT_DEVICE_NAME, DevelDevice::Class::NONE, DevelDevice::Subclass::NONE ) );
1432
1433   // Render and notify
1434   application.SendNotification();
1435   application.Render();
1436
1437   // Executes the idle callbacks added by the text control on the change of input style.
1438   application.RunIdles();
1439
1440   DALI_TEST_CHECK( !gInputStyleChangedCallbackCalled );
1441   DALI_TEST_CHECK( !inputStyleChangedSignal );
1442
1443   gInputStyleChangedCallbackCalled = false;
1444   gInputStyleMask = TextField::InputStyle::NONE;
1445   inputStyleChangedSignal = false;
1446
1447   application.ProcessEvent( GenerateKey( "", "", DALI_KEY_BACKSPACE, 0, 0, Integration::KeyEvent::Down, DEFAULT_DEVICE_NAME, DevelDevice::Class::NONE, DevelDevice::Subclass::NONE ) );
1448
1449   // Render and notify
1450   application.SendNotification();
1451   application.Render();
1452
1453   // Executes the idle callbacks added by the text control on the change of input style.
1454   application.RunIdles();
1455
1456   DALI_TEST_CHECK( gInputStyleChangedCallbackCalled );
1457   if( gInputStyleChangedCallbackCalled )
1458   {
1459     DALI_TEST_EQUALS( static_cast<unsigned int>( gInputStyleMask ),
1460                       static_cast<unsigned int>( TextField::InputStyle::COLOR ),
1461                       TEST_LOCATION );
1462
1463     const Vector4 color = field.GetProperty( TextField::Property::INPUT_COLOR ).Get<Vector4>();
1464     DALI_TEST_EQUALS( color, Color::BLACK, TEST_LOCATION );
1465   }
1466   DALI_TEST_CHECK( inputStyleChangedSignal );
1467
1468   gInputStyleChangedCallbackCalled = false;
1469   gInputStyleMask = TextField::InputStyle::NONE;
1470   inputStyleChangedSignal = false;
1471
1472   field.SetProperty( TextField::Property::INPUT_COLOR, Color::YELLOW );
1473
1474   Property::Map fontStyleMapSet;
1475   fontStyleMapSet.Insert( "weight", "thin" );
1476   fontStyleMapSet.Insert( "width", "condensed" );
1477   fontStyleMapSet.Insert( "slant", "italic" );
1478
1479   field.SetProperty( TextField::Property::INPUT_FONT_STYLE, fontStyleMapSet );
1480   field.SetProperty( TextField::Property::INPUT_POINT_SIZE, 20.f );
1481
1482   field.SetProperty( TextField::Property::INPUT_UNDERLINE, "underline" );
1483   field.SetProperty( TextField::Property::INPUT_SHADOW, "shadow" );
1484   field.SetProperty( TextField::Property::INPUT_EMBOSS, "emboss" );
1485   field.SetProperty( TextField::Property::INPUT_OUTLINE, "outline" );
1486
1487   // Render and notify
1488   application.SendNotification();
1489   application.Render();
1490
1491   // Executes the idle callbacks added by the text control on the change of input style.
1492   application.RunIdles();
1493
1494   DALI_TEST_CHECK( !gInputStyleChangedCallbackCalled );
1495   DALI_TEST_CHECK( !inputStyleChangedSignal );
1496
1497   // Create a tap event to touch the text field.
1498   application.ProcessEvent( GenerateTap( Gesture::Possible, 1u, 1u, Vector2( 63.f, 25.f ) ) );
1499   application.ProcessEvent( GenerateTap( Gesture::Started, 1u, 1u, Vector2( 63.f, 25.f ) ) );
1500
1501   // Render and notify
1502   application.SendNotification();
1503   application.Render();
1504
1505   // Executes the idle callbacks added by the text control on the change of input style.
1506   application.RunIdles();
1507
1508   DALI_TEST_CHECK( gInputStyleChangedCallbackCalled );
1509   if( gInputStyleChangedCallbackCalled )
1510   {
1511     DALI_TEST_EQUALS( static_cast<unsigned int>( gInputStyleMask ),
1512                       static_cast<unsigned int>( TextField::InputStyle::COLOR |
1513                                                  TextField::InputStyle::POINT_SIZE |
1514                                                  TextField::InputStyle::FONT_STYLE |
1515                                                  TextField::InputStyle::UNDERLINE |
1516                                                  TextField::InputStyle::SHADOW |
1517                                                  TextField::InputStyle::EMBOSS |
1518                                                  TextField::InputStyle::OUTLINE ),
1519                       TEST_LOCATION );
1520
1521     const Vector4 color = field.GetProperty( TextField::Property::INPUT_COLOR ).Get<Vector4>();
1522     DALI_TEST_EQUALS( color, Color::BLACK, TEST_LOCATION );
1523   }
1524   DALI_TEST_CHECK( inputStyleChangedSignal );
1525
1526   END_TEST;
1527 }
1528
1529 int utcDaliTextFieldEvent01(void)
1530 {
1531   ToolkitTestApplication application;
1532   tet_infoline(" utcDaliTextFieldEvent01");
1533
1534   // Creates a tap event. After creating a tap event the text field should
1535   // have the focus and add text with key events should be possible.
1536
1537   TextField field = TextField::New();
1538   DALI_TEST_CHECK( field );
1539
1540   Stage::GetCurrent().Add( field );
1541
1542   field.SetSize( 300.f, 50.f );
1543   field.SetParentOrigin( ParentOrigin::TOP_LEFT );
1544   field.SetAnchorPoint( AnchorPoint::TOP_LEFT );
1545
1546   // Avoid a crash when core load gl resources.
1547   application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
1548
1549   // Render and notify
1550   application.SendNotification();
1551   application.Render();
1552
1553   // Add a key event but as the text field has not the focus it should do nothing.
1554   application.ProcessEvent( GenerateKey( "a", "a", KEY_A_CODE, 0, 0, Integration::KeyEvent::Down, DEFAULT_DEVICE_NAME, DevelDevice::Class::NONE, DevelDevice::Subclass::NONE ) );
1555
1556   // Render and notify
1557   application.SendNotification();
1558   application.Render();
1559
1560   DALI_TEST_EQUALS( field.GetProperty<std::string>( TextField::Property::TEXT ), std::string(""), TEST_LOCATION );
1561
1562   // Create a tap event to touch the text field.
1563   application.ProcessEvent( GenerateTap( Gesture::Possible, 1u, 1u, Vector2( 150.0f, 25.0f ) ) );
1564   application.ProcessEvent( GenerateTap( Gesture::Started, 1u, 1u, Vector2( 150.0f, 25.0f ) ) );
1565
1566   // Render and notify
1567   application.SendNotification();
1568   application.Render();
1569
1570   // Now the text field has the focus, so it can handle the key events.
1571   application.ProcessEvent( GenerateKey( "a", "a", KEY_A_CODE, 0, 0, Integration::KeyEvent::Down, DEFAULT_DEVICE_NAME, DevelDevice::Class::NONE, DevelDevice::Subclass::NONE ) );
1572   application.ProcessEvent( GenerateKey( "a", "a", KEY_A_CODE, 0, 0, Integration::KeyEvent::Down, DEFAULT_DEVICE_NAME, DevelDevice::Class::NONE, DevelDevice::Subclass::NONE ) );
1573
1574   // Render and notify
1575   application.SendNotification();
1576   application.Render();
1577
1578   DALI_TEST_EQUALS( field.GetProperty<std::string>( TextField::Property::TEXT ), std::string("aa"), TEST_LOCATION );
1579
1580   // Create a second text field and send key events to it.
1581   TextField field2 = TextField::New();
1582
1583   field2.SetParentOrigin( ParentOrigin::TOP_LEFT );
1584   field2.SetAnchorPoint( AnchorPoint::TOP_LEFT );
1585   field2.SetSize( 100.f, 100.f );
1586   field2.SetPosition( 100.f, 100.f );
1587
1588   Stage::GetCurrent().Add( field2 );
1589
1590   // Render and notify
1591   application.SendNotification();
1592   application.Render();
1593
1594   // Create a tap event on the second text field.
1595   application.ProcessEvent( GenerateTap( Gesture::Possible, 1u, 1u, Vector2( 150.0f, 125.0f ) ) );
1596   application.ProcessEvent( GenerateTap( Gesture::Started, 1u, 1u, Vector2( 150.0f, 125.0f ) ) );
1597
1598   // Render and notify
1599   application.SendNotification();
1600   application.Render();
1601
1602   // The second text field has the focus. It should handle the key events.
1603   application.ProcessEvent( GenerateKey( "a", "a", KEY_A_CODE, 0, 0, Integration::KeyEvent::Down, DEFAULT_DEVICE_NAME, DevelDevice::Class::NONE, DevelDevice::Subclass::NONE ) );
1604   application.ProcessEvent( GenerateKey( "a", "a", KEY_A_CODE, 0, 0, Integration::KeyEvent::Down, DEFAULT_DEVICE_NAME, DevelDevice::Class::NONE, DevelDevice::Subclass::NONE ) );
1605
1606   // Render and notify
1607   application.SendNotification();
1608   application.Render();
1609
1610   // Check the text has been added to the second text field.
1611   DALI_TEST_EQUALS( field2.GetProperty<std::string>( TextField::Property::TEXT ), std::string("aa"), TEST_LOCATION );
1612
1613   END_TEST;
1614 }
1615
1616 int utcDaliTextFieldEvent02(void)
1617 {
1618   ToolkitTestApplication application;
1619   tet_infoline(" utcDaliTextFieldEvent02");
1620
1621   // Checks if the right number of actors are created.
1622
1623   TextField field = TextField::New();
1624   field.SetProperty( TextField::Property::POINT_SIZE, 10.f );
1625   DALI_TEST_CHECK( field );
1626   LoadMarkerImages(application, field);
1627
1628   Stage::GetCurrent().Add( field );
1629
1630   field.SetSize( 300.f, 50.f );
1631   field.SetParentOrigin( ParentOrigin::TOP_LEFT );
1632   field.SetAnchorPoint( AnchorPoint::TOP_LEFT );
1633
1634   // Avoid a crash when core load gl resources.
1635   application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
1636
1637   // Render and notify
1638   application.SendNotification();
1639   application.Render();
1640
1641   // Check there are the expected number of children ( stencil ).
1642   DALI_TEST_EQUALS( field.GetChildCount(), 1u, TEST_LOCATION );
1643
1644   Actor stencil = field.GetChildAt( 0u );
1645   DALI_TEST_EQUALS( stencil.GetChildCount(), 0u, TEST_LOCATION );
1646
1647   // Create a tap event to touch the text field.
1648   application.ProcessEvent( GenerateTap( Gesture::Possible, 1u, 1u, Vector2( 150.0f, 25.0f ) ) );
1649   application.ProcessEvent( GenerateTap( Gesture::Started, 1u, 1u, Vector2( 150.0f, 25.0f ) ) );
1650
1651   // Render and notify
1652   application.SendNotification();
1653   application.Render();
1654
1655   Actor layer = field.GetChildAt( 1u );
1656   DALI_TEST_CHECK( layer.IsLayer() );
1657
1658   DALI_TEST_EQUALS( layer.GetChildCount(), 1u, TEST_LOCATION ); // The cursor.
1659   DALI_TEST_EQUALS( stencil.GetChildCount(), 0u, TEST_LOCATION );
1660
1661   // Now the text field has the focus, so it can handle the key events.
1662   application.ProcessEvent( GenerateKey( "a", "a", KEY_A_CODE, 0, 0, Integration::KeyEvent::Down, DEFAULT_DEVICE_NAME, DevelDevice::Class::NONE, DevelDevice::Subclass::NONE ) );
1663   application.ProcessEvent( GenerateKey( "a", "a", KEY_A_CODE, 0, 0, Integration::KeyEvent::Down, DEFAULT_DEVICE_NAME, DevelDevice::Class::NONE, DevelDevice::Subclass::NONE ) );
1664
1665   // Render and notify
1666   application.SendNotification();
1667   application.Render();
1668
1669   // Checks the cursor and the renderer have been created.
1670   DALI_TEST_EQUALS( layer.GetChildCount(), 1u, TEST_LOCATION ); // The cursor.
1671   DALI_TEST_EQUALS( stencil.GetChildCount(), 1u, TEST_LOCATION ); // The renderer
1672
1673   Control cursor = Control::DownCast( layer.GetChildAt( 0u ) );
1674   DALI_TEST_CHECK( cursor );
1675
1676   // The offscreen root actor has a container with all the actors which contain the text renderers.
1677   Actor container = stencil.GetChildAt( 0u );
1678   for( unsigned int index = 0; index < container.GetChildCount(); ++index )
1679   {
1680     Renderer renderer = container.GetChildAt( index ).GetRendererAt( 0u );
1681     DALI_TEST_CHECK( renderer );
1682   }
1683
1684   // Move the cursor and check the position changes.
1685   Vector3 position1 = cursor.GetCurrentPosition();
1686
1687   application.ProcessEvent( GenerateKey( "", "", DALI_KEY_CURSOR_LEFT, 0, 0, Integration::KeyEvent::Down, DEFAULT_DEVICE_NAME, DevelDevice::Class::NONE, DevelDevice::Subclass::NONE ) );
1688   application.ProcessEvent( GenerateKey( "", "", DALI_KEY_CURSOR_LEFT, 0, 0, Integration::KeyEvent::Down, DEFAULT_DEVICE_NAME, DevelDevice::Class::NONE, DevelDevice::Subclass::NONE ) );
1689
1690   // Render and notify
1691   application.SendNotification();
1692   application.Render();
1693
1694   Vector3 position2 = cursor.GetCurrentPosition();
1695
1696   DALI_TEST_CHECK( position2.x < position1.x );
1697
1698   application.ProcessEvent( GenerateKey( "", "", DALI_KEY_CURSOR_RIGHT, 0, 0, Integration::KeyEvent::Down, DEFAULT_DEVICE_NAME, DevelDevice::Class::NONE, DevelDevice::Subclass::NONE ) );
1699   application.ProcessEvent( GenerateKey( "", "", DALI_KEY_CURSOR_RIGHT, 0, 0, Integration::KeyEvent::Down, DEFAULT_DEVICE_NAME, DevelDevice::Class::NONE, DevelDevice::Subclass::NONE ) );
1700
1701   // Render and notify
1702   application.SendNotification();
1703   application.Render();
1704
1705   Vector3 position3 = cursor.GetCurrentPosition();
1706
1707   DALI_TEST_EQUALS( position1, position3, TEST_LOCATION ); // Should be in the same position1.
1708
1709   // Send some taps and check the cursor positions.
1710
1711   // Try to tap at the beginning.
1712   application.ProcessEvent( GenerateTap( Gesture::Possible, 1u, 1u, Vector2( 1.f, 25.0f ) ) );
1713   application.ProcessEvent( GenerateTap( Gesture::Started, 1u, 1u, Vector2( 1.f, 25.0f ) ) );
1714
1715   // Render and notify
1716   application.SendNotification();
1717   application.Render();
1718
1719   // Cursor position should be the same than position1.
1720   Vector3 position4 = cursor.GetCurrentPosition();
1721
1722   DALI_TEST_EQUALS( position2, position4, TEST_LOCATION ); // Should be in the same position2.
1723
1724   // Tap away from the start position.
1725   application.ProcessEvent( GenerateTap( Gesture::Possible, 1u, 1u, Vector2( 16.f, 25.0f ) ) );
1726   application.ProcessEvent( GenerateTap( Gesture::Started, 1u, 1u, Vector2( 16.0f, 25.0f ) ) );
1727
1728   // Render and notify
1729   application.SendNotification();
1730   application.Render();
1731
1732   Vector3 position5 = cursor.GetCurrentPosition();
1733
1734   DALI_TEST_CHECK( position5.x > position4.x );
1735
1736   // Remove all the text.
1737   application.ProcessEvent( GenerateKey( "", "", DALI_KEY_BACKSPACE, 0, 0, Integration::KeyEvent::Down, DEFAULT_DEVICE_NAME, DevelDevice::Class::NONE, DevelDevice::Subclass::NONE ) );
1738   application.ProcessEvent( GenerateKey( "", "", DALI_KEY_BACKSPACE, 0, 0, Integration::KeyEvent::Down, DEFAULT_DEVICE_NAME, DevelDevice::Class::NONE, DevelDevice::Subclass::NONE ) );
1739   field.SetProperty( TextField::Property::TEXT, "" );
1740
1741   // Render and notify
1742   application.SendNotification();
1743   application.Render();
1744
1745   // Cursor position should be the same than position2.
1746   Vector3 position6 = cursor.GetCurrentPosition();
1747
1748   DALI_TEST_EQUALS( position2, position6, TEST_LOCATION );// Should be in the same position2.
1749
1750   // Should not be a renderer.
1751   DALI_TEST_EQUALS( stencil.GetChildCount(), 0u, TEST_LOCATION );
1752
1753   // Chanege exceed policy (EXCEED_POLICY_ORIGINAL doesn't use stencil )
1754   field.SetProperty( TextField::Property::TEXT, "This is a long text for the size of the text-field." );
1755   field.SetProperty( TextField::Property::EXCEED_POLICY, Dali::Toolkit::TextField::EXCEED_POLICY_ORIGINAL );
1756
1757   application.SendNotification();
1758   application.Render();
1759
1760   // There are renderer and decorator layer
1761   DALI_TEST_EQUALS( field.GetChildCount(), 2u, TEST_LOCATION );
1762
1763   END_TEST;
1764 }
1765
1766 int utcDaliTextFieldEvent03(void)
1767 {
1768   ToolkitTestApplication application;
1769   tet_infoline(" utcDaliTextFieldEvent03");
1770
1771   // Checks if the highlight actor is created.
1772
1773   TextField field = TextField::New();
1774   DALI_TEST_CHECK( field );
1775
1776   Stage::GetCurrent().Add( field );
1777
1778   field.SetProperty( TextField::Property::TEXT, "This is a long text for the size of the text-field." );
1779   field.SetProperty( TextField::Property::POINT_SIZE, 10.f );
1780   field.SetSize( 30.f, 50.f );
1781   field.SetParentOrigin( ParentOrigin::TOP_LEFT );
1782   field.SetAnchorPoint( AnchorPoint::TOP_LEFT );
1783
1784   // Avoid a crash when core load gl resources.
1785   application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
1786   LoadMarkerImages(application, field);
1787
1788   // Render and notify
1789   application.SendNotification();
1790   application.Render();
1791
1792   // Tap first to get the focus.
1793   application.ProcessEvent( GenerateTap( Gesture::Possible, 1u, 1u, Vector2( 3.f, 25.0f ) ) );
1794   application.ProcessEvent( GenerateTap( Gesture::Started, 1u, 1u, Vector2( 3.f, 25.0f ) ) );
1795
1796   // Render and notify
1797   application.SendNotification();
1798   application.Render();
1799
1800   // Double tap to select a word.
1801   application.ProcessEvent( GenerateTap( Gesture::Possible, 2u, 1u, Vector2( 3.f, 25.0f ) ) );
1802   application.ProcessEvent( GenerateTap( Gesture::Started, 2u, 1u, Vector2( 3.f, 25.0f ) ) );
1803
1804   // Render and notify
1805   application.SendNotification();
1806   application.Render();
1807
1808   // The offscreen root actor should have two actors: the renderer and the highlight actor.
1809   Actor stencil = field.GetChildAt( 0u );
1810
1811   // The highlight actor is drawn first, so is the first actor in the list
1812   Renderer highlight = stencil.GetChildAt( 0u ).GetRendererAt( 0u );
1813   DALI_TEST_CHECK( highlight );
1814
1815   // The offscreen root actor has a container with all the actors which contain the text renderers.
1816   Actor container = stencil.GetChildAt( 1u );
1817   for( unsigned int index = 0; index < container.GetChildCount(); ++index )
1818   {
1819     Renderer renderer = container.GetChildAt( index ).GetRendererAt( 0u );
1820     DALI_TEST_CHECK( renderer );
1821   }
1822
1823   END_TEST;
1824 }
1825
1826 int utcDaliTextFieldEvent04(void)
1827 {
1828   ToolkitTestApplication application;
1829   tet_infoline(" utcDaliTextFieldEvent04");
1830
1831   // Checks if the highlight actor is created.
1832
1833   TextField field = TextField::New();
1834   DALI_TEST_CHECK( field );
1835   Stage::GetCurrent().Add( field );
1836   LoadMarkerImages(application, field);
1837   // Render and notify
1838   application.SendNotification();
1839   application.Render();
1840
1841   field.SetProperty( TextField::Property::TEXT, "This is a long text for the size of the text-field." );
1842   field.SetProperty( TextField::Property::POINT_SIZE, 10.f );
1843   field.SetSize( 300.f, 50.f );
1844   field.SetParentOrigin( ParentOrigin::TOP_LEFT );
1845   field.SetAnchorPoint( AnchorPoint::TOP_LEFT );
1846
1847   // Avoid a crash when core load gl resources.
1848   application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
1849   // Render and notify
1850   application.SendNotification();
1851   application.Render();
1852
1853   // Create a tap event to touch the text field.
1854   application.ProcessEvent( GenerateTap( Gesture::Possible, 1u, 1u, Vector2( 150.0f, 25.0f ) ) );
1855   application.ProcessEvent( GenerateTap( Gesture::Started, 1u, 1u, Vector2( 150.0f, 25.0f ) ) );
1856   // Render and notify
1857   application.SendNotification();
1858   application.Render();
1859
1860
1861   // Tap first to get the focus.
1862   application.ProcessEvent( GenerateTap( Gesture::Possible, 1u, 1u, Vector2( 1.f, 25.0f ) ) );
1863   application.ProcessEvent( GenerateTap( Gesture::Started, 1u, 1u, Vector2( 1.f, 25.0f ) ) );
1864
1865   // Render and notify
1866   application.SendNotification();
1867   application.Render();
1868
1869   // Double tap to select a word.
1870   application.ProcessEvent( GenerateTap( Gesture::Possible, 2u, 1u, Vector2( 1.f, 25.0f ) ) );
1871   application.ProcessEvent( GenerateTap( Gesture::Started, 2u, 1u, Vector2( 1.f, 25.0f ) ) );
1872
1873   // Render and notify
1874   application.SendNotification();
1875   application.Render();
1876
1877   // Tap grab handle
1878   application.ProcessEvent( GenerateTap( Gesture::Possible, 1u, 1u, Vector2( 0.f, 40.0f ) ) );
1879   application.ProcessEvent( GenerateTap( Gesture::Started, 1u, 1u, Vector2( 0.f, 40.0f ) ) );
1880   END_TEST;
1881 }
1882
1883 int utcDaliTextFieldEvent05(void)
1884 {
1885   ToolkitTestApplication application;
1886   tet_infoline(" utcDaliTextFieldEvent05");
1887
1888   // Checks dragging of cursor/grab handle
1889
1890   TextField field = TextField::New();
1891   DALI_TEST_CHECK( field );
1892   Stage::GetCurrent().Add( field );
1893   LoadMarkerImages(application, field);
1894   // Render and notify
1895   application.SendNotification();
1896   application.Render();
1897
1898   field.SetProperty( TextField::Property::TEXT, "This is a long text for the size of the text-field." );
1899   field.SetProperty( TextField::Property::POINT_SIZE, 10.f );
1900   field.SetSize( 300.f, 50.f );
1901   field.SetParentOrigin( ParentOrigin::TOP_LEFT );
1902   field.SetAnchorPoint( AnchorPoint::TOP_LEFT );
1903
1904   // Avoid a crash when core load gl resources.
1905   application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
1906   // Render and notify
1907   application.SendNotification();
1908   application.Render();
1909
1910   // Create a tap event to touch the text field.
1911   application.ProcessEvent( GenerateTap( Gesture::Possible, 1u, 1u, Vector2( 150.0f, 25.0f ) ) );
1912   application.ProcessEvent( GenerateTap( Gesture::Started, 1u, 1u, Vector2( 150.0f, 25.0f ) ) );
1913   // Render and notify
1914   application.SendNotification();
1915   application.Render();
1916
1917
1918   // Tap first to get the focus.
1919   application.ProcessEvent( GenerateTap( Gesture::Possible, 1u, 1u, Vector2( 1.f, 25.0f ) ) );
1920   application.ProcessEvent( GenerateTap( Gesture::Started, 1u, 1u, Vector2( 1.f, 25.0f ) ) );
1921
1922   // Render and notify
1923   application.SendNotification();
1924   application.Render();
1925
1926   // Double tap to select a word.
1927   application.ProcessEvent( GenerateTap( Gesture::Possible, 2u, 1u, Vector2( 1.f, 25.0f ) ) );
1928   application.ProcessEvent( GenerateTap( Gesture::Started, 2u, 1u, Vector2( 1.f, 25.0f ) ) );
1929
1930   // Render and notify
1931   application.SendNotification();
1932   application.Render();
1933
1934   // drag grab handle right
1935   Vector2 pos(0.0f, 40.0f);
1936   SendPan(application, Gesture::Possible, pos);
1937   SendPan(application, Gesture::Started, pos);
1938   pos.x += 5.0f;
1939   Wait(application, 100);
1940
1941   for(int i = 0;i<20;i++)
1942   {
1943     SendPan(application, Gesture::Continuing, pos);
1944     pos.x += 5.0f;
1945     Wait(application);
1946   }
1947
1948   SendPan(application, Gesture::Finished, pos);
1949   Wait(application, RENDER_FRAME_INTERVAL);
1950
1951   Actor stencil = field.GetChildAt( 1u );
1952   END_TEST;
1953 }
1954
1955 int utcDaliTextFieldEvent06(void)
1956 {
1957   ToolkitTestApplication application;
1958   tet_infoline(" utcDaliTextFieldEvent06");
1959
1960   // Checks Longpress when in edit mode
1961
1962   TextField field = TextField::New();
1963   DALI_TEST_CHECK( field );
1964   Stage::GetCurrent().Add( field );
1965   LoadMarkerImages(application, field);
1966   // Render and notify
1967   application.SendNotification();
1968   application.Render();
1969
1970   field.SetProperty( TextField::Property::TEXT, "Thisisalongtextforthesizeofthetextfield." );
1971   field.SetProperty( TextField::Property::POINT_SIZE, 10.f );
1972   field.SetSize( 300.f, 50.f );
1973   field.SetParentOrigin( ParentOrigin::TOP_LEFT );
1974   field.SetAnchorPoint( AnchorPoint::TOP_LEFT );
1975
1976   // Avoid a crash when core load gl resources.
1977   application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
1978   // Render and notify
1979   application.SendNotification();
1980   application.Render();
1981
1982   // Create a tap event to touch the text field.
1983   application.ProcessEvent( GenerateTap( Gesture::Possible, 1u, 1u, Vector2( 150.0f, 25.0f ) ) );
1984   application.ProcessEvent( GenerateTap( Gesture::Started, 1u, 1u, Vector2( 150.0f, 25.0f ) ) );
1985   // Render and notify
1986   application.SendNotification();
1987   application.Render();
1988
1989
1990   // Tap first to get the focus.
1991   application.ProcessEvent( GenerateTap( Gesture::Possible, 1u, 1u, Vector2( 1.f, 25.0f ) ) );
1992   application.ProcessEvent( GenerateTap( Gesture::Started, 1u, 1u, Vector2( 1.f, 25.0f ) ) );
1993
1994   // Render and notify
1995   application.SendNotification();
1996   application.Render();
1997
1998   // Long Press
1999   application.ProcessEvent( GenerateLongPress( Gesture::Possible, 1u, Vector2( 1.f, 25.0f ) ) );
2000   application.ProcessEvent( GenerateLongPress( Gesture::Started,  1u, Vector2( 1.f, 25.0f ) ) );
2001
2002   // Render and notify
2003   application.SendNotification();
2004   application.Render();
2005
2006   END_TEST;
2007 }
2008
2009 int utcDaliTextFieldEvent07(void)
2010 {
2011   ToolkitTestApplication application;
2012   tet_infoline(" utcDaliTextFieldEvent07");
2013
2014   // Checks Longpress to start edit mode
2015
2016   TextField field = TextField::New();
2017   DALI_TEST_CHECK( field );
2018   Stage::GetCurrent().Add( field );
2019   LoadMarkerImages(application, field);
2020   // Render and notify
2021   application.SendNotification();
2022   application.Render();
2023
2024   field.SetProperty( TextField::Property::TEXT, "Thisisalongtextforthesizeofthetextfield." );
2025   field.SetProperty( TextField::Property::POINT_SIZE, 10.f );
2026   field.SetSize( 300.f, 50.f );
2027   field.SetParentOrigin( ParentOrigin::TOP_LEFT );
2028   field.SetAnchorPoint( AnchorPoint::TOP_LEFT );
2029   Property::Map propertyMap;
2030   propertyMap["PANEL_LAYOUT"] = InputMethod::PanelLayout::PASSWORD;
2031   field.SetProperty( TextField::Property::INPUT_METHOD_SETTINGS, propertyMap );
2032
2033   // Avoid a crash when core load gl resources.
2034   application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
2035   // Render and notify
2036   application.SendNotification();
2037   application.Render();
2038
2039   // Long Press
2040   application.ProcessEvent( GenerateLongPress( Gesture::Possible, 1u, Vector2( 1.f, 25.0f ) ) );
2041   application.ProcessEvent( GenerateLongPress( Gesture::Started,  1u, Vector2( 1.f, 25.0f ) ) );
2042
2043   // Render and notify
2044   application.SendNotification();
2045   application.Render();
2046
2047   END_TEST;
2048 }
2049
2050 int utcDaliTextFieldEvent08(void)
2051 {
2052   ToolkitTestApplication application;
2053   tet_infoline(" utcDaliTextFieldEvent08");
2054
2055   Dali::Clipboard clipboard = Clipboard::Get();
2056   clipboard.SetItem("testTextFieldEvent");
2057
2058   // Checks Longpress when only place holder text
2059
2060   TextField field = TextField::New();
2061   DALI_TEST_CHECK( field );
2062   Stage::GetCurrent().Add( field );
2063   LoadMarkerImages(application, field);
2064   // Render and notify
2065   application.SendNotification();
2066   application.Render();
2067
2068   field.SetProperty( TextField::Property::PLACEHOLDER_TEXT, "Setting Placeholder Text" );
2069   field.SetProperty( TextField::Property::POINT_SIZE, 10.f );
2070   field.SetSize( 300.f, 50.f );
2071   field.SetParentOrigin( ParentOrigin::TOP_LEFT );
2072   field.SetAnchorPoint( AnchorPoint::TOP_LEFT );
2073
2074   // Avoid a crash when core load gl resources.
2075   application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
2076   // Render and notify
2077   application.SendNotification();
2078   application.Render();
2079
2080   // Long Press
2081   application.ProcessEvent( GenerateLongPress( Gesture::Possible, 1u, Vector2( 1.f, 25.0f ) ) );
2082   application.ProcessEvent( GenerateLongPress( Gesture::Started,  1u, Vector2( 1.f, 25.0f ) ) );
2083
2084   // Render and notify
2085   application.SendNotification();
2086   application.Render();
2087
2088   Wait(application, 500);
2089
2090   // Long Press
2091   application.ProcessEvent( GenerateLongPress( Gesture::Possible, 1u, Vector2( 1.f, 25.0f ) ) );
2092   application.ProcessEvent( GenerateLongPress( Gesture::Started,  1u, Vector2( 1.f, 25.0f ) ) );
2093
2094   // Render and notify
2095   application.SendNotification();
2096   application.Render();
2097
2098   Wait(application, 500);
2099
2100   Stage stage = Stage::GetCurrent();
2101   Layer layer = stage.GetRootLayer();
2102   Actor actor = layer.FindChildByName("optionPaste");
2103
2104   if (actor)
2105   {
2106     Vector3 worldPosition = actor.GetCurrentWorldPosition();
2107     Vector2 halfStageSize = stage.GetSize() / 2.0f;
2108     Vector2 position(worldPosition.x + halfStageSize.width, worldPosition.y + halfStageSize.height);
2109
2110     Dali::Integration::TouchEvent event;
2111     event = Dali::Integration::TouchEvent();
2112     event.AddPoint( GetPointDownInside( position ) );
2113     application.ProcessEvent( event );
2114
2115     event = Dali::Integration::TouchEvent();
2116     event.AddPoint( GetPointUpInside( position ) );
2117     application.ProcessEvent( event );
2118   }
2119   DALI_TEST_EQUALS( field.GetProperty<std::string>( TextEditor::Property::TEXT ), std::string("testTextFieldEvent"), TEST_LOCATION );
2120
2121   END_TEST;
2122 }
2123
2124 int utcDaliTextFieldEvent09(void)
2125 {
2126   ToolkitTestApplication application;
2127   tet_infoline(" utcDaliTextFieldEvent09");
2128
2129   TextField field = TextField::New();
2130   DALI_TEST_CHECK( field );
2131   Stage::GetCurrent().Add( field );
2132   LoadMarkerImages(application, field);
2133   // Render and notify
2134   application.SendNotification();
2135   application.Render();
2136
2137   field.SetProperty( TextField::Property::TEXT, "Hello" );
2138   field.SetProperty( TextField::Property::POINT_SIZE, 10.f );
2139   field.SetSize( 300.f, 50.f );
2140   field.SetParentOrigin( ParentOrigin::TOP_LEFT );
2141   field.SetAnchorPoint( AnchorPoint::TOP_LEFT );
2142
2143   // Avoid a crash when core load gl resources.
2144   application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
2145
2146   // Create a tap event to touch the text field.
2147   application.ProcessEvent( GenerateTap( Gesture::Possible, 1u, 1u, Vector2( 150.0f, 25.0f ) ) );
2148   application.ProcessEvent( GenerateTap( Gesture::Started, 1u, 1u, Vector2( 150.0f, 25.0f ) ) );
2149   application.SendNotification();
2150   application.Render();
2151
2152   Property::Map map;
2153   map[ HiddenInput::Property::MODE ] = HiddenInput::Mode::HIDE_NONE;
2154   field.SetProperty( DevelTextField::Property::HIDDEN_INPUT_SETTINGS, map );
2155   application.ProcessEvent( GenerateKey( "d", "d", 0, 0, 0, Integration::KeyEvent::Down, DEFAULT_DEVICE_NAME, DevelDevice::Class::NONE, DevelDevice::Subclass::NONE ) );
2156   application.SendNotification();
2157   application.Render();
2158
2159   map[ HiddenInput::Property::MODE ] = HiddenInput::Mode::HIDE_ALL;
2160   map[ HiddenInput::Property::SUBSTITUTE_CHARACTER ] = 0x23;
2161   field.SetProperty( DevelTextField::Property::HIDDEN_INPUT_SETTINGS, map );
2162   application.ProcessEvent( GenerateKey( "d", "d", 0, 0, 0, Integration::KeyEvent::Down, DEFAULT_DEVICE_NAME, DevelDevice::Class::NONE, DevelDevice::Subclass::NONE ) );
2163   application.SendNotification();
2164   application.Render();
2165
2166   map[ HiddenInput::Property::MODE ] = HiddenInput::Mode::HIDE_COUNT;
2167   map[ HiddenInput::Property::SUBSTITUTE_COUNT ] = 2;
2168   field.SetProperty( DevelTextField::Property::HIDDEN_INPUT_SETTINGS, map );
2169   for( unsigned int index = 0u; index < 5u; ++index )
2170   {
2171     application.ProcessEvent( GenerateKey( "d", "d", 0, 0, 0, Integration::KeyEvent::Down, DEFAULT_DEVICE_NAME, DevelDevice::Class::NONE, DevelDevice::Subclass::NONE ) );
2172     application.SendNotification();
2173     application.Render();
2174   }
2175
2176   map[ HiddenInput::Property::MODE ] = HiddenInput::Mode::SHOW_COUNT;
2177   map[ HiddenInput::Property::SUBSTITUTE_COUNT ] = 2;
2178   field.SetProperty( DevelTextField::Property::HIDDEN_INPUT_SETTINGS, map );
2179   for( unsigned int index = 0u; index < 5u; ++index )
2180   {
2181     application.ProcessEvent( GenerateKey( "d", "d", 0, 0, 0, Integration::KeyEvent::Down, DEFAULT_DEVICE_NAME, DevelDevice::Class::NONE, DevelDevice::Subclass::NONE ) );
2182     application.SendNotification();
2183     application.Render();
2184   }
2185
2186   map[ HiddenInput::Property::MODE ] = HiddenInput::Mode::SHOW_LAST_CHARACTER;
2187   map[ HiddenInput::Property::SHOW_DURATION ] = 0;
2188   field.SetProperty( DevelTextField::Property::HIDDEN_INPUT_SETTINGS, map );
2189   application.ProcessEvent( GenerateKey( "", "", DALI_KEY_BACKSPACE, 0, 0, Integration::KeyEvent::Down, DEFAULT_DEVICE_NAME, DevelDevice::Class::NONE, DevelDevice::Subclass::NONE ) );
2190   application.SendNotification();
2191   application.Render();
2192   application.ProcessEvent( GenerateKey( "d", "d", 0, 0, 0, Integration::KeyEvent::Down, DEFAULT_DEVICE_NAME, DevelDevice::Class::NONE, DevelDevice::Subclass::NONE ) );
2193   application.SendNotification();
2194   application.Render();
2195
2196   map[ HiddenInput::Property::SHOW_DURATION ] = 100;
2197   field.SetProperty( DevelTextField::Property::HIDDEN_INPUT_SETTINGS, map );
2198   application.ProcessEvent( GenerateKey( "d", "d", 0, 0, 0, Integration::KeyEvent::Down, DEFAULT_DEVICE_NAME, DevelDevice::Class::NONE, DevelDevice::Subclass::NONE ) );
2199   application.SendNotification();
2200   application.Render();
2201
2202   Property::Map mapGet;
2203   mapGet = field.GetProperty<Property::Map>( DevelTextField::Property::HIDDEN_INPUT_SETTINGS );
2204   DALI_TEST_EQUALS( map.Count(), mapGet.Count(), TEST_LOCATION );
2205   DALI_TEST_EQUALS( DaliTestCheckMaps( map, mapGet ), true, TEST_LOCATION );
2206   END_TEST;
2207 }
2208
2209
2210 int utcDaliTextFieldStyleWhilstSelected(void)
2211 {
2212   ToolkitTestApplication application;
2213   tet_infoline(" utcDaliTextFieldStyleWhilstSelected");
2214
2215   // Change font and styles whilst text is selected whilst word selected
2216
2217   TextField field = TextField::New();
2218   DALI_TEST_CHECK( field );
2219   Stage::GetCurrent().Add( field );
2220   LoadMarkerImages(application, field);
2221   // Render and notify
2222   application.SendNotification();
2223   application.Render();
2224
2225   field.SetProperty( TextField::Property::TEXT, "This is a long text for the size of the text-field." );
2226   field.SetProperty( TextField::Property::POINT_SIZE, 10.f );
2227   field.SetSize( 300.f, 50.f );
2228   field.SetParentOrigin( ParentOrigin::TOP_LEFT );
2229   field.SetAnchorPoint( AnchorPoint::TOP_LEFT );
2230
2231   // Avoid a crash when core load gl resources.
2232   application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
2233   // Render and notify
2234   application.SendNotification();
2235   application.Render();
2236
2237   // Create a tap event to touch the text field.
2238   application.ProcessEvent( GenerateTap( Gesture::Possible, 1u, 1u, Vector2( 150.0f, 25.0f ) ) );
2239   application.ProcessEvent( GenerateTap( Gesture::Started, 1u, 1u, Vector2( 150.0f, 25.0f ) ) );
2240   // Render and notify
2241   application.SendNotification();
2242   application.Render();
2243
2244
2245   // Tap first to get the focus.
2246   application.ProcessEvent( GenerateTap( Gesture::Possible, 1u, 1u, Vector2( 1.f, 25.0f ) ) );
2247   application.ProcessEvent( GenerateTap( Gesture::Started, 1u, 1u, Vector2( 1.f, 25.0f ) ) );
2248
2249   // Render and notify
2250   application.SendNotification();
2251   application.Render();
2252
2253   // Double tap to select a word.
2254   application.ProcessEvent( GenerateTap( Gesture::Possible, 2u, 1u, Vector2( 1.f, 25.0f ) ) );
2255   application.ProcessEvent( GenerateTap( Gesture::Started, 2u, 1u, Vector2( 1.f, 25.0f ) ) );
2256
2257   // Render and notify
2258   application.SendNotification();
2259   application.Render();
2260
2261   field.SetProperty( TextField::Property::INPUT_FONT_FAMILY, "Setting input font family" );
2262   DALI_TEST_EQUALS( field.GetProperty<std::string>( TextField::Property::INPUT_FONT_FAMILY ), "Setting input font family", TEST_LOCATION );
2263
2264   Property::Map fontStyleMapSet;
2265   Property::Map fontStyleMapGet;
2266
2267   fontStyleMapSet.Insert( "weight", "bold" );
2268   fontStyleMapSet.Insert( "slant", "italic" );
2269   field.SetProperty( TextField::Property::INPUT_FONT_STYLE, fontStyleMapSet );
2270
2271   fontStyleMapGet = field.GetProperty<Property::Map>( TextField::Property::INPUT_FONT_STYLE );
2272   DALI_TEST_EQUALS( fontStyleMapGet.Count(), fontStyleMapSet.Count(), TEST_LOCATION );
2273   DALI_TEST_EQUALS( DaliTestCheckMaps( fontStyleMapGet, fontStyleMapSet ), true, TEST_LOCATION );
2274
2275   fontStyleMapSet.Clear();
2276   fontStyleMapSet.Insert( "width", "expanded" );
2277   fontStyleMapSet.Insert( "slant", "italic" );
2278   field.SetProperty( TextField::Property::INPUT_FONT_STYLE, fontStyleMapSet );
2279
2280   fontStyleMapGet = field.GetProperty<Property::Map>( TextField::Property::INPUT_FONT_STYLE );
2281   DALI_TEST_EQUALS( fontStyleMapGet.Count(), fontStyleMapSet.Count(), TEST_LOCATION );
2282   DALI_TEST_EQUALS( DaliTestCheckMaps( fontStyleMapGet, fontStyleMapSet ), true, TEST_LOCATION );
2283
2284   field.SetProperty( TextField::Property::INPUT_POINT_SIZE, 12.f );
2285   DALI_TEST_EQUALS( field.GetProperty<float>( TextField::Property::INPUT_POINT_SIZE ), 12.f, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
2286
2287   field.SetProperty( TextField::Property::TEXT_COLOR, Color::RED );
2288   DALI_TEST_EQUALS( field.GetProperty<Vector4>( TextField::Property::TEXT_COLOR ), Color::RED, TEST_LOCATION );
2289
2290   fontStyleMapSet.Clear();
2291   fontStyleMapSet.Insert( "weight", "bold" );
2292   fontStyleMapSet.Insert( "slant", "italic" );
2293
2294   field.SetProperty( TextField::Property::FONT_STYLE, fontStyleMapSet );
2295
2296   fontStyleMapGet = field.GetProperty<Property::Map>( TextField::Property::FONT_STYLE );
2297   DALI_TEST_EQUALS( fontStyleMapGet.Count(), fontStyleMapSet.Count(), TEST_LOCATION );
2298   DALI_TEST_EQUALS( DaliTestCheckMaps( fontStyleMapGet, fontStyleMapSet ), true, TEST_LOCATION );
2299
2300   fontStyleMapSet.Clear();
2301   fontStyleMapSet.Insert( "width", "expanded" );
2302
2303   field.SetProperty( TextField::Property::FONT_STYLE, fontStyleMapSet );
2304
2305   fontStyleMapGet = field.GetProperty<Property::Map>( TextField::Property::FONT_STYLE );
2306   DALI_TEST_EQUALS( fontStyleMapGet.Count(), fontStyleMapSet.Count(), TEST_LOCATION );
2307   DALI_TEST_EQUALS( DaliTestCheckMaps( fontStyleMapGet, fontStyleMapSet ), true, TEST_LOCATION );
2308
2309   // Press Escape to increase coverage
2310   application.ProcessEvent( GenerateKey( "", "", DALI_KEY_ESCAPE, 0, 0, Integration::KeyEvent::Up, DEFAULT_DEVICE_NAME, DevelDevice::Class::NONE, DevelDevice::Subclass::NONE ) );
2311   application.SendNotification();
2312   application.Render();
2313
2314   DALI_TEST_CHECK( !field.HasKeyInputFocus() );
2315
2316   END_TEST;
2317 }
2318
2319 int utcDaliTextFieldEscKeyLoseFocus(void)
2320 {
2321   ToolkitTestApplication application;
2322   tet_infoline(" utcDaliTextFieldEscKeyLoseFocus");
2323
2324   // Creates a tap event. After creating a tap event the text field should
2325   // have the focus and add text with key events should be possible.
2326
2327   TextField field = TextField::New();
2328   DALI_TEST_CHECK( field );
2329
2330   Stage::GetCurrent().Add( field );
2331
2332   field.SetSize( 300.f, 50.f );
2333   field.SetParentOrigin( ParentOrigin::TOP_LEFT );
2334   field.SetAnchorPoint( AnchorPoint::TOP_LEFT );
2335
2336   // Avoid a crash when core load gl resources.
2337   application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
2338
2339   // Render and notify
2340   application.SendNotification();
2341   application.Render();
2342
2343   // Add a key event but as the text field has not the focus it should do nothing.
2344   application.ProcessEvent( GenerateKey( "a", "a", KEY_A_CODE, 0, 0, Integration::KeyEvent::Down, DEFAULT_DEVICE_NAME, DevelDevice::Class::NONE, DevelDevice::Subclass::NONE ) );
2345   application.ProcessEvent( GenerateKey( "a", "a", KEY_A_CODE, 0, 0, Integration::KeyEvent::Up, DEFAULT_DEVICE_NAME, DevelDevice::Class::NONE, DevelDevice::Subclass::NONE ) );
2346
2347   // Render and notify
2348   application.SendNotification();
2349   application.Render();
2350
2351   DALI_TEST_EQUALS( field.GetProperty<std::string>( TextField::Property::TEXT ), std::string(""), TEST_LOCATION );
2352
2353   // Create a tap event to touch the text field.
2354   application.ProcessEvent( GenerateTap( Gesture::Possible, 1u, 1u, Vector2( 150.0f, 25.0f ) ) );
2355   application.ProcessEvent( GenerateTap( Gesture::Started, 1u, 1u, Vector2( 150.0f, 25.0f ) ) );
2356
2357   // Render and notify
2358   application.SendNotification();
2359   application.Render();
2360
2361   // Now the text field has the focus, so it can handle the key events.
2362   application.ProcessEvent( GenerateKey( "a", "a", KEY_A_CODE, 0, 0, Integration::KeyEvent::Down, DEFAULT_DEVICE_NAME, DevelDevice::Class::NONE, DevelDevice::Subclass::NONE ) );
2363   application.ProcessEvent( GenerateKey( "a", "a", KEY_A_CODE, 0, 0, Integration::KeyEvent::Up, DEFAULT_DEVICE_NAME, DevelDevice::Class::NONE, DevelDevice::Subclass::NONE ) );
2364   application.ProcessEvent( GenerateKey( "d", "d", KEY_D_CODE, 0, 0, Integration::KeyEvent::Down, DEFAULT_DEVICE_NAME, DevelDevice::Class::NONE, DevelDevice::Subclass::NONE ) );
2365   application.ProcessEvent( GenerateKey( "d", "d", KEY_D_CODE, 0, 0, Integration::KeyEvent::Up, DEFAULT_DEVICE_NAME, DevelDevice::Class::NONE, DevelDevice::Subclass::NONE ) );
2366
2367   // Render and notify
2368   application.SendNotification();
2369   application.Render();
2370
2371   DALI_TEST_EQUALS( field.GetProperty<std::string>( TextField::Property::TEXT ), std::string("ad"), TEST_LOCATION );
2372
2373   // Generate a Esc key event. The text field should lose the focus.
2374   application.ProcessEvent( GenerateKey( "", "", DALI_KEY_ESCAPE, 0, 0, Integration::KeyEvent::Down, DEFAULT_DEVICE_NAME, DevelDevice::Class::NONE, DevelDevice::Subclass::NONE ) );
2375   application.ProcessEvent( GenerateKey( "", "", DALI_KEY_ESCAPE, 0, 0, Integration::KeyEvent::Up, DEFAULT_DEVICE_NAME, DevelDevice::Class::NONE, DevelDevice::Subclass::NONE ) );
2376
2377   // Render and notify
2378   application.SendNotification();
2379   application.Render();
2380
2381   DALI_TEST_EQUALS( false, field.HasKeyInputFocus(), TEST_LOCATION );
2382
2383   // No more text should be introduced
2384   application.ProcessEvent( GenerateKey( "a", "a", KEY_A_CODE, 0, 0, Integration::KeyEvent::Down, DEFAULT_DEVICE_NAME, DevelDevice::Class::NONE, DevelDevice::Subclass::NONE ) );
2385   application.ProcessEvent( GenerateKey( "a", "a", KEY_A_CODE, 0, 0, Integration::KeyEvent::Up, DEFAULT_DEVICE_NAME, DevelDevice::Class::NONE, DevelDevice::Subclass::NONE ) );
2386
2387   // Render and notify
2388   application.SendNotification();
2389   application.Render();
2390
2391   DALI_TEST_EQUALS( field.GetProperty<std::string>( TextField::Property::TEXT ), std::string("ad"), TEST_LOCATION );
2392
2393   END_TEST;
2394 }
2395
2396 int utcDaliTextFieldSomeSpecialKeys(void)
2397 {
2398   ToolkitTestApplication application;
2399   tet_infoline(" utcDaliTextFieldSomeSpecialKeys");
2400
2401   // Checks some special keys when the text is selected.
2402
2403   TextField field = TextField::New();
2404   DALI_TEST_CHECK( field );
2405   Stage::GetCurrent().Add( field );
2406   LoadMarkerImages(application, field);
2407   // Render and notify
2408   application.SendNotification();
2409   application.Render();
2410
2411   const std::string longText( "This is a long text for the size of the text-field." );
2412
2413   field.SetProperty( TextField::Property::TEXT, longText );
2414   field.SetProperty( TextField::Property::POINT_SIZE, 10.f );
2415   field.SetSize( 300.f, 50.f );
2416   field.SetParentOrigin( ParentOrigin::TOP_LEFT );
2417   field.SetAnchorPoint( AnchorPoint::TOP_LEFT );
2418
2419   // Avoid a crash when core load gl resources.
2420   application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
2421   // Render and notify
2422   application.SendNotification();
2423   application.Render();
2424
2425   // Create a tap event to touch the text field.
2426   application.ProcessEvent( GenerateTap( Gesture::Possible, 1u, 1u, Vector2( 150.0f, 25.0f ) ) );
2427   application.ProcessEvent( GenerateTap( Gesture::Started, 1u, 1u, Vector2( 150.0f, 25.0f ) ) );
2428
2429   // Render and notify
2430   application.SendNotification();
2431   application.Render();
2432
2433   // Tap first to get the focus.
2434   application.ProcessEvent( GenerateTap( Gesture::Possible, 1u, 1u, Vector2( 1.f, 25.0f ) ) );
2435   application.ProcessEvent( GenerateTap( Gesture::Started, 1u, 1u, Vector2( 1.f, 25.0f ) ) );
2436
2437   // Render and notify
2438   application.SendNotification();
2439   application.Render();
2440
2441   // Double tap to select a word.
2442   application.ProcessEvent( GenerateTap( Gesture::Possible, 2u, 1u, Vector2( 1.f, 25.0f ) ) );
2443   application.ProcessEvent( GenerateTap( Gesture::Started, 2u, 1u, Vector2( 1.f, 25.0f ) ) );
2444
2445   // Render and notify
2446   application.SendNotification();
2447   application.Render();
2448
2449   // Generate a Esc key event. The text field should lose the focus.
2450   application.ProcessEvent( GenerateKey( "XF86PowerOff", "XF86PowerOff", DALI_KEY_POWER, 0, 0, Integration::KeyEvent::Down, DEFAULT_DEVICE_NAME, DevelDevice::Class::NONE, DevelDevice::Subclass::NONE ) );
2451   application.ProcessEvent( GenerateKey( "XF86PowerOff", "XF86PowerOff", DALI_KEY_POWER, 0, 0, Integration::KeyEvent::Up, DEFAULT_DEVICE_NAME, DevelDevice::Class::NONE, DevelDevice::Subclass::NONE ) );
2452
2453   // Render and notify
2454   application.SendNotification();
2455   application.Render();
2456
2457   // Generate a Esc key event. The text field should lose the focus.
2458   application.ProcessEvent( GenerateKey( "XF86Menu", "XF86Menu", DALI_KEY_MENU, 0, 0, Integration::KeyEvent::Down, DEFAULT_DEVICE_NAME, DevelDevice::Class::NONE, DevelDevice::Subclass::NONE ) );
2459   application.ProcessEvent( GenerateKey( "XF86Menu", "XF86Menu", DALI_KEY_MENU, 0, 0, Integration::KeyEvent::Up, DEFAULT_DEVICE_NAME, DevelDevice::Class::NONE, DevelDevice::Subclass::NONE ) );
2460
2461   // Render and notify
2462   application.SendNotification();
2463   application.Render();
2464
2465   // Generate a Esc key event. The text field should lose the focus.
2466   application.ProcessEvent( GenerateKey( "XF86Home", "XF86Home", DALI_KEY_HOME, 0, 0, Integration::KeyEvent::Down, DEFAULT_DEVICE_NAME, DevelDevice::Class::NONE, DevelDevice::Subclass::NONE ) );
2467   application.ProcessEvent( GenerateKey( "XF86Home", "XF86Home", DALI_KEY_HOME, 0, 0, Integration::KeyEvent::Up, DEFAULT_DEVICE_NAME, DevelDevice::Class::NONE, DevelDevice::Subclass::NONE ) );
2468
2469   // Render and notify
2470   application.SendNotification();
2471   application.Render();
2472
2473   // The text shouldn't be deleted.
2474   DALI_TEST_EQUALS( field.GetProperty<std::string>( TextField::Property::TEXT ), longText, TEST_LOCATION );
2475
2476   END_TEST;
2477 }
2478
2479 int utcDaliTextFieldSizeUpdate(void)
2480 {
2481   ToolkitTestApplication application;
2482   tet_infoline("utcDaliTextFieldSizeUpdate");
2483
2484   // Checks some special keys when the text is selected.
2485   TextField field = TextField::New();
2486   DALI_TEST_CHECK( field );
2487   Stage::GetCurrent().Add( field );
2488
2489   float previousHeight = 0.0f;
2490   float currentHeight = 0.0f;
2491   const float fieldWidth = 1920.0f;
2492
2493
2494   // "ㅁ" is bigger then "ኢ"
2495   field.SetSize( Vector2( fieldWidth ,10.0f ) );
2496   field.SetResizePolicy( ResizePolicy::FIXED , Dimension::WIDTH );
2497   field.SetResizePolicy( ResizePolicy::DIMENSION_DEPENDENCY , Dimension::HEIGHT );
2498
2499   field.SetProperty( TextField::Property::TEXT, "ኢ");
2500   field.SetParentOrigin( ParentOrigin::TOP_LEFT );
2501   field.SetAnchorPoint( AnchorPoint::TOP_LEFT );
2502
2503   field.SetKeyboardFocusable(true);
2504   KeyboardFocusManager::Get().SetCurrentFocusActor( field );
2505
2506   application.SendNotification();
2507   application.Render();
2508
2509   previousHeight = field.GetHeightForWidth( fieldWidth );
2510   DALI_TEST_EQUALS( previousHeight, field.GetProperty<float>( Actor::Property::SIZE_HEIGHT ) , TEST_LOCATION );
2511
2512   // Add  another script characters ( glyph height is defferent )
2513   application.ProcessEvent( GenerateKey( "ㅁ", "ㅁ", KEY_A_CODE, 0, 0, Integration::KeyEvent::Down, DEFAULT_DEVICE_NAME, DevelDevice::Class::NONE, DevelDevice::Subclass::NONE ) );
2514   application.ProcessEvent( GenerateKey( "ㅁ", "ㅁ", KEY_A_CODE, 0, 0, Integration::KeyEvent::Up, DEFAULT_DEVICE_NAME, DevelDevice::Class::NONE, DevelDevice::Subclass::NONE ) );
2515
2516   application.SendNotification();
2517   application.Render();
2518
2519   currentHeight = field.GetHeightForWidth( fieldWidth );
2520   DALI_TEST_EQUALS( currentHeight, field.GetProperty<float>( Actor::Property::SIZE_HEIGHT ), TEST_LOCATION );
2521   DALI_TEST_EQUALS( (previousHeight < currentHeight), true , TEST_LOCATION );
2522
2523   END_TEST;
2524 }
2525
2526 int utcDaliTextFieldExtremlyLargePointSize(void)
2527 {
2528   ToolkitTestApplication application;
2529   tet_infoline(" utcDaliTextFieldExtremlyLargePointSize");
2530
2531   TextField field = TextField::New();
2532
2533   field.SetProperty( TextField::Property::TEXT, "Text" );
2534   field.SetSize( 300.f, 50.f );
2535   field.SetParentOrigin( ParentOrigin::TOP_LEFT );
2536   field.SetAnchorPoint( AnchorPoint::TOP_LEFT );
2537   Stage::GetCurrent().Add( field );
2538
2539   try
2540   {
2541     field.SetProperty( TextField::Property::POINT_SIZE, 160.0f );
2542     application.SendNotification();
2543     DALI_TEST_CHECK( field );
2544   }
2545   catch (...)
2546   {
2547     tet_result(TET_FAIL);
2548   }
2549   END_TEST;
2550 }
2551
2552 int UtcDaliTextFieldDefaultFontStylePropertyCoverage(void)
2553 {
2554   ToolkitTestApplication application;
2555   tet_infoline("UtcDaliTextFieldFontStylePorpertyCoverage");
2556   TextField field = TextField::New();
2557   DALI_TEST_CHECK( field );
2558   Stage::GetCurrent().Add( field );
2559
2560   Property::Map fontStyleMapGet;
2561
2562   fontStyleMapGet = field.GetProperty<Property::Map>( TextField::Property::FONT_STYLE );
2563
2564   Property::Value* weightValue = NULL;
2565   Property::Value* widthValue = NULL;
2566   Property::Value* slantValue = NULL;
2567   weightValue = fontStyleMapGet.Find( "weight" );
2568   widthValue = fontStyleMapGet.Find( "width" );
2569   slantValue = fontStyleMapGet.Find( "slant" );
2570   DALI_TEST_CHECK( !weightValue );
2571   DALI_TEST_CHECK( !widthValue );
2572   DALI_TEST_CHECK( !slantValue );
2573
2574   END_TEST;
2575 }