mirror of
https://github.com/ppy/osu.git
synced 2025-01-14 00:42:55 +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 int nextFrame;
|
||||||
|
|
||||||
|
private BeatmapSetInfo importedBeatmap;
|
||||||
|
|
||||||
|
private int importedBeatmapId;
|
||||||
|
|
||||||
public override void SetUpSteps()
|
public override void SetUpSteps()
|
||||||
{
|
{
|
||||||
base.SetUpSteps();
|
base.SetUpSteps();
|
||||||
|
|
||||||
AddStep("reset sent frames", () => nextFrame = 0);
|
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", () =>
|
AddStep("add streaming client", () =>
|
||||||
{
|
{
|
||||||
@ -115,6 +123,7 @@ namespace osu.Game.Tests.Visual.Gameplay
|
|||||||
|
|
||||||
start();
|
start();
|
||||||
sendFrames();
|
sendFrames();
|
||||||
|
|
||||||
start();
|
start();
|
||||||
sendFrames();
|
sendFrames();
|
||||||
}
|
}
|
||||||
@ -157,7 +166,7 @@ namespace osu.Game.Tests.Visual.Gameplay
|
|||||||
|
|
||||||
private void waitForPlayer() => AddUntilStep("wait for player", () => Stack.CurrentScreen is Player);
|
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) =>
|
private void checkPaused(bool state) =>
|
||||||
AddAssert($"game is {(state ? "paused" : "playing")}", () => player.ChildrenOfType<DrawableRuleset>().First().IsPaused.Value == 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
|
internal class TestSpectatorStreamingClient : SpectatorStreamingClient
|
||||||
{
|
{
|
||||||
[Resolved]
|
|
||||||
private BeatmapManager beatmaps { get; set; }
|
|
||||||
|
|
||||||
public readonly User StreamingUser = new User { Id = 1234, Username = "Test user" };
|
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
|
((ISpectatorClient)this).UserFinishedPlaying((int)StreamingUser.Id, new SpectatorState
|
||||||
{
|
{
|
||||||
BeatmapID = beatmaps.GetAllUsableBeatmapSets().First().Beatmaps.First(b => b.RulesetID == 0).OnlineBeatmapID,
|
BeatmapID = beatmapId,
|
||||||
RulesetID = 0,
|
RulesetID = 0,
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
@ -212,7 +224,7 @@ namespace osu.Game.Tests.Visual.Gameplay
|
|||||||
((ISpectatorClient)this).UserSentFrames((int)StreamingUser.Id, bundle);
|
((ISpectatorClient)this).UserSentFrames((int)StreamingUser.Id, bundle);
|
||||||
|
|
||||||
if (!sentState)
|
if (!sentState)
|
||||||
sendState();
|
sendState(beatmapId);
|
||||||
}
|
}
|
||||||
|
|
||||||
public override void WatchUser(int userId)
|
public override void WatchUser(int userId)
|
||||||
@ -220,18 +232,18 @@ namespace osu.Game.Tests.Visual.Gameplay
|
|||||||
if (sentState)
|
if (sentState)
|
||||||
{
|
{
|
||||||
// usually the server would do this.
|
// usually the server would do this.
|
||||||
sendState();
|
sendState(beatmapId);
|
||||||
}
|
}
|
||||||
|
|
||||||
base.WatchUser(userId);
|
base.WatchUser(userId);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void sendState(int? beatmapId = null)
|
private void sendState(int beatmapId)
|
||||||
{
|
{
|
||||||
sentState = true;
|
sentState = true;
|
||||||
((ISpectatorClient)this).UserBeganPlaying((int)StreamingUser.Id, new SpectatorState
|
((ISpectatorClient)this).UserBeganPlaying((int)StreamingUser.Id, new SpectatorState
|
||||||
{
|
{
|
||||||
BeatmapID = beatmapId ?? beatmaps.GetAllUsableBeatmapSets().First().Beatmaps.First(b => b.RulesetID == 0).OnlineBeatmapID,
|
BeatmapID = beatmapId,
|
||||||
RulesetID = 0,
|
RulesetID = 0,
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user