00feb2938cad3cdb13041c28dbfe0b65399d7f25
[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 Device::Class::Type& deviceClass = Device::Class::NONE,
313                                    const Device::Subclass::Type& deviceSubclass = Device::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
833   // Test string type first
834   // This is purely to maintain backward compatibility, but we don't support string as the outline property type.
835   field.SetProperty( TextField::Property::OUTLINE, "Outline properties" );
836   DALI_TEST_EQUALS( field.GetProperty<std::string>( TextField::Property::OUTLINE ), std::string("Outline properties"), TEST_LOCATION );
837
838   // Then test the property map type
839   Property::Map outlineMapSet;
840   Property::Map outlineMapGet;
841
842   outlineMapSet["color"] = Color::RED;
843   outlineMapSet["width"] = 2.0f;
844
845   field.SetProperty( TextField::Property::OUTLINE, outlineMapSet );
846
847   outlineMapSet["color"] = "red";
848   outlineMapSet["width"] = "2";
849   outlineMapGet = field.GetProperty<Property::Map>( TextField::Property::OUTLINE );
850   DALI_TEST_EQUALS( outlineMapGet.Count(), outlineMapSet.Count(), TEST_LOCATION );
851   DALI_TEST_EQUALS( DaliTestCheckMaps( outlineMapGet, outlineMapSet ), true, TEST_LOCATION );
852
853   // Check the input outline property
854   field.SetProperty( TextField::Property::INPUT_OUTLINE, "Outline input properties" );
855   DALI_TEST_EQUALS( field.GetProperty<std::string>( TextField::Property::INPUT_OUTLINE ), std::string("Outline input properties"), TEST_LOCATION );
856
857   // Check the hidden input settings property
858   Property::Map hiddenMapSet;
859   Property::Map hiddenMapGet;
860   hiddenMapSet[ HiddenInput::Property::MODE ] = HiddenInput::Mode::HIDE_ALL;
861   hiddenMapSet[ HiddenInput::Property::SHOW_DURATION ] = 2;
862   hiddenMapSet[ HiddenInput::Property::SUBSTITUTE_COUNT ] = 4;
863   hiddenMapSet[ HiddenInput::Property::SUBSTITUTE_CHARACTER ] = 0x23;
864   field.SetProperty( DevelTextField::Property::HIDDEN_INPUT_SETTINGS, hiddenMapSet );
865
866   hiddenMapGet = field.GetProperty<Property::Map>( DevelTextField::Property::HIDDEN_INPUT_SETTINGS );
867   DALI_TEST_EQUALS( hiddenMapSet.Count(), hiddenMapGet.Count(), TEST_LOCATION );
868   DALI_TEST_EQUALS( DaliTestCheckMaps( hiddenMapSet, hiddenMapGet ), true, TEST_LOCATION );
869
870   // Check the pixel size of font
871   field.SetProperty( DevelTextField::Property::PIXEL_SIZE, 20.f );
872   DALI_TEST_EQUALS( field.GetProperty<float>( DevelTextField::Property::PIXEL_SIZE ), 20.f, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
873
874   // Check the enable selection property
875   field.SetProperty( DevelTextField::Property::ENABLE_SELECTION, false );
876   DALI_TEST_EQUALS( field.GetProperty<bool>( DevelTextField::Property::ENABLE_SELECTION ), false, TEST_LOCATION );
877
878   // Check the placeholder property with pixel size
879   Property::Map placeholderPixelSizeMapSet;
880   Property::Map placeholderPixelSizeMapGet;
881   Property::Map placeholderFontstyleMap;
882   placeholderPixelSizeMapSet["placeholderText"] = "Setting Placeholder Text";
883   placeholderPixelSizeMapSet["placeholderTextFocused"] = "Setting Placeholder Text Focused";
884   placeholderPixelSizeMapSet["placeholderColor"] = Color::BLUE;
885   placeholderPixelSizeMapSet["placeholderFontFamily"] = "Arial";
886   placeholderPixelSizeMapSet["placeholderPixelSize"] = 15.0f;
887   placeholderPixelSizeMapSet["placeholderEllipsis"] = true;
888
889   placeholderFontstyleMap.Insert( "weight", "bold" );
890   placeholderPixelSizeMapSet["placeholderFontStyle"] = placeholderFontstyleMap;
891   field.SetProperty( DevelTextField::Property::PLACEHOLDER, placeholderPixelSizeMapSet );
892
893   placeholderPixelSizeMapGet = field.GetProperty<Property::Map>( DevelTextField::Property::PLACEHOLDER );
894   DALI_TEST_EQUALS( placeholderPixelSizeMapGet.Count(), placeholderPixelSizeMapSet.Count(), TEST_LOCATION );
895   DALI_TEST_EQUALS( DaliTestCheckMaps( placeholderPixelSizeMapGet, placeholderPixelSizeMapSet ), true, TEST_LOCATION );
896
897   // Check the placeholder property with point size
898   Property::Map placeholderMapSet;
899   Property::Map placeholderMapGet;
900   placeholderMapSet["placeholderText"] = "Setting Placeholder Text";
901   placeholderMapSet["placeholderTextFocused"] = "Setting Placeholder Text Focused";
902   placeholderMapSet["placeholderColor"] = Color::RED;
903   placeholderMapSet["placeholderFontFamily"] = "Arial";
904   placeholderMapSet["placeholderPointSize"] = 12.0f;
905   placeholderMapSet["placeholderEllipsis"] = false;
906
907   // Check the placeholder font style property
908   placeholderFontstyleMap.Clear();
909
910   placeholderFontstyleMap.Insert( "weight", "bold" );
911   placeholderFontstyleMap.Insert( "width", "condensed" );
912   placeholderFontstyleMap.Insert( "slant", "italic" );
913   placeholderMapSet["placeholderFontStyle"] = placeholderFontstyleMap;
914   field.SetProperty( DevelTextField::Property::PLACEHOLDER, placeholderMapSet );
915
916   placeholderMapGet = field.GetProperty<Property::Map>( DevelTextField::Property::PLACEHOLDER );
917   DALI_TEST_EQUALS( placeholderMapGet.Count(), placeholderMapSet.Count(), TEST_LOCATION );
918   DALI_TEST_EQUALS( DaliTestCheckMaps( placeholderMapGet, placeholderMapSet ), true, TEST_LOCATION );
919
920   // Reset font style.
921   placeholderFontstyleMap.Clear();
922   placeholderFontstyleMap.Insert( "weight", "normal" );
923   placeholderFontstyleMap.Insert( "slant", "oblique" );
924   placeholderMapSet["placeholderFontStyle"] = placeholderFontstyleMap;
925   field.SetProperty( DevelTextField::Property::PLACEHOLDER, placeholderMapSet );
926
927   placeholderMapGet = field.GetProperty<Property::Map>( DevelTextField::Property::PLACEHOLDER );
928   DALI_TEST_EQUALS( placeholderMapGet.Count(), placeholderMapSet.Count(), TEST_LOCATION );
929   DALI_TEST_EQUALS( DaliTestCheckMaps( placeholderMapGet, placeholderMapSet ), true, TEST_LOCATION );
930
931   placeholderFontstyleMap.Clear();
932   placeholderFontstyleMap.Insert( "slant", "roman" );
933   placeholderMapSet["placeholderFontStyle"] = placeholderFontstyleMap;
934   field.SetProperty( DevelTextField::Property::PLACEHOLDER, placeholderMapSet );
935
936   placeholderMapGet = field.GetProperty<Property::Map>( DevelTextField::Property::PLACEHOLDER );
937
938   placeholderFontstyleMap.Clear();
939   placeholderMapSet["placeholderFontStyle"] = placeholderFontstyleMap;
940
941   field.SetProperty( DevelTextField::Property::PLACEHOLDER, placeholderMapSet );
942   placeholderMapGet = field.GetProperty<Property::Map>( DevelTextField::Property::PLACEHOLDER );
943   DALI_TEST_EQUALS( placeholderMapGet.Count(), placeholderMapSet.Count(), TEST_LOCATION );
944   DALI_TEST_EQUALS( DaliTestCheckMaps( placeholderMapGet, placeholderMapSet ), true, TEST_LOCATION );
945
946   // Check the ellipsis property
947   DALI_TEST_CHECK( !field.GetProperty<bool>( DevelTextField::Property::ELLIPSIS ) );
948   field.SetProperty( DevelTextField::Property::ELLIPSIS, true );
949   DALI_TEST_CHECK( field.GetProperty<bool>( DevelTextField::Property::ELLIPSIS ) );
950
951   END_TEST;
952 }
953
954 // Positive Atlas Text Renderer test
955 int utcDaliTextFieldAtlasRenderP(void)
956 {
957   ToolkitTestApplication application;
958   tet_infoline(" UtcDaliToolkitTextFieldAtlasRenderP");
959   StyleManager styleManager = StyleManager::Get();
960   styleManager.ApplyDefaultTheme();
961   TextField field = TextField::New();
962   DALI_TEST_CHECK( field );
963
964   field.SetProperty( TextField::Property::HORIZONTAL_ALIGNMENT, "CENTER" );
965
966   application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
967
968   Stage::GetCurrent().Add( field );
969
970   try
971   {
972     // Render some text with the shared atlas backend
973     field.SetProperty( TextField::Property::RENDERING_BACKEND, Text::RENDERING_SHARED_ATLAS );
974     application.SendNotification();
975     application.Render();
976   }
977   catch( ... )
978   {
979     tet_result(TET_FAIL);
980   }
981   END_TEST;
982 }
983
984 // Positive test for the textChanged signal.
985 int utcDaliTextFieldTextChangedP(void)
986 {
987   ToolkitTestApplication application;
988   tet_infoline(" utcDaliTextFieldTextChangedP");
989   TextField field = TextField::New();
990   DALI_TEST_CHECK( field );
991
992   Stage::GetCurrent().Add( field );
993
994   // connect to the text changed signal.
995   ConnectionTracker* testTracker = new ConnectionTracker();
996   field.TextChangedSignal().Connect(&TestTextChangedCallback);
997   bool textChangedSignal = false;
998   field.ConnectSignal( testTracker, "textChanged",   CallbackFunctor(&textChangedSignal) );
999
1000   gTextChangedCallBackCalled = false;
1001   field.SetProperty( TextField::Property::TEXT, "ABC" );
1002   DALI_TEST_CHECK( gTextChangedCallBackCalled );
1003   DALI_TEST_CHECK( textChangedSignal );
1004
1005   application.SendNotification();
1006
1007   field.SetKeyInputFocus();
1008
1009   gTextChangedCallBackCalled = false;
1010   application.ProcessEvent( GenerateKey( "D", "D", KEY_D_CODE, 0, 0, Integration::KeyEvent::Down, DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
1011   DALI_TEST_CHECK( gTextChangedCallBackCalled );
1012
1013   END_TEST;
1014 }
1015
1016 // Negative test for the textChanged signal.
1017 int utcDaliTextFieldTextChangedN(void)
1018 {
1019   ToolkitTestApplication application;
1020   tet_infoline(" utcDaliTextFieldTextChangedN");
1021   TextField field = TextField::New();
1022   DALI_TEST_CHECK( field );
1023
1024   Stage::GetCurrent().Add( field );
1025
1026   // connect to the text changed signal.
1027   ConnectionTracker* testTracker = new ConnectionTracker();
1028   field.TextChangedSignal().Connect(&TestTextChangedCallback);
1029   bool textChangedSignal = false;
1030   field.ConnectSignal( testTracker, "textChanged",   CallbackFunctor(&textChangedSignal) );
1031
1032   gTextChangedCallBackCalled = false;
1033   field.SetProperty( TextField::Property::PLACEHOLDER_TEXT, "ABC" ); // Setting placeholder, not TEXT
1034   DALI_TEST_CHECK( !gTextChangedCallBackCalled );
1035   DALI_TEST_CHECK( !textChangedSignal );
1036
1037   END_TEST;
1038 }
1039
1040 // Positive test for Max Characters reached signal.
1041 int utcDaliTextFieldMaxCharactersReachedP(void)
1042 {
1043   ToolkitTestApplication application;
1044   tet_infoline(" utcDaliTextFieldMaxCharactersReachedP");
1045   TextField field = TextField::New();
1046   DALI_TEST_CHECK( field );
1047
1048   Stage::GetCurrent().Add( field );
1049
1050   const int maxNumberOfCharacters = 1;
1051   field.SetProperty( TextField::Property::MAX_LENGTH, maxNumberOfCharacters );
1052
1053   field.SetKeyInputFocus();
1054
1055   // connect to the text changed signal.
1056   ConnectionTracker* testTracker = new ConnectionTracker();
1057   field.MaxLengthReachedSignal().Connect(&TestMaxLengthReachedCallback);
1058   bool maxLengthReachedSignal = false;
1059   field.ConnectSignal( testTracker, "maxLengthReached",   CallbackFunctor(&maxLengthReachedSignal) );
1060
1061   gMaxCharactersCallBackCalled = false;
1062
1063   application.ProcessEvent( GenerateKey( "a", "a", KEY_A_CODE, 0, 0, Integration::KeyEvent::Down, DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
1064   application.ProcessEvent( GenerateKey( "a", "a", KEY_A_CODE, 0, 0, Integration::KeyEvent::Down, DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
1065
1066   DALI_TEST_CHECK( gMaxCharactersCallBackCalled );
1067   DALI_TEST_CHECK( maxLengthReachedSignal );
1068
1069   END_TEST;
1070 }
1071
1072 // Negative test for Max Characters reached signal.
1073 int utcDaliTextFieldMaxCharactersReachedN(void)
1074 {
1075   ToolkitTestApplication application;
1076   tet_infoline(" utcDaliTextFieldMaxCharactersReachedN");
1077   TextField field = TextField::New();
1078   DALI_TEST_CHECK( field );
1079
1080   Stage::GetCurrent().Add( field );
1081
1082   const int maxNumberOfCharacters = 3;
1083   field.SetProperty( TextField::Property::MAX_LENGTH, maxNumberOfCharacters );
1084
1085   field.SetKeyInputFocus();
1086
1087   // connect to the text changed signal.
1088   ConnectionTracker* testTracker = new ConnectionTracker();
1089   field.MaxLengthReachedSignal().Connect(&TestMaxLengthReachedCallback);
1090   bool maxLengthReachedSignal = false;
1091   field.ConnectSignal( testTracker, "maxLengthReached",   CallbackFunctor(&maxLengthReachedSignal) );
1092
1093   gMaxCharactersCallBackCalled = false;
1094
1095   application.ProcessEvent( GenerateKey( "a", "a", KEY_A_CODE, 0, 0, Integration::KeyEvent::Down, DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
1096   application.ProcessEvent( GenerateKey( "a", "a", KEY_A_CODE, 0, 0, Integration::KeyEvent::Down, DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
1097
1098   DALI_TEST_CHECK( !gMaxCharactersCallBackCalled );
1099   DALI_TEST_CHECK( !maxLengthReachedSignal );
1100
1101   END_TEST;
1102 }
1103
1104 int utcDaliTextFieldInputStyleChanged01(void)
1105 {
1106   ToolkitTestApplication application;
1107   tet_infoline(" utcDaliTextFieldInputStyleChanged01");
1108
1109   // The text-field emits signals when the input style changes. These changes of style are
1110   // detected during the relayout process (size negotiation), i.e after the cursor has been moved. Signals
1111   // can't be emitted during the size negotiation as the callbacks may update the UI.
1112   // The text-field adds an idle callback to the adaptor to emit the signals after the size negotiation.
1113   // This creates an implementation of the adaptor stub and a queue of idle callbacks.
1114   application.CreateAdaptor();
1115
1116   // Load some fonts.
1117
1118   char* pathNamePtr = get_current_dir_name();
1119   const std::string pathName( pathNamePtr );
1120   free( pathNamePtr );
1121
1122   TextAbstraction::FontClient fontClient = TextAbstraction::FontClient::Get();
1123   fontClient.SetDpi( 93u, 93u );
1124
1125   fontClient.GetFontId( pathName + DEFAULT_FONT_DIR + "/dejavu/DejaVuSerif.ttf", DEFAULT_FONT_SIZE );
1126   fontClient.GetFontId( pathName + DEFAULT_FONT_DIR + "/dejavu/DejaVuSerif-Bold.ttf", DEFAULT_FONT_SIZE );
1127
1128   TextField field = TextField::New();
1129   DALI_TEST_CHECK( field );
1130
1131
1132   field.SetSize( 300.f, 50.f );
1133   field.SetParentOrigin( ParentOrigin::TOP_LEFT );
1134   field.SetAnchorPoint( AnchorPoint::TOP_LEFT );
1135
1136   field.SetProperty( TextField::Property::ENABLE_MARKUP, true );
1137   field.SetProperty( TextField::Property::TEXT, "<font family='DejaVuSerif' size='18'>He<color value='green'>llo</color> <font weight='bold'>world</font> demo</font>" );
1138
1139   // connect to the text changed signal.
1140   ConnectionTracker* testTracker = new ConnectionTracker();
1141   field.InputStyleChangedSignal().Connect( &TestInputStyleChangedCallback );
1142   bool inputStyleChangedSignal = false;
1143   field.ConnectSignal( testTracker, "inputStyleChanged",   CallbackFunctor(&inputStyleChangedSignal) );
1144
1145   Stage::GetCurrent().Add( field );
1146
1147   // Render and notify
1148   application.SendNotification();
1149   application.Render();
1150
1151   // Executes the idle callbacks added by the text control on the change of input style.
1152   application.RunIdles();
1153
1154   gInputStyleChangedCallbackCalled = false;
1155   gInputStyleMask = TextField::InputStyle::NONE;
1156   inputStyleChangedSignal = false;
1157
1158   // Create a tap event to touch the text field.
1159   application.ProcessEvent( GenerateTap( Gesture::Possible, 1u, 1u, Vector2( 18.f, 25.f ) ) );
1160   application.ProcessEvent( GenerateTap( Gesture::Started, 1u, 1u, Vector2( 18.f, 25.f ) ) );
1161
1162   // Render and notify
1163   application.SendNotification();
1164   application.Render();
1165
1166   // Executes the idle callbacks added by the text control on the change of input style.
1167   application.RunIdles();
1168
1169   DALI_TEST_CHECK( gInputStyleChangedCallbackCalled );
1170   if( gInputStyleChangedCallbackCalled )
1171   {
1172     DALI_TEST_EQUALS( static_cast<unsigned int>( gInputStyleMask ), static_cast<unsigned int>( TextField::InputStyle::FONT_FAMILY | TextField::InputStyle::POINT_SIZE ), TEST_LOCATION );
1173
1174     const std::string fontFamily = field.GetProperty( TextField::Property::INPUT_FONT_FAMILY ).Get<std::string>();
1175     DALI_TEST_EQUALS( fontFamily, "DejaVuSerif", TEST_LOCATION );
1176
1177     const float pointSize = field.GetProperty( TextField::Property::INPUT_POINT_SIZE ).Get<float>();
1178     DALI_TEST_EQUALS( pointSize, 18.f, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
1179   }
1180   DALI_TEST_CHECK( inputStyleChangedSignal );
1181
1182   gInputStyleChangedCallbackCalled = false;
1183   gInputStyleMask = TextField::InputStyle::NONE;
1184   inputStyleChangedSignal = false;
1185
1186   // Create a tap event to touch the text field.
1187   application.ProcessEvent( GenerateTap( Gesture::Possible, 1u, 1u, Vector2( 30.f, 25.f ) ) );
1188   application.ProcessEvent( GenerateTap( Gesture::Started, 1u, 1u, Vector2( 30.f, 25.f ) ) );
1189
1190   // Render and notify
1191   application.SendNotification();
1192   application.Render();
1193
1194   // Executes the idle callbacks added by the text control on the change of input style.
1195   application.RunIdles();
1196
1197   DALI_TEST_CHECK( !gInputStyleChangedCallbackCalled );
1198   DALI_TEST_CHECK( !inputStyleChangedSignal );
1199
1200   gInputStyleChangedCallbackCalled = false;
1201   gInputStyleMask = TextField::InputStyle::NONE;
1202   inputStyleChangedSignal = false;
1203
1204   // Create a tap event to touch the text field.
1205   application.ProcessEvent( GenerateTap( Gesture::Possible, 1u, 1u, Vector2( 43.f, 25.f ) ) );
1206   application.ProcessEvent( GenerateTap( Gesture::Started, 1u, 1u, Vector2( 43.f, 25.f ) ) );
1207
1208   // Render and notify
1209   application.SendNotification();
1210   application.Render();
1211
1212   // Executes the idle callbacks added by the text control on the change of input style.
1213   application.RunIdles();
1214
1215   DALI_TEST_CHECK( gInputStyleChangedCallbackCalled );
1216   if( gInputStyleChangedCallbackCalled )
1217   {
1218     DALI_TEST_EQUALS( static_cast<unsigned int>( gInputStyleMask ), static_cast<unsigned int>( TextField::InputStyle::COLOR ), TEST_LOCATION );
1219
1220     const Vector4 color = field.GetProperty( TextField::Property::INPUT_COLOR ).Get<Vector4>();
1221     DALI_TEST_EQUALS( color, Color::GREEN, TEST_LOCATION );
1222   }
1223   DALI_TEST_CHECK( inputStyleChangedSignal );
1224
1225   gInputStyleChangedCallbackCalled = false;
1226   gInputStyleMask = TextField::InputStyle::NONE;
1227   inputStyleChangedSignal = false;
1228
1229   // Create a tap event to touch the text field.
1230   application.ProcessEvent( GenerateTap( Gesture::Possible, 1u, 1u, Vector2( 88.f, 25.f ) ) );
1231   application.ProcessEvent( GenerateTap( Gesture::Started, 1u, 1u, Vector2( 88.f, 25.f ) ) );
1232
1233   // Render and notify
1234   application.SendNotification();
1235   application.Render();
1236
1237   // Executes the idle callbacks added by the text control on the change of input style.
1238   application.RunIdles();
1239
1240   DALI_TEST_CHECK( gInputStyleChangedCallbackCalled );
1241   if( gInputStyleChangedCallbackCalled )
1242   {
1243     DALI_TEST_EQUALS( static_cast<unsigned int>( gInputStyleMask ), static_cast<unsigned int>( TextField::InputStyle::COLOR | TextField::InputStyle::FONT_STYLE ), TEST_LOCATION );
1244
1245     const Vector4 color = field.GetProperty( TextField::Property::INPUT_COLOR ).Get<Vector4>();
1246     DALI_TEST_EQUALS( color, Color::BLACK, TEST_LOCATION );
1247
1248     const Property::Map fontStyleMapGet = field.GetProperty( TextField::Property::INPUT_FONT_STYLE ).Get<Property::Map>();
1249
1250     Property::Map fontStyleMapSet;
1251     fontStyleMapSet.Insert( "weight", "bold" );
1252
1253     DALI_TEST_EQUALS( fontStyleMapGet.Count(), fontStyleMapSet.Count(), TEST_LOCATION );
1254     DALI_TEST_EQUALS( DaliTestCheckMaps( fontStyleMapGet, fontStyleMapSet ), true, TEST_LOCATION );
1255   }
1256   DALI_TEST_CHECK( inputStyleChangedSignal );
1257
1258   gInputStyleChangedCallbackCalled = false;
1259   gInputStyleMask = TextField::InputStyle::NONE;
1260   inputStyleChangedSignal = false;
1261
1262   // Create a tap event to touch the text field.
1263   application.ProcessEvent( GenerateTap( Gesture::Possible, 1u, 1u, Vector2( 115.f, 25.f ) ) );
1264   application.ProcessEvent( GenerateTap( Gesture::Started, 1u, 1u, Vector2( 115.f, 25.f ) ) );
1265
1266   // Render and notify
1267   application.SendNotification();
1268   application.Render();
1269
1270   // Executes the idle callbacks added by the text control on the change of input style.
1271   application.RunIdles();
1272
1273   DALI_TEST_CHECK( !gInputStyleChangedCallbackCalled );
1274   DALI_TEST_CHECK( !inputStyleChangedSignal );
1275
1276   gInputStyleChangedCallbackCalled = false;
1277   gInputStyleMask = TextField::InputStyle::NONE;
1278   inputStyleChangedSignal = false;
1279
1280   // Create a tap event to touch the text field.
1281   application.ProcessEvent( GenerateTap( Gesture::Possible, 1u, 1u, Vector2( 164.f, 25.f ) ) );
1282   application.ProcessEvent( GenerateTap( Gesture::Started, 1u, 1u, Vector2( 164.f, 25.f ) ) );
1283
1284   // Render and notify
1285   application.SendNotification();
1286   application.Render();
1287
1288   // Executes the idle callbacks added by the text control on the change of input style.
1289   application.RunIdles();
1290
1291   DALI_TEST_CHECK( gInputStyleChangedCallbackCalled );
1292   if( gInputStyleChangedCallbackCalled )
1293   {
1294     DALI_TEST_EQUALS( static_cast<unsigned int>( gInputStyleMask ), static_cast<unsigned int>( TextField::InputStyle::FONT_STYLE ), TEST_LOCATION );
1295
1296     const std::string style = field.GetProperty( TextField::Property::INPUT_FONT_STYLE ).Get<std::string>();
1297     DALI_TEST_CHECK( style.empty() );
1298   }
1299   DALI_TEST_CHECK( inputStyleChangedSignal );
1300
1301   gInputStyleChangedCallbackCalled = false;
1302   gInputStyleMask = TextField::InputStyle::NONE;
1303   inputStyleChangedSignal = false;
1304
1305   // Create a tap event to touch the text field.
1306   application.ProcessEvent( GenerateTap( Gesture::Possible, 1u, 1u, Vector2( 191.f, 25.f ) ) );
1307   application.ProcessEvent( GenerateTap( Gesture::Started, 1u, 1u, Vector2( 191.f, 25.f ) ) );
1308
1309   // Render and notify
1310   application.SendNotification();
1311   application.Render();
1312
1313   // Executes the idle callbacks added by the text control on the change of input style.
1314   application.RunIdles();
1315
1316   DALI_TEST_CHECK( !gInputStyleChangedCallbackCalled );
1317   DALI_TEST_CHECK( !inputStyleChangedSignal );
1318
1319   END_TEST;
1320 }
1321
1322 int utcDaliTextFieldInputStyleChanged02(void)
1323 {
1324   ToolkitTestApplication application;
1325   tet_infoline(" utcDaliTextFieldInputStyleChanged02");
1326
1327   // The text-field emits signals when the input style changes. These changes of style are
1328   // detected during the relayout process (size negotiation), i.e after the cursor has been moved. Signals
1329   // can't be emitted during the size negotiation as the callbacks may update the UI.
1330   // The text-field adds an idle callback to the adaptor to emit the signals after the size negotiation.
1331   // This creates an implementation of the adaptor stub and a queue of idle callbacks.
1332   application.CreateAdaptor();
1333
1334   // Load some fonts.
1335
1336   char* pathNamePtr = get_current_dir_name();
1337   const std::string pathName( pathNamePtr );
1338   free( pathNamePtr );
1339
1340   TextAbstraction::FontClient fontClient = TextAbstraction::FontClient::Get();
1341   fontClient.SetDpi( 93u, 93u );
1342
1343   fontClient.GetFontId( pathName + DEFAULT_FONT_DIR + "/dejavu/DejaVuSerif.ttf", DEFAULT_FONT_SIZE );
1344   fontClient.GetFontId( pathName + DEFAULT_FONT_DIR + "/dejavu/DejaVuSerif-Bold.ttf", DEFAULT_FONT_SIZE );
1345
1346   TextField field = TextField::New();
1347   DALI_TEST_CHECK( field );
1348
1349
1350   field.SetSize( 300.f, 50.f );
1351   field.SetParentOrigin( ParentOrigin::TOP_LEFT );
1352   field.SetAnchorPoint( AnchorPoint::TOP_LEFT );
1353
1354   field.SetProperty( TextField::Property::ENABLE_MARKUP, true );
1355   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>" );
1356
1357   // connect to the text changed signal.
1358   ConnectionTracker* testTracker = new ConnectionTracker();
1359   field.InputStyleChangedSignal().Connect( &TestInputStyleChangedCallback );
1360   bool inputStyleChangedSignal = false;
1361   field.ConnectSignal( testTracker, "inputStyleChanged",   CallbackFunctor(&inputStyleChangedSignal) );
1362
1363   Stage::GetCurrent().Add( field );
1364
1365   // Render and notify
1366   application.SendNotification();
1367   application.Render();
1368
1369   // Executes the idle callbacks added by the text control on the change of input style.
1370   application.RunIdles();
1371
1372   gInputStyleChangedCallbackCalled = false;
1373   gInputStyleMask = TextField::InputStyle::NONE;
1374   inputStyleChangedSignal = false;
1375
1376   // Create a tap event to touch the text field.
1377   application.ProcessEvent( GenerateTap( Gesture::Possible, 1u, 1u, Vector2( 53.f, 25.f ) ) );
1378   application.ProcessEvent( GenerateTap( Gesture::Started, 1u, 1u, Vector2( 53.f, 25.f ) ) );
1379   application.ProcessEvent( GenerateTap( Gesture::Possible, 2u, 1u, Vector2( 53.f, 25.f ) ) );
1380   application.ProcessEvent( GenerateTap( Gesture::Started, 2u, 1u, Vector2( 53.f, 25.f ) ) );
1381
1382   // Render and notify
1383   application.SendNotification();
1384   application.Render();
1385
1386   // Executes the idle callbacks added by the text control on the change of input style.
1387   application.RunIdles();
1388
1389   DALI_TEST_CHECK( gInputStyleChangedCallbackCalled );
1390   if( gInputStyleChangedCallbackCalled )
1391   {
1392     DALI_TEST_EQUALS( static_cast<unsigned int>( gInputStyleMask ),
1393                       static_cast<unsigned int>( TextField::InputStyle::FONT_FAMILY |
1394                                                  TextField::InputStyle::POINT_SIZE  |
1395                                                  TextField::InputStyle::COLOR ),
1396                       TEST_LOCATION );
1397
1398     const Vector4 color = field.GetProperty( TextField::Property::INPUT_COLOR ).Get<Vector4>();
1399     DALI_TEST_EQUALS( color, Color::GREEN, TEST_LOCATION );
1400
1401     const std::string fontFamily = field.GetProperty( TextField::Property::INPUT_FONT_FAMILY ).Get<std::string>();
1402     DALI_TEST_EQUALS( fontFamily, "DejaVuSerif", TEST_LOCATION );
1403
1404     const float pointSize = field.GetProperty( TextField::Property::INPUT_POINT_SIZE ).Get<float>();
1405     DALI_TEST_EQUALS( pointSize, 18.f, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
1406   }
1407   DALI_TEST_CHECK( inputStyleChangedSignal );
1408
1409   gInputStyleChangedCallbackCalled = false;
1410   gInputStyleMask = TextField::InputStyle::NONE;
1411   inputStyleChangedSignal = false;
1412
1413   application.ProcessEvent( GenerateKey( "", "", DALI_KEY_BACKSPACE, 0, 0, Integration::KeyEvent::Down, DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
1414
1415   // Render and notify
1416   application.SendNotification();
1417   application.Render();
1418
1419   // Executes the idle callbacks added by the text control on the change of input style.
1420   application.RunIdles();
1421
1422   DALI_TEST_CHECK( gInputStyleChangedCallbackCalled );
1423   if( gInputStyleChangedCallbackCalled )
1424   {
1425     DALI_TEST_EQUALS( static_cast<unsigned int>( gInputStyleMask ),
1426                       static_cast<unsigned int>( TextField::InputStyle::COLOR ),
1427                       TEST_LOCATION );
1428
1429     const Vector4 color = field.GetProperty( TextField::Property::INPUT_COLOR ).Get<Vector4>();
1430     DALI_TEST_EQUALS( color, Color::BLUE, TEST_LOCATION );
1431   }
1432   DALI_TEST_CHECK( inputStyleChangedSignal );
1433
1434   gInputStyleChangedCallbackCalled = false;
1435   gInputStyleMask = TextField::InputStyle::NONE;
1436   inputStyleChangedSignal = false;
1437
1438   application.ProcessEvent( GenerateKey( "", "", DALI_KEY_BACKSPACE, 0, 0, Integration::KeyEvent::Down, DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
1439
1440   // Render and notify
1441   application.SendNotification();
1442   application.Render();
1443
1444   // Executes the idle callbacks added by the text control on the change of input style.
1445   application.RunIdles();
1446
1447   DALI_TEST_CHECK( !gInputStyleChangedCallbackCalled );
1448   DALI_TEST_CHECK( !inputStyleChangedSignal );
1449
1450   gInputStyleChangedCallbackCalled = false;
1451   gInputStyleMask = TextField::InputStyle::NONE;
1452   inputStyleChangedSignal = false;
1453
1454   application.ProcessEvent( GenerateKey( "", "", DALI_KEY_BACKSPACE, 0, 0, Integration::KeyEvent::Down, DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
1455
1456   // Render and notify
1457   application.SendNotification();
1458   application.Render();
1459
1460   // Executes the idle callbacks added by the text control on the change of input style.
1461   application.RunIdles();
1462
1463   DALI_TEST_CHECK( gInputStyleChangedCallbackCalled );
1464   if( gInputStyleChangedCallbackCalled )
1465   {
1466     DALI_TEST_EQUALS( static_cast<unsigned int>( gInputStyleMask ),
1467                       static_cast<unsigned int>( TextField::InputStyle::COLOR ),
1468                       TEST_LOCATION );
1469
1470     const Vector4 color = field.GetProperty( TextField::Property::INPUT_COLOR ).Get<Vector4>();
1471     DALI_TEST_EQUALS( color, Color::BLACK, TEST_LOCATION );
1472   }
1473   DALI_TEST_CHECK( inputStyleChangedSignal );
1474
1475   gInputStyleChangedCallbackCalled = false;
1476   gInputStyleMask = TextField::InputStyle::NONE;
1477   inputStyleChangedSignal = false;
1478
1479   field.SetProperty( TextField::Property::INPUT_COLOR, Color::YELLOW );
1480
1481   Property::Map fontStyleMapSet;
1482   fontStyleMapSet.Insert( "weight", "thin" );
1483   fontStyleMapSet.Insert( "width", "condensed" );
1484   fontStyleMapSet.Insert( "slant", "italic" );
1485
1486   field.SetProperty( TextField::Property::INPUT_FONT_STYLE, fontStyleMapSet );
1487   field.SetProperty( TextField::Property::INPUT_POINT_SIZE, 20.f );
1488
1489   field.SetProperty( TextField::Property::INPUT_UNDERLINE, "underline" );
1490   field.SetProperty( TextField::Property::INPUT_SHADOW, "shadow" );
1491   field.SetProperty( TextField::Property::INPUT_EMBOSS, "emboss" );
1492   field.SetProperty( TextField::Property::INPUT_OUTLINE, "outline" );
1493
1494   // Render and notify
1495   application.SendNotification();
1496   application.Render();
1497
1498   // Executes the idle callbacks added by the text control on the change of input style.
1499   application.RunIdles();
1500
1501   DALI_TEST_CHECK( !gInputStyleChangedCallbackCalled );
1502   DALI_TEST_CHECK( !inputStyleChangedSignal );
1503
1504   // Create a tap event to touch the text field.
1505   application.ProcessEvent( GenerateTap( Gesture::Possible, 1u, 1u, Vector2( 63.f, 25.f ) ) );
1506   application.ProcessEvent( GenerateTap( Gesture::Started, 1u, 1u, Vector2( 63.f, 25.f ) ) );
1507
1508   // Render and notify
1509   application.SendNotification();
1510   application.Render();
1511
1512   // Executes the idle callbacks added by the text control on the change of input style.
1513   application.RunIdles();
1514
1515   DALI_TEST_CHECK( gInputStyleChangedCallbackCalled );
1516   if( gInputStyleChangedCallbackCalled )
1517   {
1518     DALI_TEST_EQUALS( static_cast<unsigned int>( gInputStyleMask ),
1519                       static_cast<unsigned int>( TextField::InputStyle::COLOR |
1520                                                  TextField::InputStyle::POINT_SIZE |
1521                                                  TextField::InputStyle::FONT_STYLE |
1522                                                  TextField::InputStyle::UNDERLINE |
1523                                                  TextField::InputStyle::SHADOW |
1524                                                  TextField::InputStyle::EMBOSS |
1525                                                  TextField::InputStyle::OUTLINE ),
1526                       TEST_LOCATION );
1527
1528     const Vector4 color = field.GetProperty( TextField::Property::INPUT_COLOR ).Get<Vector4>();
1529     DALI_TEST_EQUALS( color, Color::BLACK, TEST_LOCATION );
1530   }
1531   DALI_TEST_CHECK( inputStyleChangedSignal );
1532
1533   END_TEST;
1534 }
1535
1536 int utcDaliTextFieldEvent01(void)
1537 {
1538   ToolkitTestApplication application;
1539   tet_infoline(" utcDaliTextFieldEvent01");
1540
1541   // Creates a tap event. After creating a tap event the text field should
1542   // have the focus and add text with key events should be possible.
1543
1544   TextField field = TextField::New();
1545   DALI_TEST_CHECK( field );
1546
1547   Stage::GetCurrent().Add( field );
1548
1549   field.SetSize( 300.f, 50.f );
1550   field.SetParentOrigin( ParentOrigin::TOP_LEFT );
1551   field.SetAnchorPoint( AnchorPoint::TOP_LEFT );
1552
1553   // Avoid a crash when core load gl resources.
1554   application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
1555
1556   // Render and notify
1557   application.SendNotification();
1558   application.Render();
1559
1560   // Add a key event but as the text field has not the focus it should do nothing.
1561   application.ProcessEvent( GenerateKey( "a", "a", KEY_A_CODE, 0, 0, Integration::KeyEvent::Down, DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
1562
1563   // Render and notify
1564   application.SendNotification();
1565   application.Render();
1566
1567   DALI_TEST_EQUALS( field.GetProperty<std::string>( TextField::Property::TEXT ), std::string(""), TEST_LOCATION );
1568
1569   // Create a tap event to touch the text field.
1570   application.ProcessEvent( GenerateTap( Gesture::Possible, 1u, 1u, Vector2( 150.0f, 25.0f ) ) );
1571   application.ProcessEvent( GenerateTap( Gesture::Started, 1u, 1u, Vector2( 150.0f, 25.0f ) ) );
1572
1573   // Render and notify
1574   application.SendNotification();
1575   application.Render();
1576
1577   // Now the text field has the focus, so it can handle the key events.
1578   application.ProcessEvent( GenerateKey( "a", "a", KEY_A_CODE, 0, 0, Integration::KeyEvent::Down, DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
1579   application.ProcessEvent( GenerateKey( "a", "a", KEY_A_CODE, 0, 0, Integration::KeyEvent::Down, DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
1580
1581   // Render and notify
1582   application.SendNotification();
1583   application.Render();
1584
1585   DALI_TEST_EQUALS( field.GetProperty<std::string>( TextField::Property::TEXT ), std::string("aa"), TEST_LOCATION );
1586
1587   // Create a second text field and send key events to it.
1588   TextField field2 = TextField::New();
1589
1590   field2.SetParentOrigin( ParentOrigin::TOP_LEFT );
1591   field2.SetAnchorPoint( AnchorPoint::TOP_LEFT );
1592   field2.SetSize( 100.f, 100.f );
1593   field2.SetPosition( 100.f, 100.f );
1594
1595   Stage::GetCurrent().Add( field2 );
1596
1597   // Render and notify
1598   application.SendNotification();
1599   application.Render();
1600
1601   // Create a tap event on the second text field.
1602   application.ProcessEvent( GenerateTap( Gesture::Possible, 1u, 1u, Vector2( 150.0f, 125.0f ) ) );
1603   application.ProcessEvent( GenerateTap( Gesture::Started, 1u, 1u, Vector2( 150.0f, 125.0f ) ) );
1604
1605   // Render and notify
1606   application.SendNotification();
1607   application.Render();
1608
1609   // The second text field has the focus. It should handle the key events.
1610   application.ProcessEvent( GenerateKey( "a", "a", KEY_A_CODE, 0, 0, Integration::KeyEvent::Down, DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
1611   application.ProcessEvent( GenerateKey( "a", "a", KEY_A_CODE, 0, 0, Integration::KeyEvent::Down, DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
1612
1613   // Render and notify
1614   application.SendNotification();
1615   application.Render();
1616
1617   // Check the text has been added to the second text field.
1618   DALI_TEST_EQUALS( field2.GetProperty<std::string>( TextField::Property::TEXT ), std::string("aa"), TEST_LOCATION );
1619
1620   END_TEST;
1621 }
1622
1623 int utcDaliTextFieldEvent02(void)
1624 {
1625   ToolkitTestApplication application;
1626   tet_infoline(" utcDaliTextFieldEvent02");
1627
1628   // Checks if the right number of actors are created.
1629
1630   TextField field = TextField::New();
1631   field.SetProperty( TextField::Property::POINT_SIZE, 10.f );
1632   DALI_TEST_CHECK( field );
1633   LoadMarkerImages(application, field);
1634
1635   Stage::GetCurrent().Add( field );
1636
1637   field.SetSize( 300.f, 50.f );
1638   field.SetParentOrigin( ParentOrigin::TOP_LEFT );
1639   field.SetAnchorPoint( AnchorPoint::TOP_LEFT );
1640
1641   // Avoid a crash when core load gl resources.
1642   application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
1643
1644   // Render and notify
1645   application.SendNotification();
1646   application.Render();
1647
1648   // Check there are the expected number of children ( stencil ).
1649   DALI_TEST_EQUALS( field.GetChildCount(), 1u, TEST_LOCATION );
1650
1651   Actor stencil = field.GetChildAt( 0u );
1652   DALI_TEST_EQUALS( stencil.GetChildCount(), 0u, TEST_LOCATION );
1653
1654   // Create a tap event to touch the text field.
1655   application.ProcessEvent( GenerateTap( Gesture::Possible, 1u, 1u, Vector2( 150.0f, 25.0f ) ) );
1656   application.ProcessEvent( GenerateTap( Gesture::Started, 1u, 1u, Vector2( 150.0f, 25.0f ) ) );
1657
1658   // Render and notify
1659   application.SendNotification();
1660   application.Render();
1661
1662   Actor layer = field.GetChildAt( 1u );
1663   DALI_TEST_CHECK( layer.IsLayer() );
1664
1665   DALI_TEST_EQUALS( layer.GetChildCount(), 1u, TEST_LOCATION ); // The cursor.
1666   DALI_TEST_EQUALS( stencil.GetChildCount(), 0u, TEST_LOCATION );
1667
1668   // Now the text field has the focus, so it can handle the key events.
1669   application.ProcessEvent( GenerateKey( "a", "a", KEY_A_CODE, 0, 0, Integration::KeyEvent::Down, DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
1670   application.ProcessEvent( GenerateKey( "a", "a", KEY_A_CODE, 0, 0, Integration::KeyEvent::Down, DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
1671
1672   // Render and notify
1673   application.SendNotification();
1674   application.Render();
1675
1676   // Checks the cursor and the renderer have been created.
1677   DALI_TEST_EQUALS( layer.GetChildCount(), 1u, TEST_LOCATION ); // The cursor.
1678   DALI_TEST_EQUALS( stencil.GetChildCount(), 1u, TEST_LOCATION ); // The renderer
1679
1680   Control cursor = Control::DownCast( layer.GetChildAt( 0u ) );
1681   DALI_TEST_CHECK( cursor );
1682
1683   // The offscreen root actor has a container with all the actors which contain the text renderers.
1684   Actor container = stencil.GetChildAt( 0u );
1685   for( unsigned int index = 0; index < container.GetChildCount(); ++index )
1686   {
1687     Renderer renderer = container.GetChildAt( index ).GetRendererAt( 0u );
1688     DALI_TEST_CHECK( renderer );
1689   }
1690
1691   // Move the cursor and check the position changes.
1692   Vector3 position1 = cursor.GetCurrentPosition();
1693
1694   application.ProcessEvent( GenerateKey( "", "", DALI_KEY_CURSOR_LEFT, 0, 0, Integration::KeyEvent::Down, DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
1695   application.ProcessEvent( GenerateKey( "", "", DALI_KEY_CURSOR_LEFT, 0, 0, Integration::KeyEvent::Down, DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
1696
1697   // Render and notify
1698   application.SendNotification();
1699   application.Render();
1700
1701   Vector3 position2 = cursor.GetCurrentPosition();
1702
1703   DALI_TEST_CHECK( position2.x < position1.x );
1704
1705   application.ProcessEvent( GenerateKey( "", "", DALI_KEY_CURSOR_RIGHT, 0, 0, Integration::KeyEvent::Down, DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
1706   application.ProcessEvent( GenerateKey( "", "", DALI_KEY_CURSOR_RIGHT, 0, 0, Integration::KeyEvent::Down, DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
1707
1708   // Render and notify
1709   application.SendNotification();
1710   application.Render();
1711
1712   Vector3 position3 = cursor.GetCurrentPosition();
1713
1714   DALI_TEST_EQUALS( position1, position3, TEST_LOCATION ); // Should be in the same position1.
1715
1716   // Send some taps and check the cursor positions.
1717
1718   // Try to tap at the beginning.
1719   application.ProcessEvent( GenerateTap( Gesture::Possible, 1u, 1u, Vector2( 1.f, 25.0f ) ) );
1720   application.ProcessEvent( GenerateTap( Gesture::Started, 1u, 1u, Vector2( 1.f, 25.0f ) ) );
1721
1722   // Render and notify
1723   application.SendNotification();
1724   application.Render();
1725
1726   // Cursor position should be the same than position1.
1727   Vector3 position4 = cursor.GetCurrentPosition();
1728
1729   DALI_TEST_EQUALS( position2, position4, TEST_LOCATION ); // Should be in the same position2.
1730
1731   // Tap away from the start position.
1732   application.ProcessEvent( GenerateTap( Gesture::Possible, 1u, 1u, Vector2( 16.f, 25.0f ) ) );
1733   application.ProcessEvent( GenerateTap( Gesture::Started, 1u, 1u, Vector2( 16.0f, 25.0f ) ) );
1734
1735   // Render and notify
1736   application.SendNotification();
1737   application.Render();
1738
1739   Vector3 position5 = cursor.GetCurrentPosition();
1740
1741   DALI_TEST_CHECK( position5.x > position4.x );
1742
1743   // Remove all the text.
1744   application.ProcessEvent( GenerateKey( "", "", DALI_KEY_BACKSPACE, 0, 0, Integration::KeyEvent::Down, DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
1745   application.ProcessEvent( GenerateKey( "", "", DALI_KEY_BACKSPACE, 0, 0, Integration::KeyEvent::Down, DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
1746   field.SetProperty( TextField::Property::TEXT, "" );
1747
1748   // Render and notify
1749   application.SendNotification();
1750   application.Render();
1751
1752   // Cursor position should be the same than position2.
1753   Vector3 position6 = cursor.GetCurrentPosition();
1754
1755   DALI_TEST_EQUALS( position2, position6, TEST_LOCATION );// Should be in the same position2.
1756
1757   // Should not be a renderer.
1758   DALI_TEST_EQUALS( stencil.GetChildCount(), 0u, TEST_LOCATION );
1759
1760   // Chanege exceed policy (EXCEED_POLICY_ORIGINAL doesn't use stencil )
1761   field.SetProperty( TextField::Property::TEXT, "This is a long text for the size of the text-field." );
1762   field.SetProperty( TextField::Property::EXCEED_POLICY, Dali::Toolkit::TextField::EXCEED_POLICY_ORIGINAL );
1763
1764   application.SendNotification();
1765   application.Render();
1766
1767   // There are renderer and decorator layer
1768   DALI_TEST_EQUALS( field.GetChildCount(), 2u, TEST_LOCATION );
1769
1770   END_TEST;
1771 }
1772
1773 int utcDaliTextFieldEvent03(void)
1774 {
1775   ToolkitTestApplication application;
1776   tet_infoline(" utcDaliTextFieldEvent03");
1777
1778   // Checks if the highlight actor is created.
1779
1780   TextField field = TextField::New();
1781   DALI_TEST_CHECK( field );
1782
1783   Stage::GetCurrent().Add( field );
1784
1785   field.SetProperty( TextField::Property::TEXT, "This is a long text for the size of the text-field." );
1786   field.SetProperty( TextField::Property::POINT_SIZE, 10.f );
1787   field.SetSize( 30.f, 50.f );
1788   field.SetParentOrigin( ParentOrigin::TOP_LEFT );
1789   field.SetAnchorPoint( AnchorPoint::TOP_LEFT );
1790
1791   // Avoid a crash when core load gl resources.
1792   application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
1793   LoadMarkerImages(application, field);
1794
1795   // Render and notify
1796   application.SendNotification();
1797   application.Render();
1798
1799   // Tap first to get the focus.
1800   application.ProcessEvent( GenerateTap( Gesture::Possible, 1u, 1u, Vector2( 3.f, 25.0f ) ) );
1801   application.ProcessEvent( GenerateTap( Gesture::Started, 1u, 1u, Vector2( 3.f, 25.0f ) ) );
1802
1803   // Render and notify
1804   application.SendNotification();
1805   application.Render();
1806
1807   // Double tap to select a word.
1808   application.ProcessEvent( GenerateTap( Gesture::Possible, 2u, 1u, Vector2( 3.f, 25.0f ) ) );
1809   application.ProcessEvent( GenerateTap( Gesture::Started, 2u, 1u, Vector2( 3.f, 25.0f ) ) );
1810
1811   // Render and notify
1812   application.SendNotification();
1813   application.Render();
1814
1815   // The offscreen root actor should have two actors: the renderer and the highlight actor.
1816   Actor stencil = field.GetChildAt( 0u );
1817
1818   // The highlight actor is drawn first, so is the first actor in the list
1819   Renderer highlight = stencil.GetChildAt( 0u ).GetRendererAt( 0u );
1820   DALI_TEST_CHECK( highlight );
1821
1822   // The offscreen root actor has a container with all the actors which contain the text renderers.
1823   Actor container = stencil.GetChildAt( 1u );
1824   for( unsigned int index = 0; index < container.GetChildCount(); ++index )
1825   {
1826     Renderer renderer = container.GetChildAt( index ).GetRendererAt( 0u );
1827     DALI_TEST_CHECK( renderer );
1828   }
1829
1830   END_TEST;
1831 }
1832
1833 int utcDaliTextFieldEvent04(void)
1834 {
1835   ToolkitTestApplication application;
1836   tet_infoline(" utcDaliTextFieldEvent04");
1837
1838   // Checks if the highlight actor is created.
1839
1840   TextField field = TextField::New();
1841   DALI_TEST_CHECK( field );
1842   Stage::GetCurrent().Add( field );
1843   LoadMarkerImages(application, field);
1844   // Render and notify
1845   application.SendNotification();
1846   application.Render();
1847
1848   field.SetProperty( TextField::Property::TEXT, "This is a long text for the size of the text-field." );
1849   field.SetProperty( TextField::Property::POINT_SIZE, 10.f );
1850   field.SetSize( 300.f, 50.f );
1851   field.SetParentOrigin( ParentOrigin::TOP_LEFT );
1852   field.SetAnchorPoint( AnchorPoint::TOP_LEFT );
1853
1854   // Avoid a crash when core load gl resources.
1855   application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
1856   // Render and notify
1857   application.SendNotification();
1858   application.Render();
1859
1860   // Create a tap event to touch the text field.
1861   application.ProcessEvent( GenerateTap( Gesture::Possible, 1u, 1u, Vector2( 150.0f, 25.0f ) ) );
1862   application.ProcessEvent( GenerateTap( Gesture::Started, 1u, 1u, Vector2( 150.0f, 25.0f ) ) );
1863   // Render and notify
1864   application.SendNotification();
1865   application.Render();
1866
1867
1868   // Tap first to get the focus.
1869   application.ProcessEvent( GenerateTap( Gesture::Possible, 1u, 1u, Vector2( 1.f, 25.0f ) ) );
1870   application.ProcessEvent( GenerateTap( Gesture::Started, 1u, 1u, Vector2( 1.f, 25.0f ) ) );
1871
1872   // Render and notify
1873   application.SendNotification();
1874   application.Render();
1875
1876   // Double tap to select a word.
1877   application.ProcessEvent( GenerateTap( Gesture::Possible, 2u, 1u, Vector2( 1.f, 25.0f ) ) );
1878   application.ProcessEvent( GenerateTap( Gesture::Started, 2u, 1u, Vector2( 1.f, 25.0f ) ) );
1879
1880   // Render and notify
1881   application.SendNotification();
1882   application.Render();
1883
1884   // Tap grab handle
1885   application.ProcessEvent( GenerateTap( Gesture::Possible, 1u, 1u, Vector2( 0.f, 40.0f ) ) );
1886   application.ProcessEvent( GenerateTap( Gesture::Started, 1u, 1u, Vector2( 0.f, 40.0f ) ) );
1887   END_TEST;
1888 }
1889
1890 int utcDaliTextFieldEvent05(void)
1891 {
1892   ToolkitTestApplication application;
1893   tet_infoline(" utcDaliTextFieldEvent05");
1894
1895   // Checks dragging of cursor/grab handle
1896
1897   TextField field = TextField::New();
1898   DALI_TEST_CHECK( field );
1899   Stage::GetCurrent().Add( field );
1900   LoadMarkerImages(application, field);
1901   // Render and notify
1902   application.SendNotification();
1903   application.Render();
1904
1905   field.SetProperty( TextField::Property::TEXT, "This is a long text for the size of the text-field." );
1906   field.SetProperty( TextField::Property::POINT_SIZE, 10.f );
1907   field.SetSize( 300.f, 50.f );
1908   field.SetParentOrigin( ParentOrigin::TOP_LEFT );
1909   field.SetAnchorPoint( AnchorPoint::TOP_LEFT );
1910
1911   // Avoid a crash when core load gl resources.
1912   application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
1913   // Render and notify
1914   application.SendNotification();
1915   application.Render();
1916
1917   // Create a tap event to touch the text field.
1918   application.ProcessEvent( GenerateTap( Gesture::Possible, 1u, 1u, Vector2( 150.0f, 25.0f ) ) );
1919   application.ProcessEvent( GenerateTap( Gesture::Started, 1u, 1u, Vector2( 150.0f, 25.0f ) ) );
1920   // Render and notify
1921   application.SendNotification();
1922   application.Render();
1923
1924
1925   // Tap first to get the focus.
1926   application.ProcessEvent( GenerateTap( Gesture::Possible, 1u, 1u, Vector2( 1.f, 25.0f ) ) );
1927   application.ProcessEvent( GenerateTap( Gesture::Started, 1u, 1u, Vector2( 1.f, 25.0f ) ) );
1928
1929   // Render and notify
1930   application.SendNotification();
1931   application.Render();
1932
1933   // Double tap to select a word.
1934   application.ProcessEvent( GenerateTap( Gesture::Possible, 2u, 1u, Vector2( 1.f, 25.0f ) ) );
1935   application.ProcessEvent( GenerateTap( Gesture::Started, 2u, 1u, Vector2( 1.f, 25.0f ) ) );
1936
1937   // Render and notify
1938   application.SendNotification();
1939   application.Render();
1940
1941   // drag grab handle right
1942   Vector2 pos(0.0f, 40.0f);
1943   SendPan(application, Gesture::Possible, pos);
1944   SendPan(application, Gesture::Started, pos);
1945   pos.x += 5.0f;
1946   Wait(application, 100);
1947
1948   for(int i = 0;i<20;i++)
1949   {
1950     SendPan(application, Gesture::Continuing, pos);
1951     pos.x += 5.0f;
1952     Wait(application);
1953   }
1954
1955   SendPan(application, Gesture::Finished, pos);
1956   Wait(application, RENDER_FRAME_INTERVAL);
1957
1958   Actor stencil = field.GetChildAt( 1u );
1959   END_TEST;
1960 }
1961
1962 int utcDaliTextFieldEvent06(void)
1963 {
1964   ToolkitTestApplication application;
1965   tet_infoline(" utcDaliTextFieldEvent06");
1966
1967   // Checks Longpress when in edit mode
1968
1969   TextField field = TextField::New();
1970   DALI_TEST_CHECK( field );
1971   Stage::GetCurrent().Add( field );
1972   LoadMarkerImages(application, field);
1973   // Render and notify
1974   application.SendNotification();
1975   application.Render();
1976
1977   field.SetProperty( TextField::Property::TEXT, "Thisisalongtextforthesizeofthetextfield." );
1978   field.SetProperty( TextField::Property::POINT_SIZE, 10.f );
1979   field.SetSize( 300.f, 50.f );
1980   field.SetParentOrigin( ParentOrigin::TOP_LEFT );
1981   field.SetAnchorPoint( AnchorPoint::TOP_LEFT );
1982
1983   // Avoid a crash when core load gl resources.
1984   application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
1985   // Render and notify
1986   application.SendNotification();
1987   application.Render();
1988
1989   // Create a tap event to touch the text field.
1990   application.ProcessEvent( GenerateTap( Gesture::Possible, 1u, 1u, Vector2( 150.0f, 25.0f ) ) );
1991   application.ProcessEvent( GenerateTap( Gesture::Started, 1u, 1u, Vector2( 150.0f, 25.0f ) ) );
1992   // Render and notify
1993   application.SendNotification();
1994   application.Render();
1995
1996
1997   // Tap first to get the focus.
1998   application.ProcessEvent( GenerateTap( Gesture::Possible, 1u, 1u, Vector2( 1.f, 25.0f ) ) );
1999   application.ProcessEvent( GenerateTap( Gesture::Started, 1u, 1u, Vector2( 1.f, 25.0f ) ) );
2000
2001   // Render and notify
2002   application.SendNotification();
2003   application.Render();
2004
2005   // Long Press
2006   application.ProcessEvent( GenerateLongPress( Gesture::Possible, 1u, Vector2( 1.f, 25.0f ) ) );
2007   application.ProcessEvent( GenerateLongPress( Gesture::Started,  1u, Vector2( 1.f, 25.0f ) ) );
2008
2009   // Render and notify
2010   application.SendNotification();
2011   application.Render();
2012
2013   END_TEST;
2014 }
2015
2016 int utcDaliTextFieldEvent07(void)
2017 {
2018   ToolkitTestApplication application;
2019   tet_infoline(" utcDaliTextFieldEvent07");
2020
2021   // Checks Longpress to start edit mode
2022
2023   TextField field = TextField::New();
2024   DALI_TEST_CHECK( field );
2025   Stage::GetCurrent().Add( field );
2026   LoadMarkerImages(application, field);
2027   // Render and notify
2028   application.SendNotification();
2029   application.Render();
2030
2031   field.SetProperty( TextField::Property::TEXT, "Thisisalongtextforthesizeofthetextfield." );
2032   field.SetProperty( TextField::Property::POINT_SIZE, 10.f );
2033   field.SetSize( 300.f, 50.f );
2034   field.SetParentOrigin( ParentOrigin::TOP_LEFT );
2035   field.SetAnchorPoint( AnchorPoint::TOP_LEFT );
2036   Property::Map propertyMap;
2037   propertyMap["PANEL_LAYOUT"] = InputMethod::PanelLayout::PASSWORD;
2038   field.SetProperty( TextField::Property::INPUT_METHOD_SETTINGS, propertyMap );
2039
2040   // Avoid a crash when core load gl resources.
2041   application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
2042   // Render and notify
2043   application.SendNotification();
2044   application.Render();
2045
2046   // Long Press
2047   application.ProcessEvent( GenerateLongPress( Gesture::Possible, 1u, Vector2( 1.f, 25.0f ) ) );
2048   application.ProcessEvent( GenerateLongPress( Gesture::Started,  1u, Vector2( 1.f, 25.0f ) ) );
2049
2050   // Render and notify
2051   application.SendNotification();
2052   application.Render();
2053
2054   END_TEST;
2055 }
2056
2057 int utcDaliTextFieldEvent08(void)
2058 {
2059   ToolkitTestApplication application;
2060   tet_infoline(" utcDaliTextFieldEvent08");
2061
2062   Dali::Clipboard clipboard = Clipboard::Get();
2063   clipboard.SetItem("testTextFieldEvent");
2064
2065   // Checks Longpress when only place holder text
2066
2067   TextField field = TextField::New();
2068   DALI_TEST_CHECK( field );
2069   Stage::GetCurrent().Add( field );
2070   LoadMarkerImages(application, field);
2071   // Render and notify
2072   application.SendNotification();
2073   application.Render();
2074
2075   field.SetProperty( TextField::Property::PLACEHOLDER_TEXT, "Setting Placeholder Text" );
2076   field.SetProperty( TextField::Property::POINT_SIZE, 10.f );
2077   field.SetSize( 300.f, 50.f );
2078   field.SetParentOrigin( ParentOrigin::TOP_LEFT );
2079   field.SetAnchorPoint( AnchorPoint::TOP_LEFT );
2080
2081   // Avoid a crash when core load gl resources.
2082   application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
2083   // Render and notify
2084   application.SendNotification();
2085   application.Render();
2086
2087   // Long Press
2088   application.ProcessEvent( GenerateLongPress( Gesture::Possible, 1u, Vector2( 1.f, 25.0f ) ) );
2089   application.ProcessEvent( GenerateLongPress( Gesture::Started,  1u, Vector2( 1.f, 25.0f ) ) );
2090
2091   // Render and notify
2092   application.SendNotification();
2093   application.Render();
2094
2095   Wait(application, 500);
2096
2097   // Long Press
2098   application.ProcessEvent( GenerateLongPress( Gesture::Possible, 1u, Vector2( 1.f, 25.0f ) ) );
2099   application.ProcessEvent( GenerateLongPress( Gesture::Started,  1u, Vector2( 1.f, 25.0f ) ) );
2100
2101   // Render and notify
2102   application.SendNotification();
2103   application.Render();
2104
2105   Wait(application, 500);
2106
2107   Stage stage = Stage::GetCurrent();
2108   Layer layer = stage.GetRootLayer();
2109   Actor actor = layer.FindChildByName("optionPaste");
2110
2111   if (actor)
2112   {
2113     Vector3 worldPosition = actor.GetCurrentWorldPosition();
2114     Vector2 halfStageSize = stage.GetSize() / 2.0f;
2115     Vector2 position(worldPosition.x + halfStageSize.width, worldPosition.y + halfStageSize.height);
2116
2117     Dali::Integration::TouchEvent event;
2118     event = Dali::Integration::TouchEvent();
2119     event.AddPoint( GetPointDownInside( position ) );
2120     application.ProcessEvent( event );
2121
2122     event = Dali::Integration::TouchEvent();
2123     event.AddPoint( GetPointUpInside( position ) );
2124     application.ProcessEvent( event );
2125   }
2126   DALI_TEST_EQUALS( field.GetProperty<std::string>( TextEditor::Property::TEXT ), std::string("testTextFieldEvent"), TEST_LOCATION );
2127
2128   END_TEST;
2129 }
2130
2131 int utcDaliTextFieldEvent09(void)
2132 {
2133   ToolkitTestApplication application;
2134   tet_infoline(" utcDaliTextFieldEvent09");
2135
2136   TextField field = TextField::New();
2137   DALI_TEST_CHECK( field );
2138   Stage::GetCurrent().Add( field );
2139   LoadMarkerImages(application, field);
2140   // Render and notify
2141   application.SendNotification();
2142   application.Render();
2143
2144   field.SetProperty( TextField::Property::TEXT, "Hello" );
2145   field.SetProperty( TextField::Property::POINT_SIZE, 10.f );
2146   field.SetSize( 300.f, 50.f );
2147   field.SetParentOrigin( ParentOrigin::TOP_LEFT );
2148   field.SetAnchorPoint( AnchorPoint::TOP_LEFT );
2149
2150   // Avoid a crash when core load gl resources.
2151   application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
2152
2153   // Create a tap event to touch the text field.
2154   application.ProcessEvent( GenerateTap( Gesture::Possible, 1u, 1u, Vector2( 150.0f, 25.0f ) ) );
2155   application.ProcessEvent( GenerateTap( Gesture::Started, 1u, 1u, Vector2( 150.0f, 25.0f ) ) );
2156   application.SendNotification();
2157   application.Render();
2158
2159   Property::Map map;
2160   map[ HiddenInput::Property::MODE ] = HiddenInput::Mode::HIDE_NONE;
2161   field.SetProperty( DevelTextField::Property::HIDDEN_INPUT_SETTINGS, map );
2162   application.ProcessEvent( GenerateKey( "d", "d", 0, 0, 0, Integration::KeyEvent::Down, DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2163   application.SendNotification();
2164   application.Render();
2165
2166   map[ HiddenInput::Property::MODE ] = HiddenInput::Mode::HIDE_ALL;
2167   map[ HiddenInput::Property::SUBSTITUTE_CHARACTER ] = 0x23;
2168   field.SetProperty( DevelTextField::Property::HIDDEN_INPUT_SETTINGS, map );
2169   application.ProcessEvent( GenerateKey( "d", "d", 0, 0, 0, Integration::KeyEvent::Down, DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2170   application.SendNotification();
2171   application.Render();
2172
2173   map[ HiddenInput::Property::MODE ] = HiddenInput::Mode::HIDE_COUNT;
2174   map[ HiddenInput::Property::SUBSTITUTE_COUNT ] = 2;
2175   field.SetProperty( DevelTextField::Property::HIDDEN_INPUT_SETTINGS, map );
2176   for( unsigned int index = 0u; index < 5u; ++index )
2177   {
2178     application.ProcessEvent( GenerateKey( "d", "d", 0, 0, 0, Integration::KeyEvent::Down, DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2179     application.SendNotification();
2180     application.Render();
2181   }
2182
2183   map[ HiddenInput::Property::MODE ] = HiddenInput::Mode::SHOW_COUNT;
2184   map[ HiddenInput::Property::SUBSTITUTE_COUNT ] = 2;
2185   field.SetProperty( DevelTextField::Property::HIDDEN_INPUT_SETTINGS, map );
2186   for( unsigned int index = 0u; index < 5u; ++index )
2187   {
2188     application.ProcessEvent( GenerateKey( "d", "d", 0, 0, 0, Integration::KeyEvent::Down, DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2189     application.SendNotification();
2190     application.Render();
2191   }
2192
2193   map[ HiddenInput::Property::MODE ] = HiddenInput::Mode::SHOW_LAST_CHARACTER;
2194   map[ HiddenInput::Property::SHOW_DURATION ] = 0;
2195   field.SetProperty( DevelTextField::Property::HIDDEN_INPUT_SETTINGS, map );
2196   application.ProcessEvent( GenerateKey( "", "", DALI_KEY_BACKSPACE, 0, 0, Integration::KeyEvent::Down, DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2197   application.SendNotification();
2198   application.Render();
2199   application.ProcessEvent( GenerateKey( "d", "d", 0, 0, 0, Integration::KeyEvent::Down, DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2200   application.SendNotification();
2201   application.Render();
2202
2203   map[ HiddenInput::Property::SHOW_DURATION ] = 100;
2204   field.SetProperty( DevelTextField::Property::HIDDEN_INPUT_SETTINGS, map );
2205   application.ProcessEvent( GenerateKey( "d", "d", 0, 0, 0, Integration::KeyEvent::Down, DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2206   application.SendNotification();
2207   application.Render();
2208
2209   Property::Map mapGet;
2210   mapGet = field.GetProperty<Property::Map>( DevelTextField::Property::HIDDEN_INPUT_SETTINGS );
2211   DALI_TEST_EQUALS( map.Count(), mapGet.Count(), TEST_LOCATION );
2212   DALI_TEST_EQUALS( DaliTestCheckMaps( map, mapGet ), true, TEST_LOCATION );
2213   END_TEST;
2214 }
2215
2216
2217 int utcDaliTextFieldStyleWhilstSelected(void)
2218 {
2219   ToolkitTestApplication application;
2220   tet_infoline(" utcDaliTextFieldStyleWhilstSelected");
2221
2222   // Change font and styles whilst text is selected whilst word selected
2223
2224   TextField field = TextField::New();
2225   DALI_TEST_CHECK( field );
2226   Stage::GetCurrent().Add( field );
2227   LoadMarkerImages(application, field);
2228   // Render and notify
2229   application.SendNotification();
2230   application.Render();
2231
2232   field.SetProperty( TextField::Property::TEXT, "This is a long text for the size of the text-field." );
2233   field.SetProperty( TextField::Property::POINT_SIZE, 10.f );
2234   field.SetSize( 300.f, 50.f );
2235   field.SetParentOrigin( ParentOrigin::TOP_LEFT );
2236   field.SetAnchorPoint( AnchorPoint::TOP_LEFT );
2237
2238   // Avoid a crash when core load gl resources.
2239   application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
2240   // Render and notify
2241   application.SendNotification();
2242   application.Render();
2243
2244   // Create a tap event to touch the text field.
2245   application.ProcessEvent( GenerateTap( Gesture::Possible, 1u, 1u, Vector2( 150.0f, 25.0f ) ) );
2246   application.ProcessEvent( GenerateTap( Gesture::Started, 1u, 1u, Vector2( 150.0f, 25.0f ) ) );
2247   // Render and notify
2248   application.SendNotification();
2249   application.Render();
2250
2251
2252   // Tap first to get the focus.
2253   application.ProcessEvent( GenerateTap( Gesture::Possible, 1u, 1u, Vector2( 1.f, 25.0f ) ) );
2254   application.ProcessEvent( GenerateTap( Gesture::Started, 1u, 1u, Vector2( 1.f, 25.0f ) ) );
2255
2256   // Render and notify
2257   application.SendNotification();
2258   application.Render();
2259
2260   // Double tap to select a word.
2261   application.ProcessEvent( GenerateTap( Gesture::Possible, 2u, 1u, Vector2( 1.f, 25.0f ) ) );
2262   application.ProcessEvent( GenerateTap( Gesture::Started, 2u, 1u, Vector2( 1.f, 25.0f ) ) );
2263
2264   // Render and notify
2265   application.SendNotification();
2266   application.Render();
2267
2268   field.SetProperty( TextField::Property::INPUT_FONT_FAMILY, "Setting input font family" );
2269   DALI_TEST_EQUALS( field.GetProperty<std::string>( TextField::Property::INPUT_FONT_FAMILY ), "Setting input font family", TEST_LOCATION );
2270
2271   Property::Map fontStyleMapSet;
2272   Property::Map fontStyleMapGet;
2273
2274   fontStyleMapSet.Insert( "weight", "bold" );
2275   fontStyleMapSet.Insert( "slant", "italic" );
2276   field.SetProperty( TextField::Property::INPUT_FONT_STYLE, fontStyleMapSet );
2277
2278   fontStyleMapGet = field.GetProperty<Property::Map>( TextField::Property::INPUT_FONT_STYLE );
2279   DALI_TEST_EQUALS( fontStyleMapGet.Count(), fontStyleMapSet.Count(), TEST_LOCATION );
2280   DALI_TEST_EQUALS( DaliTestCheckMaps( fontStyleMapGet, fontStyleMapSet ), true, TEST_LOCATION );
2281
2282   fontStyleMapSet.Clear();
2283   fontStyleMapSet.Insert( "width", "expanded" );
2284   fontStyleMapSet.Insert( "slant", "italic" );
2285   field.SetProperty( TextField::Property::INPUT_FONT_STYLE, fontStyleMapSet );
2286
2287   fontStyleMapGet = field.GetProperty<Property::Map>( TextField::Property::INPUT_FONT_STYLE );
2288   DALI_TEST_EQUALS( fontStyleMapGet.Count(), fontStyleMapSet.Count(), TEST_LOCATION );
2289   DALI_TEST_EQUALS( DaliTestCheckMaps( fontStyleMapGet, fontStyleMapSet ), true, TEST_LOCATION );
2290
2291   field.SetProperty( TextField::Property::INPUT_POINT_SIZE, 12.f );
2292   DALI_TEST_EQUALS( field.GetProperty<float>( TextField::Property::INPUT_POINT_SIZE ), 12.f, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
2293
2294   field.SetProperty( TextField::Property::TEXT_COLOR, Color::RED );
2295   DALI_TEST_EQUALS( field.GetProperty<Vector4>( TextField::Property::TEXT_COLOR ), Color::RED, TEST_LOCATION );
2296
2297   fontStyleMapSet.Clear();
2298   fontStyleMapSet.Insert( "weight", "bold" );
2299   fontStyleMapSet.Insert( "slant", "italic" );
2300
2301   field.SetProperty( TextField::Property::FONT_STYLE, fontStyleMapSet );
2302
2303   fontStyleMapGet = field.GetProperty<Property::Map>( TextField::Property::FONT_STYLE );
2304   DALI_TEST_EQUALS( fontStyleMapGet.Count(), fontStyleMapSet.Count(), TEST_LOCATION );
2305   DALI_TEST_EQUALS( DaliTestCheckMaps( fontStyleMapGet, fontStyleMapSet ), true, TEST_LOCATION );
2306
2307   fontStyleMapSet.Clear();
2308   fontStyleMapSet.Insert( "width", "expanded" );
2309
2310   field.SetProperty( TextField::Property::FONT_STYLE, fontStyleMapSet );
2311
2312   fontStyleMapGet = field.GetProperty<Property::Map>( TextField::Property::FONT_STYLE );
2313   DALI_TEST_EQUALS( fontStyleMapGet.Count(), fontStyleMapSet.Count(), TEST_LOCATION );
2314   DALI_TEST_EQUALS( DaliTestCheckMaps( fontStyleMapGet, fontStyleMapSet ), true, TEST_LOCATION );
2315
2316   // Press Escape to increase coverage
2317   application.ProcessEvent( GenerateKey( "", "", DALI_KEY_ESCAPE, 0, 0, Integration::KeyEvent::Up, DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2318   application.SendNotification();
2319   application.Render();
2320
2321   DALI_TEST_CHECK( !field.HasKeyInputFocus() );
2322
2323   END_TEST;
2324 }
2325
2326 int utcDaliTextFieldEscKeyLoseFocus(void)
2327 {
2328   ToolkitTestApplication application;
2329   tet_infoline(" utcDaliTextFieldEscKeyLoseFocus");
2330
2331   // Creates a tap event. After creating a tap event the text field should
2332   // have the focus and add text with key events should be possible.
2333
2334   TextField field = TextField::New();
2335   DALI_TEST_CHECK( field );
2336
2337   Stage::GetCurrent().Add( field );
2338
2339   field.SetSize( 300.f, 50.f );
2340   field.SetParentOrigin( ParentOrigin::TOP_LEFT );
2341   field.SetAnchorPoint( AnchorPoint::TOP_LEFT );
2342
2343   // Avoid a crash when core load gl resources.
2344   application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
2345
2346   // Render and notify
2347   application.SendNotification();
2348   application.Render();
2349
2350   // Add a key event but as the text field has not the focus it should do nothing.
2351   application.ProcessEvent( GenerateKey( "a", "a", KEY_A_CODE, 0, 0, Integration::KeyEvent::Down, DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2352   application.ProcessEvent( GenerateKey( "a", "a", KEY_A_CODE, 0, 0, Integration::KeyEvent::Up, DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2353
2354   // Render and notify
2355   application.SendNotification();
2356   application.Render();
2357
2358   DALI_TEST_EQUALS( field.GetProperty<std::string>( TextField::Property::TEXT ), std::string(""), TEST_LOCATION );
2359
2360   // Create a tap event to touch the text field.
2361   application.ProcessEvent( GenerateTap( Gesture::Possible, 1u, 1u, Vector2( 150.0f, 25.0f ) ) );
2362   application.ProcessEvent( GenerateTap( Gesture::Started, 1u, 1u, Vector2( 150.0f, 25.0f ) ) );
2363
2364   // Render and notify
2365   application.SendNotification();
2366   application.Render();
2367
2368   // Now the text field has the focus, so it can handle the key events.
2369   application.ProcessEvent( GenerateKey( "a", "a", KEY_A_CODE, 0, 0, Integration::KeyEvent::Down, DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2370   application.ProcessEvent( GenerateKey( "a", "a", KEY_A_CODE, 0, 0, Integration::KeyEvent::Up, DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2371   application.ProcessEvent( GenerateKey( "d", "d", KEY_D_CODE, 0, 0, Integration::KeyEvent::Down, DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2372   application.ProcessEvent( GenerateKey( "d", "d", KEY_D_CODE, 0, 0, Integration::KeyEvent::Up, DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2373
2374   // Render and notify
2375   application.SendNotification();
2376   application.Render();
2377
2378   DALI_TEST_EQUALS( field.GetProperty<std::string>( TextField::Property::TEXT ), std::string("ad"), TEST_LOCATION );
2379
2380   // Generate a Esc key event. The text field should lose the focus.
2381   application.ProcessEvent( GenerateKey( "", "", DALI_KEY_ESCAPE, 0, 0, Integration::KeyEvent::Down, DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2382   application.ProcessEvent( GenerateKey( "", "", DALI_KEY_ESCAPE, 0, 0, Integration::KeyEvent::Up, DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2383
2384   // Render and notify
2385   application.SendNotification();
2386   application.Render();
2387
2388   DALI_TEST_EQUALS( false, field.HasKeyInputFocus(), TEST_LOCATION );
2389
2390   // No more text should be introduced
2391   application.ProcessEvent( GenerateKey( "a", "a", KEY_A_CODE, 0, 0, Integration::KeyEvent::Down, DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2392   application.ProcessEvent( GenerateKey( "a", "a", KEY_A_CODE, 0, 0, Integration::KeyEvent::Up, DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2393
2394   // Render and notify
2395   application.SendNotification();
2396   application.Render();
2397
2398   DALI_TEST_EQUALS( field.GetProperty<std::string>( TextField::Property::TEXT ), std::string("ad"), TEST_LOCATION );
2399
2400   END_TEST;
2401 }
2402
2403 int utcDaliTextFieldSomeSpecialKeys(void)
2404 {
2405   ToolkitTestApplication application;
2406   tet_infoline(" utcDaliTextFieldSomeSpecialKeys");
2407
2408   // Checks some special keys when the text is selected.
2409
2410   TextField field = TextField::New();
2411   DALI_TEST_CHECK( field );
2412   Stage::GetCurrent().Add( field );
2413   LoadMarkerImages(application, field);
2414   // Render and notify
2415   application.SendNotification();
2416   application.Render();
2417
2418   const std::string longText( "This is a long text for the size of the text-field." );
2419
2420   field.SetProperty( TextField::Property::TEXT, longText );
2421   field.SetProperty( TextField::Property::POINT_SIZE, 10.f );
2422   field.SetSize( 300.f, 50.f );
2423   field.SetParentOrigin( ParentOrigin::TOP_LEFT );
2424   field.SetAnchorPoint( AnchorPoint::TOP_LEFT );
2425
2426   // Avoid a crash when core load gl resources.
2427   application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
2428   // Render and notify
2429   application.SendNotification();
2430   application.Render();
2431
2432   // Create a tap event to touch the text field.
2433   application.ProcessEvent( GenerateTap( Gesture::Possible, 1u, 1u, Vector2( 150.0f, 25.0f ) ) );
2434   application.ProcessEvent( GenerateTap( Gesture::Started, 1u, 1u, Vector2( 150.0f, 25.0f ) ) );
2435
2436   // Render and notify
2437   application.SendNotification();
2438   application.Render();
2439
2440   // Tap first to get the focus.
2441   application.ProcessEvent( GenerateTap( Gesture::Possible, 1u, 1u, Vector2( 1.f, 25.0f ) ) );
2442   application.ProcessEvent( GenerateTap( Gesture::Started, 1u, 1u, Vector2( 1.f, 25.0f ) ) );
2443
2444   // Render and notify
2445   application.SendNotification();
2446   application.Render();
2447
2448   // Double tap to select a word.
2449   application.ProcessEvent( GenerateTap( Gesture::Possible, 2u, 1u, Vector2( 1.f, 25.0f ) ) );
2450   application.ProcessEvent( GenerateTap( Gesture::Started, 2u, 1u, Vector2( 1.f, 25.0f ) ) );
2451
2452   // Render and notify
2453   application.SendNotification();
2454   application.Render();
2455
2456   // Generate a Esc key event. The text field should lose the focus.
2457   application.ProcessEvent( GenerateKey( "XF86PowerOff", "XF86PowerOff", DALI_KEY_POWER, 0, 0, Integration::KeyEvent::Down, DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2458   application.ProcessEvent( GenerateKey( "XF86PowerOff", "XF86PowerOff", DALI_KEY_POWER, 0, 0, Integration::KeyEvent::Up, DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2459
2460   // Render and notify
2461   application.SendNotification();
2462   application.Render();
2463
2464   // Generate a Esc key event. The text field should lose the focus.
2465   application.ProcessEvent( GenerateKey( "XF86Menu", "XF86Menu", DALI_KEY_MENU, 0, 0, Integration::KeyEvent::Down, DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2466   application.ProcessEvent( GenerateKey( "XF86Menu", "XF86Menu", DALI_KEY_MENU, 0, 0, Integration::KeyEvent::Up, DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2467
2468   // Render and notify
2469   application.SendNotification();
2470   application.Render();
2471
2472   // Generate a Esc key event. The text field should lose the focus.
2473   application.ProcessEvent( GenerateKey( "XF86Home", "XF86Home", DALI_KEY_HOME, 0, 0, Integration::KeyEvent::Down, DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2474   application.ProcessEvent( GenerateKey( "XF86Home", "XF86Home", DALI_KEY_HOME, 0, 0, Integration::KeyEvent::Up, DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2475
2476   // Render and notify
2477   application.SendNotification();
2478   application.Render();
2479
2480   // The text shouldn't be deleted.
2481   DALI_TEST_EQUALS( field.GetProperty<std::string>( TextField::Property::TEXT ), longText, TEST_LOCATION );
2482
2483   END_TEST;
2484 }
2485
2486 int utcDaliTextFieldSizeUpdate(void)
2487 {
2488   ToolkitTestApplication application;
2489   tet_infoline("utcDaliTextFieldSizeUpdate");
2490
2491   // Checks some special keys when the text is selected.
2492   TextField field = TextField::New();
2493   DALI_TEST_CHECK( field );
2494   Stage::GetCurrent().Add( field );
2495
2496   float previousHeight = 0.0f;
2497   float currentHeight = 0.0f;
2498   const float fieldWidth = 1920.0f;
2499
2500
2501   // "ㅁ" is bigger then "ኢ"
2502   field.SetSize( Vector2( fieldWidth ,10.0f ) );
2503   field.SetResizePolicy( ResizePolicy::FIXED , Dimension::WIDTH );
2504   field.SetResizePolicy( ResizePolicy::DIMENSION_DEPENDENCY , Dimension::HEIGHT );
2505
2506   field.SetProperty( TextField::Property::TEXT, "ኢ");
2507   field.SetParentOrigin( ParentOrigin::TOP_LEFT );
2508   field.SetAnchorPoint( AnchorPoint::TOP_LEFT );
2509
2510   field.SetKeyboardFocusable(true);
2511   KeyboardFocusManager::Get().SetCurrentFocusActor( field );
2512
2513   application.SendNotification();
2514   application.Render();
2515
2516   previousHeight = field.GetHeightForWidth( fieldWidth );
2517   DALI_TEST_EQUALS( previousHeight, field.GetProperty<float>( Actor::Property::SIZE_HEIGHT ) , TEST_LOCATION );
2518
2519   // Add  another script characters ( glyph height is defferent )
2520   application.ProcessEvent( GenerateKey( "ㅁ", "ㅁ", KEY_A_CODE, 0, 0, Integration::KeyEvent::Down, DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2521   application.ProcessEvent( GenerateKey( "ㅁ", "ㅁ", KEY_A_CODE, 0, 0, Integration::KeyEvent::Up, DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2522
2523   application.SendNotification();
2524   application.Render();
2525
2526   currentHeight = field.GetHeightForWidth( fieldWidth );
2527   DALI_TEST_EQUALS( currentHeight, field.GetProperty<float>( Actor::Property::SIZE_HEIGHT ), TEST_LOCATION );
2528   DALI_TEST_EQUALS( (previousHeight < currentHeight), true , TEST_LOCATION );
2529
2530   END_TEST;
2531 }
2532
2533 int utcDaliTextFieldExtremlyLargePointSize(void)
2534 {
2535   ToolkitTestApplication application;
2536   tet_infoline(" utcDaliTextFieldExtremlyLargePointSize");
2537
2538   TextField field = TextField::New();
2539
2540   field.SetProperty( TextField::Property::TEXT, "Text" );
2541   field.SetSize( 300.f, 50.f );
2542   field.SetParentOrigin( ParentOrigin::TOP_LEFT );
2543   field.SetAnchorPoint( AnchorPoint::TOP_LEFT );
2544   Stage::GetCurrent().Add( field );
2545
2546   try
2547   {
2548     field.SetProperty( TextField::Property::POINT_SIZE, 160.0f );
2549     application.SendNotification();
2550     DALI_TEST_CHECK( field );
2551   }
2552   catch (...)
2553   {
2554     tet_result(TET_FAIL);
2555   }
2556   END_TEST;
2557 }
2558
2559 int UtcDaliTextFieldDefaultFontStylePropertyCoverage(void)
2560 {
2561   ToolkitTestApplication application;
2562   tet_infoline("UtcDaliTextFieldFontStylePorpertyCoverage");
2563   TextField field = TextField::New();
2564   DALI_TEST_CHECK( field );
2565   Stage::GetCurrent().Add( field );
2566
2567   Property::Map fontStyleMapGet;
2568
2569   fontStyleMapGet = field.GetProperty<Property::Map>( TextField::Property::FONT_STYLE );
2570
2571   Property::Value* weightValue = NULL;
2572   Property::Value* widthValue = NULL;
2573   Property::Value* slantValue = NULL;
2574   weightValue = fontStyleMapGet.Find( "weight" );
2575   widthValue = fontStyleMapGet.Find( "width" );
2576   slantValue = fontStyleMapGet.Find( "slant" );
2577   DALI_TEST_CHECK( !weightValue );
2578   DALI_TEST_CHECK( !widthValue );
2579   DALI_TEST_CHECK( !slantValue );
2580
2581   END_TEST;
2582 }