mirror of
https://github.com/ppy/osu.git
synced 2025-01-26 19:32:55 +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.Framework.Testing;
|
||||||
using osu.Game.Beatmaps;
|
using osu.Game.Beatmaps;
|
||||||
using osu.Game.Configuration;
|
using osu.Game.Configuration;
|
||||||
|
using osu.Game.Online.API;
|
||||||
using osu.Game.Online.API.Requests.Responses;
|
using osu.Game.Online.API.Requests.Responses;
|
||||||
using osu.Game.Online.Multiplayer;
|
using osu.Game.Online.Multiplayer;
|
||||||
using osu.Game.Online.Multiplayer.MatchTypes.TeamVersus;
|
using osu.Game.Online.Multiplayer.MatchTypes.TeamVersus;
|
||||||
|
using osu.Game.Rulesets.Osu.Mods;
|
||||||
using osu.Game.Rulesets.UI;
|
using osu.Game.Rulesets.UI;
|
||||||
using osu.Game.Screens.OnlinePlay.Multiplayer.Spectate;
|
using osu.Game.Screens.OnlinePlay.Multiplayer.Spectate;
|
||||||
using osu.Game.Screens.Play;
|
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);
|
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]
|
[Test]
|
||||||
public void TestPlayersLeaveWhileSpectating()
|
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 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", () =>
|
AddStep("start play", () =>
|
||||||
{
|
{
|
||||||
@ -429,10 +443,11 @@ namespace osu.Game.Tests.Visual.Multiplayer
|
|||||||
var user = new MultiplayerRoomUser(id)
|
var user = new MultiplayerRoomUser(id)
|
||||||
{
|
{
|
||||||
User = new APIUser { Id = id },
|
User = new APIUser { Id = id },
|
||||||
|
Mods = mods ?? Array.Empty<APIMod>(),
|
||||||
};
|
};
|
||||||
|
|
||||||
OnlinePlayDependencies.MultiplayerClient.AddUser(user.User, true);
|
OnlinePlayDependencies.MultiplayerClient.AddUser(user, true);
|
||||||
SpectatorClient.SendStartPlay(id, beatmapId ?? importedBeatmapId);
|
SpectatorClient.SendStartPlay(id, beatmapId ?? importedBeatmapId, mods);
|
||||||
|
|
||||||
playingUsers.Add(user);
|
playingUsers.Add(user);
|
||||||
}
|
}
|
||||||
|
@ -81,13 +81,14 @@ namespace osu.Game.Tests.Visual.Multiplayer
|
|||||||
public void Disconnect() => isConnected.Value = false;
|
public void Disconnect() => isConnected.Value = false;
|
||||||
|
|
||||||
public MultiplayerRoomUser AddUser(APIUser user, bool markAsPlaying = false)
|
public MultiplayerRoomUser AddUser(APIUser user, bool markAsPlaying = false)
|
||||||
{
|
=> AddUser(new MultiplayerRoomUser(user.Id) { User = user }, markAsPlaying);
|
||||||
var roomUser = new MultiplayerRoomUser(user.Id) { User = user };
|
|
||||||
|
|
||||||
|
public MultiplayerRoomUser AddUser(MultiplayerRoomUser roomUser, bool markAsPlaying = false)
|
||||||
|
{
|
||||||
addUser(roomUser);
|
addUser(roomUser);
|
||||||
|
|
||||||
if (markAsPlaying)
|
if (markAsPlaying)
|
||||||
PlayingUserIds.Add(user.Id);
|
PlayingUserIds.Add(roomUser.UserID);
|
||||||
|
|
||||||
return roomUser;
|
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, ReplayFrame> lastReceivedUserFrames = new Dictionary<int, ReplayFrame>();
|
||||||
|
|
||||||
private readonly Dictionary<int, int> userBeatmapDictionary = new Dictionary<int, int>();
|
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>();
|
private readonly Dictionary<int, int> userNextFrameDictionary = new Dictionary<int, int>();
|
||||||
|
|
||||||
[Resolved]
|
[Resolved]
|
||||||
@ -52,9 +53,11 @@ namespace osu.Game.Tests.Visual.Spectator
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="userId">The user to start play for.</param>
|
/// <param name="userId">The user to start play for.</param>
|
||||||
/// <param name="beatmapId">The playing beatmap id.</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;
|
userBeatmapDictionary[userId] = beatmapId;
|
||||||
|
userModsDictionary[userId] = mods ?? Array.Empty<APIMod>();
|
||||||
userNextFrameDictionary[userId] = 0;
|
userNextFrameDictionary[userId] = 0;
|
||||||
sendPlayingState(userId);
|
sendPlayingState(userId);
|
||||||
}
|
}
|
||||||
@ -73,10 +76,12 @@ namespace osu.Game.Tests.Visual.Spectator
|
|||||||
{
|
{
|
||||||
BeatmapID = userBeatmapDictionary[userId],
|
BeatmapID = userBeatmapDictionary[userId],
|
||||||
RulesetID = 0,
|
RulesetID = 0,
|
||||||
|
Mods = userModsDictionary[userId],
|
||||||
State = state
|
State = state
|
||||||
});
|
});
|
||||||
|
|
||||||
userBeatmapDictionary.Remove(userId);
|
userBeatmapDictionary.Remove(userId);
|
||||||
|
userModsDictionary.Remove(userId);
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
@ -158,6 +163,7 @@ namespace osu.Game.Tests.Visual.Spectator
|
|||||||
{
|
{
|
||||||
BeatmapID = userBeatmapDictionary[userId],
|
BeatmapID = userBeatmapDictionary[userId],
|
||||||
RulesetID = 0,
|
RulesetID = 0,
|
||||||
|
Mods = userModsDictionary[userId],
|
||||||
State = SpectatedUserState.Playing
|
State = SpectatedUserState.Playing
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user