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