mirror of
https://github.com/ppy/osu.git
synced 2025-01-12 18:23:04 +08:00
Add test coverage of track rate adjusting during multi spectator
This commit is contained in:
parent
e6b449fe0b
commit
770c1ade2f
@ -13,9 +13,11 @@ using osu.Framework.Graphics.Containers;
|
||||
using osu.Framework.Testing;
|
||||
using osu.Game.Beatmaps;
|
||||
using osu.Game.Configuration;
|
||||
using osu.Game.Online.API;
|
||||
using osu.Game.Online.API.Requests.Responses;
|
||||
using osu.Game.Online.Multiplayer;
|
||||
using osu.Game.Online.Multiplayer.MatchTypes.TeamVersus;
|
||||
using osu.Game.Rulesets.Osu.Mods;
|
||||
using osu.Game.Rulesets.UI;
|
||||
using osu.Game.Screens.OnlinePlay.Multiplayer.Spectate;
|
||||
using osu.Game.Screens.Play;
|
||||
@ -332,6 +334,18 @@ namespace osu.Game.Tests.Visual.Multiplayer
|
||||
AddUntilStep("player 2 playing from correct point in time", () => getPlayer(PLAYER_2_ID).ChildrenOfType<DrawableRuleset>().Single().FrameStableClock.CurrentTime > 30000);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void TestGameplayRateAdjust()
|
||||
{
|
||||
start(getPlayerIds(4), mods: new[] { new APIMod(new OsuModDoubleTime()) });
|
||||
|
||||
loadSpectateScreen();
|
||||
|
||||
sendFrames(getPlayerIds(4), 300);
|
||||
|
||||
AddUntilStep("wait for correct track speed", () => Beatmap.Value.Track.Rate, () => Is.EqualTo(1.5));
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void TestPlayersLeaveWhileSpectating()
|
||||
{
|
||||
@ -420,7 +434,7 @@ namespace osu.Game.Tests.Visual.Multiplayer
|
||||
|
||||
private void start(int userId, int? beatmapId = null) => start(new[] { userId }, beatmapId);
|
||||
|
||||
private void start(int[] userIds, int? beatmapId = null)
|
||||
private void start(int[] userIds, int? beatmapId = null, APIMod[]? mods = null)
|
||||
{
|
||||
AddStep("start play", () =>
|
||||
{
|
||||
@ -429,10 +443,11 @@ namespace osu.Game.Tests.Visual.Multiplayer
|
||||
var user = new MultiplayerRoomUser(id)
|
||||
{
|
||||
User = new APIUser { Id = id },
|
||||
Mods = mods ?? Array.Empty<APIMod>(),
|
||||
};
|
||||
|
||||
OnlinePlayDependencies.MultiplayerClient.AddUser(user.User, true);
|
||||
SpectatorClient.SendStartPlay(id, beatmapId ?? importedBeatmapId);
|
||||
OnlinePlayDependencies.MultiplayerClient.AddUser(user, true);
|
||||
SpectatorClient.SendStartPlay(id, beatmapId ?? importedBeatmapId, mods);
|
||||
|
||||
playingUsers.Add(user);
|
||||
}
|
||||
|
@ -81,13 +81,14 @@ namespace osu.Game.Tests.Visual.Multiplayer
|
||||
public void Disconnect() => isConnected.Value = false;
|
||||
|
||||
public MultiplayerRoomUser AddUser(APIUser user, bool markAsPlaying = false)
|
||||
{
|
||||
var roomUser = new MultiplayerRoomUser(user.Id) { User = user };
|
||||
=> AddUser(new MultiplayerRoomUser(user.Id) { User = user }, markAsPlaying);
|
||||
|
||||
public MultiplayerRoomUser AddUser(MultiplayerRoomUser roomUser, bool markAsPlaying = false)
|
||||
{
|
||||
addUser(roomUser);
|
||||
|
||||
if (markAsPlaying)
|
||||
PlayingUserIds.Add(user.Id);
|
||||
PlayingUserIds.Add(roomUser.UserID);
|
||||
|
||||
return roomUser;
|
||||
}
|
||||
|
@ -37,6 +37,7 @@ namespace osu.Game.Tests.Visual.Spectator
|
||||
private readonly Dictionary<int, ReplayFrame> lastReceivedUserFrames = new Dictionary<int, ReplayFrame>();
|
||||
|
||||
private readonly Dictionary<int, int> userBeatmapDictionary = new Dictionary<int, int>();
|
||||
private readonly Dictionary<int, APIMod[]> userModsDictionary = new Dictionary<int, APIMod[]>();
|
||||
private readonly Dictionary<int, int> userNextFrameDictionary = new Dictionary<int, int>();
|
||||
|
||||
[Resolved]
|
||||
@ -52,9 +53,11 @@ namespace osu.Game.Tests.Visual.Spectator
|
||||
/// </summary>
|
||||
/// <param name="userId">The user to start play for.</param>
|
||||
/// <param name="beatmapId">The playing beatmap id.</param>
|
||||
public void SendStartPlay(int userId, int beatmapId)
|
||||
/// <param name="mods">The mods the user has applied.</param>
|
||||
public void SendStartPlay(int userId, int beatmapId, APIMod[]? mods = null)
|
||||
{
|
||||
userBeatmapDictionary[userId] = beatmapId;
|
||||
userModsDictionary[userId] = mods ?? Array.Empty<APIMod>();
|
||||
userNextFrameDictionary[userId] = 0;
|
||||
sendPlayingState(userId);
|
||||
}
|
||||
@ -73,10 +76,12 @@ namespace osu.Game.Tests.Visual.Spectator
|
||||
{
|
||||
BeatmapID = userBeatmapDictionary[userId],
|
||||
RulesetID = 0,
|
||||
Mods = userModsDictionary[userId],
|
||||
State = state
|
||||
});
|
||||
|
||||
userBeatmapDictionary.Remove(userId);
|
||||
userModsDictionary.Remove(userId);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@ -158,6 +163,7 @@ namespace osu.Game.Tests.Visual.Spectator
|
||||
{
|
||||
BeatmapID = userBeatmapDictionary[userId],
|
||||
RulesetID = 0,
|
||||
Mods = userModsDictionary[userId],
|
||||
State = SpectatedUserState.Playing
|
||||
});
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user