1
0
mirror of https://github.com/ppy/osu.git synced 2024-09-24 12:07:27 +08:00
osu-lazer/osu.Game/Tests/Visual/Multiplayer/MultiplayerTestScene.cs

68 lines
2.2 KiB
C#
Raw Normal View History

// Copyright (c) ppy Pty Ltd <contact@ppy.sh>. Licensed under the MIT Licence.
// See the LICENCE file in the repository root for full licence text.
using NUnit.Framework;
using osu.Game.Online.Rooms;
using osu.Game.Tests.Beatmaps;
using osu.Game.Tests.Visual.OnlinePlay;
using osu.Game.Tests.Visual.Spectator;
2020-12-25 12:38:11 +08:00
namespace osu.Game.Tests.Visual.Multiplayer
{
2021-06-25 17:02:53 +08:00
/// <summary>
/// The base test scene for all multiplayer components and screens.
/// </summary>
public abstract class MultiplayerTestScene : OnlinePlayTestScene, IMultiplayerTestDependencies
{
public const int PLAYER_1_ID = 55;
public const int PLAYER_2_ID = 56;
public TestMultiplayerClient Client => RoomDependencies.Client;
public new TestMultiplayerRoomManager RoomManager => RoomDependencies.RoomManager;
public TestUserLookupCache LookupCache => RoomDependencies?.LookupCache;
public TestSpectatorClient SpectatorClient => RoomDependencies?.SpectatorClient;
protected new MultiplayerRoomTestDependencies RoomDependencies => (MultiplayerRoomTestDependencies)base.RoomDependencies;
private readonly bool joinRoom;
2020-12-25 12:38:11 +08:00
protected MultiplayerTestScene(bool joinRoom = true)
{
this.joinRoom = joinRoom;
}
[SetUp]
public new void Setup() => Schedule(() =>
{
if (joinRoom)
{
var room = new Room
{
Name = { Value = "test name" },
Playlist =
{
new PlaylistItem
{
Beatmap = { Value = new TestBeatmap(Ruleset.Value).BeatmapInfo },
Ruleset = { Value = Ruleset.Value }
}
}
};
RoomManager.CreateRoom(room);
SelectedRoom.Value = room;
}
});
2021-02-04 23:42:38 +08:00
public override void SetUpSteps()
{
base.SetUpSteps();
if (joinRoom)
AddUntilStep("wait for room join", () => Client.Room != null);
}
2021-06-25 17:02:53 +08:00
protected override RoomTestDependencies CreateRoomDependencies() => new MultiplayerRoomTestDependencies();
}
}