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.
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>
30 #include <dali-toolkit/devel-api/controls/buttons/button-devel.h>
33 using namespace Toolkit;
36 void utc_dali_toolkit_button_startup(void)
38 test_return_value = TET_UNDEF;
41 void utc_dali_toolkit_button_cleanup(void)
43 test_return_value = TET_PASS;
48 static bool gIsCalledButtonCallback = false;
50 const int RENDER_FRAME_INTERVAL = 16;
52 static bool ButtonCallback( Button button )
54 gIsCalledButtonCallback = true;
58 static std::string GetButtonText( Button button )
60 Property::Value value = button.GetProperty( Toolkit::Button::Property::LABEL );
62 Property::Map *labelProperty = value.GetMap();
64 std::string textLabel;
68 Property::Value* value = labelProperty->Find( Toolkit::TextVisual::Property::TEXT );
69 value->Get( textLabel );
75 struct CallbackFunctor
77 CallbackFunctor(bool* callbackFlag)
78 : mCallbackFlag( callbackFlag )
84 *mCallbackFlag = true;
89 Dali::Integration::Point GetPointDownInside()
91 Dali::Integration::Point point;
92 point.SetState( PointState::DOWN );
93 point.SetScreenPosition( Vector2( 240, 400 ) );
97 Dali::Integration::Point GetPointUpInside()
99 Dali::Integration::Point point;
100 point.SetState( PointState::UP );
101 point.SetScreenPosition( Vector2( 240, 400 ) );
105 Dali::Integration::Point GetPointLeave()
107 Dali::Integration::Point point;
108 point.SetState( PointState::LEAVE );
109 point.SetScreenPosition( Vector2( 240, 400 ) );
113 Dali::Integration::Point GetPointEnter()
115 Dali::Integration::Point point;
116 point.SetState( PointState::MOTION );
117 point.SetScreenPosition( Vector2( 240, 400 ) );
121 Dali::Integration::Point GetPointDownOutside()
123 Dali::Integration::Point point;
124 point.SetState( PointState::DOWN );
125 point.SetScreenPosition( Vector2( 10, 10 ) );
129 Dali::Integration::Point GetPointUpOutside()
131 Dali::Integration::Point point;
132 point.SetState( PointState::UP );
133 point.SetScreenPosition( Vector2( 10, 10 ) );
137 static float ANIMATION_TIME( 0.5f );
141 int UtcDaliButtonConstructorP(void)
143 TestApplication application;
147 DALI_TEST_CHECK( !button );
151 int UtcDaliButtonCopyConstructorP(void)
153 TestApplication application;
155 // Initialize an object, ref count == 1
156 Button button = PushButton::New();
158 Button copy( button );
159 DALI_TEST_CHECK( copy );
163 int UtcDaliButtonAssignmentOperatorP(void)
165 TestApplication application;
167 Button button = PushButton::New();
169 Button copy( button );
170 DALI_TEST_CHECK( copy );
172 DALI_TEST_CHECK( button == copy );
176 int UtcDaliButtonDownCastP(void)
178 TestApplication application;
180 Button button = PushButton::New();
182 BaseHandle object(button);
184 Button button2 = Button::DownCast( object );
185 DALI_TEST_CHECK(button2);
187 Button button3 = DownCast< Button >(object);
188 DALI_TEST_CHECK(button3);
192 int UtcDaliButtonDownCastN(void)
194 TestApplication application;
196 BaseHandle unInitializedObject;
198 Button button1 = Button::DownCast( unInitializedObject );
199 DALI_TEST_CHECK( !button1 );
201 Button button2 = DownCast< Button >( unInitializedObject );
202 DALI_TEST_CHECK( !button2 );
206 int UtcDaliButtonDisabledPropertyP(void)
208 ToolkitTestApplication application;
210 Button button = PushButton::New();
213 button.SetProperty( button.GetPropertyIndex("disabled"), true );
215 DALI_TEST_EQUALS( button.GetProperty<bool>( button.GetPropertyIndex("disabled")), true, TEST_LOCATION );
217 button.SetProperty( button.GetPropertyIndex("disabled"), false );
219 DALI_TEST_EQUALS( button.GetProperty<bool>( button.GetPropertyIndex("disabled")), false, TEST_LOCATION );
221 button.SetProperty( button.GetPropertyIndex("disabled"), true );
223 DALI_TEST_EQUALS( button.GetProperty<bool>( button.GetPropertyIndex("disabled")), true, TEST_LOCATION );
225 button.SetProperty( button.GetPropertyIndex("disabled"), false );
227 DALI_TEST_EQUALS( button.GetProperty<bool>( button.GetPropertyIndex("disabled")), false, TEST_LOCATION );
232 int UtcDaliButtonSetDisabledWithDifferentStates01P(void)
234 ToolkitTestApplication application;
236 tet_infoline("UtcDaliButtonSetDisabledWithDifferentStates01P\n");
238 Button button = PushButton::New();
240 bool SELECTED = true;
242 button.SetProperty( Button::Property::TOGGLABLE, true);
243 button.SetProperty( Button::Property::SELECTED, SELECTED );
245 button.SetProperty( Button::Property::DISABLED, true);
247 tet_infoline("Set button to SELECTED = false whilst disabled, should not change to false\n");
248 button.SetProperty( Button::Property::SELECTED, !SELECTED );
250 bool isSelected = button.GetProperty<bool>( Button::Property::SELECTED ) ;
252 DALI_TEST_EQUALS( isSelected, SELECTED , TEST_LOCATION );
257 int UtcDaliButtonSetDisabledWithDifferentStates02P(void)
259 ToolkitTestApplication application;
261 tet_infoline("UtcDaliButtonSetDisabledWithDifferentStates02\n");
263 Button button = PushButton::New();
265 bool SELECTED = true;
267 button.SetProperty( Button::Property::TOGGLABLE, true );
268 button.SetProperty( Button::Property::SELECTED, SELECTED );
269 button.SetProperty( Button::Property::DISABLED, true );
271 bool isSelected = button.GetProperty<bool>( Button::Property::SELECTED );
272 DALI_TEST_EQUALS( isSelected, SELECTED , TEST_LOCATION );
273 tet_infoline("Set button to DISABLED = false whilst disabled and then set to unselected\n");
275 button.SetProperty( Button::Property::DISABLED, false );
276 button.SetProperty( Button::Property::SELECTED, !SELECTED );
278 isSelected = button.GetProperty<bool>( Button::Property::SELECTED );
279 DALI_TEST_EQUALS( isSelected, !SELECTED , TEST_LOCATION );
284 int UtcDaliButtonPropertyGetLabelAlignment(void)
286 ToolkitTestApplication application;
287 tet_infoline(" UtcDaliPushButtonPropertyGetLabelAlignment\n");
289 Button button = PushButton::New();
290 button.SetProperty( Toolkit::DevelButton::Property::LABEL_RELATIVE_ALIGNMENT, "END" );
291 DALI_TEST_EQUALS( button.GetProperty<std::string>( Toolkit::DevelButton::Property::LABEL_RELATIVE_ALIGNMENT ), "END", TEST_LOCATION );
296 int UtcDaliButtonIsDisabledP(void)
298 ToolkitTestApplication application;
300 Button button = PushButton::New();
302 button.SetDisabled( true );
304 DALI_TEST_CHECK( button.IsDisabled() );
306 button.SetDisabled( false );
308 DALI_TEST_CHECK( !button.IsDisabled() );
312 int UtcDaliButtonAutoRepeatingPropertyP(void)
314 ToolkitTestApplication application;
316 Button button = PushButton::New();
318 button.SetProperty( button.GetPropertyIndex("autoRepeating"), true );
320 DALI_TEST_EQUALS( button.GetProperty<bool>( button.GetPropertyIndex("autoRepeating")), true, TEST_LOCATION );
322 button.SetProperty( button.GetPropertyIndex("autoRepeating"), false );
324 DALI_TEST_EQUALS( button.GetProperty<bool>( button.GetPropertyIndex("autoRepeating")), false, TEST_LOCATION );
326 button.SetProperty( button.GetPropertyIndex("autoRepeating"), true );
328 DALI_TEST_EQUALS( button.GetProperty<bool>( button.GetPropertyIndex("autoRepeating")), true, TEST_LOCATION );
330 button.SetAutoRepeating( false );
332 DALI_TEST_CHECK( !button.IsAutoRepeating() );
336 int UtcDaliButtonIsAutoRepeatingP(void)
338 ToolkitTestApplication application;
340 Button button = PushButton::New();
342 button.SetAutoRepeating( true );
344 DALI_TEST_CHECK( button.IsAutoRepeating() );
346 button.SetAutoRepeating( false );
348 DALI_TEST_CHECK( !button.IsAutoRepeating() );
352 int UtcDaliButtonAutoRepeatingP(void)
354 ToolkitTestApplication application;
355 tet_infoline(" UtcDaliButtonPressedSignalP Setup Autorepeating and check multiple clicked signals received\n");
357 const float AUTO_REPEATING_DELAY = 0.15f;
359 Button button = PushButton::New();
360 button.SetAnchorPoint( AnchorPoint::TOP_LEFT );
361 button.SetParentOrigin( ParentOrigin::TOP_LEFT );
362 button.SetPosition( 240, 400 );
363 button.SetSize( 100, 100 );
364 Stage::GetCurrent().Add( button );
366 application.SendNotification();
367 application.Render();
369 button.SetProperty( Toolkit::Button::Property::AUTO_REPEATING, true );
370 button.SetProperty( Toolkit::Button::Property::INITIAL_AUTO_REPEATING_DELAY, AUTO_REPEATING_DELAY );
371 // connect to its touch signal
372 ConnectionTracker* testTracker = new ConnectionTracker();
373 button.PressedSignal().Connect( &ButtonCallback );
374 button.ClickedSignal().Connect( &ButtonCallback );
375 bool clickedSignal = false;
376 bool pressedSignal = false;
377 button.ConnectSignal( testTracker, "pressed", CallbackFunctor(&pressedSignal) );
378 button.ConnectSignal( testTracker, "clicked", CallbackFunctor(&clickedSignal) );
380 Dali::Integration::TouchEvent event;
382 // Touch point down and up inside the button.
384 gIsCalledButtonCallback = false;
385 event = Dali::Integration::TouchEvent();
386 event.AddPoint( GetPointDownInside() );
387 application.ProcessEvent( event );
389 DALI_TEST_EQUALS( gIsCalledButtonCallback, true, TEST_LOCATION );
390 DALI_TEST_EQUALS( pressedSignal, true, TEST_LOCATION );
391 tet_infoline("Consume first clicked signal then wait\n");
393 gIsCalledButtonCallback = false;
394 Dali::Timer timer = Timer::New( AUTO_REPEATING_DELAY );
395 timer.MockEmitSignal();
396 application.Wait( AUTO_REPEATING_DELAY*2 );
397 DALI_TEST_EQUALS( clickedSignal, true, TEST_LOCATION );
398 tet_infoline("Check gIsCalledButtonCallback was called again after last consumption of it.\n");
400 DALI_TEST_EQUALS( gIsCalledButtonCallback, true, TEST_LOCATION );
402 gIsCalledButtonCallback = false;
403 event = Dali::Integration::TouchEvent();
404 event.AddPoint( GetPointUpInside() );
405 application.ProcessEvent( event );
407 DALI_TEST_EQUALS( gIsCalledButtonCallback, true, TEST_LOCATION );
412 int UtcDaliButtonInitialAutoRepeatingDelayPropertyP(void)
414 ToolkitTestApplication application;
416 Button button = PushButton::New();
418 button.SetProperty( button.GetPropertyIndex("initialAutoRepeatingDelay"), 0.5f );
420 DALI_TEST_EQUALS( button.GetProperty<float>( button.GetPropertyIndex("initialAutoRepeatingDelay")), 0.5f, TEST_LOCATION );
422 button.SetProperty( button.GetPropertyIndex("initialAutoRepeatingDelay"), 0.2f );
424 DALI_TEST_EQUALS( button.GetProperty<float>( button.GetPropertyIndex("initialAutoRepeatingDelay")), 0.2f, TEST_LOCATION );
429 int UtcDaliButtonNextAutoRepeatingDelayPropertyP(void)
431 ToolkitTestApplication application;
433 Button button = PushButton::New();
435 button.SetProperty( button.GetPropertyIndex("nextAutoRepeatingDelay"), 0.5f );
437 DALI_TEST_EQUALS( button.GetProperty<float>( button.GetPropertyIndex("nextAutoRepeatingDelay")), 0.5f, TEST_LOCATION );
439 button.SetProperty( button.GetPropertyIndex("nextAutoRepeatingDelay"), 0.2f );
441 DALI_TEST_EQUALS( button.GetProperty<float>( button.GetPropertyIndex("nextAutoRepeatingDelay")), 0.2f, TEST_LOCATION );
445 int UtcDaliButtonTogglableButtonPropertyP(void)
447 ToolkitTestApplication application;
449 Button button = PushButton::New();
451 button.SetProperty( button.GetPropertyIndex("togglable"), true );
453 DALI_TEST_EQUALS( button.GetProperty<bool>( button.GetPropertyIndex("togglable")), true, TEST_LOCATION );
455 button.SetProperty( button.GetPropertyIndex("togglable"), false );
457 DALI_TEST_EQUALS( button.GetProperty<bool>( button.GetPropertyIndex("togglable")), false, TEST_LOCATION );
461 int UtcDaliButtonSelectedPropertyP(void)
463 ToolkitTestApplication application;
465 Button button = PushButton::New();
466 button.SetProperty( button.GetPropertyIndex("togglable"), true );
468 button.SetProperty( button.GetPropertyIndex("selected"), true );
470 DALI_TEST_EQUALS( button.GetProperty<bool>( button.GetPropertyIndex("selected")), true, TEST_LOCATION );
472 button.SetProperty( button.GetPropertyIndex("selected"), false );
474 DALI_TEST_EQUALS( button.GetProperty<bool>( button.GetPropertyIndex("selected")), false, TEST_LOCATION );
478 int UtcDaliButtonSetAnimationTimeP(void)
480 ToolkitTestApplication application;
481 tet_infoline(" UtcDaliButtonSetAnimationTimeP");
483 Button button = PushButton::New();
485 button.SetAnimationTime( ANIMATION_TIME );
487 DALI_TEST_EQUALS( button.GetAnimationTime(), ANIMATION_TIME, TEST_LOCATION );
491 int UtcDaliButtonSetLabelStringWithPropertyMapP(void)
493 ToolkitTestApplication application;
495 Button button = PushButton::New();
496 button.SetProperty( Toolkit::Button::Property::LABEL,
497 Property::Map().Add( Toolkit::Visual::Property::TYPE, Toolkit::Visual::TEXT )
498 .Add( Toolkit::TextVisual::Property::POINT_SIZE, 15.0f )
499 .Add( Toolkit::TextVisual::Property::TEXT, "Button Label")
502 DALI_TEST_EQUALS( GetButtonText( button ), "Button Label", TEST_LOCATION );
506 int UtcDaliButtonSetLabelStringWithPropertyMapStringsP(void)
508 ToolkitTestApplication application;
510 Button button = PushButton::New();
512 tet_infoline(" UtcDaliButtonSetLabelStringWithPropertyMapStringsP Setting Button text using String then replacing with Enum then string");
514 Property::Map textVisualMapInitial;
515 textVisualMapInitial["visualType"] = "TEXT";
516 textVisualMapInitial["pointSize"] = 15.0f;
517 textVisualMapInitial["text"] = "button label initial";
519 button.SetProperty( Button::Property::LABEL, textVisualMapInitial );
521 DALI_TEST_EQUALS( GetButtonText( button ), "button label initial", TEST_LOCATION );
523 tet_infoline(" UtcDaliButtonSetLabelStringWithPropertyMapStringsP Intermediate part of test");
525 Property::Map propertyMap;
526 propertyMap.Insert( Toolkit::Visual::Property::TYPE, Toolkit::Visual::TEXT );
527 propertyMap.Insert( Toolkit::TextVisual::Property::TEXT, "error if this is the final text" );
528 propertyMap.Insert( Toolkit::TextVisual::Property::POINT_SIZE, 15.0f );
530 button.SetProperty( Button::Property::LABEL, propertyMap );
532 DALI_TEST_EQUALS( GetButtonText( button ), "error if this is the final text", TEST_LOCATION );
534 tet_infoline(" UtcDaliButtonSetLabelStringWithPropertyMapStringsP Final part of test");
536 Property::Map textVisualMap;
537 textVisualMap["visualType"] = "TEXT";
538 textVisualMap["pointSize"] = 15.0f;
539 textVisualMap["text"] = "Button Label";
541 button.SetProperty( Toolkit::Button::Property::LABEL, textVisualMap );
543 DALI_TEST_EQUALS( GetButtonText( button ), "Button Label", TEST_LOCATION );
547 int UtcDaliButtonSetLabelWithStringP(void)
549 ToolkitTestApplication application;
551 Button button = PushButton::New();
553 // Set default point size for text visual as style sheet not available.
554 button.SetProperty( Toolkit::Button::Property::LABEL,
555 Property::Map().Add( Toolkit::Visual::Property::TYPE, Toolkit::Visual::TEXT )
556 .Add( Toolkit::TextVisual::Property::POINT_SIZE, 15.0f )
559 button.SetProperty( Toolkit::Button::Property::LABEL, "Button Label" );
561 DALI_TEST_EQUALS( GetButtonText( button ), "Button Label", TEST_LOCATION );
565 int UtcDaliButtonSetLabelPropertyP(void)
567 ToolkitTestApplication application;
569 tet_infoline(" UtcDaliButtonSetLabelPropertyP Set text label and then set again with new text");
572 const std::string TEST_LABEL1 = "test label one";
573 const std::string TEST_LABEL2 = "test label two";
575 Button button = PushButton::New();
577 button.SetProperty( Toolkit::Button::Property::LABEL,
578 Property::Map().Add( Toolkit::Visual::Property::TYPE, Toolkit::Visual::TEXT )
579 .Add( Toolkit::TextVisual::Property::POINT_SIZE, 15.0f )
580 .Add( Toolkit::TextVisual::Property::TEXT, TEST_LABEL1 )
583 DALI_TEST_EQUALS( GetButtonText( button ), TEST_LABEL1, TEST_LOCATION );
585 Property::Map propertyMap;
586 propertyMap.Insert( Toolkit::Visual::Property::TYPE, Toolkit::Visual::TEXT );
587 propertyMap.Insert( Toolkit::TextVisual::Property::TEXT, TEST_LABEL2 );
588 propertyMap.Insert( Toolkit::TextVisual::Property::TEXT_COLOR, Color::BLUE );
589 propertyMap.Insert( Toolkit::TextVisual::Property::POINT_SIZE, 15.0f );
590 button.SetProperty( Button::Property::LABEL, propertyMap );
592 DALI_TEST_EQUALS( GetButtonText( button ), TEST_LABEL2, TEST_LOCATION );
597 int UtcDaliButtonPressedSignalP(void)
599 ToolkitTestApplication application;
600 tet_infoline(" UtcDaliButtonPressedSignalP");
602 Button button = PushButton::New();
603 button.SetAnchorPoint( AnchorPoint::TOP_LEFT );
604 button.SetParentOrigin( ParentOrigin::TOP_LEFT );
605 button.SetPosition( 240, 400 );
606 button.SetSize( 100, 100 );
608 Stage::GetCurrent().Add( button );
610 application.SendNotification();
611 application.Render();
613 // connect to its touch signal
614 ConnectionTracker* testTracker = new ConnectionTracker();
615 button.PressedSignal().Connect( &ButtonCallback );
616 button.ReleasedSignal().Connect( &ButtonCallback );
617 bool pressedSignal = false;
618 bool releasedSignal = false;
619 button.ConnectSignal( testTracker, "pressed", CallbackFunctor(&pressedSignal) );
620 button.ConnectSignal( testTracker, "released", CallbackFunctor(&releasedSignal) );
622 Dali::Integration::TouchEvent event;
624 // Test1. Touch point down and up inside the button.
626 gIsCalledButtonCallback = false;
627 event = Dali::Integration::TouchEvent();
628 event.AddPoint( GetPointDownInside() );
629 application.ProcessEvent( event );
631 DALI_TEST_CHECK( gIsCalledButtonCallback );
632 DALI_TEST_CHECK( pressedSignal );
634 gIsCalledButtonCallback = false;
635 event = Dali::Integration::TouchEvent();
636 event.AddPoint( GetPointUpInside() );
637 application.ProcessEvent( event );
639 DALI_TEST_CHECK( gIsCalledButtonCallback );
640 DALI_TEST_CHECK( releasedSignal );
642 // Test2. Touch point down and up outside the button.
644 pressedSignal = false;
645 releasedSignal = false;
646 gIsCalledButtonCallback = false;
647 event = Dali::Integration::TouchEvent();
648 event.AddPoint( GetPointDownOutside() );
649 application.ProcessEvent( event );
651 DALI_TEST_CHECK( !gIsCalledButtonCallback );
652 DALI_TEST_CHECK( !pressedSignal );
654 gIsCalledButtonCallback = false;
655 event = Dali::Integration::TouchEvent();
656 event.AddPoint( GetPointUpOutside() );
657 application.ProcessEvent( event );
659 DALI_TEST_CHECK( !gIsCalledButtonCallback );
660 DALI_TEST_CHECK( !releasedSignal );
662 // Test3. Touch point down inside and up outside the button.
664 gIsCalledButtonCallback = false;
665 event = Dali::Integration::TouchEvent();
666 event.AddPoint( GetPointDownInside() );
667 application.ProcessEvent( event );
669 DALI_TEST_CHECK( gIsCalledButtonCallback );
671 gIsCalledButtonCallback = false;
672 event = Dali::Integration::TouchEvent();
673 event.AddPoint( GetPointLeave() );
674 application.ProcessEvent( event );
676 event = Dali::Integration::TouchEvent();
677 event.AddPoint( GetPointUpOutside() );
678 application.ProcessEvent( event );
680 DALI_TEST_CHECK( gIsCalledButtonCallback );
682 // Test4. Touch point down outside and up inside the button.
684 gIsCalledButtonCallback = false;
685 event = Dali::Integration::TouchEvent();
686 event.AddPoint( GetPointDownOutside() );
687 application.ProcessEvent( event );
689 DALI_TEST_CHECK( !gIsCalledButtonCallback );
691 gIsCalledButtonCallback = false;
692 event = Dali::Integration::TouchEvent();
693 event.AddPoint( GetPointEnter() );
694 application.ProcessEvent( event );
696 event = Dali::Integration::TouchEvent();
697 event.AddPoint( GetPointUpInside() );
698 application.ProcessEvent( event );
700 DALI_TEST_CHECK( !gIsCalledButtonCallback );
704 int UtcDaliButtonClickedSignalP(void)
706 ToolkitTestApplication application;
707 tet_infoline(" UtcDaliButtonClickedSignalP");
709 Button button = PushButton::New();
710 button.SetAnchorPoint( AnchorPoint::TOP_LEFT );
711 button.SetParentOrigin( ParentOrigin::TOP_LEFT );
712 button.SetPosition( 240, 400 );
713 button.SetSize( 100, 100 );
715 Stage::GetCurrent().Add( button );
717 application.SendNotification();
718 application.Render();
720 // connect to its touch signal
721 button.ClickedSignal().Connect( &ButtonCallback );
722 bool clickedSignal = false;
723 ConnectionTracker* testTracker = new ConnectionTracker();
724 button.ConnectSignal( testTracker, "clicked", CallbackFunctor(&clickedSignal) );
726 Dali::Integration::TouchEvent event;
728 // Test1. Touch point down and up inside the button.
730 gIsCalledButtonCallback = false;
731 event = Dali::Integration::TouchEvent();
732 event.AddPoint( GetPointDownInside() );
733 application.ProcessEvent( event );
735 event = Dali::Integration::TouchEvent();
736 event.AddPoint( GetPointUpInside() );
737 application.ProcessEvent( event );
739 DALI_TEST_CHECK( gIsCalledButtonCallback );
740 DALI_TEST_CHECK( clickedSignal );
742 // Test2. Touch point down and up outside the button.
744 gIsCalledButtonCallback = false;
745 clickedSignal = false;
746 event = Dali::Integration::TouchEvent();
747 event.AddPoint( GetPointDownOutside() );
748 application.ProcessEvent( event );
750 event = Dali::Integration::TouchEvent();
751 event.AddPoint( GetPointUpOutside() );
752 application.ProcessEvent( event );
754 DALI_TEST_CHECK( !gIsCalledButtonCallback );
755 DALI_TEST_CHECK( !clickedSignal );
757 // Test3. Touch point down inside and up outside the button.
759 gIsCalledButtonCallback = false;
760 clickedSignal = false;
761 event = Dali::Integration::TouchEvent();
762 event.AddPoint( GetPointDownInside() );
763 application.ProcessEvent( event );
765 event = Dali::Integration::TouchEvent();
766 event.AddPoint( GetPointLeave() );
767 application.ProcessEvent( event );
769 event = Dali::Integration::TouchEvent();
770 event.AddPoint( GetPointUpOutside() );
771 application.ProcessEvent( event );
773 DALI_TEST_CHECK( !gIsCalledButtonCallback );
774 DALI_TEST_CHECK( !clickedSignal );
776 // Test4. Touch point down outside and up inside the button.
778 gIsCalledButtonCallback = false;
779 clickedSignal = false;
780 event = Dali::Integration::TouchEvent();
781 event.AddPoint( GetPointDownOutside() );
782 application.ProcessEvent( event );
784 event = Dali::Integration::TouchEvent();
785 event.AddPoint( GetPointEnter() );
786 application.ProcessEvent( event );
788 event = Dali::Integration::TouchEvent();
789 event.AddPoint( GetPointUpInside() );
790 application.ProcessEvent( event );
792 DALI_TEST_CHECK( !gIsCalledButtonCallback );
793 DALI_TEST_CHECK( !clickedSignal );
797 int UtcDaliButtonStateChangedSignalP(void)
799 ToolkitTestApplication application;
800 tet_infoline(" UtcDaliButtonStateChangedSignalP");
802 Button button = PushButton::New();
804 button.SetProperty( Button::Property::TOGGLABLE, true);
806 Stage::GetCurrent().Add( button );
808 application.SendNotification();
809 application.Render();
811 // connect to its signal
812 button.StateChangedSignal().Connect( &ButtonCallback );
813 bool stateChangedSignal = false;
814 ConnectionTracker* testTracker = new ConnectionTracker();
815 button.ConnectSignal( testTracker, "stateChanged", CallbackFunctor(&stateChangedSignal) );
817 gIsCalledButtonCallback = false;
818 button.SetProperty( Button::Property::SELECTED, true);
820 DALI_TEST_CHECK( gIsCalledButtonCallback );
821 DALI_TEST_CHECK( stateChangedSignal );
823 gIsCalledButtonCallback = false;
824 stateChangedSignal = false;
826 button.SetProperty( Button::Property::SELECTED, false);
827 DALI_TEST_CHECK( gIsCalledButtonCallback );
828 DALI_TEST_CHECK( stateChangedSignal );
832 int UtcDaliButtonSetProperty(void)
834 tet_infoline("UtcDaliButtonSetProperty: ");
835 ToolkitTestApplication application;
837 PushButton pushButton = PushButton::New();
839 pushButton.SetProperty(pushButton.GetPropertyIndex("disabled"), false);
841 DALI_TEST_EQUALS( pushButton.GetProperty<bool>( pushButton.GetPropertyIndex("disabled")), false, TEST_LOCATION );
843 pushButton.SetProperty(pushButton.GetPropertyIndex("disabled"), true);
844 DALI_TEST_EQUALS( pushButton.GetProperty<bool>( pushButton.GetPropertyIndex("disabled")), true, TEST_LOCATION );
849 // Deprecated API Tests
851 int UtcDaliButtonSetDisabledP(void)
853 ToolkitTestApplication application;
855 Button button = PushButton::New();
857 button.SetDisabled( true );
859 DALI_TEST_CHECK( button.IsDisabled() );
861 button.SetDisabled( false );
863 DALI_TEST_CHECK( !button.IsDisabled() );
865 button.SetDisabled( true );
867 DALI_TEST_CHECK( button.IsDisabled() );
869 button.SetDisabled( false );
871 DALI_TEST_CHECK( !button.IsDisabled() );
875 int UtcDaliButtonSetAutoRepeatingP(void)
877 ToolkitTestApplication application;
879 Button button = PushButton::New();
881 button.SetAutoRepeating( true );
883 DALI_TEST_CHECK( button.IsAutoRepeating() );
885 button.SetAutoRepeating( false );
887 DALI_TEST_CHECK( !button.IsAutoRepeating() );
889 button.SetAutoRepeating( true );
891 DALI_TEST_CHECK( button.IsAutoRepeating() );
893 button.SetAutoRepeating( false );
895 DALI_TEST_CHECK( !button.IsAutoRepeating() );
899 int UtcDaliButtonSetInitialAutoRepeatingDelayP(void)
901 ToolkitTestApplication application;
903 Button button = PushButton::New();
905 button.SetInitialAutoRepeatingDelay( 0.5f );
907 DALI_TEST_EQUALS( button.GetInitialAutoRepeatingDelay(), 0.5f, TEST_LOCATION );
909 button.SetInitialAutoRepeatingDelay( 0.2f );
911 DALI_TEST_EQUALS( button.GetInitialAutoRepeatingDelay(), 0.2f, TEST_LOCATION );
915 int UtcDaliButtonSetNextAutoRepeatingDelayP(void)
917 ToolkitTestApplication application;
919 Button button = PushButton::New();
921 button.SetNextAutoRepeatingDelay( 0.5f );
923 DALI_TEST_EQUALS( button.GetNextAutoRepeatingDelay(), 0.5f, TEST_LOCATION );
925 button.SetProperty( Button::Property::NEXT_AUTO_REPEATING_DELAY, 0.2f );
927 DALI_TEST_EQUALS( button.GetNextAutoRepeatingDelay(), 0.2f, TEST_LOCATION );
931 int UtcDaliButtonSetTogglableButtonP(void)
933 ToolkitTestApplication application;
935 Button button = PushButton::New();
937 button.SetTogglableButton( true );
939 DALI_TEST_CHECK( button.IsTogglableButton() );
941 button.SetTogglableButton( false );
943 DALI_TEST_CHECK( !button.IsTogglableButton() );
947 int UtcDaliButtonSetSelectedP(void)
949 ToolkitTestApplication application;
951 Button button = PushButton::New();
952 button.SetTogglableButton( true );
954 button.SetSelected( true );
956 DALI_TEST_CHECK( button.IsSelected() );
958 button.SetSelected( false );
960 DALI_TEST_CHECK( !button.IsSelected() );