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/devel-api/adaptor-framework/key-devel.h>
29 #include <dali-toolkit-test-suite-utils.h>
30 #include <dali-toolkit/dali-toolkit.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";
102 const char* const PROPERTY_NAME_PLACEHOLDER = "placeholder";
103 const char* const PROPERTY_NAME_ELLIPSIS = "ellipsis";
104 const char* const PROPERTY_NAME_ENABLE_SHIFT_SELECTION = "enableShiftSelection";
106 const int DEFAULT_RENDERING_BACKEND = Dali::Toolkit::Text::DEFAULT_RENDERING_BACKEND;
108 const Vector4 PLACEHOLDER_TEXT_COLOR( 0.8f, 0.8f, 0.8f, 0.8f );
109 const Dali::Vector4 LIGHT_BLUE( 0.75f, 0.96f, 1.f, 1.f ); // The text highlight color.
111 const unsigned int CURSOR_BLINK_INTERVAL = 500u; // Cursor blink interval
112 const float RENDER_FRAME_INTERVAL = 16.66f;
114 const float TO_MILLISECONDS = 1000.f;
115 const float TO_SECONDS = 1.f / TO_MILLISECONDS;
117 const float SCROLL_THRESHOLD = 10.f;
118 const float SCROLL_SPEED = 300.f;
120 const unsigned int DEFAULT_FONT_SIZE = 1152u;
121 const std::string DEFAULT_FONT_DIR( "/resources/fonts" );
123 const int KEY_RETURN_CODE = 36;
124 const int KEY_A_CODE = 38;
125 const int KEY_D_CODE = 40;
127 const std::string DEFAULT_DEVICE_NAME("hwKeyboard");
129 static bool gTextChangedCallBackCalled;
130 static bool gMaxCharactersCallBackCalled;
131 static bool gInputStyleChangedCallbackCalled;
132 static Dali::Toolkit::TextField::InputStyle::Mask gInputStyleMask;
134 static void LoadBitmapResource(TestPlatformAbstraction& platform, int width, int height)
136 Integration::Bitmap* bitmap = Integration::Bitmap::New( Integration::Bitmap::BITMAP_2D_PACKED_PIXELS, ResourcePolicy::OWNED_DISCARD );
137 Integration::ResourcePointer resource(bitmap);
138 bitmap->GetPackedPixelsProfile()->ReserveBuffer(Pixel::RGBA8888, width, height, width, height);
141 static void LoadMarkerImages(ToolkitTestApplication& app, TextField textField)
145 LoadBitmapResource( app.GetPlatform(), width, height );
147 Property::Map propertyMap;
148 propertyMap["filename"] = "image.png";
149 propertyMap["width"] = width;
150 propertyMap["height"] = height;
151 textField.SetProperty( Toolkit::TextField::Property::SELECTION_HANDLE_IMAGE_LEFT, propertyMap );
152 textField.SetProperty( Toolkit::TextField::Property::SELECTION_HANDLE_IMAGE_RIGHT, propertyMap );
153 textField.SetProperty( Toolkit::TextField::Property::SELECTION_HANDLE_PRESSED_IMAGE_LEFT, propertyMap );
154 textField.SetProperty( Toolkit::TextField::Property::SELECTION_HANDLE_PRESSED_IMAGE_RIGHT, propertyMap );
155 textField.SetProperty( Toolkit::TextField::Property::SELECTION_HANDLE_MARKER_IMAGE_LEFT, propertyMap );
156 textField.SetProperty( Toolkit::TextField::Property::SELECTION_HANDLE_MARKER_IMAGE_RIGHT, propertyMap );
157 textField.SetProperty( Toolkit::TextField::Property::GRAB_HANDLE_IMAGE, propertyMap );
158 textField.SetProperty( Toolkit::TextField::Property::GRAB_HANDLE_PRESSED_IMAGE, propertyMap );
161 // Generate a PanGestureEvent to send to Core
162 static Integration::PanGestureEvent GeneratePan(
163 Gesture::State state,
164 const Vector2& previousPosition,
165 const Vector2& currentPosition,
166 unsigned long timeDelta,
167 unsigned int numberOfTouches = 1)
169 Integration::PanGestureEvent pan(state);
171 pan.previousPosition = previousPosition;
172 pan.currentPosition = currentPosition;
173 pan.timeDelta = timeDelta;
174 pan.numberOfTouches = numberOfTouches;
180 * Helper to generate PanGestureEvent
182 * @param[in] application Application instance
183 * @param[in] state The Gesture State
184 * @param[in] pos The current position of touch.
186 static void SendPan(ToolkitTestApplication& application, Gesture::State state, const Vector2& pos)
190 if( (state == Gesture::Started) ||
191 (state == Gesture::Possible) )
197 application.ProcessEvent(GeneratePan(state, last, pos, 16));
204 * Simulate time passed by.
206 * @note this will always process at least 1 frame (1/60 sec)
208 * @param application Test application instance
209 * @param duration Time to pass in milliseconds.
210 * @return The actual time passed in milliseconds
212 static int Wait(ToolkitTestApplication& application, int duration = 0)
216 for(int i = 0; i <= ( duration / RENDER_FRAME_INTERVAL); i++)
218 application.SendNotification();
219 application.Render(RENDER_FRAME_INTERVAL);
220 time += RENDER_FRAME_INTERVAL;
226 Dali::Integration::Point GetPointDownInside( Vector2& pos )
228 Dali::Integration::Point point;
229 point.SetState( PointState::DOWN );
230 point.SetScreenPosition( pos );
234 Dali::Integration::Point GetPointUpInside( Vector2& pos )
236 Dali::Integration::Point point;
237 point.SetState( PointState::UP );
238 point.SetScreenPosition( pos );
242 struct CallbackFunctor
244 CallbackFunctor(bool* callbackFlag)
245 : mCallbackFlag( callbackFlag )
251 *mCallbackFlag = true;
256 static void TestTextChangedCallback( TextField control )
258 tet_infoline(" TestTextChangedCallback");
260 gTextChangedCallBackCalled = true;
263 static void TestMaxLengthReachedCallback( TextField control )
265 tet_infoline(" TestMaxLengthReachedCallback");
267 gMaxCharactersCallBackCalled = true;
270 static void TestInputStyleChangedCallback( TextField control, TextField::InputStyle::Mask mask )
272 tet_infoline(" TestInputStyleChangedCallback");
274 gInputStyleChangedCallbackCalled = true;
275 gInputStyleMask = mask;
278 // Generate a TapGestureEvent to send to Core.
279 Integration::TapGestureEvent GenerateTap(
280 Gesture::State state,
281 unsigned int numberOfTaps,
282 unsigned int numberOfTouches,
285 Integration::TapGestureEvent tap( state );
287 tap.numberOfTaps = numberOfTaps;
288 tap.numberOfTouches = numberOfTouches;
294 Integration::LongPressGestureEvent GenerateLongPress(
295 Gesture::State state,
296 unsigned int numberOfTouches,
299 Integration::LongPressGestureEvent longPress( state );
301 longPress.numberOfTouches = numberOfTouches;
302 longPress.point = point;
306 // Generate a KeyEvent to send to Core.
307 Integration::KeyEvent GenerateKey( const std::string& keyName,
308 const std::string& keyString,
311 unsigned long timeStamp,
312 const Integration::KeyEvent::State& keyState,
313 const std::string& deviceName = DEFAULT_DEVICE_NAME,
314 const Device::Class::Type& deviceClass = Device::Class::NONE,
315 const Device::Subclass::Type& deviceSubclass = Device::Subclass::NONE )
317 return Integration::KeyEvent( keyName,
328 bool DaliTestCheckMaps( const Property::Map& fontStyleMapGet, const Property::Map& fontStyleMapSet )
330 if( fontStyleMapGet.Count() == fontStyleMapSet.Count() )
332 for( unsigned int index = 0u; index < fontStyleMapGet.Count(); ++index )
334 const KeyValuePair& valueGet = fontStyleMapGet.GetKeyValue( index );
336 Property::Value* valueSet = NULL;
337 if ( valueGet.first.type == Property::Key::INDEX )
339 valueSet = fontStyleMapSet.Find( valueGet.first.indexKey );
343 // Get Key is a string so searching Set Map for a string key
344 valueSet = fontStyleMapSet.Find( valueGet.first.stringKey );
347 if( NULL != valueSet )
349 if( valueSet->GetType() == Dali::Property::STRING && ( valueGet.second.Get<std::string>() != valueSet->Get<std::string>() ) )
351 tet_printf( "Value got : [%s], expected : [%s]", valueGet.second.Get<std::string>().c_str(), valueSet->Get<std::string>().c_str() );
354 else if( valueSet->GetType() == Dali::Property::BOOLEAN && ( valueGet.second.Get<bool>() != valueSet->Get<bool>() ) )
356 tet_printf( "Value got : [%d], expected : [%d]", valueGet.second.Get<bool>(), valueSet->Get<bool>() );
359 else if( valueSet->GetType() == Dali::Property::INTEGER && ( valueGet.second.Get<int>() != valueSet->Get<int>() ) )
361 tet_printf( "Value got : [%d], expected : [%d]", valueGet.second.Get<int>(), valueSet->Get<int>() );
364 else if( valueSet->GetType() == Dali::Property::FLOAT && ( valueGet.second.Get<float>() != valueSet->Get<float>() ) )
366 tet_printf( "Value got : [%f], expected : [%f]", valueGet.second.Get<float>(), valueSet->Get<float>() );
369 else if( valueSet->GetType() == Dali::Property::VECTOR2 && ( valueGet.second.Get<Vector2>() != valueSet->Get<Vector2>() ) )
371 Vector2 vector2Get = valueGet.second.Get<Vector2>();
372 Vector2 vector2Set = valueSet->Get<Vector2>();
373 tet_printf( "Value got : [%f, %f], expected : [%f, %f]", vector2Get.x, vector2Get.y, vector2Set.x, vector2Set.y );
376 else if( valueSet->GetType() == Dali::Property::VECTOR4 && ( valueGet.second.Get<Vector4>() != valueSet->Get<Vector4>() ) )
378 Vector4 vector4Get = valueGet.second.Get<Vector4>();
379 Vector4 vector4Set = valueSet->Get<Vector4>();
380 tet_printf( "Value got : [%f, %f, %f, %f], expected : [%f, %f, %f, %f]", vector4Get.r, vector4Get.g, vector4Get.b, vector4Get.a, vector4Set.r, vector4Set.g, vector4Set.b, vector4Set.a );
386 if ( valueGet.first.type == Property::Key::INDEX )
388 tet_printf( " The key %d doesn't exist.", valueGet.first.indexKey );
392 tet_printf( " The key %s doesn't exist.", valueGet.first.stringKey.c_str() );
404 int UtcDaliToolkitTextFieldConstructorP(void)
406 ToolkitTestApplication application;
407 tet_infoline(" UtcDaliToolkitTextFieldConstructorP");
409 DALI_TEST_CHECK( !textField );
413 int UtcDaliToolkitTextFieldNewP(void)
415 ToolkitTestApplication application;
416 tet_infoline(" UtcDaliToolkitTextFieldNewP");
417 TextField textField = TextField::New();
418 DALI_TEST_CHECK( textField );
422 int UtcDaliToolkitTextFieldDownCastP(void)
424 ToolkitTestApplication application;
425 tet_infoline(" UtcDaliToolkitTextFieldDownCastP");
426 TextField textField1 = TextField::New();
427 BaseHandle object( textField1 );
429 TextField textField2 = TextField::DownCast( object );
430 DALI_TEST_CHECK( textField2 );
432 TextField textField3 = DownCast< TextField >( object );
433 DALI_TEST_CHECK( textField3 );
437 int UtcDaliToolkitTextFieldDownCastN(void)
439 ToolkitTestApplication application;
440 tet_infoline(" UtcDaliToolkitTextFieldDownCastN");
441 BaseHandle uninitializedObject;
442 TextField textField1 = TextField::DownCast( uninitializedObject );
443 DALI_TEST_CHECK( !textField1 );
445 TextField textField2 = DownCast< TextField >( uninitializedObject );
446 DALI_TEST_CHECK( !textField2 );
450 int UtcDaliToolkitTextFieldCopyConstructorP(void)
452 ToolkitTestApplication application;
453 tet_infoline(" UtcDaliToolkitTextFieldCopyConstructorP");
454 TextField textField = TextField::New();
455 textField.SetProperty( TextField::Property::TEXT, "Test" );
457 TextField copy( textField );
458 DALI_TEST_CHECK( copy );
459 DALI_TEST_CHECK( copy.GetProperty<std::string>( TextLabel::Property::TEXT ) == textField.GetProperty<std::string>( TextLabel::Property::TEXT ) );
463 int UtcDaliToolkitTextFieldAssignmentOperatorP(void)
465 ToolkitTestApplication application;
466 tet_infoline(" UtcDaliToolkitTextFieldAssignmentOperatorP");
467 TextField textField = TextField::New();
468 textField.SetProperty( TextField::Property::TEXT, "Test" );
470 TextField copy = textField;
471 DALI_TEST_CHECK( copy );
472 DALI_TEST_CHECK( copy.GetProperty<std::string>( TextField::Property::TEXT ) == textField.GetProperty<std::string>( TextField::Property::TEXT ) );
476 int UtcDaliTextFieldNewP(void)
478 ToolkitTestApplication application;
479 tet_infoline(" UtcDaliToolkitTextFieldNewP");
480 TextField textField = TextField::New();
481 DALI_TEST_CHECK( textField );
485 // Positive test case for a method
486 int UtcDaliTextFieldGetPropertyP(void)
488 ToolkitTestApplication application;
489 tet_infoline(" UtcDaliToolkitTextFieldGetPropertyP");
490 TextField field = TextField::New();
491 DALI_TEST_CHECK( field );
493 // Check Property Indices are correct
494 DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_RENDERING_BACKEND ) == TextField::Property::RENDERING_BACKEND );
495 DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_TEXT ) == TextField::Property::TEXT );
496 DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_PLACEHOLDER_TEXT ) == TextField::Property::PLACEHOLDER_TEXT );
497 DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_PLACEHOLDER_TEXT_FOCUSED ) == TextField::Property::PLACEHOLDER_TEXT_FOCUSED );
498 DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_FONT_FAMILY ) == TextField::Property::FONT_FAMILY );
499 DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_FONT_STYLE ) == TextField::Property::FONT_STYLE );
500 DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_POINT_SIZE ) == TextField::Property::POINT_SIZE );
501 DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_MAX_LENGTH ) == TextField::Property::MAX_LENGTH );
502 DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_EXCEED_POLICY ) == TextField::Property::EXCEED_POLICY );
503 DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_HORIZONTAL_ALIGNMENT ) == TextField::Property::HORIZONTAL_ALIGNMENT );
504 DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_VERTICAL_ALIGNMENT ) == TextField::Property::VERTICAL_ALIGNMENT );
505 DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_TEXT_COLOR ) == TextField::Property::TEXT_COLOR );
506 DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_PLACEHOLDER_TEXT_COLOR ) == TextField::Property::PLACEHOLDER_TEXT_COLOR );
507 DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_SHADOW_OFFSET ) == TextField::Property::SHADOW_OFFSET );
508 DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_SHADOW_COLOR ) == TextField::Property::SHADOW_COLOR );
509 DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_PRIMARY_CURSOR_COLOR ) == TextField::Property::PRIMARY_CURSOR_COLOR );
510 DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_SECONDARY_CURSOR_COLOR ) == TextField::Property::SECONDARY_CURSOR_COLOR );
511 DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_ENABLE_CURSOR_BLINK ) == TextField::Property::ENABLE_CURSOR_BLINK );
512 DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_CURSOR_BLINK_INTERVAL ) == TextField::Property::CURSOR_BLINK_INTERVAL );
513 DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_CURSOR_BLINK_DURATION ) == TextField::Property::CURSOR_BLINK_DURATION );
514 DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_CURSOR_WIDTH ) == TextField::Property::CURSOR_WIDTH );
515 DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_GRAB_HANDLE_IMAGE ) == TextField::Property::GRAB_HANDLE_IMAGE );
516 DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_GRAB_HANDLE_PRESSED_IMAGE ) == TextField::Property::GRAB_HANDLE_PRESSED_IMAGE );
517 DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_SCROLL_THRESHOLD ) == TextField::Property::SCROLL_THRESHOLD );
518 DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_SCROLL_SPEED ) == TextField::Property::SCROLL_SPEED );
519 DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_SELECTION_HANDLE_IMAGE_LEFT ) == TextField::Property::SELECTION_HANDLE_IMAGE_LEFT );
520 DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_SELECTION_HANDLE_IMAGE_RIGHT ) == TextField::Property::SELECTION_HANDLE_IMAGE_RIGHT );
521 DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_SELECTION_HANDLE_PRESSED_IMAGE_LEFT ) == TextField::Property::SELECTION_HANDLE_PRESSED_IMAGE_LEFT );
522 DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_SELECTION_HANDLE_PRESSED_IMAGE_RIGHT ) == TextField::Property::SELECTION_HANDLE_PRESSED_IMAGE_RIGHT );
523 DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_SELECTION_HANDLE_MARKER_IMAGE_LEFT ) == TextField::Property::SELECTION_HANDLE_MARKER_IMAGE_LEFT );
524 DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_SELECTION_HANDLE_MARKER_IMAGE_RIGHT ) == TextField::Property::SELECTION_HANDLE_MARKER_IMAGE_RIGHT );
525 DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_SELECTION_HIGHLIGHT_COLOR ) == TextField::Property::SELECTION_HIGHLIGHT_COLOR );
526 DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_DECORATION_BOUNDING_BOX ) == TextField::Property::DECORATION_BOUNDING_BOX );
527 DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_INPUT_METHOD_SETTINGS ) == TextField::Property::INPUT_METHOD_SETTINGS );
528 DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_INPUT_COLOR ) == TextField::Property::INPUT_COLOR );
529 DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_ENABLE_MARKUP ) == TextField::Property::ENABLE_MARKUP );
530 DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_INPUT_FONT_FAMILY ) == TextField::Property::INPUT_FONT_FAMILY );
531 DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_INPUT_FONT_STYLE ) == TextField::Property::INPUT_FONT_STYLE );
532 DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_INPUT_POINT_SIZE ) == TextField::Property::INPUT_POINT_SIZE );
533 DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_UNDERLINE ) == TextField::Property::UNDERLINE );
534 DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_INPUT_UNDERLINE ) == TextField::Property::INPUT_UNDERLINE );
535 DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_SHADOW ) == TextField::Property::SHADOW );
536 DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_INPUT_SHADOW ) == TextField::Property::INPUT_SHADOW );
537 DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_EMBOSS ) == TextField::Property::EMBOSS );
538 DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_INPUT_EMBOSS ) == TextField::Property::INPUT_EMBOSS );
539 DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_OUTLINE ) == TextField::Property::OUTLINE );
540 DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_INPUT_OUTLINE ) == TextField::Property::INPUT_OUTLINE );
541 DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_HIDDEN_INPUT_SETTINGS ) == TextField::Property::HIDDEN_INPUT_SETTINGS );
542 DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_PIXEL_SIZE ) == TextField::Property::PIXEL_SIZE );
543 DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_ENABLE_SELECTION ) == TextField::Property::ENABLE_SELECTION );
544 DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_PLACEHOLDER ) == TextField::Property::PLACEHOLDER );
545 DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_ELLIPSIS ) == TextField::Property::ELLIPSIS );
546 DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_ENABLE_SHIFT_SELECTION ) == DevelTextField::Property::ENABLE_SHIFT_SELECTION );
551 bool SetPropertyMapRetrieved( TextField& field, const Property::Index property, const std::string mapKey, const std::string mapValue )
554 Property::Map imageMap;
555 imageMap[mapKey] =mapValue;
557 field.SetProperty( property , imageMap );
558 Property::Value propValue = field.GetProperty( property );
559 Property::Map* resultMap = propValue.GetMap();
561 if ( resultMap->Find( mapKey )->Get< std::string>() == mapValue )
569 // Positive test case for a method
570 int UtcDaliTextFieldSetPropertyP(void)
572 ToolkitTestApplication application;
573 tet_infoline(" UtcDaliToolkitTextFieldSetPropertyP");
574 TextField field = TextField::New();
575 DALI_TEST_CHECK( field );
576 Stage::GetCurrent().Add( field );
578 // Note - we can't check the defaults since the stylesheets are platform-specific
580 // Check the render backend property.
581 field.SetProperty( TextField::Property::RENDERING_BACKEND, Text::RENDERING_SHARED_ATLAS );
582 DALI_TEST_EQUALS( (Text::RenderingType)field.GetProperty<int>( TextField::Property::RENDERING_BACKEND ), Text::RENDERING_SHARED_ATLAS, TEST_LOCATION );
584 // Check text property.
585 field.SetProperty( TextField::Property::TEXT, "Setting Text" );
586 DALI_TEST_EQUALS( field.GetProperty<std::string>( TextField::Property::TEXT ), std::string("Setting Text"), TEST_LOCATION );
588 // Check placeholder text properties.
589 field.SetProperty( TextField::Property::PLACEHOLDER_TEXT, "Setting Placeholder Text" );
590 DALI_TEST_EQUALS( field.GetProperty<std::string>( TextField::Property::PLACEHOLDER_TEXT ), std::string("Setting Placeholder Text"), TEST_LOCATION );
592 field.SetProperty( TextField::Property::PLACEHOLDER_TEXT_FOCUSED, "Setting Placeholder Text Focused" );
593 DALI_TEST_EQUALS( field.GetProperty<std::string>( TextField::Property::PLACEHOLDER_TEXT_FOCUSED ), std::string("Setting Placeholder Text Focused"), TEST_LOCATION );
595 // Check font properties.
596 field.SetProperty( TextField::Property::FONT_FAMILY, "Setting font family" );
597 DALI_TEST_EQUALS( field.GetProperty<std::string>( TextField::Property::FONT_FAMILY ), std::string("Setting font family"), TEST_LOCATION );
599 Property::Map fontStyleMapSet;
600 Property::Map fontStyleMapGet;
601 Property::Value* slantValue = NULL;
603 fontStyleMapSet.Insert( "weight", "bold" );
604 fontStyleMapSet.Insert( "width", "condensed" );
605 fontStyleMapSet.Insert( "slant", "italic" );
606 field.SetProperty( TextField::Property::FONT_STYLE, fontStyleMapSet );
608 fontStyleMapGet = field.GetProperty<Property::Map>( TextField::Property::FONT_STYLE );
609 DALI_TEST_EQUALS( fontStyleMapGet.Count(), fontStyleMapSet.Count(), TEST_LOCATION );
610 DALI_TEST_EQUALS( DaliTestCheckMaps( fontStyleMapGet, fontStyleMapSet ), true, TEST_LOCATION );
612 field.SetProperty( TextField::Property::POINT_SIZE, 10.f );
613 DALI_TEST_EQUALS( field.GetProperty<float>( TextField::Property::POINT_SIZE ), 10.f, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
616 fontStyleMapSet.Clear();
617 fontStyleMapSet.Insert( "weight", "normal" );
618 fontStyleMapSet.Insert( "slant", "oblique" );
619 field.SetProperty( TextField::Property::FONT_STYLE, fontStyleMapSet );
621 fontStyleMapGet = field.GetProperty<Property::Map>( TextField::Property::FONT_STYLE );
622 DALI_TEST_EQUALS( fontStyleMapGet.Count(), fontStyleMapSet.Count(), TEST_LOCATION );
623 DALI_TEST_EQUALS( DaliTestCheckMaps( fontStyleMapGet, fontStyleMapSet ), true, TEST_LOCATION );
625 fontStyleMapSet.Clear();
626 fontStyleMapSet.Insert( "slant", "roman" );
627 field.SetProperty( TextField::Property::FONT_STYLE, fontStyleMapSet );
628 fontStyleMapGet = field.GetProperty<Property::Map>( TextField::Property::FONT_STYLE );
630 // Replace 'roman' for 'normal'.
631 slantValue = fontStyleMapGet.Find( "slant" );
632 if( NULL != slantValue )
634 if( "normal" == slantValue->Get<std::string>() )
636 fontStyleMapGet["slant"] = "roman";
639 DALI_TEST_EQUALS( fontStyleMapGet.Count(), fontStyleMapSet.Count(), TEST_LOCATION );
640 DALI_TEST_EQUALS( DaliTestCheckMaps( fontStyleMapGet, fontStyleMapSet ), true, TEST_LOCATION );
642 fontStyleMapSet.Clear();
644 field.SetProperty( TextField::Property::FONT_STYLE, fontStyleMapSet );
645 fontStyleMapGet = field.GetProperty<Property::Map>( TextField::Property::FONT_STYLE );
646 DALI_TEST_EQUALS( fontStyleMapGet.Count(), fontStyleMapSet.Count(), TEST_LOCATION );
647 DALI_TEST_EQUALS( DaliTestCheckMaps( fontStyleMapGet, fontStyleMapSet ), true, TEST_LOCATION );
649 // Check that the MAX_LENGTH property can be correctly set
650 const int maxNumberOfCharacters = 20;
651 field.SetProperty( TextField::Property::MAX_LENGTH, maxNumberOfCharacters );
652 DALI_TEST_EQUALS( field.GetProperty<int>( TextField::Property::MAX_LENGTH ), maxNumberOfCharacters, TEST_LOCATION );
654 // Check exceed policy
655 field.SetProperty( TextField::Property::EXCEED_POLICY, Dali::Toolkit::TextField::EXCEED_POLICY_CLIP );
656 DALI_TEST_EQUALS( field.GetProperty<int>( TextField::Property::EXCEED_POLICY ), static_cast<int>( Dali::Toolkit::TextField::EXCEED_POLICY_CLIP ), TEST_LOCATION );
657 field.SetProperty( TextField::Property::EXCEED_POLICY, Dali::Toolkit::TextField::EXCEED_POLICY_ORIGINAL );
658 DALI_TEST_EQUALS( field.GetProperty<int>( TextField::Property::EXCEED_POLICY ), static_cast<int>( Dali::Toolkit::TextField::EXCEED_POLICY_ORIGINAL ), TEST_LOCATION );
660 // Check that the Alignment properties can be correctly set
661 field.SetProperty( TextField::Property::HORIZONTAL_ALIGNMENT, "END" );
662 DALI_TEST_EQUALS( field.GetProperty<std::string>( TextField::Property::HORIZONTAL_ALIGNMENT ), "END", TEST_LOCATION );
663 field.SetProperty( TextField::Property::VERTICAL_ALIGNMENT, "CENTER" );
664 DALI_TEST_EQUALS( field.GetProperty<std::string>( TextField::Property::VERTICAL_ALIGNMENT ), "CENTER", TEST_LOCATION );
666 // Check text's color property
667 field.SetProperty( TextField::Property::TEXT_COLOR, Color::WHITE );
668 DALI_TEST_EQUALS( field.GetProperty<Vector4>( TextField::Property::TEXT_COLOR ), Color::WHITE, TEST_LOCATION );
670 // Check placeholder text's color property.
671 field.SetProperty( TextField::Property::PLACEHOLDER_TEXT_COLOR, Color::RED );
672 DALI_TEST_EQUALS( field.GetProperty<Vector4>( TextField::Property::PLACEHOLDER_TEXT_COLOR ), Color::RED, TEST_LOCATION );
674 // Check shadow properties.
675 field.SetProperty( TextField::Property::SHADOW_OFFSET, Vector2( 1.f, 1.f ) );
676 DALI_TEST_EQUALS( field.GetProperty<Vector2>( TextField::Property::SHADOW_OFFSET ), Vector2( 1.f, 1.f ), TEST_LOCATION );
677 field.SetProperty( TextField::Property::SHADOW_COLOR, Color::GREEN );
678 DALI_TEST_EQUALS( field.GetProperty<Vector4>( TextField::Property::SHADOW_COLOR ), Color::GREEN, TEST_LOCATION );
680 // Check cursor properties
681 field.SetProperty( TextField::Property::PRIMARY_CURSOR_COLOR, Color::RED );
682 DALI_TEST_EQUALS( field.GetProperty<Vector4>( TextField::Property::PRIMARY_CURSOR_COLOR ), Color::RED, TEST_LOCATION );
683 field.SetProperty( TextField::Property::SECONDARY_CURSOR_COLOR, Color::BLUE );
684 DALI_TEST_EQUALS( field.GetProperty<Vector4>( TextField::Property::SECONDARY_CURSOR_COLOR ), Color::BLUE, TEST_LOCATION );
686 field.SetProperty( TextField::Property::ENABLE_CURSOR_BLINK, false );
687 DALI_TEST_EQUALS( field.GetProperty<bool>( TextField::Property::ENABLE_CURSOR_BLINK ), false, TEST_LOCATION );
688 field.SetProperty( TextField::Property::CURSOR_BLINK_INTERVAL, 1.f );
689 DALI_TEST_EQUALS( field.GetProperty<float>( TextField::Property::CURSOR_BLINK_INTERVAL ), 1.f, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
690 field.SetProperty( TextField::Property::CURSOR_BLINK_DURATION, 10.f );
691 DALI_TEST_EQUALS( field.GetProperty<float>( TextField::Property::CURSOR_BLINK_DURATION ), 10.f, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
692 field.SetProperty( TextField::Property::CURSOR_WIDTH, 1 );
693 DALI_TEST_EQUALS( field.GetProperty<int>( TextField::Property::CURSOR_WIDTH ), 1, TEST_LOCATION );
695 // Check scroll properties.
696 field.SetProperty( TextField::Property::SCROLL_THRESHOLD, 1.f );
697 DALI_TEST_EQUALS( field.GetProperty<float>( TextField::Property::SCROLL_THRESHOLD ), 1.f, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
698 field.SetProperty( TextField::Property::SCROLL_SPEED, 100.f );
699 DALI_TEST_EQUALS( field.GetProperty<float>( TextField::Property::SCROLL_SPEED ), 100.f, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
701 // Check handle images
702 field.SetProperty( TextField::Property::GRAB_HANDLE_IMAGE, "image1" );
703 DALI_TEST_EQUALS( field.GetProperty<std::string>( TextField::Property::GRAB_HANDLE_IMAGE ), "image1", TEST_LOCATION );
704 field.SetProperty( TextField::Property::GRAB_HANDLE_PRESSED_IMAGE, "image2" );
705 DALI_TEST_EQUALS( field.GetProperty<std::string>( TextField::Property::GRAB_HANDLE_PRESSED_IMAGE ), "image2", TEST_LOCATION );
706 field.SetProperty( TextField::Property::SELECTION_HANDLE_IMAGE_LEFT, "image3" );
708 // Check handle images
709 DALI_TEST_CHECK( SetPropertyMapRetrieved( field, TextField::Property::SELECTION_HANDLE_IMAGE_LEFT, "filename", "leftHandleImage" ) );
710 DALI_TEST_CHECK( SetPropertyMapRetrieved( field, TextField::Property::SELECTION_HANDLE_IMAGE_RIGHT, "filename", "rightHandleImage" ) );
711 DALI_TEST_CHECK( SetPropertyMapRetrieved( field, TextField::Property::SELECTION_HANDLE_PRESSED_IMAGE_LEFT, "filename", "leftHandleImagePressed" ) );
712 DALI_TEST_CHECK( SetPropertyMapRetrieved( field, TextField::Property::SELECTION_HANDLE_PRESSED_IMAGE_RIGHT, "filename", "rightHandleImagePressed" ) );
713 DALI_TEST_CHECK( SetPropertyMapRetrieved( field, TextField::Property::SELECTION_HANDLE_MARKER_IMAGE_LEFT, "filename", "leftHandleMarkerImage" ) );
714 DALI_TEST_CHECK( SetPropertyMapRetrieved( field, TextField::Property::SELECTION_HANDLE_MARKER_IMAGE_RIGHT, "filename", "rightHandleMarkerImage" ) );
716 // Check the highlight color
717 field.SetProperty( TextField::Property::SELECTION_HIGHLIGHT_COLOR, Color::GREEN );
718 DALI_TEST_EQUALS( field.GetProperty<Vector4>( TextField::Property::SELECTION_HIGHLIGHT_COLOR ), Color::GREEN, TEST_LOCATION );
720 // Decoration bounding box
721 field.SetProperty( TextField::Property::DECORATION_BOUNDING_BOX, Rect<int>( 0, 0, 1, 1 ) );
722 DALI_TEST_EQUALS( field.GetProperty<Rect <int > >( TextField::Property::DECORATION_BOUNDING_BOX ), Rect<int>( 0, 0, 1, 1 ), TEST_LOCATION );
724 // Check the input method setting
725 Property::Map propertyMap;
726 InputMethod::PanelLayout::Type panelLayout = InputMethod::PanelLayout::NUMBER;
727 InputMethod::AutoCapital::Type autoCapital = InputMethod::AutoCapital::WORD;
728 InputMethod::ActionButtonTitle::Type actionButton = InputMethod::ActionButtonTitle::GO;
729 int inputVariation = 1;
730 propertyMap["PANEL_LAYOUT"] = panelLayout;
731 propertyMap["AUTO_CAPITALISE"] = autoCapital;
732 propertyMap["ACTION_BUTTON"] = actionButton;
733 propertyMap["VARIATION"] = inputVariation;
734 field.SetProperty( TextField::Property::INPUT_METHOD_SETTINGS, propertyMap );
736 Property::Value value = field.GetProperty( TextField::Property::INPUT_METHOD_SETTINGS );
738 DALI_TEST_CHECK( value.Get( map ) );
741 DALI_TEST_CHECK( map[ "PANEL_LAYOUT" ].Get( layout ) );
742 DALI_TEST_EQUALS( static_cast<int>(panelLayout), layout, TEST_LOCATION );
745 DALI_TEST_CHECK( map[ "AUTO_CAPITALISE" ].Get( capital ) );
746 DALI_TEST_EQUALS( static_cast<int>(autoCapital), capital, TEST_LOCATION );
749 DALI_TEST_CHECK( map[ "ACTION_BUTTON" ].Get( action ) );
750 DALI_TEST_EQUALS( static_cast<int>(actionButton), action, TEST_LOCATION );
753 DALI_TEST_CHECK( map[ "VARIATION" ].Get( variation ) );
754 DALI_TEST_EQUALS( inputVariation, variation, TEST_LOCATION );
756 // Check input color property.
757 field.SetProperty( TextField::Property::INPUT_COLOR, Color::YELLOW );
758 DALI_TEST_EQUALS( field.GetProperty<Vector4>( TextField::Property::INPUT_COLOR ), Color::YELLOW, TEST_LOCATION );
760 // Check the enable markup property.
761 DALI_TEST_CHECK( !field.GetProperty<bool>( TextField::Property::ENABLE_MARKUP ) );
762 field.SetProperty( TextField::Property::ENABLE_MARKUP, true );
763 DALI_TEST_CHECK( field.GetProperty<bool>( TextField::Property::ENABLE_MARKUP ) );
765 // Check input font properties.
766 field.SetProperty( TextField::Property::INPUT_FONT_FAMILY, "Setting input font family" );
767 DALI_TEST_EQUALS( field.GetProperty<std::string>( TextField::Property::INPUT_FONT_FAMILY ), "Setting input font family", TEST_LOCATION );
769 fontStyleMapSet.Clear();
770 fontStyleMapSet.Insert( "weight", "bold" );
771 fontStyleMapSet.Insert( "width", "condensed" );
772 fontStyleMapSet.Insert( "slant", "italic" );
774 field.SetProperty( TextField::Property::INPUT_FONT_STYLE, fontStyleMapSet );
775 fontStyleMapGet = field.GetProperty<Property::Map>( TextField::Property::INPUT_FONT_STYLE );
776 DALI_TEST_EQUALS( fontStyleMapGet.Count(), fontStyleMapSet.Count(), TEST_LOCATION );
777 DALI_TEST_EQUALS( DaliTestCheckMaps( fontStyleMapGet, fontStyleMapSet ), true, TEST_LOCATION );
779 field.SetProperty( TextField::Property::INPUT_POINT_SIZE, 12.f );
780 DALI_TEST_EQUALS( field.GetProperty<float>( TextField::Property::INPUT_POINT_SIZE ), 12.f, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
782 // Reset input font style.
783 fontStyleMapSet.Clear();
784 fontStyleMapSet.Insert( "weight", "normal" );
785 fontStyleMapSet.Insert( "slant", "oblique" );
787 field.SetProperty( TextField::Property::INPUT_FONT_STYLE, fontStyleMapSet );
788 fontStyleMapGet = field.GetProperty<Property::Map>( TextField::Property::INPUT_FONT_STYLE );
789 DALI_TEST_EQUALS( fontStyleMapGet.Count(), fontStyleMapSet.Count(), TEST_LOCATION );
790 DALI_TEST_EQUALS( DaliTestCheckMaps( fontStyleMapGet, fontStyleMapSet ), true, TEST_LOCATION );
792 fontStyleMapSet.Clear();
793 fontStyleMapSet.Insert( "slant", "roman" );
795 field.SetProperty( TextField::Property::INPUT_FONT_STYLE, fontStyleMapSet );
796 fontStyleMapGet = field.GetProperty<Property::Map>( TextField::Property::INPUT_FONT_STYLE );
798 // Replace 'roman' for 'normal'.
799 slantValue = fontStyleMapGet.Find( "slant" );
800 if( NULL != slantValue )
802 if( "normal" == slantValue->Get<std::string>() )
804 fontStyleMapGet["slant"] = "roman";
807 DALI_TEST_EQUALS( fontStyleMapGet.Count(), fontStyleMapSet.Count(), TEST_LOCATION );
808 DALI_TEST_EQUALS( DaliTestCheckMaps( fontStyleMapGet, fontStyleMapSet ), true, TEST_LOCATION );
810 fontStyleMapSet.Clear();
812 field.SetProperty( TextField::Property::INPUT_FONT_STYLE, fontStyleMapSet );
813 fontStyleMapGet = field.GetProperty<Property::Map>( TextField::Property::INPUT_FONT_STYLE );
814 DALI_TEST_EQUALS( fontStyleMapGet.Count(), fontStyleMapSet.Count(), TEST_LOCATION );
815 DALI_TEST_EQUALS( DaliTestCheckMaps( fontStyleMapGet, fontStyleMapSet ), true, TEST_LOCATION );
817 Property::Map underlineMapSet;
818 Property::Map underlineMapGet;
820 underlineMapSet.Insert( "enable", "true" );
821 underlineMapSet.Insert( "color", "red" );
822 underlineMapSet.Insert( "height", "1" );
824 // Check the underline property
825 field.SetProperty( TextField::Property::UNDERLINE, underlineMapSet );
827 underlineMapGet = field.GetProperty<Property::Map>( TextField::Property::UNDERLINE );
828 DALI_TEST_EQUALS( underlineMapGet.Count(), underlineMapSet.Count(), TEST_LOCATION );
829 DALI_TEST_EQUALS( DaliTestCheckMaps( underlineMapGet, underlineMapSet ), true, TEST_LOCATION );
831 // Check the input underline property
832 field.SetProperty( TextField::Property::INPUT_UNDERLINE, "Underline input properties" );
833 DALI_TEST_EQUALS( field.GetProperty<std::string>( TextField::Property::INPUT_UNDERLINE ), std::string("Underline input properties"), TEST_LOCATION );
835 // Check the shadow property
836 Property::Map shadowMapSet;
837 Property::Map shadowMapGet;
839 shadowMapSet.Insert( "color", Color::GREEN );
840 shadowMapSet.Insert( "offset", Vector2(2.0f, 2.0f) );
841 shadowMapSet.Insert( "blurRadius", 3.0f );
843 field.SetProperty( TextField::Property::SHADOW, shadowMapSet );
845 shadowMapGet = field.GetProperty<Property::Map>( TextField::Property::SHADOW );
846 DALI_TEST_EQUALS( shadowMapGet.Count(), shadowMapSet.Count(), TEST_LOCATION );
847 DALI_TEST_EQUALS( DaliTestCheckMaps( shadowMapGet, shadowMapSet ), true, TEST_LOCATION );
849 // Check the input shadow property
850 field.SetProperty( TextField::Property::INPUT_SHADOW, "Shadow input properties" );
851 DALI_TEST_EQUALS( field.GetProperty<std::string>( TextField::Property::INPUT_SHADOW ), std::string("Shadow input properties"), TEST_LOCATION );
853 // Check the emboss property
854 field.SetProperty( TextField::Property::EMBOSS, "Emboss properties" );
855 DALI_TEST_EQUALS( field.GetProperty<std::string>( TextField::Property::EMBOSS ), std::string("Emboss properties"), TEST_LOCATION );
857 // Check the input emboss property
858 field.SetProperty( TextField::Property::INPUT_EMBOSS, "Emboss input properties" );
859 DALI_TEST_EQUALS( field.GetProperty<std::string>( TextField::Property::INPUT_EMBOSS ), std::string("Emboss input properties"), TEST_LOCATION );
861 // Check the outline property
863 // Test string type first
864 // This is purely to maintain backward compatibility, but we don't support string as the outline property type.
865 field.SetProperty( TextField::Property::OUTLINE, "Outline properties" );
866 DALI_TEST_EQUALS( field.GetProperty<std::string>( TextField::Property::OUTLINE ), std::string("Outline properties"), TEST_LOCATION );
868 // Then test the property map type
869 Property::Map outlineMapSet;
870 Property::Map outlineMapGet;
872 outlineMapSet["color"] = Color::RED;
873 outlineMapSet["width"] = 2.0f;
875 field.SetProperty( TextField::Property::OUTLINE, outlineMapSet );
877 outlineMapGet = field.GetProperty<Property::Map>( TextField::Property::OUTLINE );
878 DALI_TEST_EQUALS( outlineMapGet.Count(), outlineMapSet.Count(), TEST_LOCATION );
879 DALI_TEST_EQUALS( DaliTestCheckMaps( outlineMapGet, outlineMapSet ), true, TEST_LOCATION );
881 // Check the input outline property
882 field.SetProperty( TextField::Property::INPUT_OUTLINE, "Outline input properties" );
883 DALI_TEST_EQUALS( field.GetProperty<std::string>( TextField::Property::INPUT_OUTLINE ), std::string("Outline input properties"), TEST_LOCATION );
885 // Check the hidden input settings property
886 Property::Map hiddenMapSet;
887 Property::Map hiddenMapGet;
888 hiddenMapSet[ HiddenInput::Property::MODE ] = HiddenInput::Mode::HIDE_ALL;
889 hiddenMapSet[ HiddenInput::Property::SHOW_LAST_CHARACTER_DURATION ] = 2;
890 hiddenMapSet[ HiddenInput::Property::SUBSTITUTE_COUNT ] = 4;
891 hiddenMapSet[ HiddenInput::Property::SUBSTITUTE_CHARACTER ] = 0x23;
892 field.SetProperty( TextField::Property::HIDDEN_INPUT_SETTINGS, hiddenMapSet );
894 hiddenMapGet = field.GetProperty<Property::Map>( TextField::Property::HIDDEN_INPUT_SETTINGS );
895 DALI_TEST_EQUALS( hiddenMapSet.Count(), hiddenMapGet.Count(), TEST_LOCATION );
896 DALI_TEST_EQUALS( DaliTestCheckMaps( hiddenMapSet, hiddenMapGet ), true, TEST_LOCATION );
898 // Check the pixel size of font
899 field.SetProperty( TextField::Property::PIXEL_SIZE, 20.f );
900 DALI_TEST_EQUALS( field.GetProperty<float>( TextField::Property::PIXEL_SIZE ), 20.f, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
902 // Check the enable selection property
903 field.SetProperty( TextField::Property::ENABLE_SELECTION, false );
904 DALI_TEST_EQUALS( field.GetProperty<bool>( TextField::Property::ENABLE_SELECTION ), false, TEST_LOCATION );
906 // Check the placeholder property with pixel size
907 Property::Map placeholderPixelSizeMapSet;
908 Property::Map placeholderPixelSizeMapGet;
909 Property::Map placeholderFontstyleMap;
910 placeholderPixelSizeMapSet["text"] = "Setting Placeholder Text";
911 placeholderPixelSizeMapSet["textFocused"] = "Setting Placeholder Text Focused";
912 placeholderPixelSizeMapSet["color"] = Color::BLUE;
913 placeholderPixelSizeMapSet["fontFamily"] = "Arial";
914 placeholderPixelSizeMapSet["pixelSize"] = 15.0f;
915 placeholderPixelSizeMapSet["ellipsis"] = true;
917 placeholderFontstyleMap.Insert( "weight", "bold" );
918 placeholderPixelSizeMapSet["placeholderFontStyle"] = placeholderFontstyleMap;
919 field.SetProperty( TextField::Property::PLACEHOLDER, placeholderPixelSizeMapSet );
921 placeholderPixelSizeMapGet = field.GetProperty<Property::Map>( TextField::Property::PLACEHOLDER );
922 DALI_TEST_EQUALS( placeholderPixelSizeMapGet.Count(), placeholderPixelSizeMapSet.Count(), TEST_LOCATION );
924 tet_infoline("Test Placeholder settings set as strings is converted correctly to Property Index key and holds set value");
925 Property::Map placeholderConversionMap;
926 placeholderConversionMap[ Text::PlaceHolder::Property::TEXT ] = placeholderPixelSizeMapSet["text"];
927 placeholderConversionMap[ Text::PlaceHolder::Property::TEXT_FOCUSED ] = placeholderPixelSizeMapSet["textFocused"] ;
928 placeholderConversionMap[ Text::PlaceHolder::Property::COLOR ] = placeholderPixelSizeMapSet["color"];
929 placeholderConversionMap[ Text::PlaceHolder::Property::FONT_STYLE ] = placeholderPixelSizeMapSet["fontStyle"];
930 placeholderConversionMap[ Text::PlaceHolder::Property::FONT_FAMILY ] = placeholderPixelSizeMapSet["fontFamily"];
931 placeholderConversionMap[ Text::PlaceHolder::Property::PIXEL_SIZE ] = placeholderPixelSizeMapSet["pixelSize"];
933 DALI_TEST_EQUALS( DaliTestCheckMaps( placeholderPixelSizeMapGet, placeholderConversionMap ), true, TEST_LOCATION );
935 // Check the placeholder property with point size
936 Property::Map placeholderMapSet;
937 Property::Map placeholderMapGet;
938 placeholderMapSet["text"] = "Setting Placeholder Text";
939 placeholderMapSet["textFocused"] = "Setting Placeholder Text Focused";
940 placeholderMapSet["color"] = Color::RED;
941 placeholderMapSet["fontFamily"] = "Arial";
942 placeholderMapSet["pointSize"] = 12.0f;
943 placeholderMapSet["ellipsis"] = false;
945 // Check the placeholder font style property
946 placeholderFontstyleMap.Clear();
948 placeholderFontstyleMap.Insert( "weight", "bold" );
949 placeholderFontstyleMap.Insert( "width", "condensed" );
950 placeholderFontstyleMap.Insert( "slant", "italic" );
951 placeholderMapSet["fontStyle"] = placeholderFontstyleMap;
952 field.SetProperty( TextField::Property::PLACEHOLDER, placeholderMapSet );
954 placeholderMapGet = field.GetProperty<Property::Map>( TextField::Property::PLACEHOLDER );
955 DALI_TEST_EQUALS( placeholderMapGet.Count(), placeholderMapSet.Count(), TEST_LOCATION );
957 placeholderConversionMap.Clear();
958 placeholderConversionMap[ Text::PlaceHolder::Property::TEXT ] = placeholderPixelSizeMapSet["text"];
959 placeholderConversionMap[ Text::PlaceHolder::Property::TEXT_FOCUSED ] = placeholderPixelSizeMapSet["textFocused"] ;
960 placeholderConversionMap[ Text::PlaceHolder::Property::COLOR ] = placeholderPixelSizeMapSet["color"];
961 placeholderConversionMap[ Text::PlaceHolder::Property::FONT_STYLE ] = placeholderPixelSizeMapSet["fontStyle"];
962 placeholderConversionMap[ Text::PlaceHolder::Property::FONT_FAMILY ] = placeholderPixelSizeMapSet["fontFamily"];
963 placeholderConversionMap[ Text::PlaceHolder::Property::POINT_SIZE ] = placeholderPixelSizeMapSet["pointSize"];
965 DALI_TEST_EQUALS( DaliTestCheckMaps( placeholderMapGet, placeholderConversionMap ), true, TEST_LOCATION );
968 placeholderFontstyleMap.Clear();
969 placeholderFontstyleMap.Insert( "weight", "normal" );
970 placeholderFontstyleMap.Insert( "slant", "oblique" );
971 placeholderMapSet["fontStyle"] = placeholderFontstyleMap;
972 field.SetProperty( TextField::Property::PLACEHOLDER, placeholderMapSet );
974 placeholderMapGet = field.GetProperty<Property::Map>( TextField::Property::PLACEHOLDER );
975 DALI_TEST_EQUALS( placeholderMapGet.Count(), placeholderMapSet.Count(), TEST_LOCATION );
977 placeholderConversionMap[ Text::PlaceHolder::Property::FONT_STYLE ] = placeholderPixelSizeMapSet["fontStyle"];
978 DALI_TEST_EQUALS( DaliTestCheckMaps( placeholderMapGet, placeholderConversionMap ), true, TEST_LOCATION );
980 placeholderFontstyleMap.Clear();
981 placeholderFontstyleMap.Insert( "slant", "roman" );
982 placeholderMapSet["fontStyle"] = placeholderFontstyleMap;
983 placeholderConversionMap[ Text::PlaceHolder::Property::FONT_STYLE ] = placeholderPixelSizeMapSet["fontStyle"];
985 field.SetProperty( TextField::Property::PLACEHOLDER, placeholderMapSet );
987 placeholderMapGet = field.GetProperty<Property::Map>( TextField::Property::PLACEHOLDER );
989 placeholderFontstyleMap.Clear();
990 placeholderMapSet["fontStyle"] = placeholderFontstyleMap;
991 placeholderConversionMap[ Text::PlaceHolder::Property::FONT_STYLE ] = placeholderPixelSizeMapSet["fontStyle"];
993 field.SetProperty( TextField::Property::PLACEHOLDER, placeholderMapSet );
994 placeholderMapGet = field.GetProperty<Property::Map>( TextField::Property::PLACEHOLDER );
995 DALI_TEST_EQUALS( placeholderMapGet.Count(), placeholderMapSet.Count(), TEST_LOCATION );
997 DALI_TEST_EQUALS( DaliTestCheckMaps( placeholderMapGet, placeholderConversionMap ), true, TEST_LOCATION );
999 // Check the ellipsis property
1000 DALI_TEST_CHECK( !field.GetProperty<bool>( TextField::Property::ELLIPSIS ) );
1001 field.SetProperty( TextField::Property::ELLIPSIS, true );
1002 DALI_TEST_CHECK( field.GetProperty<bool>( TextField::Property::ELLIPSIS ) );
1004 field.SetProperty( Actor::Property::LAYOUT_DIRECTION, LayoutDirection::RIGHT_TO_LEFT );
1005 DALI_TEST_EQUALS( field.GetProperty<int>( Actor::Property::LAYOUT_DIRECTION ), static_cast<int>( LayoutDirection::RIGHT_TO_LEFT ), TEST_LOCATION );
1007 application.SendNotification();
1008 application.Render();
1013 // Positive Atlas Text Renderer test
1014 int utcDaliTextFieldAtlasRenderP(void)
1016 ToolkitTestApplication application;
1017 tet_infoline(" UtcDaliToolkitTextFieldAtlasRenderP");
1018 StyleManager styleManager = StyleManager::Get();
1019 styleManager.ApplyDefaultTheme();
1020 TextField field = TextField::New();
1021 DALI_TEST_CHECK( field );
1023 field.SetProperty( TextField::Property::HORIZONTAL_ALIGNMENT, "CENTER" );
1025 application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
1027 Stage::GetCurrent().Add( field );
1031 // Render some text with the shared atlas backend
1032 field.SetProperty( TextField::Property::RENDERING_BACKEND, Text::RENDERING_SHARED_ATLAS );
1033 application.SendNotification();
1034 application.Render();
1038 tet_result(TET_FAIL);
1043 // Positive test for the textChanged signal.
1044 int utcDaliTextFieldTextChangedP(void)
1046 ToolkitTestApplication application;
1047 tet_infoline(" utcDaliTextFieldTextChangedP");
1048 TextField field = TextField::New();
1049 DALI_TEST_CHECK( field );
1051 Stage::GetCurrent().Add( field );
1053 // connect to the text changed signal.
1054 ConnectionTracker* testTracker = new ConnectionTracker();
1055 field.TextChangedSignal().Connect(&TestTextChangedCallback);
1056 bool textChangedSignal = false;
1057 field.ConnectSignal( testTracker, "textChanged", CallbackFunctor(&textChangedSignal) );
1059 gTextChangedCallBackCalled = false;
1060 field.SetProperty( TextField::Property::TEXT, "ABC" );
1061 DALI_TEST_CHECK( gTextChangedCallBackCalled );
1062 DALI_TEST_CHECK( textChangedSignal );
1064 application.SendNotification();
1066 field.SetKeyInputFocus();
1068 gTextChangedCallBackCalled = false;
1069 application.ProcessEvent( GenerateKey( "D", "D", KEY_D_CODE, 0, 0, Integration::KeyEvent::Down, DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
1070 DALI_TEST_CHECK( gTextChangedCallBackCalled );
1075 // Negative test for the textChanged signal.
1076 int utcDaliTextFieldTextChangedN(void)
1078 ToolkitTestApplication application;
1079 tet_infoline(" utcDaliTextFieldTextChangedN");
1080 TextField field = TextField::New();
1081 DALI_TEST_CHECK( field );
1083 Stage::GetCurrent().Add( field );
1085 // connect to the text changed signal.
1086 ConnectionTracker* testTracker = new ConnectionTracker();
1087 field.TextChangedSignal().Connect(&TestTextChangedCallback);
1088 bool textChangedSignal = false;
1089 field.ConnectSignal( testTracker, "textChanged", CallbackFunctor(&textChangedSignal) );
1091 gTextChangedCallBackCalled = false;
1092 field.SetProperty( TextField::Property::PLACEHOLDER_TEXT, "ABC" ); // Setting placeholder, not TEXT
1093 DALI_TEST_CHECK( !gTextChangedCallBackCalled );
1094 DALI_TEST_CHECK( !textChangedSignal );
1099 // Positive test for Max Characters reached signal.
1100 int utcDaliTextFieldMaxCharactersReachedP(void)
1102 ToolkitTestApplication application;
1103 tet_infoline(" utcDaliTextFieldMaxCharactersReachedP");
1104 TextField field = TextField::New();
1105 DALI_TEST_CHECK( field );
1107 Stage::GetCurrent().Add( field );
1109 const int maxNumberOfCharacters = 1;
1110 field.SetProperty( TextField::Property::MAX_LENGTH, maxNumberOfCharacters );
1112 field.SetKeyInputFocus();
1114 // connect to the text changed signal.
1115 ConnectionTracker* testTracker = new ConnectionTracker();
1116 field.MaxLengthReachedSignal().Connect(&TestMaxLengthReachedCallback);
1117 bool maxLengthReachedSignal = false;
1118 field.ConnectSignal( testTracker, "maxLengthReached", CallbackFunctor(&maxLengthReachedSignal) );
1120 gMaxCharactersCallBackCalled = false;
1122 application.ProcessEvent( GenerateKey( "a", "a", KEY_A_CODE, 0, 0, Integration::KeyEvent::Down, DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
1123 application.ProcessEvent( GenerateKey( "a", "a", KEY_A_CODE, 0, 0, Integration::KeyEvent::Down, DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
1125 DALI_TEST_CHECK( gMaxCharactersCallBackCalled );
1126 DALI_TEST_CHECK( maxLengthReachedSignal );
1131 // Negative test for Max Characters reached signal.
1132 int utcDaliTextFieldMaxCharactersReachedN(void)
1134 ToolkitTestApplication application;
1135 tet_infoline(" utcDaliTextFieldMaxCharactersReachedN");
1136 TextField field = TextField::New();
1137 DALI_TEST_CHECK( field );
1139 Stage::GetCurrent().Add( field );
1141 const int maxNumberOfCharacters = 3;
1142 field.SetProperty( TextField::Property::MAX_LENGTH, maxNumberOfCharacters );
1144 field.SetKeyInputFocus();
1146 // connect to the text changed signal.
1147 ConnectionTracker* testTracker = new ConnectionTracker();
1148 field.MaxLengthReachedSignal().Connect(&TestMaxLengthReachedCallback);
1149 bool maxLengthReachedSignal = false;
1150 field.ConnectSignal( testTracker, "maxLengthReached", CallbackFunctor(&maxLengthReachedSignal) );
1152 gMaxCharactersCallBackCalled = false;
1154 application.ProcessEvent( GenerateKey( "a", "a", KEY_A_CODE, 0, 0, Integration::KeyEvent::Down, DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
1155 application.ProcessEvent( GenerateKey( "a", "a", KEY_A_CODE, 0, 0, Integration::KeyEvent::Down, DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
1157 DALI_TEST_CHECK( !gMaxCharactersCallBackCalled );
1158 DALI_TEST_CHECK( !maxLengthReachedSignal );
1160 application.ProcessEvent( GenerateKey( "Return", "\r", KEY_RETURN_CODE, 0, 0, Integration::KeyEvent::Down, DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
1162 DALI_TEST_CHECK( !gMaxCharactersCallBackCalled );
1163 DALI_TEST_CHECK( !maxLengthReachedSignal );
1168 int utcDaliTextFieldInputStyleChanged01(void)
1170 ToolkitTestApplication application;
1171 tet_infoline(" utcDaliTextFieldInputStyleChanged01");
1173 // The text-field emits signals when the input style changes. These changes of style are
1174 // detected during the relayout process (size negotiation), i.e after the cursor has been moved. Signals
1175 // can't be emitted during the size negotiation as the callbacks may update the UI.
1176 // The text-field adds an idle callback to the adaptor to emit the signals after the size negotiation.
1177 // This creates an implementation of the adaptor stub and a queue of idle callbacks.
1178 application.CreateAdaptor();
1182 char* pathNamePtr = get_current_dir_name();
1183 const std::string pathName( pathNamePtr );
1184 free( pathNamePtr );
1186 TextAbstraction::FontClient fontClient = TextAbstraction::FontClient::Get();
1187 fontClient.SetDpi( 93u, 93u );
1189 fontClient.GetFontId( pathName + DEFAULT_FONT_DIR + "/dejavu/DejaVuSerif.ttf", DEFAULT_FONT_SIZE );
1190 fontClient.GetFontId( pathName + DEFAULT_FONT_DIR + "/dejavu/DejaVuSerif-Bold.ttf", DEFAULT_FONT_SIZE );
1192 TextField field = TextField::New();
1193 DALI_TEST_CHECK( field );
1196 field.SetSize( 300.f, 50.f );
1197 field.SetParentOrigin( ParentOrigin::TOP_LEFT );
1198 field.SetAnchorPoint( AnchorPoint::TOP_LEFT );
1200 field.SetProperty( TextField::Property::ENABLE_MARKUP, true );
1201 field.SetProperty( TextField::Property::TEXT, "<font family='DejaVuSerif' size='18'>He<color value='green'>llo</color> <font weight='bold'>world</font> demo</font>" );
1203 // connect to the text changed signal.
1204 ConnectionTracker* testTracker = new ConnectionTracker();
1205 field.InputStyleChangedSignal().Connect( &TestInputStyleChangedCallback );
1206 bool inputStyleChangedSignal = false;
1207 field.ConnectSignal( testTracker, "inputStyleChanged", CallbackFunctor(&inputStyleChangedSignal) );
1209 Stage::GetCurrent().Add( field );
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 gInputStyleChangedCallbackCalled = false;
1219 gInputStyleMask = TextField::InputStyle::NONE;
1220 inputStyleChangedSignal = false;
1222 // Create a tap event to touch the text field.
1223 application.ProcessEvent( GenerateTap( Gesture::Possible, 1u, 1u, Vector2( 18.f, 25.f ) ) );
1224 application.ProcessEvent( GenerateTap( Gesture::Started, 1u, 1u, Vector2( 18.f, 25.f ) ) );
1226 // Render and notify
1227 application.SendNotification();
1228 application.Render();
1230 // Executes the idle callbacks added by the text control on the change of input style.
1231 application.RunIdles();
1233 DALI_TEST_CHECK( gInputStyleChangedCallbackCalled );
1234 if( gInputStyleChangedCallbackCalled )
1236 DALI_TEST_EQUALS( static_cast<unsigned int>( gInputStyleMask ), static_cast<unsigned int>( TextField::InputStyle::FONT_FAMILY | TextField::InputStyle::POINT_SIZE ), TEST_LOCATION );
1238 const std::string fontFamily = field.GetProperty( TextField::Property::INPUT_FONT_FAMILY ).Get<std::string>();
1239 DALI_TEST_EQUALS( fontFamily, "DejaVuSerif", TEST_LOCATION );
1241 const float pointSize = field.GetProperty( TextField::Property::INPUT_POINT_SIZE ).Get<float>();
1242 DALI_TEST_EQUALS( pointSize, 18.f, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
1244 DALI_TEST_CHECK( inputStyleChangedSignal );
1246 gInputStyleChangedCallbackCalled = false;
1247 gInputStyleMask = TextField::InputStyle::NONE;
1248 inputStyleChangedSignal = false;
1250 // Create a tap event to touch the text field.
1251 application.ProcessEvent( GenerateTap( Gesture::Possible, 1u, 1u, Vector2( 30.f, 25.f ) ) );
1252 application.ProcessEvent( GenerateTap( Gesture::Started, 1u, 1u, Vector2( 30.f, 25.f ) ) );
1254 // Render and notify
1255 application.SendNotification();
1256 application.Render();
1258 // Executes the idle callbacks added by the text control on the change of input style.
1259 application.RunIdles();
1261 DALI_TEST_CHECK( !gInputStyleChangedCallbackCalled );
1262 DALI_TEST_CHECK( !inputStyleChangedSignal );
1264 gInputStyleChangedCallbackCalled = false;
1265 gInputStyleMask = TextField::InputStyle::NONE;
1266 inputStyleChangedSignal = false;
1268 // Create a tap event to touch the text field.
1269 application.ProcessEvent( GenerateTap( Gesture::Possible, 1u, 1u, Vector2( 43.f, 25.f ) ) );
1270 application.ProcessEvent( GenerateTap( Gesture::Started, 1u, 1u, Vector2( 43.f, 25.f ) ) );
1272 // Render and notify
1273 application.SendNotification();
1274 application.Render();
1276 // Executes the idle callbacks added by the text control on the change of input style.
1277 application.RunIdles();
1279 DALI_TEST_CHECK( gInputStyleChangedCallbackCalled );
1280 if( gInputStyleChangedCallbackCalled )
1282 DALI_TEST_EQUALS( static_cast<unsigned int>( gInputStyleMask ), static_cast<unsigned int>( TextField::InputStyle::COLOR ), TEST_LOCATION );
1284 const Vector4 color = field.GetProperty( TextField::Property::INPUT_COLOR ).Get<Vector4>();
1285 DALI_TEST_EQUALS( color, Color::GREEN, TEST_LOCATION );
1287 DALI_TEST_CHECK( inputStyleChangedSignal );
1289 gInputStyleChangedCallbackCalled = false;
1290 gInputStyleMask = TextField::InputStyle::NONE;
1291 inputStyleChangedSignal = false;
1293 // Create a tap event to touch the text field.
1294 application.ProcessEvent( GenerateTap( Gesture::Possible, 1u, 1u, Vector2( 88.f, 25.f ) ) );
1295 application.ProcessEvent( GenerateTap( Gesture::Started, 1u, 1u, Vector2( 88.f, 25.f ) ) );
1297 // Render and notify
1298 application.SendNotification();
1299 application.Render();
1301 // Executes the idle callbacks added by the text control on the change of input style.
1302 application.RunIdles();
1304 DALI_TEST_CHECK( gInputStyleChangedCallbackCalled );
1305 if( gInputStyleChangedCallbackCalled )
1307 DALI_TEST_EQUALS( static_cast<unsigned int>( gInputStyleMask ), static_cast<unsigned int>( TextField::InputStyle::COLOR | TextField::InputStyle::FONT_STYLE ), TEST_LOCATION );
1309 const Vector4 color = field.GetProperty( TextField::Property::INPUT_COLOR ).Get<Vector4>();
1310 DALI_TEST_EQUALS( color, Color::BLACK, TEST_LOCATION );
1312 const Property::Map fontStyleMapGet = field.GetProperty( TextField::Property::INPUT_FONT_STYLE ).Get<Property::Map>();
1314 Property::Map fontStyleMapSet;
1315 fontStyleMapSet.Insert( "weight", "bold" );
1317 DALI_TEST_EQUALS( fontStyleMapGet.Count(), fontStyleMapSet.Count(), TEST_LOCATION );
1318 DALI_TEST_EQUALS( DaliTestCheckMaps( fontStyleMapGet, fontStyleMapSet ), true, TEST_LOCATION );
1320 DALI_TEST_CHECK( inputStyleChangedSignal );
1322 gInputStyleChangedCallbackCalled = false;
1323 gInputStyleMask = TextField::InputStyle::NONE;
1324 inputStyleChangedSignal = false;
1326 // Create a tap event to touch the text field.
1327 application.ProcessEvent( GenerateTap( Gesture::Possible, 1u, 1u, Vector2( 115.f, 25.f ) ) );
1328 application.ProcessEvent( GenerateTap( Gesture::Started, 1u, 1u, Vector2( 115.f, 25.f ) ) );
1330 // Render and notify
1331 application.SendNotification();
1332 application.Render();
1334 // Executes the idle callbacks added by the text control on the change of input style.
1335 application.RunIdles();
1337 DALI_TEST_CHECK( !gInputStyleChangedCallbackCalled );
1338 DALI_TEST_CHECK( !inputStyleChangedSignal );
1340 gInputStyleChangedCallbackCalled = false;
1341 gInputStyleMask = TextField::InputStyle::NONE;
1342 inputStyleChangedSignal = false;
1344 // Create a tap event to touch the text field.
1345 application.ProcessEvent( GenerateTap( Gesture::Possible, 1u, 1u, Vector2( 164.f, 25.f ) ) );
1346 application.ProcessEvent( GenerateTap( Gesture::Started, 1u, 1u, Vector2( 164.f, 25.f ) ) );
1348 // Render and notify
1349 application.SendNotification();
1350 application.Render();
1352 // Executes the idle callbacks added by the text control on the change of input style.
1353 application.RunIdles();
1355 DALI_TEST_CHECK( gInputStyleChangedCallbackCalled );
1356 if( gInputStyleChangedCallbackCalled )
1358 DALI_TEST_EQUALS( static_cast<unsigned int>( gInputStyleMask ), static_cast<unsigned int>( TextField::InputStyle::FONT_STYLE ), TEST_LOCATION );
1360 const std::string style = field.GetProperty( TextField::Property::INPUT_FONT_STYLE ).Get<std::string>();
1361 DALI_TEST_CHECK( style.empty() );
1363 DALI_TEST_CHECK( inputStyleChangedSignal );
1365 gInputStyleChangedCallbackCalled = false;
1366 gInputStyleMask = TextField::InputStyle::NONE;
1367 inputStyleChangedSignal = false;
1369 // Create a tap event to touch the text field.
1370 application.ProcessEvent( GenerateTap( Gesture::Possible, 1u, 1u, Vector2( 191.f, 25.f ) ) );
1371 application.ProcessEvent( GenerateTap( Gesture::Started, 1u, 1u, Vector2( 191.f, 25.f ) ) );
1373 // Render and notify
1374 application.SendNotification();
1375 application.Render();
1377 // Executes the idle callbacks added by the text control on the change of input style.
1378 application.RunIdles();
1380 DALI_TEST_CHECK( !gInputStyleChangedCallbackCalled );
1381 DALI_TEST_CHECK( !inputStyleChangedSignal );
1386 int utcDaliTextFieldInputStyleChanged02(void)
1388 ToolkitTestApplication application;
1389 tet_infoline(" utcDaliTextFieldInputStyleChanged02");
1391 // The text-field emits signals when the input style changes. These changes of style are
1392 // detected during the relayout process (size negotiation), i.e after the cursor has been moved. Signals
1393 // can't be emitted during the size negotiation as the callbacks may update the UI.
1394 // The text-field adds an idle callback to the adaptor to emit the signals after the size negotiation.
1395 // This creates an implementation of the adaptor stub and a queue of idle callbacks.
1396 application.CreateAdaptor();
1400 char* pathNamePtr = get_current_dir_name();
1401 const std::string pathName( pathNamePtr );
1402 free( pathNamePtr );
1404 TextAbstraction::FontClient fontClient = TextAbstraction::FontClient::Get();
1405 fontClient.SetDpi( 93u, 93u );
1407 fontClient.GetFontId( pathName + DEFAULT_FONT_DIR + "/dejavu/DejaVuSerif.ttf", DEFAULT_FONT_SIZE );
1408 fontClient.GetFontId( pathName + DEFAULT_FONT_DIR + "/dejavu/DejaVuSerif-Bold.ttf", DEFAULT_FONT_SIZE );
1410 TextField field = TextField::New();
1411 DALI_TEST_CHECK( field );
1414 field.SetSize( 300.f, 50.f );
1415 field.SetParentOrigin( ParentOrigin::TOP_LEFT );
1416 field.SetAnchorPoint( AnchorPoint::TOP_LEFT );
1418 field.SetProperty( TextField::Property::ENABLE_MARKUP, true );
1419 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>" );
1421 // connect to the text changed signal.
1422 ConnectionTracker* testTracker = new ConnectionTracker();
1423 field.InputStyleChangedSignal().Connect( &TestInputStyleChangedCallback );
1424 bool inputStyleChangedSignal = false;
1425 field.ConnectSignal( testTracker, "inputStyleChanged", CallbackFunctor(&inputStyleChangedSignal) );
1427 Stage::GetCurrent().Add( field );
1429 // Render and notify
1430 application.SendNotification();
1431 application.Render();
1433 // Executes the idle callbacks added by the text control on the change of input style.
1434 application.RunIdles();
1436 gInputStyleChangedCallbackCalled = false;
1437 gInputStyleMask = TextField::InputStyle::NONE;
1438 inputStyleChangedSignal = false;
1440 // Create a tap event to touch the text field.
1441 application.ProcessEvent( GenerateTap( Gesture::Possible, 1u, 1u, Vector2( 53.f, 25.f ) ) );
1442 application.ProcessEvent( GenerateTap( Gesture::Started, 1u, 1u, Vector2( 53.f, 25.f ) ) );
1443 application.ProcessEvent( GenerateTap( Gesture::Possible, 2u, 1u, Vector2( 53.f, 25.f ) ) );
1444 application.ProcessEvent( GenerateTap( Gesture::Started, 2u, 1u, Vector2( 53.f, 25.f ) ) );
1446 // Render and notify
1447 application.SendNotification();
1448 application.Render();
1450 // Executes the idle callbacks added by the text control on the change of input style.
1451 application.RunIdles();
1453 DALI_TEST_CHECK( gInputStyleChangedCallbackCalled );
1454 if( gInputStyleChangedCallbackCalled )
1456 DALI_TEST_EQUALS( static_cast<unsigned int>( gInputStyleMask ),
1457 static_cast<unsigned int>( TextField::InputStyle::FONT_FAMILY |
1458 TextField::InputStyle::POINT_SIZE |
1459 TextField::InputStyle::COLOR ),
1462 const Vector4 color = field.GetProperty( TextField::Property::INPUT_COLOR ).Get<Vector4>();
1463 DALI_TEST_EQUALS( color, Color::GREEN, TEST_LOCATION );
1465 const std::string fontFamily = field.GetProperty( TextField::Property::INPUT_FONT_FAMILY ).Get<std::string>();
1466 DALI_TEST_EQUALS( fontFamily, "DejaVuSerif", TEST_LOCATION );
1468 const float pointSize = field.GetProperty( TextField::Property::INPUT_POINT_SIZE ).Get<float>();
1469 DALI_TEST_EQUALS( pointSize, 18.f, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
1471 DALI_TEST_CHECK( inputStyleChangedSignal );
1473 gInputStyleChangedCallbackCalled = false;
1474 gInputStyleMask = TextField::InputStyle::NONE;
1475 inputStyleChangedSignal = false;
1477 application.ProcessEvent( GenerateKey( "", "", DALI_KEY_BACKSPACE, 0, 0, Integration::KeyEvent::Down, DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
1479 // Render and notify
1480 application.SendNotification();
1481 application.Render();
1483 // Executes the idle callbacks added by the text control on the change of input style.
1484 application.RunIdles();
1486 DALI_TEST_CHECK( gInputStyleChangedCallbackCalled );
1487 if( gInputStyleChangedCallbackCalled )
1489 DALI_TEST_EQUALS( static_cast<unsigned int>( gInputStyleMask ),
1490 static_cast<unsigned int>( TextField::InputStyle::COLOR ),
1493 const Vector4 color = field.GetProperty( TextField::Property::INPUT_COLOR ).Get<Vector4>();
1494 DALI_TEST_EQUALS( color, Color::BLUE, TEST_LOCATION );
1496 DALI_TEST_CHECK( inputStyleChangedSignal );
1498 gInputStyleChangedCallbackCalled = false;
1499 gInputStyleMask = TextField::InputStyle::NONE;
1500 inputStyleChangedSignal = false;
1502 application.ProcessEvent( GenerateKey( "", "", DALI_KEY_BACKSPACE, 0, 0, Integration::KeyEvent::Down, DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
1504 // Render and notify
1505 application.SendNotification();
1506 application.Render();
1508 // Executes the idle callbacks added by the text control on the change of input style.
1509 application.RunIdles();
1511 DALI_TEST_CHECK( !gInputStyleChangedCallbackCalled );
1512 DALI_TEST_CHECK( !inputStyleChangedSignal );
1514 gInputStyleChangedCallbackCalled = false;
1515 gInputStyleMask = TextField::InputStyle::NONE;
1516 inputStyleChangedSignal = false;
1518 application.ProcessEvent( GenerateKey( "", "", DALI_KEY_BACKSPACE, 0, 0, Integration::KeyEvent::Down, DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
1520 // Render and notify
1521 application.SendNotification();
1522 application.Render();
1524 // Executes the idle callbacks added by the text control on the change of input style.
1525 application.RunIdles();
1527 DALI_TEST_CHECK( gInputStyleChangedCallbackCalled );
1528 if( gInputStyleChangedCallbackCalled )
1530 DALI_TEST_EQUALS( static_cast<unsigned int>( gInputStyleMask ),
1531 static_cast<unsigned int>( TextField::InputStyle::COLOR ),
1534 const Vector4 color = field.GetProperty( TextField::Property::INPUT_COLOR ).Get<Vector4>();
1535 DALI_TEST_EQUALS( color, Color::BLACK, TEST_LOCATION );
1537 DALI_TEST_CHECK( inputStyleChangedSignal );
1539 gInputStyleChangedCallbackCalled = false;
1540 gInputStyleMask = TextField::InputStyle::NONE;
1541 inputStyleChangedSignal = false;
1543 field.SetProperty( TextField::Property::INPUT_COLOR, Color::YELLOW );
1545 Property::Map fontStyleMapSet;
1546 fontStyleMapSet.Insert( "weight", "thin" );
1547 fontStyleMapSet.Insert( "width", "condensed" );
1548 fontStyleMapSet.Insert( "slant", "italic" );
1550 field.SetProperty( TextField::Property::INPUT_FONT_STYLE, fontStyleMapSet );
1551 field.SetProperty( TextField::Property::INPUT_POINT_SIZE, 20.f );
1553 field.SetProperty( TextField::Property::INPUT_UNDERLINE, "underline" );
1554 field.SetProperty( TextField::Property::INPUT_SHADOW, "shadow" );
1555 field.SetProperty( TextField::Property::INPUT_EMBOSS, "emboss" );
1556 field.SetProperty( TextField::Property::INPUT_OUTLINE, "outline" );
1558 // Render and notify
1559 application.SendNotification();
1560 application.Render();
1562 // Executes the idle callbacks added by the text control on the change of input style.
1563 application.RunIdles();
1565 DALI_TEST_CHECK( !gInputStyleChangedCallbackCalled );
1566 DALI_TEST_CHECK( !inputStyleChangedSignal );
1568 // Create a tap event to touch the text field.
1569 application.ProcessEvent( GenerateTap( Gesture::Possible, 1u, 1u, Vector2( 63.f, 25.f ) ) );
1570 application.ProcessEvent( GenerateTap( Gesture::Started, 1u, 1u, Vector2( 63.f, 25.f ) ) );
1572 // Render and notify
1573 application.SendNotification();
1574 application.Render();
1576 // Executes the idle callbacks added by the text control on the change of input style.
1577 application.RunIdles();
1579 DALI_TEST_CHECK( gInputStyleChangedCallbackCalled );
1580 if( gInputStyleChangedCallbackCalled )
1582 DALI_TEST_EQUALS( static_cast<unsigned int>( gInputStyleMask ),
1583 static_cast<unsigned int>( TextField::InputStyle::COLOR |
1584 TextField::InputStyle::POINT_SIZE |
1585 TextField::InputStyle::FONT_STYLE |
1586 TextField::InputStyle::UNDERLINE |
1587 TextField::InputStyle::SHADOW |
1588 TextField::InputStyle::EMBOSS |
1589 TextField::InputStyle::OUTLINE ),
1592 const Vector4 color = field.GetProperty( TextField::Property::INPUT_COLOR ).Get<Vector4>();
1593 DALI_TEST_EQUALS( color, Color::BLACK, TEST_LOCATION );
1595 DALI_TEST_CHECK( inputStyleChangedSignal );
1600 int utcDaliTextFieldEvent01(void)
1602 ToolkitTestApplication application;
1603 tet_infoline(" utcDaliTextFieldEvent01");
1605 // Creates a tap event. After creating a tap event the text field should
1606 // have the focus and add text with key events should be possible.
1608 TextField field = TextField::New();
1609 DALI_TEST_CHECK( field );
1611 Stage::GetCurrent().Add( field );
1613 field.SetSize( 300.f, 50.f );
1614 field.SetParentOrigin( ParentOrigin::TOP_LEFT );
1615 field.SetAnchorPoint( AnchorPoint::TOP_LEFT );
1617 // Avoid a crash when core load gl resources.
1618 application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
1620 // Render and notify
1621 application.SendNotification();
1622 application.Render();
1624 // Add a key event but as the text field has not the focus it should do nothing.
1625 application.ProcessEvent( GenerateKey( "a", "a", KEY_A_CODE, 0, 0, Integration::KeyEvent::Down, DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
1627 // Render and notify
1628 application.SendNotification();
1629 application.Render();
1631 DALI_TEST_EQUALS( field.GetProperty<std::string>( TextField::Property::TEXT ), std::string(""), TEST_LOCATION );
1633 // Create a tap event to touch the text field.
1634 application.ProcessEvent( GenerateTap( Gesture::Possible, 1u, 1u, Vector2( 150.0f, 25.0f ) ) );
1635 application.ProcessEvent( GenerateTap( Gesture::Started, 1u, 1u, Vector2( 150.0f, 25.0f ) ) );
1637 // Render and notify
1638 application.SendNotification();
1639 application.Render();
1641 // Pressing delete key should be fine even if there is no text in TextField.
1642 application.ProcessEvent( GenerateKey( "Delete", "Delete", Dali::DevelKey::DALI_KEY_DELETE, 0, 0, Integration::KeyEvent::Down, DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
1643 // Render and notify
1644 application.SendNotification();
1645 application.Render();
1647 // Now the text field has the focus, so it can handle the key events.
1648 application.ProcessEvent( GenerateKey( "a", "a", KEY_A_CODE, 0, 0, Integration::KeyEvent::Down, DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
1649 application.ProcessEvent( GenerateKey( "a", "a", KEY_A_CODE, 0, 0, Integration::KeyEvent::Down, DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
1651 // Render and notify
1652 application.SendNotification();
1653 application.Render();
1655 DALI_TEST_EQUALS( field.GetProperty<std::string>( TextField::Property::TEXT ), std::string("aa"), TEST_LOCATION );
1657 // Create a second text field and send key events to it.
1658 TextField field2 = TextField::New();
1660 field2.SetParentOrigin( ParentOrigin::TOP_LEFT );
1661 field2.SetAnchorPoint( AnchorPoint::TOP_LEFT );
1662 field2.SetSize( 100.f, 100.f );
1663 field2.SetPosition( 100.f, 100.f );
1665 Stage::GetCurrent().Add( field2 );
1667 // Render and notify
1668 application.SendNotification();
1669 application.Render();
1671 // Create a tap event on the second text field.
1672 application.ProcessEvent( GenerateTap( Gesture::Possible, 1u, 1u, Vector2( 150.0f, 125.0f ) ) );
1673 application.ProcessEvent( GenerateTap( Gesture::Started, 1u, 1u, Vector2( 150.0f, 125.0f ) ) );
1675 // Render and notify
1676 application.SendNotification();
1677 application.Render();
1679 // The second text field has the focus. It should handle the key events.
1680 application.ProcessEvent( GenerateKey( "a", "a", KEY_A_CODE, 0, 0, Integration::KeyEvent::Down, DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
1681 application.ProcessEvent( GenerateKey( "a", "a", KEY_A_CODE, 0, 0, Integration::KeyEvent::Down, DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
1683 // Render and notify
1684 application.SendNotification();
1685 application.Render();
1687 // Check the text has been added to the second text field.
1688 DALI_TEST_EQUALS( field2.GetProperty<std::string>( TextField::Property::TEXT ), std::string("aa"), TEST_LOCATION );
1693 int utcDaliTextFieldEvent02(void)
1695 ToolkitTestApplication application;
1696 tet_infoline(" utcDaliTextFieldEvent02");
1698 // Checks if the right number of actors are created.
1700 TextField field = TextField::New();
1701 field.SetProperty( TextField::Property::POINT_SIZE, 10.f );
1702 DALI_TEST_CHECK( field );
1703 LoadMarkerImages(application, field);
1705 Stage::GetCurrent().Add( field );
1707 field.SetSize( 300.f, 50.f );
1708 field.SetParentOrigin( ParentOrigin::TOP_LEFT );
1709 field.SetAnchorPoint( AnchorPoint::TOP_LEFT );
1711 // Avoid a crash when core load gl resources.
1712 application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
1714 // Render and notify
1715 application.SendNotification();
1716 application.Render();
1718 // Check there are the expected number of children ( stencil ).
1719 DALI_TEST_EQUALS( field.GetChildCount(), 1u, TEST_LOCATION );
1721 Actor stencil = field.GetChildAt( 0u );
1722 DALI_TEST_EQUALS( stencil.GetChildCount(), 0u, TEST_LOCATION );
1724 // Create a tap event to touch the text field.
1725 application.ProcessEvent( GenerateTap( Gesture::Possible, 1u, 1u, Vector2( 150.0f, 25.0f ) ) );
1726 application.ProcessEvent( GenerateTap( Gesture::Started, 1u, 1u, Vector2( 150.0f, 25.0f ) ) );
1728 // Render and notify
1729 application.SendNotification();
1730 application.Render();
1732 Actor layer = field.GetChildAt( 1u );
1733 DALI_TEST_CHECK( layer.IsLayer() );
1735 DALI_TEST_EQUALS( layer.GetChildCount(), 1u, TEST_LOCATION ); // The cursor.
1736 DALI_TEST_EQUALS( stencil.GetChildCount(), 0u, TEST_LOCATION );
1738 // Now the text field has the focus, so it can handle the key events.
1739 application.ProcessEvent( GenerateKey( "a", "a", KEY_A_CODE, 0, 0, Integration::KeyEvent::Down, DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
1740 application.ProcessEvent( GenerateKey( "a", "a", KEY_A_CODE, 0, 0, Integration::KeyEvent::Down, DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
1742 // Render and notify
1743 application.SendNotification();
1744 application.Render();
1746 // Checks the cursor and the renderer have been created.
1747 DALI_TEST_EQUALS( layer.GetChildCount(), 1u, TEST_LOCATION ); // The cursor.
1748 DALI_TEST_EQUALS( stencil.GetChildCount(), 1u, TEST_LOCATION ); // The renderer
1750 Control cursor = Control::DownCast( layer.GetChildAt( 0u ) );
1751 DALI_TEST_CHECK( cursor );
1753 // The offscreen root actor has a container with all the actors which contain the text renderers.
1754 Actor container = stencil.GetChildAt( 0u );
1755 for( unsigned int index = 0; index < container.GetChildCount(); ++index )
1757 Renderer renderer = container.GetChildAt( index ).GetRendererAt( 0u );
1758 DALI_TEST_CHECK( renderer );
1761 // Move the cursor and check the position changes.
1762 Vector3 position1 = cursor.GetCurrentPosition();
1764 application.ProcessEvent( GenerateKey( "", "", DALI_KEY_CURSOR_LEFT, 0, 0, Integration::KeyEvent::Down, DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
1765 application.ProcessEvent( GenerateKey( "", "", DALI_KEY_CURSOR_LEFT, 0, 0, Integration::KeyEvent::Down, DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
1767 // Render and notify
1768 application.SendNotification();
1769 application.Render();
1771 Vector3 position2 = cursor.GetCurrentPosition();
1773 DALI_TEST_CHECK( position2.x < position1.x );
1775 application.ProcessEvent( GenerateKey( "", "", DALI_KEY_CURSOR_RIGHT, 0, 0, Integration::KeyEvent::Down, DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
1776 application.ProcessEvent( GenerateKey( "", "", DALI_KEY_CURSOR_RIGHT, 0, 0, Integration::KeyEvent::Down, DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
1778 // Render and notify
1779 application.SendNotification();
1780 application.Render();
1782 Vector3 position3 = cursor.GetCurrentPosition();
1784 DALI_TEST_EQUALS( position1, position3, TEST_LOCATION ); // Should be in the same position1.
1786 // Send some taps and check the cursor positions.
1788 // Try to tap at the beginning.
1789 application.ProcessEvent( GenerateTap( Gesture::Possible, 1u, 1u, Vector2( 1.f, 25.0f ) ) );
1790 application.ProcessEvent( GenerateTap( Gesture::Started, 1u, 1u, Vector2( 1.f, 25.0f ) ) );
1792 // Render and notify
1793 application.SendNotification();
1794 application.Render();
1796 // Cursor position should be the same than position1.
1797 Vector3 position4 = cursor.GetCurrentPosition();
1799 DALI_TEST_EQUALS( position2, position4, TEST_LOCATION ); // Should be in the same position2.
1801 // Tap away from the start position.
1802 application.ProcessEvent( GenerateTap( Gesture::Possible, 1u, 1u, Vector2( 16.f, 25.0f ) ) );
1803 application.ProcessEvent( GenerateTap( Gesture::Started, 1u, 1u, Vector2( 16.0f, 25.0f ) ) );
1805 // Render and notify
1806 application.SendNotification();
1807 application.Render();
1809 Vector3 position5 = cursor.GetCurrentPosition();
1811 DALI_TEST_CHECK( position5.x > position4.x );
1813 // Remove all the text.
1814 application.ProcessEvent( GenerateKey( "", "", DALI_KEY_BACKSPACE, 0, 0, Integration::KeyEvent::Down, DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
1815 application.ProcessEvent( GenerateKey( "", "", DALI_KEY_BACKSPACE, 0, 0, Integration::KeyEvent::Down, DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
1816 field.SetProperty( TextField::Property::TEXT, "" );
1818 // Render and notify
1819 application.SendNotification();
1820 application.Render();
1822 // Cursor position should be the same than position2.
1823 Vector3 position6 = cursor.GetCurrentPosition();
1825 DALI_TEST_EQUALS( position2, position6, TEST_LOCATION );// Should be in the same position2.
1827 // Should not be a renderer.
1828 DALI_TEST_EQUALS( stencil.GetChildCount(), 0u, TEST_LOCATION );
1830 // Chanege exceed policy (EXCEED_POLICY_ORIGINAL doesn't use stencil )
1831 field.SetProperty( TextField::Property::TEXT, "This is a long text for the size of the text-field." );
1832 field.SetProperty( TextField::Property::EXCEED_POLICY, Dali::Toolkit::TextField::EXCEED_POLICY_ORIGINAL );
1834 application.SendNotification();
1835 application.Render();
1837 // There are renderer and decorator layer
1838 DALI_TEST_EQUALS( field.GetChildCount(), 2u, TEST_LOCATION );
1843 int utcDaliTextFieldEvent03(void)
1845 ToolkitTestApplication application;
1846 tet_infoline(" utcDaliTextFieldEvent03");
1848 // Checks if the highlight actor is created.
1850 TextField field = TextField::New();
1851 DALI_TEST_CHECK( field );
1853 Stage::GetCurrent().Add( field );
1855 field.SetProperty( TextField::Property::TEXT, "This is a long text for the size of the text-field." );
1856 field.SetProperty( TextField::Property::POINT_SIZE, 10.f );
1857 field.SetSize( 30.f, 50.f );
1858 field.SetParentOrigin( ParentOrigin::TOP_LEFT );
1859 field.SetAnchorPoint( AnchorPoint::TOP_LEFT );
1861 // Avoid a crash when core load gl resources.
1862 application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
1863 LoadMarkerImages(application, field);
1865 // Render and notify
1866 application.SendNotification();
1867 application.Render();
1869 // Tap first to get the focus.
1870 application.ProcessEvent( GenerateTap( Gesture::Possible, 1u, 1u, Vector2( 3.f, 25.0f ) ) );
1871 application.ProcessEvent( GenerateTap( Gesture::Started, 1u, 1u, Vector2( 3.f, 25.0f ) ) );
1873 // Render and notify
1874 application.SendNotification();
1875 application.Render();
1877 // Double tap to select a word.
1878 application.ProcessEvent( GenerateTap( Gesture::Possible, 2u, 1u, Vector2( 3.f, 25.0f ) ) );
1879 application.ProcessEvent( GenerateTap( Gesture::Started, 2u, 1u, Vector2( 3.f, 25.0f ) ) );
1881 // Render and notify
1882 application.SendNotification();
1883 application.Render();
1885 // The offscreen root actor should have two actors: the renderer and the highlight actor.
1886 Actor stencil = field.GetChildAt( 0u );
1888 // The highlight actor is drawn first, so is the first actor in the list
1889 Renderer highlight = stencil.GetChildAt( 0u ).GetRendererAt( 0u );
1890 DALI_TEST_CHECK( highlight );
1892 // The offscreen root actor has a container with all the actors which contain the text renderers.
1893 Actor container = stencil.GetChildAt( 1u );
1894 for( unsigned int index = 0; index < container.GetChildCount(); ++index )
1896 Renderer renderer = container.GetChildAt( index ).GetRendererAt( 0u );
1897 DALI_TEST_CHECK( renderer );
1903 int utcDaliTextFieldEvent04(void)
1905 ToolkitTestApplication application;
1906 tet_infoline(" utcDaliTextFieldEvent04");
1908 // Checks if the highlight actor is created.
1910 TextField field = TextField::New();
1911 DALI_TEST_CHECK( field );
1912 Stage::GetCurrent().Add( field );
1913 LoadMarkerImages(application, field);
1914 // Render and notify
1915 application.SendNotification();
1916 application.Render();
1918 field.SetProperty( TextField::Property::TEXT, "This is a long text for the size of the text-field." );
1919 field.SetProperty( TextField::Property::POINT_SIZE, 10.f );
1920 field.SetSize( 300.f, 50.f );
1921 field.SetParentOrigin( ParentOrigin::TOP_LEFT );
1922 field.SetAnchorPoint( AnchorPoint::TOP_LEFT );
1924 // Avoid a crash when core load gl resources.
1925 application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
1926 // Render and notify
1927 application.SendNotification();
1928 application.Render();
1930 // Create a tap event to touch the text field.
1931 application.ProcessEvent( GenerateTap( Gesture::Possible, 1u, 1u, Vector2( 150.0f, 25.0f ) ) );
1932 application.ProcessEvent( GenerateTap( Gesture::Started, 1u, 1u, Vector2( 150.0f, 25.0f ) ) );
1933 // Render and notify
1934 application.SendNotification();
1935 application.Render();
1938 // Tap first to get the focus.
1939 application.ProcessEvent( GenerateTap( Gesture::Possible, 1u, 1u, Vector2( 1.f, 25.0f ) ) );
1940 application.ProcessEvent( GenerateTap( Gesture::Started, 1u, 1u, Vector2( 1.f, 25.0f ) ) );
1942 // Render and notify
1943 application.SendNotification();
1944 application.Render();
1946 // Double tap to select a word.
1947 application.ProcessEvent( GenerateTap( Gesture::Possible, 2u, 1u, Vector2( 1.f, 25.0f ) ) );
1948 application.ProcessEvent( GenerateTap( Gesture::Started, 2u, 1u, Vector2( 1.f, 25.0f ) ) );
1950 // Render and notify
1951 application.SendNotification();
1952 application.Render();
1955 application.ProcessEvent( GenerateTap( Gesture::Possible, 1u, 1u, Vector2( 0.f, 40.0f ) ) );
1956 application.ProcessEvent( GenerateTap( Gesture::Started, 1u, 1u, Vector2( 0.f, 40.0f ) ) );
1960 int utcDaliTextFieldEvent05(void)
1962 ToolkitTestApplication application;
1963 tet_infoline(" utcDaliTextFieldEvent05");
1965 // Checks dragging of cursor/grab handle
1967 TextField field = TextField::New();
1968 DALI_TEST_CHECK( field );
1969 Stage::GetCurrent().Add( field );
1970 LoadMarkerImages(application, field);
1971 // Render and notify
1972 application.SendNotification();
1973 application.Render();
1975 field.SetProperty( TextField::Property::TEXT, "This is a long text for the size of the text-field." );
1976 field.SetProperty( TextField::Property::POINT_SIZE, 10.f );
1977 field.SetSize( 300.f, 50.f );
1978 field.SetParentOrigin( ParentOrigin::TOP_LEFT );
1979 field.SetAnchorPoint( AnchorPoint::TOP_LEFT );
1981 // Avoid a crash when core load gl resources.
1982 application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
1983 // Render and notify
1984 application.SendNotification();
1985 application.Render();
1987 // Create a tap event to touch the text field.
1988 application.ProcessEvent( GenerateTap( Gesture::Possible, 1u, 1u, Vector2( 150.0f, 25.0f ) ) );
1989 application.ProcessEvent( GenerateTap( Gesture::Started, 1u, 1u, Vector2( 150.0f, 25.0f ) ) );
1990 // Render and notify
1991 application.SendNotification();
1992 application.Render();
1995 // Tap first to get the focus.
1996 application.ProcessEvent( GenerateTap( Gesture::Possible, 1u, 1u, Vector2( 1.f, 25.0f ) ) );
1997 application.ProcessEvent( GenerateTap( Gesture::Started, 1u, 1u, Vector2( 1.f, 25.0f ) ) );
1999 // Render and notify
2000 application.SendNotification();
2001 application.Render();
2003 // Double tap to select a word.
2004 application.ProcessEvent( GenerateTap( Gesture::Possible, 2u, 1u, Vector2( 1.f, 25.0f ) ) );
2005 application.ProcessEvent( GenerateTap( Gesture::Started, 2u, 1u, Vector2( 1.f, 25.0f ) ) );
2007 // Render and notify
2008 application.SendNotification();
2009 application.Render();
2011 // drag grab handle right
2012 Vector2 pos(0.0f, 40.0f);
2013 SendPan(application, Gesture::Possible, pos);
2014 SendPan(application, Gesture::Started, pos);
2016 Wait(application, 100);
2018 for(int i = 0;i<20;i++)
2020 SendPan(application, Gesture::Continuing, pos);
2025 SendPan(application, Gesture::Finished, pos);
2026 Wait(application, RENDER_FRAME_INTERVAL);
2028 Actor stencil = field.GetChildAt( 1u );
2032 int utcDaliTextFieldEvent06(void)
2034 ToolkitTestApplication application;
2035 tet_infoline(" utcDaliTextFieldEvent06");
2037 // Checks Longpress when in edit mode
2039 TextField field = TextField::New();
2040 DALI_TEST_CHECK( field );
2041 Stage::GetCurrent().Add( field );
2042 LoadMarkerImages(application, field);
2043 // Render and notify
2044 application.SendNotification();
2045 application.Render();
2047 field.SetProperty( TextField::Property::TEXT, "Thisisalongtextforthesizeofthetextfield." );
2048 field.SetProperty( TextField::Property::POINT_SIZE, 10.f );
2049 field.SetSize( 300.f, 50.f );
2050 field.SetParentOrigin( ParentOrigin::TOP_LEFT );
2051 field.SetAnchorPoint( AnchorPoint::TOP_LEFT );
2053 // Avoid a crash when core load gl resources.
2054 application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
2055 // Render and notify
2056 application.SendNotification();
2057 application.Render();
2059 // Create a tap event to touch the text field.
2060 application.ProcessEvent( GenerateTap( Gesture::Possible, 1u, 1u, Vector2( 150.0f, 25.0f ) ) );
2061 application.ProcessEvent( GenerateTap( Gesture::Started, 1u, 1u, Vector2( 150.0f, 25.0f ) ) );
2062 // Render and notify
2063 application.SendNotification();
2064 application.Render();
2067 // Tap first to get the focus.
2068 application.ProcessEvent( GenerateTap( Gesture::Possible, 1u, 1u, Vector2( 1.f, 25.0f ) ) );
2069 application.ProcessEvent( GenerateTap( Gesture::Started, 1u, 1u, Vector2( 1.f, 25.0f ) ) );
2071 // Render and notify
2072 application.SendNotification();
2073 application.Render();
2076 application.ProcessEvent( GenerateLongPress( Gesture::Possible, 1u, Vector2( 1.f, 25.0f ) ) );
2077 application.ProcessEvent( GenerateLongPress( Gesture::Started, 1u, Vector2( 1.f, 25.0f ) ) );
2079 // Render and notify
2080 application.SendNotification();
2081 application.Render();
2086 int utcDaliTextFieldEvent07(void)
2088 ToolkitTestApplication application;
2089 tet_infoline(" utcDaliTextFieldEvent07");
2091 // Checks Longpress to start edit mode
2093 TextField field = TextField::New();
2094 DALI_TEST_CHECK( field );
2095 Stage::GetCurrent().Add( field );
2096 LoadMarkerImages(application, field);
2097 // Render and notify
2098 application.SendNotification();
2099 application.Render();
2101 field.SetProperty( TextField::Property::TEXT, "Thisisalongtextforthesizeofthetextfield." );
2102 field.SetProperty( TextField::Property::POINT_SIZE, 10.f );
2103 field.SetSize( 300.f, 50.f );
2104 field.SetParentOrigin( ParentOrigin::TOP_LEFT );
2105 field.SetAnchorPoint( AnchorPoint::TOP_LEFT );
2106 Property::Map propertyMap;
2107 propertyMap["PANEL_LAYOUT"] = InputMethod::PanelLayout::PASSWORD;
2108 field.SetProperty( TextField::Property::INPUT_METHOD_SETTINGS, propertyMap );
2110 // Avoid a crash when core load gl resources.
2111 application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
2112 // Render and notify
2113 application.SendNotification();
2114 application.Render();
2117 application.ProcessEvent( GenerateLongPress( Gesture::Possible, 1u, Vector2( 1.f, 25.0f ) ) );
2118 application.ProcessEvent( GenerateLongPress( Gesture::Started, 1u, Vector2( 1.f, 25.0f ) ) );
2120 // Render and notify
2121 application.SendNotification();
2122 application.Render();
2127 int utcDaliTextFieldEvent08(void)
2129 ToolkitTestApplication application;
2130 tet_infoline(" utcDaliTextFieldEvent08");
2132 Dali::Clipboard clipboard = Clipboard::Get();
2133 clipboard.SetItem("testTextFieldEvent");
2135 // Checks Longpress when only place holder text
2137 TextField field = TextField::New();
2138 DALI_TEST_CHECK( field );
2139 Stage::GetCurrent().Add( field );
2140 LoadMarkerImages(application, field);
2141 // Render and notify
2142 application.SendNotification();
2143 application.Render();
2145 field.SetProperty( TextField::Property::PLACEHOLDER_TEXT, "Setting Placeholder Text" );
2146 field.SetProperty( TextField::Property::POINT_SIZE, 10.f );
2147 field.SetSize( 300.f, 50.f );
2148 field.SetParentOrigin( ParentOrigin::TOP_LEFT );
2149 field.SetAnchorPoint( AnchorPoint::TOP_LEFT );
2151 // Avoid a crash when core load gl resources.
2152 application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
2153 // Render and notify
2154 application.SendNotification();
2155 application.Render();
2158 application.ProcessEvent( GenerateLongPress( Gesture::Possible, 1u, Vector2( 1.f, 25.0f ) ) );
2159 application.ProcessEvent( GenerateLongPress( Gesture::Started, 1u, Vector2( 1.f, 25.0f ) ) );
2161 // Render and notify
2162 application.SendNotification();
2163 application.Render();
2165 Wait(application, 500);
2168 application.ProcessEvent( GenerateLongPress( Gesture::Possible, 1u, Vector2( 1.f, 25.0f ) ) );
2169 application.ProcessEvent( GenerateLongPress( Gesture::Started, 1u, Vector2( 1.f, 25.0f ) ) );
2171 // Render and notify
2172 application.SendNotification();
2173 application.Render();
2175 Wait(application, 500);
2177 Stage stage = Stage::GetCurrent();
2178 Layer layer = stage.GetRootLayer();
2179 Actor actor = layer.FindChildByName("optionPaste");
2183 Vector3 worldPosition = actor.GetCurrentWorldPosition();
2184 Vector2 halfStageSize = stage.GetSize() / 2.0f;
2185 Vector2 position(worldPosition.x + halfStageSize.width, worldPosition.y + halfStageSize.height);
2187 Dali::Integration::TouchEvent event;
2188 event = Dali::Integration::TouchEvent();
2189 event.AddPoint( GetPointDownInside( position ) );
2190 application.ProcessEvent( event );
2192 event = Dali::Integration::TouchEvent();
2193 event.AddPoint( GetPointUpInside( position ) );
2194 application.ProcessEvent( event );
2196 DALI_TEST_EQUALS( field.GetProperty<std::string>( TextEditor::Property::TEXT ), std::string("testTextFieldEvent"), TEST_LOCATION );
2201 int utcDaliTextFieldEvent09(void)
2203 ToolkitTestApplication application;
2204 tet_infoline(" utcDaliTextFieldEvent09");
2206 TextField field = TextField::New();
2207 DALI_TEST_CHECK( field );
2208 Stage::GetCurrent().Add( field );
2209 LoadMarkerImages(application, field);
2210 // Render and notify
2211 application.SendNotification();
2212 application.Render();
2214 field.SetProperty( TextField::Property::TEXT, "Hello" );
2215 field.SetProperty( TextField::Property::POINT_SIZE, 10.f );
2216 field.SetSize( 300.f, 50.f );
2217 field.SetParentOrigin( ParentOrigin::TOP_LEFT );
2218 field.SetAnchorPoint( AnchorPoint::TOP_LEFT );
2220 // Avoid a crash when core load gl resources.
2221 application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
2223 // Create a tap event to touch the text field.
2224 application.ProcessEvent( GenerateTap( Gesture::Possible, 1u, 1u, Vector2( 150.0f, 25.0f ) ) );
2225 application.ProcessEvent( GenerateTap( Gesture::Started, 1u, 1u, Vector2( 150.0f, 25.0f ) ) );
2226 application.SendNotification();
2227 application.Render();
2230 map[ HiddenInput::Property::MODE ] = HiddenInput::Mode::HIDE_NONE;
2231 field.SetProperty( TextField::Property::HIDDEN_INPUT_SETTINGS, map );
2232 application.ProcessEvent( GenerateKey( "d", "d", 0, 0, 0, Integration::KeyEvent::Down, DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2233 application.SendNotification();
2234 application.Render();
2236 map[ HiddenInput::Property::MODE ] = HiddenInput::Mode::HIDE_ALL;
2237 map[ HiddenInput::Property::SUBSTITUTE_CHARACTER ] = 0x23;
2238 field.SetProperty( TextField::Property::HIDDEN_INPUT_SETTINGS, map );
2239 application.ProcessEvent( GenerateKey( "d", "d", 0, 0, 0, Integration::KeyEvent::Down, DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2240 application.SendNotification();
2241 application.Render();
2243 map[ HiddenInput::Property::MODE ] = HiddenInput::Mode::HIDE_COUNT;
2244 map[ HiddenInput::Property::SUBSTITUTE_COUNT ] = 2;
2245 field.SetProperty( TextField::Property::HIDDEN_INPUT_SETTINGS, map );
2246 for( unsigned int index = 0u; index < 5u; ++index )
2248 application.ProcessEvent( GenerateKey( "d", "d", 0, 0, 0, Integration::KeyEvent::Down, DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2249 application.SendNotification();
2250 application.Render();
2253 map[ HiddenInput::Property::MODE ] = HiddenInput::Mode::SHOW_COUNT;
2254 map[ HiddenInput::Property::SUBSTITUTE_COUNT ] = 2;
2255 field.SetProperty( TextField::Property::HIDDEN_INPUT_SETTINGS, map );
2256 for( unsigned int index = 0u; index < 5u; ++index )
2258 application.ProcessEvent( GenerateKey( "d", "d", 0, 0, 0, Integration::KeyEvent::Down, DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2259 application.SendNotification();
2260 application.Render();
2263 map[ HiddenInput::Property::MODE ] = HiddenInput::Mode::SHOW_LAST_CHARACTER;
2264 map[ HiddenInput::Property::SHOW_LAST_CHARACTER_DURATION ] = 0;
2265 field.SetProperty( TextField::Property::HIDDEN_INPUT_SETTINGS, map );
2266 application.ProcessEvent( GenerateKey( "", "", DALI_KEY_BACKSPACE, 0, 0, Integration::KeyEvent::Down, DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2267 application.SendNotification();
2268 application.Render();
2269 application.ProcessEvent( GenerateKey( "d", "d", 0, 0, 0, Integration::KeyEvent::Down, DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2270 application.SendNotification();
2271 application.Render();
2273 map[ HiddenInput::Property::SHOW_LAST_CHARACTER_DURATION ] = 100;
2274 field.SetProperty( TextField::Property::HIDDEN_INPUT_SETTINGS, map );
2275 application.ProcessEvent( GenerateKey( "d", "d", 0, 0, 0, Integration::KeyEvent::Down, DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2276 application.SendNotification();
2277 application.Render();
2279 Property::Map mapGet;
2280 mapGet = field.GetProperty<Property::Map>( TextField::Property::HIDDEN_INPUT_SETTINGS );
2281 DALI_TEST_EQUALS( map.Count(), mapGet.Count(), TEST_LOCATION );
2282 DALI_TEST_EQUALS( DaliTestCheckMaps( map, mapGet ), true, TEST_LOCATION );
2287 int utcDaliTextFieldStyleWhilstSelected(void)
2289 ToolkitTestApplication application;
2290 tet_infoline(" utcDaliTextFieldStyleWhilstSelected");
2292 // Change font and styles whilst text is selected whilst word selected
2294 TextField field = TextField::New();
2295 DALI_TEST_CHECK( field );
2296 Stage::GetCurrent().Add( field );
2297 LoadMarkerImages(application, field);
2298 // Render and notify
2299 application.SendNotification();
2300 application.Render();
2302 field.SetProperty( TextField::Property::TEXT, "This is a long text for the size of the text-field." );
2303 field.SetProperty( TextField::Property::POINT_SIZE, 10.f );
2304 field.SetSize( 300.f, 50.f );
2305 field.SetParentOrigin( ParentOrigin::TOP_LEFT );
2306 field.SetAnchorPoint( AnchorPoint::TOP_LEFT );
2308 // Avoid a crash when core load gl resources.
2309 application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
2310 // Render and notify
2311 application.SendNotification();
2312 application.Render();
2314 // Create a tap event to touch the text field.
2315 application.ProcessEvent( GenerateTap( Gesture::Possible, 1u, 1u, Vector2( 150.0f, 25.0f ) ) );
2316 application.ProcessEvent( GenerateTap( Gesture::Started, 1u, 1u, Vector2( 150.0f, 25.0f ) ) );
2317 // Render and notify
2318 application.SendNotification();
2319 application.Render();
2322 // Tap first to get the focus.
2323 application.ProcessEvent( GenerateTap( Gesture::Possible, 1u, 1u, Vector2( 1.f, 25.0f ) ) );
2324 application.ProcessEvent( GenerateTap( Gesture::Started, 1u, 1u, Vector2( 1.f, 25.0f ) ) );
2326 // Render and notify
2327 application.SendNotification();
2328 application.Render();
2330 // Double tap to select a word.
2331 application.ProcessEvent( GenerateTap( Gesture::Possible, 2u, 1u, Vector2( 1.f, 25.0f ) ) );
2332 application.ProcessEvent( GenerateTap( Gesture::Started, 2u, 1u, Vector2( 1.f, 25.0f ) ) );
2334 // Render and notify
2335 application.SendNotification();
2336 application.Render();
2338 field.SetProperty( TextField::Property::INPUT_FONT_FAMILY, "Setting input font family" );
2339 DALI_TEST_EQUALS( field.GetProperty<std::string>( TextField::Property::INPUT_FONT_FAMILY ), "Setting input font family", TEST_LOCATION );
2341 Property::Map fontStyleMapSet;
2342 Property::Map fontStyleMapGet;
2344 fontStyleMapSet.Insert( "weight", "bold" );
2345 fontStyleMapSet.Insert( "slant", "italic" );
2346 field.SetProperty( TextField::Property::INPUT_FONT_STYLE, fontStyleMapSet );
2348 fontStyleMapGet = field.GetProperty<Property::Map>( TextField::Property::INPUT_FONT_STYLE );
2349 DALI_TEST_EQUALS( fontStyleMapGet.Count(), fontStyleMapSet.Count(), TEST_LOCATION );
2350 DALI_TEST_EQUALS( DaliTestCheckMaps( fontStyleMapGet, fontStyleMapSet ), true, TEST_LOCATION );
2352 fontStyleMapSet.Clear();
2353 fontStyleMapSet.Insert( "width", "expanded" );
2354 fontStyleMapSet.Insert( "slant", "italic" );
2355 field.SetProperty( TextField::Property::INPUT_FONT_STYLE, fontStyleMapSet );
2357 fontStyleMapGet = field.GetProperty<Property::Map>( TextField::Property::INPUT_FONT_STYLE );
2358 DALI_TEST_EQUALS( fontStyleMapGet.Count(), fontStyleMapSet.Count(), TEST_LOCATION );
2359 DALI_TEST_EQUALS( DaliTestCheckMaps( fontStyleMapGet, fontStyleMapSet ), true, TEST_LOCATION );
2361 field.SetProperty( TextField::Property::INPUT_POINT_SIZE, 12.f );
2362 DALI_TEST_EQUALS( field.GetProperty<float>( TextField::Property::INPUT_POINT_SIZE ), 12.f, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
2364 field.SetProperty( TextField::Property::TEXT_COLOR, Color::RED );
2365 DALI_TEST_EQUALS( field.GetProperty<Vector4>( TextField::Property::TEXT_COLOR ), Color::RED, TEST_LOCATION );
2367 fontStyleMapSet.Clear();
2368 fontStyleMapSet.Insert( "weight", "bold" );
2369 fontStyleMapSet.Insert( "slant", "italic" );
2371 field.SetProperty( TextField::Property::FONT_STYLE, fontStyleMapSet );
2373 fontStyleMapGet = field.GetProperty<Property::Map>( TextField::Property::FONT_STYLE );
2374 DALI_TEST_EQUALS( fontStyleMapGet.Count(), fontStyleMapSet.Count(), TEST_LOCATION );
2375 DALI_TEST_EQUALS( DaliTestCheckMaps( fontStyleMapGet, fontStyleMapSet ), true, TEST_LOCATION );
2377 fontStyleMapSet.Clear();
2378 fontStyleMapSet.Insert( "width", "expanded" );
2380 field.SetProperty( TextField::Property::FONT_STYLE, fontStyleMapSet );
2382 fontStyleMapGet = field.GetProperty<Property::Map>( TextField::Property::FONT_STYLE );
2383 DALI_TEST_EQUALS( fontStyleMapGet.Count(), fontStyleMapSet.Count(), TEST_LOCATION );
2384 DALI_TEST_EQUALS( DaliTestCheckMaps( fontStyleMapGet, fontStyleMapSet ), true, TEST_LOCATION );
2386 // Press Escape to increase coverage
2387 application.ProcessEvent( GenerateKey( "", "", DALI_KEY_ESCAPE, 0, 0, Integration::KeyEvent::Up, DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2388 application.SendNotification();
2389 application.Render();
2391 DALI_TEST_CHECK( !field.HasKeyInputFocus() );
2396 int utcDaliTextFieldEscKeyLoseFocus(void)
2398 ToolkitTestApplication application;
2399 tet_infoline(" utcDaliTextFieldEscKeyLoseFocus");
2401 // Creates a tap event. After creating a tap event the text field should
2402 // have the focus and add text with key events should be possible.
2404 TextField field = TextField::New();
2405 DALI_TEST_CHECK( field );
2407 Stage::GetCurrent().Add( field );
2409 field.SetSize( 300.f, 50.f );
2410 field.SetParentOrigin( ParentOrigin::TOP_LEFT );
2411 field.SetAnchorPoint( AnchorPoint::TOP_LEFT );
2413 // Avoid a crash when core load gl resources.
2414 application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
2416 // Render and notify
2417 application.SendNotification();
2418 application.Render();
2420 // Add a key event but as the text field has not the focus it should do nothing.
2421 application.ProcessEvent( GenerateKey( "a", "a", KEY_A_CODE, 0, 0, Integration::KeyEvent::Down, DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2422 application.ProcessEvent( GenerateKey( "a", "a", KEY_A_CODE, 0, 0, Integration::KeyEvent::Up, DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2424 // Render and notify
2425 application.SendNotification();
2426 application.Render();
2428 DALI_TEST_EQUALS( field.GetProperty<std::string>( TextField::Property::TEXT ), std::string(""), TEST_LOCATION );
2430 // Create a tap event to touch the text field.
2431 application.ProcessEvent( GenerateTap( Gesture::Possible, 1u, 1u, Vector2( 150.0f, 25.0f ) ) );
2432 application.ProcessEvent( GenerateTap( Gesture::Started, 1u, 1u, Vector2( 150.0f, 25.0f ) ) );
2434 // Render and notify
2435 application.SendNotification();
2436 application.Render();
2438 // Now the text field has the focus, so it can handle the key events.
2439 application.ProcessEvent( GenerateKey( "a", "a", KEY_A_CODE, 0, 0, Integration::KeyEvent::Down, DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2440 application.ProcessEvent( GenerateKey( "a", "a", KEY_A_CODE, 0, 0, Integration::KeyEvent::Up, DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2441 application.ProcessEvent( GenerateKey( "d", "d", KEY_D_CODE, 0, 0, Integration::KeyEvent::Down, DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2442 application.ProcessEvent( GenerateKey( "d", "d", KEY_D_CODE, 0, 0, Integration::KeyEvent::Up, DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2444 // Render and notify
2445 application.SendNotification();
2446 application.Render();
2448 DALI_TEST_EQUALS( field.GetProperty<std::string>( TextField::Property::TEXT ), std::string("ad"), TEST_LOCATION );
2450 // Generate a Esc key event. The text field should lose the focus.
2451 application.ProcessEvent( GenerateKey( "", "", DALI_KEY_ESCAPE, 0, 0, Integration::KeyEvent::Down, DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2452 application.ProcessEvent( GenerateKey( "", "", DALI_KEY_ESCAPE, 0, 0, Integration::KeyEvent::Up, DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2454 // Render and notify
2455 application.SendNotification();
2456 application.Render();
2458 DALI_TEST_EQUALS( false, field.HasKeyInputFocus(), TEST_LOCATION );
2460 // No more text should be introduced
2461 application.ProcessEvent( GenerateKey( "a", "a", KEY_A_CODE, 0, 0, Integration::KeyEvent::Down, DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2462 application.ProcessEvent( GenerateKey( "a", "a", KEY_A_CODE, 0, 0, Integration::KeyEvent::Up, DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2464 // Render and notify
2465 application.SendNotification();
2466 application.Render();
2468 DALI_TEST_EQUALS( field.GetProperty<std::string>( TextField::Property::TEXT ), std::string("ad"), TEST_LOCATION );
2473 int utcDaliTextFieldSomeSpecialKeys(void)
2475 ToolkitTestApplication application;
2476 tet_infoline(" utcDaliTextFieldSomeSpecialKeys");
2478 // Checks some special keys when the text is selected.
2480 TextField field = TextField::New();
2481 DALI_TEST_CHECK( field );
2482 Stage::GetCurrent().Add( field );
2483 LoadMarkerImages(application, field);
2484 // Render and notify
2485 application.SendNotification();
2486 application.Render();
2488 const std::string longText( "This is a long text for the size of the text-field." );
2490 field.SetProperty( TextField::Property::TEXT, longText );
2491 field.SetProperty( TextField::Property::POINT_SIZE, 10.f );
2492 field.SetSize( 300.f, 50.f );
2493 field.SetParentOrigin( ParentOrigin::TOP_LEFT );
2494 field.SetAnchorPoint( AnchorPoint::TOP_LEFT );
2496 // Avoid a crash when core load gl resources.
2497 application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
2498 // Render and notify
2499 application.SendNotification();
2500 application.Render();
2502 // Create a tap event to touch the text field.
2503 application.ProcessEvent( GenerateTap( Gesture::Possible, 1u, 1u, Vector2( 150.0f, 25.0f ) ) );
2504 application.ProcessEvent( GenerateTap( Gesture::Started, 1u, 1u, Vector2( 150.0f, 25.0f ) ) );
2506 // Render and notify
2507 application.SendNotification();
2508 application.Render();
2510 // Tap first to get the focus.
2511 application.ProcessEvent( GenerateTap( Gesture::Possible, 1u, 1u, Vector2( 1.f, 25.0f ) ) );
2512 application.ProcessEvent( GenerateTap( Gesture::Started, 1u, 1u, Vector2( 1.f, 25.0f ) ) );
2514 // Render and notify
2515 application.SendNotification();
2516 application.Render();
2518 // Double tap to select a word.
2519 application.ProcessEvent( GenerateTap( Gesture::Possible, 2u, 1u, Vector2( 1.f, 25.0f ) ) );
2520 application.ProcessEvent( GenerateTap( Gesture::Started, 2u, 1u, Vector2( 1.f, 25.0f ) ) );
2522 // Render and notify
2523 application.SendNotification();
2524 application.Render();
2526 // Generate a Esc key event. The text field should lose the focus.
2527 application.ProcessEvent( GenerateKey( "XF86PowerOff", "XF86PowerOff", DALI_KEY_POWER, 0, 0, Integration::KeyEvent::Down, DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2528 application.ProcessEvent( GenerateKey( "XF86PowerOff", "XF86PowerOff", DALI_KEY_POWER, 0, 0, Integration::KeyEvent::Up, DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2530 // Render and notify
2531 application.SendNotification();
2532 application.Render();
2534 // Generate a Esc key event. The text field should lose the focus.
2535 application.ProcessEvent( GenerateKey( "XF86Menu", "XF86Menu", DALI_KEY_MENU, 0, 0, Integration::KeyEvent::Down, DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2536 application.ProcessEvent( GenerateKey( "XF86Menu", "XF86Menu", DALI_KEY_MENU, 0, 0, Integration::KeyEvent::Up, DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2538 // Render and notify
2539 application.SendNotification();
2540 application.Render();
2542 // Generate a Esc key event. The text field should lose the focus.
2543 application.ProcessEvent( GenerateKey( "XF86Home", "XF86Home", DALI_KEY_HOME, 0, 0, Integration::KeyEvent::Down, DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2544 application.ProcessEvent( GenerateKey( "XF86Home", "XF86Home", DALI_KEY_HOME, 0, 0, Integration::KeyEvent::Up, DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2546 // Render and notify
2547 application.SendNotification();
2548 application.Render();
2550 // The text shouldn't be deleted.
2551 DALI_TEST_EQUALS( field.GetProperty<std::string>( TextField::Property::TEXT ), longText, TEST_LOCATION );
2556 int utcDaliTextFieldSizeUpdate(void)
2558 ToolkitTestApplication application;
2559 tet_infoline("utcDaliTextFieldSizeUpdate");
2561 // Checks some special keys when the text is selected.
2562 TextField field = TextField::New();
2563 DALI_TEST_CHECK( field );
2564 Stage::GetCurrent().Add( field );
2566 float previousHeight = 0.0f;
2567 float currentHeight = 0.0f;
2568 const float fieldWidth = 1920.0f;
2571 // "ㅁ" is bigger then "ኢ"
2572 field.SetSize( Vector2( fieldWidth ,10.0f ) );
2573 field.SetResizePolicy( ResizePolicy::FIXED , Dimension::WIDTH );
2574 field.SetResizePolicy( ResizePolicy::DIMENSION_DEPENDENCY , Dimension::HEIGHT );
2576 field.SetProperty( TextField::Property::TEXT, "ኢ");
2577 field.SetParentOrigin( ParentOrigin::TOP_LEFT );
2578 field.SetAnchorPoint( AnchorPoint::TOP_LEFT );
2580 field.SetKeyboardFocusable(true);
2581 KeyboardFocusManager::Get().SetCurrentFocusActor( field );
2583 application.SendNotification();
2584 application.Render();
2586 previousHeight = field.GetHeightForWidth( fieldWidth );
2587 DALI_TEST_EQUALS( previousHeight, field.GetProperty<float>( Actor::Property::SIZE_HEIGHT ) , TEST_LOCATION );
2589 // Add another script characters ( glyph height is defferent )
2590 application.ProcessEvent( GenerateKey( "ㅁ", "ㅁ", KEY_A_CODE, 0, 0, Integration::KeyEvent::Down, DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2591 application.ProcessEvent( GenerateKey( "ㅁ", "ㅁ", KEY_A_CODE, 0, 0, Integration::KeyEvent::Up, DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2593 application.SendNotification();
2594 application.Render();
2596 currentHeight = field.GetHeightForWidth( fieldWidth );
2597 DALI_TEST_EQUALS( currentHeight, field.GetProperty<float>( Actor::Property::SIZE_HEIGHT ), TEST_LOCATION );
2598 DALI_TEST_EQUALS( (previousHeight < currentHeight), true , TEST_LOCATION );
2603 int utcDaliTextFieldExtremlyLargePointSize(void)
2605 ToolkitTestApplication application;
2606 tet_infoline(" utcDaliTextFieldExtremlyLargePointSize");
2608 TextField field = TextField::New();
2610 field.SetProperty( TextField::Property::TEXT, "Text" );
2611 field.SetSize( 300.f, 50.f );
2612 field.SetParentOrigin( ParentOrigin::TOP_LEFT );
2613 field.SetAnchorPoint( AnchorPoint::TOP_LEFT );
2614 Stage::GetCurrent().Add( field );
2618 field.SetProperty( TextField::Property::POINT_SIZE, 160.0f );
2619 application.SendNotification();
2620 DALI_TEST_CHECK( field );
2624 tet_result(TET_FAIL);
2629 int UtcDaliTextFieldDefaultFontStylePropertyCoverage(void)
2631 ToolkitTestApplication application;
2632 tet_infoline("UtcDaliTextFieldFontStylePorpertyCoverage");
2633 TextField field = TextField::New();
2634 DALI_TEST_CHECK( field );
2635 Stage::GetCurrent().Add( field );
2637 Property::Map fontStyleMapGet;
2639 fontStyleMapGet = field.GetProperty<Property::Map>( TextField::Property::FONT_STYLE );
2641 Property::Value* weightValue = NULL;
2642 Property::Value* widthValue = NULL;
2643 Property::Value* slantValue = NULL;
2644 weightValue = fontStyleMapGet.Find( "weight" );
2645 widthValue = fontStyleMapGet.Find( "width" );
2646 slantValue = fontStyleMapGet.Find( "slant" );
2647 DALI_TEST_CHECK( !weightValue );
2648 DALI_TEST_CHECK( !widthValue );
2649 DALI_TEST_CHECK( !slantValue );
2654 int UtcDaliTextFieldSettingPlaceholder(void)
2656 ToolkitTestApplication application;
2657 tet_infoline("UtcDaliTextFieldSettingPlaceholder");
2659 TextField field = TextField::New();
2660 DALI_TEST_CHECK( field );
2661 Stage::GetCurrent().Add( field );
2663 // Check the placeholder property with pixel size
2664 Property::Map placeholderPixelSizeMapSet;
2665 Property::Map placeholderPixelSizeMapGet;
2666 Property::Map placeholderFontstyleMap;
2667 placeholderPixelSizeMapSet[ Text::PlaceHolder::Property::TEXT ] = "Setting Placeholder Text";
2668 placeholderPixelSizeMapSet[ Text::PlaceHolder::Property::TEXT_FOCUSED ] = "Setting Placeholder Text Focused";
2669 placeholderPixelSizeMapSet[ Text::PlaceHolder::Property::COLOR ] = Color::BLUE;
2670 placeholderPixelSizeMapSet[ Text::PlaceHolder::Property::FONT_FAMILY ] = "Arial";
2671 placeholderPixelSizeMapSet[ Text::PlaceHolder::Property::PIXEL_SIZE ] = 15.0f;
2672 placeholderPixelSizeMapSet[ Text::PlaceHolder::Property::ELLIPSIS ] = true;
2674 placeholderFontstyleMap.Insert( "weight", "bold" );
2675 placeholderPixelSizeMapSet[ Text::PlaceHolder::Property::FONT_STYLE ] = placeholderFontstyleMap;
2676 field.SetProperty( TextField::Property::PLACEHOLDER, placeholderPixelSizeMapSet );
2678 placeholderPixelSizeMapGet = field.GetProperty<Property::Map>( TextField::Property::PLACEHOLDER );
2679 DALI_TEST_EQUALS( placeholderPixelSizeMapGet.Count(), placeholderPixelSizeMapSet.Count(), TEST_LOCATION );
2680 DALI_TEST_EQUALS( DaliTestCheckMaps( placeholderPixelSizeMapGet, placeholderPixelSizeMapSet ), true, TEST_LOCATION );
2682 // Check the placeholder property with point size
2683 Property::Map placeholderMapSet;
2684 Property::Map placeholderMapGet;
2685 placeholderMapSet[ Text::PlaceHolder::Property::TEXT ] = "Setting Placeholder Text";
2686 placeholderMapSet[ Text::PlaceHolder::Property::TEXT_FOCUSED ] = "Setting Placeholder Text Focused";
2687 placeholderMapSet[ Text::PlaceHolder::Property::COLOR ] = Color::RED;
2688 placeholderMapSet[ Text::PlaceHolder::Property::FONT_FAMILY ] = "Arial";
2689 placeholderMapSet[ Text::PlaceHolder::Property::POINT_SIZE ] = 12.0f;
2690 placeholderMapSet[ Text::PlaceHolder::Property::ELLIPSIS ] = false;
2692 // Check the placeholder font style property
2693 placeholderFontstyleMap.Clear();
2695 placeholderFontstyleMap.Insert( "weight", "bold" );
2696 placeholderFontstyleMap.Insert( "width", "condensed" );
2697 placeholderFontstyleMap.Insert( "slant", "italic" );
2698 placeholderMapSet[ Text::PlaceHolder::Property::FONT_STYLE ] = placeholderFontstyleMap;
2699 field.SetProperty( TextField::Property::PLACEHOLDER, placeholderMapSet );
2701 placeholderMapGet = field.GetProperty<Property::Map>( TextField::Property::PLACEHOLDER );
2702 DALI_TEST_EQUALS( placeholderMapGet.Count(), placeholderMapSet.Count(), TEST_LOCATION );
2703 DALI_TEST_EQUALS( DaliTestCheckMaps( placeholderMapGet, placeholderMapSet ), true, TEST_LOCATION );
2705 // Reset font style.
2706 placeholderFontstyleMap.Clear();
2707 placeholderFontstyleMap.Insert( "weight", "normal" );
2708 placeholderFontstyleMap.Insert( "slant", "oblique" );
2709 placeholderMapSet[ Text::PlaceHolder::Property::FONT_STYLE ] = placeholderFontstyleMap;
2710 field.SetProperty( TextField::Property::PLACEHOLDER, placeholderMapSet );
2712 placeholderMapGet = field.GetProperty<Property::Map>( TextField::Property::PLACEHOLDER );
2713 DALI_TEST_EQUALS( placeholderMapGet.Count(), placeholderMapSet.Count(), TEST_LOCATION );
2714 DALI_TEST_EQUALS( DaliTestCheckMaps( placeholderMapGet, placeholderMapSet ), true, TEST_LOCATION );
2716 placeholderFontstyleMap.Clear();
2717 placeholderFontstyleMap.Insert( "slant", "roman" );
2718 placeholderMapSet[ Text::PlaceHolder::Property::FONT_STYLE ] = placeholderFontstyleMap;
2719 field.SetProperty( TextField::Property::PLACEHOLDER, placeholderMapSet );
2721 placeholderMapGet = field.GetProperty<Property::Map>( TextField::Property::PLACEHOLDER );
2723 placeholderFontstyleMap.Clear();
2724 placeholderMapSet[ Text::PlaceHolder::Property::FONT_STYLE ] = placeholderFontstyleMap;
2726 field.SetProperty( TextField::Property::PLACEHOLDER, placeholderMapSet );
2727 placeholderMapGet = field.GetProperty<Property::Map>( TextField::Property::PLACEHOLDER );
2728 DALI_TEST_EQUALS( placeholderMapGet.Count(), placeholderMapSet.Count(), TEST_LOCATION );
2729 DALI_TEST_EQUALS( DaliTestCheckMaps( placeholderMapGet, placeholderMapSet ), true, TEST_LOCATION );
2734 int UtcDaliTextFieldSetPaddingProperty(void)
2736 ToolkitTestApplication application;
2737 tet_infoline("UtcDaliTextFieldSetPaddingProperty\n");
2739 TextField field = TextField::New();
2740 DALI_TEST_CHECK( field );
2741 field.SetSize( 300.f, 50.f );
2742 field.SetParentOrigin( ParentOrigin::TOP_LEFT );
2743 field.SetAnchorPoint( AnchorPoint::TOP_LEFT );
2744 Stage::GetCurrent().Add( field );
2746 application.SendNotification();
2747 application.Render();
2749 Vector3 originalSize = field.GetNaturalSize();
2751 field.SetProperty( Toolkit::Control::Property::PADDING, Extents( 10, 10, 10, 10 ) );
2753 application.SendNotification();
2754 application.Render();
2756 DALI_TEST_EQUALS( field.GetProperty<Extents>( Toolkit::Control::Property::PADDING ), Extents( 10, 10, 10, 10 ), TEST_LOCATION );
2758 Vector3 paddingAddedSize = field.GetNaturalSize();
2760 DALI_TEST_EQUALS( originalSize.width + 10 + 10 , paddingAddedSize.width, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
2762 DALI_TEST_EQUALS( originalSize.height + 10 + 10 , paddingAddedSize.height, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
2767 int UtcDaliTextFieldEnableShiftSelectionProperty(void)
2769 ToolkitTestApplication application;
2770 tet_infoline("UtcDaliTextFieldEnableShiftSelectionProperty");
2772 TextField field = TextField::New();
2773 DALI_TEST_CHECK( field );
2774 field.SetSize( 300.f, 50.f );
2775 field.SetParentOrigin( ParentOrigin::TOP_LEFT );
2776 field.SetAnchorPoint( AnchorPoint::TOP_LEFT );
2777 Stage::GetCurrent().Add( field );
2779 application.SendNotification();
2780 application.Render();
2782 // The default value of ENABLE_SHIFT_SELECTION is 'true'.
2783 DALI_TEST_EQUALS( field.GetProperty<bool>( DevelTextField::Property::ENABLE_SHIFT_SELECTION ), true, TEST_LOCATION );
2785 // Check the enable shift selection property
2786 field.SetProperty( DevelTextField::Property::ENABLE_SHIFT_SELECTION, false );
2787 DALI_TEST_EQUALS( field.GetProperty<bool>( DevelTextField::Property::ENABLE_SHIFT_SELECTION ), false, TEST_LOCATION );
2789 application.SendNotification();
2790 application.Render();