mirror of
https://github.com/ppy/osu.git
synced 2025-01-13 17:13:06 +08:00
Always use imported beatmap in tests
This commit is contained in:
parent
5d02de29ca
commit
8bbcb9be8a
@ -36,13 +36,21 @@ namespace osu.Game.Tests.Visual.Gameplay
|
||||
|
||||
private int nextFrame;
|
||||
|
||||
private BeatmapSetInfo importedBeatmap;
|
||||
|
||||
private int importedBeatmapId;
|
||||
|
||||
public override void SetUpSteps()
|
||||
{
|
||||
base.SetUpSteps();
|
||||
|
||||
AddStep("reset sent frames", () => nextFrame = 0);
|
||||
|
||||
AddStep("import beatmap", () => ImportBeatmapTest.LoadOszIntoOsu(game, virtualTrack: true).Wait());
|
||||
AddStep("import beatmap", () =>
|
||||
{
|
||||
importedBeatmap = ImportBeatmapTest.LoadOszIntoOsu(game, virtualTrack: true).Result;
|
||||
importedBeatmapId = importedBeatmap.Beatmaps.First(b => b.RulesetID == 0).OnlineBeatmapID ?? -1;
|
||||
});
|
||||
|
||||
AddStep("add streaming client", () =>
|
||||
{
|
||||
@ -115,6 +123,7 @@ namespace osu.Game.Tests.Visual.Gameplay
|
||||
|
||||
start();
|
||||
sendFrames();
|
||||
|
||||
start();
|
||||
sendFrames();
|
||||
}
|
||||
@ -157,7 +166,7 @@ namespace osu.Game.Tests.Visual.Gameplay
|
||||
|
||||
private void waitForPlayer() => AddUntilStep("wait for player", () => Stack.CurrentScreen is Player);
|
||||
|
||||
private void start(int? beatmapId = null) => AddStep("start play", () => testSpectatorStreamingClient.StartPlay(beatmapId));
|
||||
private void start(int? beatmapId = null) => AddStep("start play", () => testSpectatorStreamingClient.StartPlay(beatmapId ?? importedBeatmapId));
|
||||
|
||||
private void checkPaused(bool state) =>
|
||||
AddAssert($"game is {(state ? "paused" : "playing")}", () => player.ChildrenOfType<DrawableRuleset>().First().IsPaused.Value == state);
|
||||
@ -179,18 +188,21 @@ namespace osu.Game.Tests.Visual.Gameplay
|
||||
|
||||
internal class TestSpectatorStreamingClient : SpectatorStreamingClient
|
||||
{
|
||||
[Resolved]
|
||||
private BeatmapManager beatmaps { get; set; }
|
||||
|
||||
public readonly User StreamingUser = new User { Id = 1234, Username = "Test user" };
|
||||
|
||||
public void StartPlay(int? beatmapId = null) => sendState(beatmapId);
|
||||
private int beatmapId;
|
||||
|
||||
public void EndPlay()
|
||||
public void StartPlay(int beatmapId)
|
||||
{
|
||||
this.beatmapId = beatmapId;
|
||||
sendState(beatmapId);
|
||||
}
|
||||
|
||||
public void EndPlay(int beatmapId)
|
||||
{
|
||||
((ISpectatorClient)this).UserFinishedPlaying((int)StreamingUser.Id, new SpectatorState
|
||||
{
|
||||
BeatmapID = beatmaps.GetAllUsableBeatmapSets().First().Beatmaps.First(b => b.RulesetID == 0).OnlineBeatmapID,
|
||||
BeatmapID = beatmapId,
|
||||
RulesetID = 0,
|
||||
});
|
||||
}
|
||||
@ -212,7 +224,7 @@ namespace osu.Game.Tests.Visual.Gameplay
|
||||
((ISpectatorClient)this).UserSentFrames((int)StreamingUser.Id, bundle);
|
||||
|
||||
if (!sentState)
|
||||
sendState();
|
||||
sendState(beatmapId);
|
||||
}
|
||||
|
||||
public override void WatchUser(int userId)
|
||||
@ -220,18 +232,18 @@ namespace osu.Game.Tests.Visual.Gameplay
|
||||
if (sentState)
|
||||
{
|
||||
// usually the server would do this.
|
||||
sendState();
|
||||
sendState(beatmapId);
|
||||
}
|
||||
|
||||
base.WatchUser(userId);
|
||||
}
|
||||
|
||||
private void sendState(int? beatmapId = null)
|
||||
private void sendState(int beatmapId)
|
||||
{
|
||||
sentState = true;
|
||||
((ISpectatorClient)this).UserBeganPlaying((int)StreamingUser.Id, new SpectatorState
|
||||
{
|
||||
BeatmapID = beatmapId ?? beatmaps.GetAllUsableBeatmapSets().First().Beatmaps.First(b => b.RulesetID == 0).OnlineBeatmapID,
|
||||
BeatmapID = beatmapId,
|
||||
RulesetID = 0,
|
||||
});
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user