mirror of
https://github.com/ppy/osu.git
synced 2025-01-13 05:53:10 +08:00
Add failing test case
This commit is contained in:
parent
fec3bd898e
commit
0aaa62efc2
@ -3,8 +3,12 @@
|
|||||||
|
|
||||||
using System;
|
using System;
|
||||||
using NUnit.Framework;
|
using NUnit.Framework;
|
||||||
|
using osu.Framework.Allocation;
|
||||||
using osu.Framework.Bindables;
|
using osu.Framework.Bindables;
|
||||||
|
using osu.Framework.Graphics;
|
||||||
|
using osu.Framework.Screens;
|
||||||
using osu.Framework.Testing;
|
using osu.Framework.Testing;
|
||||||
|
using osu.Game.Screens;
|
||||||
using osu.Game.Screens.OnlinePlay;
|
using osu.Game.Screens.OnlinePlay;
|
||||||
using osu.Game.Tests.Visual;
|
using osu.Game.Tests.Visual;
|
||||||
|
|
||||||
@ -58,5 +62,45 @@ namespace osu.Game.Tests.NonVisual
|
|||||||
AddStep("end operation", () => operation.Dispose());
|
AddStep("end operation", () => operation.Dispose());
|
||||||
AddAssert("operation is ended", () => !operationInProgress.Value);
|
AddAssert("operation is ended", () => !operationInProgress.Value);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
[Test]
|
||||||
|
public void TestOperationDisposalAfterScreenExit()
|
||||||
|
{
|
||||||
|
TestScreenWithTracker screen = null;
|
||||||
|
OsuScreenStack stack;
|
||||||
|
IDisposable operation = null;
|
||||||
|
|
||||||
|
AddStep("create screen with tracker", () =>
|
||||||
|
{
|
||||||
|
Child = stack = new OsuScreenStack
|
||||||
|
{
|
||||||
|
RelativeSizeAxes = Axes.Both
|
||||||
|
};
|
||||||
|
|
||||||
|
stack.Push(screen = new TestScreenWithTracker());
|
||||||
|
});
|
||||||
|
AddUntilStep("wait for loaded", () => screen.IsLoaded);
|
||||||
|
|
||||||
|
AddStep("begin operation", () => operation = screen.OngoingOperationTracker.BeginOperation());
|
||||||
|
AddAssert("operation in progress", () => screen.OngoingOperationTracker.InProgress.Value);
|
||||||
|
|
||||||
|
AddStep("dispose after screen exit", () =>
|
||||||
|
{
|
||||||
|
screen.Exit();
|
||||||
|
operation.Dispose();
|
||||||
|
});
|
||||||
|
AddAssert("operation ended", () => !screen.OngoingOperationTracker.InProgress.Value);
|
||||||
|
}
|
||||||
|
|
||||||
|
private class TestScreenWithTracker : OsuScreen
|
||||||
|
{
|
||||||
|
public OngoingOperationTracker OngoingOperationTracker { get; private set; }
|
||||||
|
|
||||||
|
[BackgroundDependencyLoader]
|
||||||
|
private void load()
|
||||||
|
{
|
||||||
|
InternalChild = OngoingOperationTracker = new OngoingOperationTracker();
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user