2022-12-01 18:57:50 +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.
|
|
|
|
|
2024-05-10 07:21:06 +08:00
|
|
|
using System;
|
|
|
|
using System.Collections.Generic;
|
2022-12-01 23:29:52 +08:00
|
|
|
using System.Linq;
|
2022-12-01 18:57:50 +08:00
|
|
|
using NUnit.Framework;
|
2022-12-03 01:44:21 +08:00
|
|
|
using osu.Framework.Allocation;
|
2022-12-01 18:57:50 +08:00
|
|
|
using osu.Framework.Graphics;
|
2022-12-03 01:44:21 +08:00
|
|
|
using osu.Framework.Graphics.Containers;
|
2023-09-04 12:49:29 +08:00
|
|
|
using osu.Framework.Graphics.Cursor;
|
2022-12-01 23:29:52 +08:00
|
|
|
using osu.Framework.Testing;
|
2022-12-03 01:44:21 +08:00
|
|
|
using osu.Game.Overlays;
|
|
|
|
using osu.Game.Overlays.Mods;
|
2024-05-10 07:21:06 +08:00
|
|
|
using osu.Game.Rulesets.Mods;
|
2023-09-05 15:44:22 +08:00
|
|
|
using osu.Game.Rulesets.Osu;
|
2024-05-10 07:21:06 +08:00
|
|
|
using osu.Game.Rulesets.Osu.Mods;
|
2024-05-16 09:36:14 +08:00
|
|
|
using osu.Game.Screens.Footer;
|
|
|
|
using osu.Game.Screens.SelectV2.Footer;
|
2022-12-01 23:29:52 +08:00
|
|
|
using osuTK.Input;
|
2022-12-01 18:57:50 +08:00
|
|
|
|
2024-05-16 09:36:14 +08:00
|
|
|
namespace osu.Game.Tests.Visual.UserInterface
|
2022-12-01 18:57:50 +08:00
|
|
|
{
|
2024-05-16 09:36:14 +08:00
|
|
|
public partial class TestSceneScreenFooter : OsuManualInputManagerTestScene
|
2022-12-01 18:57:50 +08:00
|
|
|
{
|
2024-05-16 09:36:14 +08:00
|
|
|
private ScreenFooterButtonRandom randomButton = null!;
|
|
|
|
private ScreenFooterButtonMods modsButton = null!;
|
2022-12-01 23:29:52 +08:00
|
|
|
|
|
|
|
private bool nextRandomCalled;
|
|
|
|
private bool previousRandomCalled;
|
|
|
|
|
2022-12-03 01:44:21 +08:00
|
|
|
private DummyOverlay overlay = null!;
|
|
|
|
|
2023-02-14 05:07:09 +08:00
|
|
|
[Cached]
|
|
|
|
private OverlayColourProvider colourProvider { get; set; } = new OverlayColourProvider(OverlayColourScheme.Aquamarine);
|
|
|
|
|
2022-12-01 18:57:50 +08:00
|
|
|
[SetUp]
|
|
|
|
public void SetUp() => Schedule(() =>
|
|
|
|
{
|
2022-12-01 23:29:52 +08:00
|
|
|
nextRandomCalled = false;
|
|
|
|
previousRandomCalled = false;
|
|
|
|
|
2024-05-16 09:36:14 +08:00
|
|
|
ScreenFooter footer;
|
2022-12-01 18:57:50 +08:00
|
|
|
|
2022-12-03 01:44:21 +08:00
|
|
|
Children = new Drawable[]
|
2022-12-01 18:57:50 +08:00
|
|
|
{
|
2023-09-04 12:49:29 +08:00
|
|
|
new PopoverContainer
|
2022-12-03 01:44:21 +08:00
|
|
|
{
|
2023-09-04 12:49:29 +08:00
|
|
|
RelativeSizeAxes = Axes.Both,
|
2024-05-16 09:36:14 +08:00
|
|
|
Child = footer = new ScreenFooter(),
|
2022-12-03 01:44:21 +08:00
|
|
|
},
|
|
|
|
overlay = new DummyOverlay()
|
2022-12-01 18:57:50 +08:00
|
|
|
};
|
2022-12-01 20:13:37 +08:00
|
|
|
|
2024-05-16 09:36:14 +08:00
|
|
|
footer.AddButton(modsButton = new ScreenFooterButtonMods { Current = SelectedMods }, overlay);
|
|
|
|
footer.AddButton(randomButton = new ScreenFooterButtonRandom
|
2022-12-01 23:29:52 +08:00
|
|
|
{
|
|
|
|
NextRandom = () => nextRandomCalled = true,
|
|
|
|
PreviousRandom = () => previousRandomCalled = true
|
|
|
|
});
|
2024-05-16 09:36:14 +08:00
|
|
|
footer.AddButton(new ScreenFooterButtonOptions());
|
2022-12-01 23:29:52 +08:00
|
|
|
|
2022-12-03 01:44:21 +08:00
|
|
|
overlay.Hide();
|
2022-12-01 18:57:50 +08:00
|
|
|
});
|
|
|
|
|
2023-09-05 15:44:22 +08:00
|
|
|
[SetUpSteps]
|
|
|
|
public void SetUpSteps()
|
|
|
|
{
|
2024-05-10 07:21:06 +08:00
|
|
|
AddStep("clear mods", () => SelectedMods.Value = Array.Empty<Mod>());
|
2023-09-05 15:44:22 +08:00
|
|
|
AddStep("set beatmap", () => Beatmap.Value = CreateWorkingBeatmap(CreateBeatmap(new OsuRuleset().RulesetInfo)));
|
|
|
|
}
|
|
|
|
|
2024-05-10 07:21:06 +08:00
|
|
|
[Test]
|
|
|
|
public void TestMods()
|
|
|
|
{
|
|
|
|
AddStep("one mod", () => SelectedMods.Value = new List<Mod> { new OsuModHidden() });
|
|
|
|
AddStep("two mods", () => SelectedMods.Value = new List<Mod> { new OsuModHidden(), new OsuModHardRock() });
|
|
|
|
AddStep("three mods", () => SelectedMods.Value = new List<Mod> { new OsuModHidden(), new OsuModHardRock(), new OsuModDoubleTime() });
|
|
|
|
AddStep("four mods", () => SelectedMods.Value = new List<Mod> { new OsuModHidden(), new OsuModHardRock(), new OsuModDoubleTime(), new OsuModClassic() });
|
|
|
|
AddStep("five mods", () => SelectedMods.Value = new List<Mod> { new OsuModHidden(), new OsuModHardRock(), new OsuModDoubleTime(), new OsuModClassic(), new OsuModDifficultyAdjust() });
|
|
|
|
|
2024-05-10 11:38:48 +08:00
|
|
|
AddStep("modified", () => SelectedMods.Value = new List<Mod> { new OsuModDoubleTime { SpeedChange = { Value = 1.2 } } });
|
|
|
|
AddStep("modified + one", () => SelectedMods.Value = new List<Mod> { new OsuModHidden(), new OsuModDoubleTime { SpeedChange = { Value = 1.2 } } });
|
|
|
|
AddStep("modified + two", () => SelectedMods.Value = new List<Mod> { new OsuModHidden(), new OsuModHardRock(), new OsuModDoubleTime { SpeedChange = { Value = 1.2 } } });
|
|
|
|
AddStep("modified + three", () => SelectedMods.Value = new List<Mod> { new OsuModHidden(), new OsuModHardRock(), new OsuModClassic(), new OsuModDoubleTime { SpeedChange = { Value = 1.2 } } });
|
|
|
|
AddStep("modified + four", () => SelectedMods.Value = new List<Mod> { new OsuModHidden(), new OsuModHardRock(), new OsuModClassic(), new OsuModDifficultyAdjust(), new OsuModDoubleTime { SpeedChange = { Value = 1.2 } } });
|
|
|
|
|
2024-05-10 07:21:06 +08:00
|
|
|
AddStep("clear mods", () => SelectedMods.Value = Array.Empty<Mod>());
|
|
|
|
AddWaitStep("wait", 3);
|
|
|
|
AddStep("one mod", () => SelectedMods.Value = new List<Mod> { new OsuModHidden() });
|
|
|
|
|
|
|
|
AddStep("clear mods", () => SelectedMods.Value = Array.Empty<Mod>());
|
|
|
|
AddWaitStep("wait", 3);
|
|
|
|
AddStep("five mods", () => SelectedMods.Value = new List<Mod> { new OsuModHidden(), new OsuModHardRock(), new OsuModDoubleTime(), new OsuModClassic(), new OsuModDifficultyAdjust() });
|
|
|
|
}
|
|
|
|
|
2023-09-05 15:44:22 +08:00
|
|
|
[Test]
|
|
|
|
public void TestShowOptions()
|
|
|
|
{
|
|
|
|
AddStep("enable options", () =>
|
|
|
|
{
|
2024-05-16 09:36:14 +08:00
|
|
|
var optionsButton = this.ChildrenOfType<ScreenFooterButton>().Last();
|
2023-09-05 15:44:22 +08:00
|
|
|
|
|
|
|
optionsButton.Enabled.Value = true;
|
|
|
|
optionsButton.TriggerClick();
|
|
|
|
});
|
|
|
|
}
|
|
|
|
|
2022-12-01 18:57:50 +08:00
|
|
|
[Test]
|
2022-12-01 23:29:52 +08:00
|
|
|
public void TestState()
|
2022-12-01 18:57:50 +08:00
|
|
|
{
|
2024-05-16 09:36:14 +08:00
|
|
|
AddToggleStep("set options enabled state", state => this.ChildrenOfType<ScreenFooterButton>().Last().Enabled.Value = state);
|
2022-12-01 23:29:52 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
[Test]
|
|
|
|
public void TestFooterRandom()
|
|
|
|
{
|
|
|
|
AddStep("press F2", () => InputManager.Key(Key.F2));
|
|
|
|
AddAssert("next random invoked", () => nextRandomCalled && !previousRandomCalled);
|
|
|
|
}
|
|
|
|
|
|
|
|
[Test]
|
|
|
|
public void TestFooterRandomViaMouse()
|
|
|
|
{
|
|
|
|
AddStep("click button", () =>
|
|
|
|
{
|
|
|
|
InputManager.MoveMouseTo(randomButton);
|
|
|
|
InputManager.Click(MouseButton.Left);
|
|
|
|
});
|
|
|
|
AddAssert("next random invoked", () => nextRandomCalled && !previousRandomCalled);
|
|
|
|
}
|
|
|
|
|
|
|
|
[Test]
|
|
|
|
public void TestFooterRewind()
|
|
|
|
{
|
|
|
|
AddStep("press Shift+F2", () =>
|
|
|
|
{
|
|
|
|
InputManager.PressKey(Key.LShift);
|
|
|
|
InputManager.PressKey(Key.F2);
|
|
|
|
InputManager.ReleaseKey(Key.F2);
|
|
|
|
InputManager.ReleaseKey(Key.LShift);
|
|
|
|
});
|
|
|
|
AddAssert("previous random invoked", () => previousRandomCalled && !nextRandomCalled);
|
|
|
|
}
|
|
|
|
|
|
|
|
[Test]
|
|
|
|
public void TestFooterRewindViaShiftMouseLeft()
|
|
|
|
{
|
|
|
|
AddStep("shift + click button", () =>
|
|
|
|
{
|
|
|
|
InputManager.PressKey(Key.LShift);
|
|
|
|
InputManager.MoveMouseTo(randomButton);
|
|
|
|
InputManager.Click(MouseButton.Left);
|
|
|
|
InputManager.ReleaseKey(Key.LShift);
|
|
|
|
});
|
|
|
|
AddAssert("previous random invoked", () => previousRandomCalled && !nextRandomCalled);
|
|
|
|
}
|
|
|
|
|
|
|
|
[Test]
|
|
|
|
public void TestFooterRewindViaMouseRight()
|
|
|
|
{
|
|
|
|
AddStep("right click button", () =>
|
|
|
|
{
|
|
|
|
InputManager.MoveMouseTo(randomButton);
|
|
|
|
InputManager.Click(MouseButton.Right);
|
|
|
|
});
|
|
|
|
AddAssert("previous random invoked", () => previousRandomCalled && !nextRandomCalled);
|
2022-12-01 18:57:50 +08:00
|
|
|
}
|
2022-12-03 01:44:21 +08:00
|
|
|
|
|
|
|
[Test]
|
|
|
|
public void TestOverlayPresent()
|
|
|
|
{
|
|
|
|
AddStep("Press F1", () =>
|
|
|
|
{
|
|
|
|
InputManager.MoveMouseTo(modsButton);
|
|
|
|
InputManager.Click(MouseButton.Left);
|
|
|
|
});
|
|
|
|
AddAssert("Overlay visible", () => overlay.State.Value == Visibility.Visible);
|
|
|
|
AddStep("Hide", () => overlay.Hide());
|
|
|
|
}
|
|
|
|
|
|
|
|
private partial class DummyOverlay : ShearedOverlayContainer
|
|
|
|
{
|
|
|
|
public DummyOverlay()
|
|
|
|
: base(OverlayColourScheme.Green)
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
[BackgroundDependencyLoader]
|
|
|
|
private void load()
|
|
|
|
{
|
|
|
|
Header.Title = "An overlay";
|
|
|
|
}
|
|
|
|
}
|
2022-12-01 18:57:50 +08:00
|
|
|
}
|
|
|
|
}
|