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