2 * Copyright (c) 2017 Samsung Electronics Co., Ltd.
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
8 * http://www.apache.org/licenses/LICENSE-2.0
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
22 #include <dali/public-api/rendering/renderer.h>
23 #include <dali/integration-api/events/key-event-integ.h>
24 #include <dali/integration-api/events/tap-gesture-event.h>
25 #include <dali/integration-api/events/touch-event-integ.h>
26 #include <dali/integration-api/events/pan-gesture-event.h>
27 #include <dali/integration-api/events/long-press-gesture-event.h>
28 #include <dali-toolkit-test-suite-utils.h>
29 #include <dali-toolkit/dali-toolkit.h>
30 #include "toolkit-clipboard.h"
33 using namespace Toolkit;
35 void dali_textfield_startup(void)
37 test_return_value = TET_UNDEF;
40 void dali_textfield_cleanup(void)
42 test_return_value = TET_PASS;
48 const char* const PROPERTY_NAME_RENDERING_BACKEND = "renderingBackend";
49 const char* const PROPERTY_NAME_TEXT = "text";
50 const char* const PROPERTY_NAME_PLACEHOLDER_TEXT = "placeholderText";
51 const char* const PROPERTY_NAME_PLACEHOLDER_TEXT_FOCUSED = "placeholderTextFocused";
52 const char* const PROPERTY_NAME_FONT_FAMILY = "fontFamily";
53 const char* const PROPERTY_NAME_FONT_STYLE = "fontStyle";
54 const char* const PROPERTY_NAME_POINT_SIZE = "pointSize";
55 const char* const PROPERTY_NAME_MAX_LENGTH = "maxLength";
56 const char* const PROPERTY_NAME_EXCEED_POLICY = "exceedPolicy";
57 const char* const PROPERTY_NAME_HORIZONTAL_ALIGNMENT = "horizontalAlignment";
58 const char* const PROPERTY_NAME_VERTICAL_ALIGNMENT = "verticalAlignment";
59 const char* const PROPERTY_NAME_TEXT_COLOR = "textColor";
60 const char* const PROPERTY_NAME_PLACEHOLDER_TEXT_COLOR = "placeholderTextColor";
61 const char* const PROPERTY_NAME_SHADOW_OFFSET = "shadowOffset";
62 const char* const PROPERTY_NAME_SHADOW_COLOR = "shadowColor";
63 const char* const PROPERTY_NAME_PRIMARY_CURSOR_COLOR = "primaryCursorColor";
64 const char* const PROPERTY_NAME_SECONDARY_CURSOR_COLOR = "secondaryCursorColor";
65 const char* const PROPERTY_NAME_ENABLE_CURSOR_BLINK = "enableCursorBlink";
66 const char* const PROPERTY_NAME_CURSOR_BLINK_INTERVAL = "cursorBlinkInterval";
67 const char* const PROPERTY_NAME_CURSOR_BLINK_DURATION = "cursorBlinkDuration";
68 const char* const PROPERTY_NAME_CURSOR_WIDTH = "cursorWidth";
69 const char* const PROPERTY_NAME_GRAB_HANDLE_IMAGE = "grabHandleImage";
70 const char* const PROPERTY_NAME_GRAB_HANDLE_PRESSED_IMAGE = "grabHandlePressedImage";
71 const char* const PROPERTY_NAME_SCROLL_THRESHOLD = "scrollThreshold";
72 const char* const PROPERTY_NAME_SCROLL_SPEED = "scrollSpeed";
73 const char* const PROPERTY_NAME_SELECTION_HANDLE_IMAGE_LEFT = "selectionHandleImageLeft";
74 const char* const PROPERTY_NAME_SELECTION_HANDLE_IMAGE_RIGHT = "selectionHandleImageRight";
75 const char* const PROPERTY_NAME_SELECTION_HANDLE_PRESSED_IMAGE_LEFT = "selectionHandlePressedImageLeft";
76 const char* const PROPERTY_NAME_SELECTION_HANDLE_PRESSED_IMAGE_RIGHT = "selectionHandlePressedImageRight";
77 const char* const PROPERTY_NAME_SELECTION_HANDLE_MARKER_IMAGE_LEFT = "selectionHandleMarkerImageLeft";
78 const char* const PROPERTY_NAME_SELECTION_HANDLE_MARKER_IMAGE_RIGHT = "selectionHandleMarkerImageRight";
79 const char* const PROPERTY_NAME_SELECTION_HIGHLIGHT_COLOR = "selectionHighlightColor";
80 const char* const PROPERTY_NAME_DECORATION_BOUNDING_BOX = "decorationBoundingBox";
81 const char* const PROPERTY_NAME_INPUT_METHOD_SETTINGS = "inputMethodSettings";
82 const char* const PROPERTY_NAME_INPUT_COLOR = "inputColor";
83 const char* const PROPERTY_NAME_ENABLE_MARKUP = "enableMarkup";
84 const char* const PROPERTY_NAME_INPUT_FONT_FAMILY = "inputFontFamily";
85 const char* const PROPERTY_NAME_INPUT_FONT_STYLE = "inputFontStyle";
86 const char* const PROPERTY_NAME_INPUT_POINT_SIZE = "inputPointSize";
88 const char* const PROPERTY_NAME_UNDERLINE = "underline";
89 const char* const PROPERTY_NAME_INPUT_UNDERLINE = "inputUnderline";
90 const char* const PROPERTY_NAME_SHADOW = "shadow";
91 const char* const PROPERTY_NAME_INPUT_SHADOW = "inputShadow";
92 const char* const PROPERTY_NAME_EMBOSS = "emboss";
93 const char* const PROPERTY_NAME_INPUT_EMBOSS = "inputEmboss";
94 const char* const PROPERTY_NAME_OUTLINE = "outline";
95 const char* const PROPERTY_NAME_INPUT_OUTLINE = "inputOutline";
97 const char* const PROPERTY_NAME_HIDDEN_INPUT_SETTINGS = "hiddenInputSettings";
98 const char* const PROPERTY_NAME_PIXEL_SIZE = "pixelSize";
99 const char* const PROPERTY_NAME_ENABLE_SELECTION = "enableSelection";
100 const char* const PROPERTY_NAME_PLACEHOLDER = "placeholder";
101 const char* const PROPERTY_NAME_ELLIPSIS = "ellipsis";
103 const int DEFAULT_RENDERING_BACKEND = Dali::Toolkit::Text::DEFAULT_RENDERING_BACKEND;
105 const Vector4 PLACEHOLDER_TEXT_COLOR( 0.8f, 0.8f, 0.8f, 0.8f );
106 const Dali::Vector4 LIGHT_BLUE( 0.75f, 0.96f, 1.f, 1.f ); // The text highlight color.
108 const unsigned int CURSOR_BLINK_INTERVAL = 500u; // Cursor blink interval
109 const float RENDER_FRAME_INTERVAL = 16.66f;
111 const float TO_MILLISECONDS = 1000.f;
112 const float TO_SECONDS = 1.f / TO_MILLISECONDS;
114 const float SCROLL_THRESHOLD = 10.f;
115 const float SCROLL_SPEED = 300.f;
117 const unsigned int DEFAULT_FONT_SIZE = 1152u;
118 const std::string DEFAULT_FONT_DIR( "/resources/fonts" );
120 const int KEY_A_CODE = 38;
121 const int KEY_D_CODE = 40;
123 const std::string DEFAULT_DEVICE_NAME("hwKeyboard");
125 static bool gTextChangedCallBackCalled;
126 static bool gMaxCharactersCallBackCalled;
127 static bool gInputStyleChangedCallbackCalled;
128 static Dali::Toolkit::TextField::InputStyle::Mask gInputStyleMask;
130 static void LoadBitmapResource(TestPlatformAbstraction& platform, int width, int height)
132 Integration::Bitmap* bitmap = Integration::Bitmap::New( Integration::Bitmap::BITMAP_2D_PACKED_PIXELS, ResourcePolicy::OWNED_DISCARD );
133 Integration::ResourcePointer resource(bitmap);
134 bitmap->GetPackedPixelsProfile()->ReserveBuffer(Pixel::RGBA8888, width, height, width, height);
137 static void LoadMarkerImages(ToolkitTestApplication& app, TextField textField)
141 LoadBitmapResource( app.GetPlatform(), width, height );
143 Property::Map propertyMap;
144 propertyMap["filename"] = "image.png";
145 propertyMap["width"] = width;
146 propertyMap["height"] = height;
147 textField.SetProperty( Toolkit::TextField::Property::SELECTION_HANDLE_IMAGE_LEFT, propertyMap );
148 textField.SetProperty( Toolkit::TextField::Property::SELECTION_HANDLE_IMAGE_RIGHT, propertyMap );
149 textField.SetProperty( Toolkit::TextField::Property::SELECTION_HANDLE_PRESSED_IMAGE_LEFT, propertyMap );
150 textField.SetProperty( Toolkit::TextField::Property::SELECTION_HANDLE_PRESSED_IMAGE_RIGHT, propertyMap );
151 textField.SetProperty( Toolkit::TextField::Property::SELECTION_HANDLE_MARKER_IMAGE_LEFT, propertyMap );
152 textField.SetProperty( Toolkit::TextField::Property::SELECTION_HANDLE_MARKER_IMAGE_RIGHT, propertyMap );
153 textField.SetProperty( Toolkit::TextField::Property::GRAB_HANDLE_IMAGE, propertyMap );
154 textField.SetProperty( Toolkit::TextField::Property::GRAB_HANDLE_PRESSED_IMAGE, propertyMap );
157 // Generate a PanGestureEvent to send to Core
158 static Integration::PanGestureEvent GeneratePan(
159 Gesture::State state,
160 const Vector2& previousPosition,
161 const Vector2& currentPosition,
162 unsigned long timeDelta,
163 unsigned int numberOfTouches = 1)
165 Integration::PanGestureEvent pan(state);
167 pan.previousPosition = previousPosition;
168 pan.currentPosition = currentPosition;
169 pan.timeDelta = timeDelta;
170 pan.numberOfTouches = numberOfTouches;
176 * Helper to generate PanGestureEvent
178 * @param[in] application Application instance
179 * @param[in] state The Gesture State
180 * @param[in] pos The current position of touch.
182 static void SendPan(ToolkitTestApplication& application, Gesture::State state, const Vector2& pos)
186 if( (state == Gesture::Started) ||
187 (state == Gesture::Possible) )
193 application.ProcessEvent(GeneratePan(state, last, pos, 16));
200 * Simulate time passed by.
202 * @note this will always process at least 1 frame (1/60 sec)
204 * @param application Test application instance
205 * @param duration Time to pass in milliseconds.
206 * @return The actual time passed in milliseconds
208 static int Wait(ToolkitTestApplication& application, int duration = 0)
212 for(int i = 0; i <= ( duration / RENDER_FRAME_INTERVAL); i++)
214 application.SendNotification();
215 application.Render(RENDER_FRAME_INTERVAL);
216 time += RENDER_FRAME_INTERVAL;
222 Dali::Integration::Point GetPointDownInside( Vector2& pos )
224 Dali::Integration::Point point;
225 point.SetState( PointState::DOWN );
226 point.SetScreenPosition( pos );
230 Dali::Integration::Point GetPointUpInside( Vector2& pos )
232 Dali::Integration::Point point;
233 point.SetState( PointState::UP );
234 point.SetScreenPosition( pos );
238 struct CallbackFunctor
240 CallbackFunctor(bool* callbackFlag)
241 : mCallbackFlag( callbackFlag )
247 *mCallbackFlag = true;
252 static void TestTextChangedCallback( TextField control )
254 tet_infoline(" TestTextChangedCallback");
256 gTextChangedCallBackCalled = true;
259 static void TestMaxLengthReachedCallback( TextField control )
261 tet_infoline(" TestMaxLengthReachedCallback");
263 gMaxCharactersCallBackCalled = true;
266 static void TestInputStyleChangedCallback( TextField control, TextField::InputStyle::Mask mask )
268 tet_infoline(" TestInputStyleChangedCallback");
270 gInputStyleChangedCallbackCalled = true;
271 gInputStyleMask = mask;
274 // Generate a TapGestureEvent to send to Core.
275 Integration::TapGestureEvent GenerateTap(
276 Gesture::State state,
277 unsigned int numberOfTaps,
278 unsigned int numberOfTouches,
281 Integration::TapGestureEvent tap( state );
283 tap.numberOfTaps = numberOfTaps;
284 tap.numberOfTouches = numberOfTouches;
290 Integration::LongPressGestureEvent GenerateLongPress(
291 Gesture::State state,
292 unsigned int numberOfTouches,
295 Integration::LongPressGestureEvent longPress( state );
297 longPress.numberOfTouches = numberOfTouches;
298 longPress.point = point;
302 // Generate a KeyEvent to send to Core.
303 Integration::KeyEvent GenerateKey( const std::string& keyName,
304 const std::string& keyString,
307 unsigned long timeStamp,
308 const Integration::KeyEvent::State& keyState,
309 const std::string& deviceName = DEFAULT_DEVICE_NAME,
310 const Device::Class::Type& deviceClass = Device::Class::NONE,
311 const Device::Subclass::Type& deviceSubclass = Device::Subclass::NONE )
313 return Integration::KeyEvent( keyName,
324 bool DaliTestCheckMaps( const Property::Map& fontStyleMapGet, const Property::Map& fontStyleMapSet )
326 if( fontStyleMapGet.Count() == fontStyleMapSet.Count() )
328 for( unsigned int index = 0u; index < fontStyleMapGet.Count(); ++index )
330 const KeyValuePair& valueGet = fontStyleMapGet.GetKeyValue( index );
332 Property::Value* valueSet = NULL;
333 if ( valueGet.first.type == Property::Key::INDEX )
335 valueSet = fontStyleMapSet.Find( valueGet.first.indexKey );
339 // Get Key is a string so searching Set Map for a string key
340 valueSet = fontStyleMapSet.Find( valueGet.first.stringKey );
343 if( NULL != valueSet )
345 if( valueSet->GetType() == Dali::Property::STRING && ( valueGet.second.Get<std::string>() != valueSet->Get<std::string>() ) )
347 tet_printf( "Value got : [%s], expected : [%s]", valueGet.second.Get<std::string>().c_str(), valueSet->Get<std::string>().c_str() );
350 else if( valueSet->GetType() == Dali::Property::BOOLEAN && ( valueGet.second.Get<bool>() != valueSet->Get<bool>() ) )
352 tet_printf( "Value got : [%d], expected : [%d]", valueGet.second.Get<bool>(), valueSet->Get<bool>() );
355 else if( valueSet->GetType() == Dali::Property::INTEGER && ( valueGet.second.Get<int>() != valueSet->Get<int>() ) )
357 tet_printf( "Value got : [%d], expected : [%d]", valueGet.second.Get<int>(), valueSet->Get<int>() );
360 else if( valueSet->GetType() == Dali::Property::FLOAT && ( valueGet.second.Get<float>() != valueSet->Get<float>() ) )
362 tet_printf( "Value got : [%f], expected : [%f]", valueGet.second.Get<float>(), valueSet->Get<float>() );
365 else if( valueSet->GetType() == Dali::Property::VECTOR2 && ( valueGet.second.Get<Vector2>() != valueSet->Get<Vector2>() ) )
367 Vector2 vector2Get = valueGet.second.Get<Vector2>();
368 Vector2 vector2Set = valueSet->Get<Vector2>();
369 tet_printf( "Value got : [%f, %f], expected : [%f, %f]", vector2Get.x, vector2Get.y, vector2Set.x, vector2Set.y );
372 else if( valueSet->GetType() == Dali::Property::VECTOR4 && ( valueGet.second.Get<Vector4>() != valueSet->Get<Vector4>() ) )
374 Vector4 vector4Get = valueGet.second.Get<Vector4>();
375 Vector4 vector4Set = valueSet->Get<Vector4>();
376 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 );
382 if ( valueGet.first.type == Property::Key::INDEX )
384 tet_printf( " The key %d doesn't exist.", valueGet.first.indexKey );
388 tet_printf( " The key %s doesn't exist.", valueGet.first.stringKey.c_str() );
400 int UtcDaliToolkitTextFieldConstructorP(void)
402 ToolkitTestApplication application;
403 tet_infoline(" UtcDaliToolkitTextFieldConstructorP");
405 DALI_TEST_CHECK( !textField );
409 int UtcDaliToolkitTextFieldNewP(void)
411 ToolkitTestApplication application;
412 tet_infoline(" UtcDaliToolkitTextFieldNewP");
413 TextField textField = TextField::New();
414 DALI_TEST_CHECK( textField );
418 int UtcDaliToolkitTextFieldDownCastP(void)
420 ToolkitTestApplication application;
421 tet_infoline(" UtcDaliToolkitTextFieldDownCastP");
422 TextField textField1 = TextField::New();
423 BaseHandle object( textField1 );
425 TextField textField2 = TextField::DownCast( object );
426 DALI_TEST_CHECK( textField2 );
428 TextField textField3 = DownCast< TextField >( object );
429 DALI_TEST_CHECK( textField3 );
433 int UtcDaliToolkitTextFieldDownCastN(void)
435 ToolkitTestApplication application;
436 tet_infoline(" UtcDaliToolkitTextFieldDownCastN");
437 BaseHandle uninitializedObject;
438 TextField textField1 = TextField::DownCast( uninitializedObject );
439 DALI_TEST_CHECK( !textField1 );
441 TextField textField2 = DownCast< TextField >( uninitializedObject );
442 DALI_TEST_CHECK( !textField2 );
446 int UtcDaliToolkitTextFieldCopyConstructorP(void)
448 ToolkitTestApplication application;
449 tet_infoline(" UtcDaliToolkitTextFieldCopyConstructorP");
450 TextField textField = TextField::New();
451 textField.SetProperty( TextField::Property::TEXT, "Test" );
453 TextField copy( textField );
454 DALI_TEST_CHECK( copy );
455 DALI_TEST_CHECK( copy.GetProperty<std::string>( TextLabel::Property::TEXT ) == textField.GetProperty<std::string>( TextLabel::Property::TEXT ) );
459 int UtcDaliToolkitTextFieldAssignmentOperatorP(void)
461 ToolkitTestApplication application;
462 tet_infoline(" UtcDaliToolkitTextFieldAssignmentOperatorP");
463 TextField textField = TextField::New();
464 textField.SetProperty( TextField::Property::TEXT, "Test" );
466 TextField copy = textField;
467 DALI_TEST_CHECK( copy );
468 DALI_TEST_CHECK( copy.GetProperty<std::string>( TextField::Property::TEXT ) == textField.GetProperty<std::string>( TextField::Property::TEXT ) );
472 int UtcDaliTextFieldNewP(void)
474 ToolkitTestApplication application;
475 tet_infoline(" UtcDaliToolkitTextFieldNewP");
476 TextField textField = TextField::New();
477 DALI_TEST_CHECK( textField );
481 // Positive test case for a method
482 int UtcDaliTextFieldGetPropertyP(void)
484 ToolkitTestApplication application;
485 tet_infoline(" UtcDaliToolkitTextFieldGetPropertyP");
486 TextField field = TextField::New();
487 DALI_TEST_CHECK( field );
489 // Check Property Indices are correct
490 DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_RENDERING_BACKEND ) == TextField::Property::RENDERING_BACKEND );
491 DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_TEXT ) == TextField::Property::TEXT );
492 DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_PLACEHOLDER_TEXT ) == TextField::Property::PLACEHOLDER_TEXT );
493 DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_PLACEHOLDER_TEXT_FOCUSED ) == TextField::Property::PLACEHOLDER_TEXT_FOCUSED );
494 DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_FONT_FAMILY ) == TextField::Property::FONT_FAMILY );
495 DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_FONT_STYLE ) == TextField::Property::FONT_STYLE );
496 DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_POINT_SIZE ) == TextField::Property::POINT_SIZE );
497 DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_MAX_LENGTH ) == TextField::Property::MAX_LENGTH );
498 DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_EXCEED_POLICY ) == TextField::Property::EXCEED_POLICY );
499 DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_HORIZONTAL_ALIGNMENT ) == TextField::Property::HORIZONTAL_ALIGNMENT );
500 DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_VERTICAL_ALIGNMENT ) == TextField::Property::VERTICAL_ALIGNMENT );
501 DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_TEXT_COLOR ) == TextField::Property::TEXT_COLOR );
502 DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_PLACEHOLDER_TEXT_COLOR ) == TextField::Property::PLACEHOLDER_TEXT_COLOR );
503 DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_SHADOW_OFFSET ) == TextField::Property::SHADOW_OFFSET );
504 DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_SHADOW_COLOR ) == TextField::Property::SHADOW_COLOR );
505 DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_PRIMARY_CURSOR_COLOR ) == TextField::Property::PRIMARY_CURSOR_COLOR );
506 DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_SECONDARY_CURSOR_COLOR ) == TextField::Property::SECONDARY_CURSOR_COLOR );
507 DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_ENABLE_CURSOR_BLINK ) == TextField::Property::ENABLE_CURSOR_BLINK );
508 DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_CURSOR_BLINK_INTERVAL ) == TextField::Property::CURSOR_BLINK_INTERVAL );
509 DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_CURSOR_BLINK_DURATION ) == TextField::Property::CURSOR_BLINK_DURATION );
510 DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_CURSOR_WIDTH ) == TextField::Property::CURSOR_WIDTH );
511 DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_GRAB_HANDLE_IMAGE ) == TextField::Property::GRAB_HANDLE_IMAGE );
512 DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_GRAB_HANDLE_PRESSED_IMAGE ) == TextField::Property::GRAB_HANDLE_PRESSED_IMAGE );
513 DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_SCROLL_THRESHOLD ) == TextField::Property::SCROLL_THRESHOLD );
514 DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_SCROLL_SPEED ) == TextField::Property::SCROLL_SPEED );
515 DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_SELECTION_HANDLE_IMAGE_LEFT ) == TextField::Property::SELECTION_HANDLE_IMAGE_LEFT );
516 DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_SELECTION_HANDLE_IMAGE_RIGHT ) == TextField::Property::SELECTION_HANDLE_IMAGE_RIGHT );
517 DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_SELECTION_HANDLE_PRESSED_IMAGE_LEFT ) == TextField::Property::SELECTION_HANDLE_PRESSED_IMAGE_LEFT );
518 DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_SELECTION_HANDLE_PRESSED_IMAGE_RIGHT ) == TextField::Property::SELECTION_HANDLE_PRESSED_IMAGE_RIGHT );
519 DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_SELECTION_HANDLE_MARKER_IMAGE_LEFT ) == TextField::Property::SELECTION_HANDLE_MARKER_IMAGE_LEFT );
520 DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_SELECTION_HANDLE_MARKER_IMAGE_RIGHT ) == TextField::Property::SELECTION_HANDLE_MARKER_IMAGE_RIGHT );
521 DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_SELECTION_HIGHLIGHT_COLOR ) == TextField::Property::SELECTION_HIGHLIGHT_COLOR );
522 DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_DECORATION_BOUNDING_BOX ) == TextField::Property::DECORATION_BOUNDING_BOX );
523 DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_INPUT_METHOD_SETTINGS ) == TextField::Property::INPUT_METHOD_SETTINGS );
524 DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_INPUT_COLOR ) == TextField::Property::INPUT_COLOR );
525 DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_ENABLE_MARKUP ) == TextField::Property::ENABLE_MARKUP );
526 DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_INPUT_FONT_FAMILY ) == TextField::Property::INPUT_FONT_FAMILY );
527 DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_INPUT_FONT_STYLE ) == TextField::Property::INPUT_FONT_STYLE );
528 DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_INPUT_POINT_SIZE ) == TextField::Property::INPUT_POINT_SIZE );
529 DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_UNDERLINE ) == TextField::Property::UNDERLINE );
530 DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_INPUT_UNDERLINE ) == TextField::Property::INPUT_UNDERLINE );
531 DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_SHADOW ) == TextField::Property::SHADOW );
532 DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_INPUT_SHADOW ) == TextField::Property::INPUT_SHADOW );
533 DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_EMBOSS ) == TextField::Property::EMBOSS );
534 DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_INPUT_EMBOSS ) == TextField::Property::INPUT_EMBOSS );
535 DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_OUTLINE ) == TextField::Property::OUTLINE );
536 DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_INPUT_OUTLINE ) == TextField::Property::INPUT_OUTLINE );
537 DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_HIDDEN_INPUT_SETTINGS ) == TextField::Property::HIDDEN_INPUT_SETTINGS );
538 DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_PIXEL_SIZE ) == TextField::Property::PIXEL_SIZE );
539 DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_ENABLE_SELECTION ) == TextField::Property::ENABLE_SELECTION );
540 DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_PLACEHOLDER ) == TextField::Property::PLACEHOLDER );
541 DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_ELLIPSIS ) == TextField::Property::ELLIPSIS );
546 bool SetPropertyMapRetrieved( TextField& field, const Property::Index property, const std::string mapKey, const std::string mapValue )
549 Property::Map imageMap;
550 imageMap[mapKey] =mapValue;
552 field.SetProperty( property , imageMap );
553 Property::Value propValue = field.GetProperty( property );
554 Property::Map* resultMap = propValue.GetMap();
556 if ( resultMap->Find( mapKey )->Get< std::string>() == mapValue )
564 // Positive test case for a method
565 int UtcDaliTextFieldSetPropertyP(void)
567 ToolkitTestApplication application;
568 tet_infoline(" UtcDaliToolkitTextFieldSetPropertyP");
569 TextField field = TextField::New();
570 DALI_TEST_CHECK( field );
571 Stage::GetCurrent().Add( field );
573 // Note - we can't check the defaults since the stylesheets are platform-specific
575 // Check the render backend property.
576 field.SetProperty( TextField::Property::RENDERING_BACKEND, Text::RENDERING_SHARED_ATLAS );
577 DALI_TEST_EQUALS( (Text::RenderingType)field.GetProperty<int>( TextField::Property::RENDERING_BACKEND ), Text::RENDERING_SHARED_ATLAS, TEST_LOCATION );
579 // Check text property.
580 field.SetProperty( TextField::Property::TEXT, "Setting Text" );
581 DALI_TEST_EQUALS( field.GetProperty<std::string>( TextField::Property::TEXT ), std::string("Setting Text"), TEST_LOCATION );
583 // Check placeholder text properties.
584 field.SetProperty( TextField::Property::PLACEHOLDER_TEXT, "Setting Placeholder Text" );
585 DALI_TEST_EQUALS( field.GetProperty<std::string>( TextField::Property::PLACEHOLDER_TEXT ), std::string("Setting Placeholder Text"), TEST_LOCATION );
587 field.SetProperty( TextField::Property::PLACEHOLDER_TEXT_FOCUSED, "Setting Placeholder Text Focused" );
588 DALI_TEST_EQUALS( field.GetProperty<std::string>( TextField::Property::PLACEHOLDER_TEXT_FOCUSED ), std::string("Setting Placeholder Text Focused"), TEST_LOCATION );
590 // Check font properties.
591 field.SetProperty( TextField::Property::FONT_FAMILY, "Setting font family" );
592 DALI_TEST_EQUALS( field.GetProperty<std::string>( TextField::Property::FONT_FAMILY ), std::string("Setting font family"), TEST_LOCATION );
594 Property::Map fontStyleMapSet;
595 Property::Map fontStyleMapGet;
596 Property::Value* slantValue = NULL;
598 fontStyleMapSet.Insert( "weight", "bold" );
599 fontStyleMapSet.Insert( "width", "condensed" );
600 fontStyleMapSet.Insert( "slant", "italic" );
601 field.SetProperty( TextField::Property::FONT_STYLE, fontStyleMapSet );
603 fontStyleMapGet = field.GetProperty<Property::Map>( TextField::Property::FONT_STYLE );
604 DALI_TEST_EQUALS( fontStyleMapGet.Count(), fontStyleMapSet.Count(), TEST_LOCATION );
605 DALI_TEST_EQUALS( DaliTestCheckMaps( fontStyleMapGet, fontStyleMapSet ), true, TEST_LOCATION );
607 field.SetProperty( TextField::Property::POINT_SIZE, 10.f );
608 DALI_TEST_EQUALS( field.GetProperty<float>( TextField::Property::POINT_SIZE ), 10.f, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
611 fontStyleMapSet.Clear();
612 fontStyleMapSet.Insert( "weight", "normal" );
613 fontStyleMapSet.Insert( "slant", "oblique" );
614 field.SetProperty( TextField::Property::FONT_STYLE, fontStyleMapSet );
616 fontStyleMapGet = field.GetProperty<Property::Map>( TextField::Property::FONT_STYLE );
617 DALI_TEST_EQUALS( fontStyleMapGet.Count(), fontStyleMapSet.Count(), TEST_LOCATION );
618 DALI_TEST_EQUALS( DaliTestCheckMaps( fontStyleMapGet, fontStyleMapSet ), true, TEST_LOCATION );
620 fontStyleMapSet.Clear();
621 fontStyleMapSet.Insert( "slant", "roman" );
622 field.SetProperty( TextField::Property::FONT_STYLE, fontStyleMapSet );
623 fontStyleMapGet = field.GetProperty<Property::Map>( TextField::Property::FONT_STYLE );
625 // Replace 'roman' for 'normal'.
626 slantValue = fontStyleMapGet.Find( "slant" );
627 if( NULL != slantValue )
629 if( "normal" == slantValue->Get<std::string>() )
631 fontStyleMapGet["slant"] = "roman";
634 DALI_TEST_EQUALS( fontStyleMapGet.Count(), fontStyleMapSet.Count(), TEST_LOCATION );
635 DALI_TEST_EQUALS( DaliTestCheckMaps( fontStyleMapGet, fontStyleMapSet ), true, TEST_LOCATION );
637 fontStyleMapSet.Clear();
639 field.SetProperty( TextField::Property::FONT_STYLE, fontStyleMapSet );
640 fontStyleMapGet = field.GetProperty<Property::Map>( TextField::Property::FONT_STYLE );
641 DALI_TEST_EQUALS( fontStyleMapGet.Count(), fontStyleMapSet.Count(), TEST_LOCATION );
642 DALI_TEST_EQUALS( DaliTestCheckMaps( fontStyleMapGet, fontStyleMapSet ), true, TEST_LOCATION );
644 // Check that the MAX_LENGTH property can be correctly set
645 const int maxNumberOfCharacters = 20;
646 field.SetProperty( TextField::Property::MAX_LENGTH, maxNumberOfCharacters );
647 DALI_TEST_EQUALS( field.GetProperty<int>( TextField::Property::MAX_LENGTH ), maxNumberOfCharacters, TEST_LOCATION );
649 // Check exceed policy
650 field.SetProperty( TextField::Property::EXCEED_POLICY, Dali::Toolkit::TextField::EXCEED_POLICY_CLIP );
651 DALI_TEST_EQUALS( field.GetProperty<int>( TextField::Property::EXCEED_POLICY ), static_cast<int>( Dali::Toolkit::TextField::EXCEED_POLICY_CLIP ), TEST_LOCATION );
652 field.SetProperty( TextField::Property::EXCEED_POLICY, Dali::Toolkit::TextField::EXCEED_POLICY_ORIGINAL );
653 DALI_TEST_EQUALS( field.GetProperty<int>( TextField::Property::EXCEED_POLICY ), static_cast<int>( Dali::Toolkit::TextField::EXCEED_POLICY_ORIGINAL ), TEST_LOCATION );
655 // Check that the Alignment properties can be correctly set
656 field.SetProperty( TextField::Property::HORIZONTAL_ALIGNMENT, "END" );
657 DALI_TEST_EQUALS( field.GetProperty<std::string>( TextField::Property::HORIZONTAL_ALIGNMENT ), "END", TEST_LOCATION );
658 field.SetProperty( TextField::Property::VERTICAL_ALIGNMENT, "CENTER" );
659 DALI_TEST_EQUALS( field.GetProperty<std::string>( TextField::Property::VERTICAL_ALIGNMENT ), "CENTER", TEST_LOCATION );
661 // Check text's color property
662 field.SetProperty( TextField::Property::TEXT_COLOR, Color::WHITE );
663 DALI_TEST_EQUALS( field.GetProperty<Vector4>( TextField::Property::TEXT_COLOR ), Color::WHITE, TEST_LOCATION );
665 // Check placeholder text's color property.
666 field.SetProperty( TextField::Property::PLACEHOLDER_TEXT_COLOR, Color::RED );
667 DALI_TEST_EQUALS( field.GetProperty<Vector4>( TextField::Property::PLACEHOLDER_TEXT_COLOR ), Color::RED, TEST_LOCATION );
669 // Check shadow properties.
670 field.SetProperty( TextField::Property::SHADOW_OFFSET, Vector2( 1.f, 1.f ) );
671 DALI_TEST_EQUALS( field.GetProperty<Vector2>( TextField::Property::SHADOW_OFFSET ), Vector2( 1.f, 1.f ), TEST_LOCATION );
672 field.SetProperty( TextField::Property::SHADOW_COLOR, Color::GREEN );
673 DALI_TEST_EQUALS( field.GetProperty<Vector4>( TextField::Property::SHADOW_COLOR ), Color::GREEN, TEST_LOCATION );
675 // Check cursor properties
676 field.SetProperty( TextField::Property::PRIMARY_CURSOR_COLOR, Color::RED );
677 DALI_TEST_EQUALS( field.GetProperty<Vector4>( TextField::Property::PRIMARY_CURSOR_COLOR ), Color::RED, TEST_LOCATION );
678 field.SetProperty( TextField::Property::SECONDARY_CURSOR_COLOR, Color::BLUE );
679 DALI_TEST_EQUALS( field.GetProperty<Vector4>( TextField::Property::SECONDARY_CURSOR_COLOR ), Color::BLUE, TEST_LOCATION );
681 field.SetProperty( TextField::Property::ENABLE_CURSOR_BLINK, false );
682 DALI_TEST_EQUALS( field.GetProperty<bool>( TextField::Property::ENABLE_CURSOR_BLINK ), false, TEST_LOCATION );
683 field.SetProperty( TextField::Property::CURSOR_BLINK_INTERVAL, 1.f );
684 DALI_TEST_EQUALS( field.GetProperty<float>( TextField::Property::CURSOR_BLINK_INTERVAL ), 1.f, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
685 field.SetProperty( TextField::Property::CURSOR_BLINK_DURATION, 10.f );
686 DALI_TEST_EQUALS( field.GetProperty<float>( TextField::Property::CURSOR_BLINK_DURATION ), 10.f, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
687 field.SetProperty( TextField::Property::CURSOR_WIDTH, 1 );
688 DALI_TEST_EQUALS( field.GetProperty<int>( TextField::Property::CURSOR_WIDTH ), 1, TEST_LOCATION );
690 // Check scroll properties.
691 field.SetProperty( TextField::Property::SCROLL_THRESHOLD, 1.f );
692 DALI_TEST_EQUALS( field.GetProperty<float>( TextField::Property::SCROLL_THRESHOLD ), 1.f, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
693 field.SetProperty( TextField::Property::SCROLL_SPEED, 100.f );
694 DALI_TEST_EQUALS( field.GetProperty<float>( TextField::Property::SCROLL_SPEED ), 100.f, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
696 // Check handle images
697 field.SetProperty( TextField::Property::GRAB_HANDLE_IMAGE, "image1" );
698 DALI_TEST_EQUALS( field.GetProperty<std::string>( TextField::Property::GRAB_HANDLE_IMAGE ), "image1", TEST_LOCATION );
699 field.SetProperty( TextField::Property::GRAB_HANDLE_PRESSED_IMAGE, "image2" );
700 DALI_TEST_EQUALS( field.GetProperty<std::string>( TextField::Property::GRAB_HANDLE_PRESSED_IMAGE ), "image2", TEST_LOCATION );
701 field.SetProperty( TextField::Property::SELECTION_HANDLE_IMAGE_LEFT, "image3" );
703 // Check handle images
704 DALI_TEST_CHECK( SetPropertyMapRetrieved( field, TextField::Property::SELECTION_HANDLE_IMAGE_LEFT, "filename", "leftHandleImage" ) );
705 DALI_TEST_CHECK( SetPropertyMapRetrieved( field, TextField::Property::SELECTION_HANDLE_IMAGE_RIGHT, "filename", "rightHandleImage" ) );
706 DALI_TEST_CHECK( SetPropertyMapRetrieved( field, TextField::Property::SELECTION_HANDLE_PRESSED_IMAGE_LEFT, "filename", "leftHandleImagePressed" ) );
707 DALI_TEST_CHECK( SetPropertyMapRetrieved( field, TextField::Property::SELECTION_HANDLE_PRESSED_IMAGE_RIGHT, "filename", "rightHandleImagePressed" ) );
708 DALI_TEST_CHECK( SetPropertyMapRetrieved( field, TextField::Property::SELECTION_HANDLE_MARKER_IMAGE_LEFT, "filename", "leftHandleMarkerImage" ) );
709 DALI_TEST_CHECK( SetPropertyMapRetrieved( field, TextField::Property::SELECTION_HANDLE_MARKER_IMAGE_RIGHT, "filename", "rightHandleMarkerImage" ) );
711 // Check the highlight color
712 field.SetProperty( TextField::Property::SELECTION_HIGHLIGHT_COLOR, Color::GREEN );
713 DALI_TEST_EQUALS( field.GetProperty<Vector4>( TextField::Property::SELECTION_HIGHLIGHT_COLOR ), Color::GREEN, TEST_LOCATION );
715 // Decoration bounding box
716 field.SetProperty( TextField::Property::DECORATION_BOUNDING_BOX, Rect<int>( 0, 0, 1, 1 ) );
717 DALI_TEST_EQUALS( field.GetProperty<Rect <int > >( TextField::Property::DECORATION_BOUNDING_BOX ), Rect<int>( 0, 0, 1, 1 ), TEST_LOCATION );
719 // Check the input method setting
720 Property::Map propertyMap;
721 InputMethod::PanelLayout::Type panelLayout = InputMethod::PanelLayout::NUMBER;
722 InputMethod::AutoCapital::Type autoCapital = InputMethod::AutoCapital::WORD;
723 InputMethod::ActionButtonTitle::Type actionButton = InputMethod::ActionButtonTitle::GO;
724 int inputVariation = 1;
725 propertyMap["PANEL_LAYOUT"] = panelLayout;
726 propertyMap["AUTO_CAPITALISE"] = autoCapital;
727 propertyMap["ACTION_BUTTON"] = actionButton;
728 propertyMap["VARIATION"] = inputVariation;
729 field.SetProperty( TextField::Property::INPUT_METHOD_SETTINGS, propertyMap );
731 Property::Value value = field.GetProperty( TextField::Property::INPUT_METHOD_SETTINGS );
733 DALI_TEST_CHECK( value.Get( map ) );
736 DALI_TEST_CHECK( map[ "PANEL_LAYOUT" ].Get( layout ) );
737 DALI_TEST_EQUALS( static_cast<int>(panelLayout), layout, TEST_LOCATION );
740 DALI_TEST_CHECK( map[ "AUTO_CAPITALISE" ].Get( capital ) );
741 DALI_TEST_EQUALS( static_cast<int>(autoCapital), capital, TEST_LOCATION );
744 DALI_TEST_CHECK( map[ "ACTION_BUTTON" ].Get( action ) );
745 DALI_TEST_EQUALS( static_cast<int>(actionButton), action, TEST_LOCATION );
748 DALI_TEST_CHECK( map[ "VARIATION" ].Get( variation ) );
749 DALI_TEST_EQUALS( inputVariation, variation, TEST_LOCATION );
751 // Check input color property.
752 field.SetProperty( TextField::Property::INPUT_COLOR, Color::YELLOW );
753 DALI_TEST_EQUALS( field.GetProperty<Vector4>( TextField::Property::INPUT_COLOR ), Color::YELLOW, TEST_LOCATION );
755 // Check the enable markup property.
756 DALI_TEST_CHECK( !field.GetProperty<bool>( TextField::Property::ENABLE_MARKUP ) );
757 field.SetProperty( TextField::Property::ENABLE_MARKUP, true );
758 DALI_TEST_CHECK( field.GetProperty<bool>( TextField::Property::ENABLE_MARKUP ) );
760 // Check input font properties.
761 field.SetProperty( TextField::Property::INPUT_FONT_FAMILY, "Setting input font family" );
762 DALI_TEST_EQUALS( field.GetProperty<std::string>( TextField::Property::INPUT_FONT_FAMILY ), "Setting input font family", TEST_LOCATION );
764 fontStyleMapSet.Clear();
765 fontStyleMapSet.Insert( "weight", "bold" );
766 fontStyleMapSet.Insert( "width", "condensed" );
767 fontStyleMapSet.Insert( "slant", "italic" );
769 field.SetProperty( TextField::Property::INPUT_FONT_STYLE, fontStyleMapSet );
770 fontStyleMapGet = field.GetProperty<Property::Map>( TextField::Property::INPUT_FONT_STYLE );
771 DALI_TEST_EQUALS( fontStyleMapGet.Count(), fontStyleMapSet.Count(), TEST_LOCATION );
772 DALI_TEST_EQUALS( DaliTestCheckMaps( fontStyleMapGet, fontStyleMapSet ), true, TEST_LOCATION );
774 field.SetProperty( TextField::Property::INPUT_POINT_SIZE, 12.f );
775 DALI_TEST_EQUALS( field.GetProperty<float>( TextField::Property::INPUT_POINT_SIZE ), 12.f, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
777 // Reset input font style.
778 fontStyleMapSet.Clear();
779 fontStyleMapSet.Insert( "weight", "normal" );
780 fontStyleMapSet.Insert( "slant", "oblique" );
782 field.SetProperty( TextField::Property::INPUT_FONT_STYLE, fontStyleMapSet );
783 fontStyleMapGet = field.GetProperty<Property::Map>( TextField::Property::INPUT_FONT_STYLE );
784 DALI_TEST_EQUALS( fontStyleMapGet.Count(), fontStyleMapSet.Count(), TEST_LOCATION );
785 DALI_TEST_EQUALS( DaliTestCheckMaps( fontStyleMapGet, fontStyleMapSet ), true, TEST_LOCATION );
787 fontStyleMapSet.Clear();
788 fontStyleMapSet.Insert( "slant", "roman" );
790 field.SetProperty( TextField::Property::INPUT_FONT_STYLE, fontStyleMapSet );
791 fontStyleMapGet = field.GetProperty<Property::Map>( TextField::Property::INPUT_FONT_STYLE );
793 // Replace 'roman' for 'normal'.
794 slantValue = fontStyleMapGet.Find( "slant" );
795 if( NULL != slantValue )
797 if( "normal" == slantValue->Get<std::string>() )
799 fontStyleMapGet["slant"] = "roman";
802 DALI_TEST_EQUALS( fontStyleMapGet.Count(), fontStyleMapSet.Count(), TEST_LOCATION );
803 DALI_TEST_EQUALS( DaliTestCheckMaps( fontStyleMapGet, fontStyleMapSet ), true, TEST_LOCATION );
805 fontStyleMapSet.Clear();
807 field.SetProperty( TextField::Property::INPUT_FONT_STYLE, fontStyleMapSet );
808 fontStyleMapGet = field.GetProperty<Property::Map>( TextField::Property::INPUT_FONT_STYLE );
809 DALI_TEST_EQUALS( fontStyleMapGet.Count(), fontStyleMapSet.Count(), TEST_LOCATION );
810 DALI_TEST_EQUALS( DaliTestCheckMaps( fontStyleMapGet, fontStyleMapSet ), true, TEST_LOCATION );
812 Property::Map underlineMapSet;
813 Property::Map underlineMapGet;
815 underlineMapSet.Insert( "enable", "true" );
816 underlineMapSet.Insert( "color", "red" );
817 underlineMapSet.Insert( "height", "1" );
819 // Check the underline property
820 field.SetProperty( TextField::Property::UNDERLINE, underlineMapSet );
822 underlineMapGet = field.GetProperty<Property::Map>( TextField::Property::UNDERLINE );
823 DALI_TEST_EQUALS( underlineMapGet.Count(), underlineMapSet.Count(), TEST_LOCATION );
824 DALI_TEST_EQUALS( DaliTestCheckMaps( underlineMapGet, underlineMapSet ), true, TEST_LOCATION );
826 // Check the input underline property
827 field.SetProperty( TextField::Property::INPUT_UNDERLINE, "Underline input properties" );
828 DALI_TEST_EQUALS( field.GetProperty<std::string>( TextField::Property::INPUT_UNDERLINE ), std::string("Underline input properties"), TEST_LOCATION );
830 // Check the shadow property
831 Property::Map shadowMapSet;
832 Property::Map shadowMapGet;
834 shadowMapSet.Insert( "color", Color::GREEN );
835 shadowMapSet.Insert( "offset", Vector2(2.0f, 2.0f) );
836 shadowMapSet.Insert( "blurRadius", 3.0f );
838 field.SetProperty( TextField::Property::SHADOW, shadowMapSet );
840 shadowMapGet = field.GetProperty<Property::Map>( TextField::Property::SHADOW );
841 DALI_TEST_EQUALS( shadowMapGet.Count(), shadowMapSet.Count(), TEST_LOCATION );
842 DALI_TEST_EQUALS( DaliTestCheckMaps( shadowMapGet, shadowMapSet ), true, TEST_LOCATION );
844 // Check the input shadow property
845 field.SetProperty( TextField::Property::INPUT_SHADOW, "Shadow input properties" );
846 DALI_TEST_EQUALS( field.GetProperty<std::string>( TextField::Property::INPUT_SHADOW ), std::string("Shadow input properties"), TEST_LOCATION );
848 // Check the emboss property
849 field.SetProperty( TextField::Property::EMBOSS, "Emboss properties" );
850 DALI_TEST_EQUALS( field.GetProperty<std::string>( TextField::Property::EMBOSS ), std::string("Emboss properties"), TEST_LOCATION );
852 // Check the input emboss property
853 field.SetProperty( TextField::Property::INPUT_EMBOSS, "Emboss input properties" );
854 DALI_TEST_EQUALS( field.GetProperty<std::string>( TextField::Property::INPUT_EMBOSS ), std::string("Emboss input properties"), TEST_LOCATION );
856 // Check the outline property
858 // Test string type first
859 // This is purely to maintain backward compatibility, but we don't support string as the outline property type.
860 field.SetProperty( TextField::Property::OUTLINE, "Outline properties" );
861 DALI_TEST_EQUALS( field.GetProperty<std::string>( TextField::Property::OUTLINE ), std::string("Outline properties"), TEST_LOCATION );
863 // Then test the property map type
864 Property::Map outlineMapSet;
865 Property::Map outlineMapGet;
867 outlineMapSet["color"] = Color::RED;
868 outlineMapSet["width"] = 2.0f;
870 field.SetProperty( TextField::Property::OUTLINE, outlineMapSet );
872 outlineMapGet = field.GetProperty<Property::Map>( TextField::Property::OUTLINE );
873 DALI_TEST_EQUALS( outlineMapGet.Count(), outlineMapSet.Count(), TEST_LOCATION );
874 DALI_TEST_EQUALS( DaliTestCheckMaps( outlineMapGet, outlineMapSet ), true, TEST_LOCATION );
876 // Check the input outline property
877 field.SetProperty( TextField::Property::INPUT_OUTLINE, "Outline input properties" );
878 DALI_TEST_EQUALS( field.GetProperty<std::string>( TextField::Property::INPUT_OUTLINE ), std::string("Outline input properties"), TEST_LOCATION );
880 // Check the hidden input settings property
881 Property::Map hiddenMapSet;
882 Property::Map hiddenMapGet;
883 hiddenMapSet[ HiddenInput::Property::MODE ] = HiddenInput::Mode::HIDE_ALL;
884 hiddenMapSet[ HiddenInput::Property::SHOW_LAST_CHARACTER_DURATION ] = 2;
885 hiddenMapSet[ HiddenInput::Property::SUBSTITUTE_COUNT ] = 4;
886 hiddenMapSet[ HiddenInput::Property::SUBSTITUTE_CHARACTER ] = 0x23;
887 field.SetProperty( TextField::Property::HIDDEN_INPUT_SETTINGS, hiddenMapSet );
889 hiddenMapGet = field.GetProperty<Property::Map>( TextField::Property::HIDDEN_INPUT_SETTINGS );
890 DALI_TEST_EQUALS( hiddenMapSet.Count(), hiddenMapGet.Count(), TEST_LOCATION );
891 DALI_TEST_EQUALS( DaliTestCheckMaps( hiddenMapSet, hiddenMapGet ), true, TEST_LOCATION );
893 // Check the pixel size of font
894 field.SetProperty( TextField::Property::PIXEL_SIZE, 20.f );
895 DALI_TEST_EQUALS( field.GetProperty<float>( TextField::Property::PIXEL_SIZE ), 20.f, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
897 // Check the enable selection property
898 field.SetProperty( TextField::Property::ENABLE_SELECTION, false );
899 DALI_TEST_EQUALS( field.GetProperty<bool>( TextField::Property::ENABLE_SELECTION ), false, TEST_LOCATION );
901 // Check the placeholder property with pixel size
902 Property::Map placeholderPixelSizeMapSet;
903 Property::Map placeholderPixelSizeMapGet;
904 Property::Map placeholderFontstyleMap;
905 placeholderPixelSizeMapSet["text"] = "Setting Placeholder Text";
906 placeholderPixelSizeMapSet["textFocused"] = "Setting Placeholder Text Focused";
907 placeholderPixelSizeMapSet["color"] = Color::BLUE;
908 placeholderPixelSizeMapSet["fontFamily"] = "Arial";
909 placeholderPixelSizeMapSet["pixelSize"] = 15.0f;
910 placeholderPixelSizeMapSet["ellipsis"] = true;
912 placeholderFontstyleMap.Insert( "weight", "bold" );
913 placeholderPixelSizeMapSet["placeholderFontStyle"] = placeholderFontstyleMap;
914 field.SetProperty( TextField::Property::PLACEHOLDER, placeholderPixelSizeMapSet );
916 placeholderPixelSizeMapGet = field.GetProperty<Property::Map>( TextField::Property::PLACEHOLDER );
917 DALI_TEST_EQUALS( placeholderPixelSizeMapGet.Count(), placeholderPixelSizeMapSet.Count(), TEST_LOCATION );
919 tet_infoline("Test Placeholder settings set as strings is converted correctly to Property Index key and holds set value");
920 Property::Map placeholderConversionMap;
921 placeholderConversionMap[ Text::PlaceHolder::Property::TEXT ] = placeholderPixelSizeMapSet["text"];
922 placeholderConversionMap[ Text::PlaceHolder::Property::TEXT_FOCUSED ] = placeholderPixelSizeMapSet["textFocused"] ;
923 placeholderConversionMap[ Text::PlaceHolder::Property::COLOR ] = placeholderPixelSizeMapSet["color"];
924 placeholderConversionMap[ Text::PlaceHolder::Property::FONT_STYLE ] = placeholderPixelSizeMapSet["fontStyle"];
925 placeholderConversionMap[ Text::PlaceHolder::Property::FONT_FAMILY ] = placeholderPixelSizeMapSet["fontFamily"];
926 placeholderConversionMap[ Text::PlaceHolder::Property::PIXEL_SIZE ] = placeholderPixelSizeMapSet["pixelSize"];
928 DALI_TEST_EQUALS( DaliTestCheckMaps( placeholderPixelSizeMapGet, placeholderConversionMap ), true, TEST_LOCATION );
930 // Check the placeholder property with point size
931 Property::Map placeholderMapSet;
932 Property::Map placeholderMapGet;
933 placeholderMapSet["text"] = "Setting Placeholder Text";
934 placeholderMapSet["textFocused"] = "Setting Placeholder Text Focused";
935 placeholderMapSet["color"] = Color::RED;
936 placeholderMapSet["fontFamily"] = "Arial";
937 placeholderMapSet["pointSize"] = 12.0f;
938 placeholderMapSet["ellipsis"] = false;
940 // Check the placeholder font style property
941 placeholderFontstyleMap.Clear();
943 placeholderFontstyleMap.Insert( "weight", "bold" );
944 placeholderFontstyleMap.Insert( "width", "condensed" );
945 placeholderFontstyleMap.Insert( "slant", "italic" );
946 placeholderMapSet["fontStyle"] = placeholderFontstyleMap;
947 field.SetProperty( TextField::Property::PLACEHOLDER, placeholderMapSet );
949 placeholderMapGet = field.GetProperty<Property::Map>( TextField::Property::PLACEHOLDER );
950 DALI_TEST_EQUALS( placeholderMapGet.Count(), placeholderMapSet.Count(), TEST_LOCATION );
952 placeholderConversionMap.Clear();
953 placeholderConversionMap[ Text::PlaceHolder::Property::TEXT ] = placeholderPixelSizeMapSet["text"];
954 placeholderConversionMap[ Text::PlaceHolder::Property::TEXT_FOCUSED ] = placeholderPixelSizeMapSet["textFocused"] ;
955 placeholderConversionMap[ Text::PlaceHolder::Property::COLOR ] = placeholderPixelSizeMapSet["color"];
956 placeholderConversionMap[ Text::PlaceHolder::Property::FONT_STYLE ] = placeholderPixelSizeMapSet["fontStyle"];
957 placeholderConversionMap[ Text::PlaceHolder::Property::FONT_FAMILY ] = placeholderPixelSizeMapSet["fontFamily"];
958 placeholderConversionMap[ Text::PlaceHolder::Property::POINT_SIZE ] = placeholderPixelSizeMapSet["pointSize"];
960 DALI_TEST_EQUALS( DaliTestCheckMaps( placeholderMapGet, placeholderConversionMap ), true, TEST_LOCATION );
963 placeholderFontstyleMap.Clear();
964 placeholderFontstyleMap.Insert( "weight", "normal" );
965 placeholderFontstyleMap.Insert( "slant", "oblique" );
966 placeholderMapSet["fontStyle"] = placeholderFontstyleMap;
967 field.SetProperty( TextField::Property::PLACEHOLDER, placeholderMapSet );
969 placeholderMapGet = field.GetProperty<Property::Map>( TextField::Property::PLACEHOLDER );
970 DALI_TEST_EQUALS( placeholderMapGet.Count(), placeholderMapSet.Count(), TEST_LOCATION );
972 placeholderConversionMap[ Text::PlaceHolder::Property::FONT_STYLE ] = placeholderPixelSizeMapSet["fontStyle"];
973 DALI_TEST_EQUALS( DaliTestCheckMaps( placeholderMapGet, placeholderConversionMap ), true, TEST_LOCATION );
975 placeholderFontstyleMap.Clear();
976 placeholderFontstyleMap.Insert( "slant", "roman" );
977 placeholderMapSet["fontStyle"] = placeholderFontstyleMap;
978 placeholderConversionMap[ Text::PlaceHolder::Property::FONT_STYLE ] = placeholderPixelSizeMapSet["fontStyle"];
980 field.SetProperty( TextField::Property::PLACEHOLDER, placeholderMapSet );
982 placeholderMapGet = field.GetProperty<Property::Map>( TextField::Property::PLACEHOLDER );
984 placeholderFontstyleMap.Clear();
985 placeholderMapSet["fontStyle"] = placeholderFontstyleMap;
986 placeholderConversionMap[ Text::PlaceHolder::Property::FONT_STYLE ] = placeholderPixelSizeMapSet["fontStyle"];
988 field.SetProperty( TextField::Property::PLACEHOLDER, placeholderMapSet );
989 placeholderMapGet = field.GetProperty<Property::Map>( TextField::Property::PLACEHOLDER );
990 DALI_TEST_EQUALS( placeholderMapGet.Count(), placeholderMapSet.Count(), TEST_LOCATION );
992 DALI_TEST_EQUALS( DaliTestCheckMaps( placeholderMapGet, placeholderConversionMap ), true, TEST_LOCATION );
994 // Check the ellipsis property
995 DALI_TEST_CHECK( !field.GetProperty<bool>( TextField::Property::ELLIPSIS ) );
996 field.SetProperty( TextField::Property::ELLIPSIS, true );
997 DALI_TEST_CHECK( field.GetProperty<bool>( TextField::Property::ELLIPSIS ) );
999 field.SetProperty( Actor::Property::LAYOUT_DIRECTION, LayoutDirection::RIGHT_TO_LEFT );
1000 DALI_TEST_EQUALS( field.GetProperty<int>( Actor::Property::LAYOUT_DIRECTION ), static_cast<int>( LayoutDirection::RIGHT_TO_LEFT ), TEST_LOCATION );
1002 application.SendNotification();
1003 application.Render();
1008 // Positive Atlas Text Renderer test
1009 int utcDaliTextFieldAtlasRenderP(void)
1011 ToolkitTestApplication application;
1012 tet_infoline(" UtcDaliToolkitTextFieldAtlasRenderP");
1013 StyleManager styleManager = StyleManager::Get();
1014 styleManager.ApplyDefaultTheme();
1015 TextField field = TextField::New();
1016 DALI_TEST_CHECK( field );
1018 field.SetProperty( TextField::Property::HORIZONTAL_ALIGNMENT, "CENTER" );
1020 application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
1022 Stage::GetCurrent().Add( field );
1026 // Render some text with the shared atlas backend
1027 field.SetProperty( TextField::Property::RENDERING_BACKEND, Text::RENDERING_SHARED_ATLAS );
1028 application.SendNotification();
1029 application.Render();
1033 tet_result(TET_FAIL);
1038 // Positive test for the textChanged signal.
1039 int utcDaliTextFieldTextChangedP(void)
1041 ToolkitTestApplication application;
1042 tet_infoline(" utcDaliTextFieldTextChangedP");
1043 TextField field = TextField::New();
1044 DALI_TEST_CHECK( field );
1046 Stage::GetCurrent().Add( field );
1048 // connect to the text changed signal.
1049 ConnectionTracker* testTracker = new ConnectionTracker();
1050 field.TextChangedSignal().Connect(&TestTextChangedCallback);
1051 bool textChangedSignal = false;
1052 field.ConnectSignal( testTracker, "textChanged", CallbackFunctor(&textChangedSignal) );
1054 gTextChangedCallBackCalled = false;
1055 field.SetProperty( TextField::Property::TEXT, "ABC" );
1056 DALI_TEST_CHECK( gTextChangedCallBackCalled );
1057 DALI_TEST_CHECK( textChangedSignal );
1059 application.SendNotification();
1061 field.SetKeyInputFocus();
1063 gTextChangedCallBackCalled = false;
1064 application.ProcessEvent( GenerateKey( "D", "D", KEY_D_CODE, 0, 0, Integration::KeyEvent::Down, DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
1065 DALI_TEST_CHECK( gTextChangedCallBackCalled );
1070 // Negative test for the textChanged signal.
1071 int utcDaliTextFieldTextChangedN(void)
1073 ToolkitTestApplication application;
1074 tet_infoline(" utcDaliTextFieldTextChangedN");
1075 TextField field = TextField::New();
1076 DALI_TEST_CHECK( field );
1078 Stage::GetCurrent().Add( field );
1080 // connect to the text changed signal.
1081 ConnectionTracker* testTracker = new ConnectionTracker();
1082 field.TextChangedSignal().Connect(&TestTextChangedCallback);
1083 bool textChangedSignal = false;
1084 field.ConnectSignal( testTracker, "textChanged", CallbackFunctor(&textChangedSignal) );
1086 gTextChangedCallBackCalled = false;
1087 field.SetProperty( TextField::Property::PLACEHOLDER_TEXT, "ABC" ); // Setting placeholder, not TEXT
1088 DALI_TEST_CHECK( !gTextChangedCallBackCalled );
1089 DALI_TEST_CHECK( !textChangedSignal );
1094 // Positive test for Max Characters reached signal.
1095 int utcDaliTextFieldMaxCharactersReachedP(void)
1097 ToolkitTestApplication application;
1098 tet_infoline(" utcDaliTextFieldMaxCharactersReachedP");
1099 TextField field = TextField::New();
1100 DALI_TEST_CHECK( field );
1102 Stage::GetCurrent().Add( field );
1104 const int maxNumberOfCharacters = 1;
1105 field.SetProperty( TextField::Property::MAX_LENGTH, maxNumberOfCharacters );
1107 field.SetKeyInputFocus();
1109 // connect to the text changed signal.
1110 ConnectionTracker* testTracker = new ConnectionTracker();
1111 field.MaxLengthReachedSignal().Connect(&TestMaxLengthReachedCallback);
1112 bool maxLengthReachedSignal = false;
1113 field.ConnectSignal( testTracker, "maxLengthReached", CallbackFunctor(&maxLengthReachedSignal) );
1115 gMaxCharactersCallBackCalled = false;
1117 application.ProcessEvent( GenerateKey( "a", "a", KEY_A_CODE, 0, 0, Integration::KeyEvent::Down, DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
1118 application.ProcessEvent( GenerateKey( "a", "a", KEY_A_CODE, 0, 0, Integration::KeyEvent::Down, DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
1120 DALI_TEST_CHECK( gMaxCharactersCallBackCalled );
1121 DALI_TEST_CHECK( maxLengthReachedSignal );
1126 // Negative test for Max Characters reached signal.
1127 int utcDaliTextFieldMaxCharactersReachedN(void)
1129 ToolkitTestApplication application;
1130 tet_infoline(" utcDaliTextFieldMaxCharactersReachedN");
1131 TextField field = TextField::New();
1132 DALI_TEST_CHECK( field );
1134 Stage::GetCurrent().Add( field );
1136 const int maxNumberOfCharacters = 3;
1137 field.SetProperty( TextField::Property::MAX_LENGTH, maxNumberOfCharacters );
1139 field.SetKeyInputFocus();
1141 // connect to the text changed signal.
1142 ConnectionTracker* testTracker = new ConnectionTracker();
1143 field.MaxLengthReachedSignal().Connect(&TestMaxLengthReachedCallback);
1144 bool maxLengthReachedSignal = false;
1145 field.ConnectSignal( testTracker, "maxLengthReached", CallbackFunctor(&maxLengthReachedSignal) );
1147 gMaxCharactersCallBackCalled = false;
1149 application.ProcessEvent( GenerateKey( "a", "a", KEY_A_CODE, 0, 0, Integration::KeyEvent::Down, DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
1150 application.ProcessEvent( GenerateKey( "a", "a", KEY_A_CODE, 0, 0, Integration::KeyEvent::Down, DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
1152 DALI_TEST_CHECK( !gMaxCharactersCallBackCalled );
1153 DALI_TEST_CHECK( !maxLengthReachedSignal );
1158 int utcDaliTextFieldInputStyleChanged01(void)
1160 ToolkitTestApplication application;
1161 tet_infoline(" utcDaliTextFieldInputStyleChanged01");
1163 // The text-field emits signals when the input style changes. These changes of style are
1164 // detected during the relayout process (size negotiation), i.e after the cursor has been moved. Signals
1165 // can't be emitted during the size negotiation as the callbacks may update the UI.
1166 // The text-field adds an idle callback to the adaptor to emit the signals after the size negotiation.
1167 // This creates an implementation of the adaptor stub and a queue of idle callbacks.
1168 application.CreateAdaptor();
1172 char* pathNamePtr = get_current_dir_name();
1173 const std::string pathName( pathNamePtr );
1174 free( pathNamePtr );
1176 TextAbstraction::FontClient fontClient = TextAbstraction::FontClient::Get();
1177 fontClient.SetDpi( 93u, 93u );
1179 fontClient.GetFontId( pathName + DEFAULT_FONT_DIR + "/dejavu/DejaVuSerif.ttf", DEFAULT_FONT_SIZE );
1180 fontClient.GetFontId( pathName + DEFAULT_FONT_DIR + "/dejavu/DejaVuSerif-Bold.ttf", DEFAULT_FONT_SIZE );
1182 TextField field = TextField::New();
1183 DALI_TEST_CHECK( field );
1186 field.SetSize( 300.f, 50.f );
1187 field.SetParentOrigin( ParentOrigin::TOP_LEFT );
1188 field.SetAnchorPoint( AnchorPoint::TOP_LEFT );
1190 field.SetProperty( TextField::Property::ENABLE_MARKUP, true );
1191 field.SetProperty( TextField::Property::TEXT, "<font family='DejaVuSerif' size='18'>He<color value='green'>llo</color> <font weight='bold'>world</font> demo</font>" );
1193 // connect to the text changed signal.
1194 ConnectionTracker* testTracker = new ConnectionTracker();
1195 field.InputStyleChangedSignal().Connect( &TestInputStyleChangedCallback );
1196 bool inputStyleChangedSignal = false;
1197 field.ConnectSignal( testTracker, "inputStyleChanged", CallbackFunctor(&inputStyleChangedSignal) );
1199 Stage::GetCurrent().Add( field );
1201 // Render and notify
1202 application.SendNotification();
1203 application.Render();
1205 // Executes the idle callbacks added by the text control on the change of input style.
1206 application.RunIdles();
1208 gInputStyleChangedCallbackCalled = false;
1209 gInputStyleMask = TextField::InputStyle::NONE;
1210 inputStyleChangedSignal = false;
1212 // Create a tap event to touch the text field.
1213 application.ProcessEvent( GenerateTap( Gesture::Possible, 1u, 1u, Vector2( 18.f, 25.f ) ) );
1214 application.ProcessEvent( GenerateTap( Gesture::Started, 1u, 1u, Vector2( 18.f, 25.f ) ) );
1216 // Render and notify
1217 application.SendNotification();
1218 application.Render();
1220 // Executes the idle callbacks added by the text control on the change of input style.
1221 application.RunIdles();
1223 DALI_TEST_CHECK( gInputStyleChangedCallbackCalled );
1224 if( gInputStyleChangedCallbackCalled )
1226 DALI_TEST_EQUALS( static_cast<unsigned int>( gInputStyleMask ), static_cast<unsigned int>( TextField::InputStyle::FONT_FAMILY | TextField::InputStyle::POINT_SIZE ), TEST_LOCATION );
1228 const std::string fontFamily = field.GetProperty( TextField::Property::INPUT_FONT_FAMILY ).Get<std::string>();
1229 DALI_TEST_EQUALS( fontFamily, "DejaVuSerif", TEST_LOCATION );
1231 const float pointSize = field.GetProperty( TextField::Property::INPUT_POINT_SIZE ).Get<float>();
1232 DALI_TEST_EQUALS( pointSize, 18.f, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
1234 DALI_TEST_CHECK( inputStyleChangedSignal );
1236 gInputStyleChangedCallbackCalled = false;
1237 gInputStyleMask = TextField::InputStyle::NONE;
1238 inputStyleChangedSignal = false;
1240 // Create a tap event to touch the text field.
1241 application.ProcessEvent( GenerateTap( Gesture::Possible, 1u, 1u, Vector2( 30.f, 25.f ) ) );
1242 application.ProcessEvent( GenerateTap( Gesture::Started, 1u, 1u, Vector2( 30.f, 25.f ) ) );
1244 // Render and notify
1245 application.SendNotification();
1246 application.Render();
1248 // Executes the idle callbacks added by the text control on the change of input style.
1249 application.RunIdles();
1251 DALI_TEST_CHECK( !gInputStyleChangedCallbackCalled );
1252 DALI_TEST_CHECK( !inputStyleChangedSignal );
1254 gInputStyleChangedCallbackCalled = false;
1255 gInputStyleMask = TextField::InputStyle::NONE;
1256 inputStyleChangedSignal = false;
1258 // Create a tap event to touch the text field.
1259 application.ProcessEvent( GenerateTap( Gesture::Possible, 1u, 1u, Vector2( 43.f, 25.f ) ) );
1260 application.ProcessEvent( GenerateTap( Gesture::Started, 1u, 1u, Vector2( 43.f, 25.f ) ) );
1262 // Render and notify
1263 application.SendNotification();
1264 application.Render();
1266 // Executes the idle callbacks added by the text control on the change of input style.
1267 application.RunIdles();
1269 DALI_TEST_CHECK( gInputStyleChangedCallbackCalled );
1270 if( gInputStyleChangedCallbackCalled )
1272 DALI_TEST_EQUALS( static_cast<unsigned int>( gInputStyleMask ), static_cast<unsigned int>( TextField::InputStyle::COLOR ), TEST_LOCATION );
1274 const Vector4 color = field.GetProperty( TextField::Property::INPUT_COLOR ).Get<Vector4>();
1275 DALI_TEST_EQUALS( color, Color::GREEN, TEST_LOCATION );
1277 DALI_TEST_CHECK( inputStyleChangedSignal );
1279 gInputStyleChangedCallbackCalled = false;
1280 gInputStyleMask = TextField::InputStyle::NONE;
1281 inputStyleChangedSignal = false;
1283 // Create a tap event to touch the text field.
1284 application.ProcessEvent( GenerateTap( Gesture::Possible, 1u, 1u, Vector2( 88.f, 25.f ) ) );
1285 application.ProcessEvent( GenerateTap( Gesture::Started, 1u, 1u, Vector2( 88.f, 25.f ) ) );
1287 // Render and notify
1288 application.SendNotification();
1289 application.Render();
1291 // Executes the idle callbacks added by the text control on the change of input style.
1292 application.RunIdles();
1294 DALI_TEST_CHECK( gInputStyleChangedCallbackCalled );
1295 if( gInputStyleChangedCallbackCalled )
1297 DALI_TEST_EQUALS( static_cast<unsigned int>( gInputStyleMask ), static_cast<unsigned int>( TextField::InputStyle::COLOR | TextField::InputStyle::FONT_STYLE ), TEST_LOCATION );
1299 const Vector4 color = field.GetProperty( TextField::Property::INPUT_COLOR ).Get<Vector4>();
1300 DALI_TEST_EQUALS( color, Color::BLACK, TEST_LOCATION );
1302 const Property::Map fontStyleMapGet = field.GetProperty( TextField::Property::INPUT_FONT_STYLE ).Get<Property::Map>();
1304 Property::Map fontStyleMapSet;
1305 fontStyleMapSet.Insert( "weight", "bold" );
1307 DALI_TEST_EQUALS( fontStyleMapGet.Count(), fontStyleMapSet.Count(), TEST_LOCATION );
1308 DALI_TEST_EQUALS( DaliTestCheckMaps( fontStyleMapGet, fontStyleMapSet ), true, TEST_LOCATION );
1310 DALI_TEST_CHECK( inputStyleChangedSignal );
1312 gInputStyleChangedCallbackCalled = false;
1313 gInputStyleMask = TextField::InputStyle::NONE;
1314 inputStyleChangedSignal = false;
1316 // Create a tap event to touch the text field.
1317 application.ProcessEvent( GenerateTap( Gesture::Possible, 1u, 1u, Vector2( 115.f, 25.f ) ) );
1318 application.ProcessEvent( GenerateTap( Gesture::Started, 1u, 1u, Vector2( 115.f, 25.f ) ) );
1320 // Render and notify
1321 application.SendNotification();
1322 application.Render();
1324 // Executes the idle callbacks added by the text control on the change of input style.
1325 application.RunIdles();
1327 DALI_TEST_CHECK( !gInputStyleChangedCallbackCalled );
1328 DALI_TEST_CHECK( !inputStyleChangedSignal );
1330 gInputStyleChangedCallbackCalled = false;
1331 gInputStyleMask = TextField::InputStyle::NONE;
1332 inputStyleChangedSignal = false;
1334 // Create a tap event to touch the text field.
1335 application.ProcessEvent( GenerateTap( Gesture::Possible, 1u, 1u, Vector2( 164.f, 25.f ) ) );
1336 application.ProcessEvent( GenerateTap( Gesture::Started, 1u, 1u, Vector2( 164.f, 25.f ) ) );
1338 // Render and notify
1339 application.SendNotification();
1340 application.Render();
1342 // Executes the idle callbacks added by the text control on the change of input style.
1343 application.RunIdles();
1345 DALI_TEST_CHECK( gInputStyleChangedCallbackCalled );
1346 if( gInputStyleChangedCallbackCalled )
1348 DALI_TEST_EQUALS( static_cast<unsigned int>( gInputStyleMask ), static_cast<unsigned int>( TextField::InputStyle::FONT_STYLE ), TEST_LOCATION );
1350 const std::string style = field.GetProperty( TextField::Property::INPUT_FONT_STYLE ).Get<std::string>();
1351 DALI_TEST_CHECK( style.empty() );
1353 DALI_TEST_CHECK( inputStyleChangedSignal );
1355 gInputStyleChangedCallbackCalled = false;
1356 gInputStyleMask = TextField::InputStyle::NONE;
1357 inputStyleChangedSignal = false;
1359 // Create a tap event to touch the text field.
1360 application.ProcessEvent( GenerateTap( Gesture::Possible, 1u, 1u, Vector2( 191.f, 25.f ) ) );
1361 application.ProcessEvent( GenerateTap( Gesture::Started, 1u, 1u, Vector2( 191.f, 25.f ) ) );
1363 // Render and notify
1364 application.SendNotification();
1365 application.Render();
1367 // Executes the idle callbacks added by the text control on the change of input style.
1368 application.RunIdles();
1370 DALI_TEST_CHECK( !gInputStyleChangedCallbackCalled );
1371 DALI_TEST_CHECK( !inputStyleChangedSignal );
1376 int utcDaliTextFieldInputStyleChanged02(void)
1378 ToolkitTestApplication application;
1379 tet_infoline(" utcDaliTextFieldInputStyleChanged02");
1381 // The text-field emits signals when the input style changes. These changes of style are
1382 // detected during the relayout process (size negotiation), i.e after the cursor has been moved. Signals
1383 // can't be emitted during the size negotiation as the callbacks may update the UI.
1384 // The text-field adds an idle callback to the adaptor to emit the signals after the size negotiation.
1385 // This creates an implementation of the adaptor stub and a queue of idle callbacks.
1386 application.CreateAdaptor();
1390 char* pathNamePtr = get_current_dir_name();
1391 const std::string pathName( pathNamePtr );
1392 free( pathNamePtr );
1394 TextAbstraction::FontClient fontClient = TextAbstraction::FontClient::Get();
1395 fontClient.SetDpi( 93u, 93u );
1397 fontClient.GetFontId( pathName + DEFAULT_FONT_DIR + "/dejavu/DejaVuSerif.ttf", DEFAULT_FONT_SIZE );
1398 fontClient.GetFontId( pathName + DEFAULT_FONT_DIR + "/dejavu/DejaVuSerif-Bold.ttf", DEFAULT_FONT_SIZE );
1400 TextField field = TextField::New();
1401 DALI_TEST_CHECK( field );
1404 field.SetSize( 300.f, 50.f );
1405 field.SetParentOrigin( ParentOrigin::TOP_LEFT );
1406 field.SetAnchorPoint( AnchorPoint::TOP_LEFT );
1408 field.SetProperty( TextField::Property::ENABLE_MARKUP, true );
1409 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>" );
1411 // connect to the text changed signal.
1412 ConnectionTracker* testTracker = new ConnectionTracker();
1413 field.InputStyleChangedSignal().Connect( &TestInputStyleChangedCallback );
1414 bool inputStyleChangedSignal = false;
1415 field.ConnectSignal( testTracker, "inputStyleChanged", CallbackFunctor(&inputStyleChangedSignal) );
1417 Stage::GetCurrent().Add( field );
1419 // Render and notify
1420 application.SendNotification();
1421 application.Render();
1423 // Executes the idle callbacks added by the text control on the change of input style.
1424 application.RunIdles();
1426 gInputStyleChangedCallbackCalled = false;
1427 gInputStyleMask = TextField::InputStyle::NONE;
1428 inputStyleChangedSignal = false;
1430 // Create a tap event to touch the text field.
1431 application.ProcessEvent( GenerateTap( Gesture::Possible, 1u, 1u, Vector2( 53.f, 25.f ) ) );
1432 application.ProcessEvent( GenerateTap( Gesture::Started, 1u, 1u, Vector2( 53.f, 25.f ) ) );
1433 application.ProcessEvent( GenerateTap( Gesture::Possible, 2u, 1u, Vector2( 53.f, 25.f ) ) );
1434 application.ProcessEvent( GenerateTap( Gesture::Started, 2u, 1u, Vector2( 53.f, 25.f ) ) );
1436 // Render and notify
1437 application.SendNotification();
1438 application.Render();
1440 // Executes the idle callbacks added by the text control on the change of input style.
1441 application.RunIdles();
1443 DALI_TEST_CHECK( gInputStyleChangedCallbackCalled );
1444 if( gInputStyleChangedCallbackCalled )
1446 DALI_TEST_EQUALS( static_cast<unsigned int>( gInputStyleMask ),
1447 static_cast<unsigned int>( TextField::InputStyle::FONT_FAMILY |
1448 TextField::InputStyle::POINT_SIZE |
1449 TextField::InputStyle::COLOR ),
1452 const Vector4 color = field.GetProperty( TextField::Property::INPUT_COLOR ).Get<Vector4>();
1453 DALI_TEST_EQUALS( color, Color::GREEN, TEST_LOCATION );
1455 const std::string fontFamily = field.GetProperty( TextField::Property::INPUT_FONT_FAMILY ).Get<std::string>();
1456 DALI_TEST_EQUALS( fontFamily, "DejaVuSerif", TEST_LOCATION );
1458 const float pointSize = field.GetProperty( TextField::Property::INPUT_POINT_SIZE ).Get<float>();
1459 DALI_TEST_EQUALS( pointSize, 18.f, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
1461 DALI_TEST_CHECK( inputStyleChangedSignal );
1463 gInputStyleChangedCallbackCalled = false;
1464 gInputStyleMask = TextField::InputStyle::NONE;
1465 inputStyleChangedSignal = false;
1467 application.ProcessEvent( GenerateKey( "", "", DALI_KEY_BACKSPACE, 0, 0, Integration::KeyEvent::Down, DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
1469 // Render and notify
1470 application.SendNotification();
1471 application.Render();
1473 // Executes the idle callbacks added by the text control on the change of input style.
1474 application.RunIdles();
1476 DALI_TEST_CHECK( gInputStyleChangedCallbackCalled );
1477 if( gInputStyleChangedCallbackCalled )
1479 DALI_TEST_EQUALS( static_cast<unsigned int>( gInputStyleMask ),
1480 static_cast<unsigned int>( TextField::InputStyle::COLOR ),
1483 const Vector4 color = field.GetProperty( TextField::Property::INPUT_COLOR ).Get<Vector4>();
1484 DALI_TEST_EQUALS( color, Color::BLUE, TEST_LOCATION );
1486 DALI_TEST_CHECK( inputStyleChangedSignal );
1488 gInputStyleChangedCallbackCalled = false;
1489 gInputStyleMask = TextField::InputStyle::NONE;
1490 inputStyleChangedSignal = false;
1492 application.ProcessEvent( GenerateKey( "", "", DALI_KEY_BACKSPACE, 0, 0, Integration::KeyEvent::Down, DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
1494 // Render and notify
1495 application.SendNotification();
1496 application.Render();
1498 // Executes the idle callbacks added by the text control on the change of input style.
1499 application.RunIdles();
1501 DALI_TEST_CHECK( !gInputStyleChangedCallbackCalled );
1502 DALI_TEST_CHECK( !inputStyleChangedSignal );
1504 gInputStyleChangedCallbackCalled = false;
1505 gInputStyleMask = TextField::InputStyle::NONE;
1506 inputStyleChangedSignal = false;
1508 application.ProcessEvent( GenerateKey( "", "", DALI_KEY_BACKSPACE, 0, 0, Integration::KeyEvent::Down, DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
1510 // Render and notify
1511 application.SendNotification();
1512 application.Render();
1514 // Executes the idle callbacks added by the text control on the change of input style.
1515 application.RunIdles();
1517 DALI_TEST_CHECK( gInputStyleChangedCallbackCalled );
1518 if( gInputStyleChangedCallbackCalled )
1520 DALI_TEST_EQUALS( static_cast<unsigned int>( gInputStyleMask ),
1521 static_cast<unsigned int>( TextField::InputStyle::COLOR ),
1524 const Vector4 color = field.GetProperty( TextField::Property::INPUT_COLOR ).Get<Vector4>();
1525 DALI_TEST_EQUALS( color, Color::BLACK, TEST_LOCATION );
1527 DALI_TEST_CHECK( inputStyleChangedSignal );
1529 gInputStyleChangedCallbackCalled = false;
1530 gInputStyleMask = TextField::InputStyle::NONE;
1531 inputStyleChangedSignal = false;
1533 field.SetProperty( TextField::Property::INPUT_COLOR, Color::YELLOW );
1535 Property::Map fontStyleMapSet;
1536 fontStyleMapSet.Insert( "weight", "thin" );
1537 fontStyleMapSet.Insert( "width", "condensed" );
1538 fontStyleMapSet.Insert( "slant", "italic" );
1540 field.SetProperty( TextField::Property::INPUT_FONT_STYLE, fontStyleMapSet );
1541 field.SetProperty( TextField::Property::INPUT_POINT_SIZE, 20.f );
1543 field.SetProperty( TextField::Property::INPUT_UNDERLINE, "underline" );
1544 field.SetProperty( TextField::Property::INPUT_SHADOW, "shadow" );
1545 field.SetProperty( TextField::Property::INPUT_EMBOSS, "emboss" );
1546 field.SetProperty( TextField::Property::INPUT_OUTLINE, "outline" );
1548 // Render and notify
1549 application.SendNotification();
1550 application.Render();
1552 // Executes the idle callbacks added by the text control on the change of input style.
1553 application.RunIdles();
1555 DALI_TEST_CHECK( !gInputStyleChangedCallbackCalled );
1556 DALI_TEST_CHECK( !inputStyleChangedSignal );
1558 // Create a tap event to touch the text field.
1559 application.ProcessEvent( GenerateTap( Gesture::Possible, 1u, 1u, Vector2( 63.f, 25.f ) ) );
1560 application.ProcessEvent( GenerateTap( Gesture::Started, 1u, 1u, Vector2( 63.f, 25.f ) ) );
1562 // Render and notify
1563 application.SendNotification();
1564 application.Render();
1566 // Executes the idle callbacks added by the text control on the change of input style.
1567 application.RunIdles();
1569 DALI_TEST_CHECK( gInputStyleChangedCallbackCalled );
1570 if( gInputStyleChangedCallbackCalled )
1572 DALI_TEST_EQUALS( static_cast<unsigned int>( gInputStyleMask ),
1573 static_cast<unsigned int>( TextField::InputStyle::COLOR |
1574 TextField::InputStyle::POINT_SIZE |
1575 TextField::InputStyle::FONT_STYLE |
1576 TextField::InputStyle::UNDERLINE |
1577 TextField::InputStyle::SHADOW |
1578 TextField::InputStyle::EMBOSS |
1579 TextField::InputStyle::OUTLINE ),
1582 const Vector4 color = field.GetProperty( TextField::Property::INPUT_COLOR ).Get<Vector4>();
1583 DALI_TEST_EQUALS( color, Color::BLACK, TEST_LOCATION );
1585 DALI_TEST_CHECK( inputStyleChangedSignal );
1590 int utcDaliTextFieldEvent01(void)
1592 ToolkitTestApplication application;
1593 tet_infoline(" utcDaliTextFieldEvent01");
1595 // Creates a tap event. After creating a tap event the text field should
1596 // have the focus and add text with key events should be possible.
1598 TextField field = TextField::New();
1599 DALI_TEST_CHECK( field );
1601 Stage::GetCurrent().Add( field );
1603 field.SetSize( 300.f, 50.f );
1604 field.SetParentOrigin( ParentOrigin::TOP_LEFT );
1605 field.SetAnchorPoint( AnchorPoint::TOP_LEFT );
1607 // Avoid a crash when core load gl resources.
1608 application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
1610 // Render and notify
1611 application.SendNotification();
1612 application.Render();
1614 // Add a key event but as the text field has not the focus it should do nothing.
1615 application.ProcessEvent( GenerateKey( "a", "a", KEY_A_CODE, 0, 0, Integration::KeyEvent::Down, DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
1617 // Render and notify
1618 application.SendNotification();
1619 application.Render();
1621 DALI_TEST_EQUALS( field.GetProperty<std::string>( TextField::Property::TEXT ), std::string(""), TEST_LOCATION );
1623 // Create a tap event to touch the text field.
1624 application.ProcessEvent( GenerateTap( Gesture::Possible, 1u, 1u, Vector2( 150.0f, 25.0f ) ) );
1625 application.ProcessEvent( GenerateTap( Gesture::Started, 1u, 1u, Vector2( 150.0f, 25.0f ) ) );
1627 // Render and notify
1628 application.SendNotification();
1629 application.Render();
1631 // Now the text field has the focus, so it can handle the key events.
1632 application.ProcessEvent( GenerateKey( "a", "a", KEY_A_CODE, 0, 0, Integration::KeyEvent::Down, DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
1633 application.ProcessEvent( GenerateKey( "a", "a", KEY_A_CODE, 0, 0, Integration::KeyEvent::Down, DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
1635 // Render and notify
1636 application.SendNotification();
1637 application.Render();
1639 DALI_TEST_EQUALS( field.GetProperty<std::string>( TextField::Property::TEXT ), std::string("aa"), TEST_LOCATION );
1641 // Create a second text field and send key events to it.
1642 TextField field2 = TextField::New();
1644 field2.SetParentOrigin( ParentOrigin::TOP_LEFT );
1645 field2.SetAnchorPoint( AnchorPoint::TOP_LEFT );
1646 field2.SetSize( 100.f, 100.f );
1647 field2.SetPosition( 100.f, 100.f );
1649 Stage::GetCurrent().Add( field2 );
1651 // Render and notify
1652 application.SendNotification();
1653 application.Render();
1655 // Create a tap event on the second text field.
1656 application.ProcessEvent( GenerateTap( Gesture::Possible, 1u, 1u, Vector2( 150.0f, 125.0f ) ) );
1657 application.ProcessEvent( GenerateTap( Gesture::Started, 1u, 1u, Vector2( 150.0f, 125.0f ) ) );
1659 // Render and notify
1660 application.SendNotification();
1661 application.Render();
1663 // The second text field has the focus. It should handle the key events.
1664 application.ProcessEvent( GenerateKey( "a", "a", KEY_A_CODE, 0, 0, Integration::KeyEvent::Down, DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
1665 application.ProcessEvent( GenerateKey( "a", "a", KEY_A_CODE, 0, 0, Integration::KeyEvent::Down, DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
1667 // Render and notify
1668 application.SendNotification();
1669 application.Render();
1671 // Check the text has been added to the second text field.
1672 DALI_TEST_EQUALS( field2.GetProperty<std::string>( TextField::Property::TEXT ), std::string("aa"), TEST_LOCATION );
1677 int utcDaliTextFieldEvent02(void)
1679 ToolkitTestApplication application;
1680 tet_infoline(" utcDaliTextFieldEvent02");
1682 // Checks if the right number of actors are created.
1684 TextField field = TextField::New();
1685 field.SetProperty( TextField::Property::POINT_SIZE, 10.f );
1686 DALI_TEST_CHECK( field );
1687 LoadMarkerImages(application, field);
1689 Stage::GetCurrent().Add( field );
1691 field.SetSize( 300.f, 50.f );
1692 field.SetParentOrigin( ParentOrigin::TOP_LEFT );
1693 field.SetAnchorPoint( AnchorPoint::TOP_LEFT );
1695 // Avoid a crash when core load gl resources.
1696 application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
1698 // Render and notify
1699 application.SendNotification();
1700 application.Render();
1702 // Check there are the expected number of children ( stencil ).
1703 DALI_TEST_EQUALS( field.GetChildCount(), 1u, TEST_LOCATION );
1705 Actor stencil = field.GetChildAt( 0u );
1706 DALI_TEST_EQUALS( stencil.GetChildCount(), 0u, TEST_LOCATION );
1708 // Create a tap event to touch the text field.
1709 application.ProcessEvent( GenerateTap( Gesture::Possible, 1u, 1u, Vector2( 150.0f, 25.0f ) ) );
1710 application.ProcessEvent( GenerateTap( Gesture::Started, 1u, 1u, Vector2( 150.0f, 25.0f ) ) );
1712 // Render and notify
1713 application.SendNotification();
1714 application.Render();
1716 Actor layer = field.GetChildAt( 1u );
1717 DALI_TEST_CHECK( layer.IsLayer() );
1719 DALI_TEST_EQUALS( layer.GetChildCount(), 1u, TEST_LOCATION ); // The cursor.
1720 DALI_TEST_EQUALS( stencil.GetChildCount(), 0u, TEST_LOCATION );
1722 // Now the text field has the focus, so it can handle the key events.
1723 application.ProcessEvent( GenerateKey( "a", "a", KEY_A_CODE, 0, 0, Integration::KeyEvent::Down, DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
1724 application.ProcessEvent( GenerateKey( "a", "a", KEY_A_CODE, 0, 0, Integration::KeyEvent::Down, DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
1726 // Render and notify
1727 application.SendNotification();
1728 application.Render();
1730 // Checks the cursor and the renderer have been created.
1731 DALI_TEST_EQUALS( layer.GetChildCount(), 1u, TEST_LOCATION ); // The cursor.
1732 DALI_TEST_EQUALS( stencil.GetChildCount(), 1u, TEST_LOCATION ); // The renderer
1734 Control cursor = Control::DownCast( layer.GetChildAt( 0u ) );
1735 DALI_TEST_CHECK( cursor );
1737 // The offscreen root actor has a container with all the actors which contain the text renderers.
1738 Actor container = stencil.GetChildAt( 0u );
1739 for( unsigned int index = 0; index < container.GetChildCount(); ++index )
1741 Renderer renderer = container.GetChildAt( index ).GetRendererAt( 0u );
1742 DALI_TEST_CHECK( renderer );
1745 // Move the cursor and check the position changes.
1746 Vector3 position1 = cursor.GetCurrentPosition();
1748 application.ProcessEvent( GenerateKey( "", "", DALI_KEY_CURSOR_LEFT, 0, 0, Integration::KeyEvent::Down, DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
1749 application.ProcessEvent( GenerateKey( "", "", DALI_KEY_CURSOR_LEFT, 0, 0, Integration::KeyEvent::Down, DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
1751 // Render and notify
1752 application.SendNotification();
1753 application.Render();
1755 Vector3 position2 = cursor.GetCurrentPosition();
1757 DALI_TEST_CHECK( position2.x < position1.x );
1759 application.ProcessEvent( GenerateKey( "", "", DALI_KEY_CURSOR_RIGHT, 0, 0, Integration::KeyEvent::Down, DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
1760 application.ProcessEvent( GenerateKey( "", "", DALI_KEY_CURSOR_RIGHT, 0, 0, Integration::KeyEvent::Down, DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
1762 // Render and notify
1763 application.SendNotification();
1764 application.Render();
1766 Vector3 position3 = cursor.GetCurrentPosition();
1768 DALI_TEST_EQUALS( position1, position3, TEST_LOCATION ); // Should be in the same position1.
1770 // Send some taps and check the cursor positions.
1772 // Try to tap at the beginning.
1773 application.ProcessEvent( GenerateTap( Gesture::Possible, 1u, 1u, Vector2( 1.f, 25.0f ) ) );
1774 application.ProcessEvent( GenerateTap( Gesture::Started, 1u, 1u, Vector2( 1.f, 25.0f ) ) );
1776 // Render and notify
1777 application.SendNotification();
1778 application.Render();
1780 // Cursor position should be the same than position1.
1781 Vector3 position4 = cursor.GetCurrentPosition();
1783 DALI_TEST_EQUALS( position2, position4, TEST_LOCATION ); // Should be in the same position2.
1785 // Tap away from the start position.
1786 application.ProcessEvent( GenerateTap( Gesture::Possible, 1u, 1u, Vector2( 16.f, 25.0f ) ) );
1787 application.ProcessEvent( GenerateTap( Gesture::Started, 1u, 1u, Vector2( 16.0f, 25.0f ) ) );
1789 // Render and notify
1790 application.SendNotification();
1791 application.Render();
1793 Vector3 position5 = cursor.GetCurrentPosition();
1795 DALI_TEST_CHECK( position5.x > position4.x );
1797 // Remove all the text.
1798 application.ProcessEvent( GenerateKey( "", "", DALI_KEY_BACKSPACE, 0, 0, Integration::KeyEvent::Down, DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
1799 application.ProcessEvent( GenerateKey( "", "", DALI_KEY_BACKSPACE, 0, 0, Integration::KeyEvent::Down, DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
1800 field.SetProperty( TextField::Property::TEXT, "" );
1802 // Render and notify
1803 application.SendNotification();
1804 application.Render();
1806 // Cursor position should be the same than position2.
1807 Vector3 position6 = cursor.GetCurrentPosition();
1809 DALI_TEST_EQUALS( position2, position6, TEST_LOCATION );// Should be in the same position2.
1811 // Should not be a renderer.
1812 DALI_TEST_EQUALS( stencil.GetChildCount(), 0u, TEST_LOCATION );
1814 // Chanege exceed policy (EXCEED_POLICY_ORIGINAL doesn't use stencil )
1815 field.SetProperty( TextField::Property::TEXT, "This is a long text for the size of the text-field." );
1816 field.SetProperty( TextField::Property::EXCEED_POLICY, Dali::Toolkit::TextField::EXCEED_POLICY_ORIGINAL );
1818 application.SendNotification();
1819 application.Render();
1821 // There are renderer and decorator layer
1822 DALI_TEST_EQUALS( field.GetChildCount(), 2u, TEST_LOCATION );
1827 int utcDaliTextFieldEvent03(void)
1829 ToolkitTestApplication application;
1830 tet_infoline(" utcDaliTextFieldEvent03");
1832 // Checks if the highlight actor is created.
1834 TextField field = TextField::New();
1835 DALI_TEST_CHECK( field );
1837 Stage::GetCurrent().Add( field );
1839 field.SetProperty( TextField::Property::TEXT, "This is a long text for the size of the text-field." );
1840 field.SetProperty( TextField::Property::POINT_SIZE, 10.f );
1841 field.SetSize( 30.f, 50.f );
1842 field.SetParentOrigin( ParentOrigin::TOP_LEFT );
1843 field.SetAnchorPoint( AnchorPoint::TOP_LEFT );
1845 // Avoid a crash when core load gl resources.
1846 application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
1847 LoadMarkerImages(application, field);
1849 // Render and notify
1850 application.SendNotification();
1851 application.Render();
1853 // Tap first to get the focus.
1854 application.ProcessEvent( GenerateTap( Gesture::Possible, 1u, 1u, Vector2( 3.f, 25.0f ) ) );
1855 application.ProcessEvent( GenerateTap( Gesture::Started, 1u, 1u, Vector2( 3.f, 25.0f ) ) );
1857 // Render and notify
1858 application.SendNotification();
1859 application.Render();
1861 // Double tap to select a word.
1862 application.ProcessEvent( GenerateTap( Gesture::Possible, 2u, 1u, Vector2( 3.f, 25.0f ) ) );
1863 application.ProcessEvent( GenerateTap( Gesture::Started, 2u, 1u, Vector2( 3.f, 25.0f ) ) );
1865 // Render and notify
1866 application.SendNotification();
1867 application.Render();
1869 // The offscreen root actor should have two actors: the renderer and the highlight actor.
1870 Actor stencil = field.GetChildAt( 0u );
1872 // The highlight actor is drawn first, so is the first actor in the list
1873 Renderer highlight = stencil.GetChildAt( 0u ).GetRendererAt( 0u );
1874 DALI_TEST_CHECK( highlight );
1876 // The offscreen root actor has a container with all the actors which contain the text renderers.
1877 Actor container = stencil.GetChildAt( 1u );
1878 for( unsigned int index = 0; index < container.GetChildCount(); ++index )
1880 Renderer renderer = container.GetChildAt( index ).GetRendererAt( 0u );
1881 DALI_TEST_CHECK( renderer );
1887 int utcDaliTextFieldEvent04(void)
1889 ToolkitTestApplication application;
1890 tet_infoline(" utcDaliTextFieldEvent04");
1892 // Checks if the highlight actor is created.
1894 TextField field = TextField::New();
1895 DALI_TEST_CHECK( field );
1896 Stage::GetCurrent().Add( field );
1897 LoadMarkerImages(application, field);
1898 // Render and notify
1899 application.SendNotification();
1900 application.Render();
1902 field.SetProperty( TextField::Property::TEXT, "This is a long text for the size of the text-field." );
1903 field.SetProperty( TextField::Property::POINT_SIZE, 10.f );
1904 field.SetSize( 300.f, 50.f );
1905 field.SetParentOrigin( ParentOrigin::TOP_LEFT );
1906 field.SetAnchorPoint( AnchorPoint::TOP_LEFT );
1908 // Avoid a crash when core load gl resources.
1909 application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
1910 // Render and notify
1911 application.SendNotification();
1912 application.Render();
1914 // Create a tap event to touch the text field.
1915 application.ProcessEvent( GenerateTap( Gesture::Possible, 1u, 1u, Vector2( 150.0f, 25.0f ) ) );
1916 application.ProcessEvent( GenerateTap( Gesture::Started, 1u, 1u, Vector2( 150.0f, 25.0f ) ) );
1917 // Render and notify
1918 application.SendNotification();
1919 application.Render();
1922 // Tap first to get the focus.
1923 application.ProcessEvent( GenerateTap( Gesture::Possible, 1u, 1u, Vector2( 1.f, 25.0f ) ) );
1924 application.ProcessEvent( GenerateTap( Gesture::Started, 1u, 1u, Vector2( 1.f, 25.0f ) ) );
1926 // Render and notify
1927 application.SendNotification();
1928 application.Render();
1930 // Double tap to select a word.
1931 application.ProcessEvent( GenerateTap( Gesture::Possible, 2u, 1u, Vector2( 1.f, 25.0f ) ) );
1932 application.ProcessEvent( GenerateTap( Gesture::Started, 2u, 1u, Vector2( 1.f, 25.0f ) ) );
1934 // Render and notify
1935 application.SendNotification();
1936 application.Render();
1939 application.ProcessEvent( GenerateTap( Gesture::Possible, 1u, 1u, Vector2( 0.f, 40.0f ) ) );
1940 application.ProcessEvent( GenerateTap( Gesture::Started, 1u, 1u, Vector2( 0.f, 40.0f ) ) );
1944 int utcDaliTextFieldEvent05(void)
1946 ToolkitTestApplication application;
1947 tet_infoline(" utcDaliTextFieldEvent05");
1949 // Checks dragging of cursor/grab handle
1951 TextField field = TextField::New();
1952 DALI_TEST_CHECK( field );
1953 Stage::GetCurrent().Add( field );
1954 LoadMarkerImages(application, field);
1955 // Render and notify
1956 application.SendNotification();
1957 application.Render();
1959 field.SetProperty( TextField::Property::TEXT, "This is a long text for the size of the text-field." );
1960 field.SetProperty( TextField::Property::POINT_SIZE, 10.f );
1961 field.SetSize( 300.f, 50.f );
1962 field.SetParentOrigin( ParentOrigin::TOP_LEFT );
1963 field.SetAnchorPoint( AnchorPoint::TOP_LEFT );
1965 // Avoid a crash when core load gl resources.
1966 application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
1967 // Render and notify
1968 application.SendNotification();
1969 application.Render();
1971 // Create a tap event to touch the text field.
1972 application.ProcessEvent( GenerateTap( Gesture::Possible, 1u, 1u, Vector2( 150.0f, 25.0f ) ) );
1973 application.ProcessEvent( GenerateTap( Gesture::Started, 1u, 1u, Vector2( 150.0f, 25.0f ) ) );
1974 // Render and notify
1975 application.SendNotification();
1976 application.Render();
1979 // Tap first to get the focus.
1980 application.ProcessEvent( GenerateTap( Gesture::Possible, 1u, 1u, Vector2( 1.f, 25.0f ) ) );
1981 application.ProcessEvent( GenerateTap( Gesture::Started, 1u, 1u, Vector2( 1.f, 25.0f ) ) );
1983 // Render and notify
1984 application.SendNotification();
1985 application.Render();
1987 // Double tap to select a word.
1988 application.ProcessEvent( GenerateTap( Gesture::Possible, 2u, 1u, Vector2( 1.f, 25.0f ) ) );
1989 application.ProcessEvent( GenerateTap( Gesture::Started, 2u, 1u, Vector2( 1.f, 25.0f ) ) );
1991 // Render and notify
1992 application.SendNotification();
1993 application.Render();
1995 // drag grab handle right
1996 Vector2 pos(0.0f, 40.0f);
1997 SendPan(application, Gesture::Possible, pos);
1998 SendPan(application, Gesture::Started, pos);
2000 Wait(application, 100);
2002 for(int i = 0;i<20;i++)
2004 SendPan(application, Gesture::Continuing, pos);
2009 SendPan(application, Gesture::Finished, pos);
2010 Wait(application, RENDER_FRAME_INTERVAL);
2012 Actor stencil = field.GetChildAt( 1u );
2016 int utcDaliTextFieldEvent06(void)
2018 ToolkitTestApplication application;
2019 tet_infoline(" utcDaliTextFieldEvent06");
2021 // Checks Longpress when in edit mode
2023 TextField field = TextField::New();
2024 DALI_TEST_CHECK( field );
2025 Stage::GetCurrent().Add( field );
2026 LoadMarkerImages(application, field);
2027 // Render and notify
2028 application.SendNotification();
2029 application.Render();
2031 field.SetProperty( TextField::Property::TEXT, "Thisisalongtextforthesizeofthetextfield." );
2032 field.SetProperty( TextField::Property::POINT_SIZE, 10.f );
2033 field.SetSize( 300.f, 50.f );
2034 field.SetParentOrigin( ParentOrigin::TOP_LEFT );
2035 field.SetAnchorPoint( AnchorPoint::TOP_LEFT );
2037 // Avoid a crash when core load gl resources.
2038 application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
2039 // Render and notify
2040 application.SendNotification();
2041 application.Render();
2043 // Create a tap event to touch the text field.
2044 application.ProcessEvent( GenerateTap( Gesture::Possible, 1u, 1u, Vector2( 150.0f, 25.0f ) ) );
2045 application.ProcessEvent( GenerateTap( Gesture::Started, 1u, 1u, Vector2( 150.0f, 25.0f ) ) );
2046 // Render and notify
2047 application.SendNotification();
2048 application.Render();
2051 // Tap first to get the focus.
2052 application.ProcessEvent( GenerateTap( Gesture::Possible, 1u, 1u, Vector2( 1.f, 25.0f ) ) );
2053 application.ProcessEvent( GenerateTap( Gesture::Started, 1u, 1u, Vector2( 1.f, 25.0f ) ) );
2055 // Render and notify
2056 application.SendNotification();
2057 application.Render();
2060 application.ProcessEvent( GenerateLongPress( Gesture::Possible, 1u, Vector2( 1.f, 25.0f ) ) );
2061 application.ProcessEvent( GenerateLongPress( Gesture::Started, 1u, Vector2( 1.f, 25.0f ) ) );
2063 // Render and notify
2064 application.SendNotification();
2065 application.Render();
2070 int utcDaliTextFieldEvent07(void)
2072 ToolkitTestApplication application;
2073 tet_infoline(" utcDaliTextFieldEvent07");
2075 // Checks Longpress to start edit mode
2077 TextField field = TextField::New();
2078 DALI_TEST_CHECK( field );
2079 Stage::GetCurrent().Add( field );
2080 LoadMarkerImages(application, field);
2081 // Render and notify
2082 application.SendNotification();
2083 application.Render();
2085 field.SetProperty( TextField::Property::TEXT, "Thisisalongtextforthesizeofthetextfield." );
2086 field.SetProperty( TextField::Property::POINT_SIZE, 10.f );
2087 field.SetSize( 300.f, 50.f );
2088 field.SetParentOrigin( ParentOrigin::TOP_LEFT );
2089 field.SetAnchorPoint( AnchorPoint::TOP_LEFT );
2090 Property::Map propertyMap;
2091 propertyMap["PANEL_LAYOUT"] = InputMethod::PanelLayout::PASSWORD;
2092 field.SetProperty( TextField::Property::INPUT_METHOD_SETTINGS, propertyMap );
2094 // Avoid a crash when core load gl resources.
2095 application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
2096 // Render and notify
2097 application.SendNotification();
2098 application.Render();
2101 application.ProcessEvent( GenerateLongPress( Gesture::Possible, 1u, Vector2( 1.f, 25.0f ) ) );
2102 application.ProcessEvent( GenerateLongPress( Gesture::Started, 1u, Vector2( 1.f, 25.0f ) ) );
2104 // Render and notify
2105 application.SendNotification();
2106 application.Render();
2111 int utcDaliTextFieldEvent08(void)
2113 ToolkitTestApplication application;
2114 tet_infoline(" utcDaliTextFieldEvent08");
2116 Dali::Clipboard clipboard = Clipboard::Get();
2117 clipboard.SetItem("testTextFieldEvent");
2119 // Checks Longpress when only place holder text
2121 TextField field = TextField::New();
2122 DALI_TEST_CHECK( field );
2123 Stage::GetCurrent().Add( field );
2124 LoadMarkerImages(application, field);
2125 // Render and notify
2126 application.SendNotification();
2127 application.Render();
2129 field.SetProperty( TextField::Property::PLACEHOLDER_TEXT, "Setting Placeholder Text" );
2130 field.SetProperty( TextField::Property::POINT_SIZE, 10.f );
2131 field.SetSize( 300.f, 50.f );
2132 field.SetParentOrigin( ParentOrigin::TOP_LEFT );
2133 field.SetAnchorPoint( AnchorPoint::TOP_LEFT );
2135 // Avoid a crash when core load gl resources.
2136 application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
2137 // Render and notify
2138 application.SendNotification();
2139 application.Render();
2142 application.ProcessEvent( GenerateLongPress( Gesture::Possible, 1u, Vector2( 1.f, 25.0f ) ) );
2143 application.ProcessEvent( GenerateLongPress( Gesture::Started, 1u, Vector2( 1.f, 25.0f ) ) );
2145 // Render and notify
2146 application.SendNotification();
2147 application.Render();
2149 Wait(application, 500);
2152 application.ProcessEvent( GenerateLongPress( Gesture::Possible, 1u, Vector2( 1.f, 25.0f ) ) );
2153 application.ProcessEvent( GenerateLongPress( Gesture::Started, 1u, Vector2( 1.f, 25.0f ) ) );
2155 // Render and notify
2156 application.SendNotification();
2157 application.Render();
2159 Wait(application, 500);
2161 Stage stage = Stage::GetCurrent();
2162 Layer layer = stage.GetRootLayer();
2163 Actor actor = layer.FindChildByName("optionPaste");
2167 Vector3 worldPosition = actor.GetCurrentWorldPosition();
2168 Vector2 halfStageSize = stage.GetSize() / 2.0f;
2169 Vector2 position(worldPosition.x + halfStageSize.width, worldPosition.y + halfStageSize.height);
2171 Dali::Integration::TouchEvent event;
2172 event = Dali::Integration::TouchEvent();
2173 event.AddPoint( GetPointDownInside( position ) );
2174 application.ProcessEvent( event );
2176 event = Dali::Integration::TouchEvent();
2177 event.AddPoint( GetPointUpInside( position ) );
2178 application.ProcessEvent( event );
2180 DALI_TEST_EQUALS( field.GetProperty<std::string>( TextEditor::Property::TEXT ), std::string("testTextFieldEvent"), TEST_LOCATION );
2185 int utcDaliTextFieldEvent09(void)
2187 ToolkitTestApplication application;
2188 tet_infoline(" utcDaliTextFieldEvent09");
2190 TextField field = TextField::New();
2191 DALI_TEST_CHECK( field );
2192 Stage::GetCurrent().Add( field );
2193 LoadMarkerImages(application, field);
2194 // Render and notify
2195 application.SendNotification();
2196 application.Render();
2198 field.SetProperty( TextField::Property::TEXT, "Hello" );
2199 field.SetProperty( TextField::Property::POINT_SIZE, 10.f );
2200 field.SetSize( 300.f, 50.f );
2201 field.SetParentOrigin( ParentOrigin::TOP_LEFT );
2202 field.SetAnchorPoint( AnchorPoint::TOP_LEFT );
2204 // Avoid a crash when core load gl resources.
2205 application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
2207 // Create a tap event to touch the text field.
2208 application.ProcessEvent( GenerateTap( Gesture::Possible, 1u, 1u, Vector2( 150.0f, 25.0f ) ) );
2209 application.ProcessEvent( GenerateTap( Gesture::Started, 1u, 1u, Vector2( 150.0f, 25.0f ) ) );
2210 application.SendNotification();
2211 application.Render();
2214 map[ HiddenInput::Property::MODE ] = HiddenInput::Mode::HIDE_NONE;
2215 field.SetProperty( TextField::Property::HIDDEN_INPUT_SETTINGS, map );
2216 application.ProcessEvent( GenerateKey( "d", "d", 0, 0, 0, Integration::KeyEvent::Down, DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2217 application.SendNotification();
2218 application.Render();
2220 map[ HiddenInput::Property::MODE ] = HiddenInput::Mode::HIDE_ALL;
2221 map[ HiddenInput::Property::SUBSTITUTE_CHARACTER ] = 0x23;
2222 field.SetProperty( TextField::Property::HIDDEN_INPUT_SETTINGS, map );
2223 application.ProcessEvent( GenerateKey( "d", "d", 0, 0, 0, Integration::KeyEvent::Down, DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2224 application.SendNotification();
2225 application.Render();
2227 map[ HiddenInput::Property::MODE ] = HiddenInput::Mode::HIDE_COUNT;
2228 map[ HiddenInput::Property::SUBSTITUTE_COUNT ] = 2;
2229 field.SetProperty( TextField::Property::HIDDEN_INPUT_SETTINGS, map );
2230 for( unsigned int index = 0u; index < 5u; ++index )
2232 application.ProcessEvent( GenerateKey( "d", "d", 0, 0, 0, Integration::KeyEvent::Down, DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2233 application.SendNotification();
2234 application.Render();
2237 map[ HiddenInput::Property::MODE ] = HiddenInput::Mode::SHOW_COUNT;
2238 map[ HiddenInput::Property::SUBSTITUTE_COUNT ] = 2;
2239 field.SetProperty( TextField::Property::HIDDEN_INPUT_SETTINGS, map );
2240 for( unsigned int index = 0u; index < 5u; ++index )
2242 application.ProcessEvent( GenerateKey( "d", "d", 0, 0, 0, Integration::KeyEvent::Down, DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2243 application.SendNotification();
2244 application.Render();
2247 map[ HiddenInput::Property::MODE ] = HiddenInput::Mode::SHOW_LAST_CHARACTER;
2248 map[ HiddenInput::Property::SHOW_LAST_CHARACTER_DURATION ] = 0;
2249 field.SetProperty( TextField::Property::HIDDEN_INPUT_SETTINGS, map );
2250 application.ProcessEvent( GenerateKey( "", "", DALI_KEY_BACKSPACE, 0, 0, Integration::KeyEvent::Down, DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2251 application.SendNotification();
2252 application.Render();
2253 application.ProcessEvent( GenerateKey( "d", "d", 0, 0, 0, Integration::KeyEvent::Down, DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2254 application.SendNotification();
2255 application.Render();
2257 map[ HiddenInput::Property::SHOW_LAST_CHARACTER_DURATION ] = 100;
2258 field.SetProperty( TextField::Property::HIDDEN_INPUT_SETTINGS, map );
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();
2263 Property::Map mapGet;
2264 mapGet = field.GetProperty<Property::Map>( TextField::Property::HIDDEN_INPUT_SETTINGS );
2265 DALI_TEST_EQUALS( map.Count(), mapGet.Count(), TEST_LOCATION );
2266 DALI_TEST_EQUALS( DaliTestCheckMaps( map, mapGet ), true, TEST_LOCATION );
2271 int utcDaliTextFieldStyleWhilstSelected(void)
2273 ToolkitTestApplication application;
2274 tet_infoline(" utcDaliTextFieldStyleWhilstSelected");
2276 // Change font and styles whilst text is selected whilst word selected
2278 TextField field = TextField::New();
2279 DALI_TEST_CHECK( field );
2280 Stage::GetCurrent().Add( field );
2281 LoadMarkerImages(application, field);
2282 // Render and notify
2283 application.SendNotification();
2284 application.Render();
2286 field.SetProperty( TextField::Property::TEXT, "This is a long text for the size of the text-field." );
2287 field.SetProperty( TextField::Property::POINT_SIZE, 10.f );
2288 field.SetSize( 300.f, 50.f );
2289 field.SetParentOrigin( ParentOrigin::TOP_LEFT );
2290 field.SetAnchorPoint( AnchorPoint::TOP_LEFT );
2292 // Avoid a crash when core load gl resources.
2293 application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
2294 // Render and notify
2295 application.SendNotification();
2296 application.Render();
2298 // Create a tap event to touch the text field.
2299 application.ProcessEvent( GenerateTap( Gesture::Possible, 1u, 1u, Vector2( 150.0f, 25.0f ) ) );
2300 application.ProcessEvent( GenerateTap( Gesture::Started, 1u, 1u, Vector2( 150.0f, 25.0f ) ) );
2301 // Render and notify
2302 application.SendNotification();
2303 application.Render();
2306 // Tap first to get the focus.
2307 application.ProcessEvent( GenerateTap( Gesture::Possible, 1u, 1u, Vector2( 1.f, 25.0f ) ) );
2308 application.ProcessEvent( GenerateTap( Gesture::Started, 1u, 1u, Vector2( 1.f, 25.0f ) ) );
2310 // Render and notify
2311 application.SendNotification();
2312 application.Render();
2314 // Double tap to select a word.
2315 application.ProcessEvent( GenerateTap( Gesture::Possible, 2u, 1u, Vector2( 1.f, 25.0f ) ) );
2316 application.ProcessEvent( GenerateTap( Gesture::Started, 2u, 1u, Vector2( 1.f, 25.0f ) ) );
2318 // Render and notify
2319 application.SendNotification();
2320 application.Render();
2322 field.SetProperty( TextField::Property::INPUT_FONT_FAMILY, "Setting input font family" );
2323 DALI_TEST_EQUALS( field.GetProperty<std::string>( TextField::Property::INPUT_FONT_FAMILY ), "Setting input font family", TEST_LOCATION );
2325 Property::Map fontStyleMapSet;
2326 Property::Map fontStyleMapGet;
2328 fontStyleMapSet.Insert( "weight", "bold" );
2329 fontStyleMapSet.Insert( "slant", "italic" );
2330 field.SetProperty( TextField::Property::INPUT_FONT_STYLE, fontStyleMapSet );
2332 fontStyleMapGet = field.GetProperty<Property::Map>( TextField::Property::INPUT_FONT_STYLE );
2333 DALI_TEST_EQUALS( fontStyleMapGet.Count(), fontStyleMapSet.Count(), TEST_LOCATION );
2334 DALI_TEST_EQUALS( DaliTestCheckMaps( fontStyleMapGet, fontStyleMapSet ), true, TEST_LOCATION );
2336 fontStyleMapSet.Clear();
2337 fontStyleMapSet.Insert( "width", "expanded" );
2338 fontStyleMapSet.Insert( "slant", "italic" );
2339 field.SetProperty( TextField::Property::INPUT_FONT_STYLE, fontStyleMapSet );
2341 fontStyleMapGet = field.GetProperty<Property::Map>( TextField::Property::INPUT_FONT_STYLE );
2342 DALI_TEST_EQUALS( fontStyleMapGet.Count(), fontStyleMapSet.Count(), TEST_LOCATION );
2343 DALI_TEST_EQUALS( DaliTestCheckMaps( fontStyleMapGet, fontStyleMapSet ), true, TEST_LOCATION );
2345 field.SetProperty( TextField::Property::INPUT_POINT_SIZE, 12.f );
2346 DALI_TEST_EQUALS( field.GetProperty<float>( TextField::Property::INPUT_POINT_SIZE ), 12.f, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
2348 field.SetProperty( TextField::Property::TEXT_COLOR, Color::RED );
2349 DALI_TEST_EQUALS( field.GetProperty<Vector4>( TextField::Property::TEXT_COLOR ), Color::RED, TEST_LOCATION );
2351 fontStyleMapSet.Clear();
2352 fontStyleMapSet.Insert( "weight", "bold" );
2353 fontStyleMapSet.Insert( "slant", "italic" );
2355 field.SetProperty( TextField::Property::FONT_STYLE, fontStyleMapSet );
2357 fontStyleMapGet = field.GetProperty<Property::Map>( TextField::Property::FONT_STYLE );
2358 DALI_TEST_EQUALS( fontStyleMapGet.Count(), fontStyleMapSet.Count(), TEST_LOCATION );
2359 DALI_TEST_EQUALS( DaliTestCheckMaps( fontStyleMapGet, fontStyleMapSet ), true, TEST_LOCATION );
2361 fontStyleMapSet.Clear();
2362 fontStyleMapSet.Insert( "width", "expanded" );
2364 field.SetProperty( TextField::Property::FONT_STYLE, fontStyleMapSet );
2366 fontStyleMapGet = field.GetProperty<Property::Map>( TextField::Property::FONT_STYLE );
2367 DALI_TEST_EQUALS( fontStyleMapGet.Count(), fontStyleMapSet.Count(), TEST_LOCATION );
2368 DALI_TEST_EQUALS( DaliTestCheckMaps( fontStyleMapGet, fontStyleMapSet ), true, TEST_LOCATION );
2370 // Press Escape to increase coverage
2371 application.ProcessEvent( GenerateKey( "", "", DALI_KEY_ESCAPE, 0, 0, Integration::KeyEvent::Up, DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2372 application.SendNotification();
2373 application.Render();
2375 DALI_TEST_CHECK( !field.HasKeyInputFocus() );
2380 int utcDaliTextFieldEscKeyLoseFocus(void)
2382 ToolkitTestApplication application;
2383 tet_infoline(" utcDaliTextFieldEscKeyLoseFocus");
2385 // Creates a tap event. After creating a tap event the text field should
2386 // have the focus and add text with key events should be possible.
2388 TextField field = TextField::New();
2389 DALI_TEST_CHECK( field );
2391 Stage::GetCurrent().Add( field );
2393 field.SetSize( 300.f, 50.f );
2394 field.SetParentOrigin( ParentOrigin::TOP_LEFT );
2395 field.SetAnchorPoint( AnchorPoint::TOP_LEFT );
2397 // Avoid a crash when core load gl resources.
2398 application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
2400 // Render and notify
2401 application.SendNotification();
2402 application.Render();
2404 // Add a key event but as the text field has not the focus it should do nothing.
2405 application.ProcessEvent( GenerateKey( "a", "a", KEY_A_CODE, 0, 0, Integration::KeyEvent::Down, DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2406 application.ProcessEvent( GenerateKey( "a", "a", KEY_A_CODE, 0, 0, Integration::KeyEvent::Up, DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2408 // Render and notify
2409 application.SendNotification();
2410 application.Render();
2412 DALI_TEST_EQUALS( field.GetProperty<std::string>( TextField::Property::TEXT ), std::string(""), TEST_LOCATION );
2414 // Create a tap event to touch the text field.
2415 application.ProcessEvent( GenerateTap( Gesture::Possible, 1u, 1u, Vector2( 150.0f, 25.0f ) ) );
2416 application.ProcessEvent( GenerateTap( Gesture::Started, 1u, 1u, Vector2( 150.0f, 25.0f ) ) );
2418 // Render and notify
2419 application.SendNotification();
2420 application.Render();
2422 // Now the text field has the focus, so it can handle the key events.
2423 application.ProcessEvent( GenerateKey( "a", "a", KEY_A_CODE, 0, 0, Integration::KeyEvent::Down, DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2424 application.ProcessEvent( GenerateKey( "a", "a", KEY_A_CODE, 0, 0, Integration::KeyEvent::Up, DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2425 application.ProcessEvent( GenerateKey( "d", "d", KEY_D_CODE, 0, 0, Integration::KeyEvent::Down, DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2426 application.ProcessEvent( GenerateKey( "d", "d", KEY_D_CODE, 0, 0, Integration::KeyEvent::Up, DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2428 // Render and notify
2429 application.SendNotification();
2430 application.Render();
2432 DALI_TEST_EQUALS( field.GetProperty<std::string>( TextField::Property::TEXT ), std::string("ad"), TEST_LOCATION );
2434 // Generate a Esc key event. The text field should lose the focus.
2435 application.ProcessEvent( GenerateKey( "", "", DALI_KEY_ESCAPE, 0, 0, Integration::KeyEvent::Down, DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2436 application.ProcessEvent( GenerateKey( "", "", DALI_KEY_ESCAPE, 0, 0, Integration::KeyEvent::Up, DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2438 // Render and notify
2439 application.SendNotification();
2440 application.Render();
2442 DALI_TEST_EQUALS( false, field.HasKeyInputFocus(), TEST_LOCATION );
2444 // No more text should be introduced
2445 application.ProcessEvent( GenerateKey( "a", "a", KEY_A_CODE, 0, 0, Integration::KeyEvent::Down, DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2446 application.ProcessEvent( GenerateKey( "a", "a", KEY_A_CODE, 0, 0, Integration::KeyEvent::Up, DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2448 // Render and notify
2449 application.SendNotification();
2450 application.Render();
2452 DALI_TEST_EQUALS( field.GetProperty<std::string>( TextField::Property::TEXT ), std::string("ad"), TEST_LOCATION );
2457 int utcDaliTextFieldSomeSpecialKeys(void)
2459 ToolkitTestApplication application;
2460 tet_infoline(" utcDaliTextFieldSomeSpecialKeys");
2462 // Checks some special keys when the text is selected.
2464 TextField field = TextField::New();
2465 DALI_TEST_CHECK( field );
2466 Stage::GetCurrent().Add( field );
2467 LoadMarkerImages(application, field);
2468 // Render and notify
2469 application.SendNotification();
2470 application.Render();
2472 const std::string longText( "This is a long text for the size of the text-field." );
2474 field.SetProperty( TextField::Property::TEXT, longText );
2475 field.SetProperty( TextField::Property::POINT_SIZE, 10.f );
2476 field.SetSize( 300.f, 50.f );
2477 field.SetParentOrigin( ParentOrigin::TOP_LEFT );
2478 field.SetAnchorPoint( AnchorPoint::TOP_LEFT );
2480 // Avoid a crash when core load gl resources.
2481 application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
2482 // Render and notify
2483 application.SendNotification();
2484 application.Render();
2486 // Create a tap event to touch the text field.
2487 application.ProcessEvent( GenerateTap( Gesture::Possible, 1u, 1u, Vector2( 150.0f, 25.0f ) ) );
2488 application.ProcessEvent( GenerateTap( Gesture::Started, 1u, 1u, Vector2( 150.0f, 25.0f ) ) );
2490 // Render and notify
2491 application.SendNotification();
2492 application.Render();
2494 // Tap first to get the focus.
2495 application.ProcessEvent( GenerateTap( Gesture::Possible, 1u, 1u, Vector2( 1.f, 25.0f ) ) );
2496 application.ProcessEvent( GenerateTap( Gesture::Started, 1u, 1u, Vector2( 1.f, 25.0f ) ) );
2498 // Render and notify
2499 application.SendNotification();
2500 application.Render();
2502 // Double tap to select a word.
2503 application.ProcessEvent( GenerateTap( Gesture::Possible, 2u, 1u, Vector2( 1.f, 25.0f ) ) );
2504 application.ProcessEvent( GenerateTap( Gesture::Started, 2u, 1u, Vector2( 1.f, 25.0f ) ) );
2506 // Render and notify
2507 application.SendNotification();
2508 application.Render();
2510 // Generate a Esc key event. The text field should lose the focus.
2511 application.ProcessEvent( GenerateKey( "XF86PowerOff", "XF86PowerOff", DALI_KEY_POWER, 0, 0, Integration::KeyEvent::Down, DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2512 application.ProcessEvent( GenerateKey( "XF86PowerOff", "XF86PowerOff", DALI_KEY_POWER, 0, 0, Integration::KeyEvent::Up, DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2514 // Render and notify
2515 application.SendNotification();
2516 application.Render();
2518 // Generate a Esc key event. The text field should lose the focus.
2519 application.ProcessEvent( GenerateKey( "XF86Menu", "XF86Menu", DALI_KEY_MENU, 0, 0, Integration::KeyEvent::Down, DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2520 application.ProcessEvent( GenerateKey( "XF86Menu", "XF86Menu", DALI_KEY_MENU, 0, 0, Integration::KeyEvent::Up, DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2522 // Render and notify
2523 application.SendNotification();
2524 application.Render();
2526 // Generate a Esc key event. The text field should lose the focus.
2527 application.ProcessEvent( GenerateKey( "XF86Home", "XF86Home", DALI_KEY_HOME, 0, 0, Integration::KeyEvent::Down, DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2528 application.ProcessEvent( GenerateKey( "XF86Home", "XF86Home", DALI_KEY_HOME, 0, 0, Integration::KeyEvent::Up, DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2530 // Render and notify
2531 application.SendNotification();
2532 application.Render();
2534 // The text shouldn't be deleted.
2535 DALI_TEST_EQUALS( field.GetProperty<std::string>( TextField::Property::TEXT ), longText, TEST_LOCATION );
2540 int utcDaliTextFieldSizeUpdate(void)
2542 ToolkitTestApplication application;
2543 tet_infoline("utcDaliTextFieldSizeUpdate");
2545 // Checks some special keys when the text is selected.
2546 TextField field = TextField::New();
2547 DALI_TEST_CHECK( field );
2548 Stage::GetCurrent().Add( field );
2550 float previousHeight = 0.0f;
2551 float currentHeight = 0.0f;
2552 const float fieldWidth = 1920.0f;
2555 // "ㅁ" is bigger then "ኢ"
2556 field.SetSize( Vector2( fieldWidth ,10.0f ) );
2557 field.SetResizePolicy( ResizePolicy::FIXED , Dimension::WIDTH );
2558 field.SetResizePolicy( ResizePolicy::DIMENSION_DEPENDENCY , Dimension::HEIGHT );
2560 field.SetProperty( TextField::Property::TEXT, "ኢ");
2561 field.SetParentOrigin( ParentOrigin::TOP_LEFT );
2562 field.SetAnchorPoint( AnchorPoint::TOP_LEFT );
2564 field.SetKeyboardFocusable(true);
2565 KeyboardFocusManager::Get().SetCurrentFocusActor( field );
2567 application.SendNotification();
2568 application.Render();
2570 previousHeight = field.GetHeightForWidth( fieldWidth );
2571 DALI_TEST_EQUALS( previousHeight, field.GetProperty<float>( Actor::Property::SIZE_HEIGHT ) , TEST_LOCATION );
2573 // Add another script characters ( glyph height is defferent )
2574 application.ProcessEvent( GenerateKey( "ㅁ", "ㅁ", KEY_A_CODE, 0, 0, Integration::KeyEvent::Down, DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2575 application.ProcessEvent( GenerateKey( "ㅁ", "ㅁ", KEY_A_CODE, 0, 0, Integration::KeyEvent::Up, DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2577 application.SendNotification();
2578 application.Render();
2580 currentHeight = field.GetHeightForWidth( fieldWidth );
2581 DALI_TEST_EQUALS( currentHeight, field.GetProperty<float>( Actor::Property::SIZE_HEIGHT ), TEST_LOCATION );
2582 DALI_TEST_EQUALS( (previousHeight < currentHeight), true , TEST_LOCATION );
2587 int utcDaliTextFieldExtremlyLargePointSize(void)
2589 ToolkitTestApplication application;
2590 tet_infoline(" utcDaliTextFieldExtremlyLargePointSize");
2592 TextField field = TextField::New();
2594 field.SetProperty( TextField::Property::TEXT, "Text" );
2595 field.SetSize( 300.f, 50.f );
2596 field.SetParentOrigin( ParentOrigin::TOP_LEFT );
2597 field.SetAnchorPoint( AnchorPoint::TOP_LEFT );
2598 Stage::GetCurrent().Add( field );
2602 field.SetProperty( TextField::Property::POINT_SIZE, 160.0f );
2603 application.SendNotification();
2604 DALI_TEST_CHECK( field );
2608 tet_result(TET_FAIL);
2613 int UtcDaliTextFieldDefaultFontStylePropertyCoverage(void)
2615 ToolkitTestApplication application;
2616 tet_infoline("UtcDaliTextFieldFontStylePorpertyCoverage");
2617 TextField field = TextField::New();
2618 DALI_TEST_CHECK( field );
2619 Stage::GetCurrent().Add( field );
2621 Property::Map fontStyleMapGet;
2623 fontStyleMapGet = field.GetProperty<Property::Map>( TextField::Property::FONT_STYLE );
2625 Property::Value* weightValue = NULL;
2626 Property::Value* widthValue = NULL;
2627 Property::Value* slantValue = NULL;
2628 weightValue = fontStyleMapGet.Find( "weight" );
2629 widthValue = fontStyleMapGet.Find( "width" );
2630 slantValue = fontStyleMapGet.Find( "slant" );
2631 DALI_TEST_CHECK( !weightValue );
2632 DALI_TEST_CHECK( !widthValue );
2633 DALI_TEST_CHECK( !slantValue );
2638 int UtcDaliTextFieldSettingPlaceholder(void)
2640 ToolkitTestApplication application;
2641 tet_infoline("UtcDaliTextFieldSettingPlaceholder");
2643 TextField field = TextField::New();
2644 DALI_TEST_CHECK( field );
2645 Stage::GetCurrent().Add( field );
2647 // Check the placeholder property with pixel size
2648 Property::Map placeholderPixelSizeMapSet;
2649 Property::Map placeholderPixelSizeMapGet;
2650 Property::Map placeholderFontstyleMap;
2651 placeholderPixelSizeMapSet[ Text::PlaceHolder::Property::TEXT ] = "Setting Placeholder Text";
2652 placeholderPixelSizeMapSet[ Text::PlaceHolder::Property::TEXT_FOCUSED ] = "Setting Placeholder Text Focused";
2653 placeholderPixelSizeMapSet[ Text::PlaceHolder::Property::COLOR ] = Color::BLUE;
2654 placeholderPixelSizeMapSet[ Text::PlaceHolder::Property::FONT_FAMILY ] = "Arial";
2655 placeholderPixelSizeMapSet[ Text::PlaceHolder::Property::PIXEL_SIZE ] = 15.0f;
2656 placeholderPixelSizeMapSet[ Text::PlaceHolder::Property::ELLIPSIS ] = true;
2658 placeholderFontstyleMap.Insert( "weight", "bold" );
2659 placeholderPixelSizeMapSet[ Text::PlaceHolder::Property::FONT_STYLE ] = placeholderFontstyleMap;
2660 field.SetProperty( TextField::Property::PLACEHOLDER, placeholderPixelSizeMapSet );
2662 placeholderPixelSizeMapGet = field.GetProperty<Property::Map>( TextField::Property::PLACEHOLDER );
2663 DALI_TEST_EQUALS( placeholderPixelSizeMapGet.Count(), placeholderPixelSizeMapSet.Count(), TEST_LOCATION );
2664 DALI_TEST_EQUALS( DaliTestCheckMaps( placeholderPixelSizeMapGet, placeholderPixelSizeMapSet ), true, TEST_LOCATION );
2666 // Check the placeholder property with point size
2667 Property::Map placeholderMapSet;
2668 Property::Map placeholderMapGet;
2669 placeholderMapSet[ Text::PlaceHolder::Property::TEXT ] = "Setting Placeholder Text";
2670 placeholderMapSet[ Text::PlaceHolder::Property::TEXT_FOCUSED ] = "Setting Placeholder Text Focused";
2671 placeholderMapSet[ Text::PlaceHolder::Property::COLOR ] = Color::RED;
2672 placeholderMapSet[ Text::PlaceHolder::Property::FONT_FAMILY ] = "Arial";
2673 placeholderMapSet[ Text::PlaceHolder::Property::POINT_SIZE ] = 12.0f;
2674 placeholderMapSet[ Text::PlaceHolder::Property::ELLIPSIS ] = false;
2676 // Check the placeholder font style property
2677 placeholderFontstyleMap.Clear();
2679 placeholderFontstyleMap.Insert( "weight", "bold" );
2680 placeholderFontstyleMap.Insert( "width", "condensed" );
2681 placeholderFontstyleMap.Insert( "slant", "italic" );
2682 placeholderMapSet[ Text::PlaceHolder::Property::FONT_STYLE ] = placeholderFontstyleMap;
2683 field.SetProperty( TextField::Property::PLACEHOLDER, placeholderMapSet );
2685 placeholderMapGet = field.GetProperty<Property::Map>( TextField::Property::PLACEHOLDER );
2686 DALI_TEST_EQUALS( placeholderMapGet.Count(), placeholderMapSet.Count(), TEST_LOCATION );
2687 DALI_TEST_EQUALS( DaliTestCheckMaps( placeholderMapGet, placeholderMapSet ), true, TEST_LOCATION );
2689 // Reset font style.
2690 placeholderFontstyleMap.Clear();
2691 placeholderFontstyleMap.Insert( "weight", "normal" );
2692 placeholderFontstyleMap.Insert( "slant", "oblique" );
2693 placeholderMapSet[ Text::PlaceHolder::Property::FONT_STYLE ] = placeholderFontstyleMap;
2694 field.SetProperty( TextField::Property::PLACEHOLDER, placeholderMapSet );
2696 placeholderMapGet = field.GetProperty<Property::Map>( TextField::Property::PLACEHOLDER );
2697 DALI_TEST_EQUALS( placeholderMapGet.Count(), placeholderMapSet.Count(), TEST_LOCATION );
2698 DALI_TEST_EQUALS( DaliTestCheckMaps( placeholderMapGet, placeholderMapSet ), true, TEST_LOCATION );
2700 placeholderFontstyleMap.Clear();
2701 placeholderFontstyleMap.Insert( "slant", "roman" );
2702 placeholderMapSet[ Text::PlaceHolder::Property::FONT_STYLE ] = placeholderFontstyleMap;
2703 field.SetProperty( TextField::Property::PLACEHOLDER, placeholderMapSet );
2705 placeholderMapGet = field.GetProperty<Property::Map>( TextField::Property::PLACEHOLDER );
2707 placeholderFontstyleMap.Clear();
2708 placeholderMapSet[ Text::PlaceHolder::Property::FONT_STYLE ] = placeholderFontstyleMap;
2710 field.SetProperty( TextField::Property::PLACEHOLDER, placeholderMapSet );
2711 placeholderMapGet = field.GetProperty<Property::Map>( TextField::Property::PLACEHOLDER );
2712 DALI_TEST_EQUALS( placeholderMapGet.Count(), placeholderMapSet.Count(), TEST_LOCATION );
2713 DALI_TEST_EQUALS( DaliTestCheckMaps( placeholderMapGet, placeholderMapSet ), true, TEST_LOCATION );
2718 int UtcDaliTextFieldSetPaddingProperty(void)
2720 ToolkitTestApplication application;
2721 tet_infoline("UtcDaliTextFieldSetPaddingProperty\n");
2723 TextField field = TextField::New();
2724 DALI_TEST_CHECK( field );
2725 field.SetSize( 300.f, 50.f );
2726 field.SetParentOrigin( ParentOrigin::TOP_LEFT );
2727 field.SetAnchorPoint( AnchorPoint::TOP_LEFT );
2728 Stage::GetCurrent().Add( field );
2730 application.SendNotification();
2731 application.Render();
2733 Vector3 originalSize = field.GetNaturalSize();
2735 field.SetProperty( Toolkit::Control::Property::PADDING, Extents( 10, 10, 10, 10 ) );
2737 application.SendNotification();
2738 application.Render();
2740 DALI_TEST_EQUALS( field.GetProperty<Extents>( Toolkit::Control::Property::PADDING ), Extents( 10, 10, 10, 10 ), TEST_LOCATION );
2742 Vector3 paddingAddedSize = field.GetNaturalSize();
2744 DALI_TEST_EQUALS( originalSize.width + 10 + 10 , paddingAddedSize.width, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
2746 DALI_TEST_EQUALS( originalSize.height + 10 + 10 , paddingAddedSize.height, Math::MACHINE_EPSILON_1000, TEST_LOCATION );