mirror of
https://github.com/ppy/osu.git
synced 2025-02-22 18:53:21 +08:00
Replace dodgy SetUpSteps
overriding with usage of HasCustomSteps
This commit is contained in:
parent
2f264aaf0a
commit
35745c83b7
@ -29,7 +29,7 @@ namespace osu.Game.Rulesets.Catch.Tests
|
|||||||
AddStep("change component scale", () => Player.ChildrenOfType<LegacyScoreCounter>().First().Scale = new Vector2(2f));
|
AddStep("change component scale", () => Player.ChildrenOfType<LegacyScoreCounter>().First().Scale = new Vector2(2f));
|
||||||
AddStep("update target", () => Player.ChildrenOfType<SkinnableTargetContainer>().ForEach(LegacySkin.UpdateDrawableTarget));
|
AddStep("update target", () => Player.ChildrenOfType<SkinnableTargetContainer>().ForEach(LegacySkin.UpdateDrawableTarget));
|
||||||
AddStep("exit player", () => Player.Exit());
|
AddStep("exit player", () => Player.Exit());
|
||||||
CreateTest(null);
|
CreateTest();
|
||||||
}
|
}
|
||||||
|
|
||||||
AddAssert("legacy HUD combo counter hidden", () =>
|
AddAssert("legacy HUD combo counter hidden", () =>
|
||||||
|
@ -66,10 +66,7 @@ namespace osu.Game.Rulesets.Osu.Tests
|
|||||||
drawableSlider = null;
|
drawableSlider = null;
|
||||||
});
|
});
|
||||||
|
|
||||||
[SetUpSteps]
|
protected override bool HasCustomSteps => true;
|
||||||
public override void SetUpSteps()
|
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
||||||
[TestCase(0)]
|
[TestCase(0)]
|
||||||
[TestCase(1)]
|
[TestCase(1)]
|
||||||
@ -77,7 +74,7 @@ namespace osu.Game.Rulesets.Osu.Tests
|
|||||||
public void TestSnakingEnabled(int sliderIndex)
|
public void TestSnakingEnabled(int sliderIndex)
|
||||||
{
|
{
|
||||||
AddStep("enable autoplay", () => autoplay = true);
|
AddStep("enable autoplay", () => autoplay = true);
|
||||||
base.SetUpSteps();
|
CreateTest();
|
||||||
AddUntilStep("wait for track to start running", () => Beatmap.Value.Track.IsRunning);
|
AddUntilStep("wait for track to start running", () => Beatmap.Value.Track.IsRunning);
|
||||||
|
|
||||||
retrieveSlider(sliderIndex);
|
retrieveSlider(sliderIndex);
|
||||||
@ -101,7 +98,7 @@ namespace osu.Game.Rulesets.Osu.Tests
|
|||||||
public void TestSnakingDisabled(int sliderIndex)
|
public void TestSnakingDisabled(int sliderIndex)
|
||||||
{
|
{
|
||||||
AddStep("have autoplay", () => autoplay = true);
|
AddStep("have autoplay", () => autoplay = true);
|
||||||
base.SetUpSteps();
|
CreateTest();
|
||||||
AddUntilStep("wait for track to start running", () => Beatmap.Value.Track.IsRunning);
|
AddUntilStep("wait for track to start running", () => Beatmap.Value.Track.IsRunning);
|
||||||
|
|
||||||
retrieveSlider(sliderIndex);
|
retrieveSlider(sliderIndex);
|
||||||
@ -121,8 +118,7 @@ namespace osu.Game.Rulesets.Osu.Tests
|
|||||||
{
|
{
|
||||||
AddStep("enable autoplay", () => autoplay = true);
|
AddStep("enable autoplay", () => autoplay = true);
|
||||||
setSnaking(true);
|
setSnaking(true);
|
||||||
base.SetUpSteps();
|
CreateTest();
|
||||||
|
|
||||||
// repeat might have a chance to update its position depending on where in the frame its hit,
|
// repeat might have a chance to update its position depending on where in the frame its hit,
|
||||||
// so some leniency is allowed here instead of checking strict equality
|
// so some leniency is allowed here instead of checking strict equality
|
||||||
addCheckPositionChangeSteps(() => 16600, getSliderRepeat, positionAlmostSame);
|
addCheckPositionChangeSteps(() => 16600, getSliderRepeat, positionAlmostSame);
|
||||||
@ -133,15 +129,14 @@ namespace osu.Game.Rulesets.Osu.Tests
|
|||||||
{
|
{
|
||||||
AddStep("disable autoplay", () => autoplay = false);
|
AddStep("disable autoplay", () => autoplay = false);
|
||||||
setSnaking(true);
|
setSnaking(true);
|
||||||
base.SetUpSteps();
|
CreateTest();
|
||||||
|
|
||||||
addCheckPositionChangeSteps(() => 16600, getSliderRepeat, positionDecreased);
|
addCheckPositionChangeSteps(() => 16600, getSliderRepeat, positionDecreased);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void retrieveSlider(int index)
|
private void retrieveSlider(int index)
|
||||||
{
|
{
|
||||||
AddStep("retrieve slider at index", () => slider = (Slider)beatmap.HitObjects[index]);
|
AddStep("retrieve slider at index", () => slider = (Slider)beatmap.HitObjects[index]);
|
||||||
addSeekStep(() => slider);
|
addSeekStep(() => slider.StartTime);
|
||||||
AddUntilStep("retrieve drawable slider", () =>
|
AddUntilStep("retrieve drawable slider", () =>
|
||||||
(drawableSlider = (DrawableSlider)Player.DrawableRuleset.Playfield.AllHitObjects.SingleOrDefault(d => d.HitObject == slider)) != null);
|
(drawableSlider = (DrawableSlider)Player.DrawableRuleset.Playfield.AllHitObjects.SingleOrDefault(d => d.HitObject == slider)) != null);
|
||||||
}
|
}
|
||||||
@ -205,16 +200,10 @@ namespace osu.Game.Rulesets.Osu.Tests
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
private void addSeekStep(Func<Slider> slider)
|
private void addSeekStep(Func<double> getTime)
|
||||||
{
|
{
|
||||||
AddStep("seek to slider", () => Player.GameplayClockContainer.Seek(slider().StartTime));
|
AddStep("seek to time", () => Player.GameplayClockContainer.Seek(getTime()));
|
||||||
AddUntilStep("wait for seek to finish", () => Precision.AlmostEquals(slider().StartTime, Player.DrawableRuleset.FrameStableClock.CurrentTime, 100));
|
AddUntilStep("wait for seek to finish", () => Precision.AlmostEquals(getTime(), Player.DrawableRuleset.FrameStableClock.CurrentTime, 100));
|
||||||
}
|
|
||||||
|
|
||||||
private void addSeekStep(Func<double> time)
|
|
||||||
{
|
|
||||||
AddStep("seek to time", () => Player.GameplayClockContainer.Seek(time()));
|
|
||||||
AddUntilStep("wait for seek to finish", () => Precision.AlmostEquals(time(), Player.DrawableRuleset.FrameStableClock.CurrentTime, 100));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
protected override IBeatmap CreateBeatmap(RulesetInfo ruleset) => new Beatmap { HitObjects = createHitObjects() };
|
protected override IBeatmap CreateBeatmap(RulesetInfo ruleset) => new Beatmap { HitObjects = createHitObjects() };
|
||||||
|
@ -121,7 +121,7 @@ namespace osu.Game.Tests.Visual.Gameplay
|
|||||||
|
|
||||||
private void createPlayerTest()
|
private void createPlayerTest()
|
||||||
{
|
{
|
||||||
CreateTest(null);
|
CreateTest();
|
||||||
|
|
||||||
AddAssert("storyboard loaded", () => Player.Beatmap.Value.Storyboard != null);
|
AddAssert("storyboard loaded", () => Player.Beatmap.Value.Storyboard != null);
|
||||||
waitUntilStoryboardSamplesPlay();
|
waitUntilStoryboardSamplesPlay();
|
||||||
|
@ -53,7 +53,7 @@ namespace osu.Game.Tests.Visual.Gameplay
|
|||||||
public void TestStoryboardSkipOutro()
|
public void TestStoryboardSkipOutro()
|
||||||
{
|
{
|
||||||
AddStep("set storyboard duration to long", () => currentStoryboardDuration = 200000);
|
AddStep("set storyboard duration to long", () => currentStoryboardDuration = 200000);
|
||||||
CreateTest(null);
|
CreateTest();
|
||||||
AddUntilStep("completion set by processor", () => Player.ScoreProcessor.HasCompleted.Value);
|
AddUntilStep("completion set by processor", () => Player.ScoreProcessor.HasCompleted.Value);
|
||||||
AddStep("skip outro", () => InputManager.Key(osuTK.Input.Key.Space));
|
AddStep("skip outro", () => InputManager.Key(osuTK.Input.Key.Space));
|
||||||
AddUntilStep("player is no longer current screen", () => !Player.IsCurrentScreen());
|
AddUntilStep("player is no longer current screen", () => !Player.IsCurrentScreen());
|
||||||
@ -63,7 +63,7 @@ namespace osu.Game.Tests.Visual.Gameplay
|
|||||||
[Test]
|
[Test]
|
||||||
public void TestStoryboardNoSkipOutro()
|
public void TestStoryboardNoSkipOutro()
|
||||||
{
|
{
|
||||||
CreateTest(null);
|
CreateTest();
|
||||||
AddUntilStep("storyboard ends", () => Player.GameplayClockContainer.GameplayClock.CurrentTime >= currentStoryboardDuration);
|
AddUntilStep("storyboard ends", () => Player.GameplayClockContainer.GameplayClock.CurrentTime >= currentStoryboardDuration);
|
||||||
AddUntilStep("wait for score shown", () => Player.IsScoreShown);
|
AddUntilStep("wait for score shown", () => Player.IsScoreShown);
|
||||||
}
|
}
|
||||||
@ -71,7 +71,7 @@ namespace osu.Game.Tests.Visual.Gameplay
|
|||||||
[Test]
|
[Test]
|
||||||
public void TestStoryboardExitDuringOutroStillExits()
|
public void TestStoryboardExitDuringOutroStillExits()
|
||||||
{
|
{
|
||||||
CreateTest(null);
|
CreateTest();
|
||||||
AddUntilStep("completion set by processor", () => Player.ScoreProcessor.HasCompleted.Value);
|
AddUntilStep("completion set by processor", () => Player.ScoreProcessor.HasCompleted.Value);
|
||||||
AddStep("exit via pause", () => Player.ExitViaPause());
|
AddStep("exit via pause", () => Player.ExitViaPause());
|
||||||
AddAssert("player exited", () => !Player.IsCurrentScreen() && Player.GetChildScreen() == null);
|
AddAssert("player exited", () => !Player.IsCurrentScreen() && Player.GetChildScreen() == null);
|
||||||
@ -81,7 +81,7 @@ namespace osu.Game.Tests.Visual.Gameplay
|
|||||||
[TestCase(true)]
|
[TestCase(true)]
|
||||||
public void TestStoryboardToggle(bool enabledAtBeginning)
|
public void TestStoryboardToggle(bool enabledAtBeginning)
|
||||||
{
|
{
|
||||||
CreateTest(null);
|
CreateTest();
|
||||||
AddStep($"{(enabledAtBeginning ? "enable" : "disable")} storyboard", () => LocalConfig.SetValue(OsuSetting.ShowStoryboard, enabledAtBeginning));
|
AddStep($"{(enabledAtBeginning ? "enable" : "disable")} storyboard", () => LocalConfig.SetValue(OsuSetting.ShowStoryboard, enabledAtBeginning));
|
||||||
AddStep("toggle storyboard", () => LocalConfig.SetValue(OsuSetting.ShowStoryboard, !enabledAtBeginning));
|
AddStep("toggle storyboard", () => LocalConfig.SetValue(OsuSetting.ShowStoryboard, !enabledAtBeginning));
|
||||||
AddUntilStep("wait for score shown", () => Player.IsScoreShown);
|
AddUntilStep("wait for score shown", () => Player.IsScoreShown);
|
||||||
@ -130,7 +130,7 @@ namespace osu.Game.Tests.Visual.Gameplay
|
|||||||
{
|
{
|
||||||
SkipOverlay.FadeContainer fadeContainer() => Player.ChildrenOfType<SkipOverlay.FadeContainer>().First();
|
SkipOverlay.FadeContainer fadeContainer() => Player.ChildrenOfType<SkipOverlay.FadeContainer>().First();
|
||||||
|
|
||||||
CreateTest(null);
|
CreateTest();
|
||||||
AddUntilStep("completion set by processor", () => Player.ScoreProcessor.HasCompleted.Value);
|
AddUntilStep("completion set by processor", () => Player.ScoreProcessor.HasCompleted.Value);
|
||||||
AddUntilStep("skip overlay content becomes visible", () => fadeContainer().State == Visibility.Visible);
|
AddUntilStep("skip overlay content becomes visible", () => fadeContainer().State == Visibility.Visible);
|
||||||
|
|
||||||
@ -144,7 +144,7 @@ namespace osu.Game.Tests.Visual.Gameplay
|
|||||||
[Test]
|
[Test]
|
||||||
public void TestPerformExitNoOutro()
|
public void TestPerformExitNoOutro()
|
||||||
{
|
{
|
||||||
CreateTest(null);
|
CreateTest();
|
||||||
AddStep("disable storyboard", () => LocalConfig.SetValue(OsuSetting.ShowStoryboard, false));
|
AddStep("disable storyboard", () => LocalConfig.SetValue(OsuSetting.ShowStoryboard, false));
|
||||||
AddUntilStep("completion set by processor", () => Player.ScoreProcessor.HasCompleted.Value);
|
AddUntilStep("completion set by processor", () => Player.ScoreProcessor.HasCompleted.Value);
|
||||||
AddStep("exit via pause", () => Player.ExitViaPause());
|
AddStep("exit via pause", () => Player.ExitViaPause());
|
||||||
|
@ -39,10 +39,10 @@ namespace osu.Game.Tests.Visual
|
|||||||
base.SetUpSteps();
|
base.SetUpSteps();
|
||||||
|
|
||||||
if (!HasCustomSteps)
|
if (!HasCustomSteps)
|
||||||
CreateTest(null);
|
CreateTest();
|
||||||
}
|
}
|
||||||
|
|
||||||
protected void CreateTest(Action action)
|
protected void CreateTest([CanBeNull] Action action = null)
|
||||||
{
|
{
|
||||||
if (action != null && !HasCustomSteps)
|
if (action != null && !HasCustomSteps)
|
||||||
throw new InvalidOperationException($"Cannot add custom test steps without {nameof(HasCustomSteps)} being set.");
|
throw new InvalidOperationException($"Cannot add custom test steps without {nameof(HasCustomSteps)} being set.");
|
||||||
|
Loading…
Reference in New Issue
Block a user