1
0
mirror of https://github.com/ppy/osu.git synced 2024-11-07 14:27:25 +08:00
osu-lazer/osu.Game.Tests/Visual/UserInterface/TestSceneRoundedButton.cs

Ignoring revisions in .git-blame-ignore-revs. Click here to bypass and see the normal blame view.

79 lines
2.9 KiB
C#
Raw Normal View History

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.
using System;
2022-05-09 23:19:29 +08:00
using System.Collections.Generic;
using System.Linq;
2021-10-11 02:21:41 +08:00
using NUnit.Framework;
2022-05-09 23:19:29 +08:00
using osu.Framework.Extensions.IEnumerableExtensions;
2021-10-11 02:21:41 +08:00
using osu.Framework.Graphics;
using osu.Framework.Graphics.Containers;
2022-05-09 23:19:29 +08:00
using osu.Framework.Testing;
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;
using osuTK;
2021-10-11 02:21:41 +08:00
namespace osu.Game.Tests.Visual.UserInterface
{
public class TestSceneRoundedButton : OsuTestScene
{
[Test]
public void TestBasic()
{
RoundedButton button = null;
AddStep("create button", () => Child = new Container
{
RelativeSizeAxes = Axes.Both,
Children = new Drawable[]
{
button = new RoundedButton
{
Width = 400,
2022-05-09 23:19:29 +08:00
Text = "Test Button",
2021-10-11 02:21:41 +08:00
Anchor = Anchor.Centre,
Origin = Anchor.Centre,
Action = () => { }
}
}
});
AddToggleStep("toggle disabled", disabled => button.Action = disabled ? (Action)null : () => { });
}
2022-05-09 23:19:29 +08:00
[Test]
public void TestOverlay()
{
IEnumerable<OverlayColourScheme> schemes = Enum.GetValues(typeof(OverlayColourScheme)).Cast<OverlayColourScheme>();
AddStep("create buttons", () =>
{
Child = new FillFlowContainer
{
Anchor = Anchor.Centre,
Origin = Anchor.Centre,
AutoSizeAxes = Axes.Both,
Direction = FillDirection.Vertical,
Spacing = new Vector2(5f),
ChildrenEnumerable = schemes.Select(c => new DependencyProvidingContainer
{
AutoSizeAxes = Axes.Both,
CachedDependencies = new (Type, object)[] { (typeof(OverlayColourProvider), new OverlayColourProvider(c)) },
Child = new RoundedButton
{
Width = 400,
Text = $"Test {c}",
Anchor = Anchor.Centre,
Origin = Anchor.Centre,
Action = () => { },
}
}),
};
});
AddAssert("first button has correct colour", () => this.ChildrenOfType<RoundedButton>().First().BackgroundColour == new OverlayColourProvider(schemes.First()).Highlight1);
AddToggleStep("toggle disabled", disabled => this.ChildrenOfType<RoundedButton>().ForEach(b => b.Action = disabled ? (Action)null : () => { }));
}
2021-10-11 02:21:41 +08:00
}
}