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