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