1
0
mirror of https://github.com/ppy/osu.git synced 2025-03-12 01:27:20 +08:00
osu-lazer/osu.Game/Tests/Visual/Multiplayer/MultiplayerTestScene.cs

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

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 osu.Game.Online.Rooms;
using osu.Game.Tests.Beatmaps;
using osu.Game.Tests.Visual.OnlinePlay;
using osu.Game.Tests.Visual.Spectator;
2020-12-25 13:38:11 +09:00
namespace osu.Game.Tests.Visual.Multiplayer
{
2021-06-25 18:02:53 +09:00
/// <summary>
/// The base test scene for all multiplayer components and screens.
/// </summary>
2021-06-25 20:15:30 +09:00
public abstract partial class MultiplayerTestScene : OnlinePlayTestScene, IMultiplayerTestSceneDependencies
{
public const int PLAYER_1_ID = 55;
public const int PLAYER_2_ID = 56;
public TestMultiplayerClient MultiplayerClient => OnlinePlayDependencies.MultiplayerClient;
2024-02-02 19:48:13 +09:00
public TestSpectatorClient SpectatorClient => OnlinePlayDependencies.SpectatorClient;
2021-06-25 20:11:38 +09:00
protected new MultiplayerTestSceneDependencies OnlinePlayDependencies => (MultiplayerTestSceneDependencies)base.OnlinePlayDependencies;
public bool RoomJoined => MultiplayerClient.RoomJoined;
private readonly bool joinRoom;
2020-12-25 13:38:11 +09:00
protected MultiplayerTestScene(bool joinRoom = true)
{
this.joinRoom = joinRoom;
}
protected virtual Room CreateRoom()
{
return new Room
{
2024-11-13 16:55:18 +09:00
Name = "test name",
2024-11-13 18:36:47 +09:00
Type = MatchType.HeadToHead,
Playlist =
2024-11-14 17:57:32 +09:00
[
new PlaylistItem(new TestBeatmap(Ruleset.Value).BeatmapInfo)
{
RulesetID = Ruleset.Value.OnlineID
}
2024-11-14 17:57:32 +09:00
]
};
}
2021-02-05 00:42:38 +09:00
public override void SetUpSteps()
{
base.SetUpSteps();
if (joinRoom)
2021-10-27 16:10:22 +09:00
{
AddStep("join room", () =>
{
2024-02-02 21:05:12 +09:00
SelectedRoom.Value = CreateRoom();
2025-01-23 16:19:09 +09:00
MultiplayerClient.CreateRoom(SelectedRoom.Value).ConfigureAwait(false);
});
AddUntilStep("wait for room join", () => RoomJoined);
2021-10-27 16:10:22 +09:00
}
2021-02-05 00:42:38 +09:00
}
2021-06-25 18:02:53 +09:00
2021-06-25 20:11:38 +09:00
protected override OnlinePlayTestSceneDependencies CreateOnlinePlayDependencies() => new MultiplayerTestSceneDependencies();
}
}