From a294f187ee90a187604d7e3788842f46c2e592fe Mon Sep 17 00:00:00 2001 From: DrabWeb Date: Thu, 10 May 2018 21:52:26 -0300 Subject: [PATCH] Add steps and asserts to TestCaseScreenBreadcrumbs. --- .../Visual/TestCaseScreenBreadcrumbs.cs | 38 +++++++++++++++++-- 1 file changed, 34 insertions(+), 4 deletions(-) diff --git a/osu.Game.Tests/Visual/TestCaseScreenBreadcrumbs.cs b/osu.Game.Tests/Visual/TestCaseScreenBreadcrumbs.cs index 5055b0e114..6bb6b09746 100644 --- a/osu.Game.Tests/Visual/TestCaseScreenBreadcrumbs.cs +++ b/osu.Game.Tests/Visual/TestCaseScreenBreadcrumbs.cs @@ -17,6 +17,7 @@ namespace osu.Game.Tests.Visual public class TestCaseScreenBreadcrumbs : OsuTestCase { private readonly ScreenBreadcrumbControl breadcrumbs; + private TestScreen currentScreen, changedScreen = null; public TestCaseScreenBreadcrumbs() { @@ -40,11 +41,29 @@ namespace osu.Game.Tests.Visual titleText = new OsuSpriteText(), }, }, - startScreen = new TestScreenOne(), + currentScreen = startScreen = new TestScreenOne(), }; - breadcrumbs.OnScreenChanged += s => titleText.Text = $"Changed to {s.ToString()}"; - breadcrumbs.CurrentScreen = startScreen; + breadcrumbs.OnScreenChanged += s => + { + titleText.Text = $"Changed to {s.ToString()}"; + changedScreen = s; + }; + + AddStep(@"make start current", () => breadcrumbs.CurrentScreen = startScreen); + assertCurrent(); + pushNext(); + assertCurrent(); + pushNext(); + assertCurrent(); + + AddStep(@"make start current", () => + { + startScreen.MakeCurrent(); + currentScreen = startScreen; + }); + + assertCurrent(); } [BackgroundDependencyLoader] @@ -53,6 +72,9 @@ namespace osu.Game.Tests.Visual breadcrumbs.StripColour = colours.Blue; } + private void pushNext() => AddStep(@"push next screen", () => currentScreen = currentScreen.PushNext()); + private void assertCurrent() => AddAssert(@"assert the current screen is correct", () => currentScreen == changedScreen); + private abstract class TestScreen : OsuScreen { protected abstract string Title { get; } @@ -61,6 +83,14 @@ namespace osu.Game.Tests.Visual public override string ToString() => Title; + public TestScreen PushNext() + { + TestScreen screen = CreateNextScreen(); + Push(screen); + + return screen; + } + protected TestScreen() { Child = new FillFlowContainer @@ -84,7 +114,7 @@ namespace osu.Game.Tests.Visual Origin = Anchor.TopCentre, Width = 100, Text = $"Push {NextTitle}", - Action = () => Push(CreateNextScreen()), + Action = () => PushNext(), }, }, };