2020-12-19 01:23:42 +08:00
|
|
|
// 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;
|
2021-03-02 18:06:21 +08:00
|
|
|
using osu.Game.Online.Rooms;
|
|
|
|
using osu.Game.Tests.Beatmaps;
|
2021-06-25 14:00:10 +08:00
|
|
|
using osu.Game.Tests.Visual.OnlinePlay;
|
2021-06-25 16:55:16 +08:00
|
|
|
using osu.Game.Tests.Visual.Spectator;
|
2020-12-19 01:23:42 +08:00
|
|
|
|
2020-12-25 12:38:11 +08:00
|
|
|
namespace osu.Game.Tests.Visual.Multiplayer
|
2020-12-19 01:23:42 +08:00
|
|
|
{
|
2021-06-25 17:02:53 +08:00
|
|
|
/// <summary>
|
|
|
|
/// The base test scene for all multiplayer components and screens.
|
|
|
|
/// </summary>
|
2021-06-25 19:15:30 +08:00
|
|
|
public abstract class MultiplayerTestScene : OnlinePlayTestScene, IMultiplayerTestSceneDependencies
|
2020-12-19 01:23:42 +08:00
|
|
|
{
|
2021-04-26 16:22:16 +08:00
|
|
|
public const int PLAYER_1_ID = 55;
|
|
|
|
public const int PLAYER_2_ID = 56;
|
|
|
|
|
2021-06-25 17:07:47 +08:00
|
|
|
public TestMultiplayerClient Client => OnlinePlayDependencies.Client;
|
2021-07-26 14:47:13 +08:00
|
|
|
public new TestRequestHandlingMultiplayerRoomManager RoomManager => OnlinePlayDependencies.RoomManager;
|
2021-06-25 17:07:47 +08:00
|
|
|
public TestUserLookupCache LookupCache => OnlinePlayDependencies?.LookupCache;
|
|
|
|
public TestSpectatorClient SpectatorClient => OnlinePlayDependencies?.SpectatorClient;
|
2020-12-19 01:23:42 +08:00
|
|
|
|
2021-06-25 19:11:38 +08:00
|
|
|
protected new MultiplayerTestSceneDependencies OnlinePlayDependencies => (MultiplayerTestSceneDependencies)base.OnlinePlayDependencies;
|
2020-12-19 01:23:42 +08:00
|
|
|
|
|
|
|
private readonly bool joinRoom;
|
|
|
|
|
2020-12-25 12:38:11 +08:00
|
|
|
protected MultiplayerTestScene(bool joinRoom = true)
|
2020-12-19 01:23:42 +08:00
|
|
|
{
|
|
|
|
this.joinRoom = joinRoom;
|
|
|
|
}
|
|
|
|
|
|
|
|
[SetUp]
|
|
|
|
public new void Setup() => Schedule(() =>
|
|
|
|
{
|
|
|
|
if (joinRoom)
|
2021-03-02 18:06:21 +08:00
|
|
|
{
|
2021-08-09 15:44:50 +08:00
|
|
|
var room = CreateRoom();
|
2021-06-25 14:00:10 +08:00
|
|
|
|
|
|
|
RoomManager.CreateRoom(room);
|
|
|
|
SelectedRoom.Value = room;
|
2021-03-02 18:06:21 +08:00
|
|
|
}
|
2020-12-19 01:23:42 +08:00
|
|
|
});
|
2021-02-04 23:42:38 +08:00
|
|
|
|
2021-08-09 15:44:50 +08:00
|
|
|
protected virtual Room CreateRoom()
|
|
|
|
{
|
|
|
|
return new Room
|
|
|
|
{
|
|
|
|
Name = { Value = "test name" },
|
|
|
|
Playlist =
|
|
|
|
{
|
|
|
|
new PlaylistItem
|
|
|
|
{
|
|
|
|
Beatmap = { Value = new TestBeatmap(Ruleset.Value).BeatmapInfo },
|
|
|
|
Ruleset = { Value = Ruleset.Value }
|
|
|
|
}
|
|
|
|
}
|
|
|
|
};
|
|
|
|
}
|
|
|
|
|
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
|
|
|
|
2021-06-25 19:11:38 +08:00
|
|
|
protected override OnlinePlayTestSceneDependencies CreateOnlinePlayDependencies() => new MultiplayerTestSceneDependencies();
|
2020-12-19 01:23:42 +08:00
|
|
|
}
|
|
|
|
}
|