2 * Copyright (c) 2014 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>
24 #include "dali-toolkit-test-utils/toolkit-timer.h"
27 #include <dali-toolkit/dali-toolkit.h>
28 #include <dali/integration-api/events/touch-event-integ.h>
31 using namespace Toolkit;
34 void utc_dali_toolkit_button_startup(void)
36 test_return_value = TET_UNDEF;
39 void utc_dali_toolkit_button_cleanup(void)
41 test_return_value = TET_PASS;
46 static const char* TEST_IMAGE_ONE = TEST_RESOURCE_DIR "/gallery-small-1.jpg";
48 static bool gIsCalledButtonCallback = false;
50 const int RENDER_FRAME_INTERVAL = 16;
52 static bool ButtonCallback( Button button )
54 gIsCalledButtonCallback = true;
58 struct CallbackFunctor
60 CallbackFunctor(bool* callbackFlag)
61 : mCallbackFlag( callbackFlag )
67 *mCallbackFlag = true;
72 Dali::Integration::Point GetPointDownInside()
74 Dali::Integration::Point point;
75 point.SetState( PointState::DOWN );
76 point.SetScreenPosition( Vector2( 240, 400 ) );
80 Dali::Integration::Point GetPointUpInside()
82 Dali::Integration::Point point;
83 point.SetState( PointState::UP );
84 point.SetScreenPosition( Vector2( 240, 400 ) );
88 Dali::Integration::Point GetPointLeave()
90 Dali::Integration::Point point;
91 point.SetState( PointState::LEAVE );
92 point.SetScreenPosition( Vector2( 240, 400 ) );
96 Dali::Integration::Point GetPointEnter()
98 Dali::Integration::Point point;
99 point.SetState( PointState::MOTION );
100 point.SetScreenPosition( Vector2( 240, 400 ) );
104 Dali::Integration::Point GetPointDownOutside()
106 Dali::Integration::Point point;
107 point.SetState( PointState::DOWN );
108 point.SetScreenPosition( Vector2( 10, 10 ) );
112 Dali::Integration::Point GetPointUpOutside()
114 Dali::Integration::Point point;
115 point.SetState( PointState::UP );
116 point.SetScreenPosition( Vector2( 10, 10 ) );
120 static float ANIMATION_TIME( 0.5f );
124 int UtcDaliButtonConstructorP(void)
126 TestApplication application;
130 DALI_TEST_CHECK( !button );
134 int UtcDaliButtonCopyConstructorP(void)
136 TestApplication application;
138 // Initialize an object, ref count == 1
139 Button button = PushButton::New();
141 Button copy( button );
142 DALI_TEST_CHECK( copy );
146 int UtcDaliButtonAssignmentOperatorP(void)
148 TestApplication application;
150 Button button = PushButton::New();
152 Button copy( button );
153 DALI_TEST_CHECK( copy );
155 DALI_TEST_CHECK( button == copy );
159 int UtcDaliButtonDownCastP(void)
161 TestApplication application;
163 Button button = PushButton::New();
165 BaseHandle object(button);
167 Button button2 = Button::DownCast( object );
168 DALI_TEST_CHECK(button2);
170 Button button3 = DownCast< Button >(object);
171 DALI_TEST_CHECK(button3);
175 int UtcDaliButtonDownCastN(void)
177 TestApplication application;
179 BaseHandle unInitializedObject;
181 Button button1 = Button::DownCast( unInitializedObject );
182 DALI_TEST_CHECK( !button1 );
184 Button button2 = DownCast< Button >( unInitializedObject );
185 DALI_TEST_CHECK( !button2 );
189 int UtcDaliButtonSetDisabledP(void)
191 ToolkitTestApplication application;
193 Button button = PushButton::New();
195 button.SetDisabled( true );
197 DALI_TEST_CHECK( button.IsDisabled() );
199 button.SetDisabled( false );
201 DALI_TEST_CHECK( !button.IsDisabled() );
203 button.SetDisabled( true );
205 DALI_TEST_CHECK( button.IsDisabled() );
207 button.SetDisabled( false );
209 DALI_TEST_CHECK( !button.IsDisabled() );
213 int UtcDaliButtonSetDisabledWithDifferentStates01P(void)
215 ToolkitTestApplication application;
217 tet_infoline("UtcDaliButtonSetDisabledWithDifferentStates01P\n");
219 Button button = PushButton::New();
221 bool SELECTED = true;
223 button.SetProperty( Button::Property::TOGGLABLE, true);
224 button.SetProperty( Button::Property::SELECTED, SELECTED );
226 button.SetProperty( Button::Property::DISABLED, true);
228 tet_infoline("Set button to SELECTED = false whilst disabled, should not change to false\n");
229 button.SetProperty( Button::Property::SELECTED, !SELECTED );
231 bool isSelected = button.GetProperty<bool>( Button::Property::SELECTED ) ;
233 DALI_TEST_EQUALS( isSelected, SELECTED , TEST_LOCATION );
238 int UtcDaliButtonSetDisabledWithDifferentStates02P(void)
240 ToolkitTestApplication application;
242 tet_infoline("UtcDaliButtonSetDisabledWithDifferentStates02\n");
244 Button button = PushButton::New();
246 bool SELECTED = true;
248 button.SetProperty( Button::Property::TOGGLABLE, true );
249 button.SetProperty( Button::Property::SELECTED, SELECTED );
250 button.SetProperty( Button::Property::DISABLED, true );
252 bool isSelected = button.GetProperty<bool>( Button::Property::SELECTED );
253 DALI_TEST_EQUALS( isSelected, SELECTED , TEST_LOCATION );
254 tet_infoline("Set button to DISABLED = false whilst disabled and then set to unselected\n");
256 button.SetProperty( Button::Property::DISABLED, false );
257 button.SetProperty( Button::Property::SELECTED, !SELECTED );
259 isSelected = button.GetProperty<bool>( Button::Property::SELECTED );
260 DALI_TEST_EQUALS( isSelected, !SELECTED , TEST_LOCATION );
265 int UtcDaliButtonPropertyGetLabelAlignment(void)
267 ToolkitTestApplication application;
268 tet_infoline(" UtcDaliPushButtonPropertyGetLabelAlignment\n");
270 Button button = PushButton::New();
271 button.SetProperty( Toolkit::Button::Property::LABEL_RELATIVE_ALIGNMENT, "END" );
272 DALI_TEST_EQUALS( button.GetProperty<std::string>( Toolkit::Button::Property::LABEL_RELATIVE_ALIGNMENT ), "END", TEST_LOCATION );
277 int UtcDaliButtonIsDisabledP(void)
279 ToolkitTestApplication application;
281 Button button = PushButton::New();
283 button.SetDisabled( true );
285 DALI_TEST_CHECK( button.IsDisabled() );
287 button.SetDisabled( false );
289 DALI_TEST_CHECK( !button.IsDisabled() );
293 int UtcDaliButtonSetAutoRepeatingP(void)
295 ToolkitTestApplication application;
297 Button button = PushButton::New();
299 button.SetAutoRepeating( true );
301 DALI_TEST_CHECK( button.IsAutoRepeating() );
303 button.SetAutoRepeating( false );
305 DALI_TEST_CHECK( !button.IsAutoRepeating() );
307 button.SetAutoRepeating( true );
309 DALI_TEST_CHECK( button.IsAutoRepeating() );
311 button.SetAutoRepeating( false );
313 DALI_TEST_CHECK( !button.IsAutoRepeating() );
317 int UtcDaliButtonIsAutoRepeatingP(void)
319 ToolkitTestApplication application;
321 Button button = PushButton::New();
323 button.SetAutoRepeating( true );
325 DALI_TEST_CHECK( button.IsAutoRepeating() );
327 button.SetAutoRepeating( false );
329 DALI_TEST_CHECK( !button.IsAutoRepeating() );
333 int UtcDaliButtonAutoRepeatingP(void)
335 ToolkitTestApplication application;
336 tet_infoline(" UtcDaliButtonPressedSignalP Setup Autorepeating and check multiple clicked signals received\n");
338 const float AUTO_REPEATING_DELAY = 0.15f;
340 Button button = PushButton::New();
341 button.SetAnchorPoint( AnchorPoint::TOP_LEFT );
342 button.SetParentOrigin( ParentOrigin::TOP_LEFT );
343 button.SetPosition( 240, 400 );
344 button.SetSize( 100, 100 );
345 Stage::GetCurrent().Add( button );
347 application.SendNotification();
348 application.Render();
350 button.SetProperty( Toolkit::Button::Property::AUTO_REPEATING, true );
351 button.SetProperty( Toolkit::Button::Property::INITIAL_AUTO_REPEATING_DELAY, AUTO_REPEATING_DELAY );
352 // connect to its touch signal
353 ConnectionTracker* testTracker = new ConnectionTracker();
354 button.PressedSignal().Connect( &ButtonCallback );
355 button.ClickedSignal().Connect( &ButtonCallback );
356 bool clickedSignal = false;
357 bool pressedSignal = false;
358 button.ConnectSignal( testTracker, "pressed", CallbackFunctor(&pressedSignal) );
359 button.ConnectSignal( testTracker, "clicked", CallbackFunctor(&clickedSignal) );
361 Dali::Integration::TouchEvent event;
363 // Touch point down and up inside the button.
365 gIsCalledButtonCallback = false;
366 event = Dali::Integration::TouchEvent();
367 event.AddPoint( GetPointDownInside() );
368 application.ProcessEvent( event );
370 DALI_TEST_EQUALS( gIsCalledButtonCallback, true, TEST_LOCATION );
371 DALI_TEST_EQUALS( pressedSignal, true, TEST_LOCATION );
372 tet_infoline("Consume first clicked signal then wait\n");
374 gIsCalledButtonCallback = false;
375 Dali::Timer timer = Timer::New( AUTO_REPEATING_DELAY );
376 timer.MockEmitSignal();
377 application.Wait( AUTO_REPEATING_DELAY*2 );
378 DALI_TEST_EQUALS( clickedSignal, true, TEST_LOCATION );
379 tet_infoline("Check gIsCalledButtonCallback was called again after last consumption of it.\n");
381 DALI_TEST_EQUALS( gIsCalledButtonCallback, true, TEST_LOCATION );
383 gIsCalledButtonCallback = false;
384 event = Dali::Integration::TouchEvent();
385 event.AddPoint( GetPointUpInside() );
386 application.ProcessEvent( event );
388 DALI_TEST_EQUALS( gIsCalledButtonCallback, true, TEST_LOCATION );
393 int UtcDaliButtonSetInitialAutoRepeatingDelayP(void)
395 ToolkitTestApplication application;
397 Button button = PushButton::New();
399 button.SetInitialAutoRepeatingDelay( 0.5f );
401 DALI_TEST_EQUALS( button.GetInitialAutoRepeatingDelay(), 0.5f, TEST_LOCATION );
403 button.SetInitialAutoRepeatingDelay( 0.2f );
405 DALI_TEST_EQUALS( button.GetInitialAutoRepeatingDelay(), 0.2f, TEST_LOCATION );
409 int UtcDaliButtonSetNextAutoRepeatingDelayP(void)
411 ToolkitTestApplication application;
413 Button button = PushButton::New();
415 button.SetNextAutoRepeatingDelay( 0.5f );
417 DALI_TEST_EQUALS( button.GetNextAutoRepeatingDelay(), 0.5f, TEST_LOCATION );
419 button.SetProperty( Button::Property::NEXT_AUTO_REPEATING_DELAY, 0.2f );
421 DALI_TEST_EQUALS( button.GetNextAutoRepeatingDelay(), 0.2f, TEST_LOCATION );
425 int UtcDaliButtonSetTogglableButtonP(void)
427 ToolkitTestApplication application;
429 Button button = PushButton::New();
431 button.SetTogglableButton( true );
433 DALI_TEST_CHECK( button.IsTogglableButton() );
435 button.SetTogglableButton( false );
437 DALI_TEST_CHECK( !button.IsTogglableButton() );
441 int UtcDaliButtonSetSelectedP(void)
443 ToolkitTestApplication application;
445 Button button = PushButton::New();
446 button.SetTogglableButton( true );
448 button.SetSelected( true );
450 DALI_TEST_CHECK( button.IsSelected() );
452 button.SetSelected( false );
454 DALI_TEST_CHECK( !button.IsSelected() );
458 int UtcDaliButtonSetAnimationTimeP(void)
460 ToolkitTestApplication application;
461 tet_infoline(" UtcDaliButtonSetAnimationTimeP");
463 Button button = PushButton::New();
465 button.SetAnimationTime( ANIMATION_TIME );
467 DALI_TEST_EQUALS( button.GetAnimationTime(), ANIMATION_TIME, TEST_LOCATION );
471 int UtcDaliButtonSetLabelStringP(void)
473 ToolkitTestApplication application;
475 Button button = PushButton::New();
477 button.SetLabelText( "Button Label" );
479 DALI_TEST_EQUALS( button.GetLabelText(), "Button Label", TEST_LOCATION );
483 int UtcDaliButtonSetLabelPropertyP(void)
485 ToolkitTestApplication application;
487 const std::string TEST_LABEL1 = "test label one";
488 const std::string TEST_LABEL2 = "test label two";
490 Button button = PushButton::New();
492 button.SetProperty( Button::Property::LABEL_TEXT, TEST_LABEL1 );
494 std::string labelText = button.GetProperty<std::string>( Button::Property::LABEL_TEXT );
496 DALI_TEST_EQUALS( labelText, TEST_LABEL1, TEST_LOCATION );
498 Property::Map propertyMap;
499 propertyMap.Insert( Toolkit::TextLabel::Property::TEXT, TEST_LABEL2 );
500 propertyMap.Insert( Toolkit::TextLabel::Property::TEXT_COLOR, Color::BLUE);
501 button.SetProperty( Button::Property::LABEL, propertyMap );
503 labelText = button.GetProperty<std::string>( Button::Property::LABEL_TEXT );
505 DALI_TEST_EQUALS( labelText, TEST_LABEL2, TEST_LOCATION );
510 int UtcDaliButtonSetUnselectedImageP(void)
512 ToolkitTestApplication application;
513 tet_infoline(" UtcDaliButtonSetUnselectedImageP");
515 PushButton pushButton = PushButton::New();
516 Stage::GetCurrent().Add( pushButton );
518 application.SendNotification();
519 application.Render();
521 pushButton.SetUnselectedImage( "Image.jpg" );
523 application.SendNotification();
524 application.Render();
526 DALI_TEST_CHECK( pushButton );
531 int UtcDaliButtonSetSelectedImageP(void)
533 ToolkitTestApplication application;
534 tet_infoline(" UtcDaliButtonSetButtonImage");
536 PushButton pushButton = PushButton::New();
537 Stage::GetCurrent().Add( pushButton );
539 application.SendNotification();
540 application.Render();
542 pushButton.SetSelectedImage( "Image.jpg" );
544 application.SendNotification();
545 application.Render();
547 DALI_TEST_CHECK( pushButton );
552 int UtcDaliButtonPressedSignalP(void)
554 ToolkitTestApplication application;
555 tet_infoline(" UtcDaliButtonPressedSignalP");
557 Button button = PushButton::New();
558 button.SetAnchorPoint( AnchorPoint::TOP_LEFT );
559 button.SetParentOrigin( ParentOrigin::TOP_LEFT );
560 button.SetPosition( 240, 400 );
561 button.SetSize( 100, 100 );
563 Stage::GetCurrent().Add( button );
565 application.SendNotification();
566 application.Render();
568 // connect to its touch signal
569 ConnectionTracker* testTracker = new ConnectionTracker();
570 button.PressedSignal().Connect( &ButtonCallback );
571 button.ReleasedSignal().Connect( &ButtonCallback );
572 bool pressedSignal = false;
573 bool releasedSignal = false;
574 button.ConnectSignal( testTracker, "pressed", CallbackFunctor(&pressedSignal) );
575 button.ConnectSignal( testTracker, "released", CallbackFunctor(&releasedSignal) );
577 Dali::Integration::TouchEvent event;
579 // Test1. Touch point down and up inside the button.
581 gIsCalledButtonCallback = false;
582 event = Dali::Integration::TouchEvent();
583 event.AddPoint( GetPointDownInside() );
584 application.ProcessEvent( event );
586 DALI_TEST_CHECK( gIsCalledButtonCallback );
587 DALI_TEST_CHECK( pressedSignal );
589 gIsCalledButtonCallback = false;
590 event = Dali::Integration::TouchEvent();
591 event.AddPoint( GetPointUpInside() );
592 application.ProcessEvent( event );
594 DALI_TEST_CHECK( gIsCalledButtonCallback );
595 DALI_TEST_CHECK( releasedSignal );
597 // Test2. Touch point down and up outside the button.
599 pressedSignal = false;
600 releasedSignal = false;
601 gIsCalledButtonCallback = false;
602 event = Dali::Integration::TouchEvent();
603 event.AddPoint( GetPointDownOutside() );
604 application.ProcessEvent( event );
606 DALI_TEST_CHECK( !gIsCalledButtonCallback );
607 DALI_TEST_CHECK( !pressedSignal );
609 gIsCalledButtonCallback = false;
610 event = Dali::Integration::TouchEvent();
611 event.AddPoint( GetPointUpOutside() );
612 application.ProcessEvent( event );
614 DALI_TEST_CHECK( !gIsCalledButtonCallback );
615 DALI_TEST_CHECK( !releasedSignal );
617 // Test3. Touch point down inside and up outside the button.
619 gIsCalledButtonCallback = false;
620 event = Dali::Integration::TouchEvent();
621 event.AddPoint( GetPointDownInside() );
622 application.ProcessEvent( event );
624 DALI_TEST_CHECK( gIsCalledButtonCallback );
626 gIsCalledButtonCallback = false;
627 event = Dali::Integration::TouchEvent();
628 event.AddPoint( GetPointLeave() );
629 application.ProcessEvent( event );
631 event = Dali::Integration::TouchEvent();
632 event.AddPoint( GetPointUpOutside() );
633 application.ProcessEvent( event );
635 DALI_TEST_CHECK( gIsCalledButtonCallback );
637 // Test4. Touch point down outside and up inside the button.
639 gIsCalledButtonCallback = false;
640 event = Dali::Integration::TouchEvent();
641 event.AddPoint( GetPointDownOutside() );
642 application.ProcessEvent( event );
644 DALI_TEST_CHECK( !gIsCalledButtonCallback );
646 gIsCalledButtonCallback = false;
647 event = Dali::Integration::TouchEvent();
648 event.AddPoint( GetPointEnter() );
649 application.ProcessEvent( event );
651 event = Dali::Integration::TouchEvent();
652 event.AddPoint( GetPointUpInside() );
653 application.ProcessEvent( event );
655 DALI_TEST_CHECK( !gIsCalledButtonCallback );
659 int UtcDaliButtonClickedSignalP(void)
661 ToolkitTestApplication application;
662 tet_infoline(" UtcDaliButtonClickedSignalP");
664 Button button = PushButton::New();
665 button.SetAnchorPoint( AnchorPoint::TOP_LEFT );
666 button.SetParentOrigin( ParentOrigin::TOP_LEFT );
667 button.SetPosition( 240, 400 );
668 button.SetSize( 100, 100 );
670 Stage::GetCurrent().Add( button );
672 application.SendNotification();
673 application.Render();
675 // connect to its touch signal
676 button.ClickedSignal().Connect( &ButtonCallback );
677 bool clickedSignal = false;
678 ConnectionTracker* testTracker = new ConnectionTracker();
679 button.ConnectSignal( testTracker, "clicked", CallbackFunctor(&clickedSignal) );
681 Dali::Integration::TouchEvent event;
683 // Test1. Touch point down and up inside the button.
685 gIsCalledButtonCallback = false;
686 event = Dali::Integration::TouchEvent();
687 event.AddPoint( GetPointDownInside() );
688 application.ProcessEvent( event );
690 event = Dali::Integration::TouchEvent();
691 event.AddPoint( GetPointUpInside() );
692 application.ProcessEvent( event );
694 DALI_TEST_CHECK( gIsCalledButtonCallback );
695 DALI_TEST_CHECK( clickedSignal );
697 // Test2. Touch point down and up outside the button.
699 gIsCalledButtonCallback = false;
700 clickedSignal = false;
701 event = Dali::Integration::TouchEvent();
702 event.AddPoint( GetPointDownOutside() );
703 application.ProcessEvent( event );
705 event = Dali::Integration::TouchEvent();
706 event.AddPoint( GetPointUpOutside() );
707 application.ProcessEvent( event );
709 DALI_TEST_CHECK( !gIsCalledButtonCallback );
710 DALI_TEST_CHECK( !clickedSignal );
712 // Test3. Touch point down inside and up outside the button.
714 gIsCalledButtonCallback = false;
715 clickedSignal = false;
716 event = Dali::Integration::TouchEvent();
717 event.AddPoint( GetPointDownInside() );
718 application.ProcessEvent( event );
720 event = Dali::Integration::TouchEvent();
721 event.AddPoint( GetPointLeave() );
722 application.ProcessEvent( event );
724 event = Dali::Integration::TouchEvent();
725 event.AddPoint( GetPointUpOutside() );
726 application.ProcessEvent( event );
728 DALI_TEST_CHECK( !gIsCalledButtonCallback );
729 DALI_TEST_CHECK( !clickedSignal );
731 // Test4. Touch point down outside and up inside the button.
733 gIsCalledButtonCallback = false;
734 clickedSignal = false;
735 event = Dali::Integration::TouchEvent();
736 event.AddPoint( GetPointDownOutside() );
737 application.ProcessEvent( event );
739 event = Dali::Integration::TouchEvent();
740 event.AddPoint( GetPointEnter() );
741 application.ProcessEvent( event );
743 event = Dali::Integration::TouchEvent();
744 event.AddPoint( GetPointUpInside() );
745 application.ProcessEvent( event );
747 DALI_TEST_CHECK( !gIsCalledButtonCallback );
748 DALI_TEST_CHECK( !clickedSignal );
752 int UtcDaliButtonStateChangedSignalP(void)
754 ToolkitTestApplication application;
755 tet_infoline(" UtcDaliButtonStateChangedSignalP");
757 Button button = PushButton::New();
758 button.SetTogglableButton( true );
760 Stage::GetCurrent().Add( button );
762 application.SendNotification();
763 application.Render();
765 // connect to its signal
766 button.StateChangedSignal().Connect( &ButtonCallback );
767 bool stateChangedSignal = false;
768 ConnectionTracker* testTracker = new ConnectionTracker();
769 button.ConnectSignal( testTracker, "stateChanged", CallbackFunctor(&stateChangedSignal) );
771 gIsCalledButtonCallback = false;
772 button.SetSelected( true );
774 DALI_TEST_CHECK( gIsCalledButtonCallback );
775 DALI_TEST_CHECK( stateChangedSignal );
777 gIsCalledButtonCallback = false;
778 stateChangedSignal = false;
780 button.SetSelected( false );
782 DALI_TEST_CHECK( gIsCalledButtonCallback );
783 DALI_TEST_CHECK( stateChangedSignal );
787 int UtcDaliButtonSetProperty(void)
789 tet_infoline("UtcDaliButtonSetProperty: ");
790 ToolkitTestApplication application;
792 PushButton pushButton = PushButton::New();
794 pushButton.SetProperty(pushButton.GetPropertyIndex("disabled"), false);
795 DALI_TEST_CHECK( false == pushButton.IsDisabled() );
797 pushButton.SetProperty(pushButton.GetPropertyIndex("disabled"), true);
798 DALI_TEST_CHECK( true == pushButton.IsDisabled() );
803 int UtcDaliButtonSize(void)
805 ToolkitTestApplication application;
806 tet_infoline(" UtcDaliButtonSize");
808 // First an image is set, then SetSize is called.
809 PushButton pushButton = PushButton::New();
810 Stage::GetCurrent().Add( pushButton );
812 pushButton.SetBackgroundImage( "Image.jpg" );
813 pushButton.SetSize( 10.f, 10.f );
815 application.SendNotification();
816 application.Render();
818 Vector3 size = pushButton.GetCurrentSize();
820 DALI_TEST_EQUALS( size.width, 10.f, TEST_LOCATION );
821 DALI_TEST_EQUALS( size.height, 10.f, TEST_LOCATION );
825 int UtcDaliButtonSetSelectedBackgroundImageP(void)
827 ToolkitTestApplication application;
829 PushButton button = PushButton::New();
830 Stage::GetCurrent().Add( button );
834 button.SetSelectedBackgroundImage( "TestImage.jpg");
835 DALI_TEST_CHECK( true );
839 DALI_TEST_CHECK( false );
845 int UtcDaliButtonSetSelectedBackgroundImageN(void)
847 ToolkitTestApplication application;
853 button.SetSelectedBackgroundImage( "TestImage.jpg");
854 DALI_TEST_CHECK( false );
858 DALI_TEST_CHECK( true );
864 int UtcDaliButtonSetDisabledImageP(void)
866 ToolkitTestApplication application;
868 PushButton button = PushButton::New();
869 Stage::GetCurrent().Add( button );
873 button.SetDisabledImage( "TestImage.jpg");
874 DALI_TEST_CHECK( true );
878 DALI_TEST_CHECK( false );
884 int UtcDaliButtonSetDisabledImageN(void)
886 ToolkitTestApplication application;
892 button.SetDisabledImage( "TestImage.jpg");
893 DALI_TEST_CHECK( false );
897 DALI_TEST_CHECK( true );
903 int UtcDaliButtonSetDisabledSelectedImageP(void)
905 ToolkitTestApplication application;
907 PushButton button = PushButton::New();
908 Stage::GetCurrent().Add( button );
912 button.SetDisabledSelectedImage( "TestImage.jpg");
913 DALI_TEST_CHECK( true );
917 DALI_TEST_CHECK( false );
923 int UtcDaliButtonSetDisabledSelectedImageN(void)
925 ToolkitTestApplication application;
931 button.SetDisabledSelectedImage( "TestImage.jpg");
932 DALI_TEST_CHECK( false );
936 DALI_TEST_CHECK( true );
942 int UtcDaliButtonSetLabeActorlP(void)
944 ToolkitTestApplication application;
946 PushButton button = PushButton::New();
947 Stage::GetCurrent().Add( button );
951 button.SetLabel( TextLabel::New("Hello") );
952 DALI_TEST_CHECK( true );
956 DALI_TEST_CHECK( false );
962 int UtcDaliButtonSetLabelN(void)
964 ToolkitTestApplication application;
970 button.SetLabel( TextLabel::New("Hello") );
971 DALI_TEST_CHECK( false );
975 DALI_TEST_CHECK( true );
981 int UtcDaliButtonSetButtonImageP(void)
983 ToolkitTestApplication application;
985 PushButton button = PushButton::New();
986 Stage::GetCurrent().Add( button );
990 ResourceImage image1 = ResourceImage::New( "TestImage.jpg");
991 button.SetButtonImage( image1 );
993 Property::Value value = button.GetProperty(Button::Property::UNSELECTED_STATE_IMAGE );
994 DALI_TEST_CHECK( value.Get<std::string>() == "TestImage.jpg" );
998 DALI_TEST_CHECK( false );
1004 int UtcDaliButtonSetButtonImageN(void)
1006 ToolkitTestApplication application;
1012 ResourceImage image1 = ResourceImage::New( "TestImage.jpg");
1013 button.SetButtonImage( image1 );
1015 DALI_TEST_CHECK( false );
1019 DALI_TEST_CHECK( true );
1025 int UtcDaliButtonSetSelectedImageWithImageP(void)
1027 ToolkitTestApplication application;
1029 PushButton button = PushButton::New();
1030 Stage::GetCurrent().Add( button );
1031 ResourceImage image1 = ResourceImage::New( TEST_IMAGE_ONE );
1035 button.SetSelectedImage( image1 );
1036 Property::Value value = button.GetProperty(Button::Property::SELECTED_STATE_IMAGE );
1037 DALI_TEST_CHECK( value.Get<std::string>() == TEST_IMAGE_ONE );
1041 DALI_TEST_CHECK( false );
1047 int UtcDaliButtonSetSelectedImageWithImageN(void)
1049 ToolkitTestApplication application;
1055 button.SetSelectedImage( CreateBufferImage( 10, 10, Color::WHITE ) );
1056 DALI_TEST_CHECK( false );
1060 DALI_TEST_CHECK( true );
1066 int UtcDaliButtonSetSelectedColorP(void)
1068 ToolkitTestApplication application;
1069 tet_infoline(" UtcDaliButtonSetSelectedColorP");
1071 PushButton pushButton = PushButton::New();
1072 Stage::GetCurrent().Add( pushButton );
1074 application.SendNotification();
1075 application.Render();
1077 const Vector4 SET_COLOR = Color::BLUE;
1079 pushButton.SetSize( Vector2( 20.0f, 20.0f ) );
1080 pushButton.SetProperty( Button::Property::SELECTED_COLOR, SET_COLOR );
1082 application.SendNotification();
1083 application.Render();
1085 Vector4 color = pushButton.GetProperty<Vector4>( Button::Property::SELECTED_COLOR );
1087 DALI_TEST_EQUALS( color, SET_COLOR, TEST_LOCATION );
1092 int UtcDaliButtonSetUnSelectedColorP(void)
1094 ToolkitTestApplication application;
1095 tet_infoline(" UtcDaliButtonSetUnSelectedColorP");
1097 PushButton pushButton = PushButton::New();
1098 Stage::GetCurrent().Add( pushButton );
1100 application.SendNotification();
1101 application.Render();
1103 const Vector4 SET_COLOR = Color::BLUE;
1105 pushButton.SetSize( Vector2( 20.0f, 20.0f ) );
1106 pushButton.SetProperty( Button::Property::UNSELECTED_COLOR, SET_COLOR );
1108 application.SendNotification();
1109 application.Render();
1111 Vector4 color = pushButton.GetProperty<Vector4>( Button::Property::UNSELECTED_COLOR );
1113 DALI_TEST_EQUALS( color, SET_COLOR, TEST_LOCATION );
1118 int UtcDaliButtonResetSelectedColorP(void)
1120 ToolkitTestApplication application;
1121 tet_infoline(" UtcDaliButtonSetSelectedColorP");
1123 PushButton pushButton = PushButton::New();
1124 Stage::GetCurrent().Add( pushButton );
1126 application.SendNotification();
1127 application.Render();
1129 const Vector4 FIRST_COLOR = Color::BLUE;
1130 const Vector4 SECOND_COLOR = Color::BLUE;
1132 pushButton.SetSize( Vector2( 20.0f, 20.0f ) );
1133 pushButton.SetProperty( Button::Property::SELECTED_COLOR, FIRST_COLOR );
1135 application.SendNotification();
1136 application.Render();
1138 Vector4 color = pushButton.GetProperty<Vector4>( Button::Property::SELECTED_COLOR );
1140 DALI_TEST_EQUALS( color, FIRST_COLOR, TEST_LOCATION );
1142 pushButton.SetProperty( Button::Property::SELECTED_COLOR, SECOND_COLOR );
1144 application.SendNotification();
1145 application.Render();
1147 color = pushButton.GetProperty<Vector4>( Button::Property::SELECTED_COLOR );
1149 DALI_TEST_EQUALS( color, SECOND_COLOR, TEST_LOCATION );
1154 int UtcDaliButtonSetImagesWithDeprecatedProperties(void)
1156 ToolkitTestApplication application;
1157 tet_infoline(" UtcDaliButtonSetImagesWithDeprecatedProperties");
1159 PushButton pushButton = PushButton::New();
1160 Stage::GetCurrent().Add( pushButton );
1162 Property::Map propertyMap;
1163 propertyMap.Insert(Visual::Property::TYPE, Visual::COLOR);
1164 propertyMap.Insert(ColorVisual::Property::MIX_COLOR, Color::BLUE);
1166 DALI_TEST_EQUALS( pushButton.GetRendererCount(), 0, TEST_LOCATION );
1168 pushButton.SetProperty( Toolkit::Button::Property::UNSELECTED_STATE_IMAGE, propertyMap );
1169 application.SendNotification();
1170 application.Render();
1171 DALI_TEST_EQUALS( pushButton.GetRendererCount(), 1, TEST_LOCATION );
1173 tet_infoline(" Set state to selected and provide SELECTED visual");
1174 pushButton.SetProperty( Toolkit::Button::Property::SELECTED_STATE_IMAGE, propertyMap );
1175 pushButton.SetProperty( Toolkit::Button::Property::SELECTED, true );
1176 application.SendNotification();
1177 application.Render();
1178 DALI_TEST_EQUALS( pushButton.GetRendererCount(), 1, TEST_LOCATION );
1180 tet_infoline(" Set state to selected, disabled and provide DISABLED_STATE_IMAGE visual");
1181 pushButton.SetProperty( Toolkit::Button::Property::SELECTED, false );
1182 pushButton.SetProperty( Toolkit::Button::Property::DISABLED, true );
1183 pushButton.SetProperty( Toolkit::Button::Property::DISABLED_STATE_IMAGE, propertyMap );
1184 application.SendNotification();
1185 application.Render();
1186 DALI_TEST_EQUALS( pushButton.GetRendererCount(), 1, TEST_LOCATION );
1191 int UtcDaliButtonSetGetDepreciatedPropertiesWithURL(void)
1193 ToolkitTestApplication application;
1194 tet_infoline(" UtcDaliButtonSetGetDepreciatedPropertiesWithURL");
1196 PushButton button = PushButton::New();
1197 Stage::GetCurrent().Add( button );
1199 tet_infoline(" Set state to selected, disabled and provide DISABLED_STATE_IMAGE visual");
1200 button.SetProperty( Toolkit::Button::Property::DISABLED, true );
1201 button.SetProperty( Toolkit::Button::Property::DISABLED_STATE_IMAGE, TEST_IMAGE_ONE );
1203 Property::Value value = button.GetProperty(Button::Property::DISABLED_STATE_IMAGE );
1204 DALI_TEST_EQUALS( value.Get<std::string>(), TEST_IMAGE_ONE, TEST_LOCATION );