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