Allow tinkering with cursor-related settings in resume overlay test scene

This commit is contained in:
Salman Ahmed 2023-11-06 18:35:46 +03:00
parent e12ee29a94
commit 073249dafb
1 changed files with 41 additions and 17 deletions

View File

@ -2,11 +2,14 @@
// See the LICENCE file in the repository root for full licence text.
using NUnit.Framework;
using osu.Framework.Allocation;
using osu.Framework.Graphics;
using osu.Framework.Graphics.Containers;
using osu.Framework.Graphics.Cursor;
using osu.Game.Configuration;
using osu.Game.Rulesets.Osu.UI;
using osu.Game.Screens.Play;
using osu.Game.Tests.Gameplay;
using osu.Game.Tests.Visual;
namespace osu.Game.Rulesets.Osu.Tests
@ -19,24 +22,37 @@ public partial class TestSceneResumeOverlay : OsuManualInputManagerTestScene
private bool resumeFired;
[SetUp]
public void SetUp() => Schedule(() =>
{
Child = osuInputManager = new ManualOsuInputManager(new OsuRuleset().RulesetInfo)
{
Children = new Drawable[]
{
cursor = new CursorContainer(),
resume = new OsuResumeOverlay
{
GameplayCursor = cursor
},
}
};
private OsuConfigManager localConfig = null!;
resumeFired = false;
resume.ResumeAction = () => resumeFired = true;
});
[Cached]
private GameplayState gameplayState;
public TestSceneResumeOverlay()
{
gameplayState = TestGameplayState.Create(new OsuRuleset());
}
[BackgroundDependencyLoader]
private void load()
{
Dependencies.Cache(localConfig = new OsuConfigManager(LocalStorage));
}
protected override void LoadComplete()
{
base.LoadComplete();
AddSliderStep("cursor size", 0.1f, 2f, 1f, v => localConfig.SetValue(OsuSetting.GameplayCursorSize, v));
AddSliderStep("circle size", 0f, 10f, 0f, val =>
{
gameplayState.Beatmap.Difficulty.CircleSize = val;
SetUp();
});
AddToggleStep("auto size", v => localConfig.SetValue(OsuSetting.AutoCursorSize, v));
}
[SetUp]
public void SetUp() => Schedule(loadContent);
[Test]
public void TestResume()
@ -53,6 +69,14 @@ public void TestResume()
AddAssert("dismissed", () => resumeFired && resume.State.Value == Visibility.Hidden);
}
private void loadContent()
{
Child = osuInputManager = new ManualOsuInputManager(new OsuRuleset().RulesetInfo) { Children = new Drawable[] { cursor = new CursorContainer(), resume = new OsuResumeOverlay { GameplayCursor = cursor }, } };
resumeFired = false;
resume.ResumeAction = () => resumeFired = true;
}
private partial class ManualOsuInputManager : OsuInputManager
{
public ManualOsuInputManager(RulesetInfo ruleset)