2020-12-20 23:04:06 +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;
|
2021-04-07 19:46:30 +08:00
|
|
|
using osu.Framework.Allocation;
|
|
|
|
using osu.Framework.Audio;
|
2022-01-03 16:02:15 +08:00
|
|
|
using osu.Framework.Extensions;
|
2021-04-07 19:46:30 +08:00
|
|
|
using osu.Framework.Platform;
|
2020-12-20 23:04:06 +08:00
|
|
|
using osu.Framework.Screens;
|
|
|
|
using osu.Framework.Testing;
|
2021-04-07 19:46:30 +08:00
|
|
|
using osu.Game.Beatmaps;
|
2021-11-04 17:02:44 +08:00
|
|
|
using osu.Game.Online.API.Requests.Responses;
|
2021-04-07 19:46:30 +08:00
|
|
|
using osu.Game.Online.Multiplayer;
|
2020-12-25 12:38:11 +08:00
|
|
|
using osu.Game.Online.Rooms;
|
2021-04-07 19:46:30 +08:00
|
|
|
using osu.Game.Rulesets;
|
2020-12-20 23:04:06 +08:00
|
|
|
using osu.Game.Rulesets.Osu;
|
2020-12-25 23:50:00 +08:00
|
|
|
using osu.Game.Screens.OnlinePlay.Multiplayer;
|
|
|
|
using osu.Game.Screens.OnlinePlay.Multiplayer.Match;
|
2020-12-20 23:04:06 +08:00
|
|
|
using osu.Game.Tests.Beatmaps;
|
2021-04-07 19:46:30 +08:00
|
|
|
using osu.Game.Tests.Resources;
|
2020-12-20 23:04:06 +08:00
|
|
|
|
2020-12-25 12:20:37 +08:00
|
|
|
namespace osu.Game.Tests.Visual.Multiplayer
|
2020-12-20 23:04:06 +08:00
|
|
|
{
|
2020-12-25 12:38:11 +08:00
|
|
|
public class TestSceneMultiplayerMatchSubScreen : MultiplayerTestScene
|
2020-12-20 23:04:06 +08:00
|
|
|
{
|
2020-12-25 12:38:11 +08:00
|
|
|
private MultiplayerMatchSubScreen screen;
|
2020-12-20 23:04:06 +08:00
|
|
|
|
2021-04-07 19:46:30 +08:00
|
|
|
private BeatmapManager beatmaps;
|
|
|
|
private RulesetStore rulesets;
|
|
|
|
private BeatmapSetInfo importedSet;
|
|
|
|
|
2020-12-25 12:38:11 +08:00
|
|
|
public TestSceneMultiplayerMatchSubScreen()
|
2020-12-20 23:04:06 +08:00
|
|
|
: base(false)
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
2021-04-07 19:46:30 +08:00
|
|
|
[BackgroundDependencyLoader]
|
|
|
|
private void load(GameHost host, AudioManager audio)
|
|
|
|
{
|
|
|
|
Dependencies.Cache(rulesets = new RulesetStore(ContextFactory));
|
2021-05-31 17:37:32 +08:00
|
|
|
Dependencies.Cache(beatmaps = new BeatmapManager(LocalStorage, ContextFactory, rulesets, null, audio, Resources, host, Beatmap.Default));
|
2022-01-14 18:59:21 +08:00
|
|
|
Dependencies.Cache(ContextFactory);
|
|
|
|
|
2022-01-03 16:02:15 +08:00
|
|
|
beatmaps.Import(TestResources.GetQuickTestBeatmapForImport()).WaitSafely();
|
2021-04-07 19:46:30 +08:00
|
|
|
|
2021-12-17 17:26:12 +08:00
|
|
|
importedSet = beatmaps.GetAllUsableBeatmapSets().First();
|
2021-04-07 19:46:30 +08:00
|
|
|
}
|
|
|
|
|
2020-12-20 23:04:06 +08:00
|
|
|
[SetUp]
|
|
|
|
public new void Setup() => Schedule(() =>
|
|
|
|
{
|
2021-06-25 14:00:10 +08:00
|
|
|
SelectedRoom.Value = new Room { Name = { Value = "Test Room" } };
|
2020-12-20 23:04:06 +08:00
|
|
|
});
|
|
|
|
|
|
|
|
[SetUpSteps]
|
|
|
|
public void SetupSteps()
|
|
|
|
{
|
2021-06-25 14:00:10 +08:00
|
|
|
AddStep("load match", () => LoadScreen(screen = new MultiplayerMatchSubScreen(SelectedRoom.Value)));
|
2020-12-20 23:04:06 +08:00
|
|
|
AddUntilStep("wait for load", () => screen.IsCurrentScreen());
|
|
|
|
}
|
|
|
|
|
|
|
|
[Test]
|
2021-08-17 16:05:20 +08:00
|
|
|
public void TestCreatedRoom()
|
2020-12-20 23:04:06 +08:00
|
|
|
{
|
2021-12-21 12:20:12 +08:00
|
|
|
AddStep("add playlist item", () =>
|
2020-12-20 23:04:06 +08:00
|
|
|
{
|
2021-06-25 14:00:10 +08:00
|
|
|
SelectedRoom.Value.Playlist.Add(new PlaylistItem
|
2020-12-20 23:04:06 +08:00
|
|
|
{
|
|
|
|
Beatmap = { Value = new TestBeatmap(new OsuRuleset().RulesetInfo).BeatmapInfo },
|
|
|
|
Ruleset = { Value = new OsuRuleset().RulesetInfo },
|
|
|
|
});
|
2021-08-17 16:05:20 +08:00
|
|
|
});
|
|
|
|
|
2021-12-21 12:20:12 +08:00
|
|
|
ClickButtonWhenEnabled<MultiplayerMatchSettingsOverlay.CreateOrUpdateButton>();
|
|
|
|
|
2021-11-23 15:04:11 +08:00
|
|
|
AddUntilStep("wait for join", () => RoomJoined);
|
2020-12-20 23:04:06 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
[Test]
|
2021-08-17 16:05:20 +08:00
|
|
|
public void TestSettingValidity()
|
2020-12-20 23:04:06 +08:00
|
|
|
{
|
2021-08-17 16:05:20 +08:00
|
|
|
AddAssert("create button not enabled", () => !this.ChildrenOfType<MultiplayerMatchSettingsOverlay.CreateOrUpdateButton>().Single().Enabled.Value);
|
|
|
|
|
2020-12-20 23:04:06 +08:00
|
|
|
AddStep("set playlist", () =>
|
|
|
|
{
|
2021-06-25 14:00:10 +08:00
|
|
|
SelectedRoom.Value.Playlist.Add(new PlaylistItem
|
2020-12-20 23:04:06 +08:00
|
|
|
{
|
|
|
|
Beatmap = { Value = new TestBeatmap(new OsuRuleset().RulesetInfo).BeatmapInfo },
|
|
|
|
Ruleset = { Value = new OsuRuleset().RulesetInfo },
|
|
|
|
});
|
|
|
|
});
|
|
|
|
|
2021-08-17 16:05:20 +08:00
|
|
|
AddAssert("create button enabled", () => this.ChildrenOfType<MultiplayerMatchSettingsOverlay.CreateOrUpdateButton>().Single().Enabled.Value);
|
2020-12-20 23:04:06 +08:00
|
|
|
}
|
2021-04-07 19:46:30 +08:00
|
|
|
|
|
|
|
[Test]
|
|
|
|
public void TestStartMatchWhileSpectating()
|
|
|
|
{
|
|
|
|
AddStep("set playlist", () =>
|
|
|
|
{
|
2021-06-25 14:00:10 +08:00
|
|
|
SelectedRoom.Value.Playlist.Add(new PlaylistItem
|
2021-04-07 19:46:30 +08:00
|
|
|
{
|
|
|
|
Beatmap = { Value = beatmaps.GetWorkingBeatmap(importedSet.Beatmaps.First()).BeatmapInfo },
|
|
|
|
Ruleset = { Value = new OsuRuleset().RulesetInfo },
|
|
|
|
});
|
|
|
|
});
|
|
|
|
|
2021-12-21 12:20:12 +08:00
|
|
|
ClickButtonWhenEnabled<MultiplayerMatchSettingsOverlay.CreateOrUpdateButton>();
|
2021-04-07 19:46:30 +08:00
|
|
|
|
2021-11-23 15:04:11 +08:00
|
|
|
AddUntilStep("wait for room join", () => RoomJoined);
|
2021-04-08 20:38:58 +08:00
|
|
|
|
2021-04-07 19:46:30 +08:00
|
|
|
AddStep("join other user (ready)", () =>
|
|
|
|
{
|
2021-11-04 17:02:44 +08:00
|
|
|
Client.AddUser(new APIUser { Id = PLAYER_1_ID });
|
2021-04-26 16:22:16 +08:00
|
|
|
Client.ChangeUserState(PLAYER_1_ID, MultiplayerUserState.Ready);
|
2021-04-07 19:46:30 +08:00
|
|
|
});
|
|
|
|
|
2021-12-21 12:20:12 +08:00
|
|
|
ClickButtonWhenEnabled<MultiplayerSpectateButton>();
|
2021-04-07 19:46:30 +08:00
|
|
|
|
2021-08-13 12:54:52 +08:00
|
|
|
AddUntilStep("wait for spectating user state", () => Client.LocalUser?.State == MultiplayerUserState.Spectating);
|
|
|
|
|
2021-12-21 12:20:12 +08:00
|
|
|
ClickButtonWhenEnabled<MultiplayerReadyButton>();
|
2021-04-07 19:46:30 +08:00
|
|
|
|
2021-04-12 12:42:14 +08:00
|
|
|
AddUntilStep("match started", () => Client.Room?.State == MultiplayerRoomState.WaitingForLoad);
|
2021-04-07 19:46:30 +08:00
|
|
|
}
|
2020-12-20 23:04:06 +08:00
|
|
|
}
|
|
|
|
}
|