1
0
mirror of https://github.com/ppy/osu.git synced 2025-01-06 05:33:07 +08:00
osu-lazer/osu.Game.Tests/Visual/TestCasePlayerLoader.cs

86 lines
2.6 KiB
C#
Raw Normal View History

// 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.Threading;
using osu.Framework.Allocation;
2019-02-12 18:53:08 +08:00
using osu.Framework.Graphics;
2019-01-23 19:52:00 +08:00
using osu.Framework.Screens;
using osu.Game.Beatmaps;
using osu.Game.Screens;
2019-03-22 19:01:58 +08:00
using osu.Game.Screens.Menu;
using osu.Game.Screens.Play;
2019-03-22 19:01:58 +08:00
using osuTK;
namespace osu.Game.Tests.Visual
{
public class TestCasePlayerLoader : ManualInputManagerTestCase
{
private PlayerLoader loader;
2019-02-25 21:17:51 +08:00
private readonly ScreenStack stack;
2019-03-22 19:01:58 +08:00
[Cached]
private OsuLogo logo;
[Cached]
private BackgroundScreenStack backgroundStack;
public TestCasePlayerLoader()
{
2019-02-28 15:51:17 +08:00
InputManager.Add(backgroundStack = new BackgroundScreenStack { RelativeSizeAxes = Axes.Both });
InputManager.Add(stack = new ScreenStack { RelativeSizeAxes = Axes.Both });
2019-03-22 19:01:58 +08:00
InputManager.Add(logo = new OsuLogo());
}
[BackgroundDependencyLoader]
private void load(OsuGameBase game)
{
Beatmap.Value = new DummyWorkingBeatmap(game);
2019-03-22 19:01:58 +08:00
AddStep("Reset logo position", () => logo = new OsuLogo { Position = new Vector2(0, 0) });
2019-02-12 18:53:08 +08:00
AddStep("load dummy beatmap", () => stack.Push(loader = new PlayerLoader(() => new Player
{
AllowPause = false,
AllowLeadIn = false,
AllowResults = false,
})));
2019-03-19 16:24:26 +08:00
AddUntilStep("wait for current", () => loader.IsCurrentScreen());
2019-02-12 18:53:08 +08:00
AddStep("mouse in centre", () => InputManager.MoveMouseTo(loader.ScreenSpaceDrawQuad.Centre));
2019-03-19 16:24:26 +08:00
AddUntilStep("wait for no longer current", () => !loader.IsCurrentScreen());
2019-02-12 18:53:08 +08:00
AddStep("exit loader", () => loader.Exit());
2019-03-19 16:24:26 +08:00
AddUntilStep("wait for no longer alive", () => !loader.IsAlive);
2019-02-12 18:53:08 +08:00
AddStep("load slow dummy beatmap", () =>
{
2018-12-26 21:16:35 +08:00
SlowLoadPlayer slow = null;
2019-02-12 18:53:08 +08:00
stack.Push(loader = new PlayerLoader(() => slow = new SlowLoadPlayer
{
AllowPause = false,
AllowLeadIn = false,
AllowResults = false,
}));
});
2019-03-19 16:24:26 +08:00
AddUntilStep("wait for no longer current", () => !loader.IsCurrentScreen());
}
protected class SlowLoadPlayer : Player
{
public bool Ready;
[BackgroundDependencyLoader]
private void load()
{
while (!Ready)
Thread.Sleep(1);
}
}
}
}