2018-04-20 16:30:27 +08:00
|
|
|
|
// Copyright (c) 2007-2018 ppy Pty Ltd <contact@ppy.sh>.
|
|
|
|
|
// Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE
|
|
|
|
|
|
2018-08-02 18:47:50 +08:00
|
|
|
|
using System.Threading;
|
2018-04-20 16:30:27 +08:00
|
|
|
|
using osu.Framework.Allocation;
|
|
|
|
|
using osu.Game.Beatmaps;
|
|
|
|
|
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;
|
|
|
|
|
|
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);
|
|
|
|
|
|
2018-08-02 18:47:50 +08:00
|
|
|
|
AddStep("load dummy beatmap", () => Add(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
|
|
|
|
|
|
|
|
|
AddStep("mouse in centre", () => InputManager.MoveMouseTo(loader.ScreenSpaceDrawQuad.Centre));
|
|
|
|
|
|
|
|
|
|
AddUntilStep(() => !loader.IsCurrentScreen, "wait for no longer current");
|
|
|
|
|
|
|
|
|
|
AddStep("load slow dummy beatmap", () =>
|
|
|
|
|
{
|
|
|
|
|
SlowLoadPlayer slow;
|
|
|
|
|
|
|
|
|
|
Add(loader = new PlayerLoader(slow = new SlowLoadPlayer
|
|
|
|
|
{
|
|
|
|
|
AllowPause = false,
|
|
|
|
|
AllowLeadIn = false,
|
|
|
|
|
AllowResults = false,
|
|
|
|
|
}));
|
|
|
|
|
|
|
|
|
|
Scheduler.AddDelayed(() => slow.Ready = true, 5000);
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
AddUntilStep(() => !loader.IsCurrentScreen, "wait for no longer current");
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
protected class SlowLoadPlayer : Player
|
|
|
|
|
{
|
|
|
|
|
public bool Ready;
|
|
|
|
|
|
|
|
|
|
[BackgroundDependencyLoader]
|
|
|
|
|
private void load()
|
|
|
|
|
{
|
|
|
|
|
while (!Ready)
|
|
|
|
|
Thread.Sleep(1);
|
|
|
|
|
}
|
2018-04-20 16:30:27 +08:00
|
|
|
|
}
|
|
|
|
|
}
|
2018-08-02 18:47:50 +08:00
|
|
|
|
|
2018-04-20 16:30:27 +08:00
|
|
|
|
}
|