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";
101 const char* const PROPERTY_NAME_ENABLE_SELECTION = "enableSelection";
103 const int DEFAULT_RENDERING_BACKEND = Dali::Toolkit::Text::DEFAULT_RENDERING_BACKEND;
105 const Vector4 PLACEHOLDER_TEXT_COLOR( 0.8f, 0.8f, 0.8f, 0.8f );
106 const Dali::Vector4 LIGHT_BLUE( 0.75f, 0.96f, 1.f, 1.f ); // The text highlight color.
108 const unsigned int CURSOR_BLINK_INTERVAL = 500u; // Cursor blink interval
109 const float RENDER_FRAME_INTERVAL = 16.66f;
111 const float TO_MILLISECONDS = 1000.f;
112 const float TO_SECONDS = 1.f / TO_MILLISECONDS;
114 const float SCROLL_THRESHOLD = 10.f;
115 const float SCROLL_SPEED = 300.f;
117 const unsigned int DEFAULT_FONT_SIZE = 1152u;
118 const std::string DEFAULT_FONT_DIR( "/resources/fonts" );
120 const int KEY_A_CODE = 38;
121 const int KEY_D_CODE = 40;
123 const std::string DEFAULT_DEVICE_NAME("hwKeyboard");
125 static bool gTextChangedCallBackCalled;
126 static bool gMaxCharactersCallBackCalled;
127 static bool gInputStyleChangedCallbackCalled;
128 static Dali::Toolkit::TextField::InputStyle::Mask gInputStyleMask;
130 static void LoadBitmapResource(TestPlatformAbstraction& platform, int width, int height)
132 Integration::Bitmap* bitmap = Integration::Bitmap::New( Integration::Bitmap::BITMAP_2D_PACKED_PIXELS, ResourcePolicy::OWNED_DISCARD );
133 Integration::ResourcePointer resource(bitmap);
134 bitmap->GetPackedPixelsProfile()->ReserveBuffer(Pixel::RGBA8888, width, height, width, height);
137 static void LoadMarkerImages(ToolkitTestApplication& app, TextField textField)
141 LoadBitmapResource( app.GetPlatform(), width, height );
143 Property::Map propertyMap;
144 propertyMap["filename"] = "image.png";
145 propertyMap["width"] = width;
146 propertyMap["height"] = height;
147 textField.SetProperty( Toolkit::TextField::Property::SELECTION_HANDLE_IMAGE_LEFT, propertyMap );
148 textField.SetProperty( Toolkit::TextField::Property::SELECTION_HANDLE_IMAGE_RIGHT, propertyMap );
149 textField.SetProperty( Toolkit::TextField::Property::SELECTION_HANDLE_PRESSED_IMAGE_LEFT, propertyMap );
150 textField.SetProperty( Toolkit::TextField::Property::SELECTION_HANDLE_PRESSED_IMAGE_RIGHT, propertyMap );
151 textField.SetProperty( Toolkit::TextField::Property::SELECTION_HANDLE_MARKER_IMAGE_LEFT, propertyMap );
152 textField.SetProperty( Toolkit::TextField::Property::SELECTION_HANDLE_MARKER_IMAGE_RIGHT, propertyMap );
153 textField.SetProperty( Toolkit::TextField::Property::GRAB_HANDLE_IMAGE, propertyMap );
154 textField.SetProperty( Toolkit::TextField::Property::GRAB_HANDLE_PRESSED_IMAGE, propertyMap );
157 // Generate a PanGestureEvent to send to Core
158 static Integration::PanGestureEvent GeneratePan(
159 Gesture::State state,
160 const Vector2& previousPosition,
161 const Vector2& currentPosition,
162 unsigned long timeDelta,
163 unsigned int numberOfTouches = 1)
165 Integration::PanGestureEvent pan(state);
167 pan.previousPosition = previousPosition;
168 pan.currentPosition = currentPosition;
169 pan.timeDelta = timeDelta;
170 pan.numberOfTouches = numberOfTouches;
176 * Helper to generate PanGestureEvent
178 * @param[in] application Application instance
179 * @param[in] state The Gesture State
180 * @param[in] pos The current position of touch.
182 static void SendPan(ToolkitTestApplication& application, Gesture::State state, const Vector2& pos)
186 if( (state == Gesture::Started) ||
187 (state == Gesture::Possible) )
193 application.ProcessEvent(GeneratePan(state, last, pos, 16));
200 * Simulate time passed by.
202 * @note this will always process at least 1 frame (1/60 sec)
204 * @param application Test application instance
205 * @param duration Time to pass in milliseconds.
206 * @return The actual time passed in milliseconds
208 static int Wait(ToolkitTestApplication& application, int duration = 0)
212 for(int i = 0; i <= ( duration / RENDER_FRAME_INTERVAL); i++)
214 application.SendNotification();
215 application.Render(RENDER_FRAME_INTERVAL);
216 time += RENDER_FRAME_INTERVAL;
222 Dali::Integration::Point GetPointDownInside( Vector2& pos )
224 Dali::Integration::Point point;
225 point.SetState( PointState::DOWN );
226 point.SetScreenPosition( pos );
230 Dali::Integration::Point GetPointUpInside( Vector2& pos )
232 Dali::Integration::Point point;
233 point.SetState( PointState::UP );
234 point.SetScreenPosition( pos );
238 struct CallbackFunctor
240 CallbackFunctor(bool* callbackFlag)
241 : mCallbackFlag( callbackFlag )
247 *mCallbackFlag = true;
252 static void TestTextChangedCallback( TextField control )
254 tet_infoline(" TestTextChangedCallback");
256 gTextChangedCallBackCalled = true;
259 static void TestMaxLengthReachedCallback( TextField control )
261 tet_infoline(" TestMaxLengthReachedCallback");
263 gMaxCharactersCallBackCalled = true;
266 static void TestInputStyleChangedCallback( TextField control, TextField::InputStyle::Mask mask )
268 tet_infoline(" TestInputStyleChangedCallback");
270 gInputStyleChangedCallbackCalled = true;
271 gInputStyleMask = mask;
274 // Generate a TapGestureEvent to send to Core.
275 Integration::TapGestureEvent GenerateTap(
276 Gesture::State state,
277 unsigned int numberOfTaps,
278 unsigned int numberOfTouches,
281 Integration::TapGestureEvent tap( state );
283 tap.numberOfTaps = numberOfTaps;
284 tap.numberOfTouches = numberOfTouches;
290 Integration::LongPressGestureEvent GenerateLongPress(
291 Gesture::State state,
292 unsigned int numberOfTouches,
295 Integration::LongPressGestureEvent longPress( state );
297 longPress.numberOfTouches = numberOfTouches;
298 longPress.point = point;
302 // Generate a KeyEvent to send to Core.
303 Integration::KeyEvent GenerateKey( const std::string& keyName,
304 const std::string& keyString,
307 unsigned long timeStamp,
308 const Integration::KeyEvent::State& keyState,
309 const std::string& deviceName,
310 const DevelKeyEvent::DeviceClass::Type& deviceClass )
312 return Integration::KeyEvent( keyName,
322 bool DaliTestCheckMaps( const Property::Map& fontStyleMapGet, const Property::Map& fontStyleMapSet )
324 if( fontStyleMapGet.Count() == fontStyleMapSet.Count() )
326 for( unsigned int index = 0u; index < fontStyleMapGet.Count(); ++index )
328 const KeyValuePair& valueGet = fontStyleMapGet.GetKeyValue( index );
330 if( valueGet.first.type == Property::Key::STRING )
332 Property::Value* valueSet = fontStyleMapSet.Find( valueGet.first.stringKey );
333 if( NULL != valueSet )
335 if( valueGet.second.Get<std::string>() != valueSet->Get<std::string>() )
337 tet_printf( " Value got : [%s], expected : [%s]", valueGet.second.Get<std::string>().c_str(), valueSet->Get<std::string>().c_str() );
343 tet_printf( " The key %s doesn't exist.", valueGet.first.stringKey.c_str() );
349 Property::Value* valueSet = fontStyleMapSet.Find( valueGet.first.indexKey );
350 if( NULL != valueSet )
352 if( valueGet.second.Get<int>() != valueSet->Get<int>() )
354 tet_printf( " Integer Value got : [%d], expected : [%d]", valueGet.second.Get<int>(), valueSet->Get<int>() );
360 tet_printf( " The Int key %d doesn't exist.", valueGet.first.indexKey );
372 int UtcDaliToolkitTextFieldConstructorP(void)
374 ToolkitTestApplication application;
375 tet_infoline(" UtcDaliToolkitTextFieldConstructorP");
377 DALI_TEST_CHECK( !textField );
381 int UtcDaliToolkitTextFieldNewP(void)
383 ToolkitTestApplication application;
384 tet_infoline(" UtcDaliToolkitTextFieldNewP");
385 TextField textField = TextField::New();
386 DALI_TEST_CHECK( textField );
390 int UtcDaliToolkitTextFieldDownCastP(void)
392 ToolkitTestApplication application;
393 tet_infoline(" UtcDaliToolkitTextFieldDownCastP");
394 TextField textField1 = TextField::New();
395 BaseHandle object( textField1 );
397 TextField textField2 = TextField::DownCast( object );
398 DALI_TEST_CHECK( textField2 );
400 TextField textField3 = DownCast< TextField >( object );
401 DALI_TEST_CHECK( textField3 );
405 int UtcDaliToolkitTextFieldDownCastN(void)
407 ToolkitTestApplication application;
408 tet_infoline(" UtcDaliToolkitTextFieldDownCastN");
409 BaseHandle uninitializedObject;
410 TextField textField1 = TextField::DownCast( uninitializedObject );
411 DALI_TEST_CHECK( !textField1 );
413 TextField textField2 = DownCast< TextField >( uninitializedObject );
414 DALI_TEST_CHECK( !textField2 );
418 int UtcDaliToolkitTextFieldCopyConstructorP(void)
420 ToolkitTestApplication application;
421 tet_infoline(" UtcDaliToolkitTextFieldCopyConstructorP");
422 TextField textField = TextField::New();
423 textField.SetProperty( TextField::Property::TEXT, "Test" );
425 TextField copy( textField );
426 DALI_TEST_CHECK( copy );
427 DALI_TEST_CHECK( copy.GetProperty<std::string>( TextLabel::Property::TEXT ) == textField.GetProperty<std::string>( TextLabel::Property::TEXT ) );
431 int UtcDaliToolkitTextFieldAssignmentOperatorP(void)
433 ToolkitTestApplication application;
434 tet_infoline(" UtcDaliToolkitTextFieldAssignmentOperatorP");
435 TextField textField = TextField::New();
436 textField.SetProperty( TextField::Property::TEXT, "Test" );
438 TextField copy = textField;
439 DALI_TEST_CHECK( copy );
440 DALI_TEST_CHECK( copy.GetProperty<std::string>( TextField::Property::TEXT ) == textField.GetProperty<std::string>( TextField::Property::TEXT ) );
444 int UtcDaliTextFieldNewP(void)
446 ToolkitTestApplication application;
447 tet_infoline(" UtcDaliToolkitTextFieldNewP");
448 TextField textField = TextField::New();
449 DALI_TEST_CHECK( textField );
453 // Positive test case for a method
454 int UtcDaliTextFieldGetPropertyP(void)
456 ToolkitTestApplication application;
457 tet_infoline(" UtcDaliToolkitTextFieldGetPropertyP");
458 TextField field = TextField::New();
459 DALI_TEST_CHECK( field );
461 // Check Property Indices are correct
462 DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_RENDERING_BACKEND ) == TextField::Property::RENDERING_BACKEND );
463 DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_TEXT ) == TextField::Property::TEXT );
464 DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_PLACEHOLDER_TEXT ) == TextField::Property::PLACEHOLDER_TEXT );
465 DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_PLACEHOLDER_TEXT_FOCUSED ) == TextField::Property::PLACEHOLDER_TEXT_FOCUSED );
466 DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_FONT_FAMILY ) == TextField::Property::FONT_FAMILY );
467 DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_FONT_STYLE ) == TextField::Property::FONT_STYLE );
468 DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_POINT_SIZE ) == TextField::Property::POINT_SIZE );
469 DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_MAX_LENGTH ) == TextField::Property::MAX_LENGTH );
470 DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_EXCEED_POLICY ) == TextField::Property::EXCEED_POLICY );
471 DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_HORIZONTAL_ALIGNMENT ) == TextField::Property::HORIZONTAL_ALIGNMENT );
472 DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_VERTICAL_ALIGNMENT ) == TextField::Property::VERTICAL_ALIGNMENT );
473 DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_TEXT_COLOR ) == TextField::Property::TEXT_COLOR );
474 DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_PLACEHOLDER_TEXT_COLOR ) == TextField::Property::PLACEHOLDER_TEXT_COLOR );
475 DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_SHADOW_OFFSET ) == TextField::Property::SHADOW_OFFSET );
476 DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_SHADOW_COLOR ) == TextField::Property::SHADOW_COLOR );
477 DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_PRIMARY_CURSOR_COLOR ) == TextField::Property::PRIMARY_CURSOR_COLOR );
478 DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_SECONDARY_CURSOR_COLOR ) == TextField::Property::SECONDARY_CURSOR_COLOR );
479 DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_ENABLE_CURSOR_BLINK ) == TextField::Property::ENABLE_CURSOR_BLINK );
480 DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_CURSOR_BLINK_INTERVAL ) == TextField::Property::CURSOR_BLINK_INTERVAL );
481 DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_CURSOR_BLINK_DURATION ) == TextField::Property::CURSOR_BLINK_DURATION );
482 DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_CURSOR_WIDTH ) == TextField::Property::CURSOR_WIDTH );
483 DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_GRAB_HANDLE_IMAGE ) == TextField::Property::GRAB_HANDLE_IMAGE );
484 DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_GRAB_HANDLE_PRESSED_IMAGE ) == TextField::Property::GRAB_HANDLE_PRESSED_IMAGE );
485 DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_SCROLL_THRESHOLD ) == TextField::Property::SCROLL_THRESHOLD );
486 DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_SCROLL_SPEED ) == TextField::Property::SCROLL_SPEED );
487 DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_SELECTION_HANDLE_IMAGE_LEFT ) == TextField::Property::SELECTION_HANDLE_IMAGE_LEFT );
488 DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_SELECTION_HANDLE_IMAGE_RIGHT ) == TextField::Property::SELECTION_HANDLE_IMAGE_RIGHT );
489 DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_SELECTION_HANDLE_PRESSED_IMAGE_LEFT ) == TextField::Property::SELECTION_HANDLE_PRESSED_IMAGE_LEFT );
490 DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_SELECTION_HANDLE_PRESSED_IMAGE_RIGHT ) == TextField::Property::SELECTION_HANDLE_PRESSED_IMAGE_RIGHT );
491 DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_SELECTION_HANDLE_MARKER_IMAGE_LEFT ) == TextField::Property::SELECTION_HANDLE_MARKER_IMAGE_LEFT );
492 DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_SELECTION_HANDLE_MARKER_IMAGE_RIGHT ) == TextField::Property::SELECTION_HANDLE_MARKER_IMAGE_RIGHT );
493 DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_SELECTION_HIGHLIGHT_COLOR ) == TextField::Property::SELECTION_HIGHLIGHT_COLOR );
494 DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_DECORATION_BOUNDING_BOX ) == TextField::Property::DECORATION_BOUNDING_BOX );
495 DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_INPUT_METHOD_SETTINGS ) == TextField::Property::INPUT_METHOD_SETTINGS );
496 DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_INPUT_COLOR ) == TextField::Property::INPUT_COLOR );
497 DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_ENABLE_MARKUP ) == TextField::Property::ENABLE_MARKUP );
498 DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_INPUT_FONT_FAMILY ) == TextField::Property::INPUT_FONT_FAMILY );
499 DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_INPUT_FONT_STYLE ) == TextField::Property::INPUT_FONT_STYLE );
500 DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_INPUT_POINT_SIZE ) == TextField::Property::INPUT_POINT_SIZE );
501 DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_UNDERLINE ) == TextField::Property::UNDERLINE );
502 DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_INPUT_UNDERLINE ) == TextField::Property::INPUT_UNDERLINE );
503 DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_SHADOW ) == TextField::Property::SHADOW );
504 DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_INPUT_SHADOW ) == TextField::Property::INPUT_SHADOW );
505 DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_EMBOSS ) == TextField::Property::EMBOSS );
506 DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_INPUT_EMBOSS ) == TextField::Property::INPUT_EMBOSS );
507 DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_OUTLINE ) == TextField::Property::OUTLINE );
508 DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_INPUT_OUTLINE ) == TextField::Property::INPUT_OUTLINE );
509 DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_HIDDEN_INPUT_SETTINGS ) == DevelTextField::Property::HIDDEN_INPUT_SETTINGS );
510 DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_PIXEL_SIZE ) == DevelTextField::Property::PIXEL_SIZE );
511 DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_ENABLE_SELECTION ) == DevelTextField::Property::ENABLE_SELECTION );
516 bool SetPropertyMapRetrieved( TextField& field, const Property::Index property, const std::string mapKey, const std::string mapValue )
519 Property::Map imageMap;
520 imageMap[mapKey] =mapValue;
522 field.SetProperty( property , imageMap );
523 Property::Value propValue = field.GetProperty( property );
524 Property::Map* resultMap = propValue.GetMap();
526 if ( resultMap->Find( mapKey )->Get< std::string>() == mapValue )
534 // Positive test case for a method
535 int UtcDaliTextFieldSetPropertyP(void)
537 ToolkitTestApplication application;
538 tet_infoline(" UtcDaliToolkitTextFieldSetPropertyP");
539 TextField field = TextField::New();
540 DALI_TEST_CHECK( field );
541 Stage::GetCurrent().Add( field );
543 // Note - we can't check the defaults since the stylesheets are platform-specific
545 // Check the render backend property.
546 field.SetProperty( TextField::Property::RENDERING_BACKEND, Text::RENDERING_SHARED_ATLAS );
547 DALI_TEST_EQUALS( (Text::RenderingType)field.GetProperty<int>( TextField::Property::RENDERING_BACKEND ), Text::RENDERING_SHARED_ATLAS, TEST_LOCATION );
549 // Check text property.
550 field.SetProperty( TextField::Property::TEXT, "Setting Text" );
551 DALI_TEST_EQUALS( field.GetProperty<std::string>( TextField::Property::TEXT ), std::string("Setting Text"), TEST_LOCATION );
553 // Check placeholder text properties.
554 field.SetProperty( TextField::Property::PLACEHOLDER_TEXT, "Setting Placeholder Text" );
555 DALI_TEST_EQUALS( field.GetProperty<std::string>( TextField::Property::PLACEHOLDER_TEXT ), std::string("Setting Placeholder Text"), TEST_LOCATION );
557 field.SetProperty( TextField::Property::PLACEHOLDER_TEXT_FOCUSED, "Setting Placeholder Text Focused" );
558 DALI_TEST_EQUALS( field.GetProperty<std::string>( TextField::Property::PLACEHOLDER_TEXT_FOCUSED ), std::string("Setting Placeholder Text Focused"), TEST_LOCATION );
560 // Check font properties.
561 field.SetProperty( TextField::Property::FONT_FAMILY, "Setting font family" );
562 DALI_TEST_EQUALS( field.GetProperty<std::string>( TextField::Property::FONT_FAMILY ), std::string("Setting font family"), TEST_LOCATION );
564 Property::Map fontStyleMapSet;
565 Property::Map fontStyleMapGet;
566 Property::Value* slantValue = NULL;
568 fontStyleMapSet.Insert( "weight", "bold" );
569 fontStyleMapSet.Insert( "width", "condensed" );
570 fontStyleMapSet.Insert( "slant", "italic" );
571 field.SetProperty( TextField::Property::FONT_STYLE, fontStyleMapSet );
573 fontStyleMapGet = field.GetProperty<Property::Map>( TextField::Property::FONT_STYLE );
574 DALI_TEST_EQUALS( fontStyleMapGet.Count(), fontStyleMapSet.Count(), TEST_LOCATION );
575 DALI_TEST_EQUALS( DaliTestCheckMaps( fontStyleMapGet, fontStyleMapSet ), true, TEST_LOCATION );
577 field.SetProperty( TextField::Property::POINT_SIZE, 10.f );
578 DALI_TEST_EQUALS( field.GetProperty<float>( TextField::Property::POINT_SIZE ), 10.f, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
581 fontStyleMapSet.Clear();
582 fontStyleMapSet.Insert( "weight", "normal" );
583 fontStyleMapSet.Insert( "slant", "oblique" );
584 field.SetProperty( TextField::Property::FONT_STYLE, fontStyleMapSet );
586 fontStyleMapGet = field.GetProperty<Property::Map>( TextField::Property::FONT_STYLE );
587 DALI_TEST_EQUALS( fontStyleMapGet.Count(), fontStyleMapSet.Count(), TEST_LOCATION );
588 DALI_TEST_EQUALS( DaliTestCheckMaps( fontStyleMapGet, fontStyleMapSet ), true, TEST_LOCATION );
590 fontStyleMapSet.Clear();
591 fontStyleMapSet.Insert( "slant", "roman" );
592 field.SetProperty( TextField::Property::FONT_STYLE, fontStyleMapSet );
593 fontStyleMapGet = field.GetProperty<Property::Map>( TextField::Property::FONT_STYLE );
595 // Replace 'roman' for 'normal'.
596 slantValue = fontStyleMapGet.Find( "slant" );
597 if( NULL != slantValue )
599 if( "normal" == slantValue->Get<std::string>() )
601 fontStyleMapGet["slant"] = "roman";
604 DALI_TEST_EQUALS( fontStyleMapGet.Count(), fontStyleMapSet.Count(), TEST_LOCATION );
605 DALI_TEST_EQUALS( DaliTestCheckMaps( fontStyleMapGet, fontStyleMapSet ), true, TEST_LOCATION );
607 fontStyleMapSet.Clear();
609 field.SetProperty( TextField::Property::FONT_STYLE, fontStyleMapSet );
610 fontStyleMapGet = field.GetProperty<Property::Map>( TextField::Property::FONT_STYLE );
611 DALI_TEST_EQUALS( fontStyleMapGet.Count(), fontStyleMapSet.Count(), TEST_LOCATION );
612 DALI_TEST_EQUALS( DaliTestCheckMaps( fontStyleMapGet, fontStyleMapSet ), true, TEST_LOCATION );
614 // Check that the MAX_LENGTH property can be correctly set
615 const int maxNumberOfCharacters = 20;
616 field.SetProperty( TextField::Property::MAX_LENGTH, maxNumberOfCharacters );
617 DALI_TEST_EQUALS( field.GetProperty<int>( TextField::Property::MAX_LENGTH ), maxNumberOfCharacters, TEST_LOCATION );
619 // Check exceed policy
620 field.SetProperty( TextField::Property::EXCEED_POLICY, Dali::Toolkit::TextField::EXCEED_POLICY_CLIP );
621 DALI_TEST_EQUALS( field.GetProperty<int>( TextField::Property::EXCEED_POLICY ), static_cast<int>( Dali::Toolkit::TextField::EXCEED_POLICY_CLIP ), TEST_LOCATION );
622 field.SetProperty( TextField::Property::EXCEED_POLICY, Dali::Toolkit::TextField::EXCEED_POLICY_ORIGINAL );
623 DALI_TEST_EQUALS( field.GetProperty<int>( TextField::Property::EXCEED_POLICY ), static_cast<int>( Dali::Toolkit::TextField::EXCEED_POLICY_ORIGINAL ), TEST_LOCATION );
625 // Check that the Alignment properties can be correctly set
626 field.SetProperty( TextField::Property::HORIZONTAL_ALIGNMENT, "END" );
627 DALI_TEST_EQUALS( field.GetProperty<std::string>( TextField::Property::HORIZONTAL_ALIGNMENT ), "END", TEST_LOCATION );
628 field.SetProperty( TextField::Property::VERTICAL_ALIGNMENT, "CENTER" );
629 DALI_TEST_EQUALS( field.GetProperty<std::string>( TextField::Property::VERTICAL_ALIGNMENT ), "CENTER", TEST_LOCATION );
631 // Check text's color property
632 field.SetProperty( TextField::Property::TEXT_COLOR, Color::WHITE );
633 DALI_TEST_EQUALS( field.GetProperty<Vector4>( TextField::Property::TEXT_COLOR ), Color::WHITE, TEST_LOCATION );
635 // Check placeholder text's color property.
636 field.SetProperty( TextField::Property::PLACEHOLDER_TEXT_COLOR, Color::RED );
637 DALI_TEST_EQUALS( field.GetProperty<Vector4>( TextField::Property::PLACEHOLDER_TEXT_COLOR ), Color::RED, TEST_LOCATION );
639 // Check shadow properties.
640 field.SetProperty( TextField::Property::SHADOW_OFFSET, Vector2( 1.f, 1.f ) );
641 DALI_TEST_EQUALS( field.GetProperty<Vector2>( TextField::Property::SHADOW_OFFSET ), Vector2( 1.f, 1.f ), TEST_LOCATION );
642 field.SetProperty( TextField::Property::SHADOW_COLOR, Color::GREEN );
643 DALI_TEST_EQUALS( field.GetProperty<Vector4>( TextField::Property::SHADOW_COLOR ), Color::GREEN, TEST_LOCATION );
645 // Check cursor properties
646 field.SetProperty( TextField::Property::PRIMARY_CURSOR_COLOR, Color::RED );
647 DALI_TEST_EQUALS( field.GetProperty<Vector4>( TextField::Property::PRIMARY_CURSOR_COLOR ), Color::RED, TEST_LOCATION );
648 field.SetProperty( TextField::Property::SECONDARY_CURSOR_COLOR, Color::BLUE );
649 DALI_TEST_EQUALS( field.GetProperty<Vector4>( TextField::Property::SECONDARY_CURSOR_COLOR ), Color::BLUE, TEST_LOCATION );
651 field.SetProperty( TextField::Property::ENABLE_CURSOR_BLINK, false );
652 DALI_TEST_EQUALS( field.GetProperty<bool>( TextField::Property::ENABLE_CURSOR_BLINK ), false, TEST_LOCATION );
653 field.SetProperty( TextField::Property::CURSOR_BLINK_INTERVAL, 1.f );
654 DALI_TEST_EQUALS( field.GetProperty<float>( TextField::Property::CURSOR_BLINK_INTERVAL ), 1.f, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
655 field.SetProperty( TextField::Property::CURSOR_BLINK_DURATION, 10.f );
656 DALI_TEST_EQUALS( field.GetProperty<float>( TextField::Property::CURSOR_BLINK_DURATION ), 10.f, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
657 field.SetProperty( TextField::Property::CURSOR_WIDTH, 1 );
658 DALI_TEST_EQUALS( field.GetProperty<int>( TextField::Property::CURSOR_WIDTH ), 1, TEST_LOCATION );
660 // Check scroll properties.
661 field.SetProperty( TextField::Property::SCROLL_THRESHOLD, 1.f );
662 DALI_TEST_EQUALS( field.GetProperty<float>( TextField::Property::SCROLL_THRESHOLD ), 1.f, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
663 field.SetProperty( TextField::Property::SCROLL_SPEED, 100.f );
664 DALI_TEST_EQUALS( field.GetProperty<float>( TextField::Property::SCROLL_SPEED ), 100.f, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
666 // Check handle images
667 field.SetProperty( TextField::Property::GRAB_HANDLE_IMAGE, "image1" );
668 DALI_TEST_EQUALS( field.GetProperty<std::string>( TextField::Property::GRAB_HANDLE_IMAGE ), "image1", TEST_LOCATION );
669 field.SetProperty( TextField::Property::GRAB_HANDLE_PRESSED_IMAGE, "image2" );
670 DALI_TEST_EQUALS( field.GetProperty<std::string>( TextField::Property::GRAB_HANDLE_PRESSED_IMAGE ), "image2", TEST_LOCATION );
671 field.SetProperty( TextField::Property::SELECTION_HANDLE_IMAGE_LEFT, "image3" );
673 // Check handle images
674 DALI_TEST_CHECK( SetPropertyMapRetrieved( field, TextField::Property::SELECTION_HANDLE_IMAGE_LEFT, "filename", "leftHandleImage" ) );
675 DALI_TEST_CHECK( SetPropertyMapRetrieved( field, TextField::Property::SELECTION_HANDLE_IMAGE_RIGHT, "filename", "rightHandleImage" ) );
676 DALI_TEST_CHECK( SetPropertyMapRetrieved( field, TextField::Property::SELECTION_HANDLE_PRESSED_IMAGE_LEFT, "filename", "leftHandleImagePressed" ) );
677 DALI_TEST_CHECK( SetPropertyMapRetrieved( field, TextField::Property::SELECTION_HANDLE_PRESSED_IMAGE_RIGHT, "filename", "rightHandleImagePressed" ) );
678 DALI_TEST_CHECK( SetPropertyMapRetrieved( field, TextField::Property::SELECTION_HANDLE_MARKER_IMAGE_LEFT, "filename", "leftHandleMarkerImage" ) );
679 DALI_TEST_CHECK( SetPropertyMapRetrieved( field, TextField::Property::SELECTION_HANDLE_MARKER_IMAGE_RIGHT, "filename", "rightHandleMarkerImage" ) );
681 // Check the highlight color
682 field.SetProperty( TextField::Property::SELECTION_HIGHLIGHT_COLOR, Color::GREEN );
683 DALI_TEST_EQUALS( field.GetProperty<Vector4>( TextField::Property::SELECTION_HIGHLIGHT_COLOR ), Color::GREEN, TEST_LOCATION );
685 // Decoration bounding box
686 field.SetProperty( TextField::Property::DECORATION_BOUNDING_BOX, Rect<int>( 0, 0, 1, 1 ) );
687 DALI_TEST_EQUALS( field.GetProperty<Rect <int > >( TextField::Property::DECORATION_BOUNDING_BOX ), Rect<int>( 0, 0, 1, 1 ), TEST_LOCATION );
689 // Check the input method setting
690 Property::Map propertyMap;
691 InputMethod::PanelLayout::Type panelLayout = InputMethod::PanelLayout::NUMBER;
692 InputMethod::AutoCapital::Type autoCapital = InputMethod::AutoCapital::WORD;
693 InputMethod::ActionButtonTitle::Type actionButton = InputMethod::ActionButtonTitle::GO;
694 int inputVariation = 1;
695 propertyMap["PANEL_LAYOUT"] = panelLayout;
696 propertyMap["AUTO_CAPITALISE"] = autoCapital;
697 propertyMap["ACTION_BUTTON"] = actionButton;
698 propertyMap["VARIATION"] = inputVariation;
699 field.SetProperty( TextField::Property::INPUT_METHOD_SETTINGS, propertyMap );
701 Property::Value value = field.GetProperty( TextField::Property::INPUT_METHOD_SETTINGS );
703 DALI_TEST_CHECK( value.Get( map ) );
706 DALI_TEST_CHECK( map[ "PANEL_LAYOUT" ].Get( layout ) );
707 DALI_TEST_EQUALS( static_cast<int>(panelLayout), layout, TEST_LOCATION );
710 DALI_TEST_CHECK( map[ "AUTO_CAPITALISE" ].Get( capital ) );
711 DALI_TEST_EQUALS( static_cast<int>(autoCapital), capital, TEST_LOCATION );
714 DALI_TEST_CHECK( map[ "ACTION_BUTTON" ].Get( action ) );
715 DALI_TEST_EQUALS( static_cast<int>(actionButton), action, TEST_LOCATION );
718 DALI_TEST_CHECK( map[ "VARIATION" ].Get( variation ) );
719 DALI_TEST_EQUALS( inputVariation, variation, TEST_LOCATION );
721 // Check input color property.
722 field.SetProperty( TextField::Property::INPUT_COLOR, Color::YELLOW );
723 DALI_TEST_EQUALS( field.GetProperty<Vector4>( TextField::Property::INPUT_COLOR ), Color::YELLOW, TEST_LOCATION );
725 // Check the enable markup property.
726 DALI_TEST_CHECK( !field.GetProperty<bool>( TextField::Property::ENABLE_MARKUP ) );
727 field.SetProperty( TextField::Property::ENABLE_MARKUP, true );
728 DALI_TEST_CHECK( field.GetProperty<bool>( TextField::Property::ENABLE_MARKUP ) );
730 // Check input font properties.
731 field.SetProperty( TextField::Property::INPUT_FONT_FAMILY, "Setting input font family" );
732 DALI_TEST_EQUALS( field.GetProperty<std::string>( TextField::Property::INPUT_FONT_FAMILY ), "Setting input font family", TEST_LOCATION );
734 fontStyleMapSet.Clear();
735 fontStyleMapSet.Insert( "weight", "bold" );
736 fontStyleMapSet.Insert( "width", "condensed" );
737 fontStyleMapSet.Insert( "slant", "italic" );
739 field.SetProperty( TextField::Property::INPUT_FONT_STYLE, fontStyleMapSet );
740 fontStyleMapGet = field.GetProperty<Property::Map>( TextField::Property::INPUT_FONT_STYLE );
741 DALI_TEST_EQUALS( fontStyleMapGet.Count(), fontStyleMapSet.Count(), TEST_LOCATION );
742 DALI_TEST_EQUALS( DaliTestCheckMaps( fontStyleMapGet, fontStyleMapSet ), true, TEST_LOCATION );
744 field.SetProperty( TextField::Property::INPUT_POINT_SIZE, 12.f );
745 DALI_TEST_EQUALS( field.GetProperty<float>( TextField::Property::INPUT_POINT_SIZE ), 12.f, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
747 // Reset input font style.
748 fontStyleMapSet.Clear();
749 fontStyleMapSet.Insert( "weight", "normal" );
750 fontStyleMapSet.Insert( "slant", "oblique" );
752 field.SetProperty( TextField::Property::INPUT_FONT_STYLE, fontStyleMapSet );
753 fontStyleMapGet = field.GetProperty<Property::Map>( TextField::Property::INPUT_FONT_STYLE );
754 DALI_TEST_EQUALS( fontStyleMapGet.Count(), fontStyleMapSet.Count(), TEST_LOCATION );
755 DALI_TEST_EQUALS( DaliTestCheckMaps( fontStyleMapGet, fontStyleMapSet ), true, TEST_LOCATION );
757 fontStyleMapSet.Clear();
758 fontStyleMapSet.Insert( "slant", "roman" );
760 field.SetProperty( TextField::Property::INPUT_FONT_STYLE, fontStyleMapSet );
761 fontStyleMapGet = field.GetProperty<Property::Map>( TextField::Property::INPUT_FONT_STYLE );
763 // Replace 'roman' for 'normal'.
764 slantValue = fontStyleMapGet.Find( "slant" );
765 if( NULL != slantValue )
767 if( "normal" == slantValue->Get<std::string>() )
769 fontStyleMapGet["slant"] = "roman";
772 DALI_TEST_EQUALS( fontStyleMapGet.Count(), fontStyleMapSet.Count(), TEST_LOCATION );
773 DALI_TEST_EQUALS( DaliTestCheckMaps( fontStyleMapGet, fontStyleMapSet ), true, TEST_LOCATION );
775 fontStyleMapSet.Clear();
777 field.SetProperty( TextField::Property::INPUT_FONT_STYLE, fontStyleMapSet );
778 fontStyleMapGet = field.GetProperty<Property::Map>( TextField::Property::INPUT_FONT_STYLE );
779 DALI_TEST_EQUALS( fontStyleMapGet.Count(), fontStyleMapSet.Count(), TEST_LOCATION );
780 DALI_TEST_EQUALS( DaliTestCheckMaps( fontStyleMapGet, fontStyleMapSet ), true, TEST_LOCATION );
782 Property::Map underlineMapSet;
783 Property::Map underlineMapGet;
785 underlineMapSet.Insert( "enable", "true" );
786 underlineMapSet.Insert( "color", "red" );
787 underlineMapSet.Insert( "height", "1" );
789 // Check the underline property
790 field.SetProperty( TextField::Property::UNDERLINE, underlineMapSet );
792 underlineMapGet = field.GetProperty<Property::Map>( TextField::Property::UNDERLINE );
793 DALI_TEST_EQUALS( underlineMapGet.Count(), underlineMapSet.Count(), TEST_LOCATION );
794 DALI_TEST_EQUALS( DaliTestCheckMaps( underlineMapGet, underlineMapSet ), true, TEST_LOCATION );
796 // Check the input underline property
797 field.SetProperty( TextField::Property::INPUT_UNDERLINE, "Underline input properties" );
798 DALI_TEST_EQUALS( field.GetProperty<std::string>( TextField::Property::INPUT_UNDERLINE ), std::string("Underline input properties"), TEST_LOCATION );
800 // Check the shadow property
801 Property::Map shadowMapSet;
802 Property::Map shadowMapGet;
804 shadowMapSet.Insert( "color", "green" );
805 shadowMapSet.Insert( "offset", "2 2" );
807 field.SetProperty( TextField::Property::SHADOW, shadowMapSet );
809 shadowMapGet = field.GetProperty<Property::Map>( TextField::Property::SHADOW );
810 DALI_TEST_EQUALS( shadowMapGet.Count(), shadowMapSet.Count(), TEST_LOCATION );
811 DALI_TEST_EQUALS( DaliTestCheckMaps( shadowMapGet, shadowMapSet ), true, TEST_LOCATION );
813 // Check the input shadow property
814 field.SetProperty( TextField::Property::INPUT_SHADOW, "Shadow input properties" );
815 DALI_TEST_EQUALS( field.GetProperty<std::string>( TextField::Property::INPUT_SHADOW ), std::string("Shadow input properties"), TEST_LOCATION );
817 // Check the emboss property
818 field.SetProperty( TextField::Property::EMBOSS, "Emboss properties" );
819 DALI_TEST_EQUALS( field.GetProperty<std::string>( TextField::Property::EMBOSS ), std::string("Emboss properties"), TEST_LOCATION );
821 // Check the input emboss property
822 field.SetProperty( TextField::Property::INPUT_EMBOSS, "Emboss input properties" );
823 DALI_TEST_EQUALS( field.GetProperty<std::string>( TextField::Property::INPUT_EMBOSS ), std::string("Emboss input properties"), TEST_LOCATION );
825 // Check the outline property
826 field.SetProperty( TextField::Property::OUTLINE, "Outline properties" );
827 DALI_TEST_EQUALS( field.GetProperty<std::string>( TextField::Property::OUTLINE ), std::string("Outline properties"), TEST_LOCATION );
829 // Check the input outline property
830 field.SetProperty( TextField::Property::INPUT_OUTLINE, "Outline input properties" );
831 DALI_TEST_EQUALS( field.GetProperty<std::string>( TextField::Property::INPUT_OUTLINE ), std::string("Outline input properties"), TEST_LOCATION );
833 // Check the hidden input settings property
834 Property::Map hiddenMapSet;
835 Property::Map hiddenMapGet;
836 hiddenMapSet[ HiddenInput::Property::MODE ] = HiddenInput::Mode::HIDE_ALL;
837 hiddenMapSet[ HiddenInput::Property::SHOW_DURATION ] = 2;
838 hiddenMapSet[ HiddenInput::Property::SUBSTITUTE_COUNT ] = 4;
839 hiddenMapSet[ HiddenInput::Property::SUBSTITUTE_CHARACTER ] = 0x23;
840 field.SetProperty( DevelTextField::Property::HIDDEN_INPUT_SETTINGS, hiddenMapSet );
842 hiddenMapGet = field.GetProperty<Property::Map>( DevelTextField::Property::HIDDEN_INPUT_SETTINGS );
843 DALI_TEST_EQUALS( hiddenMapSet.Count(), hiddenMapGet.Count(), TEST_LOCATION );
844 DALI_TEST_EQUALS( DaliTestCheckMaps( hiddenMapSet, hiddenMapGet ), true, TEST_LOCATION );
846 // Check the pixel size of font
847 field.SetProperty( DevelTextField::Property::PIXEL_SIZE, 20.f );
848 DALI_TEST_EQUALS( field.GetProperty<float>( DevelTextField::Property::PIXEL_SIZE ), 20.f, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
850 field.SetProperty( DevelTextField::Property::ENABLE_SELECTION, false );
851 DALI_TEST_EQUALS( field.GetProperty<bool>( DevelTextField::Property::ENABLE_SELECTION ), false, TEST_LOCATION );
856 // Positive Atlas Text Renderer test
857 int utcDaliTextFieldAtlasRenderP(void)
859 ToolkitTestApplication application;
860 tet_infoline(" UtcDaliToolkitTextFieldAtlasRenderP");
861 StyleManager styleManager = StyleManager::Get();
862 styleManager.ApplyDefaultTheme();
863 TextField field = TextField::New();
864 DALI_TEST_CHECK( field );
866 field.SetProperty( TextField::Property::HORIZONTAL_ALIGNMENT, "CENTER" );
868 application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
870 Stage::GetCurrent().Add( field );
874 // Render some text with the shared atlas backend
875 field.SetProperty( TextField::Property::RENDERING_BACKEND, Text::RENDERING_SHARED_ATLAS );
876 application.SendNotification();
877 application.Render();
881 tet_result(TET_FAIL);
886 // Positive test for the textChanged signal.
887 int utcDaliTextFieldTextChangedP(void)
889 ToolkitTestApplication application;
890 tet_infoline(" utcDaliTextFieldTextChangedP");
891 TextField field = TextField::New();
892 DALI_TEST_CHECK( field );
894 Stage::GetCurrent().Add( field );
896 // connect to the text changed signal.
897 ConnectionTracker* testTracker = new ConnectionTracker();
898 field.TextChangedSignal().Connect(&TestTextChangedCallback);
899 bool textChangedSignal = false;
900 field.ConnectSignal( testTracker, "textChanged", CallbackFunctor(&textChangedSignal) );
902 gTextChangedCallBackCalled = false;
903 field.SetProperty( TextField::Property::TEXT, "ABC" );
904 DALI_TEST_CHECK( gTextChangedCallBackCalled );
905 DALI_TEST_CHECK( textChangedSignal );
907 application.SendNotification();
909 field.SetKeyInputFocus();
911 gTextChangedCallBackCalled = false;
912 application.ProcessEvent( GenerateKey( "D", "D", KEY_D_CODE, 0, 0, Integration::KeyEvent::Down, DEFAULT_DEVICE_NAME, DevelKeyEvent::DeviceClass::NONE ) );
913 DALI_TEST_CHECK( gTextChangedCallBackCalled );
918 // Negative test for the textChanged signal.
919 int utcDaliTextFieldTextChangedN(void)
921 ToolkitTestApplication application;
922 tet_infoline(" utcDaliTextFieldTextChangedN");
923 TextField field = TextField::New();
924 DALI_TEST_CHECK( field );
926 Stage::GetCurrent().Add( field );
928 // connect to the text changed signal.
929 ConnectionTracker* testTracker = new ConnectionTracker();
930 field.TextChangedSignal().Connect(&TestTextChangedCallback);
931 bool textChangedSignal = false;
932 field.ConnectSignal( testTracker, "textChanged", CallbackFunctor(&textChangedSignal) );
934 gTextChangedCallBackCalled = false;
935 field.SetProperty( TextField::Property::PLACEHOLDER_TEXT, "ABC" ); // Setting placeholder, not TEXT
936 DALI_TEST_CHECK( !gTextChangedCallBackCalled );
937 DALI_TEST_CHECK( !textChangedSignal );
942 // Positive test for Max Characters reached signal.
943 int utcDaliTextFieldMaxCharactersReachedP(void)
945 ToolkitTestApplication application;
946 tet_infoline(" utcDaliTextFieldMaxCharactersReachedP");
947 TextField field = TextField::New();
948 DALI_TEST_CHECK( field );
950 Stage::GetCurrent().Add( field );
952 const int maxNumberOfCharacters = 1;
953 field.SetProperty( TextField::Property::MAX_LENGTH, maxNumberOfCharacters );
955 field.SetKeyInputFocus();
957 // connect to the text changed signal.
958 ConnectionTracker* testTracker = new ConnectionTracker();
959 field.MaxLengthReachedSignal().Connect(&TestMaxLengthReachedCallback);
960 bool maxLengthReachedSignal = false;
961 field.ConnectSignal( testTracker, "maxLengthReached", CallbackFunctor(&maxLengthReachedSignal) );
963 gMaxCharactersCallBackCalled = false;
965 application.ProcessEvent( GenerateKey( "a", "a", KEY_A_CODE, 0, 0, Integration::KeyEvent::Down, DEFAULT_DEVICE_NAME, DevelKeyEvent::DeviceClass::NONE ) );
966 application.ProcessEvent( GenerateKey( "a", "a", KEY_A_CODE, 0, 0, Integration::KeyEvent::Down, DEFAULT_DEVICE_NAME, DevelKeyEvent::DeviceClass::NONE ) );
968 DALI_TEST_CHECK( gMaxCharactersCallBackCalled );
969 DALI_TEST_CHECK( maxLengthReachedSignal );
974 // Negative test for Max Characters reached signal.
975 int utcDaliTextFieldMaxCharactersReachedN(void)
977 ToolkitTestApplication application;
978 tet_infoline(" utcDaliTextFieldMaxCharactersReachedN");
979 TextField field = TextField::New();
980 DALI_TEST_CHECK( field );
982 Stage::GetCurrent().Add( field );
984 const int maxNumberOfCharacters = 3;
985 field.SetProperty( TextField::Property::MAX_LENGTH, maxNumberOfCharacters );
987 field.SetKeyInputFocus();
989 // connect to the text changed signal.
990 ConnectionTracker* testTracker = new ConnectionTracker();
991 field.MaxLengthReachedSignal().Connect(&TestMaxLengthReachedCallback);
992 bool maxLengthReachedSignal = false;
993 field.ConnectSignal( testTracker, "maxLengthReached", CallbackFunctor(&maxLengthReachedSignal) );
995 gMaxCharactersCallBackCalled = false;
997 application.ProcessEvent( GenerateKey( "a", "a", KEY_A_CODE, 0, 0, Integration::KeyEvent::Down, DEFAULT_DEVICE_NAME, DevelKeyEvent::DeviceClass::NONE ) );
998 application.ProcessEvent( GenerateKey( "a", "a", KEY_A_CODE, 0, 0, Integration::KeyEvent::Down, DEFAULT_DEVICE_NAME, DevelKeyEvent::DeviceClass::NONE ) );
1000 DALI_TEST_CHECK( !gMaxCharactersCallBackCalled );
1001 DALI_TEST_CHECK( !maxLengthReachedSignal );
1006 int utcDaliTextFieldInputStyleChanged01(void)
1008 ToolkitTestApplication application;
1009 tet_infoline(" utcDaliTextFieldInputStyleChanged01");
1011 // The text-field emits signals when the input style changes. These changes of style are
1012 // detected during the relayout process (size negotiation), i.e after the cursor has been moved. Signals
1013 // can't be emitted during the size negotiation as the callbacks may update the UI.
1014 // The text-field adds an idle callback to the adaptor to emit the signals after the size negotiation.
1015 // This creates an implementation of the adaptor stub and a queue of idle callbacks.
1016 application.CreateAdaptor();
1020 char* pathNamePtr = get_current_dir_name();
1021 const std::string pathName( pathNamePtr );
1022 free( pathNamePtr );
1024 TextAbstraction::FontClient fontClient = TextAbstraction::FontClient::Get();
1025 fontClient.SetDpi( 93u, 93u );
1027 fontClient.GetFontId( pathName + DEFAULT_FONT_DIR + "/dejavu/DejaVuSerif.ttf", DEFAULT_FONT_SIZE );
1028 fontClient.GetFontId( pathName + DEFAULT_FONT_DIR + "/dejavu/DejaVuSerif-Bold.ttf", DEFAULT_FONT_SIZE );
1030 TextField field = TextField::New();
1031 DALI_TEST_CHECK( field );
1034 field.SetSize( 300.f, 50.f );
1035 field.SetParentOrigin( ParentOrigin::TOP_LEFT );
1036 field.SetAnchorPoint( AnchorPoint::TOP_LEFT );
1038 field.SetProperty( TextField::Property::ENABLE_MARKUP, true );
1039 field.SetProperty( TextField::Property::TEXT, "<font family='DejaVuSerif' size='18'>He<color value='green'>llo</color> <font weight='bold'>world</font> demo</font>" );
1041 // connect to the text changed signal.
1042 ConnectionTracker* testTracker = new ConnectionTracker();
1043 field.InputStyleChangedSignal().Connect( &TestInputStyleChangedCallback );
1044 bool inputStyleChangedSignal = false;
1045 field.ConnectSignal( testTracker, "inputStyleChanged", CallbackFunctor(&inputStyleChangedSignal) );
1047 Stage::GetCurrent().Add( field );
1049 // Render and notify
1050 application.SendNotification();
1051 application.Render();
1053 // Executes the idle callbacks added by the text control on the change of input style.
1054 application.RunIdles();
1056 gInputStyleChangedCallbackCalled = false;
1057 gInputStyleMask = TextField::InputStyle::NONE;
1058 inputStyleChangedSignal = false;
1060 // Create a tap event to touch the text field.
1061 application.ProcessEvent( GenerateTap( Gesture::Possible, 1u, 1u, Vector2( 18.f, 25.f ) ) );
1062 application.ProcessEvent( GenerateTap( Gesture::Started, 1u, 1u, Vector2( 18.f, 25.f ) ) );
1064 // Render and notify
1065 application.SendNotification();
1066 application.Render();
1068 // Executes the idle callbacks added by the text control on the change of input style.
1069 application.RunIdles();
1071 DALI_TEST_CHECK( gInputStyleChangedCallbackCalled );
1072 if( gInputStyleChangedCallbackCalled )
1074 DALI_TEST_EQUALS( static_cast<unsigned int>( gInputStyleMask ), static_cast<unsigned int>( TextField::InputStyle::FONT_FAMILY | TextField::InputStyle::POINT_SIZE ), TEST_LOCATION );
1076 const std::string fontFamily = field.GetProperty( TextField::Property::INPUT_FONT_FAMILY ).Get<std::string>();
1077 DALI_TEST_EQUALS( fontFamily, "DejaVuSerif", TEST_LOCATION );
1079 const float pointSize = field.GetProperty( TextField::Property::INPUT_POINT_SIZE ).Get<float>();
1080 DALI_TEST_EQUALS( pointSize, 18.f, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
1082 DALI_TEST_CHECK( inputStyleChangedSignal );
1084 gInputStyleChangedCallbackCalled = false;
1085 gInputStyleMask = TextField::InputStyle::NONE;
1086 inputStyleChangedSignal = false;
1088 // Create a tap event to touch the text field.
1089 application.ProcessEvent( GenerateTap( Gesture::Possible, 1u, 1u, Vector2( 30.f, 25.f ) ) );
1090 application.ProcessEvent( GenerateTap( Gesture::Started, 1u, 1u, Vector2( 30.f, 25.f ) ) );
1092 // Render and notify
1093 application.SendNotification();
1094 application.Render();
1096 // Executes the idle callbacks added by the text control on the change of input style.
1097 application.RunIdles();
1099 DALI_TEST_CHECK( !gInputStyleChangedCallbackCalled );
1100 DALI_TEST_CHECK( !inputStyleChangedSignal );
1102 gInputStyleChangedCallbackCalled = false;
1103 gInputStyleMask = TextField::InputStyle::NONE;
1104 inputStyleChangedSignal = false;
1106 // Create a tap event to touch the text field.
1107 application.ProcessEvent( GenerateTap( Gesture::Possible, 1u, 1u, Vector2( 43.f, 25.f ) ) );
1108 application.ProcessEvent( GenerateTap( Gesture::Started, 1u, 1u, Vector2( 43.f, 25.f ) ) );
1110 // Render and notify
1111 application.SendNotification();
1112 application.Render();
1114 // Executes the idle callbacks added by the text control on the change of input style.
1115 application.RunIdles();
1117 DALI_TEST_CHECK( gInputStyleChangedCallbackCalled );
1118 if( gInputStyleChangedCallbackCalled )
1120 DALI_TEST_EQUALS( static_cast<unsigned int>( gInputStyleMask ), static_cast<unsigned int>( TextField::InputStyle::COLOR ), TEST_LOCATION );
1122 const Vector4 color = field.GetProperty( TextField::Property::INPUT_COLOR ).Get<Vector4>();
1123 DALI_TEST_EQUALS( color, Color::GREEN, TEST_LOCATION );
1125 DALI_TEST_CHECK( inputStyleChangedSignal );
1127 gInputStyleChangedCallbackCalled = false;
1128 gInputStyleMask = TextField::InputStyle::NONE;
1129 inputStyleChangedSignal = false;
1131 // Create a tap event to touch the text field.
1132 application.ProcessEvent( GenerateTap( Gesture::Possible, 1u, 1u, Vector2( 88.f, 25.f ) ) );
1133 application.ProcessEvent( GenerateTap( Gesture::Started, 1u, 1u, Vector2( 88.f, 25.f ) ) );
1135 // Render and notify
1136 application.SendNotification();
1137 application.Render();
1139 // Executes the idle callbacks added by the text control on the change of input style.
1140 application.RunIdles();
1142 DALI_TEST_CHECK( gInputStyleChangedCallbackCalled );
1143 if( gInputStyleChangedCallbackCalled )
1145 DALI_TEST_EQUALS( static_cast<unsigned int>( gInputStyleMask ), static_cast<unsigned int>( TextField::InputStyle::COLOR | TextField::InputStyle::FONT_STYLE ), TEST_LOCATION );
1147 const Vector4 color = field.GetProperty( TextField::Property::INPUT_COLOR ).Get<Vector4>();
1148 DALI_TEST_EQUALS( color, Color::BLACK, TEST_LOCATION );
1150 const Property::Map fontStyleMapGet = field.GetProperty( TextField::Property::INPUT_FONT_STYLE ).Get<Property::Map>();
1152 Property::Map fontStyleMapSet;
1153 fontStyleMapSet.Insert( "weight", "bold" );
1155 DALI_TEST_EQUALS( fontStyleMapGet.Count(), fontStyleMapSet.Count(), TEST_LOCATION );
1156 DALI_TEST_EQUALS( DaliTestCheckMaps( fontStyleMapGet, fontStyleMapSet ), true, TEST_LOCATION );
1158 DALI_TEST_CHECK( inputStyleChangedSignal );
1160 gInputStyleChangedCallbackCalled = false;
1161 gInputStyleMask = TextField::InputStyle::NONE;
1162 inputStyleChangedSignal = false;
1164 // Create a tap event to touch the text field.
1165 application.ProcessEvent( GenerateTap( Gesture::Possible, 1u, 1u, Vector2( 115.f, 25.f ) ) );
1166 application.ProcessEvent( GenerateTap( Gesture::Started, 1u, 1u, Vector2( 115.f, 25.f ) ) );
1168 // Render and notify
1169 application.SendNotification();
1170 application.Render();
1172 // Executes the idle callbacks added by the text control on the change of input style.
1173 application.RunIdles();
1175 DALI_TEST_CHECK( !gInputStyleChangedCallbackCalled );
1176 DALI_TEST_CHECK( !inputStyleChangedSignal );
1178 gInputStyleChangedCallbackCalled = false;
1179 gInputStyleMask = TextField::InputStyle::NONE;
1180 inputStyleChangedSignal = false;
1182 // Create a tap event to touch the text field.
1183 application.ProcessEvent( GenerateTap( Gesture::Possible, 1u, 1u, Vector2( 164.f, 25.f ) ) );
1184 application.ProcessEvent( GenerateTap( Gesture::Started, 1u, 1u, Vector2( 164.f, 25.f ) ) );
1186 // Render and notify
1187 application.SendNotification();
1188 application.Render();
1190 // Executes the idle callbacks added by the text control on the change of input style.
1191 application.RunIdles();
1193 DALI_TEST_CHECK( gInputStyleChangedCallbackCalled );
1194 if( gInputStyleChangedCallbackCalled )
1196 DALI_TEST_EQUALS( static_cast<unsigned int>( gInputStyleMask ), static_cast<unsigned int>( TextField::InputStyle::FONT_STYLE ), TEST_LOCATION );
1198 const std::string style = field.GetProperty( TextField::Property::INPUT_FONT_STYLE ).Get<std::string>();
1199 DALI_TEST_CHECK( style.empty() );
1201 DALI_TEST_CHECK( inputStyleChangedSignal );
1203 gInputStyleChangedCallbackCalled = false;
1204 gInputStyleMask = TextField::InputStyle::NONE;
1205 inputStyleChangedSignal = false;
1207 // Create a tap event to touch the text field.
1208 application.ProcessEvent( GenerateTap( Gesture::Possible, 1u, 1u, Vector2( 191.f, 25.f ) ) );
1209 application.ProcessEvent( GenerateTap( Gesture::Started, 1u, 1u, Vector2( 191.f, 25.f ) ) );
1211 // Render and notify
1212 application.SendNotification();
1213 application.Render();
1215 // Executes the idle callbacks added by the text control on the change of input style.
1216 application.RunIdles();
1218 DALI_TEST_CHECK( !gInputStyleChangedCallbackCalled );
1219 DALI_TEST_CHECK( !inputStyleChangedSignal );
1224 int utcDaliTextFieldInputStyleChanged02(void)
1226 ToolkitTestApplication application;
1227 tet_infoline(" utcDaliTextFieldInputStyleChanged02");
1229 // The text-field emits signals when the input style changes. These changes of style are
1230 // detected during the relayout process (size negotiation), i.e after the cursor has been moved. Signals
1231 // can't be emitted during the size negotiation as the callbacks may update the UI.
1232 // The text-field adds an idle callback to the adaptor to emit the signals after the size negotiation.
1233 // This creates an implementation of the adaptor stub and a queue of idle callbacks.
1234 application.CreateAdaptor();
1238 char* pathNamePtr = get_current_dir_name();
1239 const std::string pathName( pathNamePtr );
1240 free( pathNamePtr );
1242 TextAbstraction::FontClient fontClient = TextAbstraction::FontClient::Get();
1243 fontClient.SetDpi( 93u, 93u );
1245 fontClient.GetFontId( pathName + DEFAULT_FONT_DIR + "/dejavu/DejaVuSerif.ttf", DEFAULT_FONT_SIZE );
1246 fontClient.GetFontId( pathName + DEFAULT_FONT_DIR + "/dejavu/DejaVuSerif-Bold.ttf", DEFAULT_FONT_SIZE );
1248 TextField field = TextField::New();
1249 DALI_TEST_CHECK( field );
1252 field.SetSize( 300.f, 50.f );
1253 field.SetParentOrigin( ParentOrigin::TOP_LEFT );
1254 field.SetAnchorPoint( AnchorPoint::TOP_LEFT );
1256 field.SetProperty( TextField::Property::ENABLE_MARKUP, true );
1257 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>" );
1259 // connect to the text changed signal.
1260 ConnectionTracker* testTracker = new ConnectionTracker();
1261 field.InputStyleChangedSignal().Connect( &TestInputStyleChangedCallback );
1262 bool inputStyleChangedSignal = false;
1263 field.ConnectSignal( testTracker, "inputStyleChanged", CallbackFunctor(&inputStyleChangedSignal) );
1265 Stage::GetCurrent().Add( field );
1267 // Render and notify
1268 application.SendNotification();
1269 application.Render();
1271 // Executes the idle callbacks added by the text control on the change of input style.
1272 application.RunIdles();
1274 gInputStyleChangedCallbackCalled = false;
1275 gInputStyleMask = TextField::InputStyle::NONE;
1276 inputStyleChangedSignal = false;
1278 // Create a tap event to touch the text field.
1279 application.ProcessEvent( GenerateTap( Gesture::Possible, 1u, 1u, Vector2( 53.f, 25.f ) ) );
1280 application.ProcessEvent( GenerateTap( Gesture::Started, 1u, 1u, Vector2( 53.f, 25.f ) ) );
1281 application.ProcessEvent( GenerateTap( Gesture::Possible, 2u, 1u, Vector2( 53.f, 25.f ) ) );
1282 application.ProcessEvent( GenerateTap( Gesture::Started, 2u, 1u, Vector2( 53.f, 25.f ) ) );
1284 // Render and notify
1285 application.SendNotification();
1286 application.Render();
1288 // Executes the idle callbacks added by the text control on the change of input style.
1289 application.RunIdles();
1291 DALI_TEST_CHECK( gInputStyleChangedCallbackCalled );
1292 if( gInputStyleChangedCallbackCalled )
1294 DALI_TEST_EQUALS( static_cast<unsigned int>( gInputStyleMask ),
1295 static_cast<unsigned int>( TextField::InputStyle::FONT_FAMILY |
1296 TextField::InputStyle::POINT_SIZE |
1297 TextField::InputStyle::COLOR ),
1300 const Vector4 color = field.GetProperty( TextField::Property::INPUT_COLOR ).Get<Vector4>();
1301 DALI_TEST_EQUALS( color, Color::GREEN, TEST_LOCATION );
1303 const std::string fontFamily = field.GetProperty( TextField::Property::INPUT_FONT_FAMILY ).Get<std::string>();
1304 DALI_TEST_EQUALS( fontFamily, "DejaVuSerif", TEST_LOCATION );
1306 const float pointSize = field.GetProperty( TextField::Property::INPUT_POINT_SIZE ).Get<float>();
1307 DALI_TEST_EQUALS( pointSize, 18.f, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
1309 DALI_TEST_CHECK( inputStyleChangedSignal );
1311 gInputStyleChangedCallbackCalled = false;
1312 gInputStyleMask = TextField::InputStyle::NONE;
1313 inputStyleChangedSignal = false;
1315 application.ProcessEvent( GenerateKey( "", "", DALI_KEY_BACKSPACE, 0, 0, Integration::KeyEvent::Down, DEFAULT_DEVICE_NAME, DevelKeyEvent::DeviceClass::NONE ) );
1317 // Render and notify
1318 application.SendNotification();
1319 application.Render();
1321 // Executes the idle callbacks added by the text control on the change of input style.
1322 application.RunIdles();
1324 DALI_TEST_CHECK( gInputStyleChangedCallbackCalled );
1325 if( gInputStyleChangedCallbackCalled )
1327 DALI_TEST_EQUALS( static_cast<unsigned int>( gInputStyleMask ),
1328 static_cast<unsigned int>( TextField::InputStyle::COLOR ),
1331 const Vector4 color = field.GetProperty( TextField::Property::INPUT_COLOR ).Get<Vector4>();
1332 DALI_TEST_EQUALS( color, Color::BLUE, TEST_LOCATION );
1334 DALI_TEST_CHECK( inputStyleChangedSignal );
1336 gInputStyleChangedCallbackCalled = false;
1337 gInputStyleMask = TextField::InputStyle::NONE;
1338 inputStyleChangedSignal = false;
1340 application.ProcessEvent( GenerateKey( "", "", DALI_KEY_BACKSPACE, 0, 0, Integration::KeyEvent::Down, DEFAULT_DEVICE_NAME, DevelKeyEvent::DeviceClass::NONE ) );
1342 // Render and notify
1343 application.SendNotification();
1344 application.Render();
1346 // Executes the idle callbacks added by the text control on the change of input style.
1347 application.RunIdles();
1349 DALI_TEST_CHECK( !gInputStyleChangedCallbackCalled );
1350 DALI_TEST_CHECK( !inputStyleChangedSignal );
1352 gInputStyleChangedCallbackCalled = false;
1353 gInputStyleMask = TextField::InputStyle::NONE;
1354 inputStyleChangedSignal = false;
1356 application.ProcessEvent( GenerateKey( "", "", DALI_KEY_BACKSPACE, 0, 0, Integration::KeyEvent::Down, DEFAULT_DEVICE_NAME, DevelKeyEvent::DeviceClass::NONE ) );
1358 // Render and notify
1359 application.SendNotification();
1360 application.Render();
1362 // Executes the idle callbacks added by the text control on the change of input style.
1363 application.RunIdles();
1365 DALI_TEST_CHECK( gInputStyleChangedCallbackCalled );
1366 if( gInputStyleChangedCallbackCalled )
1368 DALI_TEST_EQUALS( static_cast<unsigned int>( gInputStyleMask ),
1369 static_cast<unsigned int>( TextField::InputStyle::COLOR ),
1372 const Vector4 color = field.GetProperty( TextField::Property::INPUT_COLOR ).Get<Vector4>();
1373 DALI_TEST_EQUALS( color, Color::BLACK, TEST_LOCATION );
1375 DALI_TEST_CHECK( inputStyleChangedSignal );
1377 gInputStyleChangedCallbackCalled = false;
1378 gInputStyleMask = TextField::InputStyle::NONE;
1379 inputStyleChangedSignal = false;
1381 field.SetProperty( TextField::Property::INPUT_COLOR, Color::YELLOW );
1383 Property::Map fontStyleMapSet;
1384 fontStyleMapSet.Insert( "weight", "thin" );
1385 fontStyleMapSet.Insert( "width", "condensed" );
1386 fontStyleMapSet.Insert( "slant", "italic" );
1388 field.SetProperty( TextField::Property::INPUT_FONT_STYLE, fontStyleMapSet );
1389 field.SetProperty( TextField::Property::INPUT_POINT_SIZE, 20.f );
1391 field.SetProperty( TextField::Property::INPUT_UNDERLINE, "underline" );
1392 field.SetProperty( TextField::Property::INPUT_SHADOW, "shadow" );
1393 field.SetProperty( TextField::Property::INPUT_EMBOSS, "emboss" );
1394 field.SetProperty( TextField::Property::INPUT_OUTLINE, "outline" );
1396 // Render and notify
1397 application.SendNotification();
1398 application.Render();
1400 // Executes the idle callbacks added by the text control on the change of input style.
1401 application.RunIdles();
1403 DALI_TEST_CHECK( !gInputStyleChangedCallbackCalled );
1404 DALI_TEST_CHECK( !inputStyleChangedSignal );
1406 // Create a tap event to touch the text field.
1407 application.ProcessEvent( GenerateTap( Gesture::Possible, 1u, 1u, Vector2( 63.f, 25.f ) ) );
1408 application.ProcessEvent( GenerateTap( Gesture::Started, 1u, 1u, Vector2( 63.f, 25.f ) ) );
1410 // Render and notify
1411 application.SendNotification();
1412 application.Render();
1414 // Executes the idle callbacks added by the text control on the change of input style.
1415 application.RunIdles();
1417 DALI_TEST_CHECK( gInputStyleChangedCallbackCalled );
1418 if( gInputStyleChangedCallbackCalled )
1420 DALI_TEST_EQUALS( static_cast<unsigned int>( gInputStyleMask ),
1421 static_cast<unsigned int>( TextField::InputStyle::COLOR |
1422 TextField::InputStyle::POINT_SIZE |
1423 TextField::InputStyle::FONT_STYLE |
1424 TextField::InputStyle::UNDERLINE |
1425 TextField::InputStyle::SHADOW |
1426 TextField::InputStyle::EMBOSS |
1427 TextField::InputStyle::OUTLINE ),
1430 const Vector4 color = field.GetProperty( TextField::Property::INPUT_COLOR ).Get<Vector4>();
1431 DALI_TEST_EQUALS( color, Color::BLACK, TEST_LOCATION );
1433 DALI_TEST_CHECK( inputStyleChangedSignal );
1438 int utcDaliTextFieldEvent01(void)
1440 ToolkitTestApplication application;
1441 tet_infoline(" utcDaliTextFieldEvent01");
1443 // Creates a tap event. After creating a tap event the text field should
1444 // have the focus and add text with key events should be possible.
1446 TextField field = TextField::New();
1447 DALI_TEST_CHECK( field );
1449 Stage::GetCurrent().Add( field );
1451 field.SetSize( 300.f, 50.f );
1452 field.SetParentOrigin( ParentOrigin::TOP_LEFT );
1453 field.SetAnchorPoint( AnchorPoint::TOP_LEFT );
1455 // Avoid a crash when core load gl resources.
1456 application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
1458 // Render and notify
1459 application.SendNotification();
1460 application.Render();
1462 // Add a key event but as the text field has not the focus it should do nothing.
1463 application.ProcessEvent( GenerateKey( "a", "a", KEY_A_CODE, 0, 0, Integration::KeyEvent::Down, DEFAULT_DEVICE_NAME, DevelKeyEvent::DeviceClass::NONE ) );
1465 // Render and notify
1466 application.SendNotification();
1467 application.Render();
1469 DALI_TEST_EQUALS( field.GetProperty<std::string>( TextField::Property::TEXT ), std::string(""), TEST_LOCATION );
1471 // Create a tap event to touch the text field.
1472 application.ProcessEvent( GenerateTap( Gesture::Possible, 1u, 1u, Vector2( 150.0f, 25.0f ) ) );
1473 application.ProcessEvent( GenerateTap( Gesture::Started, 1u, 1u, Vector2( 150.0f, 25.0f ) ) );
1475 // Render and notify
1476 application.SendNotification();
1477 application.Render();
1479 // Now the text field has the focus, so it can handle the key events.
1480 application.ProcessEvent( GenerateKey( "a", "a", KEY_A_CODE, 0, 0, Integration::KeyEvent::Down, DEFAULT_DEVICE_NAME, DevelKeyEvent::DeviceClass::NONE ) );
1481 application.ProcessEvent( GenerateKey( "a", "a", KEY_A_CODE, 0, 0, Integration::KeyEvent::Down, DEFAULT_DEVICE_NAME, DevelKeyEvent::DeviceClass::NONE ) );
1483 // Render and notify
1484 application.SendNotification();
1485 application.Render();
1487 DALI_TEST_EQUALS( field.GetProperty<std::string>( TextField::Property::TEXT ), std::string("aa"), TEST_LOCATION );
1489 // Create a second text field and send key events to it.
1490 TextField field2 = TextField::New();
1492 field2.SetParentOrigin( ParentOrigin::TOP_LEFT );
1493 field2.SetAnchorPoint( AnchorPoint::TOP_LEFT );
1494 field2.SetSize( 100.f, 100.f );
1495 field2.SetPosition( 100.f, 100.f );
1497 Stage::GetCurrent().Add( field2 );
1499 // Render and notify
1500 application.SendNotification();
1501 application.Render();
1503 // Create a tap event on the second text field.
1504 application.ProcessEvent( GenerateTap( Gesture::Possible, 1u, 1u, Vector2( 150.0f, 125.0f ) ) );
1505 application.ProcessEvent( GenerateTap( Gesture::Started, 1u, 1u, Vector2( 150.0f, 125.0f ) ) );
1507 // Render and notify
1508 application.SendNotification();
1509 application.Render();
1511 // The second text field has the focus. It should handle the key events.
1512 application.ProcessEvent( GenerateKey( "a", "a", KEY_A_CODE, 0, 0, Integration::KeyEvent::Down, DEFAULT_DEVICE_NAME, DevelKeyEvent::DeviceClass::NONE ) );
1513 application.ProcessEvent( GenerateKey( "a", "a", KEY_A_CODE, 0, 0, Integration::KeyEvent::Down, DEFAULT_DEVICE_NAME, DevelKeyEvent::DeviceClass::NONE ) );
1515 // Render and notify
1516 application.SendNotification();
1517 application.Render();
1519 // Check the text has been added to the second text field.
1520 DALI_TEST_EQUALS( field2.GetProperty<std::string>( TextField::Property::TEXT ), std::string("aa"), TEST_LOCATION );
1525 int utcDaliTextFieldEvent02(void)
1527 ToolkitTestApplication application;
1528 tet_infoline(" utcDaliTextFieldEvent02");
1530 // Checks if the right number of actors are created.
1532 TextField field = TextField::New();
1533 field.SetProperty( TextField::Property::POINT_SIZE, 10.f );
1534 DALI_TEST_CHECK( field );
1535 LoadMarkerImages(application, field);
1537 Stage::GetCurrent().Add( field );
1539 field.SetSize( 300.f, 50.f );
1540 field.SetParentOrigin( ParentOrigin::TOP_LEFT );
1541 field.SetAnchorPoint( AnchorPoint::TOP_LEFT );
1543 // Avoid a crash when core load gl resources.
1544 application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
1546 // Render and notify
1547 application.SendNotification();
1548 application.Render();
1550 // Check there are the expected number of children ( stencil ).
1551 DALI_TEST_EQUALS( field.GetChildCount(), 1u, TEST_LOCATION );
1553 Actor stencil = field.GetChildAt( 0u );
1554 DALI_TEST_EQUALS( stencil.GetChildCount(), 0u, TEST_LOCATION );
1556 // Create a tap event to touch the text field.
1557 application.ProcessEvent( GenerateTap( Gesture::Possible, 1u, 1u, Vector2( 150.0f, 25.0f ) ) );
1558 application.ProcessEvent( GenerateTap( Gesture::Started, 1u, 1u, Vector2( 150.0f, 25.0f ) ) );
1560 // Render and notify
1561 application.SendNotification();
1562 application.Render();
1564 Actor layer = field.GetChildAt( 1u );
1565 DALI_TEST_CHECK( layer.IsLayer() );
1567 DALI_TEST_EQUALS( layer.GetChildCount(), 1u, TEST_LOCATION ); // The cursor.
1568 DALI_TEST_EQUALS( stencil.GetChildCount(), 0u, TEST_LOCATION );
1570 // Now the text field has the focus, so it can handle the key events.
1571 application.ProcessEvent( GenerateKey( "a", "a", KEY_A_CODE, 0, 0, Integration::KeyEvent::Down, DEFAULT_DEVICE_NAME, DevelKeyEvent::DeviceClass::NONE ) );
1572 application.ProcessEvent( GenerateKey( "a", "a", KEY_A_CODE, 0, 0, Integration::KeyEvent::Down, DEFAULT_DEVICE_NAME, DevelKeyEvent::DeviceClass::NONE ) );
1574 // Render and notify
1575 application.SendNotification();
1576 application.Render();
1578 // Checks the cursor and the renderer have been created.
1579 DALI_TEST_EQUALS( layer.GetChildCount(), 1u, TEST_LOCATION ); // The cursor.
1580 DALI_TEST_EQUALS( stencil.GetChildCount(), 1u, TEST_LOCATION ); // The renderer
1582 Control cursor = Control::DownCast( layer.GetChildAt( 0u ) );
1583 DALI_TEST_CHECK( cursor );
1585 // The offscreen root actor has a container with all the actors which contain the text renderers.
1586 Actor container = stencil.GetChildAt( 0u );
1587 for( unsigned int index = 0; index < container.GetChildCount(); ++index )
1589 Renderer renderer = container.GetChildAt( index ).GetRendererAt( 0u );
1590 DALI_TEST_CHECK( renderer );
1593 // Move the cursor and check the position changes.
1594 Vector3 position1 = cursor.GetCurrentPosition();
1596 application.ProcessEvent( GenerateKey( "", "", DALI_KEY_CURSOR_LEFT, 0, 0, Integration::KeyEvent::Down, DEFAULT_DEVICE_NAME, DevelKeyEvent::DeviceClass::NONE ) );
1597 application.ProcessEvent( GenerateKey( "", "", DALI_KEY_CURSOR_LEFT, 0, 0, Integration::KeyEvent::Down, DEFAULT_DEVICE_NAME, DevelKeyEvent::DeviceClass::NONE ) );
1599 // Render and notify
1600 application.SendNotification();
1601 application.Render();
1603 Vector3 position2 = cursor.GetCurrentPosition();
1605 DALI_TEST_CHECK( position2.x < position1.x );
1607 application.ProcessEvent( GenerateKey( "", "", DALI_KEY_CURSOR_RIGHT, 0, 0, Integration::KeyEvent::Down, DEFAULT_DEVICE_NAME, DevelKeyEvent::DeviceClass::NONE ) );
1608 application.ProcessEvent( GenerateKey( "", "", DALI_KEY_CURSOR_RIGHT, 0, 0, Integration::KeyEvent::Down, DEFAULT_DEVICE_NAME, DevelKeyEvent::DeviceClass::NONE ) );
1610 // Render and notify
1611 application.SendNotification();
1612 application.Render();
1614 Vector3 position3 = cursor.GetCurrentPosition();
1616 DALI_TEST_EQUALS( position1, position3, TEST_LOCATION ); // Should be in the same position1.
1618 // Send some taps and check the cursor positions.
1620 // Try to tap at the beginning.
1621 application.ProcessEvent( GenerateTap( Gesture::Possible, 1u, 1u, Vector2( 1.f, 25.0f ) ) );
1622 application.ProcessEvent( GenerateTap( Gesture::Started, 1u, 1u, Vector2( 1.f, 25.0f ) ) );
1624 // Render and notify
1625 application.SendNotification();
1626 application.Render();
1628 // Cursor position should be the same than position1.
1629 Vector3 position4 = cursor.GetCurrentPosition();
1631 DALI_TEST_EQUALS( position2, position4, TEST_LOCATION ); // Should be in the same position2.
1633 // Tap away from the start position.
1634 application.ProcessEvent( GenerateTap( Gesture::Possible, 1u, 1u, Vector2( 16.f, 25.0f ) ) );
1635 application.ProcessEvent( GenerateTap( Gesture::Started, 1u, 1u, Vector2( 16.0f, 25.0f ) ) );
1637 // Render and notify
1638 application.SendNotification();
1639 application.Render();
1641 Vector3 position5 = cursor.GetCurrentPosition();
1643 DALI_TEST_CHECK( position5.x > position4.x );
1645 // Remove all the text.
1646 application.ProcessEvent( GenerateKey( "", "", DALI_KEY_BACKSPACE, 0, 0, Integration::KeyEvent::Down, DEFAULT_DEVICE_NAME, DevelKeyEvent::DeviceClass::NONE ) );
1647 application.ProcessEvent( GenerateKey( "", "", DALI_KEY_BACKSPACE, 0, 0, Integration::KeyEvent::Down, DEFAULT_DEVICE_NAME, DevelKeyEvent::DeviceClass::NONE ) );
1648 field.SetProperty( TextField::Property::TEXT, "" );
1650 // Render and notify
1651 application.SendNotification();
1652 application.Render();
1654 // Cursor position should be the same than position2.
1655 Vector3 position6 = cursor.GetCurrentPosition();
1657 DALI_TEST_EQUALS( position2, position6, TEST_LOCATION );// Should be in the same position2.
1659 // Should not be a renderer.
1660 DALI_TEST_EQUALS( stencil.GetChildCount(), 0u, TEST_LOCATION );
1665 int utcDaliTextFieldEvent03(void)
1667 ToolkitTestApplication application;
1668 tet_infoline(" utcDaliTextFieldEvent03");
1670 // Checks if the highlight actor is created.
1672 TextField field = TextField::New();
1673 DALI_TEST_CHECK( field );
1675 Stage::GetCurrent().Add( field );
1677 field.SetProperty( TextField::Property::TEXT, "This is a long text for the size of the text-field." );
1678 field.SetProperty( TextField::Property::POINT_SIZE, 10.f );
1679 field.SetSize( 30.f, 50.f );
1680 field.SetParentOrigin( ParentOrigin::TOP_LEFT );
1681 field.SetAnchorPoint( AnchorPoint::TOP_LEFT );
1683 // Avoid a crash when core load gl resources.
1684 application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
1685 LoadMarkerImages(application, field);
1687 // Render and notify
1688 application.SendNotification();
1689 application.Render();
1691 // Tap first to get the focus.
1692 application.ProcessEvent( GenerateTap( Gesture::Possible, 1u, 1u, Vector2( 3.f, 25.0f ) ) );
1693 application.ProcessEvent( GenerateTap( Gesture::Started, 1u, 1u, Vector2( 3.f, 25.0f ) ) );
1695 // Render and notify
1696 application.SendNotification();
1697 application.Render();
1699 // Double tap to select a word.
1700 application.ProcessEvent( GenerateTap( Gesture::Possible, 2u, 1u, Vector2( 3.f, 25.0f ) ) );
1701 application.ProcessEvent( GenerateTap( Gesture::Started, 2u, 1u, Vector2( 3.f, 25.0f ) ) );
1703 // Render and notify
1704 application.SendNotification();
1705 application.Render();
1707 // The offscreen root actor should have two actors: the renderer and the highlight actor.
1708 Actor stencil = field.GetChildAt( 0u );
1710 // The highlight actor is drawn first, so is the first actor in the list
1711 Renderer highlight = stencil.GetChildAt( 0u ).GetRendererAt( 0u );
1712 DALI_TEST_CHECK( highlight );
1714 // The offscreen root actor has a container with all the actors which contain the text renderers.
1715 Actor container = stencil.GetChildAt( 1u );
1716 for( unsigned int index = 0; index < container.GetChildCount(); ++index )
1718 Renderer renderer = container.GetChildAt( index ).GetRendererAt( 0u );
1719 DALI_TEST_CHECK( renderer );
1725 int utcDaliTextFieldEvent04(void)
1727 ToolkitTestApplication application;
1728 tet_infoline(" utcDaliTextFieldEvent04");
1730 // Checks if the highlight actor is created.
1732 TextField field = TextField::New();
1733 DALI_TEST_CHECK( field );
1734 Stage::GetCurrent().Add( field );
1735 LoadMarkerImages(application, field);
1736 // Render and notify
1737 application.SendNotification();
1738 application.Render();
1740 field.SetProperty( TextField::Property::TEXT, "This is a long text for the size of the text-field." );
1741 field.SetProperty( TextField::Property::POINT_SIZE, 10.f );
1742 field.SetSize( 300.f, 50.f );
1743 field.SetParentOrigin( ParentOrigin::TOP_LEFT );
1744 field.SetAnchorPoint( AnchorPoint::TOP_LEFT );
1746 // Avoid a crash when core load gl resources.
1747 application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
1748 // Render and notify
1749 application.SendNotification();
1750 application.Render();
1752 // Create a tap event to touch the text field.
1753 application.ProcessEvent( GenerateTap( Gesture::Possible, 1u, 1u, Vector2( 150.0f, 25.0f ) ) );
1754 application.ProcessEvent( GenerateTap( Gesture::Started, 1u, 1u, Vector2( 150.0f, 25.0f ) ) );
1755 // Render and notify
1756 application.SendNotification();
1757 application.Render();
1760 // Tap first to get the focus.
1761 application.ProcessEvent( GenerateTap( Gesture::Possible, 1u, 1u, Vector2( 1.f, 25.0f ) ) );
1762 application.ProcessEvent( GenerateTap( Gesture::Started, 1u, 1u, Vector2( 1.f, 25.0f ) ) );
1764 // Render and notify
1765 application.SendNotification();
1766 application.Render();
1768 // Double tap to select a word.
1769 application.ProcessEvent( GenerateTap( Gesture::Possible, 2u, 1u, Vector2( 1.f, 25.0f ) ) );
1770 application.ProcessEvent( GenerateTap( Gesture::Started, 2u, 1u, Vector2( 1.f, 25.0f ) ) );
1772 // Render and notify
1773 application.SendNotification();
1774 application.Render();
1777 application.ProcessEvent( GenerateTap( Gesture::Possible, 1u, 1u, Vector2( 0.f, 40.0f ) ) );
1778 application.ProcessEvent( GenerateTap( Gesture::Started, 1u, 1u, Vector2( 0.f, 40.0f ) ) );
1782 int utcDaliTextFieldEvent05(void)
1784 ToolkitTestApplication application;
1785 tet_infoline(" utcDaliTextFieldEvent05");
1787 // Checks dragging of cursor/grab handle
1789 TextField field = TextField::New();
1790 DALI_TEST_CHECK( field );
1791 Stage::GetCurrent().Add( field );
1792 LoadMarkerImages(application, field);
1793 // Render and notify
1794 application.SendNotification();
1795 application.Render();
1797 field.SetProperty( TextField::Property::TEXT, "This is a long text for the size of the text-field." );
1798 field.SetProperty( TextField::Property::POINT_SIZE, 10.f );
1799 field.SetSize( 300.f, 50.f );
1800 field.SetParentOrigin( ParentOrigin::TOP_LEFT );
1801 field.SetAnchorPoint( AnchorPoint::TOP_LEFT );
1803 // Avoid a crash when core load gl resources.
1804 application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
1805 // Render and notify
1806 application.SendNotification();
1807 application.Render();
1809 // Create a tap event to touch the text field.
1810 application.ProcessEvent( GenerateTap( Gesture::Possible, 1u, 1u, Vector2( 150.0f, 25.0f ) ) );
1811 application.ProcessEvent( GenerateTap( Gesture::Started, 1u, 1u, Vector2( 150.0f, 25.0f ) ) );
1812 // Render and notify
1813 application.SendNotification();
1814 application.Render();
1817 // Tap first to get the focus.
1818 application.ProcessEvent( GenerateTap( Gesture::Possible, 1u, 1u, Vector2( 1.f, 25.0f ) ) );
1819 application.ProcessEvent( GenerateTap( Gesture::Started, 1u, 1u, Vector2( 1.f, 25.0f ) ) );
1821 // Render and notify
1822 application.SendNotification();
1823 application.Render();
1825 // Double tap to select a word.
1826 application.ProcessEvent( GenerateTap( Gesture::Possible, 2u, 1u, Vector2( 1.f, 25.0f ) ) );
1827 application.ProcessEvent( GenerateTap( Gesture::Started, 2u, 1u, Vector2( 1.f, 25.0f ) ) );
1829 // Render and notify
1830 application.SendNotification();
1831 application.Render();
1833 // drag grab handle right
1834 Vector2 pos(0.0f, 40.0f);
1835 SendPan(application, Gesture::Possible, pos);
1836 SendPan(application, Gesture::Started, pos);
1838 Wait(application, 100);
1840 for(int i = 0;i<20;i++)
1842 SendPan(application, Gesture::Continuing, pos);
1847 SendPan(application, Gesture::Finished, pos);
1848 Wait(application, RENDER_FRAME_INTERVAL);
1850 Actor stencil = field.GetChildAt( 1u );
1854 int utcDaliTextFieldEvent06(void)
1856 ToolkitTestApplication application;
1857 tet_infoline(" utcDaliTextFieldEvent06");
1859 // Checks Longpress when in edit mode
1861 TextField field = TextField::New();
1862 DALI_TEST_CHECK( field );
1863 Stage::GetCurrent().Add( field );
1864 LoadMarkerImages(application, field);
1865 // Render and notify
1866 application.SendNotification();
1867 application.Render();
1869 field.SetProperty( TextField::Property::TEXT, "Thisisalongtextforthesizeofthetextfield." );
1870 field.SetProperty( TextField::Property::POINT_SIZE, 10.f );
1871 field.SetSize( 300.f, 50.f );
1872 field.SetParentOrigin( ParentOrigin::TOP_LEFT );
1873 field.SetAnchorPoint( AnchorPoint::TOP_LEFT );
1875 // Avoid a crash when core load gl resources.
1876 application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
1877 // Render and notify
1878 application.SendNotification();
1879 application.Render();
1881 // Create a tap event to touch the text field.
1882 application.ProcessEvent( GenerateTap( Gesture::Possible, 1u, 1u, Vector2( 150.0f, 25.0f ) ) );
1883 application.ProcessEvent( GenerateTap( Gesture::Started, 1u, 1u, Vector2( 150.0f, 25.0f ) ) );
1884 // Render and notify
1885 application.SendNotification();
1886 application.Render();
1889 // Tap first to get the focus.
1890 application.ProcessEvent( GenerateTap( Gesture::Possible, 1u, 1u, Vector2( 1.f, 25.0f ) ) );
1891 application.ProcessEvent( GenerateTap( Gesture::Started, 1u, 1u, Vector2( 1.f, 25.0f ) ) );
1893 // Render and notify
1894 application.SendNotification();
1895 application.Render();
1898 application.ProcessEvent( GenerateLongPress( Gesture::Possible, 1u, Vector2( 1.f, 25.0f ) ) );
1899 application.ProcessEvent( GenerateLongPress( Gesture::Started, 1u, Vector2( 1.f, 25.0f ) ) );
1901 // Render and notify
1902 application.SendNotification();
1903 application.Render();
1908 int utcDaliTextFieldEvent07(void)
1910 ToolkitTestApplication application;
1911 tet_infoline(" utcDaliTextFieldEvent07");
1913 // Checks Longpress to start edit mode
1915 TextField field = TextField::New();
1916 DALI_TEST_CHECK( field );
1917 Stage::GetCurrent().Add( field );
1918 LoadMarkerImages(application, field);
1919 // Render and notify
1920 application.SendNotification();
1921 application.Render();
1923 field.SetProperty( TextField::Property::TEXT, "Thisisalongtextforthesizeofthetextfield." );
1924 field.SetProperty( TextField::Property::POINT_SIZE, 10.f );
1925 field.SetSize( 300.f, 50.f );
1926 field.SetParentOrigin( ParentOrigin::TOP_LEFT );
1927 field.SetAnchorPoint( AnchorPoint::TOP_LEFT );
1928 Property::Map propertyMap;
1929 propertyMap["PANEL_LAYOUT"] = InputMethod::PanelLayout::PASSWORD;
1930 field.SetProperty( TextField::Property::INPUT_METHOD_SETTINGS, propertyMap );
1932 // Avoid a crash when core load gl resources.
1933 application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
1934 // Render and notify
1935 application.SendNotification();
1936 application.Render();
1939 application.ProcessEvent( GenerateLongPress( Gesture::Possible, 1u, Vector2( 1.f, 25.0f ) ) );
1940 application.ProcessEvent( GenerateLongPress( Gesture::Started, 1u, Vector2( 1.f, 25.0f ) ) );
1942 // Render and notify
1943 application.SendNotification();
1944 application.Render();
1949 int utcDaliTextFieldEvent08(void)
1951 ToolkitTestApplication application;
1952 tet_infoline(" utcDaliTextFieldEvent08");
1954 Dali::Clipboard clipboard = Clipboard::Get();
1955 clipboard.SetItem("testTextFieldEvent");
1957 // Checks Longpress when only place holder text
1959 TextField field = TextField::New();
1960 DALI_TEST_CHECK( field );
1961 Stage::GetCurrent().Add( field );
1962 LoadMarkerImages(application, field);
1963 // Render and notify
1964 application.SendNotification();
1965 application.Render();
1967 field.SetProperty( TextField::Property::PLACEHOLDER_TEXT, "Setting Placeholder Text" );
1968 field.SetProperty( TextField::Property::POINT_SIZE, 10.f );
1969 field.SetSize( 300.f, 50.f );
1970 field.SetParentOrigin( ParentOrigin::TOP_LEFT );
1971 field.SetAnchorPoint( AnchorPoint::TOP_LEFT );
1973 // Avoid a crash when core load gl resources.
1974 application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
1975 // Render and notify
1976 application.SendNotification();
1977 application.Render();
1980 application.ProcessEvent( GenerateLongPress( Gesture::Possible, 1u, Vector2( 1.f, 25.0f ) ) );
1981 application.ProcessEvent( GenerateLongPress( Gesture::Started, 1u, Vector2( 1.f, 25.0f ) ) );
1983 // Render and notify
1984 application.SendNotification();
1985 application.Render();
1987 Wait(application, 500);
1990 application.ProcessEvent( GenerateLongPress( Gesture::Possible, 1u, Vector2( 1.f, 25.0f ) ) );
1991 application.ProcessEvent( GenerateLongPress( Gesture::Started, 1u, Vector2( 1.f, 25.0f ) ) );
1993 // Render and notify
1994 application.SendNotification();
1995 application.Render();
1997 Wait(application, 500);
1999 Stage stage = Stage::GetCurrent();
2000 Layer layer = stage.GetRootLayer();
2001 Actor actor = layer.FindChildByName("optionPaste");
2005 Vector3 worldPosition = actor.GetCurrentWorldPosition();
2006 Vector2 halfStageSize = stage.GetSize() / 2.0f;
2007 Vector2 position(worldPosition.x + halfStageSize.width, worldPosition.y + halfStageSize.height);
2009 Dali::Integration::TouchEvent event;
2010 event = Dali::Integration::TouchEvent();
2011 event.AddPoint( GetPointDownInside( position ) );
2012 application.ProcessEvent( event );
2014 event = Dali::Integration::TouchEvent();
2015 event.AddPoint( GetPointUpInside( position ) );
2016 application.ProcessEvent( event );
2018 DALI_TEST_EQUALS( field.GetProperty<std::string>( TextEditor::Property::TEXT ), std::string("testTextFieldEvent"), TEST_LOCATION );
2023 int utcDaliTextFieldEvent09(void)
2025 ToolkitTestApplication application;
2026 tet_infoline(" utcDaliTextFieldEvent09");
2028 TextField field = TextField::New();
2029 DALI_TEST_CHECK( field );
2030 Stage::GetCurrent().Add( field );
2031 LoadMarkerImages(application, field);
2032 // Render and notify
2033 application.SendNotification();
2034 application.Render();
2036 field.SetProperty( TextField::Property::TEXT, "Hello" );
2037 field.SetProperty( TextField::Property::POINT_SIZE, 10.f );
2038 field.SetSize( 300.f, 50.f );
2039 field.SetParentOrigin( ParentOrigin::TOP_LEFT );
2040 field.SetAnchorPoint( AnchorPoint::TOP_LEFT );
2042 // Avoid a crash when core load gl resources.
2043 application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
2045 // Create a tap event to touch the text field.
2046 application.ProcessEvent( GenerateTap( Gesture::Possible, 1u, 1u, Vector2( 150.0f, 25.0f ) ) );
2047 application.ProcessEvent( GenerateTap( Gesture::Started, 1u, 1u, Vector2( 150.0f, 25.0f ) ) );
2048 application.SendNotification();
2049 application.Render();
2052 map[ HiddenInput::Property::MODE ] = HiddenInput::Mode::HIDE_NONE;
2053 field.SetProperty( DevelTextField::Property::HIDDEN_INPUT_SETTINGS, map );
2054 application.ProcessEvent( GenerateKey( "d", "d", 0, 0, 0, Integration::KeyEvent::Down, DEFAULT_DEVICE_NAME, DevelKeyEvent::DeviceClass::NONE ) );
2055 application.SendNotification();
2056 application.Render();
2058 map[ HiddenInput::Property::MODE ] = HiddenInput::Mode::HIDE_ALL;
2059 map[ HiddenInput::Property::SUBSTITUTE_CHARACTER ] = 0x23;
2060 field.SetProperty( DevelTextField::Property::HIDDEN_INPUT_SETTINGS, map );
2061 application.ProcessEvent( GenerateKey( "d", "d", 0, 0, 0, Integration::KeyEvent::Down, DEFAULT_DEVICE_NAME, DevelKeyEvent::DeviceClass::NONE ) );
2062 application.SendNotification();
2063 application.Render();
2065 map[ HiddenInput::Property::MODE ] = HiddenInput::Mode::HIDE_COUNT;
2066 map[ HiddenInput::Property::SUBSTITUTE_COUNT ] = 2;
2067 field.SetProperty( DevelTextField::Property::HIDDEN_INPUT_SETTINGS, map );
2068 for( unsigned int index = 0u; index < 5u; ++index )
2070 application.ProcessEvent( GenerateKey( "d", "d", 0, 0, 0, Integration::KeyEvent::Down, DEFAULT_DEVICE_NAME, DevelKeyEvent::DeviceClass::NONE ) );
2071 application.SendNotification();
2072 application.Render();
2075 map[ HiddenInput::Property::MODE ] = HiddenInput::Mode::SHOW_COUNT;
2076 map[ HiddenInput::Property::SUBSTITUTE_COUNT ] = 2;
2077 field.SetProperty( DevelTextField::Property::HIDDEN_INPUT_SETTINGS, map );
2078 for( unsigned int index = 0u; index < 5u; ++index )
2080 application.ProcessEvent( GenerateKey( "d", "d", 0, 0, 0, Integration::KeyEvent::Down, DEFAULT_DEVICE_NAME, DevelKeyEvent::DeviceClass::NONE ) );
2081 application.SendNotification();
2082 application.Render();
2085 map[ HiddenInput::Property::MODE ] = HiddenInput::Mode::SHOW_LAST_CHARACTER;
2086 map[ HiddenInput::Property::SHOW_DURATION ] = 0;
2087 field.SetProperty( DevelTextField::Property::HIDDEN_INPUT_SETTINGS, map );
2088 application.ProcessEvent( GenerateKey( "", "", DALI_KEY_BACKSPACE, 0, 0, Integration::KeyEvent::Down, DEFAULT_DEVICE_NAME, DevelKeyEvent::DeviceClass::NONE ) );
2089 application.SendNotification();
2090 application.Render();
2091 application.ProcessEvent( GenerateKey( "d", "d", 0, 0, 0, Integration::KeyEvent::Down, DEFAULT_DEVICE_NAME, DevelKeyEvent::DeviceClass::NONE ) );
2092 application.SendNotification();
2093 application.Render();
2095 map[ HiddenInput::Property::SHOW_DURATION ] = 100;
2096 field.SetProperty( DevelTextField::Property::HIDDEN_INPUT_SETTINGS, map );
2097 application.ProcessEvent( GenerateKey( "d", "d", 0, 0, 0, Integration::KeyEvent::Down, DEFAULT_DEVICE_NAME, DevelKeyEvent::DeviceClass::NONE ) );
2098 application.SendNotification();
2099 application.Render();
2101 Property::Map mapGet;
2102 mapGet = field.GetProperty<Property::Map>( DevelTextField::Property::HIDDEN_INPUT_SETTINGS );
2103 DALI_TEST_EQUALS( map.Count(), mapGet.Count(), TEST_LOCATION );
2104 DALI_TEST_EQUALS( DaliTestCheckMaps( map, mapGet ), true, TEST_LOCATION );
2109 int utcDaliTextFieldStyleWhilstSelected(void)
2111 ToolkitTestApplication application;
2112 tet_infoline(" utcDaliTextFieldStyleWhilstSelected");
2114 // Change font and styles whilst text is selected whilst word selected
2116 TextField field = TextField::New();
2117 DALI_TEST_CHECK( field );
2118 Stage::GetCurrent().Add( field );
2119 LoadMarkerImages(application, field);
2120 // Render and notify
2121 application.SendNotification();
2122 application.Render();
2124 field.SetProperty( TextField::Property::TEXT, "This is a long text for the size of the text-field." );
2125 field.SetProperty( TextField::Property::POINT_SIZE, 10.f );
2126 field.SetSize( 300.f, 50.f );
2127 field.SetParentOrigin( ParentOrigin::TOP_LEFT );
2128 field.SetAnchorPoint( AnchorPoint::TOP_LEFT );
2130 // Avoid a crash when core load gl resources.
2131 application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
2132 // Render and notify
2133 application.SendNotification();
2134 application.Render();
2136 // Create a tap event to touch the text field.
2137 application.ProcessEvent( GenerateTap( Gesture::Possible, 1u, 1u, Vector2( 150.0f, 25.0f ) ) );
2138 application.ProcessEvent( GenerateTap( Gesture::Started, 1u, 1u, Vector2( 150.0f, 25.0f ) ) );
2139 // Render and notify
2140 application.SendNotification();
2141 application.Render();
2144 // Tap first to get the focus.
2145 application.ProcessEvent( GenerateTap( Gesture::Possible, 1u, 1u, Vector2( 1.f, 25.0f ) ) );
2146 application.ProcessEvent( GenerateTap( Gesture::Started, 1u, 1u, Vector2( 1.f, 25.0f ) ) );
2148 // Render and notify
2149 application.SendNotification();
2150 application.Render();
2152 // Double tap to select a word.
2153 application.ProcessEvent( GenerateTap( Gesture::Possible, 2u, 1u, Vector2( 1.f, 25.0f ) ) );
2154 application.ProcessEvent( GenerateTap( Gesture::Started, 2u, 1u, Vector2( 1.f, 25.0f ) ) );
2156 // Render and notify
2157 application.SendNotification();
2158 application.Render();
2160 field.SetProperty( TextField::Property::INPUT_FONT_FAMILY, "Setting input font family" );
2161 DALI_TEST_EQUALS( field.GetProperty<std::string>( TextField::Property::INPUT_FONT_FAMILY ), "Setting input font family", TEST_LOCATION );
2163 Property::Map fontStyleMapSet;
2164 Property::Map fontStyleMapGet;
2166 fontStyleMapSet.Insert( "weight", "bold" );
2167 fontStyleMapSet.Insert( "slant", "italic" );
2168 field.SetProperty( TextField::Property::INPUT_FONT_STYLE, fontStyleMapSet );
2170 fontStyleMapGet = field.GetProperty<Property::Map>( TextField::Property::INPUT_FONT_STYLE );
2171 DALI_TEST_EQUALS( fontStyleMapGet.Count(), fontStyleMapSet.Count(), TEST_LOCATION );
2172 DALI_TEST_EQUALS( DaliTestCheckMaps( fontStyleMapGet, fontStyleMapSet ), true, TEST_LOCATION );
2174 fontStyleMapSet.Clear();
2175 fontStyleMapSet.Insert( "width", "expanded" );
2176 fontStyleMapSet.Insert( "slant", "italic" );
2177 field.SetProperty( TextField::Property::INPUT_FONT_STYLE, fontStyleMapSet );
2179 fontStyleMapGet = field.GetProperty<Property::Map>( TextField::Property::INPUT_FONT_STYLE );
2180 DALI_TEST_EQUALS( fontStyleMapGet.Count(), fontStyleMapSet.Count(), TEST_LOCATION );
2181 DALI_TEST_EQUALS( DaliTestCheckMaps( fontStyleMapGet, fontStyleMapSet ), true, TEST_LOCATION );
2183 field.SetProperty( TextField::Property::INPUT_POINT_SIZE, 12.f );
2184 DALI_TEST_EQUALS( field.GetProperty<float>( TextField::Property::INPUT_POINT_SIZE ), 12.f, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
2186 field.SetProperty( TextField::Property::TEXT_COLOR, Color::RED );
2187 DALI_TEST_EQUALS( field.GetProperty<Vector4>( TextField::Property::TEXT_COLOR ), Color::RED, TEST_LOCATION );
2189 fontStyleMapSet.Clear();
2190 fontStyleMapSet.Insert( "weight", "bold" );
2191 fontStyleMapSet.Insert( "slant", "italic" );
2193 field.SetProperty( TextField::Property::FONT_STYLE, fontStyleMapSet );
2195 fontStyleMapGet = field.GetProperty<Property::Map>( TextField::Property::FONT_STYLE );
2196 DALI_TEST_EQUALS( fontStyleMapGet.Count(), fontStyleMapSet.Count(), TEST_LOCATION );
2197 DALI_TEST_EQUALS( DaliTestCheckMaps( fontStyleMapGet, fontStyleMapSet ), true, TEST_LOCATION );
2199 fontStyleMapSet.Clear();
2200 fontStyleMapSet.Insert( "width", "expanded" );
2202 field.SetProperty( TextField::Property::FONT_STYLE, fontStyleMapSet );
2204 fontStyleMapGet = field.GetProperty<Property::Map>( TextField::Property::FONT_STYLE );
2205 DALI_TEST_EQUALS( fontStyleMapGet.Count(), fontStyleMapSet.Count(), TEST_LOCATION );
2206 DALI_TEST_EQUALS( DaliTestCheckMaps( fontStyleMapGet, fontStyleMapSet ), true, TEST_LOCATION );
2208 // Press Escape to increase coverage
2209 application.ProcessEvent( GenerateKey( "", "", DALI_KEY_ESCAPE, 0, 0, Integration::KeyEvent::Up, DEFAULT_DEVICE_NAME, DevelKeyEvent::DeviceClass::NONE ) );
2210 application.SendNotification();
2211 application.Render();
2213 DALI_TEST_CHECK( !field.HasKeyInputFocus() );
2218 int utcDaliTextFieldEscKeyLoseFocus(void)
2220 ToolkitTestApplication application;
2221 tet_infoline(" utcDaliTextFieldEscKeyLoseFocus");
2223 // Creates a tap event. After creating a tap event the text field should
2224 // have the focus and add text with key events should be possible.
2226 TextField field = TextField::New();
2227 DALI_TEST_CHECK( field );
2229 Stage::GetCurrent().Add( field );
2231 field.SetSize( 300.f, 50.f );
2232 field.SetParentOrigin( ParentOrigin::TOP_LEFT );
2233 field.SetAnchorPoint( AnchorPoint::TOP_LEFT );
2235 // Avoid a crash when core load gl resources.
2236 application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
2238 // Render and notify
2239 application.SendNotification();
2240 application.Render();
2242 // Add a key event but as the text field has not the focus it should do nothing.
2243 application.ProcessEvent( GenerateKey( "a", "a", KEY_A_CODE, 0, 0, Integration::KeyEvent::Down, DEFAULT_DEVICE_NAME, DevelKeyEvent::DeviceClass::NONE ) );
2244 application.ProcessEvent( GenerateKey( "a", "a", KEY_A_CODE, 0, 0, Integration::KeyEvent::Up, DEFAULT_DEVICE_NAME, DevelKeyEvent::DeviceClass::NONE ) );
2246 // Render and notify
2247 application.SendNotification();
2248 application.Render();
2250 DALI_TEST_EQUALS( field.GetProperty<std::string>( TextField::Property::TEXT ), std::string(""), TEST_LOCATION );
2252 // Create a tap event to touch the text field.
2253 application.ProcessEvent( GenerateTap( Gesture::Possible, 1u, 1u, Vector2( 150.0f, 25.0f ) ) );
2254 application.ProcessEvent( GenerateTap( Gesture::Started, 1u, 1u, Vector2( 150.0f, 25.0f ) ) );
2256 // Render and notify
2257 application.SendNotification();
2258 application.Render();
2260 // Now the text field has the focus, so it can handle the key events.
2261 application.ProcessEvent( GenerateKey( "a", "a", KEY_A_CODE, 0, 0, Integration::KeyEvent::Down, DEFAULT_DEVICE_NAME, DevelKeyEvent::DeviceClass::NONE ) );
2262 application.ProcessEvent( GenerateKey( "a", "a", KEY_A_CODE, 0, 0, Integration::KeyEvent::Up, DEFAULT_DEVICE_NAME, DevelKeyEvent::DeviceClass::NONE ) );
2263 application.ProcessEvent( GenerateKey( "d", "d", KEY_D_CODE, 0, 0, Integration::KeyEvent::Down, DEFAULT_DEVICE_NAME, DevelKeyEvent::DeviceClass::NONE ) );
2264 application.ProcessEvent( GenerateKey( "d", "d", KEY_D_CODE, 0, 0, Integration::KeyEvent::Up, DEFAULT_DEVICE_NAME, DevelKeyEvent::DeviceClass::NONE ) );
2266 // Render and notify
2267 application.SendNotification();
2268 application.Render();
2270 DALI_TEST_EQUALS( field.GetProperty<std::string>( TextField::Property::TEXT ), std::string("ad"), TEST_LOCATION );
2272 // Generate a Esc key event. The text field should lose the focus.
2273 application.ProcessEvent( GenerateKey( "", "", DALI_KEY_ESCAPE, 0, 0, Integration::KeyEvent::Down, DEFAULT_DEVICE_NAME, DevelKeyEvent::DeviceClass::NONE ) );
2274 application.ProcessEvent( GenerateKey( "", "", DALI_KEY_ESCAPE, 0, 0, Integration::KeyEvent::Up, DEFAULT_DEVICE_NAME, DevelKeyEvent::DeviceClass::NONE ) );
2276 // Render and notify
2277 application.SendNotification();
2278 application.Render();
2280 DALI_TEST_EQUALS( false, field.HasKeyInputFocus(), TEST_LOCATION );
2282 // No more text should be introduced
2283 application.ProcessEvent( GenerateKey( "a", "a", KEY_A_CODE, 0, 0, Integration::KeyEvent::Down, DEFAULT_DEVICE_NAME, DevelKeyEvent::DeviceClass::NONE ) );
2284 application.ProcessEvent( GenerateKey( "a", "a", KEY_A_CODE, 0, 0, Integration::KeyEvent::Up, DEFAULT_DEVICE_NAME, DevelKeyEvent::DeviceClass::NONE ) );
2286 // Render and notify
2287 application.SendNotification();
2288 application.Render();
2290 DALI_TEST_EQUALS( field.GetProperty<std::string>( TextField::Property::TEXT ), std::string("ad"), TEST_LOCATION );
2295 int utcDaliTextFieldSomeSpecialKeys(void)
2297 ToolkitTestApplication application;
2298 tet_infoline(" utcDaliTextFieldSomeSpecialKeys");
2300 // Checks some special keys when the text is selected.
2302 TextField field = TextField::New();
2303 DALI_TEST_CHECK( field );
2304 Stage::GetCurrent().Add( field );
2305 LoadMarkerImages(application, field);
2306 // Render and notify
2307 application.SendNotification();
2308 application.Render();
2310 const std::string longText( "This is a long text for the size of the text-field." );
2312 field.SetProperty( TextField::Property::TEXT, longText );
2313 field.SetProperty( TextField::Property::POINT_SIZE, 10.f );
2314 field.SetSize( 300.f, 50.f );
2315 field.SetParentOrigin( ParentOrigin::TOP_LEFT );
2316 field.SetAnchorPoint( AnchorPoint::TOP_LEFT );
2318 // Avoid a crash when core load gl resources.
2319 application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
2320 // Render and notify
2321 application.SendNotification();
2322 application.Render();
2324 // Create a tap event to touch the text field.
2325 application.ProcessEvent( GenerateTap( Gesture::Possible, 1u, 1u, Vector2( 150.0f, 25.0f ) ) );
2326 application.ProcessEvent( GenerateTap( Gesture::Started, 1u, 1u, Vector2( 150.0f, 25.0f ) ) );
2328 // Render and notify
2329 application.SendNotification();
2330 application.Render();
2332 // Tap first to get the focus.
2333 application.ProcessEvent( GenerateTap( Gesture::Possible, 1u, 1u, Vector2( 1.f, 25.0f ) ) );
2334 application.ProcessEvent( GenerateTap( Gesture::Started, 1u, 1u, Vector2( 1.f, 25.0f ) ) );
2336 // Render and notify
2337 application.SendNotification();
2338 application.Render();
2340 // Double tap to select a word.
2341 application.ProcessEvent( GenerateTap( Gesture::Possible, 2u, 1u, Vector2( 1.f, 25.0f ) ) );
2342 application.ProcessEvent( GenerateTap( Gesture::Started, 2u, 1u, Vector2( 1.f, 25.0f ) ) );
2344 // Render and notify
2345 application.SendNotification();
2346 application.Render();
2348 // Generate a Esc key event. The text field should lose the focus.
2349 application.ProcessEvent( GenerateKey( "XF86PowerOff", "XF86PowerOff", DALI_KEY_POWER, 0, 0, Integration::KeyEvent::Down, DEFAULT_DEVICE_NAME, DevelKeyEvent::DeviceClass::NONE ) );
2350 application.ProcessEvent( GenerateKey( "XF86PowerOff", "XF86PowerOff", DALI_KEY_POWER, 0, 0, Integration::KeyEvent::Up, DEFAULT_DEVICE_NAME, DevelKeyEvent::DeviceClass::NONE ) );
2352 // Render and notify
2353 application.SendNotification();
2354 application.Render();
2356 // Generate a Esc key event. The text field should lose the focus.
2357 application.ProcessEvent( GenerateKey( "XF86Menu", "XF86Menu", DALI_KEY_MENU, 0, 0, Integration::KeyEvent::Down, DEFAULT_DEVICE_NAME, DevelKeyEvent::DeviceClass::NONE ) );
2358 application.ProcessEvent( GenerateKey( "XF86Menu", "XF86Menu", DALI_KEY_MENU, 0, 0, Integration::KeyEvent::Up, DEFAULT_DEVICE_NAME, DevelKeyEvent::DeviceClass::NONE ) );
2360 // Render and notify
2361 application.SendNotification();
2362 application.Render();
2364 // Generate a Esc key event. The text field should lose the focus.
2365 application.ProcessEvent( GenerateKey( "XF86Home", "XF86Home", DALI_KEY_HOME, 0, 0, Integration::KeyEvent::Down, DEFAULT_DEVICE_NAME, DevelKeyEvent::DeviceClass::NONE ) );
2366 application.ProcessEvent( GenerateKey( "XF86Home", "XF86Home", DALI_KEY_HOME, 0, 0, Integration::KeyEvent::Up, DEFAULT_DEVICE_NAME, DevelKeyEvent::DeviceClass::NONE ) );
2368 // Render and notify
2369 application.SendNotification();
2370 application.Render();
2372 // The text shouldn't be deleted.
2373 DALI_TEST_EQUALS( field.GetProperty<std::string>( TextField::Property::TEXT ), longText, TEST_LOCATION );