2 * Copyright (c) 2020 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.
21 // Need to override adaptor classes for toolkit test harness, so include
22 // test harness headers before dali headers.
23 #include <dali-toolkit-test-suite-utils.h>
26 #include <dali/integration-api/events/touch-event-integ.h>
27 #include <dali-toolkit/dali-toolkit.h>
29 #include <dali-toolkit/devel-api/controls/buttons/button-devel.h>
31 #include <dali/devel-api/adaptor-framework/image-loading.h>
34 using namespace Toolkit;
36 void utc_dali_toolkit_pushbutton_startup(void)
38 test_return_value = TET_UNDEF;
41 void utc_dali_toolkit_pushbutton_cleanup(void)
43 test_return_value = TET_PASS;
48 static const char* TEST_IMAGE_ONE = TEST_RESOURCE_DIR "/gallery-small-1.jpg";
50 static const Vector2 INSIDE_TOUCH_POINT_POSITON = Vector2( 240, 400 );
51 static const Vector3 BUTTON_POSITON_TO_GET_INSIDE_TOUCH_EVENTS = Vector3( 200, 360, 0 );
52 static const Size BUTTON_SIZE_TO_GET_INSIDE_TOUCH_EVENTS = Size( 100, 100 );
54 static bool gPushButtonSelectedState = false;
55 bool PushButtonSelected( Button button )
57 gPushButtonSelectedState = button.GetProperty<bool>(button.GetPropertyIndex("selected") );
61 static bool gPushButtonPressed = false;
63 static bool PushButtonPressed( Button button )
65 gPushButtonPressed = true;
69 static bool gPushButtonReleased = false;
71 static bool PushButtonReleased( Button button )
73 gPushButtonReleased = true;
77 static bool gPushButtonClicked = false;
79 static bool PushButtonClicked( Button button )
81 gPushButtonClicked = true;
82 return gPushButtonClicked;
85 Dali::Integration::Point GetPointDownInside()
87 Dali::Integration::Point point;
88 point.SetState( PointState::DOWN );
89 point.SetScreenPosition( INSIDE_TOUCH_POINT_POSITON );
93 Dali::Integration::Point GetPointUpInside()
95 Dali::Integration::Point point;
96 point.SetState( PointState::UP );
97 point.SetScreenPosition( INSIDE_TOUCH_POINT_POSITON );
101 Dali::Integration::Point GetPointLeave()
103 Dali::Integration::Point point;
104 point.SetState( PointState::LEAVE );
105 point.SetScreenPosition( INSIDE_TOUCH_POINT_POSITON );
109 Dali::Integration::Point GetPointEnter()
111 Dali::Integration::Point point;
112 point.SetState( PointState::MOTION );
113 point.SetScreenPosition( INSIDE_TOUCH_POINT_POSITON );
117 Dali::Integration::Point GetPointDownOutside()
119 Dali::Integration::Point point;
120 point.SetState( PointState::DOWN );
121 point.SetScreenPosition( Vector2( 10, 10 ) );
125 Dali::Integration::Point GetPointUpOutside()
127 Dali::Integration::Point point;
128 point.SetState( PointState::UP );
129 point.SetScreenPosition( Vector2( 10, 10 ) );
133 // Set up the position of the button for the default test events
134 void SetupButtonForTestTouchEvents( ToolkitTestApplication& application, Button& button, bool useDefaultImages )
136 button.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT );
137 button.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT );
138 button.SetProperty( Actor::Property::POSITION, BUTTON_POSITON_TO_GET_INSIDE_TOUCH_EVENTS );
139 if ( useDefaultImages )
141 const Vector2 TEST_IMAGE_SIZE = Vector2( BUTTON_SIZE_TO_GET_INSIDE_TOUCH_EVENTS );
142 TestPlatformAbstraction& platform = application.GetPlatform();
143 platform.SetClosestImageSize( TEST_IMAGE_SIZE );
144 button.SetProperty( Toolkit::Button::Property::UNSELECTED_BACKGROUND_VISUAL, TEST_IMAGE_ONE );
145 button.SetProperty( Toolkit::Button::Property::SELECTED_BACKGROUND_VISUAL, TEST_IMAGE_ONE );
149 static std::string GetButtonText( Button button )
151 Property::Value value = button.GetProperty( Toolkit::Button::Property::LABEL );
153 Property::Map *labelProperty = value.GetMap();
155 std::string textLabel;
159 Property::Value* value = labelProperty->Find( Toolkit::TextVisual::Property::TEXT );
160 value->Get( textLabel );
168 int UtcDaliPushButtonConstructorP(void)
170 TestApplication application;
174 DALI_TEST_CHECK( !button );
178 int UtcDaliPushButtonCopyConstructorP(void)
180 TestApplication application;
182 // Initialize an object, ref count == 1
183 PushButton button = PushButton::New();
185 PushButton copy( button );
186 DALI_TEST_CHECK( copy );
190 int UtcDaliPushButtonAssignmentOperatorP(void)
192 TestApplication application;
194 PushButton button = PushButton::New();
196 PushButton copy( button );
197 DALI_TEST_CHECK( copy );
199 DALI_TEST_CHECK( button == copy );
203 int UtcDaliPushButtonNewP(void)
205 TestApplication application;
207 PushButton button = PushButton::New();
209 DALI_TEST_CHECK( button );
213 int UtcDaliPushButtonDownCastP(void)
215 TestApplication application;
217 PushButton button = PushButton::New();
219 BaseHandle object(button);
221 PushButton button2 = PushButton::DownCast( object );
222 DALI_TEST_CHECK(button2);
224 PushButton button3 = DownCast< PushButton >(object);
225 DALI_TEST_CHECK(button3);
229 int UtcDaliPushButtonDownCastN(void)
231 TestApplication application;
233 BaseHandle unInitializedObject;
235 PushButton button1 = PushButton::DownCast( unInitializedObject );
236 DALI_TEST_CHECK( !button1 );
238 PushButton button2 = DownCast< PushButton >( unInitializedObject );
239 DALI_TEST_CHECK( !button2 );
243 int UtcDaliPushButtonAutoRepeatingProperty(void)
245 ToolkitTestApplication application;
246 tet_infoline(" UtcDaliPushButtonSetGetAutoRepeating");
248 PushButton pushButton = PushButton::New();
250 pushButton.SetProperty( pushButton.GetPropertyIndex("autoRepeating"), true );
251 DALI_TEST_EQUALS( pushButton.GetProperty<bool>(pushButton.GetPropertyIndex("autoRepeating")), true, TEST_LOCATION );
253 pushButton.SetProperty( pushButton.GetPropertyIndex("autoRepeating"), false );
254 DALI_TEST_EQUALS( pushButton.GetProperty<bool>(pushButton.GetPropertyIndex("autoRepeating")), false, TEST_LOCATION );
256 pushButton.SetProperty( pushButton.GetPropertyIndex("autoRepeating"), true );
257 DALI_TEST_EQUALS( pushButton.GetProperty<bool>(pushButton.GetPropertyIndex("autoRepeating")), true, TEST_LOCATION );
262 int UtcDaliPushButtonSetAutoRepeating(void)
264 ToolkitTestApplication application;
265 tet_infoline("UtcDaliPushButtonSetAutoRepeating\n");
266 tet_infoline("Ensure setting AutoRepeating on a SELECTED Toggle button switches off Toggle\n");
267 PushButton pushButton = PushButton::New();
269 const bool INITIAL_TOGGLE_VALUE = true;
270 const bool INITIAL_SELECTED_VALUE = true;
272 pushButton.SetProperty( Button::Property::TOGGLABLE, INITIAL_TOGGLE_VALUE);
273 pushButton.SetProperty( Button::Property::SELECTED, INITIAL_SELECTED_VALUE );
275 DALI_TEST_EQUALS( pushButton.GetProperty<bool>( Button::Property::TOGGLABLE ), INITIAL_TOGGLE_VALUE , TEST_LOCATION );
276 DALI_TEST_EQUALS( pushButton.GetProperty<bool>( Button::Property::SELECTED ), INITIAL_SELECTED_VALUE , TEST_LOCATION );
278 pushButton.SetProperty( Button::Property::AUTO_REPEATING, true );
280 DALI_TEST_EQUALS( pushButton.GetProperty<bool>( Button::Property::TOGGLABLE ), !INITIAL_TOGGLE_VALUE , TEST_LOCATION );
285 int UtcDaliPushButtonTogglableProperty(void)
287 ToolkitTestApplication application;
288 tet_infoline(" UtcDaliPushButtonSetGetTogglableButton");
290 PushButton pushButton = PushButton::New();
292 pushButton.SetProperty( pushButton.GetPropertyIndex("togglable"), true );
293 DALI_TEST_EQUALS( pushButton.GetProperty<bool>(pushButton.GetPropertyIndex("togglable")), true, TEST_LOCATION );
295 pushButton.SetProperty( pushButton.GetPropertyIndex("togglable"), false );
296 DALI_TEST_EQUALS( pushButton.GetProperty<bool>(pushButton.GetPropertyIndex("togglable")), false, TEST_LOCATION );
298 pushButton.SetProperty( pushButton.GetPropertyIndex("togglable"), true );
299 DALI_TEST_EQUALS( pushButton.GetProperty<bool>(pushButton.GetPropertyIndex("togglable")), true, TEST_LOCATION );
304 int UtcDaliPushButtonAutoRepeatingPropertyAndTogglableButton(void)
306 ToolkitTestApplication application;
307 tet_infoline(" UtcDaliPushButtonSetGetAutoRepeatingAndTogglableButton");
309 PushButton pushButton = PushButton::New();
311 pushButton.SetProperty( Button::Property::AUTO_REPEATING, true );
312 pushButton.SetProperty( pushButton.GetPropertyIndex("togglable"), true );
314 DALI_TEST_EQUALS( pushButton.GetProperty<bool>(pushButton.GetPropertyIndex("togglable")), true, TEST_LOCATION );
315 DALI_TEST_EQUALS( pushButton.GetProperty<bool>(pushButton.GetPropertyIndex("autoRepeating")), false, TEST_LOCATION );
317 pushButton.SetProperty( pushButton.GetPropertyIndex("togglable"), true );
318 pushButton.SetProperty( Button::Property::AUTO_REPEATING, true );
320 DALI_TEST_EQUALS( pushButton.GetProperty<bool>(pushButton.GetPropertyIndex("autoRepeating")), true, TEST_LOCATION );
321 DALI_TEST_EQUALS( pushButton.GetProperty<bool>(pushButton.GetPropertyIndex("togglable")), false, TEST_LOCATION );
325 int UtcDaliPushButtonSelectedProperty01(void)
327 ToolkitTestApplication application;
328 tet_infoline(" UtcDaliPushButtonSetGetSelected01");
330 PushButton pushButton = PushButton::New();
332 pushButton.SetProperty( pushButton.GetPropertyIndex("togglable"), true );
334 pushButton.StateChangedSignal().Connect( &PushButtonSelected );
336 gPushButtonSelectedState = false;
337 pushButton.SetProperty( Button::Property::SELECTED, true );
339 DALI_TEST_EQUALS( pushButton.GetProperty<bool>( Button::Property::SELECTED ), true , TEST_LOCATION );
340 DALI_TEST_CHECK( gPushButtonSelectedState );
342 pushButton.SetProperty( Button::Property::SELECTED, false );
344 DALI_TEST_EQUALS( pushButton.GetProperty<bool>( Button::Property::SELECTED ), false , TEST_LOCATION );
345 DALI_TEST_CHECK( !gPushButtonSelectedState );
347 pushButton.SetProperty( Button::Property::SELECTED, true );
349 DALI_TEST_EQUALS( pushButton.GetProperty<bool>( Button::Property::SELECTED ), true , TEST_LOCATION );
350 DALI_TEST_CHECK( gPushButtonSelectedState );
354 int UtcDaliPushButtonSelectedProperty02(void)
356 ToolkitTestApplication application;
357 tet_infoline(" UtcDaliPushButtonSetGetSelected02");
359 PushButton pushButton = PushButton::New();
361 pushButton.SetProperty( pushButton.GetPropertyIndex("togglable"), false );
362 pushButton.StateChangedSignal().Connect( &PushButtonSelected );
364 gPushButtonSelectedState = false;
365 pushButton.SetProperty( Button::Property::SELECTED, true );
367 DALI_TEST_EQUALS( pushButton.GetProperty<bool>( Button::Property::SELECTED ), false , TEST_LOCATION );
368 DALI_TEST_CHECK( !gPushButtonSelectedState );
370 pushButton.SetProperty( Button::Property::SELECTED, false );
372 DALI_TEST_EQUALS( pushButton.GetProperty<bool>( Button::Property::SELECTED ), false , TEST_LOCATION );
373 DALI_TEST_CHECK( !gPushButtonSelectedState );
375 pushButton.SetProperty( Button::Property::SELECTED, true );
377 DALI_TEST_EQUALS( pushButton.GetProperty<bool>( Button::Property::SELECTED ), false , TEST_LOCATION );
378 DALI_TEST_CHECK( !gPushButtonSelectedState );
382 int UtcDaliPushButtonAutorepeatingDelayPropertyValues01(void)
384 ToolkitTestApplication application;
385 tet_infoline(" UtcDaliPushButtonSetGetAutorepeatingDelayValues01");
387 PushButton pushButton = PushButton::New();
389 pushButton.SetProperty( Button::Property::AUTO_REPEATING, true );
391 pushButton.SetProperty( Button::Property::INITIAL_AUTO_REPEATING_DELAY, 1.f );
393 DALI_TEST_EQUALS( pushButton.GetProperty<float>(pushButton.GetPropertyIndex("initialAutoRepeatingDelay") ), 1.f, TEST_LOCATION );
398 int UtcDaliPushButtonAutorepeatingDelayPropertyValues02(void)
400 ToolkitTestApplication application;
401 tet_infoline(" UtcDaliPushButtonSetGetAutorepeatingDelayValues02");
403 PushButton pushButton = PushButton::New();
405 bool assert1( false );
406 bool assert2( false );
408 pushButton.SetProperty( Button::Property::AUTO_REPEATING, true );
412 pushButton.SetProperty( Button::Property::INITIAL_AUTO_REPEATING_DELAY, -1.f );
414 catch( Dali::DaliException& e )
416 DALI_TEST_PRINT_ASSERT( e );
417 DALI_TEST_EQUALS(e.condition, "initialAutoRepeatingDelay > 0.f", TEST_LOCATION);
423 pushButton.SetProperty( Button::Property::NEXT_AUTO_REPEATING_DELAY, -1.f );
425 catch( Dali::DaliException& e )
427 DALI_TEST_PRINT_ASSERT( e );
428 DALI_TEST_EQUALS(e.condition, "nextAutoRepeatingDelay > 0.f", TEST_LOCATION);
432 DALI_TEST_CHECK( assert1 && assert2 );
436 int UtcDaliPushButtonLabelProperty(void)
438 ToolkitTestApplication application;
439 tet_infoline(" UtcDaliPushButtonSetLabelText");
441 const std::string STR( "Hola!" );
443 PushButton pushButton = PushButton::New();
445 application.SendNotification();
446 application.Render();
448 pushButton.SetProperty( Toolkit::Button::Property::LABEL,
449 Property::Map().Add( Toolkit::Visual::Property::TYPE, Toolkit::Visual::TEXT )
450 .Add( Toolkit::TextVisual::Property::POINT_SIZE, 15.0f )
454 pushButton.SetProperty( Toolkit::Button::Property::LABEL, STR );
456 DALI_TEST_EQUALS( GetButtonText( pushButton ), STR, TEST_LOCATION );
461 int UtcDaliPushButtonPressed(void)
463 ToolkitTestApplication application;
464 tet_infoline(" UtcDaliPushButtonPressed");
466 PushButton pushButton = PushButton::New();
467 pushButton.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT );
468 pushButton.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT );
469 pushButton.SetProperty( Actor::Property::POSITION, BUTTON_POSITON_TO_GET_INSIDE_TOUCH_EVENTS );
470 pushButton.SetProperty( Actor::Property::SIZE, BUTTON_SIZE_TO_GET_INSIDE_TOUCH_EVENTS );
472 application.GetScene().Add( pushButton );
474 application.SendNotification();
475 application.Render();
477 gPushButtonPressed = false;
479 // connect to its touch signal
480 pushButton.PressedSignal().Connect( &PushButtonPressed );
482 Dali::Integration::TouchEvent eventDown;
483 eventDown.AddPoint( GetPointDownInside() );
485 // flush the queue and render once
486 application.SendNotification();
487 application.Render();
488 application.ProcessEvent( eventDown );
490 DALI_TEST_CHECK( gPushButtonPressed );
494 int UtcDaliPushButtonReleased(void)
496 ToolkitTestApplication application;
497 tet_infoline(" UtcDaliPushButtonReleased");
499 PushButton pushButton = PushButton::New();
500 pushButton.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT );
501 pushButton.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT );
502 pushButton.SetProperty( Actor::Property::POSITION, BUTTON_POSITON_TO_GET_INSIDE_TOUCH_EVENTS );
503 pushButton.SetProperty( Actor::Property::SIZE, BUTTON_SIZE_TO_GET_INSIDE_TOUCH_EVENTS );
505 application.GetScene().Add( pushButton );
507 application.SendNotification();
508 application.Render();
510 // connect to its touch signal
511 pushButton.ReleasedSignal().Connect( &PushButtonReleased );
513 Dali::Integration::TouchEvent event;
515 // Test1. Touch point down and up inside the button.
517 gPushButtonReleased = false;
518 event = Dali::Integration::TouchEvent();
519 event.AddPoint( GetPointDownInside() );
520 application.ProcessEvent( event );
522 event = Dali::Integration::TouchEvent();
523 event.AddPoint( GetPointUpInside() );
524 application.ProcessEvent( event );
526 DALI_TEST_CHECK( gPushButtonReleased );
528 // Test2. Touch point down and up outside the button.
530 gPushButtonReleased = false;
531 event = Dali::Integration::TouchEvent();
532 event.AddPoint( GetPointDownOutside() );
533 application.ProcessEvent( event );
535 event = Dali::Integration::TouchEvent();
536 event.AddPoint( GetPointUpOutside() );
537 application.ProcessEvent( event );
539 DALI_TEST_CHECK( !gPushButtonReleased );
541 // Test3. Touch point down inside and up outside the button.
543 gPushButtonReleased = false;
544 event = Dali::Integration::TouchEvent();
545 event.AddPoint( GetPointDownInside() );
546 application.ProcessEvent( event );
548 event = Dali::Integration::TouchEvent();
549 event.AddPoint( GetPointLeave() );
550 application.ProcessEvent( event );
552 event = Dali::Integration::TouchEvent();
553 event.AddPoint( GetPointUpOutside() );
554 application.ProcessEvent( event );
556 DALI_TEST_CHECK( gPushButtonReleased );
558 // Test4. Touch point down outside and up inside the button.
560 gPushButtonReleased = false;
561 event = Dali::Integration::TouchEvent();
562 event.AddPoint( GetPointDownOutside() );
563 application.ProcessEvent( event );
565 event = Dali::Integration::TouchEvent();
566 event.AddPoint( GetPointEnter() );
567 application.ProcessEvent( event );
569 event = Dali::Integration::TouchEvent();
570 event.AddPoint( GetPointUpInside() );
571 application.ProcessEvent( event );
573 DALI_TEST_CHECK( !gPushButtonReleased );
577 int UtcDaliPushButtonSelected(void)
579 ToolkitTestApplication application;
580 tet_infoline(" UtcDaliPushButtonSelected");
582 PushButton pushButton = PushButton::New();
583 pushButton.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT );
584 pushButton.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT );
585 pushButton.SetProperty( Actor::Property::POSITION, BUTTON_POSITON_TO_GET_INSIDE_TOUCH_EVENTS );
586 pushButton.SetProperty( Actor::Property::SIZE, BUTTON_SIZE_TO_GET_INSIDE_TOUCH_EVENTS );
588 application.GetScene().Add( pushButton );
590 application.SendNotification();
591 application.Render();
593 // connect to its touch signal
594 pushButton.StateChangedSignal().Connect( &PushButtonSelected );
596 Dali::Integration::TouchEvent event;
598 // Test1. No togglable button.
600 gPushButtonSelectedState = false;
601 event = Dali::Integration::TouchEvent();
602 event.AddPoint( GetPointDownInside() );
603 application.ProcessEvent( event );
605 event = Dali::Integration::TouchEvent();
606 event.AddPoint( GetPointUpInside() );
607 application.ProcessEvent( event );
609 DALI_TEST_CHECK( !gPushButtonSelectedState );
611 // Set togglable property.
612 pushButton.SetProperty( Button::Property::TOGGLABLE, true );
614 // Test2. Touch point down and up inside the button twice.
615 gPushButtonSelectedState = false;
616 event = Dali::Integration::TouchEvent();
617 event.AddPoint( GetPointDownInside() );
618 application.ProcessEvent( event );
620 event = Dali::Integration::TouchEvent();
621 event.AddPoint( GetPointUpInside() );
622 application.ProcessEvent( event );
624 DALI_TEST_CHECK( gPushButtonSelectedState );
626 event = Dali::Integration::TouchEvent();
627 event.AddPoint( GetPointDownInside() );
628 application.ProcessEvent( event );
630 event = Dali::Integration::TouchEvent();
631 event.AddPoint( GetPointUpInside() );
632 application.ProcessEvent( event );
634 DALI_TEST_CHECK( !gPushButtonSelectedState );
636 // Test3. Touch point down and up outside the button.
638 gPushButtonSelectedState = false;
639 event = Dali::Integration::TouchEvent();
640 event.AddPoint( GetPointDownOutside() );
641 application.ProcessEvent( event );
643 event = Dali::Integration::TouchEvent();
644 event.AddPoint( GetPointUpOutside() );
645 application.ProcessEvent( event );
647 DALI_TEST_CHECK( !gPushButtonSelectedState );
649 // Test4. Touch point down inside and up outside the button.
650 // State changes on Button down
651 gPushButtonSelectedState = false;
652 event = Dali::Integration::TouchEvent();
653 event.AddPoint( GetPointDownInside() );
654 application.ProcessEvent( event );
656 event = Dali::Integration::TouchEvent();
657 event.AddPoint( GetPointLeave() );
658 application.ProcessEvent( event );
660 event = Dali::Integration::TouchEvent();
661 event.AddPoint( GetPointUpOutside() );
662 application.ProcessEvent( event );
664 DALI_TEST_CHECK( gPushButtonSelectedState );
666 // Test5. Touch point down outside and up inside the button.
667 // Start in unselected state
668 pushButton.SetProperty( Button::Property::SELECTED, false );
670 DALI_TEST_EQUALS( pushButton.GetProperty<bool>(pushButton.GetPropertyIndex("selected") ),false , TEST_LOCATION );
672 gPushButtonSelectedState = false;
673 event = Dali::Integration::TouchEvent();
674 event.AddPoint( GetPointDownOutside() );
675 application.ProcessEvent( event );
677 event = Dali::Integration::TouchEvent();
678 event.AddPoint( GetPointEnter() );
679 application.ProcessEvent( event );
681 event = Dali::Integration::TouchEvent();
682 event.AddPoint( GetPointUpInside() );
683 application.ProcessEvent( event );
685 DALI_TEST_CHECK( !gPushButtonSelectedState );
689 int UtcDaliPushButtonPropertySetLabelPadding(void)
691 ToolkitTestApplication application;
692 tet_infoline(" UtcDaliPushButtonPropertySetLabelPadding");
694 PushButton pushButton = PushButton::New();
695 pushButton.SetProperty( Toolkit::PushButton::Property::LABEL_PADDING, Vector4( 1.0f, 1.0f, 1.0f, 1.0f ) );
696 DALI_TEST_EQUALS( pushButton.GetProperty<Vector4>( Toolkit::PushButton::Property::LABEL_PADDING ), Vector4( 1.0f, 1.0f, 1.0f, 1.0f ), Math::MACHINE_EPSILON_1000, TEST_LOCATION );
698 pushButton.SetProperty( Toolkit::PushButton::Property::LABEL_PADDING, Vector4( 10.0f, 10.0f, 10.0f, 10.0f ) );
699 DALI_TEST_EQUALS( pushButton.GetProperty<Vector4>( Toolkit::PushButton::Property::LABEL_PADDING ), Vector4( 10.0f, 10.0f, 10.0f, 10.0f ), Math::MACHINE_EPSILON_1000, TEST_LOCATION );
704 int UtcDaliPushButtonPropertySetIconPadding(void)
706 ToolkitTestApplication application;
707 tet_infoline(" UtcDaliPushButtonPropertySetIconPadding");
709 PushButton pushButton = PushButton::New();
710 pushButton.SetProperty( Toolkit::PushButton::Property::ICON_PADDING, Vector4( 1.0f, 1.0f, 1.0f, 1.0f ) );
711 DALI_TEST_EQUALS( pushButton.GetProperty<Vector4>( Toolkit::PushButton::Property::ICON_PADDING ), Vector4( 1.0f, 1.0f, 1.0f, 1.0f ), Math::MACHINE_EPSILON_1000, TEST_LOCATION );
713 pushButton.SetProperty( Toolkit::PushButton::Property::ICON_PADDING, Vector4( 10.0f, 10.0f, 10.0f, 10.0f ) );
714 DALI_TEST_EQUALS( pushButton.GetProperty<Vector4>( Toolkit::PushButton::Property::ICON_PADDING ), Vector4( 10.0f, 10.0f, 10.0f, 10.0f ), Math::MACHINE_EPSILON_1000, TEST_LOCATION );
719 int UtcDaliPushButtonPaddingLayout(void)
721 ToolkitTestApplication application;
722 tet_infoline(" UtcDaliPushButtonPaddingLayout");
724 // This test creates padding for an icon and a label.
725 // The icon and label are each enabled and disabled to confirm the correct padding is used.
726 PushButton pushButton = PushButton::New();
728 const Vector4 TEST_ICON_PADDING( 20.0f, 20.0f, 20.0f, 20.0f );
729 const Vector4 TEST_LABEL_PADDING( 10.0f, 10.0f, 10.0f, 10.0f );
731 // Get actual size of test image
732 ImageDimensions testImageSize = Dali::GetClosestImageSize( TEST_IMAGE_ONE );
733 const Vector2 TEST_IMAGE_SIZE( testImageSize.GetWidth(), testImageSize.GetHeight() );
735 pushButton.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT );
736 pushButton.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT );
737 pushButton.SetProperty( Actor::Property::POSITION, Vector2( 0.0f, 0.0f ));
738 pushButton.SetResizePolicy( ResizePolicy::USE_NATURAL_SIZE, Dimension::ALL_DIMENSIONS );
740 application.GetScene().Add( pushButton );
742 application.SendNotification();
743 application.Render();
745 // First test the size is zero.
746 // No padding should be added as there is no label or icon.
747 Vector2 size( Vector2::ZERO );
748 size.width = pushButton.GetRelayoutSize( Dimension::WIDTH );
749 size.height = pushButton.GetRelayoutSize( Dimension::HEIGHT );
750 tet_printf( "Button Natural Size(%f,%f)\n", pushButton.GetNaturalSize().width, pushButton.GetNaturalSize().height );
752 DALI_TEST_EQUALS( size, Vector2::ZERO, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
754 // Check label only padding
755 pushButton.SetProperty( Toolkit::Button::Property::LABEL, "Label" );
757 application.SendNotification();
758 application.Render();
760 Vector2 sizeWithLabelWithoutPadding( Vector2::ZERO );
761 sizeWithLabelWithoutPadding.width = pushButton.GetRelayoutSize( Dimension::WIDTH );
762 sizeWithLabelWithoutPadding.height = pushButton.GetRelayoutSize( Dimension::HEIGHT );
764 tet_printf( "Button RelayoutSize label without padding (%f,%f)\n", sizeWithLabelWithoutPadding.width, sizeWithLabelWithoutPadding.height );
766 // Add label padding to label
767 pushButton.SetProperty( Toolkit::PushButton::Property::LABEL_PADDING, TEST_LABEL_PADDING );
768 application.SendNotification();
769 application.Render();
771 Vector2 sizeLabelAndPadding( Vector2::ZERO );
772 sizeLabelAndPadding.width = pushButton.GetRelayoutSize( Dimension::WIDTH );
773 sizeLabelAndPadding.height = pushButton.GetRelayoutSize( Dimension::HEIGHT );
774 tet_printf( "Button RelayoutSize after label padding(%f,%f)\n", sizeLabelAndPadding.width, sizeLabelAndPadding.height );
776 // If control size has increased beyond size of just label then padding has been applied
777 DALI_TEST_GREATER( sizeLabelAndPadding.width, sizeWithLabelWithoutPadding.width+TEST_LABEL_PADDING.x, TEST_LOCATION );
778 DALI_TEST_GREATER( sizeLabelAndPadding.height, sizeWithLabelWithoutPadding.height+TEST_LABEL_PADDING.w, TEST_LOCATION );
780 // Re-initialise the button so we can setup icon-only padding.
781 pushButton.Unparent();
782 pushButton = PushButton::New();
784 pushButton.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT );
785 pushButton.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT );
786 pushButton.SetProperty( Actor::Property::POSITION, Vector2( 0.0f, 0.0f ));
787 pushButton.SetResizePolicy( ResizePolicy::USE_NATURAL_SIZE, Dimension::ALL_DIMENSIONS );
789 application.GetScene().Add( pushButton );
792 pushButton.SetProperty( Toolkit::DevelButton::Property::LABEL_RELATIVE_ALIGNMENT, "BEGIN" );
793 pushButton.SetProperty( Toolkit::Button::Property::UNSELECTED_VISUAL, TEST_IMAGE_ONE );
794 pushButton.SetProperty( Toolkit::Button::Property::SELECTED_VISUAL, TEST_IMAGE_ONE );
796 application.SendNotification();
797 application.Render();
799 // Size of button with just icon
800 size.width = pushButton.GetRelayoutSize( Dimension::WIDTH );
801 size.height = pushButton.GetRelayoutSize( Dimension::HEIGHT );
802 tet_printf( "Button RelayoutSize with icon(%f,%f)\n", size.width, size.height );
804 pushButton.SetProperty( Toolkit::PushButton::Property::ICON_PADDING, TEST_ICON_PADDING );
806 application.SendNotification();
807 application.Render();
808 DALI_TEST_EQUALS( size, TEST_IMAGE_SIZE, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
810 size.width = pushButton.GetRelayoutSize( Dimension::WIDTH );
811 size.height = pushButton.GetRelayoutSize( Dimension::HEIGHT );
812 tet_printf( "Button RelayoutSize after icon padding(%f,%f)\n", size.width, size.height );
813 const Vector2 expectedIconAndPaddingSize( TEST_ICON_PADDING.x+TEST_ICON_PADDING.y+TEST_IMAGE_SIZE.width, TEST_ICON_PADDING.w + TEST_ICON_PADDING.z + TEST_IMAGE_SIZE.height );
814 DALI_TEST_EQUALS( size, expectedIconAndPaddingSize, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
816 // Now test padding for both label and icon simultaneously.
817 pushButton.SetProperty( Toolkit::Button::Property::LABEL, "Label" );
819 application.SendNotification();
820 application.Render();
822 size.width = pushButton.GetRelayoutSize( Dimension::WIDTH );
823 size.height = pushButton.GetRelayoutSize( Dimension::HEIGHT );
824 tet_printf( "Button RelayoutSize after label added(%f,%f)\n", size.width, size.height );
826 pushButton.SetProperty( Toolkit::PushButton::Property::LABEL_PADDING, TEST_LABEL_PADDING );
828 application.SendNotification();
829 application.Render();
831 size.width = pushButton.GetRelayoutSize( Dimension::WIDTH );
832 size.height = pushButton.GetRelayoutSize( Dimension::HEIGHT );
833 tet_printf( "Button RelayoutSize after icon and label padding(%f,%f)\n", size.width, size.height );
835 DALI_TEST_EQUALS( size.width, sizeLabelAndPadding.width + expectedIconAndPaddingSize.width, TEST_LOCATION );
836 // Test height of control is same as icon and padding, as Text is smaller than icon
837 DALI_TEST_EQUALS( size.height, expectedIconAndPaddingSize.height, TEST_LOCATION );
842 int UtcDaliPushButtonAlignmentLayout(void)
844 ToolkitTestApplication application;
845 tet_infoline(" UtcDaliPushButtonAlignmentLayout");
848 * This test checks different alignments for the icon against the label.
849 * The icon is then moved around the label in each of it's alignments.
850 * The final relayed out size is checked to confirm the layout has been done correctly.
852 * There is an Icon which has 0 width and height, but with 75 padding on all sides.
853 * - Therefore total width and height are both 150.
855 * There is a Label which has "an unknown" width and height, but with 30 padding on all sides.
856 * - Therefore total width and height are 60+x and 60+y respectively.
857 * Where x & y are the width and height of the text.
859 * The width of the button will always expand to the largest of the icon and label sizes (plus padding).
860 * So We use the padding to help us determine the orientation is correct for each alignment.
862 * |<- 150 ->| |<-- 60+x -->|
865 * | | ^ +------------+ -
867 * | Icon | 150 | Label | 60+y
869 * | | v +------------+ -
873 const Vector4 TEST_ICON_PADDING( 70.0f, 70.0f, 70.0f, 70.0f );
874 const Vector4 TEST_LABEL_PADDING( 30.0f, 30.0f, 30.0f, 30.0f );
876 // Get actual size of test image
877 ImageDimensions testImageSize = Dali::GetClosestImageSize( TEST_IMAGE_ONE );
878 const Vector2 TEST_IMAGE_SIZE( testImageSize.GetWidth(), testImageSize.GetHeight() );
880 PushButton pushButton = PushButton::New();
882 pushButton.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT );
883 pushButton.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT );
884 pushButton.SetProperty( Actor::Property::POSITION, Vector2( 0.0f, 0.0f ));
885 pushButton.SetResizePolicy( ResizePolicy::USE_NATURAL_SIZE, Dimension::ALL_DIMENSIONS );
887 application.GetScene().Add( pushButton );
889 // Add a label and get size of control
890 pushButton.SetProperty( Toolkit::Button::Property::LABEL, "Label" );
891 application.SendNotification();
892 application.Render();
894 // First get the size of control with just label
895 Vector2 justLabelSize( Vector2::ZERO );
896 justLabelSize.width = pushButton.GetRelayoutSize( Dimension::WIDTH );
897 justLabelSize.height = pushButton.GetRelayoutSize( Dimension::HEIGHT );
898 tet_printf( "Button RelayoutSize with just label and no padding(%f,%f)\n", justLabelSize.width, justLabelSize.height );
900 pushButton.SetProperty( Toolkit::PushButton::Property::LABEL_PADDING, TEST_LABEL_PADDING );
901 application.SendNotification();
902 application.Render();
904 // Size of Label and Padding
905 Vector2 expectedLabelAndPaddingSize( Vector2::ZERO );
906 expectedLabelAndPaddingSize.width = justLabelSize.width + TEST_LABEL_PADDING.x + TEST_LABEL_PADDING.y;
907 expectedLabelAndPaddingSize.height = justLabelSize.height + TEST_LABEL_PADDING.w + TEST_LABEL_PADDING.z;
909 Vector2 labelAndPaddingSize( Vector2::ZERO );
910 labelAndPaddingSize.width = pushButton.GetRelayoutSize( Dimension::WIDTH );
911 labelAndPaddingSize.height = pushButton.GetRelayoutSize( Dimension::HEIGHT );
913 DALI_TEST_EQUALS( labelAndPaddingSize, expectedLabelAndPaddingSize , Math::MACHINE_EPSILON_1000, TEST_LOCATION );
915 const Vector2 testImageWithPaddingSize = Vector2 ( ( TEST_IMAGE_SIZE.width + TEST_ICON_PADDING.x + TEST_ICON_PADDING.y ),
916 ( TEST_IMAGE_SIZE.height + TEST_ICON_PADDING.w + TEST_ICON_PADDING.z ) );
918 // Add Icon and set its alignment
919 pushButton.SetProperty( Toolkit::DevelButton::Property::LABEL_RELATIVE_ALIGNMENT, "BEGIN" );
920 pushButton.SetProperty( Toolkit::Button::Property::UNSELECTED_VISUAL, TEST_IMAGE_ONE );
921 pushButton.SetProperty( Toolkit::Button::Property::SELECTED_VISUAL, TEST_IMAGE_ONE );
922 pushButton.SetProperty( Toolkit::PushButton::Property::ICON_PADDING, TEST_ICON_PADDING );
924 application.SendNotification();
925 application.Render();
927 Vector2 size( Vector2::ZERO );
928 size.width = pushButton.GetRelayoutSize( Dimension::WIDTH );
929 size.height = pushButton.GetRelayoutSize( Dimension::HEIGHT );
932 * Test Icon right alignment.
933 * Height grows to largest of Icon or Label (+ padding).
934 * Normally this will be Icons height, except with very large font sizes.
936 * +------------+---------+
942 * +------------+---------+
944 DALI_TEST_EQUALS( size.width, ( testImageWithPaddingSize.width + labelAndPaddingSize.width ) , TEST_LOCATION );
945 DALI_TEST_EQUALS( size.height, ( std::max( testImageWithPaddingSize.height, labelAndPaddingSize.height) ) , Math::MACHINE_EPSILON_1000, TEST_LOCATION );
947 // Now test left alignment matches right for size.
948 pushButton.SetProperty( Toolkit::DevelButton::Property::LABEL_RELATIVE_ALIGNMENT, "END" );
950 application.SendNotification();
951 application.Render();
953 size.width = pushButton.GetRelayoutSize( Dimension::WIDTH );
954 size.height = pushButton.GetRelayoutSize( Dimension::HEIGHT );
957 * Test Icon left alignment.
958 * Height grows to largest of Icon or Label (+ padding).
959 * Normally this will be Icons height, except with very large font sizes.
961 * +---------+------------+
967 * +---------+------------+
969 DALI_TEST_EQUALS( size.width, ( testImageWithPaddingSize.width + labelAndPaddingSize.width ) , TEST_LOCATION );
970 DALI_TEST_EQUALS( size.height, ( std::max( testImageWithPaddingSize.height, labelAndPaddingSize.height) ) , Math::MACHINE_EPSILON_1000, TEST_LOCATION );
972 tet_infoline(" Test Icon TOP alignment - Width grows to largest of Icon or label (plus padding)");
989 tet_infoline("SetProperty on LABEL_RELATIVE_ALIGNMENT should relayout the Button");
990 pushButton.SetProperty( Toolkit::DevelButton::Property::LABEL_RELATIVE_ALIGNMENT, "BOTTOM" );
992 application.SendNotification();
993 application.Render();
995 size.width = pushButton.GetRelayoutSize( Dimension::WIDTH );
996 size.height = pushButton.GetRelayoutSize( Dimension::HEIGHT );
998 tet_printf("Natural width (%f)\n",pushButton.GetNaturalSize().width);
999 tet_printf("Natural height (%f)\n",pushButton.GetNaturalSize().height);
1001 tet_printf(" UtcDaliPushButtonAlignmentLayout Top layout - Image and Padding size (%f,%f)\n", testImageWithPaddingSize.width, testImageWithPaddingSize.height );
1002 tet_printf(" UtcDaliPushButtonAlignmentLayout Top layout - Text and Padding size (%f,%f)\n", labelAndPaddingSize.width, labelAndPaddingSize.height );
1004 DALI_TEST_EQUALS( size.width, ( std::max( testImageWithPaddingSize.width, labelAndPaddingSize.width ) ) , TEST_LOCATION );
1006 DALI_TEST_EQUALS( size.height,( testImageWithPaddingSize.height + labelAndPaddingSize.height ) , TEST_LOCATION );
1009 * Test Icon bottom alignment.
1010 * Width grows to largest of Icon or Label (+ padding).
1024 tet_infoline(" Test Icon BOTTOM alignment - Width grows to largest of Icon or label (plus padding)");
1025 pushButton.SetProperty( Toolkit::DevelButton::Property::LABEL_RELATIVE_ALIGNMENT, "TOP" );
1027 application.SendNotification();
1028 application.Render();
1030 size.width = pushButton.GetRelayoutSize( Dimension::WIDTH );
1031 size.height = pushButton.GetRelayoutSize( Dimension::HEIGHT );
1033 DALI_TEST_EQUALS( size.width, ( std::max(testImageWithPaddingSize.width, labelAndPaddingSize.width )) , TEST_LOCATION );
1034 DALI_TEST_EQUALS( size.height,( testImageWithPaddingSize.height + labelAndPaddingSize.height ) , TEST_LOCATION );
1039 int UtcDaliPushButtonSetUnSelectedVisual01P(void)
1041 tet_infoline(" Test adding a visual for the UNSELECTED_VISUAL property, removing Button from stage and counting renderers\n");
1042 ToolkitTestApplication application;
1044 PushButton pushButton = PushButton::New();
1045 pushButton.SetProperty( Actor::Property::SIZE, Vector2( BUTTON_SIZE_TO_GET_INSIDE_TOUCH_EVENTS ) );
1047 application.GetScene().Add( pushButton );
1049 Property::Map propertyMap;
1050 propertyMap.Insert(Visual::Property::TYPE, Visual::COLOR);
1051 propertyMap.Insert(ColorVisual::Property::MIX_COLOR, Color::BLUE);
1053 pushButton.SetProperty( Toolkit::Button::Property::UNSELECTED_BACKGROUND_VISUAL, propertyMap );
1055 tet_infoline(" UNSELECTED_VISUAL Added to button\n");
1057 application.SendNotification();
1058 application.Render(0);
1060 unsigned int rendererCount = pushButton.GetRendererCount();
1061 tet_printf("After adding UNSELECTED_BACKGROUND_VISUAL the renderer count is(%d)\n", rendererCount );
1063 DALI_TEST_EQUALS( pushButton.GetRendererCount(), 1 , TEST_LOCATION );
1065 tet_printf("Remove button from stage\n" );
1067 application.GetScene().Remove( pushButton );
1069 rendererCount = pushButton.GetRendererCount();
1070 tet_printf("After removing pushbutton from stage the renderer count is(%d)\n ", rendererCount );
1072 DALI_TEST_EQUALS( pushButton.GetRendererCount(), 0, TEST_LOCATION );
1074 tet_printf("After removing pushbutton from stage the renderer count is(%d)\n ", rendererCount );
1076 Property::Map propertyMap2;
1077 propertyMap2.Insert(Visual::Property::TYPE, Visual::COLOR);
1078 propertyMap2.Insert(ColorVisual::Property::MIX_COLOR, Color::RED);
1079 pushButton.SetProperty( Toolkit::Button::Property::UNSELECTED_VISUAL, propertyMap2 );
1081 tet_printf("Added UNSELECTED_VISUAL and add button back to Stage\n");
1083 application.GetScene().Add( pushButton );
1085 tet_printf("With UNSELECTED_BACKGROUND_VISUAL and UNSELECTED_VISUAL the renderer count is(%d)\n", pushButton.GetRendererCount() );
1087 DALI_TEST_EQUALS( pushButton.GetRendererCount(), 2, TEST_LOCATION );
1092 int UtcDaliPushButtonSetSelectedVisualN(void)
1094 tet_infoline(" Test adding a broken visual for the UNSELECTED_VISUAL property");
1096 ToolkitTestApplication application;
1098 PushButton pushButton = PushButton::New();
1100 pushButton.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT );
1101 pushButton.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT );
1102 pushButton.SetResizePolicy( ResizePolicy::USE_NATURAL_SIZE, Dimension::ALL_DIMENSIONS );
1104 application.GetScene().Add( pushButton );
1105 application.SendNotification();
1106 application.Render(0);
1108 unsigned int preRendererCount = pushButton.GetRendererCount();
1109 tet_printf("RendererCount prior to adding visual(%d)\n",preRendererCount);
1110 DALI_TEST_EQUALS( preRendererCount, 0, TEST_LOCATION );
1112 application.GetScene().Remove( pushButton );
1113 application.SendNotification();
1114 application.Render(0);
1116 Property::Map colorMap;
1117 const int BROKEN_VISUAL_TYPE = 999999999;
1119 colorMap.Insert(Visual::Property::TYPE, BROKEN_VISUAL_TYPE);
1120 colorMap.Insert(BorderVisual::Property::COLOR, Color::BLUE);
1121 colorMap.Insert(BorderVisual::Property::SIZE, 5.f);
1122 pushButton.SetProperty( Toolkit::Button::Property::UNSELECTED_VISUAL, colorMap );
1124 application.GetScene().Add( pushButton );
1125 application.SendNotification();
1126 application.Render(0);
1128 unsigned int postRendererCount = pushButton.GetRendererCount();
1129 tet_printf("RendererCount post broken visual (%d)\n", postRendererCount);
1130 DALI_TEST_EQUALS( postRendererCount, 0, TEST_LOCATION );
1135 int UtcDaliPushButtonToggleSignalP(void)
1137 ToolkitTestApplication application;
1138 tet_infoline(" UtcDaliButtonToggleSignalP Ensure Signals emitted");
1140 PushButton button = PushButton::New();
1141 button.SetProperty( Button::Property::TOGGLABLE, true);
1143 SetupButtonForTestTouchEvents( application, button, true );
1145 application.GetScene().Add( button );
1147 application.SendNotification();
1148 application.Render();
1150 // connect to its signal
1151 button.ClickedSignal().Connect( &PushButtonClicked );
1152 gPushButtonClicked = false;
1154 tet_infoline(" Touch down and up within button");
1155 Dali::Integration::TouchEvent event;
1156 event = Dali::Integration::TouchEvent();
1157 event.AddPoint( GetPointDownInside() );
1158 application.ProcessEvent( event );
1160 event = Dali::Integration::TouchEvent();
1161 event.AddPoint( GetPointUpInside() );
1162 application.ProcessEvent( event );
1164 DALI_TEST_EQUALS( gPushButtonClicked, true, TEST_LOCATION );
1169 // Deprecated API Tests
1171 int UtcDaliPushButtonSetGetAutoRepeating(void)
1173 ToolkitTestApplication application;
1174 tet_infoline(" UtcDaliPushButtonSetGetAutoRepeating");
1176 PushButton pushButton = PushButton::New();
1178 pushButton.SetProperty( Button::Property::AUTO_REPEATING, true );
1180 DALI_TEST_EQUALS( pushButton.GetProperty<bool>( Button::Property::AUTO_REPEATING ), true, TEST_LOCATION );
1182 pushButton.SetProperty( Button::Property::AUTO_REPEATING, false );
1184 DALI_TEST_EQUALS( pushButton.GetProperty<bool>( Button::Property::AUTO_REPEATING ), false, TEST_LOCATION );
1186 pushButton.SetProperty( Button::Property::AUTO_REPEATING, true );
1188 DALI_TEST_EQUALS( pushButton.GetProperty<bool>( Button::Property::AUTO_REPEATING ), true, TEST_LOCATION );
1192 int UtcDaliPushButtonSetGetTogglableButton(void)
1194 ToolkitTestApplication application;
1195 tet_infoline(" UtcDaliPushButtonSetGetTogglableButton");
1197 PushButton pushButton = PushButton::New();
1199 pushButton.SetProperty( Button::Property::TOGGLABLE, true );
1201 DALI_TEST_EQUALS( pushButton.GetProperty<bool>( Button::Property::TOGGLABLE ), true, TEST_LOCATION );
1203 pushButton.SetProperty( Button::Property::TOGGLABLE, false );
1205 DALI_TEST_EQUALS( pushButton.GetProperty<bool>( Button::Property::TOGGLABLE ), false, TEST_LOCATION );
1207 pushButton.SetProperty( Button::Property::TOGGLABLE, true );
1209 DALI_TEST_EQUALS( pushButton.GetProperty<bool>( Button::Property::TOGGLABLE ), true, TEST_LOCATION );
1213 int UtcDaliPushButtonSetGetAutoRepeatingAndTogglableButton(void)
1215 ToolkitTestApplication application;
1216 tet_infoline(" UtcDaliPushButtonSetGetAutoRepeatingAndTogglableButton");
1218 PushButton pushButton = PushButton::New();
1220 pushButton.SetProperty( Button::Property::AUTO_REPEATING, true );
1221 pushButton.SetProperty( Button::Property::TOGGLABLE, true);
1223 DALI_TEST_EQUALS( pushButton.GetProperty<bool>( Button::Property::TOGGLABLE ), true, TEST_LOCATION );
1224 DALI_TEST_EQUALS( pushButton.GetProperty<bool>( Button::Property::AUTO_REPEATING ), false, TEST_LOCATION );
1226 pushButton.SetProperty( Button::Property::TOGGLABLE, true);
1227 pushButton.SetProperty( Button::Property::AUTO_REPEATING, true );
1229 DALI_TEST_EQUALS( pushButton.GetProperty<bool>( Button::Property::AUTO_REPEATING ), true, TEST_LOCATION );
1230 DALI_TEST_EQUALS( pushButton.GetProperty<bool>( Button::Property::TOGGLABLE ), false, TEST_LOCATION );
1235 int UtcDaliPushButtonSetGetSelected01(void)
1237 ToolkitTestApplication application;
1238 tet_infoline(" UtcDaliPushButtonSetGetSelected01");
1240 PushButton pushButton = PushButton::New();
1242 pushButton.SetProperty( Button::Property::TOGGLABLE, true);
1243 pushButton.StateChangedSignal().Connect( &PushButtonSelected );
1245 gPushButtonSelectedState = false;
1246 pushButton.SetProperty( Button::Property::SELECTED, true );
1248 DALI_TEST_EQUALS( pushButton.GetProperty<bool>( Button::Property::SELECTED), true, TEST_LOCATION );
1249 DALI_TEST_CHECK( gPushButtonSelectedState );
1251 pushButton.SetProperty( Button::Property::SELECTED, false );
1253 DALI_TEST_EQUALS( pushButton.GetProperty<bool>( Button::Property::SELECTED), false, TEST_LOCATION );
1254 DALI_TEST_CHECK( !gPushButtonSelectedState );
1256 pushButton.SetProperty( Button::Property::SELECTED, true );
1258 DALI_TEST_EQUALS( pushButton.GetProperty<bool>( Button::Property::SELECTED), true, TEST_LOCATION );
1259 DALI_TEST_CHECK( gPushButtonSelectedState );
1263 int UtcDaliPushButtonSetGetSelected02(void)
1265 ToolkitTestApplication application;
1266 tet_infoline(" UtcDaliPushButtonSetGetSelected02");
1268 PushButton pushButton = PushButton::New();
1270 tet_infoline(" Set Toggle feature off");
1271 pushButton.SetProperty( Button::Property::TOGGLABLE, false);
1272 pushButton.StateChangedSignal().Connect( &PushButtonSelected );
1274 gPushButtonSelectedState = false;
1275 tet_infoline(" Try to set to selected, expecting failure as not a toggle button");
1276 pushButton.SetProperty( Button::Property::SELECTED, true );
1278 DALI_TEST_EQUALS( pushButton.GetProperty<bool>( Button::Property::SELECTED), false, TEST_LOCATION );
1279 DALI_TEST_CHECK( !gPushButtonSelectedState );
1281 pushButton.SetProperty( Button::Property::SELECTED, false );
1283 DALI_TEST_EQUALS( pushButton.GetProperty<bool>( Button::Property::SELECTED), false, TEST_LOCATION );
1284 DALI_TEST_CHECK( !gPushButtonSelectedState );
1286 pushButton.SetProperty( Button::Property::SELECTED, true );
1288 DALI_TEST_EQUALS( pushButton.GetProperty<bool>( Button::Property::SELECTED ), false, TEST_LOCATION );
1289 DALI_TEST_CHECK( !gPushButtonSelectedState );
1294 int UtcDaliPushButtonSetGetAutorepeatingDelayValues01(void)
1296 ToolkitTestApplication application;
1297 tet_infoline(" UtcDaliPushButtonSetGetAutorepeatingDelayValues01");
1299 PushButton pushButton = PushButton::New();
1301 pushButton.SetProperty( Button::Property::AUTO_REPEATING, true );
1303 pushButton.SetProperty( Button::Property::INITIAL_AUTO_REPEATING_DELAY, 1.f);
1304 DALI_TEST_EQUALS( pushButton.GetProperty<float>( Button::Property::INITIAL_AUTO_REPEATING_DELAY ), 1.f, TEST_LOCATION );
1306 pushButton.SetProperty( Button::Property::NEXT_AUTO_REPEATING_DELAY, 1.f);
1308 DALI_TEST_EQUALS( pushButton.GetProperty<float>( Button::Property::NEXT_AUTO_REPEATING_DELAY ), 1.f, TEST_LOCATION );
1312 int UtcDaliPushButtonSetGetAutorepeatingDelayValues02(void)
1314 ToolkitTestApplication application;
1315 tet_infoline(" UtcDaliPushButtonSetGetAutorepeatingDelayValues02");
1317 PushButton pushButton = PushButton::New();
1319 bool assert1( false );
1320 bool assert2( false );
1322 pushButton.SetProperty( Button::Property::AUTO_REPEATING, true );
1326 pushButton.SetProperty( Button::Property::INITIAL_AUTO_REPEATING_DELAY, -1.f );
1328 catch( Dali::DaliException& e )
1330 DALI_TEST_PRINT_ASSERT( e );
1331 DALI_TEST_EQUALS(e.condition, "initialAutoRepeatingDelay > 0.f", TEST_LOCATION);
1337 pushButton.SetProperty( Button::Property::NEXT_AUTO_REPEATING_DELAY, -1.f );
1339 catch( Dali::DaliException& e )
1341 DALI_TEST_PRINT_ASSERT( e );
1342 DALI_TEST_EQUALS(e.condition, "nextAutoRepeatingDelay > 0.f", TEST_LOCATION);
1346 DALI_TEST_CHECK( assert1 && assert2 );
1350 int UtcDaliPushButtonSetLabelText(void)
1352 ToolkitTestApplication application;
1353 tet_infoline(" UtcDaliPushButtonSetLabelText");
1355 const std::string STR( "Hola!" );
1357 PushButton pushButton = PushButton::New();
1359 pushButton.SetProperty( Toolkit::Button::Property::LABEL,
1360 Property::Map().Add( Toolkit::Visual::Property::TYPE, Toolkit::Visual::TEXT )
1361 .Add( Toolkit::TextVisual::Property::POINT_SIZE, 15.0f )
1364 application.SendNotification();
1365 application.Render();
1367 pushButton.SetProperty( Button::Property::LABEL, STR );
1369 DALI_TEST_EQUALS(GetButtonText( pushButton ), STR, TEST_LOCATION);