mirror of
https://github.com/ppy/osu
synced 2024-12-12 09:58:22 +00:00
Add test
This commit is contained in:
parent
b902457f8d
commit
39bd5e6478
@ -9,6 +9,7 @@ using NUnit.Framework;
|
|||||||
using osu.Framework.Allocation;
|
using osu.Framework.Allocation;
|
||||||
using osu.Framework.Bindables;
|
using osu.Framework.Bindables;
|
||||||
using osu.Framework.Graphics;
|
using osu.Framework.Graphics;
|
||||||
|
using osu.Framework.MathUtils;
|
||||||
using osu.Framework.Screens;
|
using osu.Framework.Screens;
|
||||||
using osu.Game.Rulesets.Mods;
|
using osu.Game.Rulesets.Mods;
|
||||||
using osu.Game.Rulesets.Osu;
|
using osu.Game.Rulesets.Osu;
|
||||||
@ -16,12 +17,13 @@ using osu.Game.Rulesets.Scoring;
|
|||||||
using osu.Game.Scoring;
|
using osu.Game.Scoring;
|
||||||
using osu.Game.Screens;
|
using osu.Game.Screens;
|
||||||
using osu.Game.Screens.Play;
|
using osu.Game.Screens.Play;
|
||||||
|
using osu.Game.Screens.Play.PlayerSettings;
|
||||||
|
|
||||||
namespace osu.Game.Tests.Visual.Gameplay
|
namespace osu.Game.Tests.Visual.Gameplay
|
||||||
{
|
{
|
||||||
public class TestScenePlayerLoader : ManualInputManagerTestScene
|
public class TestScenePlayerLoader : ManualInputManagerTestScene
|
||||||
{
|
{
|
||||||
private PlayerLoader loader;
|
private TestPlayerLoader loader;
|
||||||
private OsuScreenStack stack;
|
private OsuScreenStack stack;
|
||||||
|
|
||||||
[SetUp]
|
[SetUp]
|
||||||
@ -31,19 +33,28 @@ namespace osu.Game.Tests.Visual.Gameplay
|
|||||||
Beatmap.Value = CreateWorkingBeatmap(new OsuRuleset().RulesetInfo);
|
Beatmap.Value = CreateWorkingBeatmap(new OsuRuleset().RulesetInfo);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
[Test]
|
||||||
|
public void TestBlockLoadViaMouseMovement()
|
||||||
|
{
|
||||||
|
AddStep("load dummy beatmap", () => stack.Push(loader = new TestPlayerLoader(() => new TestPlayer(false, false))));
|
||||||
|
AddRepeatStep("move mouse", () => InputManager.MoveMouseTo(loader.VisualSettings.ScreenSpaceDrawQuad.TopLeft + (loader.VisualSettings.ScreenSpaceDrawQuad.BottomRight - loader.VisualSettings.ScreenSpaceDrawQuad.TopLeft) * RNG.NextSingle()), 20);
|
||||||
|
AddAssert("loader still active", () => loader.IsCurrentScreen());
|
||||||
|
AddUntilStep("loads after idle", () => !loader.IsCurrentScreen());
|
||||||
|
}
|
||||||
|
|
||||||
[Test]
|
[Test]
|
||||||
public void TestLoadContinuation()
|
public void TestLoadContinuation()
|
||||||
{
|
{
|
||||||
Player player = null;
|
Player player = null;
|
||||||
SlowLoadPlayer slowPlayer = null;
|
SlowLoadPlayer slowPlayer = null;
|
||||||
|
|
||||||
AddStep("load dummy beatmap", () => stack.Push(loader = new PlayerLoader(() => player = new TestPlayer(false, false))));
|
AddStep("load dummy beatmap", () => stack.Push(loader = new TestPlayerLoader(() => player = new TestPlayer(false, false))));
|
||||||
AddUntilStep("wait for current", () => loader.IsCurrentScreen());
|
AddUntilStep("wait for current", () => loader.IsCurrentScreen());
|
||||||
AddStep("mouse in centre", () => InputManager.MoveMouseTo(loader.ScreenSpaceDrawQuad.Centre));
|
AddStep("mouse in centre", () => InputManager.MoveMouseTo(loader.ScreenSpaceDrawQuad.Centre));
|
||||||
AddUntilStep("wait for player to be current", () => player.IsCurrentScreen());
|
AddUntilStep("wait for player to be current", () => player.IsCurrentScreen());
|
||||||
AddStep("load slow dummy beatmap", () =>
|
AddStep("load slow dummy beatmap", () =>
|
||||||
{
|
{
|
||||||
stack.Push(loader = new PlayerLoader(() => slowPlayer = new SlowLoadPlayer(false, false)));
|
stack.Push(loader = new TestPlayerLoader(() => slowPlayer = new SlowLoadPlayer(false, false)));
|
||||||
Scheduler.AddDelayed(() => slowPlayer.AllowLoad.Set(), 5000);
|
Scheduler.AddDelayed(() => slowPlayer.AllowLoad.Set(), 5000);
|
||||||
});
|
});
|
||||||
|
|
||||||
@ -61,7 +72,7 @@ namespace osu.Game.Tests.Visual.Gameplay
|
|||||||
AddStep("load player", () =>
|
AddStep("load player", () =>
|
||||||
{
|
{
|
||||||
Mods.Value = new[] { gameMod = new TestMod() };
|
Mods.Value = new[] { gameMod = new TestMod() };
|
||||||
stack.Push(loader = new PlayerLoader(() => player = new TestPlayer()));
|
stack.Push(loader = new TestPlayerLoader(() => player = new TestPlayer()));
|
||||||
});
|
});
|
||||||
|
|
||||||
AddUntilStep("wait for loader to become current", () => loader.IsCurrentScreen());
|
AddUntilStep("wait for loader to become current", () => loader.IsCurrentScreen());
|
||||||
@ -85,6 +96,16 @@ namespace osu.Game.Tests.Visual.Gameplay
|
|||||||
AddAssert("player mods applied", () => playerMod2.Applied);
|
AddAssert("player mods applied", () => playerMod2.Applied);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private class TestPlayerLoader : PlayerLoader
|
||||||
|
{
|
||||||
|
public new VisualSettings VisualSettings => base.VisualSettings;
|
||||||
|
|
||||||
|
public TestPlayerLoader(Func<Player> createPlayer)
|
||||||
|
: base(createPlayer)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
private class TestMod : Mod, IApplicableToScoreProcessor
|
private class TestMod : Mod, IApplicableToScoreProcessor
|
||||||
{
|
{
|
||||||
public override string Name => string.Empty;
|
public override string Name => string.Empty;
|
||||||
|
Loading…
Reference in New Issue
Block a user