mirror of
https://github.com/ppy/osu
synced 2024-12-25 08:12:41 +00:00
Merge pull request #18915 from peppy/slider-snaking-test-refactoring
Apply various refactorings to `TestSceneSliderSnaking`
This commit is contained in:
commit
d630b62cfc
@ -29,7 +29,7 @@ namespace osu.Game.Rulesets.Catch.Tests
|
||||
AddStep("change component scale", () => Player.ChildrenOfType<LegacyScoreCounter>().First().Scale = new Vector2(2f));
|
||||
AddStep("update target", () => Player.ChildrenOfType<SkinnableTargetContainer>().ForEach(LegacySkin.UpdateDrawableTarget));
|
||||
AddStep("exit player", () => Player.Exit());
|
||||
CreateTest(null);
|
||||
CreateTest();
|
||||
}
|
||||
|
||||
AddAssert("legacy HUD combo counter hidden", () =>
|
||||
|
@ -66,10 +66,7 @@ namespace osu.Game.Rulesets.Osu.Tests
|
||||
drawableSlider = null;
|
||||
});
|
||||
|
||||
[SetUpSteps]
|
||||
public override void SetUpSteps()
|
||||
{
|
||||
}
|
||||
protected override bool HasCustomSteps => true;
|
||||
|
||||
[TestCase(0)]
|
||||
[TestCase(1)]
|
||||
@ -77,7 +74,7 @@ namespace osu.Game.Rulesets.Osu.Tests
|
||||
public void TestSnakingEnabled(int sliderIndex)
|
||||
{
|
||||
AddStep("enable autoplay", () => autoplay = true);
|
||||
base.SetUpSteps();
|
||||
CreateTest();
|
||||
AddUntilStep("wait for track to start running", () => Beatmap.Value.Track.IsRunning);
|
||||
|
||||
retrieveSlider(sliderIndex);
|
||||
@ -101,7 +98,7 @@ namespace osu.Game.Rulesets.Osu.Tests
|
||||
public void TestSnakingDisabled(int sliderIndex)
|
||||
{
|
||||
AddStep("have autoplay", () => autoplay = true);
|
||||
base.SetUpSteps();
|
||||
CreateTest();
|
||||
AddUntilStep("wait for track to start running", () => Beatmap.Value.Track.IsRunning);
|
||||
|
||||
retrieveSlider(sliderIndex);
|
||||
@ -121,8 +118,7 @@ namespace osu.Game.Rulesets.Osu.Tests
|
||||
{
|
||||
AddStep("enable autoplay", () => autoplay = true);
|
||||
setSnaking(true);
|
||||
base.SetUpSteps();
|
||||
|
||||
CreateTest();
|
||||
// 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
|
||||
addCheckPositionChangeSteps(() => 16600, getSliderRepeat, positionAlmostSame);
|
||||
@ -133,15 +129,14 @@ namespace osu.Game.Rulesets.Osu.Tests
|
||||
{
|
||||
AddStep("disable autoplay", () => autoplay = false);
|
||||
setSnaking(true);
|
||||
base.SetUpSteps();
|
||||
|
||||
CreateTest();
|
||||
addCheckPositionChangeSteps(() => 16600, getSliderRepeat, positionDecreased);
|
||||
}
|
||||
|
||||
private void retrieveSlider(int index)
|
||||
{
|
||||
AddStep("retrieve slider at index", () => slider = (Slider)beatmap.HitObjects[index]);
|
||||
addSeekStep(() => slider);
|
||||
addSeekStep(() => slider.StartTime);
|
||||
AddUntilStep("retrieve drawable slider", () =>
|
||||
(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));
|
||||
AddUntilStep("wait for seek to finish", () => Precision.AlmostEquals(slider().StartTime, 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));
|
||||
AddStep("seek to time", () => Player.GameplayClockContainer.Seek(getTime()));
|
||||
AddUntilStep("wait for seek to finish", () => Precision.AlmostEquals(getTime(), Player.DrawableRuleset.FrameStableClock.CurrentTime, 100));
|
||||
}
|
||||
|
||||
protected override IBeatmap CreateBeatmap(RulesetInfo ruleset) => new Beatmap { HitObjects = createHitObjects() };
|
||||
|
@ -121,7 +121,7 @@ namespace osu.Game.Tests.Visual.Gameplay
|
||||
|
||||
private void createPlayerTest()
|
||||
{
|
||||
CreateTest(null);
|
||||
CreateTest();
|
||||
|
||||
AddAssert("storyboard loaded", () => Player.Beatmap.Value.Storyboard != null);
|
||||
waitUntilStoryboardSamplesPlay();
|
||||
|
@ -53,7 +53,7 @@ namespace osu.Game.Tests.Visual.Gameplay
|
||||
public void TestStoryboardSkipOutro()
|
||||
{
|
||||
AddStep("set storyboard duration to long", () => currentStoryboardDuration = 200000);
|
||||
CreateTest(null);
|
||||
CreateTest();
|
||||
AddUntilStep("completion set by processor", () => Player.ScoreProcessor.HasCompleted.Value);
|
||||
AddStep("skip outro", () => InputManager.Key(osuTK.Input.Key.Space));
|
||||
AddUntilStep("player is no longer current screen", () => !Player.IsCurrentScreen());
|
||||
@ -63,7 +63,7 @@ namespace osu.Game.Tests.Visual.Gameplay
|
||||
[Test]
|
||||
public void TestStoryboardNoSkipOutro()
|
||||
{
|
||||
CreateTest(null);
|
||||
CreateTest();
|
||||
AddUntilStep("storyboard ends", () => Player.GameplayClockContainer.GameplayClock.CurrentTime >= currentStoryboardDuration);
|
||||
AddUntilStep("wait for score shown", () => Player.IsScoreShown);
|
||||
}
|
||||
@ -71,7 +71,7 @@ namespace osu.Game.Tests.Visual.Gameplay
|
||||
[Test]
|
||||
public void TestStoryboardExitDuringOutroStillExits()
|
||||
{
|
||||
CreateTest(null);
|
||||
CreateTest();
|
||||
AddUntilStep("completion set by processor", () => Player.ScoreProcessor.HasCompleted.Value);
|
||||
AddStep("exit via pause", () => Player.ExitViaPause());
|
||||
AddAssert("player exited", () => !Player.IsCurrentScreen() && Player.GetChildScreen() == null);
|
||||
@ -81,7 +81,7 @@ namespace osu.Game.Tests.Visual.Gameplay
|
||||
[TestCase(true)]
|
||||
public void TestStoryboardToggle(bool enabledAtBeginning)
|
||||
{
|
||||
CreateTest(null);
|
||||
CreateTest();
|
||||
AddStep($"{(enabledAtBeginning ? "enable" : "disable")} storyboard", () => LocalConfig.SetValue(OsuSetting.ShowStoryboard, enabledAtBeginning));
|
||||
AddStep("toggle storyboard", () => LocalConfig.SetValue(OsuSetting.ShowStoryboard, !enabledAtBeginning));
|
||||
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();
|
||||
|
||||
CreateTest(null);
|
||||
CreateTest();
|
||||
AddUntilStep("completion set by processor", () => Player.ScoreProcessor.HasCompleted.Value);
|
||||
AddUntilStep("skip overlay content becomes visible", () => fadeContainer().State == Visibility.Visible);
|
||||
|
||||
@ -144,7 +144,7 @@ namespace osu.Game.Tests.Visual.Gameplay
|
||||
[Test]
|
||||
public void TestPerformExitNoOutro()
|
||||
{
|
||||
CreateTest(null);
|
||||
CreateTest();
|
||||
AddStep("disable storyboard", () => LocalConfig.SetValue(OsuSetting.ShowStoryboard, false));
|
||||
AddUntilStep("completion set by processor", () => Player.ScoreProcessor.HasCompleted.Value);
|
||||
AddStep("exit via pause", () => Player.ExitViaPause());
|
||||
|
@ -8,6 +8,7 @@ using osu.Framework.Allocation;
|
||||
using osu.Framework.Bindables;
|
||||
using osu.Framework.Graphics;
|
||||
using osu.Framework.Graphics.Containers;
|
||||
using osu.Framework.Logging;
|
||||
using osu.Framework.Timing;
|
||||
|
||||
namespace osu.Game.Screens.Play
|
||||
@ -101,6 +102,8 @@ namespace osu.Game.Screens.Play
|
||||
/// <param name="time">The destination time to seek to.</param>
|
||||
public virtual void Seek(double time)
|
||||
{
|
||||
Logger.Log($"{nameof(GameplayClockContainer)} seeking to {time}");
|
||||
|
||||
AdjustableSource.Seek(time);
|
||||
|
||||
// Manually process to make sure the gameplay clock is correctly updated after a seek.
|
||||
|
@ -39,10 +39,10 @@ namespace osu.Game.Tests.Visual
|
||||
base.SetUpSteps();
|
||||
|
||||
if (!HasCustomSteps)
|
||||
CreateTest(null);
|
||||
CreateTest();
|
||||
}
|
||||
|
||||
protected void CreateTest(Action action)
|
||||
protected void CreateTest([CanBeNull] Action action = null)
|
||||
{
|
||||
if (action != null && !HasCustomSteps)
|
||||
throw new InvalidOperationException($"Cannot add custom test steps without {nameof(HasCustomSteps)} being set.");
|
||||
|
Loading…
Reference in New Issue
Block a user