osu/osu.Game/Tests/Visual/Multiplayer/MultiplayerTestScene.cs

Ignoring revisions in .git-blame-ignore-revs. Click here to bypass and see the normal blame view.

72 lines
2.4 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 04:38:11 +00:00
namespace osu.Game.Tests.Visual.Multiplayer
{
2021-06-25 09:02:53 +00:00
/// <summary>
/// The base test scene for all multiplayer components and screens.
/// </summary>
2021-06-25 11:15:30 +00:00
public abstract class MultiplayerTestScene : OnlinePlayTestScene, IMultiplayerTestSceneDependencies
{
public const int PLAYER_1_ID = 55;
public const int PLAYER_2_ID = 56;
public TestMultiplayerClient MultiplayerClient => OnlinePlayDependencies.MultiplayerClient;
2021-10-27 07:10:22 +00:00
public new TestMultiplayerRoomManager RoomManager => OnlinePlayDependencies.RoomManager;
public TestSpectatorClient SpectatorClient => OnlinePlayDependencies?.SpectatorClient;
2021-06-25 11:11:38 +00:00
protected new MultiplayerTestSceneDependencies OnlinePlayDependencies => (MultiplayerTestSceneDependencies)base.OnlinePlayDependencies;
public bool RoomJoined => MultiplayerClient.RoomJoined;
private readonly bool joinRoom;
2020-12-25 04:38:11 +00:00
protected MultiplayerTestScene(bool joinRoom = true)
{
this.joinRoom = joinRoom;
}
[SetUp]
public new void Setup() => Schedule(() =>
{
if (joinRoom)
2021-10-27 07:10:22 +00:00
SelectedRoom.Value = CreateRoom();
});
2021-02-04 15:42:38 +00:00
protected virtual Room CreateRoom()
{
return new Room
{
Name = { Value = "test name" },
Type = { Value = MatchType.HeadToHead },
Playlist =
{
new PlaylistItem(new TestBeatmap(Ruleset.Value).BeatmapInfo)
{
RulesetID = Ruleset.Value.OnlineID
}
}
};
}
2021-02-04 15:42:38 +00:00
public override void SetUpSteps()
{
base.SetUpSteps();
if (joinRoom)
2021-10-27 07:10:22 +00:00
{
AddStep("join room", () => RoomManager.CreateRoom(SelectedRoom.Value));
AddUntilStep("wait for room join", () => RoomJoined);
2021-10-27 07:10:22 +00:00
}
2021-02-04 15:42:38 +00:00
}
2021-06-25 09:02:53 +00:00
2021-06-25 11:11:38 +00:00
protected override OnlinePlayTestSceneDependencies CreateOnlinePlayDependencies() => new MultiplayerTestSceneDependencies();
}
}