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";
105 const char* const PROPERTY_NAME_ENABLE_GRAB_HANDLE = "enableGrabHandle";
107 const int DEFAULT_RENDERING_BACKEND = Dali::Toolkit::Text::DEFAULT_RENDERING_BACKEND;
109 const Vector4 PLACEHOLDER_TEXT_COLOR( 0.8f, 0.8f, 0.8f, 0.8f );
110 const Dali::Vector4 LIGHT_BLUE( 0.75f, 0.96f, 1.f, 1.f ); // The text highlight color.
112 const unsigned int CURSOR_BLINK_INTERVAL = 500u; // Cursor blink interval
113 const float RENDER_FRAME_INTERVAL = 16.66f;
115 const float TO_MILLISECONDS = 1000.f;
116 const float TO_SECONDS = 1.f / TO_MILLISECONDS;
118 const float SCROLL_THRESHOLD = 10.f;
119 const float SCROLL_SPEED = 300.f;
121 const unsigned int DEFAULT_FONT_SIZE = 1152u;
122 const std::string DEFAULT_FONT_DIR( "/resources/fonts" );
124 const int KEY_RETURN_CODE = 36;
125 const int KEY_A_CODE = 38;
126 const int KEY_D_CODE = 40;
128 const std::string DEFAULT_DEVICE_NAME("hwKeyboard");
130 static bool gTextChangedCallBackCalled;
131 static bool gMaxCharactersCallBackCalled;
132 static bool gInputStyleChangedCallbackCalled;
133 static Dali::Toolkit::TextField::InputStyle::Mask gInputStyleMask;
135 static void LoadBitmapResource(TestPlatformAbstraction& platform, int width, int height)
137 Integration::Bitmap* bitmap = Integration::Bitmap::New( Integration::Bitmap::BITMAP_2D_PACKED_PIXELS, ResourcePolicy::OWNED_DISCARD );
138 Integration::ResourcePointer resource(bitmap);
139 bitmap->GetPackedPixelsProfile()->ReserveBuffer(Pixel::RGBA8888, width, height, width, height);
142 static void LoadMarkerImages(ToolkitTestApplication& app, TextField textField)
146 LoadBitmapResource( app.GetPlatform(), width, height );
148 Property::Map propertyMap;
149 propertyMap["filename"] = "image.png";
150 propertyMap["width"] = width;
151 propertyMap["height"] = height;
152 textField.SetProperty( Toolkit::TextField::Property::SELECTION_HANDLE_IMAGE_LEFT, propertyMap );
153 textField.SetProperty( Toolkit::TextField::Property::SELECTION_HANDLE_IMAGE_RIGHT, propertyMap );
154 textField.SetProperty( Toolkit::TextField::Property::SELECTION_HANDLE_PRESSED_IMAGE_LEFT, propertyMap );
155 textField.SetProperty( Toolkit::TextField::Property::SELECTION_HANDLE_PRESSED_IMAGE_RIGHT, propertyMap );
156 textField.SetProperty( Toolkit::TextField::Property::SELECTION_HANDLE_MARKER_IMAGE_LEFT, propertyMap );
157 textField.SetProperty( Toolkit::TextField::Property::SELECTION_HANDLE_MARKER_IMAGE_RIGHT, propertyMap );
158 textField.SetProperty( Toolkit::TextField::Property::GRAB_HANDLE_IMAGE, propertyMap );
159 textField.SetProperty( Toolkit::TextField::Property::GRAB_HANDLE_PRESSED_IMAGE, propertyMap );
162 // Generate a PanGestureEvent to send to Core
163 static Integration::PanGestureEvent GeneratePan(
164 Gesture::State state,
165 const Vector2& previousPosition,
166 const Vector2& currentPosition,
167 unsigned long timeDelta,
168 unsigned int numberOfTouches = 1)
170 Integration::PanGestureEvent pan(state);
172 pan.previousPosition = previousPosition;
173 pan.currentPosition = currentPosition;
174 pan.timeDelta = timeDelta;
175 pan.numberOfTouches = numberOfTouches;
181 * Helper to generate PanGestureEvent
183 * @param[in] application Application instance
184 * @param[in] state The Gesture State
185 * @param[in] pos The current position of touch.
187 static void SendPan(ToolkitTestApplication& application, Gesture::State state, const Vector2& pos)
191 if( (state == Gesture::Started) ||
192 (state == Gesture::Possible) )
198 application.ProcessEvent(GeneratePan(state, last, pos, 16));
205 * Simulate time passed by.
207 * @note this will always process at least 1 frame (1/60 sec)
209 * @param application Test application instance
210 * @param duration Time to pass in milliseconds.
211 * @return The actual time passed in milliseconds
213 static int Wait(ToolkitTestApplication& application, int duration = 0)
217 for(int i = 0; i <= ( duration / RENDER_FRAME_INTERVAL); i++)
219 application.SendNotification();
220 application.Render(RENDER_FRAME_INTERVAL);
221 time += RENDER_FRAME_INTERVAL;
227 Dali::Integration::Point GetPointDownInside( Vector2& pos )
229 Dali::Integration::Point point;
230 point.SetState( PointState::DOWN );
231 point.SetScreenPosition( pos );
235 Dali::Integration::Point GetPointUpInside( Vector2& pos )
237 Dali::Integration::Point point;
238 point.SetState( PointState::UP );
239 point.SetScreenPosition( pos );
243 struct CallbackFunctor
245 CallbackFunctor(bool* callbackFlag)
246 : mCallbackFlag( callbackFlag )
252 *mCallbackFlag = true;
257 static void TestTextChangedCallback( TextField control )
259 tet_infoline(" TestTextChangedCallback");
261 gTextChangedCallBackCalled = true;
264 static void TestMaxLengthReachedCallback( TextField control )
266 tet_infoline(" TestMaxLengthReachedCallback");
268 gMaxCharactersCallBackCalled = true;
271 static void TestInputStyleChangedCallback( TextField control, TextField::InputStyle::Mask mask )
273 tet_infoline(" TestInputStyleChangedCallback");
275 gInputStyleChangedCallbackCalled = true;
276 gInputStyleMask = mask;
279 // Generate a TapGestureEvent to send to Core.
280 Integration::TapGestureEvent GenerateTap(
281 Gesture::State state,
282 unsigned int numberOfTaps,
283 unsigned int numberOfTouches,
286 Integration::TapGestureEvent tap( state );
288 tap.numberOfTaps = numberOfTaps;
289 tap.numberOfTouches = numberOfTouches;
295 Integration::LongPressGestureEvent GenerateLongPress(
296 Gesture::State state,
297 unsigned int numberOfTouches,
300 Integration::LongPressGestureEvent longPress( state );
302 longPress.numberOfTouches = numberOfTouches;
303 longPress.point = point;
307 // Generate a KeyEvent to send to Core.
308 Integration::KeyEvent GenerateKey( const std::string& keyName,
309 const std::string& keyString,
312 unsigned long timeStamp,
313 const Integration::KeyEvent::State& keyState,
314 const std::string& deviceName = DEFAULT_DEVICE_NAME,
315 const Device::Class::Type& deviceClass = Device::Class::NONE,
316 const Device::Subclass::Type& deviceSubclass = Device::Subclass::NONE )
318 return Integration::KeyEvent( keyName,
329 bool DaliTestCheckMaps( const Property::Map& fontStyleMapGet, const Property::Map& fontStyleMapSet )
331 if( fontStyleMapGet.Count() == fontStyleMapSet.Count() )
333 for( unsigned int index = 0u; index < fontStyleMapGet.Count(); ++index )
335 const KeyValuePair& valueGet = fontStyleMapGet.GetKeyValue( index );
337 Property::Value* valueSet = NULL;
338 if ( valueGet.first.type == Property::Key::INDEX )
340 valueSet = fontStyleMapSet.Find( valueGet.first.indexKey );
344 // Get Key is a string so searching Set Map for a string key
345 valueSet = fontStyleMapSet.Find( valueGet.first.stringKey );
348 if( NULL != valueSet )
350 if( valueSet->GetType() == Dali::Property::STRING && ( valueGet.second.Get<std::string>() != valueSet->Get<std::string>() ) )
352 tet_printf( "Value got : [%s], expected : [%s]", valueGet.second.Get<std::string>().c_str(), valueSet->Get<std::string>().c_str() );
355 else if( valueSet->GetType() == Dali::Property::BOOLEAN && ( valueGet.second.Get<bool>() != valueSet->Get<bool>() ) )
357 tet_printf( "Value got : [%d], expected : [%d]", valueGet.second.Get<bool>(), valueSet->Get<bool>() );
360 else if( valueSet->GetType() == Dali::Property::INTEGER && ( valueGet.second.Get<int>() != valueSet->Get<int>() ) )
362 tet_printf( "Value got : [%d], expected : [%d]", valueGet.second.Get<int>(), valueSet->Get<int>() );
365 else if( valueSet->GetType() == Dali::Property::FLOAT && ( valueGet.second.Get<float>() != valueSet->Get<float>() ) )
367 tet_printf( "Value got : [%f], expected : [%f]", valueGet.second.Get<float>(), valueSet->Get<float>() );
370 else if( valueSet->GetType() == Dali::Property::VECTOR2 && ( valueGet.second.Get<Vector2>() != valueSet->Get<Vector2>() ) )
372 Vector2 vector2Get = valueGet.second.Get<Vector2>();
373 Vector2 vector2Set = valueSet->Get<Vector2>();
374 tet_printf( "Value got : [%f, %f], expected : [%f, %f]", vector2Get.x, vector2Get.y, vector2Set.x, vector2Set.y );
377 else if( valueSet->GetType() == Dali::Property::VECTOR4 && ( valueGet.second.Get<Vector4>() != valueSet->Get<Vector4>() ) )
379 Vector4 vector4Get = valueGet.second.Get<Vector4>();
380 Vector4 vector4Set = valueSet->Get<Vector4>();
381 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 );
387 if ( valueGet.first.type == Property::Key::INDEX )
389 tet_printf( " The key %d doesn't exist.", valueGet.first.indexKey );
393 tet_printf( " The key %s doesn't exist.", valueGet.first.stringKey.c_str() );
405 int UtcDaliToolkitTextFieldConstructorP(void)
407 ToolkitTestApplication application;
408 tet_infoline(" UtcDaliToolkitTextFieldConstructorP");
410 DALI_TEST_CHECK( !textField );
414 int UtcDaliToolkitTextFieldNewP(void)
416 ToolkitTestApplication application;
417 tet_infoline(" UtcDaliToolkitTextFieldNewP");
418 TextField textField = TextField::New();
419 DALI_TEST_CHECK( textField );
423 int UtcDaliToolkitTextFieldDownCastP(void)
425 ToolkitTestApplication application;
426 tet_infoline(" UtcDaliToolkitTextFieldDownCastP");
427 TextField textField1 = TextField::New();
428 BaseHandle object( textField1 );
430 TextField textField2 = TextField::DownCast( object );
431 DALI_TEST_CHECK( textField2 );
433 TextField textField3 = DownCast< TextField >( object );
434 DALI_TEST_CHECK( textField3 );
438 int UtcDaliToolkitTextFieldDownCastN(void)
440 ToolkitTestApplication application;
441 tet_infoline(" UtcDaliToolkitTextFieldDownCastN");
442 BaseHandle uninitializedObject;
443 TextField textField1 = TextField::DownCast( uninitializedObject );
444 DALI_TEST_CHECK( !textField1 );
446 TextField textField2 = DownCast< TextField >( uninitializedObject );
447 DALI_TEST_CHECK( !textField2 );
451 int UtcDaliToolkitTextFieldCopyConstructorP(void)
453 ToolkitTestApplication application;
454 tet_infoline(" UtcDaliToolkitTextFieldCopyConstructorP");
455 TextField textField = TextField::New();
456 textField.SetProperty( TextField::Property::TEXT, "Test" );
458 TextField copy( textField );
459 DALI_TEST_CHECK( copy );
460 DALI_TEST_CHECK( copy.GetProperty<std::string>( TextLabel::Property::TEXT ) == textField.GetProperty<std::string>( TextLabel::Property::TEXT ) );
464 int UtcDaliToolkitTextFieldAssignmentOperatorP(void)
466 ToolkitTestApplication application;
467 tet_infoline(" UtcDaliToolkitTextFieldAssignmentOperatorP");
468 TextField textField = TextField::New();
469 textField.SetProperty( TextField::Property::TEXT, "Test" );
471 TextField copy = textField;
472 DALI_TEST_CHECK( copy );
473 DALI_TEST_CHECK( copy.GetProperty<std::string>( TextField::Property::TEXT ) == textField.GetProperty<std::string>( TextField::Property::TEXT ) );
477 int UtcDaliTextFieldNewP(void)
479 ToolkitTestApplication application;
480 tet_infoline(" UtcDaliToolkitTextFieldNewP");
481 TextField textField = TextField::New();
482 DALI_TEST_CHECK( textField );
486 // Positive test case for a method
487 int UtcDaliTextFieldGetPropertyP(void)
489 ToolkitTestApplication application;
490 tet_infoline(" UtcDaliToolkitTextFieldGetPropertyP");
491 TextField field = TextField::New();
492 DALI_TEST_CHECK( field );
494 // Check Property Indices are correct
495 DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_RENDERING_BACKEND ) == TextField::Property::RENDERING_BACKEND );
496 DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_TEXT ) == TextField::Property::TEXT );
497 DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_PLACEHOLDER_TEXT ) == TextField::Property::PLACEHOLDER_TEXT );
498 DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_PLACEHOLDER_TEXT_FOCUSED ) == TextField::Property::PLACEHOLDER_TEXT_FOCUSED );
499 DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_FONT_FAMILY ) == TextField::Property::FONT_FAMILY );
500 DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_FONT_STYLE ) == TextField::Property::FONT_STYLE );
501 DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_POINT_SIZE ) == TextField::Property::POINT_SIZE );
502 DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_MAX_LENGTH ) == TextField::Property::MAX_LENGTH );
503 DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_EXCEED_POLICY ) == TextField::Property::EXCEED_POLICY );
504 DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_HORIZONTAL_ALIGNMENT ) == TextField::Property::HORIZONTAL_ALIGNMENT );
505 DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_VERTICAL_ALIGNMENT ) == TextField::Property::VERTICAL_ALIGNMENT );
506 DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_TEXT_COLOR ) == TextField::Property::TEXT_COLOR );
507 DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_PLACEHOLDER_TEXT_COLOR ) == TextField::Property::PLACEHOLDER_TEXT_COLOR );
508 DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_SHADOW_OFFSET ) == TextField::Property::SHADOW_OFFSET );
509 DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_SHADOW_COLOR ) == TextField::Property::SHADOW_COLOR );
510 DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_PRIMARY_CURSOR_COLOR ) == TextField::Property::PRIMARY_CURSOR_COLOR );
511 DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_SECONDARY_CURSOR_COLOR ) == TextField::Property::SECONDARY_CURSOR_COLOR );
512 DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_ENABLE_CURSOR_BLINK ) == TextField::Property::ENABLE_CURSOR_BLINK );
513 DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_CURSOR_BLINK_INTERVAL ) == TextField::Property::CURSOR_BLINK_INTERVAL );
514 DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_CURSOR_BLINK_DURATION ) == TextField::Property::CURSOR_BLINK_DURATION );
515 DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_CURSOR_WIDTH ) == TextField::Property::CURSOR_WIDTH );
516 DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_GRAB_HANDLE_IMAGE ) == TextField::Property::GRAB_HANDLE_IMAGE );
517 DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_GRAB_HANDLE_PRESSED_IMAGE ) == TextField::Property::GRAB_HANDLE_PRESSED_IMAGE );
518 DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_SCROLL_THRESHOLD ) == TextField::Property::SCROLL_THRESHOLD );
519 DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_SCROLL_SPEED ) == TextField::Property::SCROLL_SPEED );
520 DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_SELECTION_HANDLE_IMAGE_LEFT ) == TextField::Property::SELECTION_HANDLE_IMAGE_LEFT );
521 DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_SELECTION_HANDLE_IMAGE_RIGHT ) == TextField::Property::SELECTION_HANDLE_IMAGE_RIGHT );
522 DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_SELECTION_HANDLE_PRESSED_IMAGE_LEFT ) == TextField::Property::SELECTION_HANDLE_PRESSED_IMAGE_LEFT );
523 DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_SELECTION_HANDLE_PRESSED_IMAGE_RIGHT ) == TextField::Property::SELECTION_HANDLE_PRESSED_IMAGE_RIGHT );
524 DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_SELECTION_HANDLE_MARKER_IMAGE_LEFT ) == TextField::Property::SELECTION_HANDLE_MARKER_IMAGE_LEFT );
525 DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_SELECTION_HANDLE_MARKER_IMAGE_RIGHT ) == TextField::Property::SELECTION_HANDLE_MARKER_IMAGE_RIGHT );
526 DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_SELECTION_HIGHLIGHT_COLOR ) == TextField::Property::SELECTION_HIGHLIGHT_COLOR );
527 DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_DECORATION_BOUNDING_BOX ) == TextField::Property::DECORATION_BOUNDING_BOX );
528 DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_INPUT_METHOD_SETTINGS ) == TextField::Property::INPUT_METHOD_SETTINGS );
529 DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_INPUT_COLOR ) == TextField::Property::INPUT_COLOR );
530 DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_ENABLE_MARKUP ) == TextField::Property::ENABLE_MARKUP );
531 DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_INPUT_FONT_FAMILY ) == TextField::Property::INPUT_FONT_FAMILY );
532 DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_INPUT_FONT_STYLE ) == TextField::Property::INPUT_FONT_STYLE );
533 DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_INPUT_POINT_SIZE ) == TextField::Property::INPUT_POINT_SIZE );
534 DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_UNDERLINE ) == TextField::Property::UNDERLINE );
535 DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_INPUT_UNDERLINE ) == TextField::Property::INPUT_UNDERLINE );
536 DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_SHADOW ) == TextField::Property::SHADOW );
537 DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_INPUT_SHADOW ) == TextField::Property::INPUT_SHADOW );
538 DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_EMBOSS ) == TextField::Property::EMBOSS );
539 DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_INPUT_EMBOSS ) == TextField::Property::INPUT_EMBOSS );
540 DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_OUTLINE ) == TextField::Property::OUTLINE );
541 DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_INPUT_OUTLINE ) == TextField::Property::INPUT_OUTLINE );
542 DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_HIDDEN_INPUT_SETTINGS ) == TextField::Property::HIDDEN_INPUT_SETTINGS );
543 DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_PIXEL_SIZE ) == TextField::Property::PIXEL_SIZE );
544 DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_ENABLE_SELECTION ) == TextField::Property::ENABLE_SELECTION );
545 DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_PLACEHOLDER ) == TextField::Property::PLACEHOLDER );
546 DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_ELLIPSIS ) == TextField::Property::ELLIPSIS );
547 DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_ENABLE_SHIFT_SELECTION ) == DevelTextField::Property::ENABLE_SHIFT_SELECTION );
548 DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_ENABLE_GRAB_HANDLE ) == DevelTextField::Property::ENABLE_GRAB_HANDLE );
553 bool SetPropertyMapRetrieved( TextField& field, const Property::Index property, const std::string mapKey, const std::string mapValue )
556 Property::Map imageMap;
557 imageMap[mapKey] =mapValue;
559 field.SetProperty( property , imageMap );
560 Property::Value propValue = field.GetProperty( property );
561 Property::Map* resultMap = propValue.GetMap();
563 if ( resultMap->Find( mapKey )->Get< std::string>() == mapValue )
571 // Positive test case for a method
572 int UtcDaliTextFieldSetPropertyP(void)
574 ToolkitTestApplication application;
575 tet_infoline(" UtcDaliToolkitTextFieldSetPropertyP");
576 TextField field = TextField::New();
577 DALI_TEST_CHECK( field );
578 Stage::GetCurrent().Add( field );
580 // Note - we can't check the defaults since the stylesheets are platform-specific
582 // Check the render backend property.
583 field.SetProperty( TextField::Property::RENDERING_BACKEND, Text::RENDERING_SHARED_ATLAS );
584 DALI_TEST_EQUALS( (Text::RenderingType)field.GetProperty<int>( TextField::Property::RENDERING_BACKEND ), Text::RENDERING_SHARED_ATLAS, TEST_LOCATION );
586 // Check text property.
587 field.SetProperty( TextField::Property::TEXT, "Setting Text" );
588 DALI_TEST_EQUALS( field.GetProperty<std::string>( TextField::Property::TEXT ), std::string("Setting Text"), TEST_LOCATION );
590 // Check placeholder text properties.
591 field.SetProperty( TextField::Property::PLACEHOLDER_TEXT, "Setting Placeholder Text" );
592 DALI_TEST_EQUALS( field.GetProperty<std::string>( TextField::Property::PLACEHOLDER_TEXT ), std::string("Setting Placeholder Text"), TEST_LOCATION );
594 field.SetProperty( TextField::Property::PLACEHOLDER_TEXT_FOCUSED, "Setting Placeholder Text Focused" );
595 DALI_TEST_EQUALS( field.GetProperty<std::string>( TextField::Property::PLACEHOLDER_TEXT_FOCUSED ), std::string("Setting Placeholder Text Focused"), TEST_LOCATION );
597 // Check font properties.
598 field.SetProperty( TextField::Property::FONT_FAMILY, "Setting font family" );
599 DALI_TEST_EQUALS( field.GetProperty<std::string>( TextField::Property::FONT_FAMILY ), std::string("Setting font family"), TEST_LOCATION );
601 Property::Map fontStyleMapSet;
602 Property::Map fontStyleMapGet;
603 Property::Value* slantValue = NULL;
605 fontStyleMapSet.Insert( "weight", "bold" );
606 fontStyleMapSet.Insert( "width", "condensed" );
607 fontStyleMapSet.Insert( "slant", "italic" );
608 field.SetProperty( TextField::Property::FONT_STYLE, fontStyleMapSet );
610 fontStyleMapGet = field.GetProperty<Property::Map>( TextField::Property::FONT_STYLE );
611 DALI_TEST_EQUALS( fontStyleMapGet.Count(), fontStyleMapSet.Count(), TEST_LOCATION );
612 DALI_TEST_EQUALS( DaliTestCheckMaps( fontStyleMapGet, fontStyleMapSet ), true, TEST_LOCATION );
614 field.SetProperty( TextField::Property::POINT_SIZE, 10.f );
615 DALI_TEST_EQUALS( field.GetProperty<float>( TextField::Property::POINT_SIZE ), 10.f, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
618 fontStyleMapSet.Clear();
619 fontStyleMapSet.Insert( "weight", "normal" );
620 fontStyleMapSet.Insert( "slant", "oblique" );
621 field.SetProperty( TextField::Property::FONT_STYLE, fontStyleMapSet );
623 fontStyleMapGet = field.GetProperty<Property::Map>( TextField::Property::FONT_STYLE );
624 DALI_TEST_EQUALS( fontStyleMapGet.Count(), fontStyleMapSet.Count(), TEST_LOCATION );
625 DALI_TEST_EQUALS( DaliTestCheckMaps( fontStyleMapGet, fontStyleMapSet ), true, TEST_LOCATION );
627 fontStyleMapSet.Clear();
628 fontStyleMapSet.Insert( "slant", "roman" );
629 field.SetProperty( TextField::Property::FONT_STYLE, fontStyleMapSet );
630 fontStyleMapGet = field.GetProperty<Property::Map>( TextField::Property::FONT_STYLE );
632 // Replace 'roman' for 'normal'.
633 slantValue = fontStyleMapGet.Find( "slant" );
634 if( NULL != slantValue )
636 if( "normal" == slantValue->Get<std::string>() )
638 fontStyleMapGet["slant"] = "roman";
641 DALI_TEST_EQUALS( fontStyleMapGet.Count(), fontStyleMapSet.Count(), TEST_LOCATION );
642 DALI_TEST_EQUALS( DaliTestCheckMaps( fontStyleMapGet, fontStyleMapSet ), true, TEST_LOCATION );
644 fontStyleMapSet.Clear();
646 field.SetProperty( TextField::Property::FONT_STYLE, fontStyleMapSet );
647 fontStyleMapGet = field.GetProperty<Property::Map>( TextField::Property::FONT_STYLE );
648 DALI_TEST_EQUALS( fontStyleMapGet.Count(), fontStyleMapSet.Count(), TEST_LOCATION );
649 DALI_TEST_EQUALS( DaliTestCheckMaps( fontStyleMapGet, fontStyleMapSet ), true, TEST_LOCATION );
651 // Check that the MAX_LENGTH property can be correctly set
652 const int maxNumberOfCharacters = 20;
653 field.SetProperty( TextField::Property::MAX_LENGTH, maxNumberOfCharacters );
654 DALI_TEST_EQUALS( field.GetProperty<int>( TextField::Property::MAX_LENGTH ), maxNumberOfCharacters, TEST_LOCATION );
656 // Check exceed policy
657 field.SetProperty( TextField::Property::EXCEED_POLICY, Dali::Toolkit::TextField::EXCEED_POLICY_CLIP );
658 DALI_TEST_EQUALS( field.GetProperty<int>( TextField::Property::EXCEED_POLICY ), static_cast<int>( Dali::Toolkit::TextField::EXCEED_POLICY_CLIP ), TEST_LOCATION );
659 field.SetProperty( TextField::Property::EXCEED_POLICY, Dali::Toolkit::TextField::EXCEED_POLICY_ORIGINAL );
660 DALI_TEST_EQUALS( field.GetProperty<int>( TextField::Property::EXCEED_POLICY ), static_cast<int>( Dali::Toolkit::TextField::EXCEED_POLICY_ORIGINAL ), TEST_LOCATION );
662 // Check that the Alignment properties can be correctly set
663 field.SetProperty( TextField::Property::HORIZONTAL_ALIGNMENT, "END" );
664 DALI_TEST_EQUALS( field.GetProperty<std::string>( TextField::Property::HORIZONTAL_ALIGNMENT ), "END", TEST_LOCATION );
665 field.SetProperty( TextField::Property::VERTICAL_ALIGNMENT, "CENTER" );
666 DALI_TEST_EQUALS( field.GetProperty<std::string>( TextField::Property::VERTICAL_ALIGNMENT ), "CENTER", TEST_LOCATION );
668 // Check text's color property
669 field.SetProperty( TextField::Property::TEXT_COLOR, Color::WHITE );
670 DALI_TEST_EQUALS( field.GetProperty<Vector4>( TextField::Property::TEXT_COLOR ), Color::WHITE, TEST_LOCATION );
672 // Check placeholder text's color property.
673 field.SetProperty( TextField::Property::PLACEHOLDER_TEXT_COLOR, Color::RED );
674 DALI_TEST_EQUALS( field.GetProperty<Vector4>( TextField::Property::PLACEHOLDER_TEXT_COLOR ), Color::RED, TEST_LOCATION );
676 // Check shadow properties.
677 field.SetProperty( TextField::Property::SHADOW_OFFSET, Vector2( 1.f, 1.f ) );
678 DALI_TEST_EQUALS( field.GetProperty<Vector2>( TextField::Property::SHADOW_OFFSET ), Vector2( 1.f, 1.f ), TEST_LOCATION );
679 field.SetProperty( TextField::Property::SHADOW_COLOR, Color::GREEN );
680 DALI_TEST_EQUALS( field.GetProperty<Vector4>( TextField::Property::SHADOW_COLOR ), Color::GREEN, TEST_LOCATION );
682 // Check cursor properties
683 field.SetProperty( TextField::Property::PRIMARY_CURSOR_COLOR, Color::RED );
684 DALI_TEST_EQUALS( field.GetProperty<Vector4>( TextField::Property::PRIMARY_CURSOR_COLOR ), Color::RED, TEST_LOCATION );
685 field.SetProperty( TextField::Property::SECONDARY_CURSOR_COLOR, Color::BLUE );
686 DALI_TEST_EQUALS( field.GetProperty<Vector4>( TextField::Property::SECONDARY_CURSOR_COLOR ), Color::BLUE, TEST_LOCATION );
688 field.SetProperty( TextField::Property::ENABLE_CURSOR_BLINK, false );
689 DALI_TEST_EQUALS( field.GetProperty<bool>( TextField::Property::ENABLE_CURSOR_BLINK ), false, TEST_LOCATION );
690 field.SetProperty( TextField::Property::CURSOR_BLINK_INTERVAL, 1.f );
691 DALI_TEST_EQUALS( field.GetProperty<float>( TextField::Property::CURSOR_BLINK_INTERVAL ), 1.f, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
692 field.SetProperty( TextField::Property::CURSOR_BLINK_DURATION, 10.f );
693 DALI_TEST_EQUALS( field.GetProperty<float>( TextField::Property::CURSOR_BLINK_DURATION ), 10.f, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
694 field.SetProperty( TextField::Property::CURSOR_WIDTH, 1 );
695 DALI_TEST_EQUALS( field.GetProperty<int>( TextField::Property::CURSOR_WIDTH ), 1, TEST_LOCATION );
697 // Check scroll properties.
698 field.SetProperty( TextField::Property::SCROLL_THRESHOLD, 1.f );
699 DALI_TEST_EQUALS( field.GetProperty<float>( TextField::Property::SCROLL_THRESHOLD ), 1.f, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
700 field.SetProperty( TextField::Property::SCROLL_SPEED, 100.f );
701 DALI_TEST_EQUALS( field.GetProperty<float>( TextField::Property::SCROLL_SPEED ), 100.f, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
703 // Check handle images
704 field.SetProperty( TextField::Property::GRAB_HANDLE_IMAGE, "image1" );
705 DALI_TEST_EQUALS( field.GetProperty<std::string>( TextField::Property::GRAB_HANDLE_IMAGE ), "image1", TEST_LOCATION );
706 field.SetProperty( TextField::Property::GRAB_HANDLE_PRESSED_IMAGE, "image2" );
707 DALI_TEST_EQUALS( field.GetProperty<std::string>( TextField::Property::GRAB_HANDLE_PRESSED_IMAGE ), "image2", TEST_LOCATION );
708 field.SetProperty( TextField::Property::SELECTION_HANDLE_IMAGE_LEFT, "image3" );
710 // Check handle images
711 DALI_TEST_CHECK( SetPropertyMapRetrieved( field, TextField::Property::SELECTION_HANDLE_IMAGE_LEFT, "filename", "leftHandleImage" ) );
712 DALI_TEST_CHECK( SetPropertyMapRetrieved( field, TextField::Property::SELECTION_HANDLE_IMAGE_RIGHT, "filename", "rightHandleImage" ) );
713 DALI_TEST_CHECK( SetPropertyMapRetrieved( field, TextField::Property::SELECTION_HANDLE_PRESSED_IMAGE_LEFT, "filename", "leftHandleImagePressed" ) );
714 DALI_TEST_CHECK( SetPropertyMapRetrieved( field, TextField::Property::SELECTION_HANDLE_PRESSED_IMAGE_RIGHT, "filename", "rightHandleImagePressed" ) );
715 DALI_TEST_CHECK( SetPropertyMapRetrieved( field, TextField::Property::SELECTION_HANDLE_MARKER_IMAGE_LEFT, "filename", "leftHandleMarkerImage" ) );
716 DALI_TEST_CHECK( SetPropertyMapRetrieved( field, TextField::Property::SELECTION_HANDLE_MARKER_IMAGE_RIGHT, "filename", "rightHandleMarkerImage" ) );
718 // Check the highlight color
719 field.SetProperty( TextField::Property::SELECTION_HIGHLIGHT_COLOR, Color::GREEN );
720 DALI_TEST_EQUALS( field.GetProperty<Vector4>( TextField::Property::SELECTION_HIGHLIGHT_COLOR ), Color::GREEN, TEST_LOCATION );
722 // Decoration bounding box
723 field.SetProperty( TextField::Property::DECORATION_BOUNDING_BOX, Rect<int>( 0, 0, 1, 1 ) );
724 DALI_TEST_EQUALS( field.GetProperty<Rect <int > >( TextField::Property::DECORATION_BOUNDING_BOX ), Rect<int>( 0, 0, 1, 1 ), TEST_LOCATION );
726 // Check the input method setting
727 Property::Map propertyMap;
728 InputMethod::PanelLayout::Type panelLayout = InputMethod::PanelLayout::NUMBER;
729 InputMethod::AutoCapital::Type autoCapital = InputMethod::AutoCapital::WORD;
730 InputMethod::ActionButtonTitle::Type actionButton = InputMethod::ActionButtonTitle::GO;
731 int inputVariation = 1;
732 propertyMap["PANEL_LAYOUT"] = panelLayout;
733 propertyMap["AUTO_CAPITALISE"] = autoCapital;
734 propertyMap["ACTION_BUTTON"] = actionButton;
735 propertyMap["VARIATION"] = inputVariation;
736 field.SetProperty( TextField::Property::INPUT_METHOD_SETTINGS, propertyMap );
738 Property::Value value = field.GetProperty( TextField::Property::INPUT_METHOD_SETTINGS );
740 DALI_TEST_CHECK( value.Get( map ) );
743 DALI_TEST_CHECK( map[ "PANEL_LAYOUT" ].Get( layout ) );
744 DALI_TEST_EQUALS( static_cast<int>(panelLayout), layout, TEST_LOCATION );
747 DALI_TEST_CHECK( map[ "AUTO_CAPITALISE" ].Get( capital ) );
748 DALI_TEST_EQUALS( static_cast<int>(autoCapital), capital, TEST_LOCATION );
751 DALI_TEST_CHECK( map[ "ACTION_BUTTON" ].Get( action ) );
752 DALI_TEST_EQUALS( static_cast<int>(actionButton), action, TEST_LOCATION );
755 DALI_TEST_CHECK( map[ "VARIATION" ].Get( variation ) );
756 DALI_TEST_EQUALS( inputVariation, variation, TEST_LOCATION );
758 // Check input color property.
759 field.SetProperty( TextField::Property::INPUT_COLOR, Color::YELLOW );
760 DALI_TEST_EQUALS( field.GetProperty<Vector4>( TextField::Property::INPUT_COLOR ), Color::YELLOW, TEST_LOCATION );
762 // Check the enable markup property.
763 DALI_TEST_CHECK( !field.GetProperty<bool>( TextField::Property::ENABLE_MARKUP ) );
764 field.SetProperty( TextField::Property::ENABLE_MARKUP, true );
765 DALI_TEST_CHECK( field.GetProperty<bool>( TextField::Property::ENABLE_MARKUP ) );
767 // Check input font properties.
768 field.SetProperty( TextField::Property::INPUT_FONT_FAMILY, "Setting input font family" );
769 DALI_TEST_EQUALS( field.GetProperty<std::string>( TextField::Property::INPUT_FONT_FAMILY ), "Setting input font family", TEST_LOCATION );
771 fontStyleMapSet.Clear();
772 fontStyleMapSet.Insert( "weight", "bold" );
773 fontStyleMapSet.Insert( "width", "condensed" );
774 fontStyleMapSet.Insert( "slant", "italic" );
776 field.SetProperty( TextField::Property::INPUT_FONT_STYLE, fontStyleMapSet );
777 fontStyleMapGet = field.GetProperty<Property::Map>( TextField::Property::INPUT_FONT_STYLE );
778 DALI_TEST_EQUALS( fontStyleMapGet.Count(), fontStyleMapSet.Count(), TEST_LOCATION );
779 DALI_TEST_EQUALS( DaliTestCheckMaps( fontStyleMapGet, fontStyleMapSet ), true, TEST_LOCATION );
781 field.SetProperty( TextField::Property::INPUT_POINT_SIZE, 12.f );
782 DALI_TEST_EQUALS( field.GetProperty<float>( TextField::Property::INPUT_POINT_SIZE ), 12.f, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
784 // Reset input font style.
785 fontStyleMapSet.Clear();
786 fontStyleMapSet.Insert( "weight", "normal" );
787 fontStyleMapSet.Insert( "slant", "oblique" );
789 field.SetProperty( TextField::Property::INPUT_FONT_STYLE, fontStyleMapSet );
790 fontStyleMapGet = field.GetProperty<Property::Map>( TextField::Property::INPUT_FONT_STYLE );
791 DALI_TEST_EQUALS( fontStyleMapGet.Count(), fontStyleMapSet.Count(), TEST_LOCATION );
792 DALI_TEST_EQUALS( DaliTestCheckMaps( fontStyleMapGet, fontStyleMapSet ), true, TEST_LOCATION );
794 fontStyleMapSet.Clear();
795 fontStyleMapSet.Insert( "slant", "roman" );
797 field.SetProperty( TextField::Property::INPUT_FONT_STYLE, fontStyleMapSet );
798 fontStyleMapGet = field.GetProperty<Property::Map>( TextField::Property::INPUT_FONT_STYLE );
800 // Replace 'roman' for 'normal'.
801 slantValue = fontStyleMapGet.Find( "slant" );
802 if( NULL != slantValue )
804 if( "normal" == slantValue->Get<std::string>() )
806 fontStyleMapGet["slant"] = "roman";
809 DALI_TEST_EQUALS( fontStyleMapGet.Count(), fontStyleMapSet.Count(), TEST_LOCATION );
810 DALI_TEST_EQUALS( DaliTestCheckMaps( fontStyleMapGet, fontStyleMapSet ), true, TEST_LOCATION );
812 fontStyleMapSet.Clear();
814 field.SetProperty( TextField::Property::INPUT_FONT_STYLE, fontStyleMapSet );
815 fontStyleMapGet = field.GetProperty<Property::Map>( TextField::Property::INPUT_FONT_STYLE );
816 DALI_TEST_EQUALS( fontStyleMapGet.Count(), fontStyleMapSet.Count(), TEST_LOCATION );
817 DALI_TEST_EQUALS( DaliTestCheckMaps( fontStyleMapGet, fontStyleMapSet ), true, TEST_LOCATION );
819 Property::Map underlineMapSet;
820 Property::Map underlineMapGet;
822 underlineMapSet.Insert( "enable", "true" );
823 underlineMapSet.Insert( "color", "red" );
824 underlineMapSet.Insert( "height", "1" );
826 // Check the underline property
827 field.SetProperty( TextField::Property::UNDERLINE, underlineMapSet );
829 underlineMapGet = field.GetProperty<Property::Map>( TextField::Property::UNDERLINE );
830 DALI_TEST_EQUALS( underlineMapGet.Count(), underlineMapSet.Count(), TEST_LOCATION );
831 DALI_TEST_EQUALS( DaliTestCheckMaps( underlineMapGet, underlineMapSet ), true, TEST_LOCATION );
833 // Check the input underline property
834 field.SetProperty( TextField::Property::INPUT_UNDERLINE, "Underline input properties" );
835 DALI_TEST_EQUALS( field.GetProperty<std::string>( TextField::Property::INPUT_UNDERLINE ), std::string("Underline input properties"), TEST_LOCATION );
837 // Check the shadow property
838 Property::Map shadowMapSet;
839 Property::Map shadowMapGet;
841 shadowMapSet.Insert( "color", Color::GREEN );
842 shadowMapSet.Insert( "offset", Vector2(2.0f, 2.0f) );
843 shadowMapSet.Insert( "blurRadius", 3.0f );
845 field.SetProperty( TextField::Property::SHADOW, shadowMapSet );
847 shadowMapGet = field.GetProperty<Property::Map>( TextField::Property::SHADOW );
848 DALI_TEST_EQUALS( shadowMapGet.Count(), shadowMapSet.Count(), TEST_LOCATION );
849 DALI_TEST_EQUALS( DaliTestCheckMaps( shadowMapGet, shadowMapSet ), true, TEST_LOCATION );
851 // Check the input shadow property
852 field.SetProperty( TextField::Property::INPUT_SHADOW, "Shadow input properties" );
853 DALI_TEST_EQUALS( field.GetProperty<std::string>( TextField::Property::INPUT_SHADOW ), std::string("Shadow input properties"), TEST_LOCATION );
855 // Check the emboss property
856 field.SetProperty( TextField::Property::EMBOSS, "Emboss properties" );
857 DALI_TEST_EQUALS( field.GetProperty<std::string>( TextField::Property::EMBOSS ), std::string("Emboss properties"), TEST_LOCATION );
859 // Check the input emboss property
860 field.SetProperty( TextField::Property::INPUT_EMBOSS, "Emboss input properties" );
861 DALI_TEST_EQUALS( field.GetProperty<std::string>( TextField::Property::INPUT_EMBOSS ), std::string("Emboss input properties"), TEST_LOCATION );
863 // Check the outline property
865 // Test string type first
866 // This is purely to maintain backward compatibility, but we don't support string as the outline property type.
867 field.SetProperty( TextField::Property::OUTLINE, "Outline properties" );
868 DALI_TEST_EQUALS( field.GetProperty<std::string>( TextField::Property::OUTLINE ), std::string("Outline properties"), TEST_LOCATION );
870 // Then test the property map type
871 Property::Map outlineMapSet;
872 Property::Map outlineMapGet;
874 outlineMapSet["color"] = Color::RED;
875 outlineMapSet["width"] = 2.0f;
877 field.SetProperty( TextField::Property::OUTLINE, outlineMapSet );
879 outlineMapGet = field.GetProperty<Property::Map>( TextField::Property::OUTLINE );
880 DALI_TEST_EQUALS( outlineMapGet.Count(), outlineMapSet.Count(), TEST_LOCATION );
881 DALI_TEST_EQUALS( DaliTestCheckMaps( outlineMapGet, outlineMapSet ), true, TEST_LOCATION );
883 // Check the input outline property
884 field.SetProperty( TextField::Property::INPUT_OUTLINE, "Outline input properties" );
885 DALI_TEST_EQUALS( field.GetProperty<std::string>( TextField::Property::INPUT_OUTLINE ), std::string("Outline input properties"), TEST_LOCATION );
887 // Check the hidden input settings property
888 Property::Map hiddenMapSet;
889 Property::Map hiddenMapGet;
890 hiddenMapSet[ HiddenInput::Property::MODE ] = HiddenInput::Mode::HIDE_ALL;
891 hiddenMapSet[ HiddenInput::Property::SHOW_LAST_CHARACTER_DURATION ] = 2;
892 hiddenMapSet[ HiddenInput::Property::SUBSTITUTE_COUNT ] = 4;
893 hiddenMapSet[ HiddenInput::Property::SUBSTITUTE_CHARACTER ] = 0x23;
894 field.SetProperty( TextField::Property::HIDDEN_INPUT_SETTINGS, hiddenMapSet );
896 hiddenMapGet = field.GetProperty<Property::Map>( TextField::Property::HIDDEN_INPUT_SETTINGS );
897 DALI_TEST_EQUALS( hiddenMapSet.Count(), hiddenMapGet.Count(), TEST_LOCATION );
898 DALI_TEST_EQUALS( DaliTestCheckMaps( hiddenMapSet, hiddenMapGet ), true, TEST_LOCATION );
900 // Check the pixel size of font
901 field.SetProperty( TextField::Property::PIXEL_SIZE, 20.f );
902 DALI_TEST_EQUALS( field.GetProperty<float>( TextField::Property::PIXEL_SIZE ), 20.f, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
904 // Check the enable selection property
905 field.SetProperty( TextField::Property::ENABLE_SELECTION, false );
906 DALI_TEST_EQUALS( field.GetProperty<bool>( TextField::Property::ENABLE_SELECTION ), false, TEST_LOCATION );
908 // Check the placeholder property with pixel size
909 Property::Map placeholderPixelSizeMapSet;
910 Property::Map placeholderPixelSizeMapGet;
911 Property::Map placeholderFontstyleMap;
912 placeholderPixelSizeMapSet["text"] = "Setting Placeholder Text";
913 placeholderPixelSizeMapSet["textFocused"] = "Setting Placeholder Text Focused";
914 placeholderPixelSizeMapSet["color"] = Color::BLUE;
915 placeholderPixelSizeMapSet["fontFamily"] = "Arial";
916 placeholderPixelSizeMapSet["pixelSize"] = 15.0f;
917 placeholderPixelSizeMapSet["ellipsis"] = true;
919 placeholderFontstyleMap.Insert( "weight", "bold" );
920 placeholderPixelSizeMapSet["placeholderFontStyle"] = placeholderFontstyleMap;
921 field.SetProperty( TextField::Property::PLACEHOLDER, placeholderPixelSizeMapSet );
923 placeholderPixelSizeMapGet = field.GetProperty<Property::Map>( TextField::Property::PLACEHOLDER );
924 DALI_TEST_EQUALS( placeholderPixelSizeMapGet.Count(), placeholderPixelSizeMapSet.Count(), TEST_LOCATION );
926 tet_infoline("Test Placeholder settings set as strings is converted correctly to Property Index key and holds set value");
927 Property::Map placeholderConversionMap;
928 placeholderConversionMap[ Text::PlaceHolder::Property::TEXT ] = placeholderPixelSizeMapSet["text"];
929 placeholderConversionMap[ Text::PlaceHolder::Property::TEXT_FOCUSED ] = placeholderPixelSizeMapSet["textFocused"] ;
930 placeholderConversionMap[ Text::PlaceHolder::Property::COLOR ] = placeholderPixelSizeMapSet["color"];
931 placeholderConversionMap[ Text::PlaceHolder::Property::FONT_STYLE ] = placeholderPixelSizeMapSet["fontStyle"];
932 placeholderConversionMap[ Text::PlaceHolder::Property::FONT_FAMILY ] = placeholderPixelSizeMapSet["fontFamily"];
933 placeholderConversionMap[ Text::PlaceHolder::Property::PIXEL_SIZE ] = placeholderPixelSizeMapSet["pixelSize"];
935 DALI_TEST_EQUALS( DaliTestCheckMaps( placeholderPixelSizeMapGet, placeholderConversionMap ), true, TEST_LOCATION );
937 // Check the placeholder property with point size
938 Property::Map placeholderMapSet;
939 Property::Map placeholderMapGet;
940 placeholderMapSet["text"] = "Setting Placeholder Text";
941 placeholderMapSet["textFocused"] = "Setting Placeholder Text Focused";
942 placeholderMapSet["color"] = Color::RED;
943 placeholderMapSet["fontFamily"] = "Arial";
944 placeholderMapSet["pointSize"] = 12.0f;
945 placeholderMapSet["ellipsis"] = false;
947 // Check the placeholder font style property
948 placeholderFontstyleMap.Clear();
950 placeholderFontstyleMap.Insert( "weight", "bold" );
951 placeholderFontstyleMap.Insert( "width", "condensed" );
952 placeholderFontstyleMap.Insert( "slant", "italic" );
953 placeholderMapSet["fontStyle"] = placeholderFontstyleMap;
954 field.SetProperty( TextField::Property::PLACEHOLDER, placeholderMapSet );
956 placeholderMapGet = field.GetProperty<Property::Map>( TextField::Property::PLACEHOLDER );
957 DALI_TEST_EQUALS( placeholderMapGet.Count(), placeholderMapSet.Count(), TEST_LOCATION );
959 placeholderConversionMap.Clear();
960 placeholderConversionMap[ Text::PlaceHolder::Property::TEXT ] = placeholderPixelSizeMapSet["text"];
961 placeholderConversionMap[ Text::PlaceHolder::Property::TEXT_FOCUSED ] = placeholderPixelSizeMapSet["textFocused"] ;
962 placeholderConversionMap[ Text::PlaceHolder::Property::COLOR ] = placeholderPixelSizeMapSet["color"];
963 placeholderConversionMap[ Text::PlaceHolder::Property::FONT_STYLE ] = placeholderPixelSizeMapSet["fontStyle"];
964 placeholderConversionMap[ Text::PlaceHolder::Property::FONT_FAMILY ] = placeholderPixelSizeMapSet["fontFamily"];
965 placeholderConversionMap[ Text::PlaceHolder::Property::POINT_SIZE ] = placeholderPixelSizeMapSet["pointSize"];
967 DALI_TEST_EQUALS( DaliTestCheckMaps( placeholderMapGet, placeholderConversionMap ), true, TEST_LOCATION );
970 placeholderFontstyleMap.Clear();
971 placeholderFontstyleMap.Insert( "weight", "normal" );
972 placeholderFontstyleMap.Insert( "slant", "oblique" );
973 placeholderMapSet["fontStyle"] = placeholderFontstyleMap;
974 field.SetProperty( TextField::Property::PLACEHOLDER, placeholderMapSet );
976 placeholderMapGet = field.GetProperty<Property::Map>( TextField::Property::PLACEHOLDER );
977 DALI_TEST_EQUALS( placeholderMapGet.Count(), placeholderMapSet.Count(), TEST_LOCATION );
979 placeholderConversionMap[ Text::PlaceHolder::Property::FONT_STYLE ] = placeholderPixelSizeMapSet["fontStyle"];
980 DALI_TEST_EQUALS( DaliTestCheckMaps( placeholderMapGet, placeholderConversionMap ), true, TEST_LOCATION );
982 placeholderFontstyleMap.Clear();
983 placeholderFontstyleMap.Insert( "slant", "roman" );
984 placeholderMapSet["fontStyle"] = placeholderFontstyleMap;
985 placeholderConversionMap[ Text::PlaceHolder::Property::FONT_STYLE ] = placeholderPixelSizeMapSet["fontStyle"];
987 field.SetProperty( TextField::Property::PLACEHOLDER, placeholderMapSet );
989 placeholderMapGet = field.GetProperty<Property::Map>( TextField::Property::PLACEHOLDER );
991 placeholderFontstyleMap.Clear();
992 placeholderMapSet["fontStyle"] = placeholderFontstyleMap;
993 placeholderConversionMap[ Text::PlaceHolder::Property::FONT_STYLE ] = placeholderPixelSizeMapSet["fontStyle"];
995 field.SetProperty( TextField::Property::PLACEHOLDER, placeholderMapSet );
996 placeholderMapGet = field.GetProperty<Property::Map>( TextField::Property::PLACEHOLDER );
997 DALI_TEST_EQUALS( placeholderMapGet.Count(), placeholderMapSet.Count(), TEST_LOCATION );
999 DALI_TEST_EQUALS( DaliTestCheckMaps( placeholderMapGet, placeholderConversionMap ), true, TEST_LOCATION );
1001 // Check the ellipsis property
1002 DALI_TEST_CHECK( !field.GetProperty<bool>( TextField::Property::ELLIPSIS ) );
1003 field.SetProperty( TextField::Property::ELLIPSIS, true );
1004 DALI_TEST_CHECK( field.GetProperty<bool>( TextField::Property::ELLIPSIS ) );
1006 field.SetProperty( Actor::Property::LAYOUT_DIRECTION, LayoutDirection::RIGHT_TO_LEFT );
1007 DALI_TEST_EQUALS( field.GetProperty<int>( Actor::Property::LAYOUT_DIRECTION ), static_cast<int>( LayoutDirection::RIGHT_TO_LEFT ), TEST_LOCATION );
1009 application.SendNotification();
1010 application.Render();
1015 // Positive Atlas Text Renderer test
1016 int utcDaliTextFieldAtlasRenderP(void)
1018 ToolkitTestApplication application;
1019 tet_infoline(" UtcDaliToolkitTextFieldAtlasRenderP");
1020 StyleManager styleManager = StyleManager::Get();
1021 styleManager.ApplyDefaultTheme();
1022 TextField field = TextField::New();
1023 DALI_TEST_CHECK( field );
1025 field.SetProperty( TextField::Property::HORIZONTAL_ALIGNMENT, "CENTER" );
1027 application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
1029 Stage::GetCurrent().Add( field );
1033 // Render some text with the shared atlas backend
1034 field.SetProperty( TextField::Property::RENDERING_BACKEND, Text::RENDERING_SHARED_ATLAS );
1035 application.SendNotification();
1036 application.Render();
1040 tet_result(TET_FAIL);
1045 // Positive test for the textChanged signal.
1046 int utcDaliTextFieldTextChangedP(void)
1048 ToolkitTestApplication application;
1049 tet_infoline(" utcDaliTextFieldTextChangedP");
1050 TextField field = TextField::New();
1051 DALI_TEST_CHECK( field );
1053 Stage::GetCurrent().Add( field );
1055 // connect to the text changed signal.
1056 ConnectionTracker* testTracker = new ConnectionTracker();
1057 field.TextChangedSignal().Connect(&TestTextChangedCallback);
1058 bool textChangedSignal = false;
1059 field.ConnectSignal( testTracker, "textChanged", CallbackFunctor(&textChangedSignal) );
1061 gTextChangedCallBackCalled = false;
1062 field.SetProperty( TextField::Property::TEXT, "ABC" );
1063 DALI_TEST_CHECK( gTextChangedCallBackCalled );
1064 DALI_TEST_CHECK( textChangedSignal );
1066 application.SendNotification();
1068 field.SetKeyInputFocus();
1070 gTextChangedCallBackCalled = false;
1071 application.ProcessEvent( GenerateKey( "D", "D", KEY_D_CODE, 0, 0, Integration::KeyEvent::Down, DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
1072 DALI_TEST_CHECK( gTextChangedCallBackCalled );
1077 // Negative test for the textChanged signal.
1078 int utcDaliTextFieldTextChangedN(void)
1080 ToolkitTestApplication application;
1081 tet_infoline(" utcDaliTextFieldTextChangedN");
1082 TextField field = TextField::New();
1083 DALI_TEST_CHECK( field );
1085 Stage::GetCurrent().Add( field );
1087 // connect to the text changed signal.
1088 ConnectionTracker* testTracker = new ConnectionTracker();
1089 field.TextChangedSignal().Connect(&TestTextChangedCallback);
1090 bool textChangedSignal = false;
1091 field.ConnectSignal( testTracker, "textChanged", CallbackFunctor(&textChangedSignal) );
1093 gTextChangedCallBackCalled = false;
1094 field.SetProperty( TextField::Property::PLACEHOLDER_TEXT, "ABC" ); // Setting placeholder, not TEXT
1095 DALI_TEST_CHECK( !gTextChangedCallBackCalled );
1096 DALI_TEST_CHECK( !textChangedSignal );
1101 // Positive test for Max Characters reached signal.
1102 int utcDaliTextFieldMaxCharactersReachedP(void)
1104 ToolkitTestApplication application;
1105 tet_infoline(" utcDaliTextFieldMaxCharactersReachedP");
1106 TextField field = TextField::New();
1107 DALI_TEST_CHECK( field );
1109 Stage::GetCurrent().Add( field );
1111 const int maxNumberOfCharacters = 1;
1112 field.SetProperty( TextField::Property::MAX_LENGTH, maxNumberOfCharacters );
1114 field.SetKeyInputFocus();
1116 // connect to the text changed signal.
1117 ConnectionTracker* testTracker = new ConnectionTracker();
1118 field.MaxLengthReachedSignal().Connect(&TestMaxLengthReachedCallback);
1119 bool maxLengthReachedSignal = false;
1120 field.ConnectSignal( testTracker, "maxLengthReached", CallbackFunctor(&maxLengthReachedSignal) );
1122 gMaxCharactersCallBackCalled = false;
1124 application.ProcessEvent( GenerateKey( "a", "a", KEY_A_CODE, 0, 0, Integration::KeyEvent::Down, DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
1125 application.ProcessEvent( GenerateKey( "a", "a", KEY_A_CODE, 0, 0, Integration::KeyEvent::Down, DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
1127 DALI_TEST_CHECK( gMaxCharactersCallBackCalled );
1128 DALI_TEST_CHECK( maxLengthReachedSignal );
1133 // Negative test for Max Characters reached signal.
1134 int utcDaliTextFieldMaxCharactersReachedN(void)
1136 ToolkitTestApplication application;
1137 tet_infoline(" utcDaliTextFieldMaxCharactersReachedN");
1138 TextField field = TextField::New();
1139 DALI_TEST_CHECK( field );
1141 Stage::GetCurrent().Add( field );
1143 const int maxNumberOfCharacters = 3;
1144 field.SetProperty( TextField::Property::MAX_LENGTH, maxNumberOfCharacters );
1146 field.SetKeyInputFocus();
1148 // connect to the text changed signal.
1149 ConnectionTracker* testTracker = new ConnectionTracker();
1150 field.MaxLengthReachedSignal().Connect(&TestMaxLengthReachedCallback);
1151 bool maxLengthReachedSignal = false;
1152 field.ConnectSignal( testTracker, "maxLengthReached", CallbackFunctor(&maxLengthReachedSignal) );
1154 gMaxCharactersCallBackCalled = false;
1156 application.ProcessEvent( GenerateKey( "a", "a", KEY_A_CODE, 0, 0, Integration::KeyEvent::Down, DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
1157 application.ProcessEvent( GenerateKey( "a", "a", KEY_A_CODE, 0, 0, Integration::KeyEvent::Down, DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
1159 DALI_TEST_CHECK( !gMaxCharactersCallBackCalled );
1160 DALI_TEST_CHECK( !maxLengthReachedSignal );
1162 application.ProcessEvent( GenerateKey( "Return", "\r", KEY_RETURN_CODE, 0, 0, Integration::KeyEvent::Down, DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
1164 DALI_TEST_CHECK( !gMaxCharactersCallBackCalled );
1165 DALI_TEST_CHECK( !maxLengthReachedSignal );
1170 int utcDaliTextFieldInputStyleChanged01(void)
1172 ToolkitTestApplication application;
1173 tet_infoline(" utcDaliTextFieldInputStyleChanged01");
1175 // The text-field emits signals when the input style changes. These changes of style are
1176 // detected during the relayout process (size negotiation), i.e after the cursor has been moved. Signals
1177 // can't be emitted during the size negotiation as the callbacks may update the UI.
1178 // The text-field adds an idle callback to the adaptor to emit the signals after the size negotiation.
1179 // This creates an implementation of the adaptor stub and a queue of idle callbacks.
1180 application.CreateAdaptor();
1184 char* pathNamePtr = get_current_dir_name();
1185 const std::string pathName( pathNamePtr );
1186 free( pathNamePtr );
1188 TextAbstraction::FontClient fontClient = TextAbstraction::FontClient::Get();
1189 fontClient.SetDpi( 93u, 93u );
1191 fontClient.GetFontId( pathName + DEFAULT_FONT_DIR + "/dejavu/DejaVuSerif.ttf", DEFAULT_FONT_SIZE );
1192 fontClient.GetFontId( pathName + DEFAULT_FONT_DIR + "/dejavu/DejaVuSerif-Bold.ttf", DEFAULT_FONT_SIZE );
1194 TextField field = TextField::New();
1195 DALI_TEST_CHECK( field );
1198 field.SetSize( 300.f, 50.f );
1199 field.SetParentOrigin( ParentOrigin::TOP_LEFT );
1200 field.SetAnchorPoint( AnchorPoint::TOP_LEFT );
1202 field.SetProperty( TextField::Property::ENABLE_MARKUP, true );
1203 field.SetProperty( TextField::Property::TEXT, "<font family='DejaVuSerif' size='18'>He<color value='green'>llo</color> <font weight='bold'>world</font> demo</font>" );
1205 // connect to the text changed signal.
1206 ConnectionTracker* testTracker = new ConnectionTracker();
1207 field.InputStyleChangedSignal().Connect( &TestInputStyleChangedCallback );
1208 bool inputStyleChangedSignal = false;
1209 field.ConnectSignal( testTracker, "inputStyleChanged", CallbackFunctor(&inputStyleChangedSignal) );
1211 Stage::GetCurrent().Add( field );
1213 // Render and notify
1214 application.SendNotification();
1215 application.Render();
1217 // Executes the idle callbacks added by the text control on the change of input style.
1218 application.RunIdles();
1220 gInputStyleChangedCallbackCalled = false;
1221 gInputStyleMask = TextField::InputStyle::NONE;
1222 inputStyleChangedSignal = false;
1224 // Create a tap event to touch the text field.
1225 application.ProcessEvent( GenerateTap( Gesture::Possible, 1u, 1u, Vector2( 18.f, 25.f ) ) );
1226 application.ProcessEvent( GenerateTap( Gesture::Started, 1u, 1u, Vector2( 18.f, 25.f ) ) );
1228 // Render and notify
1229 application.SendNotification();
1230 application.Render();
1232 // Executes the idle callbacks added by the text control on the change of input style.
1233 application.RunIdles();
1235 DALI_TEST_CHECK( gInputStyleChangedCallbackCalled );
1236 if( gInputStyleChangedCallbackCalled )
1238 DALI_TEST_EQUALS( static_cast<unsigned int>( gInputStyleMask ), static_cast<unsigned int>( TextField::InputStyle::FONT_FAMILY | TextField::InputStyle::POINT_SIZE ), TEST_LOCATION );
1240 const std::string fontFamily = field.GetProperty( TextField::Property::INPUT_FONT_FAMILY ).Get<std::string>();
1241 DALI_TEST_EQUALS( fontFamily, "DejaVuSerif", TEST_LOCATION );
1243 const float pointSize = field.GetProperty( TextField::Property::INPUT_POINT_SIZE ).Get<float>();
1244 DALI_TEST_EQUALS( pointSize, 18.f, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
1246 DALI_TEST_CHECK( inputStyleChangedSignal );
1248 gInputStyleChangedCallbackCalled = false;
1249 gInputStyleMask = TextField::InputStyle::NONE;
1250 inputStyleChangedSignal = false;
1252 // Create a tap event to touch the text field.
1253 application.ProcessEvent( GenerateTap( Gesture::Possible, 1u, 1u, Vector2( 30.f, 25.f ) ) );
1254 application.ProcessEvent( GenerateTap( Gesture::Started, 1u, 1u, Vector2( 30.f, 25.f ) ) );
1256 // Render and notify
1257 application.SendNotification();
1258 application.Render();
1260 // Executes the idle callbacks added by the text control on the change of input style.
1261 application.RunIdles();
1263 DALI_TEST_CHECK( !gInputStyleChangedCallbackCalled );
1264 DALI_TEST_CHECK( !inputStyleChangedSignal );
1266 gInputStyleChangedCallbackCalled = false;
1267 gInputStyleMask = TextField::InputStyle::NONE;
1268 inputStyleChangedSignal = false;
1270 // Create a tap event to touch the text field.
1271 application.ProcessEvent( GenerateTap( Gesture::Possible, 1u, 1u, Vector2( 43.f, 25.f ) ) );
1272 application.ProcessEvent( GenerateTap( Gesture::Started, 1u, 1u, Vector2( 43.f, 25.f ) ) );
1274 // Render and notify
1275 application.SendNotification();
1276 application.Render();
1278 // Executes the idle callbacks added by the text control on the change of input style.
1279 application.RunIdles();
1281 DALI_TEST_CHECK( gInputStyleChangedCallbackCalled );
1282 if( gInputStyleChangedCallbackCalled )
1284 DALI_TEST_EQUALS( static_cast<unsigned int>( gInputStyleMask ), static_cast<unsigned int>( TextField::InputStyle::COLOR ), TEST_LOCATION );
1286 const Vector4 color = field.GetProperty( TextField::Property::INPUT_COLOR ).Get<Vector4>();
1287 DALI_TEST_EQUALS( color, Color::GREEN, TEST_LOCATION );
1289 DALI_TEST_CHECK( inputStyleChangedSignal );
1291 gInputStyleChangedCallbackCalled = false;
1292 gInputStyleMask = TextField::InputStyle::NONE;
1293 inputStyleChangedSignal = false;
1295 // Create a tap event to touch the text field.
1296 application.ProcessEvent( GenerateTap( Gesture::Possible, 1u, 1u, Vector2( 88.f, 25.f ) ) );
1297 application.ProcessEvent( GenerateTap( Gesture::Started, 1u, 1u, Vector2( 88.f, 25.f ) ) );
1299 // Render and notify
1300 application.SendNotification();
1301 application.Render();
1303 // Executes the idle callbacks added by the text control on the change of input style.
1304 application.RunIdles();
1306 DALI_TEST_CHECK( gInputStyleChangedCallbackCalled );
1307 if( gInputStyleChangedCallbackCalled )
1309 DALI_TEST_EQUALS( static_cast<unsigned int>( gInputStyleMask ), static_cast<unsigned int>( TextField::InputStyle::COLOR | TextField::InputStyle::FONT_STYLE ), TEST_LOCATION );
1311 const Vector4 color = field.GetProperty( TextField::Property::INPUT_COLOR ).Get<Vector4>();
1312 DALI_TEST_EQUALS( color, Color::BLACK, TEST_LOCATION );
1314 const Property::Map fontStyleMapGet = field.GetProperty( TextField::Property::INPUT_FONT_STYLE ).Get<Property::Map>();
1316 Property::Map fontStyleMapSet;
1317 fontStyleMapSet.Insert( "weight", "bold" );
1319 DALI_TEST_EQUALS( fontStyleMapGet.Count(), fontStyleMapSet.Count(), TEST_LOCATION );
1320 DALI_TEST_EQUALS( DaliTestCheckMaps( fontStyleMapGet, fontStyleMapSet ), true, TEST_LOCATION );
1322 DALI_TEST_CHECK( inputStyleChangedSignal );
1324 gInputStyleChangedCallbackCalled = false;
1325 gInputStyleMask = TextField::InputStyle::NONE;
1326 inputStyleChangedSignal = false;
1328 // Create a tap event to touch the text field.
1329 application.ProcessEvent( GenerateTap( Gesture::Possible, 1u, 1u, Vector2( 115.f, 25.f ) ) );
1330 application.ProcessEvent( GenerateTap( Gesture::Started, 1u, 1u, Vector2( 115.f, 25.f ) ) );
1332 // Render and notify
1333 application.SendNotification();
1334 application.Render();
1336 // Executes the idle callbacks added by the text control on the change of input style.
1337 application.RunIdles();
1339 DALI_TEST_CHECK( !gInputStyleChangedCallbackCalled );
1340 DALI_TEST_CHECK( !inputStyleChangedSignal );
1342 gInputStyleChangedCallbackCalled = false;
1343 gInputStyleMask = TextField::InputStyle::NONE;
1344 inputStyleChangedSignal = false;
1346 // Create a tap event to touch the text field.
1347 application.ProcessEvent( GenerateTap( Gesture::Possible, 1u, 1u, Vector2( 164.f, 25.f ) ) );
1348 application.ProcessEvent( GenerateTap( Gesture::Started, 1u, 1u, Vector2( 164.f, 25.f ) ) );
1350 // Render and notify
1351 application.SendNotification();
1352 application.Render();
1354 // Executes the idle callbacks added by the text control on the change of input style.
1355 application.RunIdles();
1357 DALI_TEST_CHECK( gInputStyleChangedCallbackCalled );
1358 if( gInputStyleChangedCallbackCalled )
1360 DALI_TEST_EQUALS( static_cast<unsigned int>( gInputStyleMask ), static_cast<unsigned int>( TextField::InputStyle::FONT_STYLE ), TEST_LOCATION );
1362 const std::string style = field.GetProperty( TextField::Property::INPUT_FONT_STYLE ).Get<std::string>();
1363 DALI_TEST_CHECK( style.empty() );
1365 DALI_TEST_CHECK( inputStyleChangedSignal );
1367 gInputStyleChangedCallbackCalled = false;
1368 gInputStyleMask = TextField::InputStyle::NONE;
1369 inputStyleChangedSignal = false;
1371 // Create a tap event to touch the text field.
1372 application.ProcessEvent( GenerateTap( Gesture::Possible, 1u, 1u, Vector2( 191.f, 25.f ) ) );
1373 application.ProcessEvent( GenerateTap( Gesture::Started, 1u, 1u, Vector2( 191.f, 25.f ) ) );
1375 // Render and notify
1376 application.SendNotification();
1377 application.Render();
1379 // Executes the idle callbacks added by the text control on the change of input style.
1380 application.RunIdles();
1382 DALI_TEST_CHECK( !gInputStyleChangedCallbackCalled );
1383 DALI_TEST_CHECK( !inputStyleChangedSignal );
1388 int utcDaliTextFieldInputStyleChanged02(void)
1390 ToolkitTestApplication application;
1391 tet_infoline(" utcDaliTextFieldInputStyleChanged02");
1393 // The text-field emits signals when the input style changes. These changes of style are
1394 // detected during the relayout process (size negotiation), i.e after the cursor has been moved. Signals
1395 // can't be emitted during the size negotiation as the callbacks may update the UI.
1396 // The text-field adds an idle callback to the adaptor to emit the signals after the size negotiation.
1397 // This creates an implementation of the adaptor stub and a queue of idle callbacks.
1398 application.CreateAdaptor();
1402 char* pathNamePtr = get_current_dir_name();
1403 const std::string pathName( pathNamePtr );
1404 free( pathNamePtr );
1406 TextAbstraction::FontClient fontClient = TextAbstraction::FontClient::Get();
1407 fontClient.SetDpi( 93u, 93u );
1409 fontClient.GetFontId( pathName + DEFAULT_FONT_DIR + "/dejavu/DejaVuSerif.ttf", DEFAULT_FONT_SIZE );
1410 fontClient.GetFontId( pathName + DEFAULT_FONT_DIR + "/dejavu/DejaVuSerif-Bold.ttf", DEFAULT_FONT_SIZE );
1412 TextField field = TextField::New();
1413 DALI_TEST_CHECK( field );
1416 field.SetSize( 300.f, 50.f );
1417 field.SetParentOrigin( ParentOrigin::TOP_LEFT );
1418 field.SetAnchorPoint( AnchorPoint::TOP_LEFT );
1420 field.SetProperty( TextField::Property::ENABLE_MARKUP, true );
1421 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>" );
1423 // connect to the text changed signal.
1424 ConnectionTracker* testTracker = new ConnectionTracker();
1425 field.InputStyleChangedSignal().Connect( &TestInputStyleChangedCallback );
1426 bool inputStyleChangedSignal = false;
1427 field.ConnectSignal( testTracker, "inputStyleChanged", CallbackFunctor(&inputStyleChangedSignal) );
1429 Stage::GetCurrent().Add( field );
1431 // Render and notify
1432 application.SendNotification();
1433 application.Render();
1435 // Executes the idle callbacks added by the text control on the change of input style.
1436 application.RunIdles();
1438 gInputStyleChangedCallbackCalled = false;
1439 gInputStyleMask = TextField::InputStyle::NONE;
1440 inputStyleChangedSignal = false;
1442 // Create a tap event to touch the text field.
1443 application.ProcessEvent( GenerateTap( Gesture::Possible, 1u, 1u, Vector2( 53.f, 25.f ) ) );
1444 application.ProcessEvent( GenerateTap( Gesture::Started, 1u, 1u, Vector2( 53.f, 25.f ) ) );
1445 application.ProcessEvent( GenerateTap( Gesture::Possible, 2u, 1u, Vector2( 53.f, 25.f ) ) );
1446 application.ProcessEvent( GenerateTap( Gesture::Started, 2u, 1u, Vector2( 53.f, 25.f ) ) );
1448 // Render and notify
1449 application.SendNotification();
1450 application.Render();
1452 // Executes the idle callbacks added by the text control on the change of input style.
1453 application.RunIdles();
1455 DALI_TEST_CHECK( gInputStyleChangedCallbackCalled );
1456 if( gInputStyleChangedCallbackCalled )
1458 DALI_TEST_EQUALS( static_cast<unsigned int>( gInputStyleMask ),
1459 static_cast<unsigned int>( TextField::InputStyle::FONT_FAMILY |
1460 TextField::InputStyle::POINT_SIZE |
1461 TextField::InputStyle::COLOR ),
1464 const Vector4 color = field.GetProperty( TextField::Property::INPUT_COLOR ).Get<Vector4>();
1465 DALI_TEST_EQUALS( color, Color::GREEN, TEST_LOCATION );
1467 const std::string fontFamily = field.GetProperty( TextField::Property::INPUT_FONT_FAMILY ).Get<std::string>();
1468 DALI_TEST_EQUALS( fontFamily, "DejaVuSerif", TEST_LOCATION );
1470 const float pointSize = field.GetProperty( TextField::Property::INPUT_POINT_SIZE ).Get<float>();
1471 DALI_TEST_EQUALS( pointSize, 18.f, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
1473 DALI_TEST_CHECK( inputStyleChangedSignal );
1475 gInputStyleChangedCallbackCalled = false;
1476 gInputStyleMask = TextField::InputStyle::NONE;
1477 inputStyleChangedSignal = false;
1479 application.ProcessEvent( GenerateKey( "", "", DALI_KEY_BACKSPACE, 0, 0, Integration::KeyEvent::Down, DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
1481 // Render and notify
1482 application.SendNotification();
1483 application.Render();
1485 // Executes the idle callbacks added by the text control on the change of input style.
1486 application.RunIdles();
1488 DALI_TEST_CHECK( gInputStyleChangedCallbackCalled );
1489 if( gInputStyleChangedCallbackCalled )
1491 DALI_TEST_EQUALS( static_cast<unsigned int>( gInputStyleMask ),
1492 static_cast<unsigned int>( TextField::InputStyle::COLOR ),
1495 const Vector4 color = field.GetProperty( TextField::Property::INPUT_COLOR ).Get<Vector4>();
1496 DALI_TEST_EQUALS( color, Color::BLUE, TEST_LOCATION );
1498 DALI_TEST_CHECK( inputStyleChangedSignal );
1500 gInputStyleChangedCallbackCalled = false;
1501 gInputStyleMask = TextField::InputStyle::NONE;
1502 inputStyleChangedSignal = false;
1504 application.ProcessEvent( GenerateKey( "", "", DALI_KEY_BACKSPACE, 0, 0, Integration::KeyEvent::Down, DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
1506 // Render and notify
1507 application.SendNotification();
1508 application.Render();
1510 // Executes the idle callbacks added by the text control on the change of input style.
1511 application.RunIdles();
1513 DALI_TEST_CHECK( !gInputStyleChangedCallbackCalled );
1514 DALI_TEST_CHECK( !inputStyleChangedSignal );
1516 gInputStyleChangedCallbackCalled = false;
1517 gInputStyleMask = TextField::InputStyle::NONE;
1518 inputStyleChangedSignal = false;
1520 application.ProcessEvent( GenerateKey( "", "", DALI_KEY_BACKSPACE, 0, 0, Integration::KeyEvent::Down, DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
1522 // Render and notify
1523 application.SendNotification();
1524 application.Render();
1526 // Executes the idle callbacks added by the text control on the change of input style.
1527 application.RunIdles();
1529 DALI_TEST_CHECK( gInputStyleChangedCallbackCalled );
1530 if( gInputStyleChangedCallbackCalled )
1532 DALI_TEST_EQUALS( static_cast<unsigned int>( gInputStyleMask ),
1533 static_cast<unsigned int>( TextField::InputStyle::COLOR ),
1536 const Vector4 color = field.GetProperty( TextField::Property::INPUT_COLOR ).Get<Vector4>();
1537 DALI_TEST_EQUALS( color, Color::BLACK, TEST_LOCATION );
1539 DALI_TEST_CHECK( inputStyleChangedSignal );
1541 gInputStyleChangedCallbackCalled = false;
1542 gInputStyleMask = TextField::InputStyle::NONE;
1543 inputStyleChangedSignal = false;
1545 field.SetProperty( TextField::Property::INPUT_COLOR, Color::YELLOW );
1547 Property::Map fontStyleMapSet;
1548 fontStyleMapSet.Insert( "weight", "thin" );
1549 fontStyleMapSet.Insert( "width", "condensed" );
1550 fontStyleMapSet.Insert( "slant", "italic" );
1552 field.SetProperty( TextField::Property::INPUT_FONT_STYLE, fontStyleMapSet );
1553 field.SetProperty( TextField::Property::INPUT_POINT_SIZE, 20.f );
1555 field.SetProperty( TextField::Property::INPUT_UNDERLINE, "underline" );
1556 field.SetProperty( TextField::Property::INPUT_SHADOW, "shadow" );
1557 field.SetProperty( TextField::Property::INPUT_EMBOSS, "emboss" );
1558 field.SetProperty( TextField::Property::INPUT_OUTLINE, "outline" );
1560 // Render and notify
1561 application.SendNotification();
1562 application.Render();
1564 // Executes the idle callbacks added by the text control on the change of input style.
1565 application.RunIdles();
1567 DALI_TEST_CHECK( !gInputStyleChangedCallbackCalled );
1568 DALI_TEST_CHECK( !inputStyleChangedSignal );
1570 // Create a tap event to touch the text field.
1571 application.ProcessEvent( GenerateTap( Gesture::Possible, 1u, 1u, Vector2( 63.f, 25.f ) ) );
1572 application.ProcessEvent( GenerateTap( Gesture::Started, 1u, 1u, Vector2( 63.f, 25.f ) ) );
1574 // Render and notify
1575 application.SendNotification();
1576 application.Render();
1578 // Executes the idle callbacks added by the text control on the change of input style.
1579 application.RunIdles();
1581 DALI_TEST_CHECK( gInputStyleChangedCallbackCalled );
1582 if( gInputStyleChangedCallbackCalled )
1584 DALI_TEST_EQUALS( static_cast<unsigned int>( gInputStyleMask ),
1585 static_cast<unsigned int>( TextField::InputStyle::COLOR |
1586 TextField::InputStyle::POINT_SIZE |
1587 TextField::InputStyle::FONT_STYLE |
1588 TextField::InputStyle::UNDERLINE |
1589 TextField::InputStyle::SHADOW |
1590 TextField::InputStyle::EMBOSS |
1591 TextField::InputStyle::OUTLINE ),
1594 const Vector4 color = field.GetProperty( TextField::Property::INPUT_COLOR ).Get<Vector4>();
1595 DALI_TEST_EQUALS( color, Color::BLACK, TEST_LOCATION );
1597 DALI_TEST_CHECK( inputStyleChangedSignal );
1602 int utcDaliTextFieldEvent01(void)
1604 ToolkitTestApplication application;
1605 tet_infoline(" utcDaliTextFieldEvent01");
1607 // Creates a tap event. After creating a tap event the text field should
1608 // have the focus and add text with key events should be possible.
1610 TextField field = TextField::New();
1611 DALI_TEST_CHECK( field );
1613 Stage::GetCurrent().Add( field );
1615 field.SetSize( 300.f, 50.f );
1616 field.SetParentOrigin( ParentOrigin::TOP_LEFT );
1617 field.SetAnchorPoint( AnchorPoint::TOP_LEFT );
1619 // Avoid a crash when core load gl resources.
1620 application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
1622 // Render and notify
1623 application.SendNotification();
1624 application.Render();
1626 // Add a key event but as the text field has not the focus it should do nothing.
1627 application.ProcessEvent( GenerateKey( "a", "a", KEY_A_CODE, 0, 0, Integration::KeyEvent::Down, DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
1629 // Render and notify
1630 application.SendNotification();
1631 application.Render();
1633 DALI_TEST_EQUALS( field.GetProperty<std::string>( TextField::Property::TEXT ), std::string(""), TEST_LOCATION );
1635 // Create a tap event to touch the text field.
1636 application.ProcessEvent( GenerateTap( Gesture::Possible, 1u, 1u, Vector2( 150.0f, 25.0f ) ) );
1637 application.ProcessEvent( GenerateTap( Gesture::Started, 1u, 1u, Vector2( 150.0f, 25.0f ) ) );
1639 // Render and notify
1640 application.SendNotification();
1641 application.Render();
1643 // Pressing delete key should be fine even if there is no text in TextField.
1644 application.ProcessEvent( GenerateKey( "Delete", "Delete", Dali::DevelKey::DALI_KEY_DELETE, 0, 0, Integration::KeyEvent::Down, DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
1645 // Render and notify
1646 application.SendNotification();
1647 application.Render();
1649 // Now the text field has the focus, so it can handle the key events.
1650 application.ProcessEvent( GenerateKey( "a", "a", KEY_A_CODE, 0, 0, Integration::KeyEvent::Down, DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
1651 application.ProcessEvent( GenerateKey( "a", "a", KEY_A_CODE, 0, 0, Integration::KeyEvent::Down, DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
1653 // Render and notify
1654 application.SendNotification();
1655 application.Render();
1657 DALI_TEST_EQUALS( field.GetProperty<std::string>( TextField::Property::TEXT ), std::string("aa"), TEST_LOCATION );
1659 // Create a second text field and send key events to it.
1660 TextField field2 = TextField::New();
1662 field2.SetParentOrigin( ParentOrigin::TOP_LEFT );
1663 field2.SetAnchorPoint( AnchorPoint::TOP_LEFT );
1664 field2.SetSize( 100.f, 100.f );
1665 field2.SetPosition( 100.f, 100.f );
1667 Stage::GetCurrent().Add( field2 );
1669 // Render and notify
1670 application.SendNotification();
1671 application.Render();
1673 // Create a tap event on the second text field.
1674 application.ProcessEvent( GenerateTap( Gesture::Possible, 1u, 1u, Vector2( 150.0f, 125.0f ) ) );
1675 application.ProcessEvent( GenerateTap( Gesture::Started, 1u, 1u, Vector2( 150.0f, 125.0f ) ) );
1677 // Render and notify
1678 application.SendNotification();
1679 application.Render();
1681 // The second text field has the focus. It should handle the key events.
1682 application.ProcessEvent( GenerateKey( "a", "a", KEY_A_CODE, 0, 0, Integration::KeyEvent::Down, DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
1683 application.ProcessEvent( GenerateKey( "a", "a", KEY_A_CODE, 0, 0, Integration::KeyEvent::Down, DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
1685 // Render and notify
1686 application.SendNotification();
1687 application.Render();
1689 // Check the text has been added to the second text field.
1690 DALI_TEST_EQUALS( field2.GetProperty<std::string>( TextField::Property::TEXT ), std::string("aa"), TEST_LOCATION );
1695 int utcDaliTextFieldEvent02(void)
1697 ToolkitTestApplication application;
1698 tet_infoline(" utcDaliTextFieldEvent02");
1700 // Checks if the right number of actors are created.
1702 TextField field = TextField::New();
1703 field.SetProperty( TextField::Property::POINT_SIZE, 10.f );
1704 DALI_TEST_CHECK( field );
1705 LoadMarkerImages(application, field);
1707 Stage::GetCurrent().Add( field );
1709 field.SetSize( 300.f, 50.f );
1710 field.SetParentOrigin( ParentOrigin::TOP_LEFT );
1711 field.SetAnchorPoint( AnchorPoint::TOP_LEFT );
1713 // Avoid a crash when core load gl resources.
1714 application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
1716 // Render and notify
1717 application.SendNotification();
1718 application.Render();
1720 // Check there are the expected number of children ( stencil ).
1721 DALI_TEST_EQUALS( field.GetChildCount(), 1u, TEST_LOCATION );
1723 Actor stencil = field.GetChildAt( 0u );
1724 DALI_TEST_EQUALS( stencil.GetChildCount(), 0u, TEST_LOCATION );
1726 // Create a tap event to touch the text field.
1727 application.ProcessEvent( GenerateTap( Gesture::Possible, 1u, 1u, Vector2( 150.0f, 25.0f ) ) );
1728 application.ProcessEvent( GenerateTap( Gesture::Started, 1u, 1u, Vector2( 150.0f, 25.0f ) ) );
1730 // Render and notify
1731 application.SendNotification();
1732 application.Render();
1734 Actor layer = field.GetChildAt( 1u );
1735 DALI_TEST_CHECK( layer.IsLayer() );
1737 DALI_TEST_EQUALS( layer.GetChildCount(), 1u, TEST_LOCATION ); // The cursor.
1738 DALI_TEST_EQUALS( stencil.GetChildCount(), 0u, TEST_LOCATION );
1740 // Now the text field has the focus, so it can handle the key events.
1741 application.ProcessEvent( GenerateKey( "a", "a", KEY_A_CODE, 0, 0, Integration::KeyEvent::Down, DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
1742 application.ProcessEvent( GenerateKey( "a", "a", KEY_A_CODE, 0, 0, Integration::KeyEvent::Down, DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
1744 // Render and notify
1745 application.SendNotification();
1746 application.Render();
1748 // Checks the cursor and the renderer have been created.
1749 DALI_TEST_EQUALS( layer.GetChildCount(), 1u, TEST_LOCATION ); // The cursor.
1750 DALI_TEST_EQUALS( stencil.GetChildCount(), 1u, TEST_LOCATION ); // The renderer
1752 Control cursor = Control::DownCast( layer.GetChildAt( 0u ) );
1753 DALI_TEST_CHECK( cursor );
1755 // The offscreen root actor has a container with all the actors which contain the text renderers.
1756 Actor container = stencil.GetChildAt( 0u );
1757 for( unsigned int index = 0; index < container.GetChildCount(); ++index )
1759 Renderer renderer = container.GetChildAt( index ).GetRendererAt( 0u );
1760 DALI_TEST_CHECK( renderer );
1763 // Move the cursor and check the position changes.
1764 Vector3 position1 = cursor.GetCurrentPosition();
1766 application.ProcessEvent( GenerateKey( "", "", DALI_KEY_CURSOR_LEFT, 0, 0, Integration::KeyEvent::Down, DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
1767 application.ProcessEvent( GenerateKey( "", "", DALI_KEY_CURSOR_LEFT, 0, 0, Integration::KeyEvent::Down, DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
1769 // Render and notify
1770 application.SendNotification();
1771 application.Render();
1773 Vector3 position2 = cursor.GetCurrentPosition();
1775 DALI_TEST_CHECK( position2.x < position1.x );
1777 application.ProcessEvent( GenerateKey( "", "", DALI_KEY_CURSOR_RIGHT, 0, 0, Integration::KeyEvent::Down, DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
1778 application.ProcessEvent( GenerateKey( "", "", DALI_KEY_CURSOR_RIGHT, 0, 0, Integration::KeyEvent::Down, DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
1780 // Render and notify
1781 application.SendNotification();
1782 application.Render();
1784 Vector3 position3 = cursor.GetCurrentPosition();
1786 DALI_TEST_EQUALS( position1, position3, TEST_LOCATION ); // Should be in the same position1.
1788 // Send some taps and check the cursor positions.
1790 // Try to tap at the beginning.
1791 application.ProcessEvent( GenerateTap( Gesture::Possible, 1u, 1u, Vector2( 1.f, 25.0f ) ) );
1792 application.ProcessEvent( GenerateTap( Gesture::Started, 1u, 1u, Vector2( 1.f, 25.0f ) ) );
1794 // Render and notify
1795 application.SendNotification();
1796 application.Render();
1798 // Cursor position should be the same than position1.
1799 Vector3 position4 = cursor.GetCurrentPosition();
1801 DALI_TEST_EQUALS( position2, position4, TEST_LOCATION ); // Should be in the same position2.
1803 // Tap away from the start position.
1804 application.ProcessEvent( GenerateTap( Gesture::Possible, 1u, 1u, Vector2( 16.f, 25.0f ) ) );
1805 application.ProcessEvent( GenerateTap( Gesture::Started, 1u, 1u, Vector2( 16.0f, 25.0f ) ) );
1807 // Render and notify
1808 application.SendNotification();
1809 application.Render();
1811 Vector3 position5 = cursor.GetCurrentPosition();
1813 DALI_TEST_CHECK( position5.x > position4.x );
1815 // Remove all the text.
1816 application.ProcessEvent( GenerateKey( "", "", DALI_KEY_BACKSPACE, 0, 0, Integration::KeyEvent::Down, DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
1817 application.ProcessEvent( GenerateKey( "", "", DALI_KEY_BACKSPACE, 0, 0, Integration::KeyEvent::Down, DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
1818 field.SetProperty( TextField::Property::TEXT, "" );
1820 // Render and notify
1821 application.SendNotification();
1822 application.Render();
1824 // Cursor position should be the same than position2.
1825 Vector3 position6 = cursor.GetCurrentPosition();
1827 DALI_TEST_EQUALS( position2, position6, TEST_LOCATION );// Should be in the same position2.
1829 // Should not be a renderer.
1830 DALI_TEST_EQUALS( stencil.GetChildCount(), 0u, TEST_LOCATION );
1832 // Chanege exceed policy (EXCEED_POLICY_ORIGINAL doesn't use stencil )
1833 field.SetProperty( TextField::Property::TEXT, "This is a long text for the size of the text-field." );
1834 field.SetProperty( TextField::Property::EXCEED_POLICY, Dali::Toolkit::TextField::EXCEED_POLICY_ORIGINAL );
1836 application.SendNotification();
1837 application.Render();
1839 // There are renderer and decorator layer
1840 DALI_TEST_EQUALS( field.GetChildCount(), 2u, TEST_LOCATION );
1845 int utcDaliTextFieldEvent03(void)
1847 ToolkitTestApplication application;
1848 tet_infoline(" utcDaliTextFieldEvent03");
1850 // Checks if the highlight actor is created.
1852 TextField field = TextField::New();
1853 DALI_TEST_CHECK( field );
1855 Stage::GetCurrent().Add( field );
1857 field.SetProperty( TextField::Property::TEXT, "This is a long text for the size of the text-field." );
1858 field.SetProperty( TextField::Property::POINT_SIZE, 10.f );
1859 field.SetSize( 30.f, 50.f );
1860 field.SetParentOrigin( ParentOrigin::TOP_LEFT );
1861 field.SetAnchorPoint( AnchorPoint::TOP_LEFT );
1863 // Avoid a crash when core load gl resources.
1864 application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
1865 LoadMarkerImages(application, field);
1867 // Render and notify
1868 application.SendNotification();
1869 application.Render();
1871 // Tap first to get the focus.
1872 application.ProcessEvent( GenerateTap( Gesture::Possible, 1u, 1u, Vector2( 3.f, 25.0f ) ) );
1873 application.ProcessEvent( GenerateTap( Gesture::Started, 1u, 1u, Vector2( 3.f, 25.0f ) ) );
1875 // Render and notify
1876 application.SendNotification();
1877 application.Render();
1879 // Double tap to select a word.
1880 application.ProcessEvent( GenerateTap( Gesture::Possible, 2u, 1u, Vector2( 3.f, 25.0f ) ) );
1881 application.ProcessEvent( GenerateTap( Gesture::Started, 2u, 1u, Vector2( 3.f, 25.0f ) ) );
1883 // Render and notify
1884 application.SendNotification();
1885 application.Render();
1887 // The offscreen root actor should have two actors: the renderer and the highlight actor.
1888 Actor stencil = field.GetChildAt( 0u );
1890 // The highlight actor is drawn first, so is the first actor in the list
1891 Renderer highlight = stencil.GetChildAt( 0u ).GetRendererAt( 0u );
1892 DALI_TEST_CHECK( highlight );
1894 // The offscreen root actor has a container with all the actors which contain the text renderers.
1895 Actor container = stencil.GetChildAt( 1u );
1896 for( unsigned int index = 0; index < container.GetChildCount(); ++index )
1898 Renderer renderer = container.GetChildAt( index ).GetRendererAt( 0u );
1899 DALI_TEST_CHECK( renderer );
1905 int utcDaliTextFieldEvent04(void)
1907 ToolkitTestApplication application;
1908 tet_infoline(" utcDaliTextFieldEvent04");
1910 // Checks if the highlight actor is created.
1912 TextField field = TextField::New();
1913 DALI_TEST_CHECK( field );
1914 Stage::GetCurrent().Add( field );
1915 LoadMarkerImages(application, field);
1916 // Render and notify
1917 application.SendNotification();
1918 application.Render();
1920 field.SetProperty( TextField::Property::TEXT, "This is a long text for the size of the text-field." );
1921 field.SetProperty( TextField::Property::POINT_SIZE, 10.f );
1922 field.SetSize( 300.f, 50.f );
1923 field.SetParentOrigin( ParentOrigin::TOP_LEFT );
1924 field.SetAnchorPoint( AnchorPoint::TOP_LEFT );
1926 // Avoid a crash when core load gl resources.
1927 application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
1928 // Render and notify
1929 application.SendNotification();
1930 application.Render();
1932 // Create a tap event to touch the text field.
1933 application.ProcessEvent( GenerateTap( Gesture::Possible, 1u, 1u, Vector2( 150.0f, 25.0f ) ) );
1934 application.ProcessEvent( GenerateTap( Gesture::Started, 1u, 1u, Vector2( 150.0f, 25.0f ) ) );
1935 // Render and notify
1936 application.SendNotification();
1937 application.Render();
1940 // Tap first to get the focus.
1941 application.ProcessEvent( GenerateTap( Gesture::Possible, 1u, 1u, Vector2( 1.f, 25.0f ) ) );
1942 application.ProcessEvent( GenerateTap( Gesture::Started, 1u, 1u, Vector2( 1.f, 25.0f ) ) );
1944 // Render and notify
1945 application.SendNotification();
1946 application.Render();
1948 // Double tap to select a word.
1949 application.ProcessEvent( GenerateTap( Gesture::Possible, 2u, 1u, Vector2( 1.f, 25.0f ) ) );
1950 application.ProcessEvent( GenerateTap( Gesture::Started, 2u, 1u, Vector2( 1.f, 25.0f ) ) );
1952 // Render and notify
1953 application.SendNotification();
1954 application.Render();
1957 application.ProcessEvent( GenerateTap( Gesture::Possible, 1u, 1u, Vector2( 0.f, 40.0f ) ) );
1958 application.ProcessEvent( GenerateTap( Gesture::Started, 1u, 1u, Vector2( 0.f, 40.0f ) ) );
1962 int utcDaliTextFieldEvent05(void)
1964 ToolkitTestApplication application;
1965 tet_infoline(" utcDaliTextFieldEvent05");
1967 // Checks dragging of cursor/grab handle
1969 TextField field = TextField::New();
1970 DALI_TEST_CHECK( field );
1971 Stage::GetCurrent().Add( field );
1972 LoadMarkerImages(application, field);
1973 // Render and notify
1974 application.SendNotification();
1975 application.Render();
1977 field.SetProperty( TextField::Property::TEXT, "This is a long text for the size of the text-field." );
1978 field.SetProperty( TextField::Property::POINT_SIZE, 10.f );
1979 field.SetSize( 300.f, 50.f );
1980 field.SetParentOrigin( ParentOrigin::TOP_LEFT );
1981 field.SetAnchorPoint( AnchorPoint::TOP_LEFT );
1983 // Avoid a crash when core load gl resources.
1984 application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
1985 // Render and notify
1986 application.SendNotification();
1987 application.Render();
1989 // Create a tap event to touch the text field.
1990 application.ProcessEvent( GenerateTap( Gesture::Possible, 1u, 1u, Vector2( 150.0f, 25.0f ) ) );
1991 application.ProcessEvent( GenerateTap( Gesture::Started, 1u, 1u, Vector2( 150.0f, 25.0f ) ) );
1992 // Render and notify
1993 application.SendNotification();
1994 application.Render();
1996 // Tap first to get the focus.
1997 application.ProcessEvent( GenerateTap( Gesture::Possible, 1u, 1u, Vector2( 1.f, 25.0f ) ) );
1998 application.ProcessEvent( GenerateTap( Gesture::Started, 1u, 1u, Vector2( 1.f, 25.0f ) ) );
2000 // Render and notify
2001 application.SendNotification();
2002 application.Render();
2004 // Double tap to select a word.
2005 application.ProcessEvent( GenerateTap( Gesture::Possible, 2u, 1u, Vector2( 1.f, 25.0f ) ) );
2006 application.ProcessEvent( GenerateTap( Gesture::Started, 2u, 1u, Vector2( 1.f, 25.0f ) ) );
2008 // Render and notify
2009 application.SendNotification();
2010 application.Render();
2012 // drag grab handle right
2013 Vector2 pos(0.0f, 40.0f);
2014 SendPan(application, Gesture::Possible, pos);
2015 SendPan(application, Gesture::Started, pos);
2017 Wait(application, 100);
2019 for(int i = 0;i<20;i++)
2021 SendPan(application, Gesture::Continuing, pos);
2026 SendPan(application, Gesture::Finished, pos);
2027 Wait(application, RENDER_FRAME_INTERVAL);
2029 Actor stencil = field.GetChildAt( 1u );
2033 int utcDaliTextFieldEvent06(void)
2035 ToolkitTestApplication application;
2036 tet_infoline(" utcDaliTextFieldEvent06");
2038 // Checks Longpress when in edit mode
2040 TextField field = TextField::New();
2041 DALI_TEST_CHECK( field );
2042 Stage::GetCurrent().Add( field );
2043 LoadMarkerImages(application, field);
2044 // Render and notify
2045 application.SendNotification();
2046 application.Render();
2048 field.SetProperty( TextField::Property::TEXT, "Thisisalongtextforthesizeofthetextfield." );
2049 field.SetProperty( TextField::Property::POINT_SIZE, 10.f );
2050 field.SetSize( 300.f, 50.f );
2051 field.SetParentOrigin( ParentOrigin::TOP_LEFT );
2052 field.SetAnchorPoint( AnchorPoint::TOP_LEFT );
2054 // Avoid a crash when core load gl resources.
2055 application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
2056 // Render and notify
2057 application.SendNotification();
2058 application.Render();
2060 // Create a tap event to touch the text field.
2061 application.ProcessEvent( GenerateTap( Gesture::Possible, 1u, 1u, Vector2( 150.0f, 25.0f ) ) );
2062 application.ProcessEvent( GenerateTap( Gesture::Started, 1u, 1u, Vector2( 150.0f, 25.0f ) ) );
2063 // Render and notify
2064 application.SendNotification();
2065 application.Render();
2068 // Tap first to get the focus.
2069 application.ProcessEvent( GenerateTap( Gesture::Possible, 1u, 1u, Vector2( 1.f, 25.0f ) ) );
2070 application.ProcessEvent( GenerateTap( Gesture::Started, 1u, 1u, Vector2( 1.f, 25.0f ) ) );
2072 // Render and notify
2073 application.SendNotification();
2074 application.Render();
2077 application.ProcessEvent( GenerateLongPress( Gesture::Possible, 1u, Vector2( 1.f, 25.0f ) ) );
2078 application.ProcessEvent( GenerateLongPress( Gesture::Started, 1u, Vector2( 1.f, 25.0f ) ) );
2080 // Render and notify
2081 application.SendNotification();
2082 application.Render();
2087 int utcDaliTextFieldEvent07(void)
2089 ToolkitTestApplication application;
2090 tet_infoline(" utcDaliTextFieldEvent07");
2092 // Checks Longpress to start edit mode
2094 TextField field = TextField::New();
2095 DALI_TEST_CHECK( field );
2096 Stage::GetCurrent().Add( field );
2097 LoadMarkerImages(application, field);
2098 // Render and notify
2099 application.SendNotification();
2100 application.Render();
2102 field.SetProperty( TextField::Property::TEXT, "Thisisalongtextforthesizeofthetextfield." );
2103 field.SetProperty( TextField::Property::POINT_SIZE, 10.f );
2104 field.SetSize( 300.f, 50.f );
2105 field.SetParentOrigin( ParentOrigin::TOP_LEFT );
2106 field.SetAnchorPoint( AnchorPoint::TOP_LEFT );
2107 Property::Map propertyMap;
2108 propertyMap["PANEL_LAYOUT"] = InputMethod::PanelLayout::PASSWORD;
2109 field.SetProperty( TextField::Property::INPUT_METHOD_SETTINGS, propertyMap );
2111 // Avoid a crash when core load gl resources.
2112 application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
2113 // Render and notify
2114 application.SendNotification();
2115 application.Render();
2118 application.ProcessEvent( GenerateLongPress( Gesture::Possible, 1u, Vector2( 1.f, 25.0f ) ) );
2119 application.ProcessEvent( GenerateLongPress( Gesture::Started, 1u, Vector2( 1.f, 25.0f ) ) );
2121 // Render and notify
2122 application.SendNotification();
2123 application.Render();
2128 int utcDaliTextFieldEvent08(void)
2130 ToolkitTestApplication application;
2131 tet_infoline(" utcDaliTextFieldEvent08");
2133 Dali::Clipboard clipboard = Clipboard::Get();
2134 clipboard.SetItem("testTextFieldEvent");
2136 // Checks Longpress when only place holder text
2138 TextField field = TextField::New();
2139 DALI_TEST_CHECK( field );
2140 Stage::GetCurrent().Add( field );
2141 LoadMarkerImages(application, field);
2142 // Render and notify
2143 application.SendNotification();
2144 application.Render();
2146 field.SetProperty( TextField::Property::PLACEHOLDER_TEXT, "Setting Placeholder Text" );
2147 field.SetProperty( TextField::Property::POINT_SIZE, 10.f );
2148 field.SetSize( 300.f, 50.f );
2149 field.SetParentOrigin( ParentOrigin::TOP_LEFT );
2150 field.SetAnchorPoint( AnchorPoint::TOP_LEFT );
2152 // Avoid a crash when core load gl resources.
2153 application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
2154 // Render and notify
2155 application.SendNotification();
2156 application.Render();
2159 application.ProcessEvent( GenerateLongPress( Gesture::Possible, 1u, Vector2( 1.f, 25.0f ) ) );
2160 application.ProcessEvent( GenerateLongPress( Gesture::Started, 1u, Vector2( 1.f, 25.0f ) ) );
2162 // Render and notify
2163 application.SendNotification();
2164 application.Render();
2166 Wait(application, 500);
2169 application.ProcessEvent( GenerateLongPress( Gesture::Possible, 1u, Vector2( 1.f, 25.0f ) ) );
2170 application.ProcessEvent( GenerateLongPress( Gesture::Started, 1u, Vector2( 1.f, 25.0f ) ) );
2172 // Render and notify
2173 application.SendNotification();
2174 application.Render();
2176 Wait(application, 500);
2178 Stage stage = Stage::GetCurrent();
2179 Layer layer = stage.GetRootLayer();
2180 Actor actor = layer.FindChildByName("optionPaste");
2184 Vector3 worldPosition = actor.GetCurrentWorldPosition();
2185 Vector2 halfStageSize = stage.GetSize() / 2.0f;
2186 Vector2 position(worldPosition.x + halfStageSize.width, worldPosition.y + halfStageSize.height);
2188 Dali::Integration::TouchEvent event;
2189 event = Dali::Integration::TouchEvent();
2190 event.AddPoint( GetPointDownInside( position ) );
2191 application.ProcessEvent( event );
2193 event = Dali::Integration::TouchEvent();
2194 event.AddPoint( GetPointUpInside( position ) );
2195 application.ProcessEvent( event );
2197 DALI_TEST_EQUALS( field.GetProperty<std::string>( TextEditor::Property::TEXT ), std::string("testTextFieldEvent"), TEST_LOCATION );
2202 int utcDaliTextFieldEvent09(void)
2204 ToolkitTestApplication application;
2205 tet_infoline(" utcDaliTextFieldEvent09");
2207 TextField field = TextField::New();
2208 DALI_TEST_CHECK( field );
2209 Stage::GetCurrent().Add( field );
2210 LoadMarkerImages(application, field);
2211 // Render and notify
2212 application.SendNotification();
2213 application.Render();
2215 field.SetProperty( TextField::Property::TEXT, "Hello" );
2216 field.SetProperty( TextField::Property::POINT_SIZE, 10.f );
2217 field.SetSize( 300.f, 50.f );
2218 field.SetParentOrigin( ParentOrigin::TOP_LEFT );
2219 field.SetAnchorPoint( AnchorPoint::TOP_LEFT );
2221 // Avoid a crash when core load gl resources.
2222 application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
2224 // Create a tap event to touch the text field.
2225 application.ProcessEvent( GenerateTap( Gesture::Possible, 1u, 1u, Vector2( 150.0f, 25.0f ) ) );
2226 application.ProcessEvent( GenerateTap( Gesture::Started, 1u, 1u, Vector2( 150.0f, 25.0f ) ) );
2227 application.SendNotification();
2228 application.Render();
2231 map[ HiddenInput::Property::MODE ] = HiddenInput::Mode::HIDE_NONE;
2232 field.SetProperty( TextField::Property::HIDDEN_INPUT_SETTINGS, map );
2233 application.ProcessEvent( GenerateKey( "d", "d", 0, 0, 0, Integration::KeyEvent::Down, DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2234 application.SendNotification();
2235 application.Render();
2237 map[ HiddenInput::Property::MODE ] = HiddenInput::Mode::HIDE_ALL;
2238 map[ HiddenInput::Property::SUBSTITUTE_CHARACTER ] = 0x23;
2239 field.SetProperty( TextField::Property::HIDDEN_INPUT_SETTINGS, map );
2240 application.ProcessEvent( GenerateKey( "d", "d", 0, 0, 0, Integration::KeyEvent::Down, DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2241 application.SendNotification();
2242 application.Render();
2244 map[ HiddenInput::Property::MODE ] = HiddenInput::Mode::HIDE_COUNT;
2245 map[ HiddenInput::Property::SUBSTITUTE_COUNT ] = 2;
2246 field.SetProperty( TextField::Property::HIDDEN_INPUT_SETTINGS, map );
2247 for( unsigned int index = 0u; index < 5u; ++index )
2249 application.ProcessEvent( GenerateKey( "d", "d", 0, 0, 0, Integration::KeyEvent::Down, DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2250 application.SendNotification();
2251 application.Render();
2254 map[ HiddenInput::Property::MODE ] = HiddenInput::Mode::SHOW_COUNT;
2255 map[ HiddenInput::Property::SUBSTITUTE_COUNT ] = 2;
2256 field.SetProperty( TextField::Property::HIDDEN_INPUT_SETTINGS, map );
2257 for( unsigned int index = 0u; index < 5u; ++index )
2259 application.ProcessEvent( GenerateKey( "d", "d", 0, 0, 0, Integration::KeyEvent::Down, DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2260 application.SendNotification();
2261 application.Render();
2264 map[ HiddenInput::Property::MODE ] = HiddenInput::Mode::SHOW_LAST_CHARACTER;
2265 map[ HiddenInput::Property::SHOW_LAST_CHARACTER_DURATION ] = 0;
2266 field.SetProperty( TextField::Property::HIDDEN_INPUT_SETTINGS, map );
2267 application.ProcessEvent( GenerateKey( "", "", DALI_KEY_BACKSPACE, 0, 0, Integration::KeyEvent::Down, DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2268 application.SendNotification();
2269 application.Render();
2270 application.ProcessEvent( GenerateKey( "d", "d", 0, 0, 0, Integration::KeyEvent::Down, DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2271 application.SendNotification();
2272 application.Render();
2274 map[ HiddenInput::Property::SHOW_LAST_CHARACTER_DURATION ] = 100;
2275 field.SetProperty( TextField::Property::HIDDEN_INPUT_SETTINGS, map );
2276 application.ProcessEvent( GenerateKey( "d", "d", 0, 0, 0, Integration::KeyEvent::Down, DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2277 application.SendNotification();
2278 application.Render();
2280 Property::Map mapGet;
2281 mapGet = field.GetProperty<Property::Map>( TextField::Property::HIDDEN_INPUT_SETTINGS );
2282 DALI_TEST_EQUALS( map.Count(), mapGet.Count(), TEST_LOCATION );
2283 DALI_TEST_EQUALS( DaliTestCheckMaps( map, mapGet ), true, TEST_LOCATION );
2288 int utcDaliTextFieldStyleWhilstSelected(void)
2290 ToolkitTestApplication application;
2291 tet_infoline(" utcDaliTextFieldStyleWhilstSelected");
2293 // Change font and styles whilst text is selected whilst word selected
2295 TextField field = TextField::New();
2296 DALI_TEST_CHECK( field );
2297 Stage::GetCurrent().Add( field );
2298 LoadMarkerImages(application, field);
2299 // Render and notify
2300 application.SendNotification();
2301 application.Render();
2303 field.SetProperty( TextField::Property::TEXT, "This is a long text for the size of the text-field." );
2304 field.SetProperty( TextField::Property::POINT_SIZE, 10.f );
2305 field.SetSize( 300.f, 50.f );
2306 field.SetParentOrigin( ParentOrigin::TOP_LEFT );
2307 field.SetAnchorPoint( AnchorPoint::TOP_LEFT );
2309 // Avoid a crash when core load gl resources.
2310 application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
2311 // Render and notify
2312 application.SendNotification();
2313 application.Render();
2315 // Create a tap event to touch the text field.
2316 application.ProcessEvent( GenerateTap( Gesture::Possible, 1u, 1u, Vector2( 150.0f, 25.0f ) ) );
2317 application.ProcessEvent( GenerateTap( Gesture::Started, 1u, 1u, Vector2( 150.0f, 25.0f ) ) );
2318 // Render and notify
2319 application.SendNotification();
2320 application.Render();
2323 // Tap first to get the focus.
2324 application.ProcessEvent( GenerateTap( Gesture::Possible, 1u, 1u, Vector2( 1.f, 25.0f ) ) );
2325 application.ProcessEvent( GenerateTap( Gesture::Started, 1u, 1u, Vector2( 1.f, 25.0f ) ) );
2327 // Render and notify
2328 application.SendNotification();
2329 application.Render();
2331 // Double tap to select a word.
2332 application.ProcessEvent( GenerateTap( Gesture::Possible, 2u, 1u, Vector2( 1.f, 25.0f ) ) );
2333 application.ProcessEvent( GenerateTap( Gesture::Started, 2u, 1u, Vector2( 1.f, 25.0f ) ) );
2335 // Render and notify
2336 application.SendNotification();
2337 application.Render();
2339 field.SetProperty( TextField::Property::INPUT_FONT_FAMILY, "Setting input font family" );
2340 DALI_TEST_EQUALS( field.GetProperty<std::string>( TextField::Property::INPUT_FONT_FAMILY ), "Setting input font family", TEST_LOCATION );
2342 Property::Map fontStyleMapSet;
2343 Property::Map fontStyleMapGet;
2345 fontStyleMapSet.Insert( "weight", "bold" );
2346 fontStyleMapSet.Insert( "slant", "italic" );
2347 field.SetProperty( TextField::Property::INPUT_FONT_STYLE, fontStyleMapSet );
2349 fontStyleMapGet = field.GetProperty<Property::Map>( TextField::Property::INPUT_FONT_STYLE );
2350 DALI_TEST_EQUALS( fontStyleMapGet.Count(), fontStyleMapSet.Count(), TEST_LOCATION );
2351 DALI_TEST_EQUALS( DaliTestCheckMaps( fontStyleMapGet, fontStyleMapSet ), true, TEST_LOCATION );
2353 fontStyleMapSet.Clear();
2354 fontStyleMapSet.Insert( "width", "expanded" );
2355 fontStyleMapSet.Insert( "slant", "italic" );
2356 field.SetProperty( TextField::Property::INPUT_FONT_STYLE, fontStyleMapSet );
2358 fontStyleMapGet = field.GetProperty<Property::Map>( TextField::Property::INPUT_FONT_STYLE );
2359 DALI_TEST_EQUALS( fontStyleMapGet.Count(), fontStyleMapSet.Count(), TEST_LOCATION );
2360 DALI_TEST_EQUALS( DaliTestCheckMaps( fontStyleMapGet, fontStyleMapSet ), true, TEST_LOCATION );
2362 field.SetProperty( TextField::Property::INPUT_POINT_SIZE, 12.f );
2363 DALI_TEST_EQUALS( field.GetProperty<float>( TextField::Property::INPUT_POINT_SIZE ), 12.f, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
2365 field.SetProperty( TextField::Property::TEXT_COLOR, Color::RED );
2366 DALI_TEST_EQUALS( field.GetProperty<Vector4>( TextField::Property::TEXT_COLOR ), Color::RED, TEST_LOCATION );
2368 fontStyleMapSet.Clear();
2369 fontStyleMapSet.Insert( "weight", "bold" );
2370 fontStyleMapSet.Insert( "slant", "italic" );
2372 field.SetProperty( TextField::Property::FONT_STYLE, fontStyleMapSet );
2374 fontStyleMapGet = field.GetProperty<Property::Map>( TextField::Property::FONT_STYLE );
2375 DALI_TEST_EQUALS( fontStyleMapGet.Count(), fontStyleMapSet.Count(), TEST_LOCATION );
2376 DALI_TEST_EQUALS( DaliTestCheckMaps( fontStyleMapGet, fontStyleMapSet ), true, TEST_LOCATION );
2378 fontStyleMapSet.Clear();
2379 fontStyleMapSet.Insert( "width", "expanded" );
2381 field.SetProperty( TextField::Property::FONT_STYLE, fontStyleMapSet );
2383 fontStyleMapGet = field.GetProperty<Property::Map>( TextField::Property::FONT_STYLE );
2384 DALI_TEST_EQUALS( fontStyleMapGet.Count(), fontStyleMapSet.Count(), TEST_LOCATION );
2385 DALI_TEST_EQUALS( DaliTestCheckMaps( fontStyleMapGet, fontStyleMapSet ), true, TEST_LOCATION );
2387 // Press Escape to increase coverage
2388 application.ProcessEvent( GenerateKey( "", "", DALI_KEY_ESCAPE, 0, 0, Integration::KeyEvent::Up, DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2389 application.SendNotification();
2390 application.Render();
2392 DALI_TEST_CHECK( !field.HasKeyInputFocus() );
2397 int utcDaliTextFieldEscKeyLoseFocus(void)
2399 ToolkitTestApplication application;
2400 tet_infoline(" utcDaliTextFieldEscKeyLoseFocus");
2402 // Creates a tap event. After creating a tap event the text field should
2403 // have the focus and add text with key events should be possible.
2405 TextField field = TextField::New();
2406 DALI_TEST_CHECK( field );
2408 Stage::GetCurrent().Add( field );
2410 field.SetSize( 300.f, 50.f );
2411 field.SetParentOrigin( ParentOrigin::TOP_LEFT );
2412 field.SetAnchorPoint( AnchorPoint::TOP_LEFT );
2414 // Avoid a crash when core load gl resources.
2415 application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
2417 // Render and notify
2418 application.SendNotification();
2419 application.Render();
2421 // Add a key event but as the text field has not the focus it should do nothing.
2422 application.ProcessEvent( GenerateKey( "a", "a", KEY_A_CODE, 0, 0, Integration::KeyEvent::Down, DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2423 application.ProcessEvent( GenerateKey( "a", "a", KEY_A_CODE, 0, 0, Integration::KeyEvent::Up, DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2425 // Render and notify
2426 application.SendNotification();
2427 application.Render();
2429 DALI_TEST_EQUALS( field.GetProperty<std::string>( TextField::Property::TEXT ), std::string(""), TEST_LOCATION );
2431 // Create a tap event to touch the text field.
2432 application.ProcessEvent( GenerateTap( Gesture::Possible, 1u, 1u, Vector2( 150.0f, 25.0f ) ) );
2433 application.ProcessEvent( GenerateTap( Gesture::Started, 1u, 1u, Vector2( 150.0f, 25.0f ) ) );
2435 // Render and notify
2436 application.SendNotification();
2437 application.Render();
2439 // Now the text field has the focus, so it can handle the key events.
2440 application.ProcessEvent( GenerateKey( "a", "a", KEY_A_CODE, 0, 0, Integration::KeyEvent::Down, DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2441 application.ProcessEvent( GenerateKey( "a", "a", KEY_A_CODE, 0, 0, Integration::KeyEvent::Up, DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2442 application.ProcessEvent( GenerateKey( "d", "d", KEY_D_CODE, 0, 0, Integration::KeyEvent::Down, DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2443 application.ProcessEvent( GenerateKey( "d", "d", KEY_D_CODE, 0, 0, Integration::KeyEvent::Up, DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2445 // Render and notify
2446 application.SendNotification();
2447 application.Render();
2449 DALI_TEST_EQUALS( field.GetProperty<std::string>( TextField::Property::TEXT ), std::string("ad"), TEST_LOCATION );
2451 // Generate a Esc key event. The text field should lose the focus.
2452 application.ProcessEvent( GenerateKey( "", "", DALI_KEY_ESCAPE, 0, 0, Integration::KeyEvent::Down, DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2453 application.ProcessEvent( GenerateKey( "", "", DALI_KEY_ESCAPE, 0, 0, Integration::KeyEvent::Up, DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2455 // Render and notify
2456 application.SendNotification();
2457 application.Render();
2459 DALI_TEST_EQUALS( false, field.HasKeyInputFocus(), TEST_LOCATION );
2461 // No more text should be introduced
2462 application.ProcessEvent( GenerateKey( "a", "a", KEY_A_CODE, 0, 0, Integration::KeyEvent::Down, DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2463 application.ProcessEvent( GenerateKey( "a", "a", KEY_A_CODE, 0, 0, Integration::KeyEvent::Up, DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2465 // Render and notify
2466 application.SendNotification();
2467 application.Render();
2469 DALI_TEST_EQUALS( field.GetProperty<std::string>( TextField::Property::TEXT ), std::string("ad"), TEST_LOCATION );
2474 int utcDaliTextFieldSomeSpecialKeys(void)
2476 ToolkitTestApplication application;
2477 tet_infoline(" utcDaliTextFieldSomeSpecialKeys");
2479 // Checks some special keys when the text is selected.
2481 TextField field = TextField::New();
2482 DALI_TEST_CHECK( field );
2483 Stage::GetCurrent().Add( field );
2484 LoadMarkerImages(application, field);
2485 // Render and notify
2486 application.SendNotification();
2487 application.Render();
2489 const std::string longText( "This is a long text for the size of the text-field." );
2491 field.SetProperty( TextField::Property::TEXT, longText );
2492 field.SetProperty( TextField::Property::POINT_SIZE, 10.f );
2493 field.SetSize( 300.f, 50.f );
2494 field.SetParentOrigin( ParentOrigin::TOP_LEFT );
2495 field.SetAnchorPoint( AnchorPoint::TOP_LEFT );
2497 // Avoid a crash when core load gl resources.
2498 application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
2499 // Render and notify
2500 application.SendNotification();
2501 application.Render();
2503 // Create a tap event to touch the text field.
2504 application.ProcessEvent( GenerateTap( Gesture::Possible, 1u, 1u, Vector2( 150.0f, 25.0f ) ) );
2505 application.ProcessEvent( GenerateTap( Gesture::Started, 1u, 1u, Vector2( 150.0f, 25.0f ) ) );
2507 // Render and notify
2508 application.SendNotification();
2509 application.Render();
2511 // Tap first to get the focus.
2512 application.ProcessEvent( GenerateTap( Gesture::Possible, 1u, 1u, Vector2( 1.f, 25.0f ) ) );
2513 application.ProcessEvent( GenerateTap( Gesture::Started, 1u, 1u, Vector2( 1.f, 25.0f ) ) );
2515 // Render and notify
2516 application.SendNotification();
2517 application.Render();
2519 // Double tap to select a word.
2520 application.ProcessEvent( GenerateTap( Gesture::Possible, 2u, 1u, Vector2( 1.f, 25.0f ) ) );
2521 application.ProcessEvent( GenerateTap( Gesture::Started, 2u, 1u, Vector2( 1.f, 25.0f ) ) );
2523 // Render and notify
2524 application.SendNotification();
2525 application.Render();
2527 // Generate a Esc key event. The text field should lose the focus.
2528 application.ProcessEvent( GenerateKey( "XF86PowerOff", "XF86PowerOff", DALI_KEY_POWER, 0, 0, Integration::KeyEvent::Down, DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2529 application.ProcessEvent( GenerateKey( "XF86PowerOff", "XF86PowerOff", DALI_KEY_POWER, 0, 0, Integration::KeyEvent::Up, DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2531 // Render and notify
2532 application.SendNotification();
2533 application.Render();
2535 // Generate a Esc key event. The text field should lose the focus.
2536 application.ProcessEvent( GenerateKey( "XF86Menu", "XF86Menu", DALI_KEY_MENU, 0, 0, Integration::KeyEvent::Down, DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2537 application.ProcessEvent( GenerateKey( "XF86Menu", "XF86Menu", DALI_KEY_MENU, 0, 0, Integration::KeyEvent::Up, DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2539 // Render and notify
2540 application.SendNotification();
2541 application.Render();
2543 // Generate a Esc key event. The text field should lose the focus.
2544 application.ProcessEvent( GenerateKey( "XF86Home", "XF86Home", DALI_KEY_HOME, 0, 0, Integration::KeyEvent::Down, DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2545 application.ProcessEvent( GenerateKey( "XF86Home", "XF86Home", DALI_KEY_HOME, 0, 0, Integration::KeyEvent::Up, DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2547 // Render and notify
2548 application.SendNotification();
2549 application.Render();
2551 // The text shouldn't be deleted.
2552 DALI_TEST_EQUALS( field.GetProperty<std::string>( TextField::Property::TEXT ), longText, TEST_LOCATION );
2557 int utcDaliTextFieldSizeUpdate(void)
2559 ToolkitTestApplication application;
2560 tet_infoline("utcDaliTextFieldSizeUpdate");
2562 // Checks some special keys when the text is selected.
2563 TextField field = TextField::New();
2564 DALI_TEST_CHECK( field );
2565 Stage::GetCurrent().Add( field );
2567 float previousHeight = 0.0f;
2568 float currentHeight = 0.0f;
2569 const float fieldWidth = 1920.0f;
2572 // "ㅁ" is bigger then "ኢ"
2573 field.SetSize( Vector2( fieldWidth ,10.0f ) );
2574 field.SetResizePolicy( ResizePolicy::FIXED , Dimension::WIDTH );
2575 field.SetResizePolicy( ResizePolicy::DIMENSION_DEPENDENCY , Dimension::HEIGHT );
2577 field.SetProperty( TextField::Property::TEXT, "ኢ");
2578 field.SetParentOrigin( ParentOrigin::TOP_LEFT );
2579 field.SetAnchorPoint( AnchorPoint::TOP_LEFT );
2581 field.SetKeyboardFocusable(true);
2582 KeyboardFocusManager::Get().SetCurrentFocusActor( field );
2584 application.SendNotification();
2585 application.Render();
2587 previousHeight = field.GetHeightForWidth( fieldWidth );
2588 DALI_TEST_EQUALS( previousHeight, field.GetProperty<float>( Actor::Property::SIZE_HEIGHT ) , TEST_LOCATION );
2590 // Add another script characters ( glyph height is defferent )
2591 application.ProcessEvent( GenerateKey( "ㅁ", "ㅁ", KEY_A_CODE, 0, 0, Integration::KeyEvent::Down, DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2592 application.ProcessEvent( GenerateKey( "ㅁ", "ㅁ", KEY_A_CODE, 0, 0, Integration::KeyEvent::Up, DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2594 application.SendNotification();
2595 application.Render();
2597 currentHeight = field.GetHeightForWidth( fieldWidth );
2598 DALI_TEST_EQUALS( currentHeight, field.GetProperty<float>( Actor::Property::SIZE_HEIGHT ), TEST_LOCATION );
2599 DALI_TEST_EQUALS( (previousHeight < currentHeight), true , TEST_LOCATION );
2604 int utcDaliTextFieldExtremlyLargePointSize(void)
2606 ToolkitTestApplication application;
2607 tet_infoline(" utcDaliTextFieldExtremlyLargePointSize");
2609 TextField field = TextField::New();
2611 field.SetProperty( TextField::Property::TEXT, "Text" );
2612 field.SetSize( 300.f, 50.f );
2613 field.SetParentOrigin( ParentOrigin::TOP_LEFT );
2614 field.SetAnchorPoint( AnchorPoint::TOP_LEFT );
2615 Stage::GetCurrent().Add( field );
2619 field.SetProperty( TextField::Property::POINT_SIZE, 160.0f );
2620 application.SendNotification();
2621 DALI_TEST_CHECK( field );
2625 tet_result(TET_FAIL);
2630 int UtcDaliTextFieldDefaultFontStylePropertyCoverage(void)
2632 ToolkitTestApplication application;
2633 tet_infoline("UtcDaliTextFieldFontStylePorpertyCoverage");
2634 TextField field = TextField::New();
2635 DALI_TEST_CHECK( field );
2636 Stage::GetCurrent().Add( field );
2638 Property::Map fontStyleMapGet;
2640 fontStyleMapGet = field.GetProperty<Property::Map>( TextField::Property::FONT_STYLE );
2642 Property::Value* weightValue = NULL;
2643 Property::Value* widthValue = NULL;
2644 Property::Value* slantValue = NULL;
2645 weightValue = fontStyleMapGet.Find( "weight" );
2646 widthValue = fontStyleMapGet.Find( "width" );
2647 slantValue = fontStyleMapGet.Find( "slant" );
2648 DALI_TEST_CHECK( !weightValue );
2649 DALI_TEST_CHECK( !widthValue );
2650 DALI_TEST_CHECK( !slantValue );
2655 int UtcDaliTextFieldSettingPlaceholder(void)
2657 ToolkitTestApplication application;
2658 tet_infoline("UtcDaliTextFieldSettingPlaceholder");
2660 TextField field = TextField::New();
2661 DALI_TEST_CHECK( field );
2662 Stage::GetCurrent().Add( field );
2664 // Check the placeholder property with pixel size
2665 Property::Map placeholderPixelSizeMapSet;
2666 Property::Map placeholderPixelSizeMapGet;
2667 Property::Map placeholderFontstyleMap;
2668 placeholderPixelSizeMapSet[ Text::PlaceHolder::Property::TEXT ] = "Setting Placeholder Text";
2669 placeholderPixelSizeMapSet[ Text::PlaceHolder::Property::TEXT_FOCUSED ] = "Setting Placeholder Text Focused";
2670 placeholderPixelSizeMapSet[ Text::PlaceHolder::Property::COLOR ] = Color::BLUE;
2671 placeholderPixelSizeMapSet[ Text::PlaceHolder::Property::FONT_FAMILY ] = "Arial";
2672 placeholderPixelSizeMapSet[ Text::PlaceHolder::Property::PIXEL_SIZE ] = 15.0f;
2673 placeholderPixelSizeMapSet[ Text::PlaceHolder::Property::ELLIPSIS ] = true;
2675 placeholderFontstyleMap.Insert( "weight", "bold" );
2676 placeholderPixelSizeMapSet[ Text::PlaceHolder::Property::FONT_STYLE ] = placeholderFontstyleMap;
2677 field.SetProperty( TextField::Property::PLACEHOLDER, placeholderPixelSizeMapSet );
2679 placeholderPixelSizeMapGet = field.GetProperty<Property::Map>( TextField::Property::PLACEHOLDER );
2680 DALI_TEST_EQUALS( placeholderPixelSizeMapGet.Count(), placeholderPixelSizeMapSet.Count(), TEST_LOCATION );
2681 DALI_TEST_EQUALS( DaliTestCheckMaps( placeholderPixelSizeMapGet, placeholderPixelSizeMapSet ), true, TEST_LOCATION );
2683 // Check the placeholder property with point size
2684 Property::Map placeholderMapSet;
2685 Property::Map placeholderMapGet;
2686 placeholderMapSet[ Text::PlaceHolder::Property::TEXT ] = "Setting Placeholder Text";
2687 placeholderMapSet[ Text::PlaceHolder::Property::TEXT_FOCUSED ] = "Setting Placeholder Text Focused";
2688 placeholderMapSet[ Text::PlaceHolder::Property::COLOR ] = Color::RED;
2689 placeholderMapSet[ Text::PlaceHolder::Property::FONT_FAMILY ] = "Arial";
2690 placeholderMapSet[ Text::PlaceHolder::Property::POINT_SIZE ] = 12.0f;
2691 placeholderMapSet[ Text::PlaceHolder::Property::ELLIPSIS ] = false;
2693 // Check the placeholder font style property
2694 placeholderFontstyleMap.Clear();
2696 placeholderFontstyleMap.Insert( "weight", "bold" );
2697 placeholderFontstyleMap.Insert( "width", "condensed" );
2698 placeholderFontstyleMap.Insert( "slant", "italic" );
2699 placeholderMapSet[ Text::PlaceHolder::Property::FONT_STYLE ] = placeholderFontstyleMap;
2700 field.SetProperty( TextField::Property::PLACEHOLDER, placeholderMapSet );
2702 placeholderMapGet = field.GetProperty<Property::Map>( TextField::Property::PLACEHOLDER );
2703 DALI_TEST_EQUALS( placeholderMapGet.Count(), placeholderMapSet.Count(), TEST_LOCATION );
2704 DALI_TEST_EQUALS( DaliTestCheckMaps( placeholderMapGet, placeholderMapSet ), true, TEST_LOCATION );
2706 // Reset font style.
2707 placeholderFontstyleMap.Clear();
2708 placeholderFontstyleMap.Insert( "weight", "normal" );
2709 placeholderFontstyleMap.Insert( "slant", "oblique" );
2710 placeholderMapSet[ Text::PlaceHolder::Property::FONT_STYLE ] = placeholderFontstyleMap;
2711 field.SetProperty( TextField::Property::PLACEHOLDER, placeholderMapSet );
2713 placeholderMapGet = field.GetProperty<Property::Map>( TextField::Property::PLACEHOLDER );
2714 DALI_TEST_EQUALS( placeholderMapGet.Count(), placeholderMapSet.Count(), TEST_LOCATION );
2715 DALI_TEST_EQUALS( DaliTestCheckMaps( placeholderMapGet, placeholderMapSet ), true, TEST_LOCATION );
2717 placeholderFontstyleMap.Clear();
2718 placeholderFontstyleMap.Insert( "slant", "roman" );
2719 placeholderMapSet[ Text::PlaceHolder::Property::FONT_STYLE ] = placeholderFontstyleMap;
2720 field.SetProperty( TextField::Property::PLACEHOLDER, placeholderMapSet );
2722 placeholderMapGet = field.GetProperty<Property::Map>( TextField::Property::PLACEHOLDER );
2724 placeholderFontstyleMap.Clear();
2725 placeholderMapSet[ Text::PlaceHolder::Property::FONT_STYLE ] = placeholderFontstyleMap;
2727 field.SetProperty( TextField::Property::PLACEHOLDER, placeholderMapSet );
2728 placeholderMapGet = field.GetProperty<Property::Map>( TextField::Property::PLACEHOLDER );
2729 DALI_TEST_EQUALS( placeholderMapGet.Count(), placeholderMapSet.Count(), TEST_LOCATION );
2730 DALI_TEST_EQUALS( DaliTestCheckMaps( placeholderMapGet, placeholderMapSet ), true, TEST_LOCATION );
2735 int UtcDaliTextFieldSetPaddingProperty(void)
2737 ToolkitTestApplication application;
2738 tet_infoline("UtcDaliTextFieldSetPaddingProperty\n");
2740 TextField field = TextField::New();
2741 DALI_TEST_CHECK( field );
2742 field.SetSize( 300.f, 50.f );
2743 field.SetParentOrigin( ParentOrigin::TOP_LEFT );
2744 field.SetAnchorPoint( AnchorPoint::TOP_LEFT );
2745 Stage::GetCurrent().Add( field );
2747 application.SendNotification();
2748 application.Render();
2750 Vector3 originalSize = field.GetNaturalSize();
2752 field.SetProperty( Toolkit::Control::Property::PADDING, Extents( 10, 10, 10, 10 ) );
2754 application.SendNotification();
2755 application.Render();
2757 DALI_TEST_EQUALS( field.GetProperty<Extents>( Toolkit::Control::Property::PADDING ), Extents( 10, 10, 10, 10 ), TEST_LOCATION );
2759 Vector3 paddingAddedSize = field.GetNaturalSize();
2761 DALI_TEST_EQUALS( originalSize.width + 10 + 10 , paddingAddedSize.width, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
2763 DALI_TEST_EQUALS( originalSize.height + 10 + 10 , paddingAddedSize.height, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
2768 int UtcDaliTextFieldEnableShiftSelectionProperty(void)
2770 ToolkitTestApplication application;
2771 tet_infoline("UtcDaliTextFieldEnableShiftSelectionProperty");
2773 TextField field = TextField::New();
2774 DALI_TEST_CHECK( field );
2775 field.SetSize( 300.f, 50.f );
2776 field.SetParentOrigin( ParentOrigin::TOP_LEFT );
2777 field.SetAnchorPoint( AnchorPoint::TOP_LEFT );
2778 Stage::GetCurrent().Add( field );
2780 application.SendNotification();
2781 application.Render();
2783 // The default value of ENABLE_SHIFT_SELECTION is 'true'.
2784 DALI_TEST_EQUALS( field.GetProperty<bool>( DevelTextField::Property::ENABLE_SHIFT_SELECTION ), true, TEST_LOCATION );
2786 // Check the enable shift selection property
2787 field.SetProperty( DevelTextField::Property::ENABLE_SHIFT_SELECTION, false );
2788 DALI_TEST_EQUALS( field.GetProperty<bool>( DevelTextField::Property::ENABLE_SHIFT_SELECTION ), false, TEST_LOCATION );
2790 application.SendNotification();
2791 application.Render();
2796 int UtcDaliTextFieldEnableGrabHandleProperty(void)
2798 ToolkitTestApplication application;
2799 tet_infoline("UtcDaliTextFieldEnableGrabHandleProperty");
2801 TextField field = TextField::New();
2802 DALI_TEST_CHECK( field );
2803 field.SetSize( 300.f, 50.f );
2804 field.SetParentOrigin( ParentOrigin::TOP_LEFT );
2805 field.SetAnchorPoint( AnchorPoint::TOP_LEFT );
2806 Stage::GetCurrent().Add( field );
2808 application.SendNotification();
2809 application.Render();
2811 // The default value of ENABLE_GRAB_HANDLE is 'true'.
2812 DALI_TEST_EQUALS( field.GetProperty<bool>( DevelTextField::Property::ENABLE_GRAB_HANDLE ), true, TEST_LOCATION );
2814 // Check the enable grab handle property
2815 field.SetProperty( DevelTextField::Property::ENABLE_GRAB_HANDLE, false );
2816 DALI_TEST_EQUALS( field.GetProperty<bool>( DevelTextField::Property::ENABLE_GRAB_HANDLE ), false, TEST_LOCATION );
2818 application.SendNotification();
2819 application.Render();