diff --git a/osu.Game.Tests/Visual/Multiplayer/TestSceneLoungeRoomsContainer.cs b/osu.Game.Tests/Visual/Multiplayer/TestSceneLoungeRoomsContainer.cs
index d63d52a463..22e7acce44 100644
--- a/osu.Game.Tests/Visual/Multiplayer/TestSceneLoungeRoomsContainer.cs
+++ b/osu.Game.Tests/Visual/Multiplayer/TestSceneLoungeRoomsContainer.cs
@@ -9,6 +9,7 @@ using osu.Game.Graphics;
using osu.Game.Online.Rooms;
using osu.Game.Rulesets.Catch;
using osu.Game.Rulesets.Osu;
+using osu.Game.Screens.OnlinePlay;
using osu.Game.Screens.OnlinePlay.Lounge.Components;
using osu.Game.Tests.Visual.OnlinePlay;
using osuTK.Graphics;
@@ -18,6 +19,8 @@ namespace osu.Game.Tests.Visual.Multiplayer
{
public class TestSceneLoungeRoomsContainer : OnlinePlaySubScreenTestScene
{
+ protected new TestBasicRoomManager RoomManager => (TestBasicRoomManager)base.RoomManager;
+
private RoomsContainer container;
[BackgroundDependencyLoader]
@@ -32,6 +35,8 @@ namespace osu.Game.Tests.Visual.Multiplayer
};
}
+ protected override IRoomManager CreateRoomManager() => new TestBasicRoomManager();
+
[Test]
public void TestBasicListChanges()
{
diff --git a/osu.Game.Tests/Visual/Playlists/TestScenePlaylistsLoungeSubScreen.cs b/osu.Game.Tests/Visual/Playlists/TestScenePlaylistsLoungeSubScreen.cs
index 62a6f40d65..34e66b9cb2 100644
--- a/osu.Game.Tests/Visual/Playlists/TestScenePlaylistsLoungeSubScreen.cs
+++ b/osu.Game.Tests/Visual/Playlists/TestScenePlaylistsLoungeSubScreen.cs
@@ -3,10 +3,10 @@
using System.Linq;
using NUnit.Framework;
-using osu.Framework.Allocation;
using osu.Framework.Screens;
using osu.Framework.Testing;
using osu.Game.Graphics.Containers;
+using osu.Game.Screens.OnlinePlay;
using osu.Game.Screens.OnlinePlay.Lounge;
using osu.Game.Screens.OnlinePlay.Lounge.Components;
using osu.Game.Screens.OnlinePlay.Playlists;
@@ -16,12 +16,11 @@ namespace osu.Game.Tests.Visual.Playlists
{
public class TestScenePlaylistsLoungeSubScreen : OnlinePlaySubScreenTestScene
{
+ protected new TestBasicRoomManager RoomManager => (TestBasicRoomManager)base.RoomManager;
+
private LoungeSubScreen loungeScreen;
- [BackgroundDependencyLoader]
- private void load()
- {
- }
+ protected override IRoomManager CreateRoomManager() => new TestBasicRoomManager();
public override void SetUpSteps()
{
diff --git a/osu.Game/Tests/Visual/OnlinePlay/OnlinePlaySubScreenTestScene.cs b/osu.Game/Tests/Visual/OnlinePlay/OnlinePlaySubScreenTestScene.cs
index 177f6635a7..c4a8658d93 100644
--- a/osu.Game/Tests/Visual/OnlinePlay/OnlinePlaySubScreenTestScene.cs
+++ b/osu.Game/Tests/Visual/OnlinePlay/OnlinePlaySubScreenTestScene.cs
@@ -2,16 +2,12 @@
// See the LICENCE file in the repository root for full licence text.
using System;
-using System.Linq;
using osu.Framework.Allocation;
using osu.Framework.Bindables;
-using osu.Game.Beatmaps;
using osu.Game.Online.Rooms;
-using osu.Game.Rulesets;
using osu.Game.Screens;
using osu.Game.Screens.OnlinePlay;
using osu.Game.Screens.OnlinePlay.Lounge.Components;
-using osu.Game.Users;
namespace osu.Game.Tests.Visual.OnlinePlay
{
@@ -28,7 +24,7 @@ namespace osu.Game.Tests.Visual.OnlinePlay
///
/// The cached
///
- protected TestRoomManager RoomManager { get; private set; }
+ protected IRoomManager RoomManager { get; private set; }
protected Bindable Filter { get; private set; }
@@ -53,78 +49,20 @@ namespace osu.Game.Tests.Visual.OnlinePlay
protected virtual IReadOnlyDependencyContainer CreateScreenDependencies(IReadOnlyDependencyContainer parent)
{
SelectedRoom = new Bindable();
- RoomManager = new TestRoomManager();
+ RoomManager = CreateRoomManager();
Filter = new Bindable(new FilterCriteria());
OngoingOperationTracker = new OngoingOperationTracker();
var dependencies = new DependencyContainer(new CachedModelDependencyContainer(parent) { Model = { BindTarget = SelectedRoom } });
dependencies.CacheAs(SelectedRoom);
- dependencies.CacheAs(RoomManager);
+ dependencies.CacheAs(RoomManager);
dependencies.CacheAs(Filter);
dependencies.CacheAs(OngoingOperationTracker);
return dependencies;
}
- protected class TestRoomManager : IRoomManager
- {
- public event Action RoomsUpdated
- {
- add { }
- remove { }
- }
-
- public readonly BindableList Rooms = new BindableList();
-
- public IBindable InitialRoomsReceived { get; } = new Bindable(true);
-
- IBindableList IRoomManager.Rooms => Rooms;
-
- public void CreateRoom(Room room, Action onSuccess = null, Action onError = null)
- {
- room.RoomID.Value ??= Rooms.Select(r => r.RoomID.Value).Where(id => id != null).Select(id => id.Value).DefaultIfEmpty().Max() + 1;
- Rooms.Add(room);
- onSuccess?.Invoke(room);
- }
-
- public void JoinRoom(Room room, Action onSuccess = null, Action onError = null) => onSuccess?.Invoke(room);
-
- public void PartRoom()
- {
- }
-
- public void AddRooms(int count, RulesetInfo ruleset = null)
- {
- for (int i = 0; i < count; i++)
- {
- var room = new Room
- {
- RoomID = { Value = i },
- Name = { Value = $"Room {i}" },
- Host = { Value = new User { Username = "Host" } },
- EndDate = { Value = DateTimeOffset.Now + TimeSpan.FromSeconds(10) },
- Category = { Value = i % 2 == 0 ? RoomCategory.Spotlight : RoomCategory.Normal }
- };
-
- if (ruleset != null)
- {
- room.Playlist.Add(new PlaylistItem
- {
- Ruleset = { Value = ruleset },
- Beatmap =
- {
- Value = new BeatmapInfo
- {
- Metadata = new BeatmapMetadata()
- }
- }
- });
- }
-
- CreateRoom(room);
- }
- }
- }
+ protected virtual IRoomManager CreateRoomManager() => new TestBasicRoomManager();
///
/// A dummy screen used for injecting new dependencies into the hierarchy before any screen is pushed via .
diff --git a/osu.Game/Tests/Visual/OnlinePlay/TestBasicRoomManager.cs b/osu.Game/Tests/Visual/OnlinePlay/TestBasicRoomManager.cs
new file mode 100644
index 0000000000..fd81072651
--- /dev/null
+++ b/osu.Game/Tests/Visual/OnlinePlay/TestBasicRoomManager.cs
@@ -0,0 +1,74 @@
+// Copyright (c) ppy Pty Ltd . Licensed under the MIT Licence.
+// See the LICENCE file in the repository root for full licence text.
+
+using System;
+using System.Linq;
+using osu.Framework.Bindables;
+using osu.Game.Beatmaps;
+using osu.Game.Online.Rooms;
+using osu.Game.Rulesets;
+using osu.Game.Screens.OnlinePlay;
+using osu.Game.Users;
+
+namespace osu.Game.Tests.Visual.OnlinePlay
+{
+ public class TestBasicRoomManager : IRoomManager
+ {
+ public event Action RoomsUpdated
+ {
+ add { }
+ remove { }
+ }
+
+ public readonly BindableList Rooms = new BindableList();
+
+ public IBindable InitialRoomsReceived { get; } = new Bindable(true);
+
+ IBindableList IRoomManager.Rooms => Rooms;
+
+ public void CreateRoom(Room room, Action onSuccess = null, Action onError = null)
+ {
+ room.RoomID.Value ??= Rooms.Select(r => r.RoomID.Value).Where(id => id != null).Select(id => id.Value).DefaultIfEmpty().Max() + 1;
+ Rooms.Add(room);
+ onSuccess?.Invoke(room);
+ }
+
+ public void JoinRoom(Room room, Action onSuccess = null, Action onError = null) => onSuccess?.Invoke(room);
+
+ public void PartRoom()
+ {
+ }
+
+ public void AddRooms(int count, RulesetInfo ruleset = null)
+ {
+ for (int i = 0; i < count; i++)
+ {
+ var room = new Room
+ {
+ RoomID = { Value = i },
+ Name = { Value = $"Room {i}" },
+ Host = { Value = new User { Username = "Host" } },
+ EndDate = { Value = DateTimeOffset.Now + TimeSpan.FromSeconds(10) },
+ Category = { Value = i % 2 == 0 ? RoomCategory.Spotlight : RoomCategory.Normal }
+ };
+
+ if (ruleset != null)
+ {
+ room.Playlist.Add(new PlaylistItem
+ {
+ Ruleset = { Value = ruleset },
+ Beatmap =
+ {
+ Value = new BeatmapInfo
+ {
+ Metadata = new BeatmapMetadata()
+ }
+ }
+ });
+ }
+
+ CreateRoom(room);
+ }
+ }
+ }
+}