#include <dali-toolkit/dali-toolkit.h>
#include <dali/integration-api/events/touch-event-integ.h>
+#include <dali-toolkit/devel-api/controls/buttons/button-devel.h>
+#include <dali-toolkit/devel-api/visuals/visual-properties-devel.h>
+#include <dali-toolkit/devel-api/visuals/text-visual-properties.h>
+
using namespace Dali;
using namespace Toolkit;
return false;
}
+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;
+}
+
struct CallbackFunctor
{
CallbackFunctor(bool* callbackFlag)
tet_infoline(" UtcDaliPushButtonPropertyGetLabelAlignment\n");
Button button = PushButton::New();
- button.SetProperty( Toolkit::Button::Property::LABEL_RELATIVE_ALIGNMENT, "END" );
- DALI_TEST_EQUALS( button.GetProperty<std::string>( Toolkit::Button::Property::LABEL_RELATIVE_ALIGNMENT ), "END", TEST_LOCATION );
+ button.SetProperty( Toolkit::DevelButton::Property::LABEL_RELATIVE_ALIGNMENT, "END" );
+ DALI_TEST_EQUALS( button.GetProperty<std::string>( Toolkit::DevelButton::Property::LABEL_RELATIVE_ALIGNMENT ), "END", TEST_LOCATION );
END_TEST;
}
END_TEST;
}
-int UtcDaliButtonSetLabelStringP(void)
+int UtcDaliButtonSetLabelStringWithPropertyMapP(void)
+{
+ ToolkitTestApplication application;
+
+ 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 )
+ .Add( Toolkit::TextVisual::Property::TEXT, "Button Label")
+ );
+
+ DALI_TEST_EQUALS( GetButtonText( button ), "Button Label", TEST_LOCATION );
+ END_TEST;
+}
+
+int UtcDaliButtonSetLabelStringWithPropertyMapStringsP(void)
+{
+ ToolkitTestApplication application;
+
+ Button button = PushButton::New();
+
+ tet_infoline(" UtcDaliButtonSetLabelStringWithPropertyMapStringsP Setting Button text using String then replacing with Enum then string");
+
+ Property::Map textVisualMapInitial;
+ textVisualMapInitial["visualType"] = "TEXT";
+ textVisualMapInitial["pointSize"] = 15.0f;
+ textVisualMapInitial["text"] = "button label initial";
+
+ button.SetProperty( Button::Property::LABEL, textVisualMapInitial );
+
+ DALI_TEST_EQUALS( GetButtonText( button ), "button label initial", TEST_LOCATION );
+
+ tet_infoline(" UtcDaliButtonSetLabelStringWithPropertyMapStringsP Intermediate part of test");
+
+ Property::Map propertyMap;
+ propertyMap.Insert( Toolkit::Visual::Property::TYPE, Toolkit::DevelVisual::TEXT );
+ propertyMap.Insert( Toolkit::TextVisual::Property::TEXT, "error if this is the final text" );
+ propertyMap.Insert( Toolkit::TextVisual::Property::POINT_SIZE, 15.0f );
+
+ button.SetProperty( Button::Property::LABEL, propertyMap );
+
+ DALI_TEST_EQUALS( GetButtonText( button ), "error if this is the final text", TEST_LOCATION );
+
+ tet_infoline(" UtcDaliButtonSetLabelStringWithPropertyMapStringsP Final part of test");
+
+ Property::Map textVisualMap;
+ textVisualMap["visualType"] = "TEXT";
+ textVisualMap["pointSize"] = 15.0f;
+ textVisualMap["text"] = "Button Label";
+
+ button.SetProperty( Toolkit::Button::Property::LABEL, textVisualMap );
+
+ DALI_TEST_EQUALS( GetButtonText( button ), "Button Label", TEST_LOCATION );
+ END_TEST;
+}
+
+int UtcDaliButtonSetLabelWithStringP(void)
{
ToolkitTestApplication application;
Button button = PushButton::New();
- button.SetLabelText( "Button Label" );
+ // Set default point size for text visual as style sheet not available.
+ 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( Toolkit::Button::Property::LABEL, "Button Label" );
- DALI_TEST_EQUALS( button.GetLabelText(), "Button Label", TEST_LOCATION );
+ DALI_TEST_EQUALS( GetButtonText( button ), "Button Label", TEST_LOCATION );
END_TEST;
}
{
ToolkitTestApplication application;
+ tet_infoline(" UtcDaliButtonSetLabelPropertyP Set text label and then set again with new text");
+
+
const std::string TEST_LABEL1 = "test label one";
const std::string TEST_LABEL2 = "test label two";
Button button = PushButton::New();
- button.SetProperty( Button::Property::LABEL_TEXT, TEST_LABEL1 );
-
- std::string labelText = button.GetProperty<std::string>( Button::Property::LABEL_TEXT );
+ button.SetProperty( Toolkit::Button::Property::LABEL,
+ Property::Map().Add( Toolkit::Visual::Property::TYPE, Toolkit::DevelVisual::TEXT )
+ .Add( Toolkit::TextVisual::Property::POINT_SIZE, 15.0f )
+ .Add( Toolkit::TextVisual::Property::TEXT, TEST_LABEL1 )
+ );
- DALI_TEST_EQUALS( labelText, TEST_LABEL1, TEST_LOCATION );
+ DALI_TEST_EQUALS( GetButtonText( button ), TEST_LABEL1, TEST_LOCATION );
Property::Map propertyMap;
- propertyMap.Insert( Toolkit::TextLabel::Property::TEXT, TEST_LABEL2 );
- propertyMap.Insert( Toolkit::TextLabel::Property::TEXT_COLOR, Color::BLUE);
+ 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 );
+ DALI_TEST_EQUALS( GetButtonText( button ), TEST_LABEL2, TEST_LOCATION );
END_TEST;
}
try
{
- ResourceImage image1 = ResourceImage::New( "TestImage.jpg");
+ 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>() == "TestImage.jpg" );
+ 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;
}
try
{
- ResourceImage image1 = ResourceImage::New( "TestImage.jpg");
+ ResourceImage image1 = ResourceImage::New( TEST_IMAGE_ONE );
button.SetButtonImage( image1 );
DALI_TEST_CHECK( false );
try
{
button.SetSelectedImage( image1 );
- Property::Value value = button.GetProperty(Button::Property::SELECTED_STATE_IMAGE );
+ 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;
}
tet_infoline(" UtcDaliButtonSetImagesWithDeprecatedProperties");
PushButton pushButton = PushButton::New();
+
Stage::GetCurrent().Add( pushButton );
Property::Map propertyMap;
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;
+}