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