1
0
mirror of https://github.com/ppy/osu.git synced 2025-01-28 02:02:53 +08:00

Add the ability for tests to alter the room and user states which during testing

This commit is contained in:
Dean Herbert 2021-08-09 16:44:50 +09:00
parent 0fa1f085df
commit 1e5d9003d3
3 changed files with 27 additions and 13 deletions

View File

@ -20,6 +20,7 @@ using osu.Game.Scoring;
using osu.Game.Screens.Play.HUD;
using osu.Game.Tests.Visual.OnlinePlay;
using osu.Game.Tests.Visual.Spectator;
using osu.Game.Users;
namespace osu.Game.Tests.Visual.Multiplayer
{
@ -53,7 +54,10 @@ namespace osu.Game.Tests.Visual.Multiplayer
var playable = Beatmap.Value.GetPlayableBeatmap(Ruleset.Value);
foreach (var user in users)
{
SpectatorClient.StartPlay(user, Beatmap.Value.BeatmapInfo.OnlineBeatmapID ?? 0);
OnlinePlayDependencies.Client.AddUser(new User { Id = user });
}
// Todo: This is REALLY bad.
Client.CurrentMatchPlayingUserIds.AddRange(users);

View File

@ -36,24 +36,29 @@ namespace osu.Game.Tests.Visual.Multiplayer
{
if (joinRoom)
{
var room = new Room
{
Name = { Value = "test name" },
Playlist =
{
new PlaylistItem
{
Beatmap = { Value = new TestBeatmap(Ruleset.Value).BeatmapInfo },
Ruleset = { Value = Ruleset.Value }
}
}
};
var room = CreateRoom();
RoomManager.CreateRoom(room);
SelectedRoom.Value = room;
}
});
protected virtual Room CreateRoom()
{
return new Room
{
Name = { Value = "test name" },
Playlist =
{
new PlaylistItem
{
Beatmap = { Value = new TestBeatmap(Ruleset.Value).BeatmapInfo },
Ruleset = { Value = Ruleset.Value }
}
}
};
}
public override void SetUpSteps()
{
base.SetUpSteps();

View File

@ -50,7 +50,12 @@ namespace osu.Game.Tests.Visual.Multiplayer
public void Disconnect() => isConnected.Value = false;
public void AddUser(User user) => ((IMultiplayerClient)this).UserJoined(new MultiplayerRoomUser(user.Id) { User = user });
public MultiplayerRoomUser AddUser(User user)
{
var roomUser = new MultiplayerRoomUser(user.Id) { User = user };
((IMultiplayerClient)this).UserJoined(roomUser);
return roomUser;
}
public void AddNullUser(int userId) => ((IMultiplayerClient)this).UserJoined(new MultiplayerRoomUser(userId));