1
0
mirror of https://github.com/ppy/osu.git synced 2024-09-24 12:07:27 +08:00
osu-lazer/osu.Game/Tests/Visual/Multiplayer/MultiplayerTestScene.cs

77 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.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;
using osu.Game.Online.Rooms;
using osu.Game.Screens.OnlinePlay;
using osu.Game.Screens.OnlinePlay.Lounge.Components;
using osu.Game.Tests.Beatmaps;
2020-12-25 12:38:11 +08:00
namespace osu.Game.Tests.Visual.Multiplayer
{
2020-12-25 12:38:11 +08:00
public abstract class MultiplayerTestScene : RoomTestScene
{
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-21 17:42:23 +08:00
[Cached(typeof(IRoomManager))]
2020-12-25 12:38:11 +08:00
public TestMultiplayerRoomManager RoomManager { get; }
[Cached]
public Bindable<FilterCriteria> Filter { get; }
[Cached]
public OngoingOperationTracker OngoingOperationTracker { get; }
protected override Container<Drawable> Content => content;
2020-12-25 12:38:11 +08:00
private readonly TestMultiplayerRoomContainer content;
private readonly bool joinRoom;
2020-12-25 12:38:11 +08:00
protected MultiplayerTestScene(bool joinRoom = true)
{
this.joinRoom = joinRoom;
2020-12-25 12:38:11 +08:00
base.Content.Add(content = new TestMultiplayerRoomContainer { RelativeSizeAxes = Axes.Both });
Client = content.Client;
RoomManager = content.RoomManager;
Filter = content.Filter;
OngoingOperationTracker = content.OngoingOperationTracker;
}
[SetUp]
public new void Setup() => Schedule(() =>
{
RoomManager.Schedule(() => RoomManager.PartRoom());
if (joinRoom)
{
Room.Name.Value = "test name";
Room.Playlist.Add(new PlaylistItem
{
Beatmap = { Value = new TestBeatmap(Ruleset.Value).BeatmapInfo },
Ruleset = { Value = Ruleset.Value }
});
RoomManager.Schedule(() => RoomManager.CreateRoom(Room));
}
});
2021-02-04 23:42:38 +08:00
public override void SetUpSteps()
{
base.SetUpSteps();
if (joinRoom)
AddUntilStep("wait for room join", () => Client.Room != null);
}
}
}