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