2020-12-19 02:23:42 +09: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;
|
|
|
|
using osu.Framework.Allocation;
|
|
|
|
using osu.Framework.Bindables;
|
|
|
|
using osu.Framework.Graphics;
|
|
|
|
using osu.Framework.Graphics.Containers;
|
2020-12-25 13:38:11 +09:00
|
|
|
using osu.Game.Online.Multiplayer;
|
2021-03-02 19:06:21 +09:00
|
|
|
using osu.Game.Online.Rooms;
|
2020-12-25 16:50:00 +01:00
|
|
|
using osu.Game.Screens.OnlinePlay;
|
|
|
|
using osu.Game.Screens.OnlinePlay.Lounge.Components;
|
2021-03-02 19:06:21 +09:00
|
|
|
using osu.Game.Tests.Beatmaps;
|
2020-12-19 02:23:42 +09:00
|
|
|
|
2020-12-25 13:38:11 +09:00
|
|
|
namespace osu.Game.Tests.Visual.Multiplayer
|
2020-12-19 02:23:42 +09:00
|
|
|
{
|
2020-12-25 13:38:11 +09:00
|
|
|
public abstract class MultiplayerTestScene : RoomTestScene
|
2020-12-19 02:23:42 +09:00
|
|
|
{
|
2021-04-26 17:22:16 +09:00
|
|
|
public const int PLAYER_1_ID = 55;
|
|
|
|
public const int PLAYER_2_ID = 56;
|
|
|
|
|
2021-05-20 15:39:45 +09:00
|
|
|
[Cached(typeof(MultiplayerClient))]
|
2020-12-25 13:38:11 +09:00
|
|
|
public TestMultiplayerClient Client { get; }
|
2020-12-19 02:23:42 +09:00
|
|
|
|
2020-12-21 18:42:23 +09:00
|
|
|
[Cached(typeof(IRoomManager))]
|
2020-12-25 13:38:11 +09:00
|
|
|
public TestMultiplayerRoomManager RoomManager { get; }
|
2020-12-19 02:23:42 +09:00
|
|
|
|
|
|
|
[Cached]
|
|
|
|
public Bindable<FilterCriteria> Filter { get; }
|
|
|
|
|
2021-01-08 22:28:21 +01:00
|
|
|
[Cached]
|
2021-01-09 21:38:20 +01:00
|
|
|
public OngoingOperationTracker OngoingOperationTracker { get; }
|
2021-01-08 22:28:21 +01:00
|
|
|
|
2020-12-19 02:23:42 +09:00
|
|
|
protected override Container<Drawable> Content => content;
|
2020-12-25 13:38:11 +09:00
|
|
|
private readonly TestMultiplayerRoomContainer content;
|
2020-12-19 02:23:42 +09:00
|
|
|
|
|
|
|
private readonly bool joinRoom;
|
|
|
|
|
2020-12-25 13:38:11 +09:00
|
|
|
protected MultiplayerTestScene(bool joinRoom = true)
|
2020-12-19 02:23:42 +09:00
|
|
|
{
|
|
|
|
this.joinRoom = joinRoom;
|
2020-12-25 13:38:11 +09:00
|
|
|
base.Content.Add(content = new TestMultiplayerRoomContainer { RelativeSizeAxes = Axes.Both });
|
2020-12-19 02:23:42 +09:00
|
|
|
|
|
|
|
Client = content.Client;
|
|
|
|
RoomManager = content.RoomManager;
|
|
|
|
Filter = content.Filter;
|
2021-01-09 21:38:20 +01:00
|
|
|
OngoingOperationTracker = content.OngoingOperationTracker;
|
2020-12-19 02:23:42 +09:00
|
|
|
}
|
|
|
|
|
|
|
|
[SetUp]
|
|
|
|
public new void Setup() => Schedule(() =>
|
|
|
|
{
|
|
|
|
RoomManager.Schedule(() => RoomManager.PartRoom());
|
|
|
|
|
|
|
|
if (joinRoom)
|
2021-03-02 19:06:21 +09:00
|
|
|
{
|
|
|
|
Room.Name.Value = "test name";
|
|
|
|
Room.Playlist.Add(new PlaylistItem
|
|
|
|
{
|
|
|
|
Beatmap = { Value = new TestBeatmap(Ruleset.Value).BeatmapInfo },
|
|
|
|
Ruleset = { Value = Ruleset.Value }
|
|
|
|
});
|
|
|
|
|
2020-12-19 02:41:04 +09:00
|
|
|
RoomManager.Schedule(() => RoomManager.CreateRoom(Room));
|
2021-03-02 19:06:21 +09:00
|
|
|
}
|
2020-12-19 02:23:42 +09:00
|
|
|
});
|
2021-02-05 00:42:38 +09:00
|
|
|
|
|
|
|
public override void SetUpSteps()
|
|
|
|
{
|
|
|
|
base.SetUpSteps();
|
|
|
|
|
|
|
|
if (joinRoom)
|
|
|
|
AddUntilStep("wait for room join", () => Client.Room != null);
|
|
|
|
}
|
2020-12-19 02:23:42 +09:00
|
|
|
}
|
|
|
|
}
|