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

Add failing test

This commit is contained in:
smoogipoo 2021-04-22 23:22:44 +09:00
parent 93b53f54fa
commit 0ee73b8e53
2 changed files with 34 additions and 3 deletions

View File

@ -41,6 +41,32 @@ namespace osu.Game.Tests.NonVisual.Multiplayer
checkPlayingUserCount(0); checkPlayingUserCount(0);
} }
[Test]
public void TestPlayingUsersUpdatedOnJoin()
{
AddStep("leave room", () => Client.LeaveRoom());
AddUntilStep("wait for room part", () => Client.Room == null);
AddStep("create room initially in gameplay", () =>
{
Room.RoomID.Value = null;
Client.RoomSetupAction = room =>
{
room.State = MultiplayerRoomState.Playing;
room.Users.Add(new MultiplayerRoomUser(55)
{
User = new User { Id = 55 },
State = MultiplayerUserState.Playing
});
};
RoomManager.CreateRoom(Room);
});
AddUntilStep("wait for room join", () => Client.Room != null);
checkPlayingUserCount(1);
}
private void checkPlayingUserCount(int expectedCount) private void checkPlayingUserCount(int expectedCount)
=> AddAssert($"{"user".ToQuantity(expectedCount)} playing", () => Client.CurrentMatchPlayingUserIds.Count == expectedCount); => AddAssert($"{"user".ToQuantity(expectedCount)} playing", () => Client.CurrentMatchPlayingUserIds.Count == expectedCount);

View File

@ -25,6 +25,8 @@ namespace osu.Game.Tests.Visual.Multiplayer
public override IBindable<bool> IsConnected => isConnected; public override IBindable<bool> IsConnected => isConnected;
private readonly Bindable<bool> isConnected = new Bindable<bool>(true); private readonly Bindable<bool> isConnected = new Bindable<bool>(true);
public Action<MultiplayerRoom>? RoomSetupAction;
[Resolved] [Resolved]
private IAPIProvider api { get; set; } = null!; private IAPIProvider api { get; set; } = null!;
@ -112,7 +114,7 @@ namespace osu.Game.Tests.Visual.Multiplayer
{ {
var apiRoom = roomManager.Rooms.Single(r => r.RoomID.Value == roomId); var apiRoom = roomManager.Rooms.Single(r => r.RoomID.Value == roomId);
var user = new MultiplayerRoomUser(api.LocalUser.Value.Id) var localUser = new MultiplayerRoomUser(api.LocalUser.Value.Id)
{ {
User = api.LocalUser.Value User = api.LocalUser.Value
}; };
@ -129,10 +131,13 @@ namespace osu.Game.Tests.Visual.Multiplayer
AllowedMods = apiRoom.Playlist.Last().AllowedMods.Select(m => new APIMod(m)).ToArray(), AllowedMods = apiRoom.Playlist.Last().AllowedMods.Select(m => new APIMod(m)).ToArray(),
PlaylistItemId = apiRoom.Playlist.Last().ID PlaylistItemId = apiRoom.Playlist.Last().ID
}, },
Users = { user }, Users = { localUser },
Host = user Host = localUser
}; };
RoomSetupAction?.Invoke(room);
RoomSetupAction = null;
return Task.FromResult(room); return Task.FromResult(room);
} }