Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove SelectedRoom from online play tests #31867

Merged
merged 6 commits into from
Mar 4, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,13 @@ namespace osu.Game.Tests.NonVisual.Multiplayer
[HeadlessTest]
public partial class StatefulMultiplayerClientTest : MultiplayerTestScene
{
public override void SetUpSteps()
{
base.SetUpSteps();
AddStep("join room", () => JoinRoom(CreateDefaultRoom()));
WaitForJoined();
}

[Test]
public void TestUserAddedOnJoin()
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ namespace osu.Game.Tests.Visual.Multiplayer
{
public partial class TestSceneDrawableRoomParticipantsList : OnlinePlayTestScene
{
private Room room = null!;
private DrawableRoomParticipantsList list = null!;

public override void SetUpSteps()
Expand All @@ -23,7 +24,7 @@ public override void SetUpSteps()

AddStep("create list", () =>
{
SelectedRoom.Value = new Room
room = new Room
{
Name = "test room",
Host = new APIUser
Expand All @@ -33,7 +34,7 @@ public override void SetUpSteps()
}
};

Child = list = new DrawableRoomParticipantsList(SelectedRoom.Value)
Child = list = new DrawableRoomParticipantsList(room)
{
Anchor = Anchor.Centre,
Origin = Anchor.Centre,
Expand Down Expand Up @@ -119,7 +120,7 @@ public void TestAddAndRemoveUsers()
AddAssert("4 circles displayed", () => list.ChildrenOfType<UpdateableAvatar>().Count() == 4);
AddAssert("46 hidden users", () => list.ChildrenOfType<DrawableRoomParticipantsList.HiddenUserCount>().Single().Count == 46);

AddStep("remove from end", () => removeUserAt(SelectedRoom.Value!.RecentParticipants.Count - 1));
AddStep("remove from end", () => removeUserAt(room.RecentParticipants.Count - 1));
AddAssert("4 circles displayed", () => list.ChildrenOfType<UpdateableAvatar>().Count() == 4);
AddAssert("45 hidden users", () => list.ChildrenOfType<DrawableRoomParticipantsList.HiddenUserCount>().Single().Count == 45);

Expand All @@ -138,18 +139,18 @@ public void TestAddAndRemoveUsers()

private void addUser(int id)
{
SelectedRoom.Value!.RecentParticipants = SelectedRoom.Value!.RecentParticipants.Append(new APIUser
room.RecentParticipants = room.RecentParticipants.Append(new APIUser
{
Id = id,
Username = $"User {id}"
}).ToArray();
SelectedRoom.Value!.ParticipantCount++;
room.ParticipantCount++;
}

private void removeUserAt(int index)
{
SelectedRoom.Value!.RecentParticipants = SelectedRoom.Value!.RecentParticipants.Where(u => !u.Equals(SelectedRoom.Value!.RecentParticipants[index])).ToArray();
SelectedRoom.Value!.ParticipantCount--;
room.RecentParticipants = room.RecentParticipants.Where(u => !u.Equals(room.RecentParticipants[index])).ToArray();
room.ParticipantCount--;
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ namespace osu.Game.Tests.Visual.Multiplayer
public partial class TestSceneLoungeRoomsContainer : OnlinePlayTestScene
{
private BindableList<Room> rooms = null!;
private IBindable<Room?> selectedRoom = null!;
private RoomListing container = null!;

public override void SetUpSteps()
Expand All @@ -30,6 +31,8 @@ public override void SetUpSteps()
AddStep("create container", () =>
{
rooms = new BindableList<Room>();
selectedRoom = new Bindable<Room?>();

Child = new PopoverContainer
{
RelativeSizeAxes = Axes.Both,
Expand All @@ -40,7 +43,7 @@ public override void SetUpSteps()
{
RelativeSizeAxes = Axes.Both,
Rooms = { BindTarget = rooms },
SelectedRoom = { BindTarget = SelectedRoom }
SelectedRoom = { BindTarget = selectedRoom }
}
};
});
Expand Down Expand Up @@ -195,7 +198,7 @@ public void TestPasswordProtectedRooms()
AddStep("add rooms", () => rooms.AddRange(GenerateRooms(3, withPassword: true)));
}

private bool checkRoomSelected(Room? room) => SelectedRoom.Value == room;
private bool checkRoomSelected(Room? room) => selectedRoom.Value == room;

private Room? getRoomInFlow(int index) =>
(container.ChildrenOfType<FillFlowContainer<DrawableLoungeRoom>>().First().FlowingChildren.ElementAt(index) as DrawableRoom)?.Room;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,15 +16,15 @@ namespace osu.Game.Tests.Visual.Multiplayer
{
public partial class TestSceneMatchBeatmapDetailArea : OnlinePlayTestScene
{
private Room room = null!;

public override void SetUpSteps()
{
base.SetUpSteps();

AddStep("create area", () =>
{
SelectedRoom.Value = new Room();

Child = new MatchBeatmapDetailArea(SelectedRoom.Value)
Child = new MatchBeatmapDetailArea(room = new Room())
{
Anchor = Anchor.Centre,
Origin = Anchor.Centre,
Expand All @@ -36,9 +36,9 @@ public override void SetUpSteps()

private void createNewItem()
{
SelectedRoom.Value!.Playlist = SelectedRoom.Value.Playlist.Append(new PlaylistItem(new TestBeatmap(new OsuRuleset().RulesetInfo).BeatmapInfo)
room.Playlist = room.Playlist.Append(new PlaylistItem(new TestBeatmap(new OsuRuleset().RulesetInfo).BeatmapInfo)
{
ID = SelectedRoom.Value.Playlist.Count,
ID = room.Playlist.Count,
RulesetID = new OsuRuleset().RulesetInfo.OnlineID,
RequiredMods = new[]
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -61,9 +61,7 @@ public override void SetUpSteps()

AddStep("create leaderboard", () =>
{
SelectedRoom.Value = new Room { RoomID = 3 };

Child = new MatchLeaderboard(SelectedRoom.Value)
Child = new MatchLeaderboard(new Room { RoomID = 3 })
{
Origin = Anchor.Centre,
Anchor = Anchor.Centre,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,9 @@ public override void SetUpSteps()
{
base.SetUpSteps();

AddStep("join room", () => JoinRoom(CreateDefaultRoom()));
WaitForJoined();

AddStep("reset", () =>
{
leaderboard?.RemoveAndDisposeImmediately();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
using osu.Game.Online.API.Requests.Responses;
using osu.Game.Online.Multiplayer;
using osu.Game.Online.Multiplayer.MatchTypes.TeamVersus;
using osu.Game.Online.Rooms;
using osu.Game.Rulesets.Osu.Mods;
using osu.Game.Rulesets.UI;
using osu.Game.Screens.OnlinePlay.Multiplayer.Spectate;
Expand All @@ -42,6 +43,7 @@ public partial class TestSceneMultiSpectatorScreen : MultiplayerTestScene
private BeatmapManager beatmapManager { get; set; } = null!;

private MultiSpectatorScreen spectatorScreen = null!;
private Room room = null!;

private readonly List<MultiplayerRoomUser> playingUsers = new List<MultiplayerRoomUser>();

Expand All @@ -63,6 +65,10 @@ public override void SetUpSteps()
base.SetUpSteps();

AddStep("clear playing users", () => playingUsers.Clear());

AddStep("create room", () => room = CreateDefaultRoom());
AddStep("join room", () => JoinRoom(room));
WaitForJoined();
}

[TestCase(1)]
Expand Down Expand Up @@ -456,7 +462,7 @@ private void loadSpectateScreen(bool waitForPlayerLoad = true, Action<WorkingBea

applyToBeatmap?.Invoke(Beatmap.Value);

LoadScreen(spectatorScreen = new MultiSpectatorScreen(SelectedRoom.Value!, playingUsers.ToArray()));
LoadScreen(spectatorScreen = new MultiSpectatorScreen(room, playingUsers.ToArray()));
});

AddUntilStep("wait for screen load", () => spectatorScreen.LoadState == LoadState.Loaded && (!waitForPlayerLoad || spectatorScreen.AllPlayersLoaded));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,11 +20,6 @@ public partial class TestSceneMultiplayerLoungeSubScreen : MultiplayerTestScene
{
private MultiplayerLoungeSubScreen loungeScreen = null!;

public TestSceneMultiplayerLoungeSubScreen()
: base(false)
{
}

public override void SetUpSteps()
{
base.SetUpSteps();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ public partial class TestSceneMultiplayerMatchSongSelect : MultiplayerTestScene

private TestMultiplayerMatchSongSelect songSelect = null!;
private Live<BeatmapSetInfo> importedBeatmapSet = null!;
private Room room = null!;

[Resolved]
private OsuConfigManager configManager { get; set; } = null!;
Expand All @@ -58,6 +59,15 @@ private void load(GameHost host, AudioManager audio)
Add(beatmapStore);
}

public override void SetUpSteps()
{
base.SetUpSteps();

AddStep("create room", () => room = CreateDefaultRoom());
AddStep("join room", () => JoinRoom(room));
WaitForJoined();
}

private void setUp()
{
AddStep("create song select", () =>
Expand All @@ -66,7 +76,7 @@ private void setUp()
Beatmap.SetDefault();
SelectedMods.SetDefault();

LoadScreen(songSelect = new TestMultiplayerMatchSongSelect(SelectedRoom.Value!));
LoadScreen(songSelect = new TestMultiplayerMatchSongSelect(room));
});

AddUntilStep("wait for present", () => songSelect.IsCurrentScreen() && songSelect.BeatmapSetsLoaded);
Expand Down Expand Up @@ -138,8 +148,8 @@ public void TestChangeRulesetImmediatelyAfterLoadComplete()

AddStep("create song select", () =>
{
SelectedRoom.Value!.Playlist.Single().RulesetID = 2;
songSelect = new TestMultiplayerMatchSongSelect(SelectedRoom.Value, SelectedRoom.Value.Playlist.Single());
room.Playlist.Single().RulesetID = 2;
songSelect = new TestMultiplayerMatchSongSelect(room, room.Playlist.Single());
songSelect.OnLoadComplete += _ => Ruleset.Value = new TaikoRuleset().RulesetInfo;
LoadScreen(songSelect);
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,11 +43,7 @@ public partial class TestSceneMultiplayerMatchSubScreen : MultiplayerTestScene
private MultiplayerMatchSubScreen screen = null!;
private BeatmapManager beatmaps = null!;
private BeatmapSetInfo importedSet = null!;

public TestSceneMultiplayerMatchSubScreen()
: base(false)
{
}
private Room room = null!;

[BackgroundDependencyLoader]
private void load(GameHost host, AudioManager audio)
Expand All @@ -66,8 +62,8 @@ public void SetupSteps()
{
AddStep("load match", () =>
{
SelectedRoom.Value = new Room { Name = "Test Room" };
LoadScreen(screen = new TestMultiplayerMatchSubScreen(SelectedRoom.Value!));
room = new Room { Name = "Test Room" };
LoadScreen(screen = new TestMultiplayerMatchSubScreen(room));
});

AddUntilStep("wait for load", () => screen.IsCurrentScreen());
Expand All @@ -78,7 +74,7 @@ public void TestCreatedRoom()
{
AddStep("add playlist item", () =>
{
SelectedRoom.Value!.Playlist =
room.Playlist =
[
new PlaylistItem(new TestBeatmap(new OsuRuleset().RulesetInfo).BeatmapInfo)
{
Expand All @@ -97,7 +93,7 @@ public void TestTaikoOnlyMod()
{
AddStep("add playlist item", () =>
{
SelectedRoom.Value!.Playlist =
room.Playlist =
[
new PlaylistItem(new TestBeatmap(new TaikoRuleset().RulesetInfo).BeatmapInfo)
{
Expand All @@ -122,7 +118,7 @@ public void TestSettingValidity()

AddStep("set playlist", () =>
{
SelectedRoom.Value!.Playlist =
room.Playlist =
[
new PlaylistItem(new TestBeatmap(new OsuRuleset().RulesetInfo).BeatmapInfo)
{
Expand All @@ -139,7 +135,7 @@ public void TestStartMatchWhileSpectating()
{
AddStep("set playlist", () =>
{
SelectedRoom.Value!.Playlist =
room.Playlist =
[
new PlaylistItem(beatmaps.GetWorkingBeatmap(importedSet.Beatmaps.First()).BeatmapInfo)
{
Expand Down Expand Up @@ -170,7 +166,7 @@ public void TestFreeModSelectionHasAllowedMods()
{
AddStep("add playlist item with allowed mod", () =>
{
SelectedRoom.Value!.Playlist =
room.Playlist =
[
new PlaylistItem(new TestBeatmap(new OsuRuleset().RulesetInfo).BeatmapInfo)
{
Expand Down Expand Up @@ -199,7 +195,7 @@ public void TestModSelectKeyWithAllowedMods()
{
AddStep("add playlist item with allowed mod", () =>
{
SelectedRoom.Value!.Playlist =
room.Playlist =
[
new PlaylistItem(new TestBeatmap(new OsuRuleset().RulesetInfo).BeatmapInfo)
{
Expand All @@ -223,7 +219,7 @@ public void TestModSelectKeyWithNoAllowedMods()
{
AddStep("add playlist item with no allowed mods", () =>
{
SelectedRoom.Value!.Playlist =
room.Playlist =
[
new PlaylistItem(new TestBeatmap(new OsuRuleset().RulesetInfo).BeatmapInfo)
{
Expand All @@ -246,7 +242,7 @@ public void TestNextPlaylistItemSelectedAfterCompletion()
{
AddStep("add two playlist items", () =>
{
SelectedRoom.Value!.Playlist =
room.Playlist =
[
new PlaylistItem(beatmaps.GetWorkingBeatmap(importedSet.Beatmaps.First()).BeatmapInfo)
{
Expand Down Expand Up @@ -285,7 +281,7 @@ public void TestModSelectOverlay()
{
AddStep("add playlist item", () =>
{
SelectedRoom.Value!.Playlist =
room.Playlist =
[
new PlaylistItem(new TestBeatmap(new OsuRuleset().RulesetInfo).BeatmapInfo)
{
Expand Down Expand Up @@ -322,7 +318,7 @@ public void TestChangeSettingsButtonVisibleForHost()
{
AddStep("add playlist item", () =>
{
SelectedRoom.Value!.Playlist =
room.Playlist =
[
new PlaylistItem(new TestBeatmap(new OsuRuleset().RulesetInfo).BeatmapInfo)
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,9 +28,12 @@ namespace osu.Game.Tests.Visual.Multiplayer
{
public partial class TestSceneMultiplayerParticipantsList : MultiplayerTestScene
{
[SetUpSteps]
public void SetupSteps()
public override void SetUpSteps()
{
base.SetUpSteps();

AddStep("join room", () => JoinRoom(CreateDefaultRoom()));
WaitForJoined();
createNewParticipantsList();
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,13 @@ public partial class TestSceneMultiplayerPlayer : MultiplayerTestScene
{
private MultiplayerPlayer player = null!;

public override void SetUpSteps()
{
base.SetUpSteps();
AddStep("join room", () => JoinRoom(CreateDefaultRoom()));
WaitForJoined();
}

[Test]
public void TestGameplay()
{
Expand Down
Loading
Loading