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.
|
|
|
|
|
2022-06-17 15:37:17 +08:00
|
|
|
#nullable disable
|
|
|
|
|
2020-12-20 23:04:06 +08:00
|
|
|
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;
|
2022-05-23 01:27:20 +08:00
|
|
|
using osu.Framework.Graphics.Containers;
|
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;
|
2022-02-15 15:01:14 +08:00
|
|
|
using osu.Game.Online.API;
|
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;
|
2022-02-15 15:18:40 +08:00
|
|
|
using osu.Game.Overlays.Mods;
|
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;
|
2022-02-15 15:18:40 +08:00
|
|
|
using osu.Game.Rulesets.Osu.Mods;
|
2022-02-02 17:42:20 +08:00
|
|
|
using osu.Game.Rulesets.Taiko;
|
|
|
|
using osu.Game.Rulesets.Taiko.Mods;
|
|
|
|
using osu.Game.Rulesets.UI;
|
2022-05-09 16:55:40 +08:00
|
|
|
using osu.Game.Screens.OnlinePlay;
|
2022-02-15 15:18:40 +08:00
|
|
|
using osu.Game.Screens.OnlinePlay.Match;
|
2020-12-25 23:50:00 +08:00
|
|
|
using osu.Game.Screens.OnlinePlay.Multiplayer;
|
|
|
|
using osu.Game.Screens.OnlinePlay.Multiplayer.Match;
|
2022-02-02 17:42:20 +08:00
|
|
|
using osu.Game.Screens.OnlinePlay.Multiplayer.Participants;
|
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;
|
2022-05-23 01:27:20 +08:00
|
|
|
using osuTK.Input;
|
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)
|
|
|
|
{
|
2022-02-16 16:13:51 +08:00
|
|
|
Dependencies.Cache(rulesets = new RealmRulesetStore(Realm));
|
2022-01-25 11:58:15 +08:00
|
|
|
Dependencies.Cache(beatmaps = new BeatmapManager(LocalStorage, Realm, rulesets, null, audio, Resources, host, Beatmap.Default));
|
|
|
|
Dependencies.Cache(Realm);
|
2022-01-14 18:59:21 +08:00
|
|
|
|
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]
|
2022-07-01 15:17:40 +08:00
|
|
|
[FlakyTest]
|
|
|
|
/*
|
|
|
|
* Fail rate around 1.5%
|
|
|
|
*
|
|
|
|
* TearDown : System.AggregateException : One or more errors occurred. (Index was out of range. Must be non-negative and less than the size of the collection. (Parameter 'index'))
|
|
|
|
----> System.ArgumentOutOfRangeException : Index was out of range. Must be non-negative and less than the size of the collection. (Parameter 'index')
|
|
|
|
* --TearDown
|
|
|
|
* at System.Threading.Tasks.Task.ThrowIfExceptional(Boolean includeTaskCanceledExceptions)
|
|
|
|
* at System.Threading.Tasks.Task.Wait(Int32 millisecondsTimeout, CancellationToken cancellationToken)
|
|
|
|
* at osu.Framework.Extensions.TaskExtensions.WaitSafely(Task task)
|
|
|
|
* at osu.Framework.Testing.TestScene.checkForErrors()
|
|
|
|
* at osu.Framework.Testing.TestScene.RunTestsFromNUnit()
|
|
|
|
*--ArgumentOutOfRangeException
|
|
|
|
* at osu.Framework.Bindables.BindableList`1.removeAt(Int32 index, BindableList`1 caller)
|
|
|
|
* at osu.Framework.Bindables.BindableList`1.removeAt(Int32 index, BindableList`1 caller)
|
|
|
|
* at osu.Framework.Bindables.BindableList`1.removeAt(Int32 index, BindableList`1 caller)
|
|
|
|
* at osu.Game.Online.Multiplayer.MultiplayerClient.<>c__DisplayClass106_0.<PlaylistItemChanged>b__0() in C:\BuildAgent\work\ecd860037212ac52\osu.Game\Online\Multiplayer\MultiplayerClient .cs:line 702
|
|
|
|
* at osu.Framework.Threading.ScheduledDelegate.RunTaskInternal()
|
|
|
|
*/
|
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
|
|
|
{
|
2022-02-15 22:33:26 +08:00
|
|
|
SelectedRoom.Value.Playlist.Add(new PlaylistItem(new TestBeatmap(new OsuRuleset().RulesetInfo).BeatmapInfo)
|
2020-12-20 23:04:06 +08:00
|
|
|
{
|
2022-02-15 15:01:14 +08:00
|
|
|
RulesetID = new OsuRuleset().RulesetInfo.OnlineID
|
2020-12-20 23:04:06 +08:00
|
|
|
});
|
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
|
|
|
}
|
|
|
|
|
2022-02-02 17:42:20 +08:00
|
|
|
[Test]
|
2022-07-01 15:17:40 +08:00
|
|
|
[FlakyTest]
|
2022-02-02 17:42:20 +08:00
|
|
|
public void TestTaikoOnlyMod()
|
|
|
|
{
|
|
|
|
AddStep("add playlist item", () =>
|
|
|
|
{
|
2022-02-15 22:33:26 +08:00
|
|
|
SelectedRoom.Value.Playlist.Add(new PlaylistItem(new TestBeatmap(new TaikoRuleset().RulesetInfo).BeatmapInfo)
|
2022-02-02 17:42:20 +08:00
|
|
|
{
|
2022-02-15 15:01:14 +08:00
|
|
|
RulesetID = new TaikoRuleset().RulesetInfo.OnlineID,
|
|
|
|
AllowedMods = new[] { new APIMod(new TaikoModSwap()) }
|
2022-02-02 17:42:20 +08:00
|
|
|
});
|
|
|
|
});
|
|
|
|
|
|
|
|
ClickButtonWhenEnabled<MultiplayerMatchSettingsOverlay.CreateOrUpdateButton>();
|
|
|
|
|
|
|
|
AddUntilStep("wait for join", () => RoomJoined);
|
|
|
|
|
2022-02-16 08:43:28 +08:00
|
|
|
AddStep("select swap mod", () => MultiplayerClient.ChangeUserMods(API.LocalUser.Value.OnlineID, new[] { new TaikoModSwap() }));
|
2022-02-02 17:42:20 +08:00
|
|
|
AddUntilStep("participant panel has mod", () => this.ChildrenOfType<ParticipantPanel>().Any(p => p.ChildrenOfType<ModIcon>().Any(m => m.Mod is TaikoModSwap)));
|
|
|
|
}
|
|
|
|
|
2020-12-20 23:04:06 +08:00
|
|
|
[Test]
|
2022-07-01 15:17:40 +08:00
|
|
|
[FlakyTest]
|
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", () =>
|
|
|
|
{
|
2022-02-15 22:33:26 +08:00
|
|
|
SelectedRoom.Value.Playlist.Add(new PlaylistItem(new TestBeatmap(new OsuRuleset().RulesetInfo).BeatmapInfo)
|
2020-12-20 23:04:06 +08:00
|
|
|
{
|
2022-02-15 15:01:14 +08:00
|
|
|
RulesetID = new OsuRuleset().RulesetInfo.OnlineID
|
2020-12-20 23:04:06 +08:00
|
|
|
});
|
|
|
|
});
|
|
|
|
|
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]
|
2022-07-01 15:17:40 +08:00
|
|
|
[FlakyTest]
|
2021-04-07 19:46:30 +08:00
|
|
|
public void TestStartMatchWhileSpectating()
|
|
|
|
{
|
|
|
|
AddStep("set playlist", () =>
|
|
|
|
{
|
2022-02-15 22:33:26 +08:00
|
|
|
SelectedRoom.Value.Playlist.Add(new PlaylistItem(beatmaps.GetWorkingBeatmap(importedSet.Beatmaps.First()).BeatmapInfo)
|
2021-04-07 19:46:30 +08:00
|
|
|
{
|
2022-02-15 15:01:14 +08:00
|
|
|
RulesetID = new OsuRuleset().RulesetInfo.OnlineID
|
2021-04-07 19:46:30 +08:00
|
|
|
});
|
|
|
|
});
|
|
|
|
|
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)", () =>
|
|
|
|
{
|
2022-02-16 08:43:28 +08:00
|
|
|
MultiplayerClient.AddUser(new APIUser { Id = PLAYER_1_ID });
|
|
|
|
MultiplayerClient.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
|
|
|
|
2022-02-16 08:43:28 +08:00
|
|
|
AddUntilStep("wait for spectating user state", () => MultiplayerClient.LocalUser?.State == MultiplayerUserState.Spectating);
|
2021-08-13 12:54:52 +08:00
|
|
|
|
2021-12-21 12:20:12 +08:00
|
|
|
ClickButtonWhenEnabled<MultiplayerReadyButton>();
|
2021-04-07 19:46:30 +08:00
|
|
|
|
2022-02-16 08:43:28 +08:00
|
|
|
AddUntilStep("match started", () => MultiplayerClient.Room?.State == MultiplayerRoomState.WaitingForLoad);
|
2021-04-07 19:46:30 +08:00
|
|
|
}
|
2022-02-15 15:18:40 +08:00
|
|
|
|
|
|
|
[Test]
|
2022-07-01 15:17:40 +08:00
|
|
|
[FlakyTest]
|
2022-02-15 15:18:40 +08:00
|
|
|
public void TestFreeModSelectionHasAllowedMods()
|
|
|
|
{
|
|
|
|
AddStep("add playlist item with allowed mod", () =>
|
|
|
|
{
|
2022-02-15 22:33:26 +08:00
|
|
|
SelectedRoom.Value.Playlist.Add(new PlaylistItem(new TestBeatmap(new OsuRuleset().RulesetInfo).BeatmapInfo)
|
2022-02-15 15:18:40 +08:00
|
|
|
{
|
|
|
|
RulesetID = new OsuRuleset().RulesetInfo.OnlineID,
|
|
|
|
AllowedMods = new[] { new APIMod(new OsuModDoubleTime()) }
|
|
|
|
});
|
|
|
|
});
|
|
|
|
|
|
|
|
ClickButtonWhenEnabled<MultiplayerMatchSettingsOverlay.CreateOrUpdateButton>();
|
|
|
|
|
|
|
|
AddUntilStep("wait for join", () => RoomJoined);
|
|
|
|
|
|
|
|
ClickButtonWhenEnabled<RoomSubScreen.UserModSelectButton>();
|
|
|
|
|
2022-05-06 03:59:44 +08:00
|
|
|
AddUntilStep("mod select contents loaded",
|
|
|
|
() => this.ChildrenOfType<ModColumn>().Any() && this.ChildrenOfType<ModColumn>().All(col => col.IsLoaded && col.ItemsLoaded));
|
2022-02-15 16:13:31 +08:00
|
|
|
AddUntilStep("mod select contains only double time mod",
|
2022-05-11 04:29:57 +08:00
|
|
|
() => this.ChildrenOfType<UserModSelectOverlay>()
|
2022-05-06 03:59:44 +08:00
|
|
|
.SingleOrDefault()?
|
|
|
|
.ChildrenOfType<ModPanel>()
|
|
|
|
.SingleOrDefault(panel => !panel.Filtered.Value)?.Mod is OsuModDoubleTime);
|
2022-02-15 15:18:40 +08:00
|
|
|
}
|
2022-05-09 16:55:40 +08:00
|
|
|
|
2022-05-22 05:16:29 +08:00
|
|
|
[Test]
|
2022-07-01 15:17:40 +08:00
|
|
|
[FlakyTest]
|
2022-05-22 05:16:29 +08:00
|
|
|
public void TestModSelectKeyWithAllowedMods()
|
|
|
|
{
|
|
|
|
AddStep("add playlist item with allowed mod", () =>
|
|
|
|
{
|
|
|
|
SelectedRoom.Value.Playlist.Add(new PlaylistItem(new TestBeatmap(new OsuRuleset().RulesetInfo).BeatmapInfo)
|
|
|
|
{
|
|
|
|
RulesetID = new OsuRuleset().RulesetInfo.OnlineID,
|
|
|
|
AllowedMods = new[] { new APIMod(new OsuModDoubleTime()) }
|
|
|
|
});
|
|
|
|
});
|
|
|
|
|
|
|
|
ClickButtonWhenEnabled<MultiplayerMatchSettingsOverlay.CreateOrUpdateButton>();
|
|
|
|
|
|
|
|
AddUntilStep("wait for join", () => RoomJoined);
|
|
|
|
|
2022-05-23 01:27:20 +08:00
|
|
|
AddStep("press toggle mod select key", () => InputManager.Key(Key.F1));
|
2022-05-22 05:16:29 +08:00
|
|
|
|
2022-05-23 01:27:20 +08:00
|
|
|
AddUntilStep("mod select shown", () => this.ChildrenOfType<ModSelectOverlay>().Single().State.Value == Visibility.Visible);
|
2022-05-22 05:16:29 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
[Test]
|
2022-07-01 15:17:40 +08:00
|
|
|
[FlakyTest]
|
|
|
|
/*
|
|
|
|
* Fail rate around 0.3%
|
|
|
|
*
|
|
|
|
* Somehow there are two mod select overlays?
|
|
|
|
*
|
|
|
|
* TearDown : System.InvalidOperationException : Sequence contains more than one element
|
|
|
|
* --TearDown
|
|
|
|
* at System.Linq.ThrowHelper.ThrowMoreThanOneElementException()
|
|
|
|
* at System.Linq.Enumerable.TryGetSingle[TSource](IEnumerable`1 source, Boolean& found)
|
|
|
|
* at System.Linq.Enumerable.Single[TSource](IEnumerable`1 source)
|
|
|
|
* at osu.Game.Tests.Visual.Multiplayer.TestSceneMultiplayerMatchSubScreen.<TestModSelectKeyWithNoAllowedMods>b__14_3() in /opt/buildagent/work/ecd860037212ac52/osu.Game.Tests/Visual/Multiplayer/TestSceneMultiplayerMatchSubScreen.cs:line 223
|
|
|
|
*/
|
2022-05-22 05:16:29 +08:00
|
|
|
public void TestModSelectKeyWithNoAllowedMods()
|
|
|
|
{
|
|
|
|
AddStep("add playlist item with no allowed mods", () =>
|
|
|
|
{
|
|
|
|
SelectedRoom.Value.Playlist.Add(new PlaylistItem(new TestBeatmap(new OsuRuleset().RulesetInfo).BeatmapInfo)
|
|
|
|
{
|
|
|
|
RulesetID = new OsuRuleset().RulesetInfo.OnlineID,
|
|
|
|
});
|
|
|
|
});
|
|
|
|
ClickButtonWhenEnabled<MultiplayerMatchSettingsOverlay.CreateOrUpdateButton>();
|
|
|
|
|
|
|
|
AddUntilStep("wait for join", () => RoomJoined);
|
|
|
|
|
2022-05-23 01:27:20 +08:00
|
|
|
AddStep("press toggle mod select key", () => InputManager.Key(Key.F1));
|
2022-05-22 05:16:29 +08:00
|
|
|
|
2022-05-23 01:27:20 +08:00
|
|
|
AddWaitStep("wait some", 3);
|
|
|
|
AddAssert("mod select not shown", () => this.ChildrenOfType<ModSelectOverlay>().Single().State.Value == Visibility.Hidden);
|
2022-05-22 05:16:29 +08:00
|
|
|
}
|
|
|
|
|
2022-05-09 16:55:40 +08:00
|
|
|
[Test]
|
2022-07-01 15:17:40 +08:00
|
|
|
[FlakyTest]
|
2022-05-09 16:55:40 +08:00
|
|
|
public void TestNextPlaylistItemSelectedAfterCompletion()
|
|
|
|
{
|
|
|
|
AddStep("add two playlist items", () =>
|
|
|
|
{
|
|
|
|
SelectedRoom.Value.Playlist.AddRange(new[]
|
|
|
|
{
|
|
|
|
new PlaylistItem(beatmaps.GetWorkingBeatmap(importedSet.Beatmaps.First()).BeatmapInfo)
|
|
|
|
{
|
|
|
|
RulesetID = new OsuRuleset().RulesetInfo.OnlineID
|
|
|
|
},
|
|
|
|
new PlaylistItem(beatmaps.GetWorkingBeatmap(importedSet.Beatmaps.First()).BeatmapInfo)
|
|
|
|
{
|
|
|
|
RulesetID = new OsuRuleset().RulesetInfo.OnlineID
|
|
|
|
}
|
|
|
|
});
|
|
|
|
});
|
|
|
|
|
|
|
|
ClickButtonWhenEnabled<MultiplayerMatchSettingsOverlay.CreateOrUpdateButton>();
|
|
|
|
|
|
|
|
AddUntilStep("wait for join", () => RoomJoined);
|
|
|
|
|
|
|
|
ClickButtonWhenEnabled<MultiplayerReadyButton>();
|
|
|
|
ClickButtonWhenEnabled<MultiplayerReadyButton>();
|
|
|
|
|
|
|
|
AddStep("change user to loaded", () => MultiplayerClient.ChangeState(MultiplayerUserState.Loaded));
|
|
|
|
AddUntilStep("user playing", () => MultiplayerClient.LocalUser?.State == MultiplayerUserState.Playing);
|
|
|
|
AddStep("abort gameplay", () => MultiplayerClient.AbortGameplay());
|
|
|
|
|
|
|
|
AddUntilStep("last playlist item selected", () =>
|
|
|
|
{
|
|
|
|
var lastItem = this.ChildrenOfType<DrawableRoomPlaylistItem>().Single(p => p.Item.ID == MultiplayerClient.APIRoom?.Playlist.Last().ID);
|
|
|
|
return lastItem.IsSelectedItem;
|
|
|
|
});
|
|
|
|
}
|
2020-12-20 23:04:06 +08:00
|
|
|
}
|
|
|
|
}
|