diff --git a/osu.Game.Tests/Visual/Multiplayer/TestSceneMultiplayer.cs b/osu.Game.Tests/Visual/Multiplayer/TestSceneMultiplayer.cs
index e18fa96218..7c151ffac3 100644
--- a/osu.Game.Tests/Visual/Multiplayer/TestSceneMultiplayer.cs
+++ b/osu.Game.Tests/Visual/Multiplayer/TestSceneMultiplayer.cs
@@ -140,7 +140,7 @@ namespace osu.Game.Tests.Visual.Multiplayer
{
AddStep("create room", () =>
{
- API.Queue(new CreateRoomRequest(new Room
+ multiplayerScreen.RoomManager.AddRoom(new Room
{
Name = { Value = "Test Room" },
Playlist =
@@ -151,7 +151,7 @@ namespace osu.Game.Tests.Visual.Multiplayer
Ruleset = { Value = new OsuRuleset().RulesetInfo },
}
}
- }));
+ });
});
AddStep("refresh rooms", () => multiplayerScreen.RoomManager.Filter.Value = new FilterCriteria());
@@ -187,7 +187,7 @@ namespace osu.Game.Tests.Visual.Multiplayer
{
AddStep("create room", () =>
{
- API.Queue(new CreateRoomRequest(new Room
+ multiplayerScreen.RoomManager.AddRoom(new Room
{
Name = { Value = "Test Room" },
Password = { Value = "password" },
@@ -199,7 +199,7 @@ namespace osu.Game.Tests.Visual.Multiplayer
Ruleset = { Value = new OsuRuleset().RulesetInfo },
}
}
- }));
+ });
});
AddStep("refresh rooms", () => multiplayerScreen.RoomManager.Filter.Value = new FilterCriteria());
@@ -433,9 +433,9 @@ namespace osu.Game.Tests.Visual.Multiplayer
private class TestMultiplayer : Screens.OnlinePlay.Multiplayer.Multiplayer
{
- public new TestMultiplayerRoomManager RoomManager { get; private set; }
+ public new TestRequestHandlingMultiplayerRoomManager RoomManager { get; private set; }
- protected override RoomManager CreateRoomManager() => RoomManager = new TestMultiplayerRoomManager();
+ protected override RoomManager CreateRoomManager() => RoomManager = new TestRequestHandlingMultiplayerRoomManager();
}
}
}
diff --git a/osu.Game.Tests/Visual/Navigation/TestSceneScreenNavigation.cs b/osu.Game.Tests/Visual/Navigation/TestSceneScreenNavigation.cs
index 52401d32e5..7188a4e57f 100644
--- a/osu.Game.Tests/Visual/Navigation/TestSceneScreenNavigation.cs
+++ b/osu.Game.Tests/Visual/Navigation/TestSceneScreenNavigation.cs
@@ -353,10 +353,10 @@ namespace osu.Game.Tests.Visual.Navigation
public TestMultiplayer()
{
- Client = new TestMultiplayerClient((TestMultiplayerRoomManager)RoomManager);
+ Client = new TestMultiplayerClient((TestRequestHandlingMultiplayerRoomManager)RoomManager);
}
- protected override RoomManager CreateRoomManager() => new TestMultiplayerRoomManager();
+ protected override RoomManager CreateRoomManager() => new TestRequestHandlingMultiplayerRoomManager();
}
}
}
diff --git a/osu.Game/Tests/Visual/Multiplayer/IMultiplayerTestSceneDependencies.cs b/osu.Game/Tests/Visual/Multiplayer/IMultiplayerTestSceneDependencies.cs
index 204c189591..3362ebbbd6 100644
--- a/osu.Game/Tests/Visual/Multiplayer/IMultiplayerTestSceneDependencies.cs
+++ b/osu.Game/Tests/Visual/Multiplayer/IMultiplayerTestSceneDependencies.cs
@@ -22,7 +22,7 @@ namespace osu.Game.Tests.Visual.Multiplayer
///
/// The cached .
///
- new TestMultiplayerRoomManager RoomManager { get; }
+ new TestRequestHandlingMultiplayerRoomManager RoomManager { get; }
///
/// The cached .
diff --git a/osu.Game/Tests/Visual/Multiplayer/MultiplayerTestScene.cs b/osu.Game/Tests/Visual/Multiplayer/MultiplayerTestScene.cs
index b7d3793ab1..42345b7266 100644
--- a/osu.Game/Tests/Visual/Multiplayer/MultiplayerTestScene.cs
+++ b/osu.Game/Tests/Visual/Multiplayer/MultiplayerTestScene.cs
@@ -18,7 +18,7 @@ namespace osu.Game.Tests.Visual.Multiplayer
public const int PLAYER_2_ID = 56;
public TestMultiplayerClient Client => OnlinePlayDependencies.Client;
- public new TestMultiplayerRoomManager RoomManager => OnlinePlayDependencies.RoomManager;
+ public new TestRequestHandlingMultiplayerRoomManager RoomManager => OnlinePlayDependencies.RoomManager;
public TestUserLookupCache LookupCache => OnlinePlayDependencies?.LookupCache;
public TestSpectatorClient SpectatorClient => OnlinePlayDependencies?.SpectatorClient;
diff --git a/osu.Game/Tests/Visual/Multiplayer/MultiplayerTestSceneDependencies.cs b/osu.Game/Tests/Visual/Multiplayer/MultiplayerTestSceneDependencies.cs
index a2b0b066a7..2e13fb6a56 100644
--- a/osu.Game/Tests/Visual/Multiplayer/MultiplayerTestSceneDependencies.cs
+++ b/osu.Game/Tests/Visual/Multiplayer/MultiplayerTestSceneDependencies.cs
@@ -18,7 +18,7 @@ namespace osu.Game.Tests.Visual.Multiplayer
public TestMultiplayerClient Client { get; }
public TestUserLookupCache LookupCache { get; }
public TestSpectatorClient SpectatorClient { get; }
- public new TestMultiplayerRoomManager RoomManager => (TestMultiplayerRoomManager)base.RoomManager;
+ public new TestRequestHandlingMultiplayerRoomManager RoomManager => (TestRequestHandlingMultiplayerRoomManager)base.RoomManager;
public MultiplayerTestSceneDependencies()
{
@@ -31,7 +31,7 @@ namespace osu.Game.Tests.Visual.Multiplayer
CacheAs(SpectatorClient);
}
- protected override IRoomManager CreateRoomManager() => new TestMultiplayerRoomManager();
+ protected override IRoomManager CreateRoomManager() => new TestRequestHandlingMultiplayerRoomManager();
protected virtual TestSpectatorClient CreateSpectatorClient() => new TestSpectatorClient();
}
diff --git a/osu.Game/Tests/Visual/Multiplayer/TestMultiplayerClient.cs b/osu.Game/Tests/Visual/Multiplayer/TestMultiplayerClient.cs
index 1528ed0bc8..3349d670c8 100644
--- a/osu.Game/Tests/Visual/Multiplayer/TestMultiplayerClient.cs
+++ b/osu.Game/Tests/Visual/Multiplayer/TestMultiplayerClient.cs
@@ -38,9 +38,9 @@ namespace osu.Game.Tests.Visual.Multiplayer
[Resolved]
private BeatmapManager beatmaps { get; set; } = null!;
- private readonly TestMultiplayerRoomManager roomManager;
+ private readonly TestRequestHandlingMultiplayerRoomManager roomManager;
- public TestMultiplayerClient(TestMultiplayerRoomManager roomManager)
+ public TestMultiplayerClient(TestRequestHandlingMultiplayerRoomManager roomManager)
{
this.roomManager = roomManager;
}
diff --git a/osu.Game/Tests/Visual/Multiplayer/TestMultiplayerRoomManager.cs b/osu.Game/Tests/Visual/Multiplayer/TestRequestHandlingMultiplayerRoomManager.cs
similarity index 85%
rename from osu.Game/Tests/Visual/Multiplayer/TestMultiplayerRoomManager.cs
rename to osu.Game/Tests/Visual/Multiplayer/TestRequestHandlingMultiplayerRoomManager.cs
index 59679f3d66..2e56c8a094 100644
--- a/osu.Game/Tests/Visual/Multiplayer/TestMultiplayerRoomManager.cs
+++ b/osu.Game/Tests/Visual/Multiplayer/TestRequestHandlingMultiplayerRoomManager.cs
@@ -20,7 +20,11 @@ namespace osu.Game.Tests.Visual.Multiplayer
///
/// A for use in multiplayer test scenes. Should generally not be used by itself outside of a .
///
- public class TestMultiplayerRoomManager : MultiplayerRoomManager
+ ///
+ /// This implementation will pretend to be a server, handling room retrieval and manipulation requests
+ /// and returning a roughly expected state, without the need for a server to be running.
+ ///
+ public class TestRequestHandlingMultiplayerRoomManager : MultiplayerRoomManager
{
[Resolved]
private IAPIProvider api { get; set; }
@@ -33,13 +37,16 @@ namespace osu.Game.Tests.Visual.Multiplayer
public new readonly List Rooms = new List();
+ private int currentRoomId;
+ private int currentPlaylistItemId;
+
[BackgroundDependencyLoader]
private void load()
{
int currentScoreId = 0;
- int currentRoomId = 0;
- int currentPlaylistItemId = 0;
+ // Handling here is pretending to be a server, while also updating the local state to match
+ // how the server would eventually respond and update the RoomManager.
((DummyAPIAccess)api).HandleRequest = req =>
{
switch (req)
@@ -48,19 +55,16 @@ namespace osu.Game.Tests.Visual.Multiplayer
var apiRoom = new Room();
apiRoom.CopyFrom(createRoomRequest.Room);
- apiRoom.RoomID.Value ??= currentRoomId++;
// Passwords are explicitly not copied between rooms.
apiRoom.HasPassword.Value = !string.IsNullOrEmpty(createRoomRequest.Room.Password.Value);
apiRoom.Password.Value = createRoomRequest.Room.Password.Value;
- for (int i = 0; i < apiRoom.Playlist.Count; i++)
- apiRoom.Playlist[i].ID = currentPlaylistItemId++;
+ AddRoom(apiRoom);
var responseRoom = new APICreatedRoom();
responseRoom.CopyFrom(createResponseRoom(apiRoom, false));
- Rooms.Add(apiRoom);
createRoomRequest.TriggerSuccess(responseRoom);
return true;
@@ -128,6 +132,17 @@ namespace osu.Game.Tests.Visual.Multiplayer
};
}
+ public void AddRoom(Room room)
+ {
+ room.RoomID.Value ??= currentRoomId++;
+ for (int i = 0; i < room.Playlist.Count; i++)
+ room.Playlist[i].ID = currentPlaylistItemId++;
+
+ Rooms.Add(room);
+ }
+
+ public new void RemoveRoom(Room room) => base.RemoveRoom(room);
+
private Room createResponseRoom(Room room, bool withParticipants)
{
var responseRoom = new Room();