Update TestSceneStoryboardWithOutro.cs

- Construct storyboard in CreateWorkingBeatmap()
- Use GameplayClockContainer.GameplayClock.CurrentTime
- Remove unnecessary lines
This commit is contained in:
Christine Chen 2021-04-17 13:57:32 -04:00
parent 5a015290b9
commit 7f5b1e84a1

View File

@ -3,7 +3,6 @@
using System.Threading.Tasks;
using NUnit.Framework;
using osu.Framework.Allocation;
using osu.Framework.Graphics;
using osu.Framework.Screens;
using osu.Framework.Testing;
@ -13,7 +12,6 @@ using osu.Game.Rulesets;
using osu.Game.Rulesets.Osu;
using osu.Game.Rulesets.Osu.Objects;
using osu.Game.Scoring;
using osu.Game.Screens.Play;
using osu.Game.Screens.Ranking;
using osu.Game.Storyboards;
using osuTK;
@ -24,28 +22,14 @@ namespace osu.Game.Tests.Visual.Gameplay
{
protected new OutroPlayer Player => (OutroPlayer)base.Player;
private Storyboard storyboard;
private const double storyboard_duration = 2000;
[BackgroundDependencyLoader]
private void load(OsuConfigManager config)
{
config.SetValue(OsuSetting.ShowStoryboard, true);
storyboard = new Storyboard();
var sprite = new StoryboardSprite("unknown", Anchor.TopLeft, Vector2.Zero);
sprite.TimelineGroup.Alpha.Add(Easing.None, 0, storyboard_duration, 1, 0);
storyboard.GetLayer("Background").Add(sprite);
}
[SetUpSteps]
public override void SetUpSteps()
{
base.SetUpSteps();
AddStep("ignore user settings", () =>
{
Player.DimmableStoryboard.IgnoreUserSettings.Value = true;
});
AddStep("enable storyboard", () => LocalConfig.SetValue(OsuSetting.ShowStoryboard, true));
AddStep("set dim level to 0", () => LocalConfig.SetValue<double>(OsuSetting.DimLevel, 0));
}
[Test]
@ -61,7 +45,7 @@ namespace osu.Game.Tests.Visual.Gameplay
public void TestStoryboardNoSkipOutro()
{
AddUntilStep("storyboard loaded", () => Player.Beatmap.Value.StoryboardLoaded);
AddUntilStep("storyboard ends", () => Player.HUDOverlay.Progress.ReferenceClock.CurrentTime >= storyboard_duration);
AddUntilStep("storyboard ends", () => Player.GameplayClockContainer.GameplayClock.CurrentTime >= storyboard_duration);
AddUntilStep("wait for score shown", () => Player.IsScoreShown);
}
@ -87,8 +71,18 @@ namespace osu.Game.Tests.Visual.Gameplay
return beatmap;
}
protected override WorkingBeatmap CreateWorkingBeatmap(IBeatmap beatmap, Storyboard storyboard = null) =>
new ClockBackedTestWorkingBeatmap(beatmap, storyboard ?? this.storyboard, Clock, Audio);
protected override WorkingBeatmap CreateWorkingBeatmap(IBeatmap beatmap, Storyboard storyboard = null)
{
if (storyboard == null)
{
storyboard = new Storyboard();
var sprite = new StoryboardSprite("unknown", Anchor.TopLeft, Vector2.Zero);
sprite.TimelineGroup.Alpha.Add(Easing.None, 0, storyboard_duration, 1, 0);
storyboard.GetLayer("Background").Add(sprite);
}
return base.CreateWorkingBeatmap(beatmap, storyboard);
}
protected class OutroPlayer : TestPlayer
{
@ -96,8 +90,6 @@ namespace osu.Game.Tests.Visual.Gameplay
public bool IsScoreShown => !this.IsCurrentScreen() && this.GetChildScreen() is ResultsScreen;
public new DimmableStoryboard DimmableStoryboard => base.DimmableStoryboard;
public OutroPlayer()
: base(false)
{
@ -105,7 +97,6 @@ namespace osu.Game.Tests.Visual.Gameplay
protected override Task ImportScore(Score score)
{
// avoid database errors from trying to store the score
return Task.CompletedTask;
}
}