1
0
mirror of https://github.com/ppy/osu.git synced 2024-09-23 10:07:25 +08:00
osu-lazer/osu.Game.Tests/Visual/UserInterface/TestSceneModSelectScreen.cs

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

77 lines
3.2 KiB
C#
Raw Normal View History

2022-03-27 05:43:17 +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.Linq;
2022-03-27 05:43:17 +08:00
using NUnit.Framework;
using osu.Framework.Graphics;
using osu.Framework.Graphics.Containers;
using osu.Framework.Testing;
using osu.Game.Graphics.UserInterface;
2022-03-27 05:43:17 +08:00
using osu.Game.Overlays.Mods;
using osu.Game.Rulesets.Osu.Mods;
using osuTK.Input;
2022-03-27 05:43:17 +08:00
namespace osu.Game.Tests.Visual.UserInterface
{
[TestFixture]
public class TestSceneModSelectScreen : OsuManualInputManagerTestScene
2022-03-27 05:43:17 +08:00
{
private ModSelectScreen modSelectScreen;
2022-03-27 05:43:17 +08:00
[SetUpSteps]
public void SetUpSteps()
{
2022-03-27 05:43:17 +08:00
AddStep("create screen", () => Child = modSelectScreen = new ModSelectScreen
{
RelativeSizeAxes = Axes.Both,
State = { Value = Visibility.Visible },
SelectedMods = { BindTarget = SelectedMods }
2022-03-27 05:43:17 +08:00
});
}
2022-03-27 05:43:17 +08:00
[Test]
public void TestStateChange()
{
2022-03-27 05:43:17 +08:00
AddToggleStep("toggle state", visible => modSelectScreen.State.Value = visible ? Visibility.Visible : Visibility.Hidden);
}
[Test]
public void TestCustomisationToggleState()
{
assertCustomisationToggleState(disabled: true, active: false);
AddStep("select customisable mod", () => SelectedMods.Value = new[] { new OsuModDoubleTime() });
assertCustomisationToggleState(disabled: false, active: false);
AddStep("select mod requiring configuration", () => SelectedMods.Value = new[] { new OsuModDifficultyAdjust() });
assertCustomisationToggleState(disabled: false, active: true);
AddStep("dismiss mod customisation", () =>
{
InputManager.MoveMouseTo(modSelectScreen.ChildrenOfType<ShearedToggleButton>().Single());
InputManager.Click(MouseButton.Left);
});
AddStep("append another mod not requiring config", () => SelectedMods.Value = SelectedMods.Value.Append(new OsuModFlashlight()).ToArray());
assertCustomisationToggleState(disabled: false, active: false);
AddStep("select mod without configuration", () => SelectedMods.Value = new[] { new OsuModAutoplay() });
assertCustomisationToggleState(disabled: true, active: false);
AddStep("select mod requiring configuration", () => SelectedMods.Value = new[] { new OsuModDifficultyAdjust() });
assertCustomisationToggleState(disabled: false, active: true);
AddStep("select mod without configuration", () => SelectedMods.Value = new[] { new OsuModAutoplay() });
assertCustomisationToggleState(disabled: true, active: false); // config was dismissed without explicit user action.
}
private void assertCustomisationToggleState(bool disabled, bool active)
{
ShearedToggleButton getToggle() => modSelectScreen.ChildrenOfType<ShearedToggleButton>().Single();
AddAssert($"customisation toggle is {(disabled ? "" : "not ")}disabled", () => getToggle().Active.Disabled == disabled);
AddAssert($"customisation toggle is {(active ? "" : "not ")}active", () => getToggle().Active.Value == active);
}
2022-03-27 05:43:17 +08:00
}
}