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=d01f3b0be70689cd36e8ce6b9992082c3eaa9a75;hp=ead898d941a48be1f0a39d0227ee10998547596e;hb=5e351965bad7e1de2e94027548b022bac692603c;hpb=3a727ff0ae4baf350511079f016aeaadd4b0faa9 diff --git a/automated-tests/src/dali-toolkit/utc-Dali-Button.cpp b/automated-tests/src/dali-toolkit/utc-Dali-Button.cpp index ead898d..d01f3b0 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) 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. @@ -21,11 +21,14 @@ // Need to override adaptor classes for toolkit test harness, so include // test harness headers before dali headers. #include +#include "dali-toolkit-test-utils/toolkit-timer.h" #include #include #include +#include + using namespace Dali; using namespace Toolkit; @@ -44,12 +47,31 @@ namespace { static bool gIsCalledButtonCallback = false; +const int RENDER_FRAME_INTERVAL = 16; + static bool ButtonCallback( Button button ) { gIsCalledButtonCallback = 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) @@ -112,8 +134,8 @@ Dali::Integration::Point GetPointUpOutside() return point; } - static float ANIMATION_TIME( 0.5f ); + } // namespace int UtcDaliButtonConstructorP(void) @@ -181,27 +203,93 @@ 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 ); - button.SetDisabled( false ); + DALI_TEST_EQUALS( button.GetProperty( button.GetPropertyIndex("disabled")), true, TEST_LOCATION ); - DALI_TEST_CHECK( !button.IsDisabled() ); + button.SetProperty( button.GetPropertyIndex("disabled"), false ); - button.SetDisabled( true ); + DALI_TEST_EQUALS( button.GetProperty( button.GetPropertyIndex("disabled")), false, TEST_LOCATION ); - DALI_TEST_CHECK( button.IsDisabled() ); + button.SetProperty( button.GetPropertyIndex("disabled"), true ); - button.SetDisabled( false ); + DALI_TEST_EQUALS( button.GetProperty( button.GetPropertyIndex("disabled")), true, TEST_LOCATION ); + + button.SetProperty( button.GetPropertyIndex("disabled"), false ); + + DALI_TEST_EQUALS( button.GetProperty( button.GetPropertyIndex("disabled")), false, TEST_LOCATION ); + + END_TEST; +} + +int UtcDaliButtonSetDisabledWithDifferentStates01P(void) +{ + ToolkitTestApplication application; + + tet_infoline("UtcDaliButtonSetDisabledWithDifferentStates01P\n"); + + Button button = PushButton::New(); + + 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 ); + + bool isSelected = button.GetProperty( Button::Property::SELECTED ) ; + + DALI_TEST_EQUALS( isSelected, SELECTED , TEST_LOCATION ); + + END_TEST; +} + +int UtcDaliButtonSetDisabledWithDifferentStates02P(void) +{ + ToolkitTestApplication application; + + tet_infoline("UtcDaliButtonSetDisabledWithDifferentStates02\n"); + + Button button = PushButton::New(); + + bool SELECTED = true; + + button.SetProperty( Button::Property::TOGGLABLE, true ); + button.SetProperty( Button::Property::SELECTED, SELECTED ); + button.SetProperty( Button::Property::DISABLED, true ); + + bool isSelected = button.GetProperty( 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.SetProperty( Button::Property::DISABLED, false ); + button.SetProperty( Button::Property::SELECTED, !SELECTED ); + + isSelected = button.GetProperty( Button::Property::SELECTED ); + DALI_TEST_EQUALS( isSelected, !SELECTED , TEST_LOCATION ); + + END_TEST; +} + +int UtcDaliButtonPropertyGetLabelAlignment(void) +{ + ToolkitTestApplication application; + tet_infoline(" UtcDaliPushButtonPropertyGetLabelAlignment\n"); + + Button button = PushButton::New(); + button.SetProperty( Toolkit::DevelButton::Property::LABEL_RELATIVE_ALIGNMENT, "END" ); + DALI_TEST_EQUALS( button.GetProperty( Toolkit::DevelButton::Property::LABEL_RELATIVE_ALIGNMENT ), "END", TEST_LOCATION ); - DALI_TEST_CHECK( !button.IsDisabled() ); END_TEST; } @@ -221,23 +309,23 @@ int UtcDaliButtonIsDisabledP(void) END_TEST; } -int UtcDaliButtonSetAutoRepeatingP(void) +int UtcDaliButtonAutoRepeatingPropertyP(void) { ToolkitTestApplication application; Button button = PushButton::New(); - button.SetAutoRepeating( true ); + button.SetProperty( button.GetPropertyIndex("autoRepeating"), true ); - DALI_TEST_CHECK( button.IsAutoRepeating() ); + DALI_TEST_EQUALS( button.GetProperty( button.GetPropertyIndex("autoRepeating")), true, TEST_LOCATION ); - button.SetAutoRepeating( false ); + button.SetProperty( button.GetPropertyIndex("autoRepeating"), false ); - DALI_TEST_CHECK( !button.IsAutoRepeating() ); + DALI_TEST_EQUALS( button.GetProperty( button.GetPropertyIndex("autoRepeating")), false, TEST_LOCATION ); - button.SetAutoRepeating( true ); + button.SetProperty( button.GetPropertyIndex("autoRepeating"), true ); - DALI_TEST_CHECK( button.IsAutoRepeating() ); + DALI_TEST_EQUALS( button.GetProperty( button.GetPropertyIndex("autoRepeating")), true, TEST_LOCATION ); button.SetAutoRepeating( false ); @@ -261,68 +349,129 @@ int UtcDaliButtonIsAutoRepeatingP(void) END_TEST; } -int UtcDaliButtonSetInitialAutoRepeatingDelayP(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.SetAnchorPoint( AnchorPoint::TOP_LEFT ); + button.SetParentOrigin( ParentOrigin::TOP_LEFT ); + button.SetPosition( 240, 400 ); + button.SetSize( 100, 100 ); + Stage::GetCurrent().Add( button ); - button.SetInitialAutoRepeatingDelay( 0.5f ); + application.SendNotification(); + application.Render(); - DALI_TEST_EQUALS( button.GetInitialAutoRepeatingDelay(), 0.5f, TEST_LOCATION ); + 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.SetInitialAutoRepeatingDelay( 0.2f ); + Dali::Integration::TouchEvent event; + + // 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 ); + + DALI_TEST_EQUALS( gIsCalledButtonCallback, true, TEST_LOCATION ); - DALI_TEST_EQUALS( button.GetInitialAutoRepeatingDelay(), 0.2f, TEST_LOCATION ); END_TEST; } -int UtcDaliButtonSetNextAutoRepeatingDelayP(void) +int UtcDaliButtonInitialAutoRepeatingDelayPropertyP(void) { ToolkitTestApplication application; Button button = PushButton::New(); - button.SetNextAutoRepeatingDelay( 0.5f ); + button.SetProperty( button.GetPropertyIndex("initialAutoRepeatingDelay"), 0.5f ); - DALI_TEST_EQUALS( button.GetNextAutoRepeatingDelay(), 0.5f, TEST_LOCATION ); + DALI_TEST_EQUALS( button.GetProperty( button.GetPropertyIndex("initialAutoRepeatingDelay")), 0.5f, TEST_LOCATION ); - button.SetNextAutoRepeatingDelay( 0.2f ); + button.SetProperty( button.GetPropertyIndex("initialAutoRepeatingDelay"), 0.2f ); + + DALI_TEST_EQUALS( button.GetProperty( button.GetPropertyIndex("initialAutoRepeatingDelay")), 0.2f, TEST_LOCATION ); - DALI_TEST_EQUALS( button.GetNextAutoRepeatingDelay(), 0.2f, TEST_LOCATION ); END_TEST; } -int UtcDaliButtonSetTogglableButtonP(void) +int UtcDaliButtonNextAutoRepeatingDelayPropertyP(void) { ToolkitTestApplication application; Button button = PushButton::New(); - button.SetTogglableButton( true ); + button.SetProperty( button.GetPropertyIndex("nextAutoRepeatingDelay"), 0.5f ); - DALI_TEST_CHECK( button.IsTogglableButton() ); + DALI_TEST_EQUALS( button.GetProperty( button.GetPropertyIndex("nextAutoRepeatingDelay")), 0.5f, TEST_LOCATION ); - button.SetTogglableButton( false ); + button.SetProperty( button.GetPropertyIndex("nextAutoRepeatingDelay"), 0.2f ); - DALI_TEST_CHECK( !button.IsTogglableButton() ); + DALI_TEST_EQUALS( button.GetProperty( button.GetPropertyIndex("nextAutoRepeatingDelay")), 0.2f, TEST_LOCATION ); END_TEST; } -int UtcDaliButtonSetSelectedP(void) +int UtcDaliButtonTogglableButtonPropertyP(void) { ToolkitTestApplication application; Button button = PushButton::New(); - button.SetTogglableButton( true ); - button.SetSelected( true ); + button.SetProperty( button.GetPropertyIndex("togglable"), true ); - DALI_TEST_CHECK( button.IsSelected() ); + DALI_TEST_EQUALS( button.GetProperty( button.GetPropertyIndex("togglable")), true, TEST_LOCATION ); - button.SetSelected( false ); + button.SetProperty( button.GetPropertyIndex("togglable"), false ); - DALI_TEST_CHECK( !button.IsSelected() ); + DALI_TEST_EQUALS( button.GetProperty( button.GetPropertyIndex("togglable")), false, TEST_LOCATION ); + END_TEST; +} + +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( button.GetPropertyIndex("selected")), true, TEST_LOCATION ); + + button.SetProperty( button.GetPropertyIndex("selected"), false ); + + DALI_TEST_EQUALS( button.GetProperty( button.GetPropertyIndex("selected")), false, TEST_LOCATION ); END_TEST; } @@ -339,76 +488,108 @@ int UtcDaliButtonSetAnimationTimeP(void) 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::Visual::TEXT ) + .Add( Toolkit::TextVisual::Property::POINT_SIZE, 15.0f ) + .Add( Toolkit::TextVisual::Property::TEXT, "Button Label") + ); - button.SetLabelText( "Button Label" ); - - DALI_TEST_EQUALS( button.GetLabelText(), "Button Label", TEST_LOCATION ); + DALI_TEST_EQUALS( GetButtonText( button ), "Button Label", TEST_LOCATION ); END_TEST; } -int UtcDaliButtonSetLabelActorP(void) +int UtcDaliButtonSetLabelStringWithPropertyMapStringsP(void) { ToolkitTestApplication application; Button button = PushButton::New(); - button.SetLabelText( "Button Label" ); + 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 ); - DALI_TEST_EQUALS( button.GetLabelText(), "Button Label", TEST_LOCATION ); + 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 UtcDaliButtonSetUnselectedImageP(void) +int UtcDaliButtonSetLabelWithStringP(void) { ToolkitTestApplication application; - tet_infoline(" UtcDaliButtonSetUnselectedImageP"); - - PushButton pushButton = PushButton::New(); - Stage::GetCurrent().Add( pushButton ); - - application.SendNotification(); - application.Render(); - - pushButton.SetSize( Vector2( 20.0f, 20.0f ) ); - pushButton.SetUnselectedImage( "Image.jpg" ); - application.SendNotification(); - application.Render(); + Button button = PushButton::New(); - Vector3 size = pushButton.GetCurrentSize(); + // 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 ) + ); - DALI_TEST_EQUALS( size.width, 20.f, TEST_LOCATION ); - DALI_TEST_EQUALS( size.height, 20.f, TEST_LOCATION ); + button.SetProperty( Toolkit::Button::Property::LABEL, "Button Label" ); + DALI_TEST_EQUALS( GetButtonText( button ), "Button Label", TEST_LOCATION ); END_TEST; } -int UtcDaliButtonSetSelectedImageP(void) +int UtcDaliButtonSetLabelPropertyP(void) { ToolkitTestApplication application; - tet_infoline(" UtcDaliButtonSetButtonImage"); - PushButton pushButton = PushButton::New(); - Stage::GetCurrent().Add( pushButton ); + tet_infoline(" UtcDaliButtonSetLabelPropertyP Set text label and then set again with new text"); - application.SendNotification(); - application.Render(); - pushButton.SetSize( Vector2( 20.0f, 20.0f ) ); - pushButton.SetSelectedImage( "Image.jpg" ); + const std::string TEST_LABEL1 = "test label one"; + const std::string TEST_LABEL2 = "test label two"; - application.SendNotification(); - application.Render(); + 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 ) + ); - Vector3 size = pushButton.GetCurrentSize(); + DALI_TEST_EQUALS( GetButtonText( button ), TEST_LABEL1, TEST_LOCATION ); - DALI_TEST_EQUALS( size.width, 20.f, TEST_LOCATION ); - DALI_TEST_EQUALS( size.height, 20.f, 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; } @@ -619,7 +800,8 @@ int UtcDaliButtonStateChangedSignalP(void) tet_infoline(" UtcDaliButtonStateChangedSignalP"); Button button = PushButton::New(); - button.SetTogglableButton( true ); + + button.SetProperty( Button::Property::TOGGLABLE, true); Stage::GetCurrent().Add( button ); @@ -633,7 +815,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 ); @@ -641,8 +823,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; @@ -656,354 +837,126 @@ 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(); + DALI_TEST_EQUALS( pushButton.GetProperty( pushButton.GetPropertyIndex("disabled")), false, TEST_LOCATION ); - 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 ); - } + pushButton.SetProperty(pushButton.GetPropertyIndex("disabled"), true); + DALI_TEST_EQUALS( pushButton.GetProperty( pushButton.GetPropertyIndex("disabled")), true, TEST_LOCATION ); END_TEST; } -int UtcDaliButtonSetDisabledImageN(void) -{ - ToolkitTestApplication application; - - PushButton button; +// Deprecated API Tests - try - { - button.SetDisabledImage( "TestImage.jpg"); - DALI_TEST_CHECK( false ); - } - catch(...) - { - DALI_TEST_CHECK( true ); - } - - END_TEST; -} - -int UtcDaliButtonSetDisabledSelectedImageP(void) +int UtcDaliButtonSetDisabledP(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; -} + Button button = PushButton::New(); -int UtcDaliButtonSetDisabledSelectedImageN(void) -{ - ToolkitTestApplication application; + button.SetDisabled( true ); - PushButton button; + DALI_TEST_CHECK( button.IsDisabled() ); - try - { - button.SetDisabledSelectedImage( "TestImage.jpg"); - DALI_TEST_CHECK( false ); - } - catch(...) - { - DALI_TEST_CHECK( true ); - } + button.SetDisabled( false ); - END_TEST; -} + DALI_TEST_CHECK( !button.IsDisabled() ); -int UtcDaliButtonSetLabelP(void) -{ - ToolkitTestApplication application; + button.SetDisabled( true ); - PushButton button = PushButton::New(); - Stage::GetCurrent().Add( button ); + DALI_TEST_CHECK( button.IsDisabled() ); - try - { - button.SetLabel( TextLabel::New("Hello") ); - DALI_TEST_CHECK( true ); - } - catch(...) - { - DALI_TEST_CHECK( false ); - } + button.SetDisabled( false ); + DALI_TEST_CHECK( !button.IsDisabled() ); END_TEST; } -int UtcDaliButtonSetLabelN(void) +int UtcDaliButtonSetAutoRepeatingP(void) { ToolkitTestApplication application; - PushButton button; - - try - { - button.SetLabel( TextLabel::New("Hello") ); - DALI_TEST_CHECK( false ); - } - catch(...) - { - DALI_TEST_CHECK( true ); - } - - END_TEST; -} + Button button = PushButton::New(); -int UtcDaliButtonSetButtonImageP(void) -{ - ToolkitTestApplication application; + button.SetAutoRepeating( true ); - PushButton button = PushButton::New(); - Stage::GetCurrent().Add( button ); + DALI_TEST_CHECK( button.IsAutoRepeating() ); - try - { - button.SetButtonImage( CreateBufferImage( 10, 10, Color::WHITE ) ); - DALI_TEST_CHECK( ImageView::DownCast( button.GetButtonImage() ) ); - } - catch(...) - { - DALI_TEST_CHECK( false ); - } + button.SetAutoRepeating( false ); - END_TEST; -} + DALI_TEST_CHECK( !button.IsAutoRepeating() ); -int UtcDaliButtonSetButtonImageN(void) -{ - ToolkitTestApplication application; + button.SetAutoRepeating( true ); - PushButton button; + DALI_TEST_CHECK( button.IsAutoRepeating() ); - try - { - button.SetButtonImage( CreateBufferImage( 10, 10, Color::WHITE ) ); - DALI_TEST_CHECK( false ); - } - catch(...) - { - DALI_TEST_CHECK( true ); - } + button.SetAutoRepeating( false ); + DALI_TEST_CHECK( !button.IsAutoRepeating() ); END_TEST; } -int UtcDaliButtonSetSelectedImageWithImageP(void) +int UtcDaliButtonSetInitialAutoRepeatingDelayP(void) { ToolkitTestApplication application; - PushButton button = PushButton::New(); - Stage::GetCurrent().Add( button ); - - try - { - button.SetSelectedImage( CreateBufferImage( 10, 10, Color::WHITE ) ); - DALI_TEST_CHECK( ImageView::DownCast( button.GetSelectedImage() ) ); - } - catch(...) - { - DALI_TEST_CHECK( false ); - } - - END_TEST; -} + Button button = PushButton::New(); -int UtcDaliButtonSetSelectedImageWithImageN(void) -{ - ToolkitTestApplication application; + button.SetInitialAutoRepeatingDelay( 0.5f ); - PushButton button; + DALI_TEST_EQUALS( button.GetInitialAutoRepeatingDelay(), 0.5f, TEST_LOCATION ); - try - { - button.SetSelectedImage( CreateBufferImage( 10, 10, Color::WHITE ) ); - DALI_TEST_CHECK( false ); - } - catch(...) - { - DALI_TEST_CHECK( true ); - } + button.SetInitialAutoRepeatingDelay( 0.2f ); + DALI_TEST_EQUALS( button.GetInitialAutoRepeatingDelay(), 0.2f, TEST_LOCATION ); END_TEST; } -int UtcDaliButtonSetSelectedColorP(void) +int UtcDaliButtonSetNextAutoRepeatingDelayP(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 ); + Button button = PushButton::New(); - application.SendNotification(); - application.Render(); + button.SetNextAutoRepeatingDelay( 0.5f ); - Vector4 color = pushButton.GetProperty( Button::Property::SELECTED_COLOR ); + DALI_TEST_EQUALS( button.GetNextAutoRepeatingDelay(), 0.5f, TEST_LOCATION ); - DALI_TEST_EQUALS( color, SET_COLOR, TEST_LOCATION ); + button.SetProperty( Button::Property::NEXT_AUTO_REPEATING_DELAY, 0.2f ); + DALI_TEST_EQUALS( button.GetNextAutoRepeatingDelay(), 0.2f, TEST_LOCATION ); END_TEST; } -int UtcDaliButtonSetUnSelectedColorP(void) +int UtcDaliButtonSetTogglableButtonP(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 ); + Button button = PushButton::New(); - application.SendNotification(); - application.Render(); + button.SetTogglableButton( true ); - Vector4 color = pushButton.GetProperty( Button::Property::UNSELECTED_COLOR ); + DALI_TEST_CHECK( button.IsTogglableButton() ); - DALI_TEST_EQUALS( color, SET_COLOR, TEST_LOCATION ); + button.SetTogglableButton( false ); + DALI_TEST_CHECK( !button.IsTogglableButton() ); END_TEST; } -int UtcDaliButtonResetSelectedColorP(void) +int UtcDaliButtonSetSelectedP(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( Button::Property::SELECTED_COLOR ); - - DALI_TEST_EQUALS( color, FIRST_COLOR, TEST_LOCATION ); - pushButton.SetProperty( Button::Property::SELECTED_COLOR, SECOND_COLOR ); + Button button = PushButton::New(); + button.SetTogglableButton( true ); - application.SendNotification(); - application.Render(); + button.SetSelected( true ); - color = pushButton.GetProperty( Button::Property::SELECTED_COLOR ); + DALI_TEST_CHECK( button.IsSelected() ); - DALI_TEST_EQUALS( color, SECOND_COLOR, TEST_LOCATION ); + button.SetSelected( false ); + DALI_TEST_CHECK( !button.IsSelected() ); END_TEST; }