2019-01-24 16:43:03 +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.
|
2018-04-20 16:30:27 +08:00
|
|
|
|
|
2018-08-02 18:47:50 +08:00
|
|
|
|
using System.Threading;
|
2018-04-20 16:30:27 +08:00
|
|
|
|
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;
|
2018-04-20 16:30:27 +08:00
|
|
|
|
using osu.Game.Beatmaps;
|
2019-02-25 21:05:49 +08:00
|
|
|
|
using osu.Game.Screens;
|
2018-04-20 16:30:27 +08:00
|
|
|
|
using osu.Game.Screens.Play;
|
|
|
|
|
|
|
|
|
|
namespace osu.Game.Tests.Visual
|
|
|
|
|
{
|
2018-08-02 18:47:50 +08:00
|
|
|
|
public class TestCasePlayerLoader : ManualInputManagerTestCase
|
2018-04-20 16:30:27 +08:00
|
|
|
|
{
|
2018-08-02 18:47:50 +08:00
|
|
|
|
private PlayerLoader loader;
|
2019-02-25 21:17:51 +08:00
|
|
|
|
private readonly ScreenStack stack;
|
2018-08-02 18:47:50 +08:00
|
|
|
|
|
2019-02-25 21:05:49 +08:00
|
|
|
|
[Cached]
|
|
|
|
|
private BackgroundScreenStack backgroundStack;
|
|
|
|
|
|
|
|
|
|
public TestCasePlayerLoader()
|
|
|
|
|
{
|
2019-02-28 15:51:17 +08:00
|
|
|
|
InputManager.Add(backgroundStack = new BackgroundScreenStack { RelativeSizeAxes = Axes.Both });
|
2019-02-25 21:05:49 +08:00
|
|
|
|
InputManager.Add(stack = new ScreenStack { RelativeSizeAxes = Axes.Both });
|
|
|
|
|
}
|
|
|
|
|
|
2018-04-20 16:30:27 +08:00
|
|
|
|
[BackgroundDependencyLoader]
|
|
|
|
|
private void load(OsuGameBase game)
|
|
|
|
|
{
|
2018-05-23 16:37:39 +08:00
|
|
|
|
Beatmap.Value = new DummyWorkingBeatmap(game);
|
|
|
|
|
|
2019-02-12 18:53:08 +08:00
|
|
|
|
AddStep("load dummy beatmap", () => stack.Push(loader = new PlayerLoader(() => new Player
|
2018-04-20 16:30:27 +08:00
|
|
|
|
{
|
|
|
|
|
AllowPause = false,
|
|
|
|
|
AllowLeadIn = false,
|
|
|
|
|
AllowResults = false,
|
|
|
|
|
})));
|
2018-08-02 18:47:50 +08:00
|
|
|
|
|
2019-02-12 18:53:08 +08:00
|
|
|
|
AddUntilStep(() => loader.IsCurrentScreen(), "wait for current");
|
|
|
|
|
|
2018-08-02 18:47:50 +08:00
|
|
|
|
AddStep("mouse in centre", () => InputManager.MoveMouseTo(loader.ScreenSpaceDrawQuad.Centre));
|
|
|
|
|
|
2019-01-23 19:52:00 +08:00
|
|
|
|
AddUntilStep(() => !loader.IsCurrentScreen(), "wait for no longer current");
|
2018-08-02 18:47:50 +08:00
|
|
|
|
|
2019-02-12 18:53:08 +08:00
|
|
|
|
AddStep("exit loader", () => loader.Exit());
|
|
|
|
|
|
|
|
|
|
AddUntilStep(() => !loader.IsAlive, "wait for no longer alive");
|
|
|
|
|
|
2018-08-02 18:47:50 +08:00
|
|
|
|
AddStep("load slow dummy beatmap", () =>
|
|
|
|
|
{
|
2018-12-26 21:16:35 +08:00
|
|
|
|
SlowLoadPlayer slow = null;
|
2018-08-02 18:47:50 +08:00
|
|
|
|
|
2019-02-12 18:53:08 +08:00
|
|
|
|
stack.Push(loader = new PlayerLoader(() => slow = new SlowLoadPlayer
|
2018-08-02 18:47:50 +08:00
|
|
|
|
{
|
|
|
|
|
AllowPause = false,
|
|
|
|
|
AllowLeadIn = false,
|
|
|
|
|
AllowResults = false,
|
|
|
|
|
}));
|
|
|
|
|
|
|
|
|
|
Scheduler.AddDelayed(() => slow.Ready = true, 5000);
|
|
|
|
|
});
|
|
|
|
|
|
2019-01-23 19:52:00 +08:00
|
|
|
|
AddUntilStep(() => !loader.IsCurrentScreen(), "wait for no longer current");
|
2018-08-02 18:47:50 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
protected class SlowLoadPlayer : Player
|
|
|
|
|
{
|
|
|
|
|
public bool Ready;
|
|
|
|
|
|
|
|
|
|
[BackgroundDependencyLoader]
|
|
|
|
|
private void load()
|
|
|
|
|
{
|
|
|
|
|
while (!Ready)
|
|
|
|
|
Thread.Sleep(1);
|
|
|
|
|
}
|
2018-04-20 16:30:27 +08:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|