X-Git-Url: http://review.tizen.org/git/?p=platform%2Fcore%2Fuifw%2Fdali-toolkit.git;a=blobdiff_plain;f=automated-tests%2Fsrc%2Fdali-toolkit-internal%2Futc-Dali-PushButton.cpp;h=edaf7fd3819fc1213ee6e8b99963ee261fa8d9ba;hp=ccfb8637bdf09711cc698eb341300b0c33b63bc5;hb=acbf7e2c17c1578c7125fa07c7eaabe1fe214406;hpb=be0d47169c97f0a3100834d0c129032bdefce9c6 diff --git a/automated-tests/src/dali-toolkit-internal/utc-Dali-PushButton.cpp b/automated-tests/src/dali-toolkit-internal/utc-Dali-PushButton.cpp index ccfb863..edaf7fd 100644 --- a/automated-tests/src/dali-toolkit-internal/utc-Dali-PushButton.cpp +++ b/automated-tests/src/dali-toolkit-internal/utc-Dali-PushButton.cpp @@ -18,10 +18,10 @@ #include #include +#include #include #include #include -#include using namespace Dali; @@ -30,21 +30,46 @@ using namespace Toolkit; namespace { -static bool gPushButtonToggleState = false; -bool PushButtonToggled( Button button, bool toggled ) +static bool gPushButtonSelectedState = false; +bool PushButtonSelected( Button button, bool selected ) { - gPushButtonToggleState = toggled && ( toggled == static_cast( button ).IsToggled() ); + gPushButtonSelectedState = selected && ( selected == static_cast( button ).IsSelected() ); return true; } -const Dali::TouchPoint pointDownInside( 0, TouchPoint::Down, 240, 400 ); -const Dali::TouchPoint pointUpInside( 0, TouchPoint::Up, 240, 400 ); -const Dali::TouchPoint pointLeave( 0, TouchPoint::Leave, 240, 400 ); -const Dali::TouchPoint pointEnter( 0, TouchPoint::Motion, 240, 400 ); -const Dali::TouchPoint pointMotionOut( 0, TouchPoint::Motion, 10, 10 ); -const Dali::TouchPoint pointDownOutside( 0, TouchPoint::Down, 10, 10 ); -const Dali::TouchPoint pointUpOutside( 0, TouchPoint::Up, 10, 10 ); +Dali::Integration::Point GetPointDownInside() +{ + Dali::Integration::Point point; + point.SetState( PointState::DOWN ); + point.SetScreenPosition( Vector2( 240, 400 ) ); + return point; +} + +Dali::Integration::Point GetPointUpInside() +{ + Dali::Integration::Point point; + point.SetState( PointState::UP ); + point.SetScreenPosition( Vector2( 240, 400 ) ); + return point; +} + +Dali::Integration::Point GetPointMotionOut() +{ + Dali::Integration::Point point; + point.SetState( PointState::MOTION ); + point.SetScreenPosition( Vector2( 10, 10 ) ); + return point; +} + +Dali::Integration::Point GetPointUpOutside() +{ + Dali::Integration::Point point; + point.SetState( PointState::UP ); + point.SetScreenPosition( Vector2( 10, 10 ) ); + return point; +} + } // namespace @@ -67,15 +92,15 @@ class TETButton; } /** - * Creates a Button to test if interrupt events are handled correctly. + * Creates a PushButton to test if interrupt events are handled correctly. */ -class TETButton : public Button +class TETButton : public PushButton { public: // PushButton Pressed - typedef SignalV2< bool ( Button ) > PressedSignalV2; + typedef Signal< bool ( PushButton ) > ButtonSignalType; - PressedSignalV2& PressedSignal(); + ButtonSignalType& PressedSignal(); /** * Default constructor. @@ -85,7 +110,7 @@ public: /** * Copy constructor. */ - TETButton( const Button& button ); + TETButton( const PushButton& button ); /** * Assignment operator. @@ -121,7 +146,7 @@ namespace Internal /** * Internal implementation */ -class TETButton : public Button +class TETButton : public PushButton { public: /** @@ -142,7 +167,7 @@ public: /** * @return the pressed signal. */ - Toolkit::TETButton::PressedSignalV2& PressedSignal(); + Toolkit::TETButton::ButtonSignalType& PressedSignal(); /** * Callback called when an interrupt events is received. @@ -154,7 +179,7 @@ public: */ void OnButtonDown(); - Toolkit::TETButton::PressedSignalV2 mPressedSignal; ///< Signal emitted when the button is pressed. + Toolkit::TETButton::ButtonSignalType mPressedSignal; ///< Signal emitted when the button is pressed. }; } // namespace Internal @@ -163,8 +188,8 @@ TETButton::TETButton() { } -TETButton::TETButton( const Button& button ) -: Button( button ) +TETButton::TETButton( const PushButton& button ) +: PushButton( button ) { } @@ -172,7 +197,7 @@ TETButton& TETButton::operator=( const TETButton& button ) { if( &button != this ) { - Button::operator=( button ); + PushButton::operator=( button ); } return *this; } @@ -187,7 +212,7 @@ TETButton TETButton::DownCast( BaseHandle handle ) return Control::DownCast(handle); } -TETButton::PressedSignalV2& TETButton::PressedSignal() +TETButton::ButtonSignalType& TETButton::PressedSignal() { TETButton button( *this ); DALI_ASSERT_ALWAYS( button ); @@ -198,11 +223,11 @@ TETButton::PressedSignalV2& TETButton::PressedSignal() } TETButton::TETButton( Internal::TETButton& implementation ) -: Button( implementation ) +: PushButton( implementation ) {} TETButton::TETButton( Dali::Internal::CustomActor* internal ) -: Button( internal ) +: PushButton( internal ) { VerifyCustomActorPointer(internal); } @@ -211,7 +236,7 @@ namespace Internal { TETButton::TETButton() -: Button(), +: PushButton(), mPressedSignal() { } @@ -235,7 +260,7 @@ Toolkit::TETButton TETButton::New() return tetButton; } -Toolkit::TETButton::PressedSignalV2& TETButton::PressedSignal() +Toolkit::TETButton::ButtonSignalType& TETButton::PressedSignal() { return mPressedSignal; } @@ -277,7 +302,7 @@ public: { } - bool Callback( Button button ) + bool Callback( PushButton button ) { switch( mTest ) { @@ -304,7 +329,7 @@ public: Test mTest; }; -static bool TestCallback(Actor actor, const TouchEvent& event) +static bool TestCallback(Actor actor, const TouchData& event) { return true; } @@ -313,6 +338,22 @@ static bool TestCallback(Actor actor, const TouchEvent& event) ////////////////////////////////////////////////////////// +int UtcDaliPushButtonDownCast(void) +{ + ToolkitTestApplication application; + tet_infoline(" UtcDaliPushButtonDownCast"); + + TETButton tetButton= Toolkit::TETButton::New(); + + BaseHandle object(tetButton); + + TETButton tetButton2 = TETButton::DownCast( object ); + DALI_TEST_CHECK(tetButton2); + + TETButton tetButton3 = DownCast< TETButton >(object); + DALI_TEST_CHECK(tetButton3); + END_TEST; +} int UtcDaliPushButtonInterruptEventWhenInsensitive(void) { @@ -343,7 +384,7 @@ int UtcDaliPushButtonInterruptEventWhenInsensitive(void) // * Actor's touch event is connected to a callback function // and this callback function consumes the event. - actor.TouchedSignal().Connect( &TestCallback ); + actor.TouchSignal().Connect( &TestCallback ); // * Button's pressed signal is connected to a callback function // which also consumes the event. @@ -369,7 +410,7 @@ int UtcDaliPushButtonInterruptEventWhenInsensitive(void) // A down event is sent inside the button's boundary. event = Dali::Integration::TouchEvent(); - event.AddPoint( pointDownInside ); + event.AddPoint( GetPointDownInside() ); // flush the queue and render once application.SendNotification(); @@ -379,7 +420,7 @@ int UtcDaliPushButtonInterruptEventWhenInsensitive(void) // An up event is sent outside the button's boundary but inside the actor's one. event = Dali::Integration::TouchEvent(); - event.AddPoint( pointUpOutside ); + event.AddPoint( GetPointUpOutside() ); // flush the queue and render once application.SendNotification(); @@ -403,7 +444,7 @@ int UtcDaliPushButtonInterruptEventWhenInsensitive(void) // A down event is sent inside the button's boundary. event = Dali::Integration::TouchEvent(); - event.AddPoint( pointDownInside ); + event.AddPoint( GetPointDownInside() ); // flush the queue and render once application.SendNotification(); @@ -413,7 +454,7 @@ int UtcDaliPushButtonInterruptEventWhenInsensitive(void) // A motion event is sent outside the button's boundary but inside the actor's one. event = Dali::Integration::TouchEvent(); - event.AddPoint( pointMotionOut ); + event.AddPoint( GetPointMotionOut() ); // flush the queue and render once application.SendNotification(); @@ -433,7 +474,7 @@ int UtcDaliPushButtonInterruptEventWhenInsensitive(void) // A down event is sent inside the button's boundary. event = Dali::Integration::TouchEvent(); - event.AddPoint( pointDownInside ); + event.AddPoint( GetPointDownInside() ); // flush the queue and render once application.SendNotification(); @@ -444,7 +485,7 @@ int UtcDaliPushButtonInterruptEventWhenInsensitive(void) // An up event is sent inside the button's boundary. event = Dali::Integration::TouchEvent(); - event.AddPoint( pointUpInside ); + event.AddPoint( GetPointUpInside() ); // flush the queue and render once application.SendNotification(); @@ -486,7 +527,7 @@ int UtcDaliPushButtonInterruptEventWhenNonVisible(void) // * Actor's touch event is connected to a callback function // and this callback function consumes the event. - actor.TouchedSignal().Connect( &TestCallback ); + actor.TouchSignal().Connect( &TestCallback ); // * Button's pressed signal is connected to a callback function // which also consumes the event. @@ -512,7 +553,7 @@ int UtcDaliPushButtonInterruptEventWhenNonVisible(void) // A down event is sent inside the button's boundary. event = Dali::Integration::TouchEvent(); - event.AddPoint( pointDownInside ); + event.AddPoint( GetPointDownInside() ); // flush the queue and render once application.SendNotification(); @@ -530,7 +571,7 @@ int UtcDaliPushButtonInterruptEventWhenNonVisible(void) // An up event is sent outside the button's boundary but inside the actor's one. event = Dali::Integration::TouchEvent(); - event.AddPoint( pointUpOutside ); + event.AddPoint( GetPointUpOutside() ); // flush the queue and render once application.SendNotification(); @@ -557,7 +598,7 @@ int UtcDaliPushButtonInterruptEventWhenNonVisible(void) // A down event is sent inside the button's boundary. event = Dali::Integration::TouchEvent(); - event.AddPoint( pointDownInside ); + event.AddPoint( GetPointDownInside() ); // flush the queue and render once application.SendNotification(); @@ -575,7 +616,7 @@ int UtcDaliPushButtonInterruptEventWhenNonVisible(void) // A motion event is sent outside the button's boundary but inside the actor's one. event = Dali::Integration::TouchEvent(); - event.AddPoint( pointMotionOut ); + event.AddPoint( GetPointMotionOut() ); // flush the queue and render once application.SendNotification(); @@ -601,7 +642,7 @@ int UtcDaliPushButtonInterruptEventWhenNonVisible(void) // A down event is sent inside the button's boundary. event = Dali::Integration::TouchEvent(); - event.AddPoint( pointDownInside ); + event.AddPoint( GetPointDownInside() ); // flush the queue and render once application.SendNotification(); @@ -620,7 +661,7 @@ int UtcDaliPushButtonInterruptEventWhenNonVisible(void) // An up event is sent inside the button's boundary. event = Dali::Integration::TouchEvent(); - event.AddPoint( pointUpInside ); + event.AddPoint( GetPointUpInside() ); // flush the queue and render once application.SendNotification(); @@ -638,88 +679,40 @@ int UtcDaliPushButtonProperties(void) PushButton button = PushButton::New(); Stage::GetCurrent().Add( button ); - // PushButton::PROPERTY_AUTO_REPEATING + // Button::PROPERTY_AUTO_REPEATING button.SetAutoRepeating( false ); - DALI_TEST_CHECK( ! button.GetProperty< bool >( PushButton::PROPERTY_AUTO_REPEATING ) ); - button.SetProperty( PushButton::PROPERTY_AUTO_REPEATING, true ); + DALI_TEST_CHECK( ! button.GetProperty< bool >( Button::Property::AUTO_REPEATING ) ); + button.SetProperty( Button::Property::AUTO_REPEATING, true ); DALI_TEST_CHECK( button.IsAutoRepeating() ) ; - DALI_TEST_CHECK( button.GetProperty< bool >( PushButton::PROPERTY_AUTO_REPEATING ) ); + DALI_TEST_CHECK( button.GetProperty< bool >( Button::Property::AUTO_REPEATING ) ); - // PushButton::PROPERTY_INITIAL_AUTO_REPEATING_DELAY + // Button::PROPERTY_INITIAL_AUTO_REPEATING_DELAY button.SetInitialAutoRepeatingDelay( 10.0f ); - DALI_TEST_EQUALS( 10.0f, button.GetProperty< float >( PushButton::PROPERTY_INITIAL_AUTO_REPEATING_DELAY ), TEST_LOCATION ); - button.SetProperty( PushButton::PROPERTY_INITIAL_AUTO_REPEATING_DELAY, 25.0f ); + DALI_TEST_EQUALS( 10.0f, button.GetProperty< float >( Button::Property::INITIAL_AUTO_REPEATING_DELAY ), TEST_LOCATION ); + button.SetProperty( Button::Property::INITIAL_AUTO_REPEATING_DELAY, 25.0f ); DALI_TEST_EQUALS( 25.0f, button.GetInitialAutoRepeatingDelay(), TEST_LOCATION ); - DALI_TEST_EQUALS( 25.0f, button.GetProperty< float >( PushButton::PROPERTY_INITIAL_AUTO_REPEATING_DELAY ), TEST_LOCATION ); + DALI_TEST_EQUALS( 25.0f, button.GetProperty< float >( Button::Property::INITIAL_AUTO_REPEATING_DELAY ), TEST_LOCATION ); - // PushButton::PROPERTY_NEXT_AUTO_REPEATING_DELAY + // Button::PROPERTY_NEXT_AUTO_REPEATING_DELAY button.SetNextAutoRepeatingDelay( 3.0f ); - DALI_TEST_EQUALS( 3.0f, button.GetProperty< float >( PushButton::PROPERTY_NEXT_AUTO_REPEATING_DELAY ), TEST_LOCATION ); - button.SetProperty( PushButton::PROPERTY_NEXT_AUTO_REPEATING_DELAY, 4.0f ); + DALI_TEST_EQUALS( 3.0f, button.GetProperty< float >( Button::Property::NEXT_AUTO_REPEATING_DELAY ), TEST_LOCATION ); + button.SetProperty( Button::Property::NEXT_AUTO_REPEATING_DELAY, 4.0f ); DALI_TEST_EQUALS( 4.0f, button.GetNextAutoRepeatingDelay(), TEST_LOCATION ); - DALI_TEST_EQUALS( 4.0f, button.GetProperty< float >( PushButton::PROPERTY_NEXT_AUTO_REPEATING_DELAY ), TEST_LOCATION ); - - // PushButton::PROPERTY_TOGGLABLE - button.SetToggleButton( false ); - DALI_TEST_CHECK( ! button.GetProperty< bool >( PushButton::PROPERTY_TOGGLABLE ) ); - button.SetProperty( PushButton::PROPERTY_TOGGLABLE, true ); - DALI_TEST_CHECK( button.IsToggleButton() ) ; - DALI_TEST_CHECK( button.GetProperty< bool >( PushButton::PROPERTY_TOGGLABLE ) ); - - // PushButton::PROPERTY_TOGGLE - button.SetToggled( false ); - DALI_TEST_CHECK( ! button.GetProperty< bool >( PushButton::PROPERTY_TOGGLE ) ); - button.SetProperty( PushButton::PROPERTY_TOGGLE, true ); - DALI_TEST_CHECK( button.IsToggled() ) ; - DALI_TEST_CHECK( button.GetProperty< bool >( PushButton::PROPERTY_TOGGLE ) ); - - // PushButton::PROPERTY_NORMAL_STATE_ACTOR - { - button.SetButtonImage( Image::New( "IMAGE_PATH_1") ); - DALI_TEST_EQUALS( "IMAGE_PATH_1", button.GetProperty( PushButton::PROPERTY_NORMAL_STATE_ACTOR ).GetValue( "image" ).GetValue( "filename" ).Get< std::string >(), TEST_LOCATION ); - - Property::Map map; - map[ "type" ] = "ImageActor"; - - button.SetProperty( PushButton::PROPERTY_NORMAL_STATE_ACTOR, map ); - DALI_TEST_EQUALS( "ImageActor", button.GetProperty( PushButton::PROPERTY_NORMAL_STATE_ACTOR ).GetValue( "type" ).Get< std::string >(), TEST_LOCATION ); - } - - // PushButton::PROPERTY_PRESSED_IMAGE - { - button.SetPressedImage( Image::New( "IMAGE_PATH_2") ); - DALI_TEST_EQUALS( "IMAGE_PATH_2", button.GetProperty( PushButton::PROPERTY_PRESSED_STATE_ACTOR ).GetValue( "image" ).GetValue( "filename" ).Get< std::string >(), TEST_LOCATION ); - - Property::Map map; - map[ "type" ] = "Actor"; - - button.SetProperty( PushButton::PROPERTY_PRESSED_STATE_ACTOR, map ); - DALI_TEST_EQUALS( "Actor", button.GetProperty( PushButton::PROPERTY_PRESSED_STATE_ACTOR ).GetValue( "type" ).Get< std::string >(), TEST_LOCATION ); - DALI_TEST_CHECK( "ImageActor" != button.GetProperty( PushButton::PROPERTY_PRESSED_STATE_ACTOR ).GetValue( "type" ).Get< std::string >() ); - } + DALI_TEST_EQUALS( 4.0f, button.GetProperty< float >( Button::Property::NEXT_AUTO_REPEATING_DELAY ), TEST_LOCATION ); + + // Button::PROPERTY_TOGGLABLE + button.SetTogglableButton( false ); + DALI_TEST_CHECK( ! button.GetProperty< bool >( Button::Property::TOGGLABLE ) ); + button.SetProperty( Button::Property::TOGGLABLE, true ); + DALI_TEST_CHECK( button.IsTogglableButton() ) ; + DALI_TEST_CHECK( button.GetProperty< bool >( Button::Property::TOGGLABLE ) ); + + // Button::PROPERTY_SELECTED + button.SetSelected( false ); + DALI_TEST_CHECK( ! button.GetProperty< bool >( Button::Property::SELECTED ) ); + button.SetProperty( Button::Property::SELECTED, true ); + DALI_TEST_CHECK( button.IsSelected() ) ; + DALI_TEST_CHECK( button.GetProperty< bool >( Button::Property::SELECTED ) ); - // PushButton::PROPERTY_DIMMED_STATE_ACTOR - { - button.SetDimmedImage( Image::New( "IMAGE_PATH_3") ); - DALI_TEST_EQUALS( "IMAGE_PATH_3", button.GetProperty( PushButton::PROPERTY_DIMMED_STATE_ACTOR ).GetValue( "image" ).GetValue( "filename" ).Get< std::string >(), TEST_LOCATION ); - - Property::Map map; - map[ "type" ] = "Actor"; - - button.SetProperty( PushButton::PROPERTY_DIMMED_STATE_ACTOR, map ); - DALI_TEST_EQUALS( "Actor", button.GetProperty( PushButton::PROPERTY_DIMMED_STATE_ACTOR ).GetValue( "type" ).Get< std::string >(), TEST_LOCATION ); - } - - // PushButton::PROPERTY_LABEL_ACTOR - { - button.SetLabelText( "LABEL_TEXT_CUSTOM" ); - DALI_TEST_EQUALS( "TextView", button.GetProperty( PushButton::PROPERTY_LABEL_ACTOR ).GetValue( "type" ).Get< std::string >(), TEST_LOCATION ); - - Property::Map map; - map[ "type" ] = "Actor"; - - button.SetProperty( PushButton::PROPERTY_LABEL_ACTOR, map ); - DALI_TEST_EQUALS( "Actor", button.GetProperty( PushButton::PROPERTY_LABEL_ACTOR ).GetValue( "type" ).Get< std::string >(), TEST_LOCATION ); - } END_TEST; }