2021-10-11 02:21:41 +08:00
// Copyright (c) ppy Pty Ltd <contact@ppy.sh>. Licensed under the MIT Licence.
// See the LICENCE file in the repository root for full licence text.
2022-06-17 15:37:17 +08:00
#nullable disable
2022-05-09 23:19:29 +08:00
using System.Linq ;
2021-10-11 02:21:41 +08:00
using NUnit.Framework ;
2022-05-10 02:19:34 +08:00
using osu.Framework.Bindables ;
2021-10-11 02:21:41 +08:00
using osu.Framework.Graphics ;
2022-05-24 17:42:40 +08:00
using osu.Framework.Graphics.Containers ;
2022-05-09 23:19:29 +08:00
using osu.Framework.Testing ;
2022-05-24 17:42:40 +08:00
using osu.Game.Graphics ;
2021-10-11 02:21:41 +08:00
using osu.Game.Graphics.UserInterfaceV2 ;
2022-05-09 23:19:29 +08:00
using osu.Game.Overlays ;
2022-05-24 17:42:40 +08:00
using osu.Game.Overlays.Settings ;
2021-10-11 02:21:41 +08:00
namespace osu.Game.Tests.Visual.UserInterface
{
2022-05-10 02:19:34 +08:00
public class TestSceneRoundedButton : ThemeComparisonTestScene
2021-10-11 02:21:41 +08:00
{
2022-05-10 02:19:34 +08:00
private readonly BindableBool enabled = new BindableBool ( true ) ;
2021-10-11 02:21:41 +08:00
2022-05-24 17:42:40 +08:00
protected override Drawable CreateContent ( )
2022-05-10 02:19:34 +08:00
{
2022-05-24 17:42:40 +08:00
return new FillFlowContainer
{
RelativeSizeAxes = Axes . Both ,
Children = new Drawable [ ]
{
new RoundedButton
{
Width = 400 ,
Text = "Test button" ,
Anchor = Anchor . Centre ,
Origin = Anchor . Centre ,
Enabled = { BindTarget = enabled } ,
} ,
new SettingsButton
{
Text = "Test button" ,
Anchor = Anchor . Centre ,
Origin = Anchor . Centre ,
Enabled = { BindTarget = enabled } ,
} ,
}
} ;
}
2021-10-11 02:21:41 +08:00
2022-05-10 02:19:34 +08:00
[Test]
public void TestDisabled ( )
{
AddToggleStep ( "toggle disabled" , disabled = > enabled . Value = ! disabled ) ;
2021-10-11 02:21:41 +08:00
}
2022-05-09 23:19:29 +08:00
[Test]
2022-05-10 02:19:34 +08:00
public void TestBackgroundColour ( )
2022-05-09 23:19:29 +08:00
{
2022-05-10 02:19:34 +08:00
AddStep ( "set red scheme" , ( ) = > CreateThemedContent ( OverlayColourScheme . Red ) ) ;
2022-05-24 17:42:40 +08:00
AddAssert ( "rounded button has correct colour" , ( ) = > Cell ( 0 , 1 ) . ChildrenOfType < RoundedButton > ( ) . First ( ) . BackgroundColour = = new OsuColour ( ) . Blue3 ) ;
AddAssert ( "settings button has correct colour" , ( ) = > Cell ( 0 , 1 ) . ChildrenOfType < SettingsButton > ( ) . First ( ) . BackgroundColour = = new OverlayColourProvider ( OverlayColourScheme . Red ) . Highlight1 ) ;
2022-05-09 23:19:29 +08:00
}
2021-10-11 02:21:41 +08:00
}
}