2 * Copyright (c) 2017 Samsung Electronics Co., Ltd.
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
8 * http://www.apache.org/licenses/LICENSE-2.0
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.
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"
35 using namespace Toolkit;
37 void dali_textfield_startup(void)
39 test_return_value = TET_UNDEF;
42 void dali_textfield_cleanup(void)
44 test_return_value = TET_PASS;
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";
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";
99 const char* const PROPERTY_NAME_HIDDEN_INPUT_SETTINGS = "hiddenInputSettings";
100 const char* const PROPERTY_NAME_PIXEL_SIZE = "pixelSize";
102 const int DEFAULT_RENDERING_BACKEND = Dali::Toolkit::Text::DEFAULT_RENDERING_BACKEND;
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.
107 const unsigned int CURSOR_BLINK_INTERVAL = 500u; // Cursor blink interval
108 const float RENDER_FRAME_INTERVAL = 16.66f;
110 const float TO_MILLISECONDS = 1000.f;
111 const float TO_SECONDS = 1.f / TO_MILLISECONDS;
113 const float SCROLL_THRESHOLD = 10.f;
114 const float SCROLL_SPEED = 300.f;
116 const unsigned int DEFAULT_FONT_SIZE = 1152u;
117 const std::string DEFAULT_FONT_DIR( "/resources/fonts" );
119 const int KEY_A_CODE = 38;
120 const int KEY_D_CODE = 40;
122 const std::string DEFAULT_DEVICE_NAME("hwKeyboard");
124 static bool gTextChangedCallBackCalled;
125 static bool gMaxCharactersCallBackCalled;
126 static bool gInputStyleChangedCallbackCalled;
127 static Dali::Toolkit::TextField::InputStyle::Mask gInputStyleMask;
129 static void LoadBitmapResource(TestPlatformAbstraction& platform, int width, int height)
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);
136 static void LoadMarkerImages(ToolkitTestApplication& app, TextField textField)
140 LoadBitmapResource( app.GetPlatform(), width, height );
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 );
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)
164 Integration::PanGestureEvent pan(state);
166 pan.previousPosition = previousPosition;
167 pan.currentPosition = currentPosition;
168 pan.timeDelta = timeDelta;
169 pan.numberOfTouches = numberOfTouches;
175 * Helper to generate PanGestureEvent
177 * @param[in] application Application instance
178 * @param[in] state The Gesture State
179 * @param[in] pos The current position of touch.
181 static void SendPan(ToolkitTestApplication& application, Gesture::State state, const Vector2& pos)
185 if( (state == Gesture::Started) ||
186 (state == Gesture::Possible) )
192 application.ProcessEvent(GeneratePan(state, last, pos, 16));
199 * Simulate time passed by.
201 * @note this will always process at least 1 frame (1/60 sec)
203 * @param application Test application instance
204 * @param duration Time to pass in milliseconds.
205 * @return The actual time passed in milliseconds
207 static int Wait(ToolkitTestApplication& application, int duration = 0)
211 for(int i = 0; i <= ( duration / RENDER_FRAME_INTERVAL); i++)
213 application.SendNotification();
214 application.Render(RENDER_FRAME_INTERVAL);
215 time += RENDER_FRAME_INTERVAL;
221 Dali::Integration::Point GetPointDownInside( Vector2& pos )
223 Dali::Integration::Point point;
224 point.SetState( PointState::DOWN );
225 point.SetScreenPosition( pos );
229 Dali::Integration::Point GetPointUpInside( Vector2& pos )
231 Dali::Integration::Point point;
232 point.SetState( PointState::UP );
233 point.SetScreenPosition( pos );
237 struct CallbackFunctor
239 CallbackFunctor(bool* callbackFlag)
240 : mCallbackFlag( callbackFlag )
246 *mCallbackFlag = true;
251 static void TestTextChangedCallback( TextField control )
253 tet_infoline(" TestTextChangedCallback");
255 gTextChangedCallBackCalled = true;
258 static void TestMaxLengthReachedCallback( TextField control )
260 tet_infoline(" TestMaxLengthReachedCallback");
262 gMaxCharactersCallBackCalled = true;
265 static void TestInputStyleChangedCallback( TextField control, TextField::InputStyle::Mask mask )
267 tet_infoline(" TestInputStyleChangedCallback");
269 gInputStyleChangedCallbackCalled = true;
270 gInputStyleMask = mask;
273 // Generate a TapGestureEvent to send to Core.
274 Integration::TapGestureEvent GenerateTap(
275 Gesture::State state,
276 unsigned int numberOfTaps,
277 unsigned int numberOfTouches,
280 Integration::TapGestureEvent tap( state );
282 tap.numberOfTaps = numberOfTaps;
283 tap.numberOfTouches = numberOfTouches;
289 Integration::LongPressGestureEvent GenerateLongPress(
290 Gesture::State state,
291 unsigned int numberOfTouches,
294 Integration::LongPressGestureEvent longPress( state );
296 longPress.numberOfTouches = numberOfTouches;
297 longPress.point = point;
301 // Generate a KeyEvent to send to Core.
302 Integration::KeyEvent GenerateKey( const std::string& keyName,
303 const std::string& keyString,
306 unsigned long timeStamp,
307 const Integration::KeyEvent::State& keyState,
308 const std::string& deviceName,
309 const DevelKeyEvent::DeviceClass::Type& deviceClass )
311 return Integration::KeyEvent( keyName,
321 bool DaliTestCheckMaps( const Property::Map& fontStyleMapGet, const Property::Map& fontStyleMapSet )
323 if( fontStyleMapGet.Count() == fontStyleMapSet.Count() )
325 for( unsigned int index = 0u; index < fontStyleMapGet.Count(); ++index )
327 const KeyValuePair& valueGet = fontStyleMapGet.GetKeyValue( index );
329 if( valueGet.first.type == Property::Key::STRING )
331 Property::Value* valueSet = fontStyleMapSet.Find( valueGet.first.stringKey );
332 if( NULL != valueSet )
334 if( valueGet.second.Get<std::string>() != valueSet->Get<std::string>() )
336 tet_printf( " Value got : [%s], expected : [%s]", valueGet.second.Get<std::string>().c_str(), valueSet->Get<std::string>().c_str() );
342 tet_printf( " The key %s doesn't exist.", valueGet.first.stringKey.c_str() );
348 Property::Value* valueSet = fontStyleMapSet.Find( valueGet.first.indexKey );
349 if( NULL != valueSet )
351 if( valueGet.second.Get<int>() != valueSet->Get<int>() )
353 tet_printf( " Integer Value got : [%d], expected : [%d]", valueGet.second.Get<int>(), valueSet->Get<int>() );
359 tet_printf( " The Int key %d doesn't exist.", valueGet.first.indexKey );
371 int UtcDaliToolkitTextFieldConstructorP(void)
373 ToolkitTestApplication application;
374 tet_infoline(" UtcDaliToolkitTextFieldConstructorP");
376 DALI_TEST_CHECK( !textField );
380 int UtcDaliToolkitTextFieldNewP(void)
382 ToolkitTestApplication application;
383 tet_infoline(" UtcDaliToolkitTextFieldNewP");
384 TextField textField = TextField::New();
385 DALI_TEST_CHECK( textField );
389 int UtcDaliToolkitTextFieldDownCastP(void)
391 ToolkitTestApplication application;
392 tet_infoline(" UtcDaliToolkitTextFieldDownCastP");
393 TextField textField1 = TextField::New();
394 BaseHandle object( textField1 );
396 TextField textField2 = TextField::DownCast( object );
397 DALI_TEST_CHECK( textField2 );
399 TextField textField3 = DownCast< TextField >( object );
400 DALI_TEST_CHECK( textField3 );
404 int UtcDaliToolkitTextFieldDownCastN(void)
406 ToolkitTestApplication application;
407 tet_infoline(" UtcDaliToolkitTextFieldDownCastN");
408 BaseHandle uninitializedObject;
409 TextField textField1 = TextField::DownCast( uninitializedObject );
410 DALI_TEST_CHECK( !textField1 );
412 TextField textField2 = DownCast< TextField >( uninitializedObject );
413 DALI_TEST_CHECK( !textField2 );
417 int UtcDaliToolkitTextFieldCopyConstructorP(void)
419 ToolkitTestApplication application;
420 tet_infoline(" UtcDaliToolkitTextFieldCopyConstructorP");
421 TextField textField = TextField::New();
422 textField.SetProperty( TextField::Property::TEXT, "Test" );
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 ) );
430 int UtcDaliToolkitTextFieldAssignmentOperatorP(void)
432 ToolkitTestApplication application;
433 tet_infoline(" UtcDaliToolkitTextFieldAssignmentOperatorP");
434 TextField textField = TextField::New();
435 textField.SetProperty( TextField::Property::TEXT, "Test" );
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 ) );
443 int UtcDaliTextFieldNewP(void)
445 ToolkitTestApplication application;
446 tet_infoline(" UtcDaliToolkitTextFieldNewP");
447 TextField textField = TextField::New();
448 DALI_TEST_CHECK( textField );
452 // Positive test case for a method
453 int UtcDaliTextFieldGetPropertyP(void)
455 ToolkitTestApplication application;
456 tet_infoline(" UtcDaliToolkitTextFieldGetPropertyP");
457 TextField field = TextField::New();
458 DALI_TEST_CHECK( field );
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 );
514 bool SetPropertyMapRetrieved( TextField& field, const Property::Index property, const std::string mapKey, const std::string mapValue )
517 Property::Map imageMap;
518 imageMap[mapKey] =mapValue;
520 field.SetProperty( property , imageMap );
521 Property::Value propValue = field.GetProperty( property );
522 Property::Map* resultMap = propValue.GetMap();
524 if ( resultMap->Find( mapKey )->Get< std::string>() == mapValue )
532 // Positive test case for a method
533 int UtcDaliTextFieldSetPropertyP(void)
535 ToolkitTestApplication application;
536 tet_infoline(" UtcDaliToolkitTextFieldSetPropertyP");
537 TextField field = TextField::New();
538 DALI_TEST_CHECK( field );
539 Stage::GetCurrent().Add( field );
541 // Note - we can't check the defaults since the stylesheets are platform-specific
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 );
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 );
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 );
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 );
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 );
562 Property::Map fontStyleMapSet;
563 Property::Map fontStyleMapGet;
564 Property::Value* slantValue = NULL;
566 fontStyleMapSet.Insert( "weight", "bold" );
567 fontStyleMapSet.Insert( "width", "condensed" );
568 fontStyleMapSet.Insert( "slant", "italic" );
569 field.SetProperty( TextField::Property::FONT_STYLE, fontStyleMapSet );
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 );
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 );
579 fontStyleMapSet.Clear();
580 fontStyleMapSet.Insert( "weight", "normal" );
581 fontStyleMapSet.Insert( "slant", "oblique" );
582 field.SetProperty( TextField::Property::FONT_STYLE, fontStyleMapSet );
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 );
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 );
593 // Replace 'roman' for 'normal'.
594 slantValue = fontStyleMapGet.Find( "slant" );
595 if( NULL != slantValue )
597 if( "normal" == slantValue->Get<std::string>() )
599 fontStyleMapGet["slant"] = "roman";
602 DALI_TEST_EQUALS( fontStyleMapGet.Count(), fontStyleMapSet.Count(), TEST_LOCATION );
603 DALI_TEST_EQUALS( DaliTestCheckMaps( fontStyleMapGet, fontStyleMapSet ), true, TEST_LOCATION );
605 fontStyleMapSet.Clear();
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 );
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 );
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 );
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 );
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 );
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 );
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 );
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 );
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 );
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 );
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" );
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" ) );
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 );
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 );
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 );
699 Property::Value value = field.GetProperty( TextField::Property::INPUT_METHOD_SETTINGS );
701 DALI_TEST_CHECK( value.Get( map ) );
704 DALI_TEST_CHECK( map[ "PANEL_LAYOUT" ].Get( layout ) );
705 DALI_TEST_EQUALS( static_cast<int>(panelLayout), layout, TEST_LOCATION );
708 DALI_TEST_CHECK( map[ "AUTO_CAPITALISE" ].Get( capital ) );
709 DALI_TEST_EQUALS( static_cast<int>(autoCapital), capital, TEST_LOCATION );
712 DALI_TEST_CHECK( map[ "ACTION_BUTTON" ].Get( action ) );
713 DALI_TEST_EQUALS( static_cast<int>(actionButton), action, TEST_LOCATION );
716 DALI_TEST_CHECK( map[ "VARIATION" ].Get( variation ) );
717 DALI_TEST_EQUALS( inputVariation, variation, TEST_LOCATION );
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 );
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 ) );
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 );
732 fontStyleMapSet.Clear();
733 fontStyleMapSet.Insert( "weight", "bold" );
734 fontStyleMapSet.Insert( "width", "condensed" );
735 fontStyleMapSet.Insert( "slant", "italic" );
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 );
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 );
745 // Reset input font style.
746 fontStyleMapSet.Clear();
747 fontStyleMapSet.Insert( "weight", "normal" );
748 fontStyleMapSet.Insert( "slant", "oblique" );
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 );
755 fontStyleMapSet.Clear();
756 fontStyleMapSet.Insert( "slant", "roman" );
758 field.SetProperty( TextField::Property::INPUT_FONT_STYLE, fontStyleMapSet );
759 fontStyleMapGet = field.GetProperty<Property::Map>( TextField::Property::INPUT_FONT_STYLE );
761 // Replace 'roman' for 'normal'.
762 slantValue = fontStyleMapGet.Find( "slant" );
763 if( NULL != slantValue )
765 if( "normal" == slantValue->Get<std::string>() )
767 fontStyleMapGet["slant"] = "roman";
770 DALI_TEST_EQUALS( fontStyleMapGet.Count(), fontStyleMapSet.Count(), TEST_LOCATION );
771 DALI_TEST_EQUALS( DaliTestCheckMaps( fontStyleMapGet, fontStyleMapSet ), true, TEST_LOCATION );
773 fontStyleMapSet.Clear();
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 );
780 Property::Map underlineMapSet;
781 Property::Map underlineMapGet;
783 underlineMapSet.Insert( "enable", "true" );
784 underlineMapSet.Insert( "color", "red" );
785 underlineMapSet.Insert( "height", "1" );
787 // Check the underline property
788 field.SetProperty( TextField::Property::UNDERLINE, underlineMapSet );
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 );
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 );
798 // Check the shadow property
799 Property::Map shadowMapSet;
800 Property::Map shadowMapGet;
802 shadowMapSet.Insert( "color", "green" );
803 shadowMapSet.Insert( "offset", "2 2" );
805 field.SetProperty( TextField::Property::SHADOW, shadowMapSet );
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 );
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 );
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 );
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 );
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 );
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 );
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 );
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 );
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 );
851 // Positive Atlas Text Renderer test
852 int utcDaliTextFieldAtlasRenderP(void)
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 );
861 field.SetProperty( TextField::Property::HORIZONTAL_ALIGNMENT, "CENTER" );
863 application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
865 Stage::GetCurrent().Add( field );
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();
876 tet_result(TET_FAIL);
881 // Positive test for the textChanged signal.
882 int utcDaliTextFieldTextChangedP(void)
884 ToolkitTestApplication application;
885 tet_infoline(" utcDaliTextFieldTextChangedP");
886 TextField field = TextField::New();
887 DALI_TEST_CHECK( field );
889 Stage::GetCurrent().Add( field );
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) );
897 gTextChangedCallBackCalled = false;
898 field.SetProperty( TextField::Property::TEXT, "ABC" );
899 DALI_TEST_CHECK( gTextChangedCallBackCalled );
900 DALI_TEST_CHECK( textChangedSignal );
902 application.SendNotification();
904 field.SetKeyInputFocus();
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 );
913 // Negative test for the textChanged signal.
914 int utcDaliTextFieldTextChangedN(void)
916 ToolkitTestApplication application;
917 tet_infoline(" utcDaliTextFieldTextChangedN");
918 TextField field = TextField::New();
919 DALI_TEST_CHECK( field );
921 Stage::GetCurrent().Add( field );
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) );
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 );
937 // Positive test for Max Characters reached signal.
938 int utcDaliTextFieldMaxCharactersReachedP(void)
940 ToolkitTestApplication application;
941 tet_infoline(" utcDaliTextFieldMaxCharactersReachedP");
942 TextField field = TextField::New();
943 DALI_TEST_CHECK( field );
945 Stage::GetCurrent().Add( field );
947 const int maxNumberOfCharacters = 1;
948 field.SetProperty( TextField::Property::MAX_LENGTH, maxNumberOfCharacters );
950 field.SetKeyInputFocus();
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) );
958 gMaxCharactersCallBackCalled = false;
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 ) );
963 DALI_TEST_CHECK( gMaxCharactersCallBackCalled );
964 DALI_TEST_CHECK( maxLengthReachedSignal );
969 // Negative test for Max Characters reached signal.
970 int utcDaliTextFieldMaxCharactersReachedN(void)
972 ToolkitTestApplication application;
973 tet_infoline(" utcDaliTextFieldMaxCharactersReachedN");
974 TextField field = TextField::New();
975 DALI_TEST_CHECK( field );
977 Stage::GetCurrent().Add( field );
979 const int maxNumberOfCharacters = 3;
980 field.SetProperty( TextField::Property::MAX_LENGTH, maxNumberOfCharacters );
982 field.SetKeyInputFocus();
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) );
990 gMaxCharactersCallBackCalled = false;
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 ) );
995 DALI_TEST_CHECK( !gMaxCharactersCallBackCalled );
996 DALI_TEST_CHECK( !maxLengthReachedSignal );
1001 int utcDaliTextFieldInputStyleChanged01(void)
1003 ToolkitTestApplication application;
1004 tet_infoline(" utcDaliTextFieldInputStyleChanged01");
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();
1015 char* pathNamePtr = get_current_dir_name();
1016 const std::string pathName( pathNamePtr );
1017 free( pathNamePtr );
1019 TextAbstraction::FontClient fontClient = TextAbstraction::FontClient::Get();
1020 fontClient.SetDpi( 93u, 93u );
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 );
1025 TextField field = TextField::New();
1026 DALI_TEST_CHECK( field );
1029 field.SetSize( 300.f, 50.f );
1030 field.SetParentOrigin( ParentOrigin::TOP_LEFT );
1031 field.SetAnchorPoint( AnchorPoint::TOP_LEFT );
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>" );
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) );
1042 Stage::GetCurrent().Add( field );
1044 // Render and notify
1045 application.SendNotification();
1046 application.Render();
1048 // Executes the idle callbacks added by the text control on the change of input style.
1049 application.RunIdles();
1051 gInputStyleChangedCallbackCalled = false;
1052 gInputStyleMask = TextField::InputStyle::NONE;
1053 inputStyleChangedSignal = false;
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 ) ) );
1059 // Render and notify
1060 application.SendNotification();
1061 application.Render();
1063 // Executes the idle callbacks added by the text control on the change of input style.
1064 application.RunIdles();
1066 DALI_TEST_CHECK( gInputStyleChangedCallbackCalled );
1067 if( gInputStyleChangedCallbackCalled )
1069 DALI_TEST_EQUALS( static_cast<unsigned int>( gInputStyleMask ), static_cast<unsigned int>( TextField::InputStyle::FONT_FAMILY | TextField::InputStyle::POINT_SIZE ), TEST_LOCATION );
1071 const std::string fontFamily = field.GetProperty( TextField::Property::INPUT_FONT_FAMILY ).Get<std::string>();
1072 DALI_TEST_EQUALS( fontFamily, "DejaVuSerif", TEST_LOCATION );
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 );
1077 DALI_TEST_CHECK( inputStyleChangedSignal );
1079 gInputStyleChangedCallbackCalled = false;
1080 gInputStyleMask = TextField::InputStyle::NONE;
1081 inputStyleChangedSignal = false;
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 ) ) );
1087 // Render and notify
1088 application.SendNotification();
1089 application.Render();
1091 // Executes the idle callbacks added by the text control on the change of input style.
1092 application.RunIdles();
1094 DALI_TEST_CHECK( !gInputStyleChangedCallbackCalled );
1095 DALI_TEST_CHECK( !inputStyleChangedSignal );
1097 gInputStyleChangedCallbackCalled = false;
1098 gInputStyleMask = TextField::InputStyle::NONE;
1099 inputStyleChangedSignal = false;
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 ) ) );
1105 // Render and notify
1106 application.SendNotification();
1107 application.Render();
1109 // Executes the idle callbacks added by the text control on the change of input style.
1110 application.RunIdles();
1112 DALI_TEST_CHECK( gInputStyleChangedCallbackCalled );
1113 if( gInputStyleChangedCallbackCalled )
1115 DALI_TEST_EQUALS( static_cast<unsigned int>( gInputStyleMask ), static_cast<unsigned int>( TextField::InputStyle::COLOR ), TEST_LOCATION );
1117 const Vector4 color = field.GetProperty( TextField::Property::INPUT_COLOR ).Get<Vector4>();
1118 DALI_TEST_EQUALS( color, Color::GREEN, TEST_LOCATION );
1120 DALI_TEST_CHECK( inputStyleChangedSignal );
1122 gInputStyleChangedCallbackCalled = false;
1123 gInputStyleMask = TextField::InputStyle::NONE;
1124 inputStyleChangedSignal = false;
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 ) ) );
1130 // Render and notify
1131 application.SendNotification();
1132 application.Render();
1134 // Executes the idle callbacks added by the text control on the change of input style.
1135 application.RunIdles();
1137 DALI_TEST_CHECK( gInputStyleChangedCallbackCalled );
1138 if( gInputStyleChangedCallbackCalled )
1140 DALI_TEST_EQUALS( static_cast<unsigned int>( gInputStyleMask ), static_cast<unsigned int>( TextField::InputStyle::COLOR | TextField::InputStyle::FONT_STYLE ), TEST_LOCATION );
1142 const Vector4 color = field.GetProperty( TextField::Property::INPUT_COLOR ).Get<Vector4>();
1143 DALI_TEST_EQUALS( color, Color::BLACK, TEST_LOCATION );
1145 const Property::Map fontStyleMapGet = field.GetProperty( TextField::Property::INPUT_FONT_STYLE ).Get<Property::Map>();
1147 Property::Map fontStyleMapSet;
1148 fontStyleMapSet.Insert( "weight", "bold" );
1150 DALI_TEST_EQUALS( fontStyleMapGet.Count(), fontStyleMapSet.Count(), TEST_LOCATION );
1151 DALI_TEST_EQUALS( DaliTestCheckMaps( fontStyleMapGet, fontStyleMapSet ), true, TEST_LOCATION );
1153 DALI_TEST_CHECK( inputStyleChangedSignal );
1155 gInputStyleChangedCallbackCalled = false;
1156 gInputStyleMask = TextField::InputStyle::NONE;
1157 inputStyleChangedSignal = false;
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 ) ) );
1163 // Render and notify
1164 application.SendNotification();
1165 application.Render();
1167 // Executes the idle callbacks added by the text control on the change of input style.
1168 application.RunIdles();
1170 DALI_TEST_CHECK( !gInputStyleChangedCallbackCalled );
1171 DALI_TEST_CHECK( !inputStyleChangedSignal );
1173 gInputStyleChangedCallbackCalled = false;
1174 gInputStyleMask = TextField::InputStyle::NONE;
1175 inputStyleChangedSignal = false;
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 ) ) );
1181 // Render and notify
1182 application.SendNotification();
1183 application.Render();
1185 // Executes the idle callbacks added by the text control on the change of input style.
1186 application.RunIdles();
1188 DALI_TEST_CHECK( gInputStyleChangedCallbackCalled );
1189 if( gInputStyleChangedCallbackCalled )
1191 DALI_TEST_EQUALS( static_cast<unsigned int>( gInputStyleMask ), static_cast<unsigned int>( TextField::InputStyle::FONT_STYLE ), TEST_LOCATION );
1193 const std::string style = field.GetProperty( TextField::Property::INPUT_FONT_STYLE ).Get<std::string>();
1194 DALI_TEST_CHECK( style.empty() );
1196 DALI_TEST_CHECK( inputStyleChangedSignal );
1198 gInputStyleChangedCallbackCalled = false;
1199 gInputStyleMask = TextField::InputStyle::NONE;
1200 inputStyleChangedSignal = false;
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 ) ) );
1206 // Render and notify
1207 application.SendNotification();
1208 application.Render();
1210 // Executes the idle callbacks added by the text control on the change of input style.
1211 application.RunIdles();
1213 DALI_TEST_CHECK( !gInputStyleChangedCallbackCalled );
1214 DALI_TEST_CHECK( !inputStyleChangedSignal );
1219 int utcDaliTextFieldInputStyleChanged02(void)
1221 ToolkitTestApplication application;
1222 tet_infoline(" utcDaliTextFieldInputStyleChanged02");
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();
1233 char* pathNamePtr = get_current_dir_name();
1234 const std::string pathName( pathNamePtr );
1235 free( pathNamePtr );
1237 TextAbstraction::FontClient fontClient = TextAbstraction::FontClient::Get();
1238 fontClient.SetDpi( 93u, 93u );
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 );
1243 TextField field = TextField::New();
1244 DALI_TEST_CHECK( field );
1247 field.SetSize( 300.f, 50.f );
1248 field.SetParentOrigin( ParentOrigin::TOP_LEFT );
1249 field.SetAnchorPoint( AnchorPoint::TOP_LEFT );
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>" );
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) );
1260 Stage::GetCurrent().Add( field );
1262 // Render and notify
1263 application.SendNotification();
1264 application.Render();
1266 // Executes the idle callbacks added by the text control on the change of input style.
1267 application.RunIdles();
1269 gInputStyleChangedCallbackCalled = false;
1270 gInputStyleMask = TextField::InputStyle::NONE;
1271 inputStyleChangedSignal = false;
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 ) ) );
1279 // Render and notify
1280 application.SendNotification();
1281 application.Render();
1283 // Executes the idle callbacks added by the text control on the change of input style.
1284 application.RunIdles();
1286 DALI_TEST_CHECK( gInputStyleChangedCallbackCalled );
1287 if( gInputStyleChangedCallbackCalled )
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 ),
1295 const Vector4 color = field.GetProperty( TextField::Property::INPUT_COLOR ).Get<Vector4>();
1296 DALI_TEST_EQUALS( color, Color::GREEN, TEST_LOCATION );
1298 const std::string fontFamily = field.GetProperty( TextField::Property::INPUT_FONT_FAMILY ).Get<std::string>();
1299 DALI_TEST_EQUALS( fontFamily, "DejaVuSerif", TEST_LOCATION );
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 );
1304 DALI_TEST_CHECK( inputStyleChangedSignal );
1306 gInputStyleChangedCallbackCalled = false;
1307 gInputStyleMask = TextField::InputStyle::NONE;
1308 inputStyleChangedSignal = false;
1310 application.ProcessEvent( GenerateKey( "", "", DALI_KEY_BACKSPACE, 0, 0, Integration::KeyEvent::Down, DEFAULT_DEVICE_NAME, DevelKeyEvent::DeviceClass::NONE ) );
1312 // Render and notify
1313 application.SendNotification();
1314 application.Render();
1316 // Executes the idle callbacks added by the text control on the change of input style.
1317 application.RunIdles();
1319 DALI_TEST_CHECK( gInputStyleChangedCallbackCalled );
1320 if( gInputStyleChangedCallbackCalled )
1322 DALI_TEST_EQUALS( static_cast<unsigned int>( gInputStyleMask ),
1323 static_cast<unsigned int>( TextField::InputStyle::COLOR ),
1326 const Vector4 color = field.GetProperty( TextField::Property::INPUT_COLOR ).Get<Vector4>();
1327 DALI_TEST_EQUALS( color, Color::BLUE, TEST_LOCATION );
1329 DALI_TEST_CHECK( inputStyleChangedSignal );
1331 gInputStyleChangedCallbackCalled = false;
1332 gInputStyleMask = TextField::InputStyle::NONE;
1333 inputStyleChangedSignal = false;
1335 application.ProcessEvent( GenerateKey( "", "", DALI_KEY_BACKSPACE, 0, 0, Integration::KeyEvent::Down, DEFAULT_DEVICE_NAME, DevelKeyEvent::DeviceClass::NONE ) );
1337 // Render and notify
1338 application.SendNotification();
1339 application.Render();
1341 // Executes the idle callbacks added by the text control on the change of input style.
1342 application.RunIdles();
1344 DALI_TEST_CHECK( !gInputStyleChangedCallbackCalled );
1345 DALI_TEST_CHECK( !inputStyleChangedSignal );
1347 gInputStyleChangedCallbackCalled = false;
1348 gInputStyleMask = TextField::InputStyle::NONE;
1349 inputStyleChangedSignal = false;
1351 application.ProcessEvent( GenerateKey( "", "", DALI_KEY_BACKSPACE, 0, 0, Integration::KeyEvent::Down, DEFAULT_DEVICE_NAME, DevelKeyEvent::DeviceClass::NONE ) );
1353 // Render and notify
1354 application.SendNotification();
1355 application.Render();
1357 // Executes the idle callbacks added by the text control on the change of input style.
1358 application.RunIdles();
1360 DALI_TEST_CHECK( gInputStyleChangedCallbackCalled );
1361 if( gInputStyleChangedCallbackCalled )
1363 DALI_TEST_EQUALS( static_cast<unsigned int>( gInputStyleMask ),
1364 static_cast<unsigned int>( TextField::InputStyle::COLOR ),
1367 const Vector4 color = field.GetProperty( TextField::Property::INPUT_COLOR ).Get<Vector4>();
1368 DALI_TEST_EQUALS( color, Color::BLACK, TEST_LOCATION );
1370 DALI_TEST_CHECK( inputStyleChangedSignal );
1372 gInputStyleChangedCallbackCalled = false;
1373 gInputStyleMask = TextField::InputStyle::NONE;
1374 inputStyleChangedSignal = false;
1376 field.SetProperty( TextField::Property::INPUT_COLOR, Color::YELLOW );
1378 Property::Map fontStyleMapSet;
1379 fontStyleMapSet.Insert( "weight", "thin" );
1380 fontStyleMapSet.Insert( "width", "condensed" );
1381 fontStyleMapSet.Insert( "slant", "italic" );
1383 field.SetProperty( TextField::Property::INPUT_FONT_STYLE, fontStyleMapSet );
1384 field.SetProperty( TextField::Property::INPUT_POINT_SIZE, 20.f );
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" );
1391 // Render and notify
1392 application.SendNotification();
1393 application.Render();
1395 // Executes the idle callbacks added by the text control on the change of input style.
1396 application.RunIdles();
1398 DALI_TEST_CHECK( !gInputStyleChangedCallbackCalled );
1399 DALI_TEST_CHECK( !inputStyleChangedSignal );
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 ) ) );
1405 // Render and notify
1406 application.SendNotification();
1407 application.Render();
1409 // Executes the idle callbacks added by the text control on the change of input style.
1410 application.RunIdles();
1412 DALI_TEST_CHECK( gInputStyleChangedCallbackCalled );
1413 if( gInputStyleChangedCallbackCalled )
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 ),
1425 const Vector4 color = field.GetProperty( TextField::Property::INPUT_COLOR ).Get<Vector4>();
1426 DALI_TEST_EQUALS( color, Color::BLACK, TEST_LOCATION );
1428 DALI_TEST_CHECK( inputStyleChangedSignal );
1433 int utcDaliTextFieldEvent01(void)
1435 ToolkitTestApplication application;
1436 tet_infoline(" utcDaliTextFieldEvent01");
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.
1441 TextField field = TextField::New();
1442 DALI_TEST_CHECK( field );
1444 Stage::GetCurrent().Add( field );
1446 field.SetSize( 300.f, 50.f );
1447 field.SetParentOrigin( ParentOrigin::TOP_LEFT );
1448 field.SetAnchorPoint( AnchorPoint::TOP_LEFT );
1450 // Avoid a crash when core load gl resources.
1451 application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
1453 // Render and notify
1454 application.SendNotification();
1455 application.Render();
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 ) );
1460 // Render and notify
1461 application.SendNotification();
1462 application.Render();
1464 DALI_TEST_EQUALS( field.GetProperty<std::string>( TextField::Property::TEXT ), std::string(""), TEST_LOCATION );
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 ) ) );
1470 // Render and notify
1471 application.SendNotification();
1472 application.Render();
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 ) );
1478 // Render and notify
1479 application.SendNotification();
1480 application.Render();
1482 DALI_TEST_EQUALS( field.GetProperty<std::string>( TextField::Property::TEXT ), std::string("aa"), TEST_LOCATION );
1484 // Create a second text field and send key events to it.
1485 TextField field2 = TextField::New();
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 );
1492 Stage::GetCurrent().Add( field2 );
1494 // Render and notify
1495 application.SendNotification();
1496 application.Render();
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 ) ) );
1502 // Render and notify
1503 application.SendNotification();
1504 application.Render();
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 ) );
1510 // Render and notify
1511 application.SendNotification();
1512 application.Render();
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 );
1520 int utcDaliTextFieldEvent02(void)
1522 ToolkitTestApplication application;
1523 tet_infoline(" utcDaliTextFieldEvent02");
1525 // Checks if the right number of actors are created.
1527 TextField field = TextField::New();
1528 field.SetProperty( TextField::Property::POINT_SIZE, 10.f );
1529 DALI_TEST_CHECK( field );
1530 LoadMarkerImages(application, field);
1532 Stage::GetCurrent().Add( field );
1534 field.SetSize( 300.f, 50.f );
1535 field.SetParentOrigin( ParentOrigin::TOP_LEFT );
1536 field.SetAnchorPoint( AnchorPoint::TOP_LEFT );
1538 // Avoid a crash when core load gl resources.
1539 application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
1541 // Render and notify
1542 application.SendNotification();
1543 application.Render();
1545 // Check there are the expected number of children ( stencil ).
1546 DALI_TEST_EQUALS( field.GetChildCount(), 1u, TEST_LOCATION );
1548 Actor stencil = field.GetChildAt( 0u );
1549 DALI_TEST_EQUALS( stencil.GetChildCount(), 0u, TEST_LOCATION );
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 ) ) );
1555 // Render and notify
1556 application.SendNotification();
1557 application.Render();
1559 Actor layer = field.GetChildAt( 1u );
1560 DALI_TEST_CHECK( layer.IsLayer() );
1562 DALI_TEST_EQUALS( layer.GetChildCount(), 1u, TEST_LOCATION ); // The cursor.
1563 DALI_TEST_EQUALS( stencil.GetChildCount(), 0u, TEST_LOCATION );
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 ) );
1569 // Render and notify
1570 application.SendNotification();
1571 application.Render();
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
1577 Control cursor = Control::DownCast( layer.GetChildAt( 0u ) );
1578 DALI_TEST_CHECK( cursor );
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 )
1584 Renderer renderer = container.GetChildAt( index ).GetRendererAt( 0u );
1585 DALI_TEST_CHECK( renderer );
1588 // Move the cursor and check the position changes.
1589 Vector3 position1 = cursor.GetCurrentPosition();
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 ) );
1594 // Render and notify
1595 application.SendNotification();
1596 application.Render();
1598 Vector3 position2 = cursor.GetCurrentPosition();
1600 DALI_TEST_CHECK( position2.x < position1.x );
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 ) );
1605 // Render and notify
1606 application.SendNotification();
1607 application.Render();
1609 Vector3 position3 = cursor.GetCurrentPosition();
1611 DALI_TEST_EQUALS( position1, position3, TEST_LOCATION ); // Should be in the same position1.
1613 // Send some taps and check the cursor positions.
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 ) ) );
1619 // Render and notify
1620 application.SendNotification();
1621 application.Render();
1623 // Cursor position should be the same than position1.
1624 Vector3 position4 = cursor.GetCurrentPosition();
1626 DALI_TEST_EQUALS( position2, position4, TEST_LOCATION ); // Should be in the same position2.
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 ) ) );
1632 // Render and notify
1633 application.SendNotification();
1634 application.Render();
1636 Vector3 position5 = cursor.GetCurrentPosition();
1638 DALI_TEST_CHECK( position5.x > position4.x );
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, "" );
1645 // Render and notify
1646 application.SendNotification();
1647 application.Render();
1649 // Cursor position should be the same than position2.
1650 Vector3 position6 = cursor.GetCurrentPosition();
1652 DALI_TEST_EQUALS( position2, position6, TEST_LOCATION );// Should be in the same position2.
1654 // Should not be a renderer.
1655 DALI_TEST_EQUALS( stencil.GetChildCount(), 0u, TEST_LOCATION );
1660 int utcDaliTextFieldEvent03(void)
1662 ToolkitTestApplication application;
1663 tet_infoline(" utcDaliTextFieldEvent03");
1665 // Checks if the highlight actor is created.
1667 TextField field = TextField::New();
1668 DALI_TEST_CHECK( field );
1670 Stage::GetCurrent().Add( field );
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 );
1678 // Avoid a crash when core load gl resources.
1679 application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
1680 LoadMarkerImages(application, field);
1682 // Render and notify
1683 application.SendNotification();
1684 application.Render();
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 ) ) );
1690 // Render and notify
1691 application.SendNotification();
1692 application.Render();
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 ) ) );
1698 // Render and notify
1699 application.SendNotification();
1700 application.Render();
1702 // The offscreen root actor should have two actors: the renderer and the highlight actor.
1703 Actor stencil = field.GetChildAt( 0u );
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 );
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 )
1713 Renderer renderer = container.GetChildAt( index ).GetRendererAt( 0u );
1714 DALI_TEST_CHECK( renderer );
1720 int utcDaliTextFieldEvent04(void)
1722 ToolkitTestApplication application;
1723 tet_infoline(" utcDaliTextFieldEvent04");
1725 // Checks if the highlight actor is created.
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();
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 );
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();
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();
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 ) ) );
1759 // Render and notify
1760 application.SendNotification();
1761 application.Render();
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 ) ) );
1767 // Render and notify
1768 application.SendNotification();
1769 application.Render();
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 ) ) );
1777 int utcDaliTextFieldEvent05(void)
1779 ToolkitTestApplication application;
1780 tet_infoline(" utcDaliTextFieldEvent05");
1782 // Checks dragging of cursor/grab handle
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();
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 );
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();
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();
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 ) ) );
1816 // Render and notify
1817 application.SendNotification();
1818 application.Render();
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 ) ) );
1824 // Render and notify
1825 application.SendNotification();
1826 application.Render();
1828 // drag grab handle right
1829 Vector2 pos(0.0f, 40.0f);
1830 SendPan(application, Gesture::Possible, pos);
1831 SendPan(application, Gesture::Started, pos);
1833 Wait(application, 100);
1835 for(int i = 0;i<20;i++)
1837 SendPan(application, Gesture::Continuing, pos);
1842 SendPan(application, Gesture::Finished, pos);
1843 Wait(application, RENDER_FRAME_INTERVAL);
1845 Actor stencil = field.GetChildAt( 1u );
1849 int utcDaliTextFieldEvent06(void)
1851 ToolkitTestApplication application;
1852 tet_infoline(" utcDaliTextFieldEvent06");
1854 // Checks Longpress when in edit mode
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();
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 );
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();
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();
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 ) ) );
1888 // Render and notify
1889 application.SendNotification();
1890 application.Render();
1893 application.ProcessEvent( GenerateLongPress( Gesture::Possible, 1u, Vector2( 1.f, 25.0f ) ) );
1894 application.ProcessEvent( GenerateLongPress( Gesture::Started, 1u, Vector2( 1.f, 25.0f ) ) );
1896 // Render and notify
1897 application.SendNotification();
1898 application.Render();
1903 int utcDaliTextFieldEvent07(void)
1905 ToolkitTestApplication application;
1906 tet_infoline(" utcDaliTextFieldEvent07");
1908 // Checks Longpress to start edit mode
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();
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 );
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();
1934 application.ProcessEvent( GenerateLongPress( Gesture::Possible, 1u, Vector2( 1.f, 25.0f ) ) );
1935 application.ProcessEvent( GenerateLongPress( Gesture::Started, 1u, Vector2( 1.f, 25.0f ) ) );
1937 // Render and notify
1938 application.SendNotification();
1939 application.Render();
1944 int utcDaliTextFieldEvent08(void)
1946 ToolkitTestApplication application;
1947 tet_infoline(" utcDaliTextFieldEvent08");
1949 Dali::Clipboard clipboard = Clipboard::Get();
1950 clipboard.SetItem("testTextFieldEvent");
1952 // Checks Longpress when only place holder text
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();
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 );
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();
1975 application.ProcessEvent( GenerateLongPress( Gesture::Possible, 1u, Vector2( 1.f, 25.0f ) ) );
1976 application.ProcessEvent( GenerateLongPress( Gesture::Started, 1u, Vector2( 1.f, 25.0f ) ) );
1978 // Render and notify
1979 application.SendNotification();
1980 application.Render();
1982 Wait(application, 500);
1985 application.ProcessEvent( GenerateLongPress( Gesture::Possible, 1u, Vector2( 1.f, 25.0f ) ) );
1986 application.ProcessEvent( GenerateLongPress( Gesture::Started, 1u, Vector2( 1.f, 25.0f ) ) );
1988 // Render and notify
1989 application.SendNotification();
1990 application.Render();
1992 Wait(application, 500);
1994 Stage stage = Stage::GetCurrent();
1995 Layer layer = stage.GetRootLayer();
1996 Actor actor = layer.FindChildByName("optionPaste");
2000 Vector3 worldPosition = actor.GetCurrentWorldPosition();
2001 Vector2 halfStageSize = stage.GetSize() / 2.0f;
2002 Vector2 position(worldPosition.x + halfStageSize.width, worldPosition.y + halfStageSize.height);
2004 Dali::Integration::TouchEvent event;
2005 event = Dali::Integration::TouchEvent();
2006 event.AddPoint( GetPointDownInside( position ) );
2007 application.ProcessEvent( event );
2009 event = Dali::Integration::TouchEvent();
2010 event.AddPoint( GetPointUpInside( position ) );
2011 application.ProcessEvent( event );
2013 DALI_TEST_EQUALS( field.GetProperty<std::string>( TextEditor::Property::TEXT ), std::string("testTextFieldEvent"), TEST_LOCATION );
2018 int utcDaliTextFieldEvent09(void)
2020 ToolkitTestApplication application;
2021 tet_infoline(" utcDaliTextFieldEvent09");
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();
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 );
2037 // Avoid a crash when core load gl resources.
2038 application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
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();
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();
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();
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 )
2065 application.ProcessEvent( GenerateKey( "d", "d", 0, 0, 0, Integration::KeyEvent::Down, DEFAULT_DEVICE_NAME, DevelKeyEvent::DeviceClass::NONE ) );
2066 application.SendNotification();
2067 application.Render();
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 )
2075 application.ProcessEvent( GenerateKey( "d", "d", 0, 0, 0, Integration::KeyEvent::Down, DEFAULT_DEVICE_NAME, DevelKeyEvent::DeviceClass::NONE ) );
2076 application.SendNotification();
2077 application.Render();
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();
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();
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 );
2104 int utcDaliTextFieldStyleWhilstSelected(void)
2106 ToolkitTestApplication application;
2107 tet_infoline(" utcDaliTextFieldStyleWhilstSelected");
2109 // Change font and styles whilst text is selected whilst word selected
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();
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 );
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();
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();
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 ) ) );
2143 // Render and notify
2144 application.SendNotification();
2145 application.Render();
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 ) ) );
2151 // Render and notify
2152 application.SendNotification();
2153 application.Render();
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 );
2158 Property::Map fontStyleMapSet;
2159 Property::Map fontStyleMapGet;
2161 fontStyleMapSet.Insert( "weight", "bold" );
2162 fontStyleMapSet.Insert( "slant", "italic" );
2163 field.SetProperty( TextField::Property::INPUT_FONT_STYLE, fontStyleMapSet );
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 );
2169 fontStyleMapSet.Clear();
2170 fontStyleMapSet.Insert( "width", "expanded" );
2171 fontStyleMapSet.Insert( "slant", "italic" );
2172 field.SetProperty( TextField::Property::INPUT_FONT_STYLE, fontStyleMapSet );
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 );
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 );
2181 field.SetProperty( TextField::Property::TEXT_COLOR, Color::RED );
2182 DALI_TEST_EQUALS( field.GetProperty<Vector4>( TextField::Property::TEXT_COLOR ), Color::RED, TEST_LOCATION );
2184 fontStyleMapSet.Clear();
2185 fontStyleMapSet.Insert( "weight", "bold" );
2186 fontStyleMapSet.Insert( "slant", "italic" );
2188 field.SetProperty( TextField::Property::FONT_STYLE, fontStyleMapSet );
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 );
2194 fontStyleMapSet.Clear();
2195 fontStyleMapSet.Insert( "width", "expanded" );
2197 field.SetProperty( TextField::Property::FONT_STYLE, fontStyleMapSet );
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 );
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();
2208 DALI_TEST_CHECK( !field.HasKeyInputFocus() );
2213 int utcDaliTextFieldEscKeyLoseFocus(void)
2215 ToolkitTestApplication application;
2216 tet_infoline(" utcDaliTextFieldEscKeyLoseFocus");
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.
2221 TextField field = TextField::New();
2222 DALI_TEST_CHECK( field );
2224 Stage::GetCurrent().Add( field );
2226 field.SetSize( 300.f, 50.f );
2227 field.SetParentOrigin( ParentOrigin::TOP_LEFT );
2228 field.SetAnchorPoint( AnchorPoint::TOP_LEFT );
2230 // Avoid a crash when core load gl resources.
2231 application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
2233 // Render and notify
2234 application.SendNotification();
2235 application.Render();
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 ) );
2241 // Render and notify
2242 application.SendNotification();
2243 application.Render();
2245 DALI_TEST_EQUALS( field.GetProperty<std::string>( TextField::Property::TEXT ), std::string(""), TEST_LOCATION );
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 ) ) );
2251 // Render and notify
2252 application.SendNotification();
2253 application.Render();
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 ) );
2261 // Render and notify
2262 application.SendNotification();
2263 application.Render();
2265 DALI_TEST_EQUALS( field.GetProperty<std::string>( TextField::Property::TEXT ), std::string("ad"), TEST_LOCATION );
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 ) );
2271 // Render and notify
2272 application.SendNotification();
2273 application.Render();
2275 DALI_TEST_EQUALS( false, field.HasKeyInputFocus(), TEST_LOCATION );
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 ) );
2281 // Render and notify
2282 application.SendNotification();
2283 application.Render();
2285 DALI_TEST_EQUALS( field.GetProperty<std::string>( TextField::Property::TEXT ), std::string("ad"), TEST_LOCATION );
2290 int utcDaliTextFieldSomeSpecialKeys(void)
2292 ToolkitTestApplication application;
2293 tet_infoline(" utcDaliTextFieldSomeSpecialKeys");
2295 // Checks some special keys when the text is selected.
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();
2305 const std::string longText( "This is a long text for the size of the text-field." );
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 );
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();
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 ) ) );
2323 // Render and notify
2324 application.SendNotification();
2325 application.Render();
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 ) ) );
2331 // Render and notify
2332 application.SendNotification();
2333 application.Render();
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 ) ) );
2339 // Render and notify
2340 application.SendNotification();
2341 application.Render();
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 ) );
2347 // Render and notify
2348 application.SendNotification();
2349 application.Render();
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 ) );
2355 // Render and notify
2356 application.SendNotification();
2357 application.Render();
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 ) );
2363 // Render and notify
2364 application.SendNotification();
2365 application.Render();
2367 // The text shouldn't be deleted.
2368 DALI_TEST_EQUALS( field.GetProperty<std::string>( TextField::Property::TEXT ), longText, TEST_LOCATION );