/*
- * Copyright (c) 2014 Samsung Electronics Co., Ltd.
+ * Copyright (c) 2020 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.
// Need to override adaptor classes for toolkit test harness, so include
// test harness headers before dali headers.
#include <dali-toolkit-test-suite-utils.h>
+#include "dali-toolkit-test-utils/toolkit-timer.h"
#include <dali.h>
#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>
+
using namespace Dali;
using namespace Toolkit;
namespace
{
static bool gIsCalledButtonCallback = false;
+static bool gIsCalledChildButtonCallback = false;
static bool ButtonCallback( Button button )
{
return false;
}
+static bool ChildButtonCallback( Button button )
+{
+ gIsCalledChildButtonCallback = true;
+ 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)
bool* mCallbackFlag;
};
-
-Image CreateSolidColorImage( const Vector4& color, unsigned int width, unsigned int height )
-{
- BufferImage imageData = BufferImage::New( width, height, Pixel::RGBA8888 );
-
- // Create the image
- PixelBuffer* pixbuf = imageData.GetBuffer();
- unsigned int size = width * height;
-
- for( size_t i = 0; i < size; i++ )
- {
- pixbuf[i*4+0] = 0xFF * color.r;
- pixbuf[i*4+1] = 0xFF * color.g;
- pixbuf[i*4+2] = 0xFF * color.b;
- pixbuf[i*4+3] = 0xFF * color.a;
- }
-
- imageData.Update();
-
- return imageData;
-}
-
Dali::Integration::Point GetPointDownInside()
{
Dali::Integration::Point point;
return point;
}
-
-static float ANIMATION_TIME( 0.5f );
} // namespace
int UtcDaliButtonConstructorP(void)
END_TEST;
}
-int UtcDaliButtonSetDisabledP(void)
+int UtcDaliButtonDisabledPropertyP(void)
{
ToolkitTestApplication application;
Button button = PushButton::New();
- button.SetDisabled( true );
- DALI_TEST_CHECK( button.IsDisabled() );
+ button.SetProperty( button.GetPropertyIndex("disabled"), true );
+
+ DALI_TEST_EQUALS( button.GetProperty<bool>( button.GetPropertyIndex("disabled")), true, TEST_LOCATION );
- button.SetDisabled( false );
+ button.SetProperty( button.GetPropertyIndex("disabled"), false );
- DALI_TEST_CHECK( !button.IsDisabled() );
+ DALI_TEST_EQUALS( button.GetProperty<bool>( button.GetPropertyIndex("disabled")), false, TEST_LOCATION );
- button.SetDisabled( true );
+ button.SetProperty( button.GetPropertyIndex("disabled"), true );
- DALI_TEST_CHECK( button.IsDisabled() );
+ DALI_TEST_EQUALS( button.GetProperty<bool>( button.GetPropertyIndex("disabled")), true, TEST_LOCATION );
- button.SetDisabled( false );
+ button.SetProperty( button.GetPropertyIndex("disabled"), false );
+
+ DALI_TEST_EQUALS( button.GetProperty<bool>( button.GetPropertyIndex("disabled")), false, TEST_LOCATION );
- DALI_TEST_CHECK( !button.IsDisabled() );
END_TEST;
}
-int UtcDaliButtonIsDisabledP(void)
+int UtcDaliButtonSetDisabledWithDifferentStates01P(void)
{
ToolkitTestApplication application;
+ tet_infoline("UtcDaliButtonSetDisabledWithDifferentStates01P\n");
+
Button button = PushButton::New();
- button.SetDisabled( true );
+ bool SELECTED = true;
+
+ button.SetProperty( Button::Property::TOGGLABLE, true);
+ button.SetProperty( Button::Property::SELECTED, SELECTED );
+
+ button.SetProperty( Button::Property::DISABLED, true);
+
+ tet_infoline("Set button to SELECTED = false whilst disabled, should not change to false\n");
+ button.SetProperty( Button::Property::SELECTED, !SELECTED );
- DALI_TEST_CHECK( button.IsDisabled() );
+ bool isSelected = button.GetProperty<bool>( Button::Property::SELECTED ) ;
- button.SetDisabled( false );
+ DALI_TEST_EQUALS( isSelected, SELECTED , TEST_LOCATION );
- DALI_TEST_CHECK( !button.IsDisabled() );
END_TEST;
}
-int UtcDaliButtonSetAutoRepeatingP(void)
+int UtcDaliButtonSetDisabledWithDifferentStates02P(void)
{
ToolkitTestApplication application;
+ tet_infoline("UtcDaliButtonSetDisabledWithDifferentStates02\n");
+
Button button = PushButton::New();
- button.SetAutoRepeating( true );
+ bool SELECTED = true;
+
+ button.SetProperty( Button::Property::TOGGLABLE, true );
+ button.SetProperty( Button::Property::SELECTED, SELECTED );
+ button.SetProperty( Button::Property::DISABLED, true );
- DALI_TEST_CHECK( button.IsAutoRepeating() );
+ bool isSelected = button.GetProperty<bool>( Button::Property::SELECTED );
+ DALI_TEST_EQUALS( isSelected, SELECTED , TEST_LOCATION );
+ tet_infoline("Set button to DISABLED = false whilst disabled and then set to unselected\n");
- button.SetAutoRepeating( false );
+ button.SetProperty( Button::Property::DISABLED, false);
+ button.SetProperty( Button::Property::SELECTED, !SELECTED );
- DALI_TEST_CHECK( !button.IsAutoRepeating() );
+ isSelected = button.GetProperty<bool>( Button::Property::SELECTED );
+ DALI_TEST_EQUALS( isSelected, !SELECTED , TEST_LOCATION );
- button.SetAutoRepeating( true );
+ END_TEST;
+}
- DALI_TEST_CHECK( button.IsAutoRepeating() );
+int UtcDaliButtonPropertyGetLabelAlignment(void)
+{
+ ToolkitTestApplication application;
+ tet_infoline(" UtcDaliPushButtonPropertyGetLabelAlignment\n");
- button.SetAutoRepeating( false );
+ Button button = PushButton::New();
+ 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 );
- DALI_TEST_CHECK( !button.IsAutoRepeating() );
END_TEST;
}
-int UtcDaliButtonIsAutoRepeatingP(void)
+int UtcDaliButtonIsDisabledP(void)
{
ToolkitTestApplication application;
Button button = PushButton::New();
- button.SetAutoRepeating( true );
+ button.SetProperty( Button::Property::DISABLED, true);
- DALI_TEST_CHECK( button.IsAutoRepeating() );
+ DALI_TEST_EQUALS( button.GetProperty<bool>( Button::Property::DISABLED ), true, TEST_LOCATION );
- button.SetAutoRepeating( false );
+ button.SetProperty( Button::Property::DISABLED, false);
- DALI_TEST_CHECK( !button.IsAutoRepeating() );
+ DALI_TEST_EQUALS( button.GetProperty<bool>( Button::Property::DISABLED ), false, TEST_LOCATION );
END_TEST;
}
-int UtcDaliButtonSetInitialAutoRepeatingDelayP(void)
+int UtcDaliButtonAutoRepeatingPropertyP(void)
{
ToolkitTestApplication application;
Button button = PushButton::New();
- button.SetInitialAutoRepeatingDelay( 0.5f );
+ button.SetProperty( button.GetPropertyIndex("autoRepeating"), true );
- DALI_TEST_EQUALS( button.GetInitialAutoRepeatingDelay(), 0.5f, TEST_LOCATION );
+ DALI_TEST_EQUALS( button.GetProperty<bool>( button.GetPropertyIndex("autoRepeating")), true, TEST_LOCATION );
- button.SetInitialAutoRepeatingDelay( 0.2f );
+ button.SetProperty( button.GetPropertyIndex("autoRepeating"), false );
+
+ DALI_TEST_EQUALS( button.GetProperty<bool>( button.GetPropertyIndex("autoRepeating")), false, TEST_LOCATION );
+
+ button.SetProperty( button.GetPropertyIndex("autoRepeating"), true );
+
+ DALI_TEST_EQUALS( button.GetProperty<bool>( button.GetPropertyIndex("autoRepeating")), true, TEST_LOCATION );
- DALI_TEST_EQUALS( button.GetInitialAutoRepeatingDelay(), 0.2f, TEST_LOCATION );
END_TEST;
}
-int UtcDaliButtonSetNextAutoRepeatingDelayP(void)
+int UtcDaliButtonIsAutoRepeatingP(void)
{
ToolkitTestApplication application;
Button button = PushButton::New();
- button.SetNextAutoRepeatingDelay( 0.5f );
+ button.SetProperty( Button::Property::AUTO_REPEATING, true);
- DALI_TEST_EQUALS( button.GetNextAutoRepeatingDelay(), 0.5f, TEST_LOCATION );
+ DALI_TEST_EQUALS( button.GetProperty<bool>( Button::Property::AUTO_REPEATING ), true, TEST_LOCATION );
- button.SetNextAutoRepeatingDelay( 0.2f );
+ button.SetProperty( Button::Property::AUTO_REPEATING, false);
+
+ DALI_TEST_EQUALS( button.GetProperty<bool>( Button::Property::AUTO_REPEATING ), false, TEST_LOCATION );
- DALI_TEST_EQUALS( button.GetNextAutoRepeatingDelay(), 0.2f, TEST_LOCATION );
END_TEST;
}
-int UtcDaliButtonSetTogglableButtonP(void)
+int UtcDaliButtonAutoRepeatingP(void)
{
ToolkitTestApplication application;
+ tet_infoline(" UtcDaliButtonPressedSignalP Setup Autorepeating and check multiple clicked signals received\n");
+
+ const float AUTO_REPEATING_DELAY = 0.15f;
Button button = PushButton::New();
+ button.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT );
+ button.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT );
+ button.SetProperty( Actor::Property::POSITION, Vector2( 240, 400 ));
+ button.SetProperty( Actor::Property::SIZE, Vector2( 100, 100 ) );
+ application.GetScene().Add( button );
+
+ application.SendNotification();
+ application.Render();
+
+ button.SetProperty( Toolkit::Button::Property::AUTO_REPEATING, true );
+ button.SetProperty( Toolkit::Button::Property::INITIAL_AUTO_REPEATING_DELAY, AUTO_REPEATING_DELAY );
+ // connect to its touch signal
+ ConnectionTracker* testTracker = new ConnectionTracker();
+ button.PressedSignal().Connect( &ButtonCallback );
+ button.ClickedSignal().Connect( &ButtonCallback );
+ bool clickedSignal = false;
+ bool pressedSignal = false;
+ button.ConnectSignal( testTracker, "pressed", CallbackFunctor(&pressedSignal) );
+ button.ConnectSignal( testTracker, "clicked", CallbackFunctor(&clickedSignal) );
- button.SetTogglableButton( true );
+ Dali::Integration::TouchEvent event;
- DALI_TEST_CHECK( button.IsTogglableButton() );
+ // Touch point down and up inside the button.
+
+ gIsCalledButtonCallback = false;
+ event = Dali::Integration::TouchEvent();
+ event.AddPoint( GetPointDownInside() );
+ application.ProcessEvent( event );
+
+ DALI_TEST_EQUALS( gIsCalledButtonCallback, true, TEST_LOCATION );
+ DALI_TEST_EQUALS( pressedSignal, true, TEST_LOCATION );
+ tet_infoline("Consume first clicked signal then wait\n");
+
+ gIsCalledButtonCallback = false;
+ Dali::Timer timer = Timer::New( AUTO_REPEATING_DELAY );
+ timer.MockEmitSignal();
+ application.Wait( AUTO_REPEATING_DELAY*2 );
+ DALI_TEST_EQUALS( clickedSignal, true, TEST_LOCATION );
+ tet_infoline("Check gIsCalledButtonCallback was called again after last consumption of it.\n");
+
+ DALI_TEST_EQUALS( gIsCalledButtonCallback, true, TEST_LOCATION );
+
+ gIsCalledButtonCallback = false;
+ event = Dali::Integration::TouchEvent();
+ event.AddPoint( GetPointUpInside() );
+ application.ProcessEvent( event );
- button.SetTogglableButton( false );
+ DALI_TEST_EQUALS( gIsCalledButtonCallback, true, TEST_LOCATION );
- DALI_TEST_CHECK( !button.IsTogglableButton() );
END_TEST;
}
-int UtcDaliButtonSetSelectedP(void)
+int UtcDaliButtonInitialAutoRepeatingDelayPropertyP(void)
{
ToolkitTestApplication application;
Button button = PushButton::New();
- button.SetTogglableButton( true );
- button.SetSelected( true );
+ button.SetProperty( button.GetPropertyIndex("initialAutoRepeatingDelay"), 0.5f );
+
+ DALI_TEST_EQUALS( button.GetProperty<float>( button.GetPropertyIndex("initialAutoRepeatingDelay")), 0.5f, TEST_LOCATION );
- DALI_TEST_CHECK( button.IsSelected() );
+ button.SetProperty( button.GetPropertyIndex("initialAutoRepeatingDelay"), 0.2f );
- button.SetSelected( false );
+ DALI_TEST_EQUALS( button.GetProperty<float>( button.GetPropertyIndex("initialAutoRepeatingDelay")), 0.2f, TEST_LOCATION );
- DALI_TEST_CHECK( !button.IsSelected() );
END_TEST;
}
-int UtcDaliButtonSetAnimationTimeP(void)
+int UtcDaliButtonNextAutoRepeatingDelayPropertyP(void)
{
ToolkitTestApplication application;
- tet_infoline(" UtcDaliButtonSetAnimationTimeP");
Button button = PushButton::New();
- button.SetAnimationTime( ANIMATION_TIME );
+ button.SetProperty( button.GetPropertyIndex("nextAutoRepeatingDelay"), 0.5f );
+
+ DALI_TEST_EQUALS( button.GetProperty<float>( button.GetPropertyIndex("nextAutoRepeatingDelay")), 0.5f, TEST_LOCATION );
+
+ button.SetProperty( button.GetPropertyIndex("nextAutoRepeatingDelay"), 0.2f );
- DALI_TEST_EQUALS( button.GetAnimationTime(), ANIMATION_TIME, TEST_LOCATION );
+ DALI_TEST_EQUALS( button.GetProperty<float>( button.GetPropertyIndex("nextAutoRepeatingDelay")), 0.2f, TEST_LOCATION );
END_TEST;
}
-int UtcDaliButtonSetLabelStringP(void)
+int UtcDaliButtonTogglableButtonPropertyP(void)
{
ToolkitTestApplication application;
Button button = PushButton::New();
- button.SetLabelText( "Button Label" );
+ button.SetProperty( button.GetPropertyIndex("togglable"), true );
- DALI_TEST_EQUALS( button.GetLabelText(), "Button Label", TEST_LOCATION );
+ DALI_TEST_EQUALS( button.GetProperty<bool>( button.GetPropertyIndex("togglable")), true, TEST_LOCATION );
+
+ button.SetProperty( button.GetPropertyIndex("togglable"), false );
+
+ DALI_TEST_EQUALS( button.GetProperty<bool>( button.GetPropertyIndex("togglable")), false, TEST_LOCATION );
END_TEST;
}
-int UtcDaliButtonSetLabelActorP(void)
+int UtcDaliButtonSelectedPropertyP(void)
{
ToolkitTestApplication application;
Button button = PushButton::New();
+ button.SetProperty( button.GetPropertyIndex("togglable"), true );
+
+ button.SetProperty( button.GetPropertyIndex("selected"), true );
+
+ DALI_TEST_EQUALS( button.GetProperty<bool>( button.GetPropertyIndex("selected")), true, TEST_LOCATION );
- button.SetLabelText( "Button Label" );
+ button.SetProperty( button.GetPropertyIndex("selected"), false );
- DALI_TEST_EQUALS( button.GetLabelText(), "Button Label", TEST_LOCATION );
+ DALI_TEST_EQUALS( button.GetProperty<bool>( button.GetPropertyIndex("selected")), false, TEST_LOCATION );
END_TEST;
}
-int UtcDaliButtonSetUnselectedImageP(void)
+int UtcDaliButtonSetLabelStringWithPropertyMapP(void)
{
ToolkitTestApplication application;
- tet_infoline(" UtcDaliButtonSetUnselectedImageP");
- PushButton pushButton = PushButton::New();
- Stage::GetCurrent().Add( pushButton );
+ Button button = PushButton::New();
+ button.SetProperty( Toolkit::Button::Property::LABEL,
+ Property::Map().Add( Toolkit::Visual::Property::TYPE, Toolkit::Visual::TEXT )
+ .Add( Toolkit::TextVisual::Property::POINT_SIZE, 15.0f )
+ .Add( Toolkit::TextVisual::Property::TEXT, "Button Label")
+ );
- application.SendNotification();
- application.Render();
+ DALI_TEST_EQUALS( GetButtonText( button ), "Button Label", TEST_LOCATION );
+ END_TEST;
+}
+
+int UtcDaliButtonSetLabelStringWithPropertyMapStringsP(void)
+{
+ ToolkitTestApplication application;
- pushButton.SetSize( Vector2( 20.0f, 20.0f ) );
- pushButton.SetUnselectedImage( "Image.jpg" );
+ Button button = PushButton::New();
- application.SendNotification();
- application.Render();
+ 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::Visual::TEXT );
+ propertyMap.Insert( Toolkit::TextVisual::Property::TEXT, "error if this is the final text" );
+ propertyMap.Insert( Toolkit::TextVisual::Property::POINT_SIZE, 15.0f );
- Vector3 size = pushButton.GetCurrentSize();
+ button.SetProperty( Button::Property::LABEL, propertyMap );
- DALI_TEST_EQUALS( size.width, 20.f, TEST_LOCATION );
- DALI_TEST_EQUALS( size.height, 20.f, TEST_LOCATION );
+ 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 UtcDaliButtonSetSelectedImageP(void)
+int UtcDaliButtonSetLabelWithStringP(void)
{
ToolkitTestApplication application;
- tet_infoline(" UtcDaliButtonSetButtonImage");
- PushButton pushButton = PushButton::New();
- Stage::GetCurrent().Add( pushButton );
+ Button button = PushButton::New();
- application.SendNotification();
- application.Render();
+ // 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::Visual::TEXT )
+ .Add( Toolkit::TextVisual::Property::POINT_SIZE, 15.0f )
+ );
- pushButton.SetSize( Vector2( 20.0f, 20.0f ) );
- pushButton.SetSelectedImage( "Image.jpg" );
+ button.SetProperty( Toolkit::Button::Property::LABEL, "Button Label" );
- application.SendNotification();
- application.Render();
+ DALI_TEST_EQUALS( GetButtonText( button ), "Button Label", TEST_LOCATION );
+ END_TEST;
+}
- Vector3 size = pushButton.GetCurrentSize();
+int UtcDaliButtonSetLabelPropertyP(void)
+{
+ ToolkitTestApplication application;
- DALI_TEST_EQUALS( size.width, 20.f, TEST_LOCATION );
- DALI_TEST_EQUALS( size.height, 20.f, TEST_LOCATION );
+ 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( Toolkit::Button::Property::LABEL,
+ Property::Map().Add( Toolkit::Visual::Property::TYPE, Toolkit::Visual::TEXT )
+ .Add( Toolkit::TextVisual::Property::POINT_SIZE, 15.0f )
+ .Add( Toolkit::TextVisual::Property::TEXT, TEST_LABEL1 )
+ );
+
+ DALI_TEST_EQUALS( GetButtonText( button ), TEST_LABEL1, TEST_LOCATION );
+
+ Property::Map propertyMap;
+ propertyMap.Insert( Toolkit::Visual::Property::TYPE, Toolkit::Visual::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 );
+
+ DALI_TEST_EQUALS( GetButtonText( button ), TEST_LABEL2, TEST_LOCATION );
END_TEST;
}
tet_infoline(" UtcDaliButtonPressedSignalP");
Button button = PushButton::New();
- button.SetAnchorPoint( AnchorPoint::TOP_LEFT );
- button.SetParentOrigin( ParentOrigin::TOP_LEFT );
- button.SetPosition( 240, 400 );
- button.SetSize( 100, 100 );
+ button.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT );
+ button.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT );
+ button.SetProperty( Actor::Property::POSITION, Vector2( 240, 400 ));
+ button.SetProperty( Actor::Property::SIZE, Vector2( 100, 100 ) );
- Stage::GetCurrent().Add( button );
+ application.GetScene().Add( button );
application.SendNotification();
application.Render();
tet_infoline(" UtcDaliButtonClickedSignalP");
Button button = PushButton::New();
- button.SetAnchorPoint( AnchorPoint::TOP_LEFT );
- button.SetParentOrigin( ParentOrigin::TOP_LEFT );
- button.SetPosition( 240, 400 );
- button.SetSize( 100, 100 );
+ button.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT );
+ button.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT );
+ button.SetProperty( Actor::Property::POSITION, Vector2( 240, 400 ));
+ button.SetProperty( Actor::Property::SIZE, Vector2( 100, 100 ) );
- Stage::GetCurrent().Add( button );
+ application.GetScene().Add( button );
application.SendNotification();
application.Render();
tet_infoline(" UtcDaliButtonStateChangedSignalP");
Button button = PushButton::New();
- button.SetTogglableButton( true );
- Stage::GetCurrent().Add( button );
+ button.SetProperty( Button::Property::TOGGLABLE, true);
+
+ application.GetScene().Add( button );
application.SendNotification();
application.Render();
button.ConnectSignal( testTracker, "stateChanged", CallbackFunctor(&stateChangedSignal) );
gIsCalledButtonCallback = false;
- button.SetSelected( true );
+ button.SetProperty( Button::Property::SELECTED, true);
DALI_TEST_CHECK( gIsCalledButtonCallback );
DALI_TEST_CHECK( stateChangedSignal );
gIsCalledButtonCallback = false;
stateChangedSignal = false;
- button.SetSelected( false );
-
+ button.SetProperty( Button::Property::SELECTED, false);
DALI_TEST_CHECK( gIsCalledButtonCallback );
DALI_TEST_CHECK( stateChangedSignal );
END_TEST;
PushButton pushButton = PushButton::New();
pushButton.SetProperty(pushButton.GetPropertyIndex("disabled"), false);
- DALI_TEST_CHECK( false == pushButton.IsDisabled() );
+
+ DALI_TEST_EQUALS( pushButton.GetProperty<bool>( pushButton.GetPropertyIndex("disabled")), false, TEST_LOCATION );
pushButton.SetProperty(pushButton.GetPropertyIndex("disabled"), true);
- DALI_TEST_CHECK( true == pushButton.IsDisabled() );
+ DALI_TEST_EQUALS( pushButton.GetProperty<bool>( pushButton.GetPropertyIndex("disabled")), true, TEST_LOCATION );
END_TEST;
}
-int UtcDaliButtonSize(void)
+int UtcDaliButtonEventConsumption(void)
{
- ToolkitTestApplication application;
- tet_infoline(" UtcDaliButtonSize");
+ /**
+ * [ Parent ]
+ * [ Child ]
+ *
+ * Child parented and positioned under parent.
+ * Touch up and down performed on child.
+ * Should only trigger signal on child.
+ */
- // First an image is set, then SetSize is called.
- PushButton pushButton = PushButton::New();
- Stage::GetCurrent().Add( pushButton );
-
- pushButton.SetBackgroundImage( "Image.jpg" );
- pushButton.SetSize( 10.f, 10.f );
-
- application.SendNotification();
- application.Render();
-
- Vector3 size = pushButton.GetCurrentSize();
-
- DALI_TEST_EQUALS( size.width, 10.f, TEST_LOCATION );
- DALI_TEST_EQUALS( size.height, 10.f, TEST_LOCATION );
- END_TEST;
-}
-
-int UtcDaliButtonSetSelectedBackgroundImageP(void)
-{
ToolkitTestApplication application;
- PushButton button = PushButton::New();
- Stage::GetCurrent().Add( button );
+ Button parentButton = PushButton::New();
+ parentButton.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT );
+ parentButton.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT );
+ parentButton.SetProperty( Actor::Property::SIZE, Vector2( 20, 20 ) );
+ application.GetScene().Add( parentButton );
- try
- {
- button.SetSelectedBackgroundImage( "TestImage.jpg");
- DALI_TEST_CHECK( true );
- }
- catch(...)
- {
- DALI_TEST_CHECK( false );
- }
+ Button childButton = PushButton::New();
+ childButton.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT );
+ childButton.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::BOTTOM_LEFT );
+ childButton.SetProperty( Actor::Property::SIZE, Vector2( 20, 20 ) );
+ parentButton.Add( childButton );
- 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 );
- }
+ // Reset signal flags
+ gIsCalledChildButtonCallback = false;
+ gIsCalledButtonCallback = false;
- END_TEST;
-}
+ parentButton.ClickedSignal().Connect( &ButtonCallback );
+ childButton.ClickedSignal().Connect( &ChildButtonCallback );
-int UtcDaliButtonSetDisabledImageN(void)
-{
- ToolkitTestApplication application;
+ // Peform a button click at coordinates (10,30) which is the child.
+ Dali::Integration::TouchEvent event;
+ event = Dali::Integration::TouchEvent();
+ Dali::Integration::Point point;
+ point.SetState( PointState::DOWN );
+ point.SetScreenPosition( Vector2( 10, 30 ) );
+ event.AddPoint( point );
+ // flush the queue and render once
+ application.SendNotification();
+ application.Render();
+ application.ProcessEvent( event );
- PushButton button;
+ event = Dali::Integration::TouchEvent();
+ point.SetState( PointState::UP );
+ point.SetScreenPosition( Vector2( 10, 30 ) );
+ event.AddPoint( point );
+ // flush the queue and render once
+ application.SendNotification();
+ application.Render();
+ application.ProcessEvent( event );
- try
- {
- button.SetDisabledImage( "TestImage.jpg");
- DALI_TEST_CHECK( false );
- }
- catch(...)
- {
- DALI_TEST_CHECK( true );
- }
+ DALI_TEST_EQUALS( gIsCalledChildButtonCallback, true, TEST_LOCATION );
+ DALI_TEST_EQUALS( ! gIsCalledButtonCallback, true, TEST_LOCATION );
END_TEST;
}
-int UtcDaliButtonSetDisabledSelectedImageP(void)
+int UtcDaliButtonRelease(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;
-}
+ /**
+ * Down event followed by interrupted event should signal Release.
+ */
-int UtcDaliButtonSetDisabledSelectedImageN(void)
-{
ToolkitTestApplication application;
- PushButton button;
+ Button parentButton = PushButton::New();
+ parentButton.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT );
+ parentButton.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT );
+ parentButton.SetProperty( Actor::Property::SIZE, Vector2( 20, 20 ) );
+ application.GetScene().Add( parentButton );
+ parentButton.ReleasedSignal().Connect( &ButtonCallback );
- try
- {
- button.SetDisabledSelectedImage( "TestImage.jpg");
- DALI_TEST_CHECK( false );
- }
- catch(...)
- {
- DALI_TEST_CHECK( true );
- }
-
- END_TEST;
-}
+ // Reset signal flags
+ gIsCalledButtonCallback = false;
-int UtcDaliButtonSetLabelP(void)
-{
- ToolkitTestApplication application;
+ // Peform a button down and then button interrupted at coordinates (10,10).
+ Dali::Integration::TouchEvent event;
+ event = Dali::Integration::TouchEvent();
+ Dali::Integration::Point point;
+ point.SetState( PointState::DOWN );
+ point.SetScreenPosition( Vector2( 10, 10 ) );
+ event.AddPoint( point );
+ // flush the queue and render once
+ application.SendNotification();
+ application.Render();
+ application.ProcessEvent( event );
- PushButton button = PushButton::New();
- Stage::GetCurrent().Add( button );
+ event = Dali::Integration::TouchEvent();
+ point.SetState( PointState::INTERRUPTED );
+ event.AddPoint( point );
+ // flush the queue and render once
+ application.SendNotification();
+ application.Render();
+ application.ProcessEvent( event );
- try
- {
- button.SetLabel( TextLabel::New("Hello") );
- DALI_TEST_CHECK( true );
- }
- catch(...)
- {
- DALI_TEST_CHECK( false );
- }
+ DALI_TEST_EQUALS( gIsCalledButtonCallback, true, TEST_LOCATION );
END_TEST;
}
-int UtcDaliButtonSetLabelN(void)
+int UtcDaliButtonMultiTouch(void)
{
- ToolkitTestApplication application;
-
- PushButton button;
-
- try
- {
- button.SetLabel( TextLabel::New("Hello") );
- DALI_TEST_CHECK( false );
- }
- catch(...)
- {
- DALI_TEST_CHECK( true );
- }
+ /**
+ * Down event followed by a multi touch point event should signal Release.
+ */
- END_TEST;
-}
-
-int UtcDaliButtonSetButtonImageP(void)
-{
ToolkitTestApplication application;
- PushButton button = PushButton::New();
- Stage::GetCurrent().Add( button );
-
- try
- {
- button.SetButtonImage( CreateBufferImage( 10, 10, Color::WHITE ) );
- DALI_TEST_CHECK( ImageView::DownCast( button.GetButtonImage() ) );
- }
- catch(...)
- {
- DALI_TEST_CHECK( false );
- }
-
- END_TEST;
-}
+ Button button = PushButton::New();
+ button.SetProperty( Button::Property::TOGGLABLE, true);
-int UtcDaliButtonSetButtonImageN(void)
-{
- ToolkitTestApplication application;
+ button.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT );
+ button.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT );
+ button.SetProperty( Actor::Property::SIZE, Vector2( 20, 20 ) );
+ application.GetScene().Add( button );
+ button.ReleasedSignal().Connect( &ButtonCallback );
- PushButton button;
+ // Reset signal flags
+ gIsCalledButtonCallback = false;
- try
- {
- button.SetButtonImage( CreateBufferImage( 10, 10, Color::WHITE ) );
- DALI_TEST_CHECK( false );
- }
- catch(...)
- {
- DALI_TEST_CHECK( true );
- }
+ // Peform a button down and then button interrupted at coordinates (10,10).
+ Dali::Integration::TouchEvent downEvent;
+ downEvent = Dali::Integration::TouchEvent();
+ Dali::Integration::Point point;
- END_TEST;
-}
+ // Add Press button
+ point.SetState( PointState::DOWN );
+ point.SetScreenPosition( Vector2( 15, 15 ) );
+ downEvent.AddPoint( point );
+ // flush the queue and render once
+ application.SendNotification();
+ application.Render();
+ application.ProcessEvent( downEvent );
-int UtcDaliButtonSetSelectedImageWithImageP(void)
-{
- ToolkitTestApplication application;
+ // Release button
+ Dali::Integration::TouchEvent upEvent;
+ upEvent = Dali::Integration::TouchEvent();
+ point.SetState( PointState::UP );
+ point.SetScreenPosition( Vector2( 15, 15 ) );
+ upEvent.AddPoint( point );
+ // flush the queue and render once
+ application.SendNotification();
+ application.Render();
+ application.ProcessEvent( upEvent );
- PushButton button = PushButton::New();
- Stage::GetCurrent().Add( button );
+ tet_infoline("Button should now be selected\n");
+ bool isSelected = button.GetProperty<bool>( Button::Property::SELECTED ) ;
+ DALI_TEST_EQUALS( isSelected, true, TEST_LOCATION );
- try
- {
- button.SetSelectedImage( CreateBufferImage( 10, 10, Color::WHITE ) );
- DALI_TEST_CHECK( ImageView::DownCast( button.GetSelectedImage() ) );
- }
- catch(...)
- {
- DALI_TEST_CHECK( false );
- }
+ // Add first point
+ Dali::Integration::TouchEvent multiEvent;
+ multiEvent = Dali::Integration::TouchEvent();
+ point.SetState( PointState::DOWN );
+ point.SetScreenPosition( Vector2( 10, 10 ) );
+ multiEvent.AddPoint( point );
- END_TEST;
-}
+ // Add second point
+ point.SetState( PointState::DOWN );
+ point.SetScreenPosition( Vector2( 15, 15 ) );
+ multiEvent.AddPoint( point );
-int UtcDaliButtonSetSelectedImageWithImageN(void)
-{
- ToolkitTestApplication application;
+ tet_infoline("Before a multi touch event\n");
- PushButton button;
+ // flush the queue and render once
+ application.SendNotification();
+ application.Render();
+ application.ProcessEvent( multiEvent );
- try
- {
- button.SetSelectedImage( CreateBufferImage( 10, 10, Color::WHITE ) );
- DALI_TEST_CHECK( false );
- }
- catch(...)
- {
- DALI_TEST_CHECK( true );
- }
+ DALI_TEST_EQUALS( gIsCalledButtonCallback, true, TEST_LOCATION );
END_TEST;
}