1
0
mirror of https://github.com/ppy/osu.git synced 2025-02-15 22:22:54 +08:00

Add failing test

Add test case demonstrating the lack of update of the metadata display's
mods upon setting the Mods property in PlayerLoader.
This commit is contained in:
Bartłomiej Dach 2020-01-08 19:55:35 +01:00
parent d33a507d96
commit a3f7d3c445
2 changed files with 25 additions and 9 deletions

View File

@ -146,6 +146,18 @@ namespace osu.Game.Tests.Visual.Gameplay
AddAssert("player mods applied", () => playerMod2.Applied); AddAssert("player mods applied", () => playerMod2.Applied);
} }
[Test]
public void TestModDisplayChanges()
{
var testMod = new TestMod();
AddStep("load player", () => ResetPlayer(true));
AddUntilStep("wait for loader to become current", () => loader.IsCurrentScreen());
AddStep("set test mod in loader", () => loader.Mods.Value = new[] { testMod });
AddAssert("test mod is displayed", () => (TestMod)loader.DisplayedMods.Single() == testMod);
}
[Test] [Test]
public void TestMutedNotificationMasterVolume() => addVolumeSteps("master volume", () => audioManager.Volume.Value = 0, null, () => audioManager.Volume.IsDefault); public void TestMutedNotificationMasterVolume() => addVolumeSteps("master volume", () => audioManager.Volume.Value = 0, null, () => audioManager.Volume.IsDefault);
@ -221,6 +233,8 @@ namespace osu.Game.Tests.Visual.Gameplay
public new Task DisposalTask => base.DisposalTask; public new Task DisposalTask => base.DisposalTask;
public IReadOnlyList<Mod> DisplayedMods => MetadataInfo.Mods;
public TestPlayerLoader(Func<Player> createPlayer) public TestPlayerLoader(Func<Player> createPlayer)
: base(createPlayer) : base(createPlayer)
{ {

View File

@ -44,7 +44,7 @@ namespace osu.Game.Screens.Play
private LogoTrackingContainer content; private LogoTrackingContainer content;
private BeatmapMetadataDisplay info; protected BeatmapMetadataDisplay MetadataInfo;
private bool hideOverlays; private bool hideOverlays;
public override bool HideOverlaysOnEnter => hideOverlays; public override bool HideOverlaysOnEnter => hideOverlays;
@ -96,7 +96,7 @@ namespace osu.Game.Screens.Play
RelativeSizeAxes = Axes.Both, RelativeSizeAxes = Axes.Both,
}).WithChildren(new Drawable[] }).WithChildren(new Drawable[]
{ {
info = new BeatmapMetadataDisplay(Beatmap.Value, Mods.Value, content.LogoFacade) MetadataInfo = new BeatmapMetadataDisplay(Beatmap.Value, Mods.Value, content.LogoFacade)
{ {
Alpha = 0, Alpha = 0,
Anchor = Anchor.Centre, Anchor = Anchor.Centre,
@ -138,7 +138,7 @@ namespace osu.Game.Screens.Play
contentIn(); contentIn();
info.Delay(750).FadeIn(500); MetadataInfo.Delay(750).FadeIn(500);
this.Delay(1800).Schedule(pushWhenLoaded); this.Delay(1800).Schedule(pushWhenLoaded);
if (!muteWarningShownOnce.Value) if (!muteWarningShownOnce.Value)
@ -158,7 +158,7 @@ namespace osu.Game.Screens.Play
contentIn(); contentIn();
info.Loading = true; MetadataInfo.Loading = true;
//we will only be resumed if the player has requested a re-run (see ValidForResume setting above) //we will only be resumed if the player has requested a re-run (see ValidForResume setting above)
loadNewPlayer(); loadNewPlayer();
@ -174,7 +174,7 @@ namespace osu.Game.Screens.Play
player.RestartCount = restartCount; player.RestartCount = restartCount;
player.RestartRequested = restartRequested; player.RestartRequested = restartRequested;
LoadTask = LoadComponentAsync(player, _ => info.Loading = false); LoadTask = LoadComponentAsync(player, _ => MetadataInfo.Loading = false);
} }
private void contentIn() private void contentIn()
@ -350,7 +350,7 @@ namespace osu.Game.Screens.Play
} }
} }
private class BeatmapMetadataDisplay : Container protected class BeatmapMetadataDisplay : Container
{ {
private class MetadataLine : Container private class MetadataLine : Container
{ {
@ -379,11 +379,12 @@ namespace osu.Game.Screens.Play
} }
private readonly WorkingBeatmap beatmap; private readonly WorkingBeatmap beatmap;
private readonly IReadOnlyList<Mod> mods;
private readonly Drawable facade; private readonly Drawable facade;
private LoadingAnimation loading; private LoadingAnimation loading;
private Sprite backgroundSprite; private Sprite backgroundSprite;
public IReadOnlyList<Mod> Mods { get; }
public bool Loading public bool Loading
{ {
set set
@ -404,8 +405,9 @@ namespace osu.Game.Screens.Play
public BeatmapMetadataDisplay(WorkingBeatmap beatmap, IReadOnlyList<Mod> mods, Drawable facade) public BeatmapMetadataDisplay(WorkingBeatmap beatmap, IReadOnlyList<Mod> mods, Drawable facade)
{ {
this.beatmap = beatmap; this.beatmap = beatmap;
this.mods = mods;
this.facade = facade; this.facade = facade;
Mods = mods;
} }
[BackgroundDependencyLoader] [BackgroundDependencyLoader]
@ -492,7 +494,7 @@ namespace osu.Game.Screens.Play
Origin = Anchor.TopCentre, Origin = Anchor.TopCentre,
AutoSizeAxes = Axes.Both, AutoSizeAxes = Axes.Both,
Margin = new MarginPadding { Top = 20 }, Margin = new MarginPadding { Top = 20 },
Current = { Value = mods } Current = { Value = Mods }
} }
}, },
} }