+
+int UtcDaliButtonSetSelectedBackgroundImageP(void)
+{
+ ToolkitTestApplication application;
+
+ PushButton button = PushButton::New();
+ Stage::GetCurrent().Add( button );
+
+ try
+ {
+ button.SetSelectedBackgroundImage( "TestImage.jpg");
+ DALI_TEST_CHECK( true );
+ }
+ catch(...)
+ {
+ DALI_TEST_CHECK( false );
+ }
+
+ END_TEST;
+}
+
+int UtcDaliButtonSetSelectedBackgroundImageN(void)
+{
+ ToolkitTestApplication application;
+
+ PushButton button;
+
+ try
+ {
+ button.SetSelectedBackgroundImage( "TestImage.jpg");
+ DALI_TEST_CHECK( false );
+ }
+ catch(...)
+ {
+ DALI_TEST_CHECK( true );
+ }
+
+ END_TEST;
+}
+
+int UtcDaliButtonSetDisabledImageP(void)
+{
+ ToolkitTestApplication application;
+
+ PushButton button = PushButton::New();
+ Stage::GetCurrent().Add( button );
+
+ try
+ {
+ button.SetDisabledImage( "TestImage.jpg");
+ DALI_TEST_CHECK( true );
+ }
+ catch(...)
+ {
+ DALI_TEST_CHECK( false );
+ }
+
+ END_TEST;
+}
+
+int UtcDaliButtonSetDisabledImageN(void)
+{
+ ToolkitTestApplication application;
+
+ PushButton button;
+
+ try
+ {
+ button.SetDisabledImage( "TestImage.jpg");
+ DALI_TEST_CHECK( false );
+ }
+ catch(...)
+ {
+ DALI_TEST_CHECK( true );
+ }
+
+ END_TEST;
+}
+
+int UtcDaliButtonSetDisabledSelectedImageP(void)
+{
+ ToolkitTestApplication application;
+
+ PushButton button = PushButton::New();
+ Stage::GetCurrent().Add( button );
+
+ try
+ {
+ button.SetDisabledSelectedImage( "TestImage.jpg");
+ DALI_TEST_CHECK( true );
+ }
+ catch(...)
+ {
+ DALI_TEST_CHECK( false );
+ }
+
+ END_TEST;
+}
+
+int UtcDaliButtonSetDisabledSelectedImageN(void)
+{
+ ToolkitTestApplication application;
+
+ PushButton button;
+
+ try
+ {
+ button.SetDisabledSelectedImage( "TestImage.jpg");
+ DALI_TEST_CHECK( false );
+ }
+ catch(...)
+ {
+ DALI_TEST_CHECK( true );
+ }
+
+ END_TEST;
+}
+
+int UtcDaliButtonSetLabeActorlP(void)
+{
+ ToolkitTestApplication application;
+
+ PushButton button = PushButton::New();
+ Stage::GetCurrent().Add( button );
+
+ try
+ {
+ button.SetLabel( TextLabel::New("Hello") );
+ DALI_TEST_CHECK( true );
+ }
+ catch(...)
+ {
+ DALI_TEST_CHECK( false );
+ }
+
+ END_TEST;
+}
+
+int UtcDaliButtonSetLabelN(void)
+{
+ ToolkitTestApplication application;
+
+ PushButton button;
+
+ try
+ {
+ button.SetLabel( TextLabel::New("Hello") );
+ DALI_TEST_CHECK( false );
+ }
+ catch(...)
+ {
+ DALI_TEST_CHECK( true );
+ }
+
+ END_TEST;
+}
+
+int UtcDaliButtonSetButtonImageP(void)
+{
+ ToolkitTestApplication application;
+
+ PushButton button = PushButton::New();
+ Stage::GetCurrent().Add( button );
+
+ try
+ {
+ ResourceImage image1 = ResourceImage::New( TEST_IMAGE_ONE );
+ button.SetButtonImage( image1 );
+
+ Property::Value value = button.GetProperty(Button::Property::UNSELECTED_STATE_IMAGE );
+ DALI_TEST_CHECK( value.Get<std::string>() == TEST_IMAGE_ONE );
+ }
+ catch(...)
+ {
+ DALI_TEST_CHECK( false );
+ }
+
+ std::string imageUrl;
+
+ Dali::Actor actor = button.GetButtonImage();
+
+ Toolkit::ImageView imageView = Toolkit::ImageView ::DownCast( actor );
+
+ tet_infoline(" UtcDaliButtonSetButtonImageP Ensure an ImageView is returned\n");
+ DALI_TEST_CHECK ( imageView )
+
+ END_TEST;
+}
+
+int UtcDaliButtonSetButtonImageN(void)
+{
+ ToolkitTestApplication application;
+
+ PushButton button;
+
+ try
+ {
+ ResourceImage image1 = ResourceImage::New( TEST_IMAGE_ONE );
+ button.SetButtonImage( image1 );
+
+ DALI_TEST_CHECK( false );
+ }
+ catch(...)
+ {
+ DALI_TEST_CHECK( true );
+ }
+
+ END_TEST;
+}
+
+int UtcDaliButtonSetSelectedImageWithImageP(void)
+{
+ ToolkitTestApplication application;
+
+ PushButton button = PushButton::New();
+ Stage::GetCurrent().Add( button );
+ ResourceImage image1 = ResourceImage::New( TEST_IMAGE_ONE );
+
+ try
+ {
+ button.SetSelectedImage( image1 );
+ Property::Value value = button.GetProperty( Button::Property::SELECTED_STATE_IMAGE );
+ DALI_TEST_CHECK( value.Get<std::string>() == TEST_IMAGE_ONE );
+ }
+ catch(...)
+ {
+ DALI_TEST_CHECK( false );
+ }
+
+ std::string imageUrl;
+
+ Dali::Actor actor = button.GetSelectedImage();
+
+ Toolkit::ImageView imageView = Toolkit::ImageView::DownCast( actor );
+
+ tet_infoline(" UtcDaliButtonSetSelectedImageWithImageP Ensure an ImageView is returned\n");
+
+ END_TEST;
+}
+
+int UtcDaliButtonSetSelectedImageWithImageN(void)
+{
+ ToolkitTestApplication application;
+
+ PushButton button;
+
+ try
+ {
+ button.SetSelectedImage( CreateBufferImage( 10, 10, Color::WHITE ) );
+ DALI_TEST_CHECK( false );
+ }
+ catch(...)
+ {
+ DALI_TEST_CHECK( true );
+ }
+
+ END_TEST;
+}
+
+int UtcDaliButtonSetSelectedColorP(void)
+{
+ ToolkitTestApplication application;
+ tet_infoline(" UtcDaliButtonSetSelectedColorP");
+
+ PushButton pushButton = PushButton::New();
+ Stage::GetCurrent().Add( pushButton );
+
+ application.SendNotification();
+ application.Render();
+
+ const Vector4 SET_COLOR = Color::BLUE;
+
+ pushButton.SetSize( Vector2( 20.0f, 20.0f ) );
+ pushButton.SetProperty( Button::Property::SELECTED_COLOR, SET_COLOR );
+
+ application.SendNotification();
+ application.Render();
+
+ Vector4 color = pushButton.GetProperty<Vector4>( Button::Property::SELECTED_COLOR );
+
+ DALI_TEST_EQUALS( color, SET_COLOR, TEST_LOCATION );
+
+ END_TEST;
+}
+
+int UtcDaliButtonSetUnSelectedColorP(void)
+{
+ ToolkitTestApplication application;
+ tet_infoline(" UtcDaliButtonSetUnSelectedColorP");
+
+ PushButton pushButton = PushButton::New();
+ Stage::GetCurrent().Add( pushButton );
+
+ application.SendNotification();
+ application.Render();
+
+ const Vector4 SET_COLOR = Color::BLUE;
+
+ pushButton.SetSize( Vector2( 20.0f, 20.0f ) );
+ pushButton.SetProperty( Button::Property::UNSELECTED_COLOR, SET_COLOR );
+
+ application.SendNotification();
+ application.Render();
+
+ Vector4 color = pushButton.GetProperty<Vector4>( Button::Property::UNSELECTED_COLOR );
+
+ DALI_TEST_EQUALS( color, SET_COLOR, TEST_LOCATION );
+
+ END_TEST;
+}
+
+int UtcDaliButtonResetSelectedColorP(void)
+{
+ ToolkitTestApplication application;
+ tet_infoline(" UtcDaliButtonSetSelectedColorP");
+
+ PushButton pushButton = PushButton::New();
+ Stage::GetCurrent().Add( pushButton );
+
+ application.SendNotification();
+ application.Render();
+
+ const Vector4 FIRST_COLOR = Color::BLUE;
+ const Vector4 SECOND_COLOR = Color::BLUE;
+
+ pushButton.SetSize( Vector2( 20.0f, 20.0f ) );
+ pushButton.SetProperty( Button::Property::SELECTED_COLOR, FIRST_COLOR );
+
+ application.SendNotification();
+ application.Render();
+
+ Vector4 color = pushButton.GetProperty<Vector4>( Button::Property::SELECTED_COLOR );
+
+ DALI_TEST_EQUALS( color, FIRST_COLOR, TEST_LOCATION );
+
+ pushButton.SetProperty( Button::Property::SELECTED_COLOR, SECOND_COLOR );
+
+ application.SendNotification();
+ application.Render();
+
+ color = pushButton.GetProperty<Vector4>( Button::Property::SELECTED_COLOR );
+
+ DALI_TEST_EQUALS( color, SECOND_COLOR, TEST_LOCATION );
+
+ END_TEST;
+}
+
+int UtcDaliButtonSetImagesWithDeprecatedProperties(void)
+{
+ ToolkitTestApplication application;
+ tet_infoline(" UtcDaliButtonSetImagesWithDeprecatedProperties");
+
+ PushButton pushButton = PushButton::New();
+
+ Stage::GetCurrent().Add( pushButton );
+
+ Property::Map propertyMap;
+ propertyMap.Insert(Visual::Property::TYPE, Visual::COLOR);
+ propertyMap.Insert(ColorVisual::Property::MIX_COLOR, Color::BLUE);
+
+ DALI_TEST_EQUALS( pushButton.GetRendererCount(), 0, TEST_LOCATION );
+
+ pushButton.SetProperty( Toolkit::Button::Property::UNSELECTED_STATE_IMAGE, propertyMap );
+ application.SendNotification();
+ application.Render();
+ DALI_TEST_EQUALS( pushButton.GetRendererCount(), 1, TEST_LOCATION );
+
+ tet_infoline(" Set state to selected and provide SELECTED visual");
+ pushButton.SetProperty( Toolkit::Button::Property::SELECTED_STATE_IMAGE, propertyMap );
+ pushButton.SetProperty( Toolkit::Button::Property::SELECTED, true );
+ application.SendNotification();
+ application.Render();
+ DALI_TEST_EQUALS( pushButton.GetRendererCount(), 1, TEST_LOCATION );
+
+ tet_infoline(" Set state to selected, disabled and provide DISABLED_STATE_IMAGE visual");
+ pushButton.SetProperty( Toolkit::Button::Property::SELECTED, false );
+ pushButton.SetProperty( Toolkit::Button::Property::DISABLED, true );
+ pushButton.SetProperty( Toolkit::Button::Property::DISABLED_STATE_IMAGE, propertyMap );
+ application.SendNotification();
+ application.Render();
+ DALI_TEST_EQUALS( pushButton.GetRendererCount(), 1, TEST_LOCATION );
+
+END_TEST;
+}
+
+int UtcDaliButtonSetGetDepreciatedPropertiesWithURL(void)
+{
+ ToolkitTestApplication application;
+ tet_infoline(" UtcDaliButtonSetGetDepreciatedPropertiesWithURL");
+
+ PushButton button = PushButton::New();
+ Stage::GetCurrent().Add( button );
+
+ tet_infoline(" Set state to selected, disabled and provide DISABLED_STATE_IMAGE visual");
+ button.SetProperty( Toolkit::Button::Property::DISABLED, true );
+ button.SetProperty( Toolkit::Button::Property::DISABLED_STATE_IMAGE, TEST_IMAGE_ONE );
+
+ Property::Value value = button.GetProperty(Button::Property::DISABLED_STATE_IMAGE );
+ DALI_TEST_EQUALS( value.Get<std::string>(), TEST_IMAGE_ONE, TEST_LOCATION );
+
+END_TEST;
+}
+
+int UtcDaliButtonSetLabelTextDeprecatedPropertyP(void)
+{
+ ToolkitTestApplication application;
+ tet_infoline(" UtcDaliButtonSetLabelTextDeprecatedPropertyP");
+
+ const std::string TEST_LABEL1 = "test label one";
+ const std::string TEST_LABEL2 = "test label two";
+
+ Button button = PushButton::New();
+
+ button.SetProperty( Toolkit::Button::Property::LABEL,
+ Property::Map().Add( Toolkit::Visual::Property::TYPE, Toolkit::DevelVisual::TEXT )
+ .Add( Toolkit::TextVisual::Property::POINT_SIZE, 15.0f )
+ );
+
+ button.SetProperty( Button::Property::LABEL_TEXT, TEST_LABEL1 );
+
+ std::string labelText = button.GetProperty<std::string>( Button::Property::LABEL_TEXT );
+
+ DALI_TEST_EQUALS( labelText, TEST_LABEL1, TEST_LOCATION );
+
+ Property::Map propertyMap;
+ propertyMap.Insert( Toolkit::Visual::Property::TYPE, Toolkit::DevelVisual::TEXT );
+ propertyMap.Insert( Toolkit::TextVisual::Property::TEXT, TEST_LABEL2 );
+ propertyMap.Insert( Toolkit::TextVisual::Property::TEXT_COLOR, Color::BLUE );
+ propertyMap.Insert( Toolkit::TextVisual::Property::POINT_SIZE, 15.0f );
+ button.SetProperty( Button::Property::LABEL, propertyMap );
+
+ labelText = button.GetProperty<std::string>( Button::Property::LABEL_TEXT );
+
+ DALI_TEST_EQUALS( labelText, TEST_LABEL2, TEST_LOCATION );
+
+ END_TEST;
+}