2020-12-28 12:09:32 +01: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 16:37:17 +09:00
|
|
|
#nullable disable
|
|
|
|
|
2020-12-28 12:09:32 +01:00
|
|
|
using System;
|
|
|
|
using System.Collections.Generic;
|
|
|
|
using System.Linq;
|
|
|
|
using NUnit.Framework;
|
|
|
|
using osu.Framework.Allocation;
|
|
|
|
using osu.Framework.Audio;
|
2021-02-22 13:32:54 +09:00
|
|
|
using osu.Framework.Bindables;
|
|
|
|
using osu.Framework.Extensions.TypeExtensions;
|
2020-12-28 12:09:32 +01:00
|
|
|
using osu.Framework.Platform;
|
|
|
|
using osu.Framework.Screens;
|
2021-02-22 13:32:54 +09:00
|
|
|
using osu.Framework.Testing;
|
2020-12-28 12:09:32 +01:00
|
|
|
using osu.Game.Beatmaps;
|
2022-04-06 14:01:25 +09:00
|
|
|
using osu.Game.Database;
|
2021-08-24 13:34:23 +09:00
|
|
|
using osu.Game.Online.Rooms;
|
2021-02-22 13:32:54 +09:00
|
|
|
using osu.Game.Overlays.Mods;
|
2020-12-28 12:09:32 +01:00
|
|
|
using osu.Game.Rulesets;
|
2021-02-22 13:32:54 +09:00
|
|
|
using osu.Game.Rulesets.Mods;
|
2020-12-28 12:09:32 +01:00
|
|
|
using osu.Game.Rulesets.Osu;
|
|
|
|
using osu.Game.Rulesets.Osu.Mods;
|
|
|
|
using osu.Game.Rulesets.Taiko;
|
|
|
|
using osu.Game.Rulesets.Taiko.Mods;
|
2021-02-22 13:32:54 +09:00
|
|
|
using osu.Game.Screens.OnlinePlay;
|
2020-12-28 12:09:32 +01:00
|
|
|
using osu.Game.Screens.OnlinePlay.Multiplayer;
|
|
|
|
using osu.Game.Screens.Select;
|
2022-04-06 14:51:08 +09:00
|
|
|
using osu.Game.Tests.Resources;
|
2020-12-28 12:09:32 +01:00
|
|
|
|
|
|
|
namespace osu.Game.Tests.Visual.Multiplayer
|
|
|
|
{
|
2021-06-25 15:00:10 +09:00
|
|
|
public partial class TestSceneMultiplayerMatchSongSelect : MultiplayerTestScene
|
2020-12-28 12:09:32 +01:00
|
|
|
{
|
|
|
|
private BeatmapManager manager;
|
|
|
|
private RulesetStore rulesets;
|
|
|
|
|
2022-04-06 14:01:25 +09:00
|
|
|
private IList<BeatmapInfo> beatmaps => importedBeatmapSet?.PerformRead(s => s.Beatmaps) ?? new List<BeatmapInfo>();
|
2020-12-28 12:09:32 +01:00
|
|
|
|
|
|
|
private TestMultiplayerMatchSongSelect songSelect;
|
|
|
|
|
2022-04-06 14:01:25 +09:00
|
|
|
private Live<BeatmapSetInfo> importedBeatmapSet;
|
|
|
|
|
2020-12-28 12:09:32 +01:00
|
|
|
[BackgroundDependencyLoader]
|
|
|
|
private void load(GameHost host, AudioManager audio)
|
|
|
|
{
|
2022-02-16 17:13:51 +09:00
|
|
|
Dependencies.Cache(rulesets = new RealmRulesetStore(Realm));
|
2022-07-28 16:19:05 +09:00
|
|
|
Dependencies.Cache(manager = new BeatmapManager(LocalStorage, Realm, null, audio, Resources, host, Beatmap.Default));
|
2022-01-25 12:58:15 +09:00
|
|
|
Dependencies.Cache(Realm);
|
2020-12-28 12:09:32 +01:00
|
|
|
|
2022-04-06 14:51:08 +09:00
|
|
|
importedBeatmapSet = manager.Import(TestResources.CreateTestBeatmapSetInfo(8, rulesets.AvailableRulesets.ToArray()));
|
2020-12-28 12:09:32 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
public override void SetUpSteps()
|
|
|
|
{
|
|
|
|
base.SetUpSteps();
|
|
|
|
|
|
|
|
AddStep("reset", () =>
|
|
|
|
{
|
|
|
|
Ruleset.Value = new OsuRuleset().RulesetInfo;
|
|
|
|
Beatmap.SetDefault();
|
|
|
|
SelectedMods.SetDefault();
|
|
|
|
});
|
|
|
|
|
2021-08-24 13:34:23 +09:00
|
|
|
AddStep("create song select", () => LoadScreen(songSelect = new TestMultiplayerMatchSongSelect(SelectedRoom.Value)));
|
2021-11-25 21:11:13 +09:00
|
|
|
AddUntilStep("wait for present", () => songSelect.IsCurrentScreen() && songSelect.BeatmapSetsLoaded);
|
2020-12-28 12:09:32 +01:00
|
|
|
}
|
|
|
|
|
2023-07-19 19:08:32 +09:00
|
|
|
[Test]
|
|
|
|
public void TestSelectFreeMods()
|
|
|
|
{
|
|
|
|
AddStep("set some freemods", () => songSelect.FreeMods.Value = new OsuRuleset().GetModsFor(ModType.Fun).ToArray());
|
|
|
|
AddStep("set all freemods", () => songSelect.FreeMods.Value = new OsuRuleset().CreateAllMods().ToArray());
|
|
|
|
AddStep("set no freemods", () => songSelect.FreeMods.Value = Array.Empty<Mod>());
|
|
|
|
}
|
|
|
|
|
2020-12-28 12:09:32 +01:00
|
|
|
[Test]
|
|
|
|
public void TestBeatmapConfirmed()
|
|
|
|
{
|
|
|
|
BeatmapInfo selectedBeatmap = null;
|
|
|
|
|
|
|
|
AddStep("change ruleset", () => Ruleset.Value = new TaikoRuleset().RulesetInfo);
|
|
|
|
AddStep("select beatmap",
|
2022-01-27 15:19:48 +09:00
|
|
|
() => songSelect.Carousel.SelectBeatmap(selectedBeatmap = beatmaps.First(beatmap => beatmap.Ruleset.OnlineID == new TaikoRuleset().LegacyID)));
|
2022-06-30 17:58:43 +09:00
|
|
|
|
2020-12-28 12:09:32 +01:00
|
|
|
AddUntilStep("wait for selection", () => Beatmap.Value.BeatmapInfo.Equals(selectedBeatmap));
|
2022-06-30 17:58:43 +09:00
|
|
|
AddUntilStep("wait for ongoing operation to complete", () => !OnlinePlayDependencies.OngoingOperationTracker.InProgress.Value);
|
|
|
|
|
2020-12-28 12:09:32 +01:00
|
|
|
AddStep("set mods", () => SelectedMods.Value = new[] { new TaikoModDoubleTime() });
|
|
|
|
|
|
|
|
AddStep("confirm selection", () => songSelect.FinaliseSelection());
|
2021-12-01 02:06:40 +09:00
|
|
|
|
|
|
|
AddUntilStep("song select exited", () => !songSelect.IsCurrentScreen());
|
2020-12-28 12:09:32 +01:00
|
|
|
|
|
|
|
AddAssert("beatmap not changed", () => Beatmap.Value.BeatmapInfo.Equals(selectedBeatmap));
|
|
|
|
AddAssert("ruleset not changed", () => Ruleset.Value.Equals(new TaikoRuleset().RulesetInfo));
|
|
|
|
AddAssert("mods not changed", () => SelectedMods.Value.Single() is TaikoModDoubleTime);
|
|
|
|
}
|
|
|
|
|
2021-02-22 13:32:54 +09:00
|
|
|
[TestCase(typeof(OsuModHidden), typeof(OsuModHidden))] // Same mod.
|
|
|
|
[TestCase(typeof(OsuModHidden), typeof(OsuModTraceable))] // Incompatible.
|
|
|
|
public void TestAllowedModDeselectedWhenRequired(Type allowedMod, Type requiredMod)
|
|
|
|
{
|
2023-06-18 14:16:31 +02:00
|
|
|
AddStep("change ruleset", () => Ruleset.Value = new OsuRuleset().RulesetInfo);
|
2021-02-22 13:32:54 +09:00
|
|
|
AddStep($"select {allowedMod.ReadableName()} as allowed", () => songSelect.FreeMods.Value = new[] { (Mod)Activator.CreateInstance(allowedMod) });
|
|
|
|
AddStep($"select {requiredMod.ReadableName()} as required", () => songSelect.Mods.Value = new[] { (Mod)Activator.CreateInstance(requiredMod) });
|
|
|
|
|
|
|
|
AddAssert("freemods empty", () => songSelect.FreeMods.Value.Count == 0);
|
2023-05-03 14:30:57 +09:00
|
|
|
|
|
|
|
// A previous test's mod overlay could still be fading out.
|
|
|
|
AddUntilStep("wait for only one freemod overlay", () => this.ChildrenOfType<FreeModSelectOverlay>().Count() == 1);
|
|
|
|
|
2023-06-18 14:16:31 +02:00
|
|
|
assertFreeModNotShown(allowedMod);
|
|
|
|
assertFreeModNotShown(requiredMod);
|
2021-02-22 13:32:54 +09:00
|
|
|
}
|
|
|
|
|
2023-06-18 14:16:31 +02:00
|
|
|
private void assertFreeModNotShown(Type type)
|
2021-02-22 13:32:54 +09:00
|
|
|
{
|
2023-06-18 14:16:31 +02:00
|
|
|
AddAssert($"{type.ReadableName()} not displayed in freemod overlay",
|
2022-05-10 22:29:57 +02:00
|
|
|
() => this.ChildrenOfType<FreeModSelectOverlay>()
|
2022-05-07 13:10:03 +02:00
|
|
|
.Single()
|
|
|
|
.ChildrenOfType<ModPanel>()
|
2023-06-18 14:16:31 +02:00
|
|
|
.Where(panel => panel.Visible)
|
2022-05-07 13:10:03 +02:00
|
|
|
.All(b => b.Mod.GetType() != type));
|
2021-02-22 13:32:54 +09:00
|
|
|
}
|
|
|
|
|
2020-12-28 12:09:32 +01:00
|
|
|
private partial class TestMultiplayerMatchSongSelect : MultiplayerMatchSongSelect
|
|
|
|
{
|
2021-02-22 13:32:54 +09:00
|
|
|
public new Bindable<IReadOnlyList<Mod>> Mods => base.Mods;
|
|
|
|
|
|
|
|
public new Bindable<IReadOnlyList<Mod>> FreeMods => base.FreeMods;
|
|
|
|
|
2020-12-28 12:09:32 +01:00
|
|
|
public new BeatmapCarousel Carousel => base.Carousel;
|
2021-08-24 13:34:23 +09:00
|
|
|
|
2022-09-07 20:01:17 +09:00
|
|
|
public TestMultiplayerMatchSongSelect(Room room)
|
|
|
|
: base(room)
|
2021-08-24 13:34:23 +09:00
|
|
|
{
|
|
|
|
}
|
2020-12-28 12:09:32 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|