#include <iostream>
#include <stdlib.h>
+#include <dali-toolkit/internal/controls/buttons/push-button-impl.h>
#include <dali-toolkit-test-suite-utils.h>
#include <dali-toolkit/dali-toolkit.h>
#include <dali/integration-api/events/touch-event-integ.h>
-#include <dali-toolkit/internal/controls/buttons/button-impl.h>
using namespace Dali;
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<PushButton&>( button ).IsToggled() );
+ gPushButtonSelectedState = selected && ( selected == static_cast<PushButton&>( 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
}
/**
- * 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.
/**
* Copy constructor.
*/
- TETButton( const Button& button );
+ TETButton( const PushButton& button );
/**
* Assignment operator.
/**
* Internal implementation
*/
-class TETButton : public Button
+class TETButton : public PushButton
{
public:
/**
/**
* @return the pressed signal.
*/
- Toolkit::TETButton::PressedSignalV2& PressedSignal();
+ Toolkit::TETButton::ButtonSignalType& PressedSignal();
/**
* Callback called when an interrupt events is received.
*/
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
{
}
-TETButton::TETButton( const Button& button )
-: Button( button )
+TETButton::TETButton( const PushButton& button )
+: PushButton( button )
{
}
{
if( &button != this )
{
- Button::operator=( button );
+ PushButton::operator=( button );
}
return *this;
}
return Control::DownCast<TETButton, Internal::TETButton>(handle);
}
-TETButton::PressedSignalV2& TETButton::PressedSignal()
+TETButton::ButtonSignalType& TETButton::PressedSignal()
{
TETButton button( *this );
DALI_ASSERT_ALWAYS( button );
}
TETButton::TETButton( Internal::TETButton& implementation )
-: Button( implementation )
+: PushButton( implementation )
{}
TETButton::TETButton( Dali::Internal::CustomActor* internal )
-: Button( internal )
+: PushButton( internal )
{
VerifyCustomActorPointer<Internal::TETButton>(internal);
}
{
TETButton::TETButton()
-: Button(),
+: PushButton(),
mPressedSignal()
{
}
return tetButton;
}
-Toolkit::TETButton::PressedSignalV2& TETButton::PressedSignal()
+Toolkit::TETButton::ButtonSignalType& TETButton::PressedSignal()
{
return mPressedSignal;
}
{
}
- bool Callback( Button button )
+ bool Callback( PushButton button )
{
switch( mTest )
{
Test mTest;
};
-static bool TestCallback(Actor actor, const TouchEvent& event)
+static bool TestCallback(Actor actor, const TouchData& event)
{
return true;
}
//////////////////////////////////////////////////////////
+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)
{
// * 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.
// 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();
// 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();
// 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();
// 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();
// 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();
// 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();
// * 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.
// 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();
// 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();
// 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();
// 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();
// 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();
// 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();
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.push_back( Property::StringValuePair( "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.push_back( Property::StringValuePair( "type", "TextActor" ) );
-
- button.SetProperty( PushButton::PROPERTY_PRESSED_STATE_ACTOR, map );
- DALI_TEST_EQUALS( "TextActor", button.GetProperty( PushButton::PROPERTY_PRESSED_STATE_ACTOR ).GetValue( "type" ).Get< std::string >(), TEST_LOCATION );
- }
+ 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.push_back( Property::StringValuePair( "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.push_back( Property::StringValuePair( "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;
}