Restructure test scene to demonstrate failure

This commit is contained in:
Bartłomiej Dach 2023-01-18 21:41:00 +01:00
parent 761298cd8e
commit 06212bca51
No known key found for this signature in database
1 changed files with 26 additions and 9 deletions

View File

@ -25,35 +25,33 @@ public partial class TestSceneJudgementCounter : OsuTestScene
private JudgementTally judgementTally = null!; private JudgementTally judgementTally = null!;
private TestJudgementCounterDisplay counterDisplay = null!; private TestJudgementCounterDisplay counterDisplay = null!;
private DependencyProvidingContainer content = null!;
protected override Container<Drawable> Content => content;
private readonly Bindable<JudgementResult> lastJudgementResult = new Bindable<JudgementResult>(); private readonly Bindable<JudgementResult> lastJudgementResult = new Bindable<JudgementResult>();
private int iteration; private int iteration;
[SetUpSteps] [SetUpSteps]
public void SetupSteps() => AddStep("Create components", () => public void SetUpSteps() => AddStep("Create components", () =>
{ {
var ruleset = CreateRuleset(); var ruleset = CreateRuleset();
Debug.Assert(ruleset != null); Debug.Assert(ruleset != null);
scoreProcessor = new ScoreProcessor(ruleset); scoreProcessor = new ScoreProcessor(ruleset);
Child = new DependencyProvidingContainer base.Content.Child = new DependencyProvidingContainer
{ {
RelativeSizeAxes = Axes.Both, RelativeSizeAxes = Axes.Both,
CachedDependencies = new (Type, object)[] { (typeof(ScoreProcessor), scoreProcessor), (typeof(Ruleset), ruleset) }, CachedDependencies = new (Type, object)[] { (typeof(ScoreProcessor), scoreProcessor), (typeof(Ruleset), ruleset) },
Children = new Drawable[] Children = new Drawable[]
{ {
judgementTally = new JudgementTally(), judgementTally = new JudgementTally(),
new DependencyProvidingContainer content = new DependencyProvidingContainer
{ {
RelativeSizeAxes = Axes.Both, RelativeSizeAxes = Axes.Both,
CachedDependencies = new (Type, object)[] { (typeof(JudgementTally), judgementTally) }, CachedDependencies = new (Type, object)[] { (typeof(JudgementTally), judgementTally) },
Child = counterDisplay = new TestJudgementCounterDisplay
{
Margin = new MarginPadding { Top = 100 },
Anchor = Anchor.TopCentre,
Origin = Anchor.TopCentre
}
} }
}, },
}; };
@ -78,6 +76,8 @@ private void applyOneJudgement(HitResult result)
[Test] [Test]
public void TestAddJudgementsToCounters() public void TestAddJudgementsToCounters()
{ {
AddStep("create counter", () => Child = counterDisplay = new TestJudgementCounterDisplay());
AddRepeatStep("Add judgement", () => applyOneJudgement(HitResult.Great), 2); AddRepeatStep("Add judgement", () => applyOneJudgement(HitResult.Great), 2);
AddRepeatStep("Add judgement", () => applyOneJudgement(HitResult.Miss), 2); AddRepeatStep("Add judgement", () => applyOneJudgement(HitResult.Miss), 2);
AddRepeatStep("Add judgement", () => applyOneJudgement(HitResult.Meh), 2); AddRepeatStep("Add judgement", () => applyOneJudgement(HitResult.Meh), 2);
@ -86,6 +86,8 @@ public void TestAddJudgementsToCounters()
[Test] [Test]
public void TestAddWhilstHidden() public void TestAddWhilstHidden()
{ {
AddStep("create counter", () => Child = counterDisplay = new TestJudgementCounterDisplay());
AddRepeatStep("Add judgement", () => applyOneJudgement(HitResult.LargeTickHit), 2); AddRepeatStep("Add judgement", () => applyOneJudgement(HitResult.LargeTickHit), 2);
AddAssert("Check value added whilst hidden", () => hiddenCount() == 2); AddAssert("Check value added whilst hidden", () => hiddenCount() == 2);
AddStep("Show all judgements", () => counterDisplay.Mode.Value = JudgementCounterDisplay.DisplayMode.All); AddStep("Show all judgements", () => counterDisplay.Mode.Value = JudgementCounterDisplay.DisplayMode.All);
@ -94,6 +96,8 @@ public void TestAddWhilstHidden()
[Test] [Test]
public void TestChangeFlowDirection() public void TestChangeFlowDirection()
{ {
AddStep("create counter", () => Child = counterDisplay = new TestJudgementCounterDisplay());
AddStep("Set direction vertical", () => counterDisplay.FlowDirection.Value = Direction.Vertical); AddStep("Set direction vertical", () => counterDisplay.FlowDirection.Value = Direction.Vertical);
AddStep("Set direction horizontal", () => counterDisplay.FlowDirection.Value = Direction.Horizontal); AddStep("Set direction horizontal", () => counterDisplay.FlowDirection.Value = Direction.Horizontal);
} }
@ -101,6 +105,8 @@ public void TestChangeFlowDirection()
[Test] [Test]
public void TestToggleJudgementNames() public void TestToggleJudgementNames()
{ {
AddStep("create counter", () => Child = counterDisplay = new TestJudgementCounterDisplay());
AddStep("Hide judgement names", () => counterDisplay.ShowJudgementNames.Value = false); AddStep("Hide judgement names", () => counterDisplay.ShowJudgementNames.Value = false);
AddWaitStep("wait some", 2); AddWaitStep("wait some", 2);
AddAssert("Assert hidden", () => counterDisplay.CounterFlow.Children.First().ResultName.Alpha == 0); AddAssert("Assert hidden", () => counterDisplay.CounterFlow.Children.First().ResultName.Alpha == 0);
@ -112,6 +118,8 @@ public void TestToggleJudgementNames()
[Test] [Test]
public void TestHideMaxValue() public void TestHideMaxValue()
{ {
AddStep("create counter", () => Child = counterDisplay = new TestJudgementCounterDisplay());
AddStep("Hide max judgement", () => counterDisplay.ShowMaxJudgement.Value = false); AddStep("Hide max judgement", () => counterDisplay.ShowMaxJudgement.Value = false);
AddWaitStep("wait some", 2); AddWaitStep("wait some", 2);
AddAssert("Check max hidden", () => counterDisplay.CounterFlow.ChildrenOfType<JudgementCounter>().First().Alpha == 0); AddAssert("Check max hidden", () => counterDisplay.CounterFlow.ChildrenOfType<JudgementCounter>().First().Alpha == 0);
@ -121,6 +129,8 @@ public void TestHideMaxValue()
[Test] [Test]
public void TestCycleDisplayModes() public void TestCycleDisplayModes()
{ {
AddStep("create counter", () => Child = counterDisplay = new TestJudgementCounterDisplay());
AddStep("Show basic judgements", () => counterDisplay.Mode.Value = JudgementCounterDisplay.DisplayMode.Simple); AddStep("Show basic judgements", () => counterDisplay.Mode.Value = JudgementCounterDisplay.DisplayMode.Simple);
AddWaitStep("wait some", 2); AddWaitStep("wait some", 2);
AddAssert("Check only basic", () => counterDisplay.CounterFlow.ChildrenOfType<JudgementCounter>().Last().Alpha == 0); AddAssert("Check only basic", () => counterDisplay.CounterFlow.ChildrenOfType<JudgementCounter>().Last().Alpha == 0);
@ -139,6 +149,13 @@ private int hiddenCount()
private partial class TestJudgementCounterDisplay : JudgementCounterDisplay private partial class TestJudgementCounterDisplay : JudgementCounterDisplay
{ {
public new FillFlowContainer<JudgementCounter> CounterFlow => base.CounterFlow; public new FillFlowContainer<JudgementCounter> CounterFlow => base.CounterFlow;
public TestJudgementCounterDisplay()
{
Margin = new MarginPadding { Top = 100 };
Anchor = Anchor.TopCentre;
Origin = Anchor.TopCentre;
}
} }
} }
} }