X-Git-Url: http://review.tizen.org/git/?p=platform%2Fcore%2Fuifw%2Fdali-toolkit.git;a=blobdiff_plain;f=automated-tests%2Fsrc%2Fdali-toolkit%2Futc-Dali-RadioButton.cpp;h=85cced6a9dc0a45dd79a77190a7e807f10b80d6e;hp=ca1ac84bf758acef9ef451ab52b48d0e833fc4bb;hb=1a1dc01690d6b218743ce6a3e1acc63699bc171a;hpb=928136dbb9e23970f3894eabc7c8b224003b77be diff --git a/automated-tests/src/dali-toolkit/utc-Dali-RadioButton.cpp b/automated-tests/src/dali-toolkit/utc-Dali-RadioButton.cpp index ca1ac84..85cced6 100644 --- a/automated-tests/src/dali-toolkit/utc-Dali-RadioButton.cpp +++ b/automated-tests/src/dali-toolkit/utc-Dali-RadioButton.cpp @@ -21,6 +21,8 @@ #include #include +#include +#include using namespace Dali; using namespace Dali::Toolkit; @@ -45,12 +47,64 @@ static void TestCallback(BaseHandle handle) gObjectCreatedCallBackCalled = true; } +static std::string GetButtonText( Button button ) +{ + Property::Value value = button.GetProperty( Toolkit::Button::Property::LABEL ); + + Property::Map *labelProperty = value.GetMap(); + + std::string textLabel; + + if ( labelProperty ) + { + Property::Value* value = labelProperty->Find( Toolkit::TextVisual::Property::TEXT ); + value->Get( textLabel ); + } + + return textLabel; +} + +} + +int UtcDaliRadioButtonConstructorP(void) +{ + TestApplication application; + + RadioButton button; + + DALI_TEST_CHECK( !button ); + END_TEST; +} + +int UtcDaliRadioButtonCopyConstructorP(void) +{ + TestApplication application; + + // Initialize an object, ref count == 1 + RadioButton button = RadioButton::New(); + + RadioButton copy( button ); + DALI_TEST_CHECK( copy ); + END_TEST; +} + +int UtcDaliRadioButtonAssignmentOperatorP(void) +{ + TestApplication application; + + RadioButton button = RadioButton::New(); + + RadioButton copy( button ); + DALI_TEST_CHECK( copy ); + + DALI_TEST_CHECK( button == copy ); + END_TEST; } -int UtcDaliRadioButtonNew(void) +int UtcDaliRadioButtonNewP(void) { ToolkitTestApplication application; - tet_infoline(" UtcDaliRadioButtonNew"); + tet_infoline(" UtcDaliRadioButtonNewP"); // Create the Slider actor RadioButton radioButton; @@ -78,7 +132,7 @@ int UtcDaliRadioButtonNew(void) END_TEST; } -int UtcDaliRadioButtonDestructor(void) +int UtcDaliRadioButtonDestructorP(void) { ToolkitTestApplication application; @@ -101,32 +155,27 @@ int UtcDaliRadioButtonDownCast(void) END_TEST; } -int UtcDaliRadioButtonLabelActor(void) -{ - // TODO - END_TEST; -} - -int UtcDaliRadioButtonSelected(void) +int UtcDaliRadioButtonLabelProperty(void) { ToolkitTestApplication application; + const std::string labelText = "test actor 1"; + RadioButton radioButton = RadioButton::New(); - // Default selected - DALI_TEST_CHECK( radioButton.IsSelected() == false ); + radioButton.SetProperty( Toolkit::Button::Property::LABEL, + Property::Map().Add( Toolkit::Visual::Property::TYPE, Toolkit::DevelVisual::TEXT ) + .Add( Toolkit::TextVisual::Property::POINT_SIZE, 15.0f ) + ); - // False - radioButton.SetSelected( false ); - DALI_TEST_CHECK( radioButton.IsSelected() == false ); + radioButton.SetProperty( Toolkit::Button::Property::LABEL, labelText ); + DALI_TEST_EQUALS( GetButtonText( radioButton ), labelText, TEST_LOCATION ); - // True - radioButton.SetSelected( true ); - DALI_TEST_CHECK( radioButton.IsSelected() == true ); - // False - radioButton.SetSelected( false ); - DALI_TEST_CHECK( radioButton.IsSelected() == false ); + std::string labelText2 = "test actor 2"; + radioButton.SetProperty( Toolkit::Button::Property::LABEL, labelText2 ); + + DALI_TEST_EQUALS( GetButtonText( radioButton ), labelText2, TEST_LOCATION ); END_TEST; } @@ -144,19 +193,19 @@ int UtcDaliRadioButtonSelectedProperty(void) radioButton.SetPosition( 0.0f, 0.0f ); // Default selected - DALI_TEST_CHECK( radioButton.GetProperty( Button::PROPERTY_SELECTED ) == false ); + DALI_TEST_CHECK( radioButton.GetProperty( Button::Property::SELECTED ) == false ); // Setting false selected - radioButton.SetProperty( Button::PROPERTY_SELECTED, false ); - DALI_TEST_CHECK( radioButton.GetProperty( Button::PROPERTY_SELECTED ) == false ); + radioButton.SetProperty( Button::Property::SELECTED, false ); + DALI_TEST_CHECK( radioButton.GetProperty( Button::Property::SELECTED ) == false ); // Setting true selected - radioButton.SetProperty( Button::PROPERTY_SELECTED, true ); - DALI_TEST_CHECK( radioButton.GetProperty( Button::PROPERTY_SELECTED ) == true ); + radioButton.SetProperty( Button::Property::SELECTED, true ); + DALI_TEST_CHECK( radioButton.GetProperty( Button::Property::SELECTED ) == true ); // Setting false again - radioButton.SetProperty( Button::PROPERTY_SELECTED, false ); - DALI_TEST_CHECK( radioButton.GetProperty( Button::PROPERTY_SELECTED ) == false ); + radioButton.SetProperty( Button::Property::SELECTED, false ); + DALI_TEST_CHECK( radioButton.GetProperty( Button::Property::SELECTED ) == false ); // Test selecting radio buttons RadioButton radioButton2 = RadioButton::New( "label" ); @@ -183,16 +232,20 @@ int UtcDaliRadioButtonSelectedProperty(void) application.Render(); // Simulate touch events - DALI_TEST_CHECK( radioButton2.GetProperty( Button::PROPERTY_SELECTED ) == false ); - DALI_TEST_CHECK( radioButton3.GetProperty( Button::PROPERTY_SELECTED ) == false ); + DALI_TEST_CHECK( radioButton2.GetProperty( Button::Property::SELECTED ) == false ); + DALI_TEST_CHECK( radioButton3.GetProperty( Button::Property::SELECTED ) == false ); // Select first radio { Dali::Integration::TouchEvent event1 = Dali::Integration::TouchEvent(); Dali::Integration::TouchEvent event2 = Dali::Integration::TouchEvent(); - const Dali::TouchPoint pointDown( 0, TouchPoint::Down, 10.0f, 10.0f ); - const Dali::TouchPoint pointUp( 0, TouchPoint::Up, 10.0f, 10.0f ); + Dali::Integration::Point pointDown; + pointDown.SetState( PointState::DOWN ); + pointDown.SetScreenPosition( Vector2( 1.0f, 1.0f ) ); + + Dali::Integration::Point pointUp( pointDown ); + pointUp.SetState( PointState::UP ); event1.AddPoint( pointDown ); application.ProcessEvent( event1 ); @@ -203,8 +256,8 @@ int UtcDaliRadioButtonSelectedProperty(void) application.SendNotification(); application.Render(); - DALI_TEST_CHECK( radioButton2.GetProperty( Button::PROPERTY_SELECTED ) == true ); - DALI_TEST_CHECK( radioButton3.GetProperty( Button::PROPERTY_SELECTED ) == false ); + DALI_TEST_CHECK( radioButton2.GetProperty( Button::Property::SELECTED ) == true ); + DALI_TEST_CHECK( radioButton3.GetProperty( Button::Property::SELECTED ) == false ); } // Select an already selected radio @@ -212,8 +265,12 @@ int UtcDaliRadioButtonSelectedProperty(void) Dali::Integration::TouchEvent event1 = Dali::Integration::TouchEvent(); Dali::Integration::TouchEvent event2 = Dali::Integration::TouchEvent(); - const Dali::TouchPoint pointDown( 0, TouchPoint::Down, 10.0f, 10.0f ); - const Dali::TouchPoint pointUp( 0, TouchPoint::Up, 10.0f, 10.0f ); + Dali::Integration::Point pointDown; + pointDown.SetState( PointState::DOWN ); + pointDown.SetScreenPosition( Vector2( 1.0f, 1.0f ) ); + + Dali::Integration::Point pointUp( pointDown ); + pointUp.SetState( PointState::UP ); event1.AddPoint( pointDown ); application.ProcessEvent( event1 ); @@ -224,8 +281,8 @@ int UtcDaliRadioButtonSelectedProperty(void) application.SendNotification(); application.Render(); - DALI_TEST_CHECK( radioButton2.GetProperty( Button::PROPERTY_SELECTED ) == true ); - DALI_TEST_CHECK( radioButton3.GetProperty( Button::PROPERTY_SELECTED ) == false ); + DALI_TEST_CHECK( radioButton2.GetProperty( Button::Property::SELECTED ) == true ); + DALI_TEST_CHECK( radioButton3.GetProperty( Button::Property::SELECTED ) == false ); } // Select second radio @@ -233,8 +290,12 @@ int UtcDaliRadioButtonSelectedProperty(void) Dali::Integration::TouchEvent event1 = Dali::Integration::TouchEvent(); Dali::Integration::TouchEvent event2 = Dali::Integration::TouchEvent(); - const Dali::TouchPoint pointDown( 0, TouchPoint::Down, 10.0f, 50.0f ); - const Dali::TouchPoint pointUp( 0, TouchPoint::Up, 10.0f, 50.0f ); + Dali::Integration::Point pointDown; + pointDown.SetState( PointState::DOWN ); + pointDown.SetScreenPosition( Vector2( 1.0f, 41.0f ) ); + + Dali::Integration::Point pointUp( pointDown ); + pointUp.SetState( PointState::UP ); event1.AddPoint( pointDown ); application.ProcessEvent( event1 ); @@ -245,8 +306,8 @@ int UtcDaliRadioButtonSelectedProperty(void) application.SendNotification(); application.Render(); - DALI_TEST_CHECK( radioButton2.GetProperty( Button::PROPERTY_SELECTED ) == false ); - DALI_TEST_CHECK( radioButton3.GetProperty( Button::PROPERTY_SELECTED ) == true ); + DALI_TEST_CHECK( radioButton2.GetProperty( Button::Property::SELECTED ) == false ); + DALI_TEST_CHECK( radioButton3.GetProperty( Button::Property::SELECTED ) == true ); } // Select outside radio group @@ -254,8 +315,12 @@ int UtcDaliRadioButtonSelectedProperty(void) Dali::Integration::TouchEvent event1 = Dali::Integration::TouchEvent(); Dali::Integration::TouchEvent event2 = Dali::Integration::TouchEvent(); - const Dali::TouchPoint pointDown( 0, TouchPoint::Down, 10.0f, 500.0f ); - const Dali::TouchPoint pointUp( 0, TouchPoint::Up, 10.0f, 500.0f ); + Dali::Integration::Point pointDown; + pointDown.SetState( PointState::DOWN ); + pointDown.SetScreenPosition( Vector2( 1.0f, 500.0f ) ); + + Dali::Integration::Point pointUp( pointDown ); + pointUp.SetState( PointState::UP ); event1.AddPoint( pointDown ); application.ProcessEvent( event1 ); @@ -266,9 +331,61 @@ int UtcDaliRadioButtonSelectedProperty(void) application.SendNotification(); application.Render(); - DALI_TEST_CHECK( radioButton2.GetProperty( Button::PROPERTY_SELECTED ) == false ); - DALI_TEST_CHECK( radioButton3.GetProperty( Button::PROPERTY_SELECTED ) == true ); + DALI_TEST_CHECK( radioButton2.GetProperty( Button::Property::SELECTED ) == false ); + DALI_TEST_CHECK( radioButton3.GetProperty( Button::Property::SELECTED ) == true ); } END_TEST; } + + +// Deprecated API Tests + +int UtcDaliRadioButtonLabelActor(void) +{ + ToolkitTestApplication application; + + std::string labelText = "test actor 1"; + + RadioButton radioButton = RadioButton::New(); + + radioButton.SetProperty( Toolkit::Button::Property::LABEL, + Property::Map().Add( Toolkit::Visual::Property::TYPE, Toolkit::DevelVisual::TEXT ) + .Add( Toolkit::TextVisual::Property::POINT_SIZE, 15.0f ) + ); + + radioButton.SetLabelText( labelText ); + + DALI_TEST_EQUALS( radioButton.GetLabelText(), labelText, TEST_LOCATION ); + + std::string labelText2 = "test actor 2"; + radioButton.SetLabelText( labelText2 ); + DALI_TEST_EQUALS( radioButton.GetLabelText(), labelText2, TEST_LOCATION ); + + END_TEST; +} + +int UtcDaliRadioButtonSelected(void) +{ + ToolkitTestApplication application; + + RadioButton radioButton = RadioButton::New(); + + // Default selected + DALI_TEST_CHECK( radioButton.IsSelected() == false ); + + // False + radioButton.SetSelected( false ); + DALI_TEST_CHECK( radioButton.IsSelected() == false ); + + // True + radioButton.SetSelected( true ); + DALI_TEST_CHECK( radioButton.IsSelected() == true ); + + // False + radioButton.SetSelected( false ); + DALI_TEST_CHECK( radioButton.IsSelected() == false ); + + END_TEST; +} +