osu/osu.Game/Tests/Visual/Multiplayer/MultiplayerTestScene.cs

51 lines
1.6 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 04:38:11 +00:00
using osu.Game.Online.Multiplayer;
using osu.Game.Screens.OnlinePlay;
using osu.Game.Screens.OnlinePlay.Lounge.Components;
2020-12-25 04:38:11 +00:00
namespace osu.Game.Tests.Visual.Multiplayer
{
2020-12-25 04:38:11 +00:00
public abstract class MultiplayerTestScene : RoomTestScene
{
[Cached(typeof(StatefulMultiplayerClient))]
2020-12-25 04:38:11 +00:00
public TestMultiplayerClient Client { get; }
2020-12-21 09:42:23 +00:00
[Cached(typeof(IRoomManager))]
2020-12-25 04:38:11 +00:00
public TestMultiplayerRoomManager RoomManager { get; }
[Cached]
public Bindable<FilterCriteria> Filter { get; }
protected override Container<Drawable> Content => content;
2020-12-25 04:38:11 +00:00
private readonly TestMultiplayerRoomContainer content;
private readonly bool joinRoom;
2020-12-25 04:38:11 +00:00
protected MultiplayerTestScene(bool joinRoom = true)
{
this.joinRoom = joinRoom;
2020-12-25 04:38:11 +00:00
base.Content.Add(content = new TestMultiplayerRoomContainer { RelativeSizeAxes = Axes.Both });
Client = content.Client;
RoomManager = content.RoomManager;
Filter = content.Filter;
}
[SetUp]
public new void Setup() => Schedule(() =>
{
RoomManager.Schedule(() => RoomManager.PartRoom());
if (joinRoom)
RoomManager.Schedule(() => RoomManager.CreateRoom(Room));
});
}
}