mirror of
https://github.com/osukey/osukey.git
synced 2025-07-02 08:49:59 +09:00
Move SpectatorClient into multiplayer dependencies
This commit is contained in:
@ -6,21 +6,14 @@ using System.Linq;
|
|||||||
using NUnit.Framework;
|
using NUnit.Framework;
|
||||||
using osu.Framework.Testing;
|
using osu.Framework.Testing;
|
||||||
using osu.Framework.Timing;
|
using osu.Framework.Timing;
|
||||||
using osu.Game.Online.Spectator;
|
|
||||||
using osu.Game.Rulesets.Osu.Scoring;
|
using osu.Game.Rulesets.Osu.Scoring;
|
||||||
using osu.Game.Screens.OnlinePlay.Multiplayer.Spectate;
|
using osu.Game.Screens.OnlinePlay.Multiplayer.Spectate;
|
||||||
using osu.Game.Screens.Play.HUD;
|
using osu.Game.Screens.Play.HUD;
|
||||||
using osu.Game.Tests.Visual.OnlinePlay;
|
|
||||||
using osu.Game.Tests.Visual.Spectator;
|
|
||||||
|
|
||||||
namespace osu.Game.Tests.Visual.Multiplayer
|
namespace osu.Game.Tests.Visual.Multiplayer
|
||||||
{
|
{
|
||||||
public class TestSceneMultiSpectatorLeaderboard : MultiplayerTestScene
|
public class TestSceneMultiSpectatorLeaderboard : MultiplayerTestScene
|
||||||
{
|
{
|
||||||
public TestSpectatorClient SpectatorClient => RoomDependencies?.SpectatorClient;
|
|
||||||
|
|
||||||
protected new TestDependencies RoomDependencies => (TestDependencies)base.RoomDependencies;
|
|
||||||
|
|
||||||
private Dictionary<int, ManualClock> clocks;
|
private Dictionary<int, ManualClock> clocks;
|
||||||
private MultiSpectatorLeaderboard leaderboard;
|
private MultiSpectatorLeaderboard leaderboard;
|
||||||
|
|
||||||
@ -118,17 +111,5 @@ namespace osu.Game.Tests.Visual.Multiplayer
|
|||||||
|
|
||||||
private void assertCombo(int userId, int expectedCombo)
|
private void assertCombo(int userId, int expectedCombo)
|
||||||
=> AddUntilStep($"player {userId} has {expectedCombo} combo", () => this.ChildrenOfType<GameplayLeaderboardScore>().Single(s => s.User?.Id == userId).Combo.Value == expectedCombo);
|
=> AddUntilStep($"player {userId} has {expectedCombo} combo", () => this.ChildrenOfType<GameplayLeaderboardScore>().Single(s => s.User?.Id == userId).Combo.Value == expectedCombo);
|
||||||
|
|
||||||
protected override RoomTestDependencies CreateRoomDependencies() => new TestDependencies();
|
|
||||||
|
|
||||||
protected class TestDependencies : MultiplayerRoomTestDependencies
|
|
||||||
{
|
|
||||||
public readonly TestSpectatorClient SpectatorClient = new TestSpectatorClient();
|
|
||||||
|
|
||||||
public TestDependencies()
|
|
||||||
{
|
|
||||||
CacheAs<SpectatorClient>(SpectatorClient);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -8,21 +8,14 @@ using osu.Framework.Allocation;
|
|||||||
using osu.Framework.Graphics;
|
using osu.Framework.Graphics;
|
||||||
using osu.Framework.Testing;
|
using osu.Framework.Testing;
|
||||||
using osu.Game.Beatmaps;
|
using osu.Game.Beatmaps;
|
||||||
using osu.Game.Online.Spectator;
|
|
||||||
using osu.Game.Screens.OnlinePlay.Multiplayer.Spectate;
|
using osu.Game.Screens.OnlinePlay.Multiplayer.Spectate;
|
||||||
using osu.Game.Screens.Play;
|
using osu.Game.Screens.Play;
|
||||||
using osu.Game.Tests.Beatmaps.IO;
|
using osu.Game.Tests.Beatmaps.IO;
|
||||||
using osu.Game.Tests.Visual.OnlinePlay;
|
|
||||||
using osu.Game.Tests.Visual.Spectator;
|
|
||||||
|
|
||||||
namespace osu.Game.Tests.Visual.Multiplayer
|
namespace osu.Game.Tests.Visual.Multiplayer
|
||||||
{
|
{
|
||||||
public class TestSceneMultiSpectatorScreen : MultiplayerTestScene
|
public class TestSceneMultiSpectatorScreen : MultiplayerTestScene
|
||||||
{
|
{
|
||||||
public TestSpectatorClient SpectatorClient => RoomDependencies?.SpectatorClient;
|
|
||||||
|
|
||||||
protected new TestDependencies RoomDependencies => (TestDependencies)base.RoomDependencies;
|
|
||||||
|
|
||||||
[Resolved]
|
[Resolved]
|
||||||
private OsuGameBase game { get; set; }
|
private OsuGameBase game { get; set; }
|
||||||
|
|
||||||
@ -279,17 +272,5 @@ namespace osu.Game.Tests.Visual.Multiplayer
|
|||||||
private Player getPlayer(int userId) => getInstance(userId).ChildrenOfType<Player>().Single();
|
private Player getPlayer(int userId) => getInstance(userId).ChildrenOfType<Player>().Single();
|
||||||
|
|
||||||
private PlayerArea getInstance(int userId) => spectatorScreen.ChildrenOfType<PlayerArea>().Single(p => p.UserId == userId);
|
private PlayerArea getInstance(int userId) => spectatorScreen.ChildrenOfType<PlayerArea>().Single(p => p.UserId == userId);
|
||||||
|
|
||||||
protected override RoomTestDependencies CreateRoomDependencies() => new TestDependencies();
|
|
||||||
|
|
||||||
protected class TestDependencies : MultiplayerRoomTestDependencies
|
|
||||||
{
|
|
||||||
public readonly TestSpectatorClient SpectatorClient = new TestSpectatorClient();
|
|
||||||
|
|
||||||
public TestDependencies()
|
|
||||||
{
|
|
||||||
CacheAs<SpectatorClient>(SpectatorClient);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -27,9 +27,7 @@ namespace osu.Game.Tests.Visual.Multiplayer
|
|||||||
{
|
{
|
||||||
private static IEnumerable<int> users => Enumerable.Range(0, 16);
|
private static IEnumerable<int> users => Enumerable.Range(0, 16);
|
||||||
|
|
||||||
public TestMultiplayerSpectatorClient SpectatorClient => RoomDependencies?.SpectatorClient;
|
public new TestMultiplayerSpectatorClient SpectatorClient => (TestMultiplayerSpectatorClient)RoomDependencies?.SpectatorClient;
|
||||||
|
|
||||||
protected new TestDependencies RoomDependencies => (TestDependencies)base.RoomDependencies;
|
|
||||||
|
|
||||||
private MultiplayerGameplayLeaderboard leaderboard;
|
private MultiplayerGameplayLeaderboard leaderboard;
|
||||||
private OsuConfigManager config;
|
private OsuConfigManager config;
|
||||||
@ -104,12 +102,7 @@ namespace osu.Game.Tests.Visual.Multiplayer
|
|||||||
|
|
||||||
protected class TestDependencies : MultiplayerRoomTestDependencies
|
protected class TestDependencies : MultiplayerRoomTestDependencies
|
||||||
{
|
{
|
||||||
public readonly TestMultiplayerSpectatorClient SpectatorClient = new TestMultiplayerSpectatorClient();
|
protected override TestSpectatorClient CreateSpectatorClient() => new TestMultiplayerSpectatorClient();
|
||||||
|
|
||||||
public TestDependencies()
|
|
||||||
{
|
|
||||||
CacheAs<SpectatorClient>(SpectatorClient);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public class TestMultiplayerSpectatorClient : TestSpectatorClient
|
public class TestMultiplayerSpectatorClient : TestSpectatorClient
|
||||||
|
@ -148,6 +148,7 @@ namespace osu.Game.Tests.Visual.Multiplayer
|
|||||||
{
|
{
|
||||||
public TestDependencies()
|
public TestDependencies()
|
||||||
{
|
{
|
||||||
|
// Need to set these values as early as possible.
|
||||||
RoomManager.TimeBetweenListingPolls.Value = 1;
|
RoomManager.TimeBetweenListingPolls.Value = 1;
|
||||||
RoomManager.TimeBetweenSelectionPolls.Value = 1;
|
RoomManager.TimeBetweenSelectionPolls.Value = 1;
|
||||||
}
|
}
|
||||||
|
@ -5,6 +5,7 @@ using osu.Game.Database;
|
|||||||
using osu.Game.Online.Multiplayer;
|
using osu.Game.Online.Multiplayer;
|
||||||
using osu.Game.Screens.OnlinePlay;
|
using osu.Game.Screens.OnlinePlay;
|
||||||
using osu.Game.Tests.Visual.OnlinePlay;
|
using osu.Game.Tests.Visual.OnlinePlay;
|
||||||
|
using osu.Game.Tests.Visual.Spectator;
|
||||||
|
|
||||||
namespace osu.Game.Tests.Visual.Multiplayer
|
namespace osu.Game.Tests.Visual.Multiplayer
|
||||||
{
|
{
|
||||||
@ -24,5 +25,10 @@ namespace osu.Game.Tests.Visual.Multiplayer
|
|||||||
/// The cached <see cref="UserLookupCache"/>.
|
/// The cached <see cref="UserLookupCache"/>.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
TestUserLookupCache LookupCache { get; }
|
TestUserLookupCache LookupCache { get; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// The cached <see cref="osu.Game.Online.Spectator.SpectatorClient"/>.
|
||||||
|
/// </summary>
|
||||||
|
TestSpectatorClient SpectatorClient { get; }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -3,8 +3,10 @@
|
|||||||
|
|
||||||
using osu.Game.Database;
|
using osu.Game.Database;
|
||||||
using osu.Game.Online.Multiplayer;
|
using osu.Game.Online.Multiplayer;
|
||||||
|
using osu.Game.Online.Spectator;
|
||||||
using osu.Game.Screens.OnlinePlay;
|
using osu.Game.Screens.OnlinePlay;
|
||||||
using osu.Game.Tests.Visual.OnlinePlay;
|
using osu.Game.Tests.Visual.OnlinePlay;
|
||||||
|
using osu.Game.Tests.Visual.Spectator;
|
||||||
|
|
||||||
namespace osu.Game.Tests.Visual.Multiplayer
|
namespace osu.Game.Tests.Visual.Multiplayer
|
||||||
{
|
{
|
||||||
@ -12,17 +14,23 @@ namespace osu.Game.Tests.Visual.Multiplayer
|
|||||||
{
|
{
|
||||||
public TestMultiplayerClient Client { get; }
|
public TestMultiplayerClient Client { get; }
|
||||||
public TestUserLookupCache LookupCache { get; }
|
public TestUserLookupCache LookupCache { get; }
|
||||||
|
public TestSpectatorClient SpectatorClient { get; }
|
||||||
|
|
||||||
public new TestMultiplayerRoomManager RoomManager => (TestMultiplayerRoomManager)base.RoomManager;
|
public new TestMultiplayerRoomManager RoomManager => (TestMultiplayerRoomManager)base.RoomManager;
|
||||||
|
|
||||||
public MultiplayerRoomTestDependencies()
|
public MultiplayerRoomTestDependencies()
|
||||||
{
|
{
|
||||||
Client = new TestMultiplayerClient(RoomManager);
|
Client = new TestMultiplayerClient(RoomManager);
|
||||||
LookupCache = new TestUserLookupCache();
|
LookupCache = new TestUserLookupCache();
|
||||||
|
SpectatorClient = CreateSpectatorClient();
|
||||||
|
|
||||||
CacheAs<MultiplayerClient>(Client);
|
CacheAs<MultiplayerClient>(Client);
|
||||||
CacheAs<UserLookupCache>(LookupCache);
|
CacheAs<UserLookupCache>(LookupCache);
|
||||||
|
CacheAs<SpectatorClient>(SpectatorClient);
|
||||||
}
|
}
|
||||||
|
|
||||||
protected override IRoomManager CreateRoomManager() => new TestMultiplayerRoomManager();
|
protected override IRoomManager CreateRoomManager() => new TestMultiplayerRoomManager();
|
||||||
|
|
||||||
|
protected virtual TestSpectatorClient CreateSpectatorClient() => new TestSpectatorClient();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -5,6 +5,7 @@ using NUnit.Framework;
|
|||||||
using osu.Game.Online.Rooms;
|
using osu.Game.Online.Rooms;
|
||||||
using osu.Game.Tests.Beatmaps;
|
using osu.Game.Tests.Beatmaps;
|
||||||
using osu.Game.Tests.Visual.OnlinePlay;
|
using osu.Game.Tests.Visual.OnlinePlay;
|
||||||
|
using osu.Game.Tests.Visual.Spectator;
|
||||||
|
|
||||||
namespace osu.Game.Tests.Visual.Multiplayer
|
namespace osu.Game.Tests.Visual.Multiplayer
|
||||||
{
|
{
|
||||||
@ -16,6 +17,7 @@ namespace osu.Game.Tests.Visual.Multiplayer
|
|||||||
public TestMultiplayerClient Client => RoomDependencies.Client;
|
public TestMultiplayerClient Client => RoomDependencies.Client;
|
||||||
public new TestMultiplayerRoomManager RoomManager => RoomDependencies.RoomManager;
|
public new TestMultiplayerRoomManager RoomManager => RoomDependencies.RoomManager;
|
||||||
public TestUserLookupCache LookupCache => RoomDependencies?.LookupCache;
|
public TestUserLookupCache LookupCache => RoomDependencies?.LookupCache;
|
||||||
|
public TestSpectatorClient SpectatorClient => RoomDependencies?.SpectatorClient;
|
||||||
|
|
||||||
protected new MultiplayerRoomTestDependencies RoomDependencies => (MultiplayerRoomTestDependencies)base.RoomDependencies;
|
protected new MultiplayerRoomTestDependencies RoomDependencies => (MultiplayerRoomTestDependencies)base.RoomDependencies;
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user