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