2021-10-29 12:56:07 +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 System.Linq;
|
|
|
|
using NUnit.Framework;
|
|
|
|
using osu.Framework.Allocation;
|
|
|
|
using osu.Framework.Audio;
|
|
|
|
using osu.Framework.Platform;
|
2021-10-29 14:44:48 +08:00
|
|
|
using osu.Framework.Screens;
|
2021-10-29 12:56:07 +08:00
|
|
|
using osu.Framework.Testing;
|
|
|
|
using osu.Game.Beatmaps;
|
|
|
|
using osu.Game.Database;
|
2021-10-29 14:44:48 +08:00
|
|
|
using osu.Game.Online.Multiplayer;
|
2021-10-29 12:56:07 +08:00
|
|
|
using osu.Game.Online.Rooms;
|
|
|
|
using osu.Game.Rulesets;
|
|
|
|
using osu.Game.Rulesets.Osu;
|
|
|
|
using osu.Game.Screens.OnlinePlay.Lounge;
|
|
|
|
using osu.Game.Screens.OnlinePlay.Multiplayer;
|
|
|
|
using osu.Game.Screens.OnlinePlay.Multiplayer.Match;
|
2021-10-29 14:44:48 +08:00
|
|
|
using osu.Game.Screens.Play;
|
|
|
|
using osu.Game.Tests.Resources;
|
2021-10-29 12:56:07 +08:00
|
|
|
|
2021-11-19 14:43:11 +08:00
|
|
|
namespace osu.Game.Tests.Visual.Multiplayer
|
2021-10-29 12:56:07 +08:00
|
|
|
{
|
|
|
|
public abstract class QueueModeTestScene : ScreenTestScene
|
|
|
|
{
|
2021-11-16 13:53:10 +08:00
|
|
|
protected abstract QueueMode Mode { get; }
|
2021-10-29 12:56:07 +08:00
|
|
|
|
2021-10-29 14:44:48 +08:00
|
|
|
protected BeatmapInfo InitialBeatmap { get; private set; }
|
|
|
|
protected BeatmapInfo OtherBeatmap { get; private set; }
|
|
|
|
|
2021-12-20 17:24:59 +08:00
|
|
|
protected IScreen CurrentScreen => multiplayerComponents.CurrentScreen;
|
|
|
|
protected IScreen CurrentSubScreen => multiplayerComponents.MultiplayerScreen.CurrentSubScreen;
|
2021-10-29 14:44:48 +08:00
|
|
|
|
2021-10-29 12:56:07 +08:00
|
|
|
private BeatmapManager beatmaps;
|
|
|
|
private RulesetStore rulesets;
|
2021-10-29 14:44:48 +08:00
|
|
|
private BeatmapSetInfo importedSet;
|
2021-10-29 12:56:07 +08:00
|
|
|
|
2021-12-20 17:24:59 +08:00
|
|
|
private TestMultiplayerComponents multiplayerComponents;
|
2021-10-29 12:56:07 +08:00
|
|
|
|
2021-12-20 17:24:59 +08:00
|
|
|
protected TestMultiplayerClient Client => multiplayerComponents.Client;
|
2021-10-29 12:56:07 +08:00
|
|
|
|
|
|
|
[Cached(typeof(UserLookupCache))]
|
|
|
|
private UserLookupCache lookupCache = new TestUserLookupCache();
|
|
|
|
|
|
|
|
[BackgroundDependencyLoader]
|
|
|
|
private void load(GameHost host, AudioManager audio)
|
|
|
|
{
|
|
|
|
Dependencies.Cache(rulesets = new RulesetStore(ContextFactory));
|
|
|
|
Dependencies.Cache(beatmaps = new BeatmapManager(LocalStorage, ContextFactory, rulesets, null, audio, Resources, host, Beatmap.Default));
|
|
|
|
}
|
|
|
|
|
|
|
|
public override void SetUpSteps()
|
|
|
|
{
|
|
|
|
base.SetUpSteps();
|
|
|
|
|
|
|
|
AddStep("import beatmap", () =>
|
|
|
|
{
|
2021-10-29 14:44:48 +08:00
|
|
|
beatmaps.Import(TestResources.GetQuickTestBeatmapForImport()).Wait();
|
|
|
|
importedSet = beatmaps.GetAllUsableBeatmapSetsEnumerable(IncludedDetails.All).First();
|
|
|
|
InitialBeatmap = importedSet.Beatmaps.First(b => b.RulesetID == 0);
|
|
|
|
OtherBeatmap = importedSet.Beatmaps.Last(b => b.RulesetID == 0);
|
2021-10-29 12:56:07 +08:00
|
|
|
});
|
|
|
|
|
2021-12-20 17:24:59 +08:00
|
|
|
AddStep("load multiplayer", () => LoadScreen(multiplayerComponents = new TestMultiplayerComponents()));
|
|
|
|
AddUntilStep("wait for multiplayer to load", () => multiplayerComponents.IsLoaded);
|
2021-10-29 12:56:07 +08:00
|
|
|
AddUntilStep("wait for lounge to load", () => this.ChildrenOfType<MultiplayerLoungeSubScreen>().FirstOrDefault()?.IsLoaded == true);
|
|
|
|
|
2021-12-20 17:24:59 +08:00
|
|
|
AddUntilStep("wait for lounge", () => multiplayerComponents.ChildrenOfType<LoungeSubScreen>().SingleOrDefault()?.IsLoaded == true);
|
|
|
|
AddStep("open room", () => multiplayerComponents.ChildrenOfType<LoungeSubScreen>().Single().Open(new Room
|
2021-10-29 12:56:07 +08:00
|
|
|
{
|
|
|
|
Name = { Value = "Test Room" },
|
|
|
|
QueueMode = { Value = Mode },
|
|
|
|
Playlist =
|
|
|
|
{
|
|
|
|
new PlaylistItem
|
|
|
|
{
|
2021-10-29 14:44:48 +08:00
|
|
|
Beatmap = { Value = InitialBeatmap },
|
|
|
|
Ruleset = { Value = new OsuRuleset().RulesetInfo },
|
2021-10-29 12:56:07 +08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}));
|
|
|
|
|
|
|
|
AddUntilStep("wait for room open", () => this.ChildrenOfType<MultiplayerMatchSubScreen>().FirstOrDefault()?.IsLoaded == true);
|
|
|
|
AddWaitStep("wait for transition", 2);
|
|
|
|
|
2021-12-21 12:20:12 +08:00
|
|
|
ClickButtonWhenEnabled<MultiplayerMatchSettingsOverlay.CreateOrUpdateButton>();
|
2021-10-29 12:56:07 +08:00
|
|
|
|
2021-12-20 12:10:13 +08:00
|
|
|
AddUntilStep("wait for join", () => Client.RoomJoined);
|
2021-10-29 12:56:07 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
[Test]
|
|
|
|
public void TestCreatedWithCorrectMode()
|
|
|
|
{
|
2021-10-29 14:44:48 +08:00
|
|
|
AddAssert("room created with correct mode", () => Client.APIRoom?.QueueMode.Value == Mode);
|
|
|
|
}
|
|
|
|
|
|
|
|
protected void RunGameplay()
|
|
|
|
{
|
2021-11-01 18:25:47 +08:00
|
|
|
AddUntilStep("wait for idle", () => Client.LocalUser?.State == MultiplayerUserState.Idle);
|
2021-12-21 12:20:12 +08:00
|
|
|
ClickButtonWhenEnabled<MultiplayerReadyButton>();
|
2021-10-29 14:44:48 +08:00
|
|
|
|
|
|
|
AddUntilStep("wait for ready", () => Client.LocalUser?.State == MultiplayerUserState.Ready);
|
2021-12-21 12:20:12 +08:00
|
|
|
ClickButtonWhenEnabled<MultiplayerReadyButton>();
|
2021-11-23 16:09:38 +08:00
|
|
|
|
2021-12-20 17:24:59 +08:00
|
|
|
AddUntilStep("wait for player", () => multiplayerComponents.CurrentScreen is Player player && player.IsLoaded);
|
|
|
|
AddStep("exit player", () => multiplayerComponents.MultiplayerScreen.MakeCurrent());
|
2021-11-23 16:09:38 +08:00
|
|
|
}
|
2021-10-29 12:56:07 +08:00
|
|
|
}
|
|
|
|
}
|