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=16b38f6d81e9588b15c9de8e81cc8926c82300e7;hp=521d6cab182b57f1f694f3c1e9e8e67a8b39d904;hb=5e351965bad7e1de2e94027548b022bac692603c;hpb=d69d0761421e562cd4780c07499cae61963559bd diff --git a/automated-tests/src/dali-toolkit/utc-Dali-RadioButton.cpp b/automated-tests/src/dali-toolkit/utc-Dali-RadioButton.cpp index 521d6ca..16b38f6 100644 --- a/automated-tests/src/dali-toolkit/utc-Dali-RadioButton.cpp +++ b/automated-tests/src/dali-toolkit/utc-Dali-RadioButton.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2014 Samsung Electronics Co., Ltd. + * Copyright (c) 2017 Samsung Electronics Co., Ltd. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -45,6 +45,23 @@ 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) @@ -136,42 +153,27 @@ int UtcDaliRadioButtonDownCast(void) END_TEST; } -int UtcDaliRadioButtonLabelActor(void) +int UtcDaliRadioButtonLabelProperty(void) { ToolkitTestApplication application; - TextLabel actor1 = TextLabel::New( "test actor 1" ); - - RadioButton radioButton = RadioButton::New( actor1 ); - DALI_TEST_CHECK( actor1 == radioButton.GetLabel() ); - - TextLabel actor2 = TextLabel::New( "test actor 2" ); - radioButton.SetLabel( actor2 ); - DALI_TEST_CHECK( actor2 == radioButton.GetLabel() ); - - END_TEST; -} - -int UtcDaliRadioButtonSelected(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::Visual::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; } @@ -236,8 +238,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 ); @@ -257,8 +263,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 ); @@ -278,8 +288,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 ); @@ -299,8 +313,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 ); @@ -317,3 +335,55 @@ int UtcDaliRadioButtonSelectedProperty(void) 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::Visual::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; +} +