mirror of
https://github.com/ppy/osu.git
synced 2025-01-12 20:22:55 +08:00
Add failing test
This commit is contained in:
parent
93b53f54fa
commit
0ee73b8e53
@ -41,6 +41,32 @@ namespace osu.Game.Tests.NonVisual.Multiplayer
|
||||
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)
|
||||
=> AddAssert($"{"user".ToQuantity(expectedCount)} playing", () => Client.CurrentMatchPlayingUserIds.Count == expectedCount);
|
||||
|
||||
|
@ -25,6 +25,8 @@ namespace osu.Game.Tests.Visual.Multiplayer
|
||||
public override IBindable<bool> IsConnected => isConnected;
|
||||
private readonly Bindable<bool> isConnected = new Bindable<bool>(true);
|
||||
|
||||
public Action<MultiplayerRoom>? RoomSetupAction;
|
||||
|
||||
[Resolved]
|
||||
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 user = new MultiplayerRoomUser(api.LocalUser.Value.Id)
|
||||
var localUser = new MultiplayerRoomUser(api.LocalUser.Value.Id)
|
||||
{
|
||||
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(),
|
||||
PlaylistItemId = apiRoom.Playlist.Last().ID
|
||||
},
|
||||
Users = { user },
|
||||
Host = user
|
||||
Users = { localUser },
|
||||
Host = localUser
|
||||
};
|
||||
|
||||
RoomSetupAction?.Invoke(room);
|
||||
RoomSetupAction = null;
|
||||
|
||||
return Task.FromResult(room);
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user