1
0
mirror of https://github.com/ppy/osu.git synced 2025-02-13 16:02:58 +08:00

Add test coverage

This commit is contained in:
Salman Ahmed 2022-11-18 17:49:03 +03:00
parent 1be8c6bd9c
commit 8943819ee7

View File

@ -4,6 +4,7 @@
#nullable disable
using System.Linq;
using System.Threading;
using NUnit.Framework;
using osu.Framework.Allocation;
using osu.Framework.Extensions;
@ -85,6 +86,19 @@ namespace osu.Game.Tests.Visual.Navigation
AddAssert("did perform", () => actionPerformed);
}
[Test]
public void TestPerformEnsuresScreenIsLoaded()
{
TestLoadBlockingScreen screen = null;
AddStep("push blocking screen", () => Game.ScreenStack.Push(screen = new TestLoadBlockingScreen()));
AddStep("perform", () => Game.PerformFromScreen(_ => actionPerformed = true, new[] { typeof(TestLoadBlockingScreen) }));
AddAssert("action not performed", () => !actionPerformed);
AddStep("allow load", () => screen.LoadEvent.Set());
AddUntilStep("action performed", () => actionPerformed);
}
[Test]
public void TestOverlaysAlwaysClosed()
{
@ -270,5 +284,16 @@ namespace osu.Game.Tests.Visual.Navigation
return base.OnExiting(e);
}
}
public class TestLoadBlockingScreen : OsuScreen
{
public readonly ManualResetEventSlim LoadEvent = new ManualResetEventSlim();
[BackgroundDependencyLoader]
private void load()
{
LoadEvent.Wait(10000);
}
}
}
}