mirror of
https://github.com/ppy/osu
synced 2025-01-31 10:22:02 +00:00
Fix running TestScenePlayerLoader
interactively leaving volume in a bad state
This commit is contained in:
parent
adeabc632b
commit
a15e6f19aa
@ -56,6 +56,10 @@ namespace osu.Game.Tests.Visual.Gameplay
|
|||||||
|
|
||||||
private readonly ChangelogOverlay changelogOverlay;
|
private readonly ChangelogOverlay changelogOverlay;
|
||||||
|
|
||||||
|
private double savedTrackVolume;
|
||||||
|
private double savedMasterVolume;
|
||||||
|
private bool savedMutedState;
|
||||||
|
|
||||||
public TestScenePlayerLoader()
|
public TestScenePlayerLoader()
|
||||||
{
|
{
|
||||||
AddRange(new Drawable[]
|
AddRange(new Drawable[]
|
||||||
@ -75,11 +79,7 @@ namespace osu.Game.Tests.Visual.Gameplay
|
|||||||
}
|
}
|
||||||
|
|
||||||
[SetUp]
|
[SetUp]
|
||||||
public void Setup() => Schedule(() =>
|
public void Setup() => Schedule(() => player = null);
|
||||||
{
|
|
||||||
player = null;
|
|
||||||
audioManager.Volume.SetDefault();
|
|
||||||
});
|
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Sets the input manager child to a new test player loader container instance.
|
/// Sets the input manager child to a new test player loader container instance.
|
||||||
@ -147,6 +147,7 @@ namespace osu.Game.Tests.Visual.Gameplay
|
|||||||
moveMouse();
|
moveMouse();
|
||||||
return player?.LoadState == LoadState.Ready;
|
return player?.LoadState == LoadState.Ready;
|
||||||
});
|
});
|
||||||
|
|
||||||
AddRepeatStep("move mouse", moveMouse, 20);
|
AddRepeatStep("move mouse", moveMouse, 20);
|
||||||
|
|
||||||
AddAssert("loader still active", () => loader.IsCurrentScreen());
|
AddAssert("loader still active", () => loader.IsCurrentScreen());
|
||||||
@ -154,6 +155,8 @@ namespace osu.Game.Tests.Visual.Gameplay
|
|||||||
|
|
||||||
void moveMouse()
|
void moveMouse()
|
||||||
{
|
{
|
||||||
|
notificationOverlay.State.Value = Visibility.Hidden;
|
||||||
|
|
||||||
InputManager.MoveMouseTo(
|
InputManager.MoveMouseTo(
|
||||||
loader.VisualSettings.ScreenSpaceDrawQuad.TopLeft
|
loader.VisualSettings.ScreenSpaceDrawQuad.TopLeft
|
||||||
+ (loader.VisualSettings.ScreenSpaceDrawQuad.BottomRight - loader.VisualSettings.ScreenSpaceDrawQuad.TopLeft)
|
+ (loader.VisualSettings.ScreenSpaceDrawQuad.BottomRight - loader.VisualSettings.ScreenSpaceDrawQuad.TopLeft)
|
||||||
@ -274,6 +277,8 @@ namespace osu.Game.Tests.Visual.Gameplay
|
|||||||
AddStep("load player", () => resetPlayer(false, beforeLoad));
|
AddStep("load player", () => resetPlayer(false, beforeLoad));
|
||||||
AddUntilStep("wait for player", () => player?.LoadState == LoadState.Ready);
|
AddUntilStep("wait for player", () => player?.LoadState == LoadState.Ready);
|
||||||
|
|
||||||
|
saveVolumes();
|
||||||
|
|
||||||
AddAssert("check for notification", () => notificationOverlay.UnreadCount.Value == 1);
|
AddAssert("check for notification", () => notificationOverlay.UnreadCount.Value == 1);
|
||||||
AddStep("click notification", () =>
|
AddStep("click notification", () =>
|
||||||
{
|
{
|
||||||
@ -287,6 +292,8 @@ namespace osu.Game.Tests.Visual.Gameplay
|
|||||||
|
|
||||||
AddAssert("check " + volumeName, assert);
|
AddAssert("check " + volumeName, assert);
|
||||||
|
|
||||||
|
restoreVolumes();
|
||||||
|
|
||||||
AddUntilStep("wait for player load", () => player.IsLoaded);
|
AddUntilStep("wait for player load", () => player.IsLoaded);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -294,6 +301,9 @@ namespace osu.Game.Tests.Visual.Gameplay
|
|||||||
[TestCase(false)]
|
[TestCase(false)]
|
||||||
public void TestEpilepsyWarning(bool warning)
|
public void TestEpilepsyWarning(bool warning)
|
||||||
{
|
{
|
||||||
|
saveVolumes();
|
||||||
|
setFullVolume();
|
||||||
|
|
||||||
AddStep("change epilepsy warning", () => epilepsyWarning = warning);
|
AddStep("change epilepsy warning", () => epilepsyWarning = warning);
|
||||||
AddStep("load dummy beatmap", () => resetPlayer(false));
|
AddStep("load dummy beatmap", () => resetPlayer(false));
|
||||||
|
|
||||||
@ -306,6 +316,30 @@ namespace osu.Game.Tests.Visual.Gameplay
|
|||||||
AddUntilStep("sound volume decreased", () => Beatmap.Value.Track.AggregateVolume.Value == 0.25);
|
AddUntilStep("sound volume decreased", () => Beatmap.Value.Track.AggregateVolume.Value == 0.25);
|
||||||
AddUntilStep("sound volume restored", () => Beatmap.Value.Track.AggregateVolume.Value == 1);
|
AddUntilStep("sound volume restored", () => Beatmap.Value.Track.AggregateVolume.Value == 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
restoreVolumes();
|
||||||
|
}
|
||||||
|
|
||||||
|
[Test]
|
||||||
|
public void TestEpilepsyWarningEarlyExit()
|
||||||
|
{
|
||||||
|
saveVolumes();
|
||||||
|
setFullVolume();
|
||||||
|
|
||||||
|
AddStep("set epilepsy warning", () => epilepsyWarning = true);
|
||||||
|
AddStep("load dummy beatmap", () => resetPlayer(false));
|
||||||
|
|
||||||
|
AddUntilStep("wait for current", () => loader.IsCurrentScreen());
|
||||||
|
|
||||||
|
AddUntilStep("wait for epilepsy warning", () => getWarning().Alpha > 0);
|
||||||
|
AddUntilStep("warning is shown", () => getWarning().State.Value == Visibility.Visible);
|
||||||
|
|
||||||
|
AddStep("exit early", () => loader.Exit());
|
||||||
|
|
||||||
|
AddUntilStep("warning is hidden", () => getWarning().State.Value == Visibility.Hidden);
|
||||||
|
AddUntilStep("sound volume restored", () => Beatmap.Value.Track.AggregateVolume.Value == 1);
|
||||||
|
|
||||||
|
restoreVolumes();
|
||||||
}
|
}
|
||||||
|
|
||||||
[TestCase(true, 1.0, false)] // on battery, above cutoff --> no warning
|
[TestCase(true, 1.0, false)] // on battery, above cutoff --> no warning
|
||||||
@ -336,21 +370,34 @@ namespace osu.Game.Tests.Visual.Gameplay
|
|||||||
AddUntilStep("wait for player load", () => player.IsLoaded);
|
AddUntilStep("wait for player load", () => player.IsLoaded);
|
||||||
}
|
}
|
||||||
|
|
||||||
[Test]
|
private void restoreVolumes()
|
||||||
public void TestEpilepsyWarningEarlyExit()
|
|
||||||
{
|
{
|
||||||
AddStep("set epilepsy warning", () => epilepsyWarning = true);
|
AddStep("restore previous volumes", () =>
|
||||||
AddStep("load dummy beatmap", () => resetPlayer(false));
|
{
|
||||||
|
audioManager.VolumeTrack.Value = savedTrackVolume;
|
||||||
|
audioManager.Volume.Value = savedMasterVolume;
|
||||||
|
volumeOverlay.IsMuted.Value = savedMutedState;
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
AddUntilStep("wait for current", () => loader.IsCurrentScreen());
|
private void setFullVolume()
|
||||||
|
{
|
||||||
|
AddStep("set volumes to 100%", () =>
|
||||||
|
{
|
||||||
|
audioManager.VolumeTrack.Value = 1;
|
||||||
|
audioManager.Volume.Value = 1;
|
||||||
|
volumeOverlay.IsMuted.Value = false;
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
AddUntilStep("wait for epilepsy warning", () => getWarning().Alpha > 0);
|
private void saveVolumes()
|
||||||
AddUntilStep("warning is shown", () => getWarning().State.Value == Visibility.Visible);
|
{
|
||||||
|
AddStep("save previous volumes", () =>
|
||||||
AddStep("exit early", () => loader.Exit());
|
{
|
||||||
|
savedTrackVolume = audioManager.VolumeTrack.Value;
|
||||||
AddUntilStep("warning is hidden", () => getWarning().State.Value == Visibility.Hidden);
|
savedMasterVolume = audioManager.Volume.Value;
|
||||||
AddUntilStep("sound volume restored", () => Beatmap.Value.Track.AggregateVolume.Value == 1);
|
savedMutedState = volumeOverlay.IsMuted.Value;
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
private EpilepsyWarning getWarning() => loader.ChildrenOfType<EpilepsyWarning>().SingleOrDefault();
|
private EpilepsyWarning getWarning() => loader.ChildrenOfType<EpilepsyWarning>().SingleOrDefault();
|
||||||
|
Loading…
Reference in New Issue
Block a user