Adjust test scene to avoid cross-test interference

* Move steps from ctor to a separate basic test.
* Wait for barrage to complete in basic test, as not doing so polluted
  state of other tests.
* Reset score processor after every test.
This commit is contained in:
Bartłomiej Dach 2021-06-07 13:13:24 +02:00
parent 0531c2dcd9
commit 1b4771655a

View File

@ -30,15 +30,22 @@ namespace osu.Game.Tests.Visual.Gameplay
{
public class TestSceneHitErrorMeter : OsuTestScene
{
[Cached]
private ScoreProcessor scoreProcessor = new ScoreProcessor();
[Cached(typeof(ScoreProcessor))]
private TestScoreProcessor scoreProcessor = new TestScoreProcessor();
[Cached(typeof(DrawableRuleset))]
private TestDrawableRuleset drawableRuleset = new TestDrawableRuleset();
public TestSceneHitErrorMeter()
[SetUpSteps]
public void SetUp()
{
recreateDisplay(new OsuHitWindows(), 5);
AddStep("reset score processor", () => scoreProcessor.Reset());
}
[Test]
public void TestBasic()
{
AddStep("create display", () => recreateDisplay(new OsuHitWindows(), 5));
AddRepeatStep("New random judgement", () => newJudgement(), 40);
@ -46,12 +53,11 @@ namespace osu.Game.Tests.Visual.Gameplay
AddRepeatStep("New max positive", () => newJudgement(drawableRuleset.HitWindows.WindowFor(HitResult.Meh)), 20);
AddStep("New fixed judgement (50ms)", () => newJudgement(50));
ScheduledDelegate del = null;
AddStep("Judgement barrage", () =>
{
int runCount = 0;
ScheduledDelegate del = null;
del = Scheduler.AddDelayed(() =>
{
newJudgement(runCount++ / 10f);
@ -61,6 +67,7 @@ namespace osu.Game.Tests.Visual.Gameplay
del?.Cancel();
}, 10, true);
});
AddUntilStep("wait for barrage", () => del.Cancelled);
}
[Test]
@ -211,5 +218,10 @@ namespace osu.Game.Tests.Visual.Gameplay
public override void CancelResume() => throw new NotImplementedException();
}
private class TestScoreProcessor : ScoreProcessor
{
public void Reset() => base.Reset(false);
}
}
}