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