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