Add test coverage of navigation

This commit is contained in:
Dean Herbert
2022-04-18 16:34:13 +09:00
parent 07da1cd731
commit 288f759bb4
3 changed files with 75 additions and 27 deletions

View File

@ -1,20 +0,0 @@
// Copyright (c) ppy Pty Ltd <contact@ppy.sh>. Licensed under the MIT Licence.
// See the LICENCE file in the repository root for full licence text.
using NUnit.Framework;
using osu.Game.Overlays;
namespace osu.Game.Tests.Visual.Navigation
{
public class TestFirstRunSetup : OsuTestScene
{
[Test]
public void TestOverlay()
{
AddStep("add overlay", () =>
{
Child = new FirstRunSetupOverlay();
});
}
}
}

View File

@ -0,0 +1,63 @@
// Copyright (c) ppy Pty Ltd <contact@ppy.sh>. Licensed under the MIT Licence.
// See the LICENCE file in the repository root for full licence text.
using NUnit.Framework;
using osu.Framework.Graphics.Containers;
using osu.Framework.Testing;
using osu.Game.Overlays;
using osu.Game.Overlays.FirstRunSetup;
namespace osu.Game.Tests.Visual.Navigation
{
public class TestSceneFirstRunSetupOverlay : OsuTestScene
{
private FirstRunSetupOverlay overlay;
[SetUpSteps]
public void SetUpSteps()
{
AddStep("add overlay", () =>
{
Child = overlay = new FirstRunSetupOverlay();
});
}
[Test]
public void TestOverlayRunsToFinish()
{
AddUntilStep("step through", () =>
{
if (overlay.CurrentScreen?.IsLoaded != false)
overlay.NextButton.TriggerClick();
return overlay.State.Value == Visibility.Hidden;
});
}
[Test]
public void TestBackButton()
{
AddAssert("back button disabled", () => !overlay.BackButton.Enabled.Value);
AddUntilStep("step to last", () =>
{
var nextButton = overlay.NextButton;
if (overlay.CurrentScreen?.IsLoaded != false)
nextButton.TriggerClick();
return nextButton.Text.ToString() == "Finish";
});
AddUntilStep("step back to start", () =>
{
if (overlay.CurrentScreen?.IsLoaded != false)
overlay.BackButton.TriggerClick();
return overlay.CurrentScreen is ScreenWelcome;
});
AddAssert("back button disabled", () => !overlay.BackButton.Enabled.Value);
}
}
}