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-Button.cpp;h=83ebfb67868ac91860c8bf27d02beaabcc4b99b2;hp=244f66738c2c30f87500372512b3acf0b3a869c8;hb=8a647e87a01c5c78451653c1264a9eea81ac9b20;hpb=fb0d31619217589b3da2a9bea27a4adad9d7380a diff --git a/automated-tests/src/dali-toolkit/utc-Dali-Button.cpp b/automated-tests/src/dali-toolkit/utc-Dali-Button.cpp index 244f667..83ebfb6 100644 --- a/automated-tests/src/dali-toolkit/utc-Dali-Button.cpp +++ b/automated-tests/src/dali-toolkit/utc-Dali-Button.cpp @@ -1,5 +1,5 @@ /* - * 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. @@ -28,8 +28,6 @@ #include #include -#include -#include using namespace Dali; using namespace Toolkit; @@ -47,11 +45,8 @@ void utc_dali_toolkit_button_cleanup(void) namespace { -static const char* TEST_IMAGE_ONE = TEST_RESOURCE_DIR "/gallery-small-1.jpg"; - static bool gIsCalledButtonCallback = false; - -const int RENDER_FRAME_INTERVAL = 16; +static bool gIsCalledChildButtonCallback = false; static bool ButtonCallback( Button button ) { @@ -59,6 +54,12 @@ 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 ); @@ -138,13 +139,11 @@ Dali::Integration::Point GetPointUpOutside() return point; } -static float ANIMATION_TIME( 0.5f ); - } // namespace int UtcDaliButtonConstructorP(void) { - TestApplication application; + ToolkitTestApplication application; Button button; @@ -154,7 +153,7 @@ int UtcDaliButtonConstructorP(void) int UtcDaliButtonCopyConstructorP(void) { - TestApplication application; + ToolkitTestApplication application; // Initialize an object, ref count == 1 Button button = PushButton::New(); @@ -164,9 +163,28 @@ int UtcDaliButtonCopyConstructorP(void) END_TEST; } +int UtcDaliButtonMoveConstructor(void) +{ + ToolkitTestApplication application; + + Button button = PushButton::New(); + DALI_TEST_EQUALS( 1, button.GetBaseObject().ReferenceCount(), TEST_LOCATION ); + DALI_TEST_EQUALS( button.GetProperty( Button::Property::TOGGLABLE ), false , TEST_LOCATION ); + button.SetProperty( Button::Property::TOGGLABLE, true ); + DALI_TEST_EQUALS( button.GetProperty( Button::Property::TOGGLABLE ), true , TEST_LOCATION ); + + Button moved = std::move( button ); + DALI_TEST_CHECK( moved ); + DALI_TEST_EQUALS( 1, moved.GetBaseObject().ReferenceCount(), TEST_LOCATION ); + DALI_TEST_EQUALS( moved.GetProperty( Button::Property::TOGGLABLE ), true , TEST_LOCATION ); + DALI_TEST_CHECK( !button ); + + END_TEST; +} + int UtcDaliButtonAssignmentOperatorP(void) { - TestApplication application; + ToolkitTestApplication application; Button button = PushButton::New(); @@ -177,9 +195,29 @@ int UtcDaliButtonAssignmentOperatorP(void) END_TEST; } +int UtcDaliButtonMoveAssignment(void) +{ + ToolkitTestApplication application; + + Button button = PushButton::New(); + DALI_TEST_EQUALS( 1, button.GetBaseObject().ReferenceCount(), TEST_LOCATION ); + DALI_TEST_EQUALS( button.GetProperty( Button::Property::TOGGLABLE ), false , TEST_LOCATION ); + button.SetProperty( Button::Property::TOGGLABLE, true ); + DALI_TEST_EQUALS( button.GetProperty( Button::Property::TOGGLABLE ), true , TEST_LOCATION ); + + Button moved; + moved = std::move( button ); + DALI_TEST_CHECK( moved ); + DALI_TEST_EQUALS( 1, moved.GetBaseObject().ReferenceCount(), TEST_LOCATION ); + DALI_TEST_EQUALS( moved.GetProperty( Button::Property::TOGGLABLE ), true , TEST_LOCATION ); + DALI_TEST_CHECK( !button ); + + END_TEST; +} + int UtcDaliButtonDownCastP(void) { - TestApplication application; + ToolkitTestApplication application; Button button = PushButton::New(); @@ -195,7 +233,7 @@ int UtcDaliButtonDownCastP(void) int UtcDaliButtonDownCastN(void) { - TestApplication application; + ToolkitTestApplication application; BaseHandle unInitializedObject; @@ -207,27 +245,29 @@ int UtcDaliButtonDownCastN(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( button.GetPropertyIndex("disabled")), true, TEST_LOCATION ); + + button.SetProperty( button.GetPropertyIndex("disabled"), false ); - button.SetDisabled( false ); + DALI_TEST_EQUALS( button.GetProperty( button.GetPropertyIndex("disabled")), false, TEST_LOCATION ); - DALI_TEST_CHECK( !button.IsDisabled() ); + button.SetProperty( button.GetPropertyIndex("disabled"), true ); - button.SetDisabled( true ); + DALI_TEST_EQUALS( button.GetProperty( button.GetPropertyIndex("disabled")), true, TEST_LOCATION ); - DALI_TEST_CHECK( button.IsDisabled() ); + button.SetProperty( button.GetPropertyIndex("disabled"), false ); - button.SetDisabled( false ); + DALI_TEST_EQUALS( button.GetProperty( button.GetPropertyIndex("disabled")), false, TEST_LOCATION ); - DALI_TEST_CHECK( !button.IsDisabled() ); END_TEST; } @@ -274,7 +314,7 @@ int UtcDaliButtonSetDisabledWithDifferentStates02P(void) DALI_TEST_EQUALS( isSelected, SELECTED , TEST_LOCATION ); tet_infoline("Set button to DISABLED = false whilst disabled and then set to unselected\n"); - button.SetProperty( Button::Property::DISABLED, false ); + button.SetProperty( Button::Property::DISABLED, false); button.SetProperty( Button::Property::SELECTED, !SELECTED ); isSelected = button.GetProperty( Button::Property::SELECTED ); @@ -301,37 +341,34 @@ int UtcDaliButtonIsDisabledP(void) Button button = PushButton::New(); - button.SetDisabled( true ); + button.SetProperty( Button::Property::DISABLED, true); - DALI_TEST_CHECK( button.IsDisabled() ); + DALI_TEST_EQUALS( button.GetProperty( Button::Property::DISABLED ), true, TEST_LOCATION ); - button.SetDisabled( false ); + button.SetProperty( Button::Property::DISABLED, false); - DALI_TEST_CHECK( !button.IsDisabled() ); + DALI_TEST_EQUALS( button.GetProperty( Button::Property::DISABLED ), false, TEST_LOCATION ); END_TEST; } -int UtcDaliButtonSetAutoRepeatingP(void) +int UtcDaliButtonAutoRepeatingPropertyP(void) { ToolkitTestApplication application; Button button = PushButton::New(); - button.SetAutoRepeating( true ); - - DALI_TEST_CHECK( button.IsAutoRepeating() ); + button.SetProperty( button.GetPropertyIndex("autoRepeating"), true ); - button.SetAutoRepeating( false ); + DALI_TEST_EQUALS( button.GetProperty( button.GetPropertyIndex("autoRepeating")), true, TEST_LOCATION ); - DALI_TEST_CHECK( !button.IsAutoRepeating() ); + button.SetProperty( button.GetPropertyIndex("autoRepeating"), false ); - button.SetAutoRepeating( true ); + DALI_TEST_EQUALS( button.GetProperty( button.GetPropertyIndex("autoRepeating")), false, TEST_LOCATION ); - DALI_TEST_CHECK( button.IsAutoRepeating() ); + button.SetProperty( button.GetPropertyIndex("autoRepeating"), true ); - button.SetAutoRepeating( false ); + DALI_TEST_EQUALS( button.GetProperty( button.GetPropertyIndex("autoRepeating")), true, TEST_LOCATION ); - DALI_TEST_CHECK( !button.IsAutoRepeating() ); END_TEST; } @@ -341,13 +378,14 @@ int UtcDaliButtonIsAutoRepeatingP(void) Button button = PushButton::New(); - button.SetAutoRepeating( true ); + button.SetProperty( Button::Property::AUTO_REPEATING, true); - DALI_TEST_CHECK( button.IsAutoRepeating() ); + DALI_TEST_EQUALS( button.GetProperty( Button::Property::AUTO_REPEATING ), true, TEST_LOCATION ); - button.SetAutoRepeating( false ); + button.SetProperty( Button::Property::AUTO_REPEATING, false); + + DALI_TEST_EQUALS( button.GetProperty( Button::Property::AUTO_REPEATING ), false, TEST_LOCATION ); - DALI_TEST_CHECK( !button.IsAutoRepeating() ); END_TEST; } @@ -359,11 +397,11 @@ int UtcDaliButtonAutoRepeatingP(void) const float AUTO_REPEATING_DELAY = 0.15f; Button button = PushButton::New(); - button.SetAnchorPoint( AnchorPoint::TOP_LEFT ); - button.SetParentOrigin( ParentOrigin::TOP_LEFT ); - button.SetPosition( 240, 400 ); - button.SetSize( 100, 100 ); - Stage::GetCurrent().Add( button ); + 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(); @@ -411,81 +449,69 @@ int UtcDaliButtonAutoRepeatingP(void) END_TEST; } -int UtcDaliButtonSetInitialAutoRepeatingDelayP(void) +int UtcDaliButtonInitialAutoRepeatingDelayPropertyP(void) { ToolkitTestApplication application; Button button = PushButton::New(); - button.SetInitialAutoRepeatingDelay( 0.5f ); + button.SetProperty( button.GetPropertyIndex("initialAutoRepeatingDelay"), 0.5f ); + + DALI_TEST_EQUALS( button.GetProperty( button.GetPropertyIndex("initialAutoRepeatingDelay")), 0.5f, TEST_LOCATION ); - DALI_TEST_EQUALS( button.GetInitialAutoRepeatingDelay(), 0.5f, TEST_LOCATION ); + button.SetProperty( button.GetPropertyIndex("initialAutoRepeatingDelay"), 0.2f ); - button.SetInitialAutoRepeatingDelay( 0.2f ); + DALI_TEST_EQUALS( button.GetProperty( button.GetPropertyIndex("initialAutoRepeatingDelay")), 0.2f, TEST_LOCATION ); - DALI_TEST_EQUALS( button.GetInitialAutoRepeatingDelay(), 0.2f, TEST_LOCATION ); END_TEST; } -int UtcDaliButtonSetNextAutoRepeatingDelayP(void) +int UtcDaliButtonNextAutoRepeatingDelayPropertyP(void) { ToolkitTestApplication application; Button button = PushButton::New(); - button.SetNextAutoRepeatingDelay( 0.5f ); + button.SetProperty( button.GetPropertyIndex("nextAutoRepeatingDelay"), 0.5f ); - DALI_TEST_EQUALS( button.GetNextAutoRepeatingDelay(), 0.5f, TEST_LOCATION ); + DALI_TEST_EQUALS( button.GetProperty( button.GetPropertyIndex("nextAutoRepeatingDelay")), 0.5f, TEST_LOCATION ); - button.SetProperty( Button::Property::NEXT_AUTO_REPEATING_DELAY, 0.2f ); + button.SetProperty( button.GetPropertyIndex("nextAutoRepeatingDelay"), 0.2f ); - DALI_TEST_EQUALS( button.GetNextAutoRepeatingDelay(), 0.2f, TEST_LOCATION ); + DALI_TEST_EQUALS( button.GetProperty( button.GetPropertyIndex("nextAutoRepeatingDelay")), 0.2f, TEST_LOCATION ); END_TEST; } -int UtcDaliButtonSetTogglableButtonP(void) +int UtcDaliButtonTogglableButtonPropertyP(void) { ToolkitTestApplication application; Button button = PushButton::New(); - button.SetTogglableButton( true ); + button.SetProperty( button.GetPropertyIndex("togglable"), true ); - DALI_TEST_CHECK( button.IsTogglableButton() ); + DALI_TEST_EQUALS( button.GetProperty( button.GetPropertyIndex("togglable")), true, TEST_LOCATION ); - button.SetTogglableButton( false ); + button.SetProperty( button.GetPropertyIndex("togglable"), false ); - DALI_TEST_CHECK( !button.IsTogglableButton() ); + DALI_TEST_EQUALS( button.GetProperty( button.GetPropertyIndex("togglable")), false, TEST_LOCATION ); END_TEST; } -int UtcDaliButtonSetSelectedP(void) +int UtcDaliButtonSelectedPropertyP(void) { ToolkitTestApplication application; Button button = PushButton::New(); - button.SetTogglableButton( true ); - - button.SetSelected( true ); - - DALI_TEST_CHECK( button.IsSelected() ); - - button.SetSelected( false ); + button.SetProperty( button.GetPropertyIndex("togglable"), true ); - DALI_TEST_CHECK( !button.IsSelected() ); - END_TEST; -} - -int UtcDaliButtonSetAnimationTimeP(void) -{ - ToolkitTestApplication application; - tet_infoline(" UtcDaliButtonSetAnimationTimeP"); + button.SetProperty( button.GetPropertyIndex("selected"), true ); - Button button = PushButton::New(); + DALI_TEST_EQUALS( button.GetProperty( button.GetPropertyIndex("selected")), true, TEST_LOCATION ); - button.SetAnimationTime( ANIMATION_TIME ); + button.SetProperty( button.GetPropertyIndex("selected"), false ); - DALI_TEST_EQUALS( button.GetAnimationTime(), ANIMATION_TIME, TEST_LOCATION ); + DALI_TEST_EQUALS( button.GetProperty( button.GetPropertyIndex("selected")), false, TEST_LOCATION ); END_TEST; } @@ -495,7 +521,7 @@ int UtcDaliButtonSetLabelStringWithPropertyMapP(void) Button button = PushButton::New(); button.SetProperty( Toolkit::Button::Property::LABEL, - Property::Map().Add( Toolkit::Visual::Property::TYPE, Toolkit::DevelVisual::TEXT ) + 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") ); @@ -524,7 +550,7 @@ int UtcDaliButtonSetLabelStringWithPropertyMapStringsP(void) tet_infoline(" UtcDaliButtonSetLabelStringWithPropertyMapStringsP Intermediate part of test"); Property::Map propertyMap; - propertyMap.Insert( Toolkit::Visual::Property::TYPE, Toolkit::DevelVisual::TEXT ); + 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 ); @@ -553,7 +579,7 @@ int UtcDaliButtonSetLabelWithStringP(void) // 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 ) + Property::Map().Add( Toolkit::Visual::Property::TYPE, Toolkit::Visual::TEXT ) .Add( Toolkit::TextVisual::Property::POINT_SIZE, 15.0f ) ); @@ -576,7 +602,7 @@ int UtcDaliButtonSetLabelPropertyP(void) Button button = PushButton::New(); button.SetProperty( Toolkit::Button::Property::LABEL, - Property::Map().Add( Toolkit::Visual::Property::TYPE, Toolkit::DevelVisual::TEXT ) + 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 ) ); @@ -584,7 +610,7 @@ int UtcDaliButtonSetLabelPropertyP(void) DALI_TEST_EQUALS( GetButtonText( button ), TEST_LABEL1, TEST_LOCATION ); Property::Map propertyMap; - propertyMap.Insert( Toolkit::Visual::Property::TYPE, Toolkit::DevelVisual::TEXT ); + 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 ); @@ -595,60 +621,18 @@ int UtcDaliButtonSetLabelPropertyP(void) END_TEST; } -int UtcDaliButtonSetUnselectedImageP(void) -{ - ToolkitTestApplication application; - tet_infoline(" UtcDaliButtonSetUnselectedImageP"); - - PushButton pushButton = PushButton::New(); - Stage::GetCurrent().Add( pushButton ); - - application.SendNotification(); - application.Render(); - - pushButton.SetUnselectedImage( "Image.jpg" ); - - application.SendNotification(); - application.Render(); - - DALI_TEST_CHECK( pushButton ); - - END_TEST; -} - -int UtcDaliButtonSetSelectedImageP(void) -{ - ToolkitTestApplication application; - tet_infoline(" UtcDaliButtonSetButtonImage"); - - PushButton pushButton = PushButton::New(); - Stage::GetCurrent().Add( pushButton ); - - application.SendNotification(); - application.Render(); - - pushButton.SetSelectedImage( "Image.jpg" ); - - application.SendNotification(); - application.Render(); - - DALI_TEST_CHECK( pushButton ); - - END_TEST; -} - int UtcDaliButtonPressedSignalP(void) { ToolkitTestApplication application; 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(); @@ -750,12 +734,12 @@ int UtcDaliButtonClickedSignalP(void) 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(); @@ -843,9 +827,10 @@ int UtcDaliButtonStateChangedSignalP(void) 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(); @@ -857,7 +842,7 @@ int UtcDaliButtonStateChangedSignalP(void) 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 ); @@ -865,8 +850,7 @@ int UtcDaliButtonStateChangedSignalP(void) gIsCalledButtonCallback = false; stateChangedSignal = false; - button.SetSelected( false ); - + button.SetProperty( Button::Property::SELECTED, false); DALI_TEST_CHECK( gIsCalledButtonCallback ); DALI_TEST_CHECK( stateChangedSignal ); END_TEST; @@ -880,469 +864,186 @@ int UtcDaliButtonSetProperty(void) PushButton pushButton = PushButton::New(); pushButton.SetProperty(pushButton.GetPropertyIndex("disabled"), false); - DALI_TEST_CHECK( false == pushButton.IsDisabled() ); - - pushButton.SetProperty(pushButton.GetPropertyIndex("disabled"), true); - DALI_TEST_CHECK( true == pushButton.IsDisabled() ); - - END_TEST; -} - -int UtcDaliButtonSize(void) -{ - ToolkitTestApplication application; - tet_infoline(" UtcDaliButtonSize"); - - // 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 ); - - 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() == 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; + DALI_TEST_EQUALS( pushButton.GetProperty( pushButton.GetPropertyIndex("disabled")), false, TEST_LOCATION ); - try - { - ResourceImage image1 = ResourceImage::New( TEST_IMAGE_ONE ); - button.SetButtonImage( image1 ); - - DALI_TEST_CHECK( false ); - } - catch(...) - { - DALI_TEST_CHECK( true ); - } + pushButton.SetProperty(pushButton.GetPropertyIndex("disabled"), true); + DALI_TEST_EQUALS( pushButton.GetProperty( pushButton.GetPropertyIndex("disabled")), true, TEST_LOCATION ); END_TEST; } -int UtcDaliButtonSetSelectedImageWithImageP(void) +int UtcDaliButtonEventConsumption(void) { - ToolkitTestApplication application; - - PushButton button = PushButton::New(); - Stage::GetCurrent().Add( button ); - ResourceImage image1 = ResourceImage::New( TEST_IMAGE_ONE ); + /** + * [ Parent ] + * [ Child ] + * + * Child parented and positioned under parent. + * Touch up and down performed on child. + * Should only trigger signal on child. + */ - try - { - button.SetSelectedImage( image1 ); - Property::Value value = button.GetProperty( Button::Property::SELECTED_STATE_IMAGE ); - DALI_TEST_CHECK( value.Get() == 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; + 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.SetSelectedImage( CreateBufferImage( 10, 10, Color::WHITE ) ); - DALI_TEST_CHECK( false ); - } - catch(...) - { - DALI_TEST_CHECK( true ); - } + 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 UtcDaliButtonSetSelectedColorP(void) -{ - ToolkitTestApplication application; - tet_infoline(" UtcDaliButtonSetSelectedColorP"); + // Reset signal flags + gIsCalledChildButtonCallback = false; + gIsCalledButtonCallback = false; - PushButton pushButton = PushButton::New(); - Stage::GetCurrent().Add( pushButton ); + parentButton.ClickedSignal().Connect( &ButtonCallback ); + childButton.ClickedSignal().Connect( &ChildButtonCallback ); + // 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 ); - const Vector4 SET_COLOR = Color::BLUE; - - pushButton.SetSize( Vector2( 20.0f, 20.0f ) ); - pushButton.SetProperty( Button::Property::SELECTED_COLOR, SET_COLOR ); - + 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 ); - Vector4 color = pushButton.GetProperty( Button::Property::SELECTED_COLOR ); - - DALI_TEST_EQUALS( color, SET_COLOR, TEST_LOCATION ); + DALI_TEST_EQUALS( gIsCalledChildButtonCallback, true, TEST_LOCATION ); + DALI_TEST_EQUALS( ! gIsCalledButtonCallback, true, TEST_LOCATION ); END_TEST; } -int UtcDaliButtonSetUnSelectedColorP(void) +int UtcDaliButtonRelease(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 ); + /** + * Down event followed by interrupted event should signal Release. + */ - application.SendNotification(); - application.Render(); - - Vector4 color = pushButton.GetProperty( 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 ); + 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 ); - 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 ); + // Reset signal flags + gIsCalledButtonCallback = false; + // 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 ); - Vector4 color = pushButton.GetProperty( Button::Property::SELECTED_COLOR ); - - DALI_TEST_EQUALS( color, FIRST_COLOR, TEST_LOCATION ); - - pushButton.SetProperty( Button::Property::SELECTED_COLOR, SECOND_COLOR ); - + event = Dali::Integration::TouchEvent(); + point.SetState( PointState::INTERRUPTED ); + event.AddPoint( point ); + // flush the queue and render once application.SendNotification(); application.Render(); + application.ProcessEvent( event ); - color = pushButton.GetProperty( Button::Property::SELECTED_COLOR ); - - DALI_TEST_EQUALS( color, SECOND_COLOR, TEST_LOCATION ); + DALI_TEST_EQUALS( gIsCalledButtonCallback, true, TEST_LOCATION ); END_TEST; } -int UtcDaliButtonSetImagesWithDeprecatedProperties(void) +int UtcDaliButtonMultiTouch(void) { - ToolkitTestApplication application; - tet_infoline(" UtcDaliButtonSetImagesWithDeprecatedProperties"); + /** + * Down event followed by a multi touch point event should signal Release. + */ - PushButton pushButton = PushButton::New(); + ToolkitTestApplication application; - Stage::GetCurrent().Add( pushButton ); + Button button = PushButton::New(); + button.SetProperty( Button::Property::TOGGLABLE, true); - Property::Map propertyMap; - propertyMap.Insert(Visual::Property::TYPE, Visual::COLOR); - propertyMap.Insert(ColorVisual::Property::MIX_COLOR, Color::BLUE); + 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 ); - DALI_TEST_EQUALS( pushButton.GetRendererCount(), 0, TEST_LOCATION ); + // Reset signal flags + gIsCalledButtonCallback = false; - pushButton.SetProperty( Toolkit::Button::Property::UNSELECTED_STATE_IMAGE, propertyMap ); - application.SendNotification(); - application.Render(); - DALI_TEST_EQUALS( pushButton.GetRendererCount(), 1, TEST_LOCATION ); + // Peform a button down and then button interrupted at coordinates (10,10). + Dali::Integration::TouchEvent downEvent; + downEvent = Dali::Integration::TouchEvent(); + Dali::Integration::Point point; - 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 ); + // 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(); - DALI_TEST_EQUALS( pushButton.GetRendererCount(), 1, TEST_LOCATION ); + application.ProcessEvent( downEvent ); - 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 ); + // 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(); - 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(), TEST_IMAGE_ONE, TEST_LOCATION ); - -END_TEST; -} - -int UtcDaliButtonSetLabelTextDeprecatedPropertyP(void) -{ - ToolkitTestApplication application; - tet_infoline(" UtcDaliButtonSetLabelTextDeprecatedPropertyP"); + application.ProcessEvent( upEvent ); - 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 ); + tet_infoline("Button should now be selected\n"); + bool isSelected = button.GetProperty( Button::Property::SELECTED ) ; + DALI_TEST_EQUALS( isSelected, true, TEST_LOCATION ); - std::string labelText = button.GetProperty( Button::Property::LABEL_TEXT ); + // Add first point + Dali::Integration::TouchEvent multiEvent; + multiEvent = Dali::Integration::TouchEvent(); + point.SetState( PointState::DOWN ); + point.SetScreenPosition( Vector2( 10, 10 ) ); + multiEvent.AddPoint( point ); - DALI_TEST_EQUALS( labelText, TEST_LABEL1, TEST_LOCATION ); + // Add second point + point.SetState( PointState::DOWN ); + point.SetScreenPosition( Vector2( 15, 15 ) ); + multiEvent.AddPoint( point ); - 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 ); + tet_infoline("Before a multi touch event\n"); - labelText = button.GetProperty( Button::Property::LABEL_TEXT ); + // flush the queue and render once + application.SendNotification(); + application.Render(); + application.ProcessEvent( multiEvent ); - DALI_TEST_EQUALS( labelText, TEST_LABEL2, TEST_LOCATION ); + DALI_TEST_EQUALS( gIsCalledButtonCallback, true, TEST_LOCATION ); END_TEST; }