mirror of
https://github.com/ppy/osu.git
synced 2026-05-24 02:09:54 +08:00
Add back test covering immediate exit song select
This commit is contained in:
@@ -793,15 +793,8 @@ namespace osu.Game.Tests.Visual.Navigation
|
||||
{
|
||||
AddStep("push song select", () => Game.ScreenStack.Push(new TestPlaySongSelect()));
|
||||
AddStep("press back button", () => Game.ChildrenOfType<BackButton>().First().Action!.Invoke());
|
||||
AddWaitStep("wait two frames", 2);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void TestPushSongSelectAndPressBackButtonImmediatelyV2()
|
||||
{
|
||||
AddStep("push song select", () => Game.ScreenStack.Push(new TestPlaySongSelect()));
|
||||
AddStep("press back button", () => Game.ChildrenOfType<BackButton>().First().Action!.Invoke());
|
||||
AddWaitStep("wait two frames", 2);
|
||||
ConfirmAtMainMenu();
|
||||
}
|
||||
|
||||
[Test]
|
||||
|
||||
@@ -1,11 +1,14 @@
|
||||
// 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 System.Linq;
|
||||
using NUnit.Framework;
|
||||
using osu.Framework.Allocation;
|
||||
using osu.Framework.Extensions;
|
||||
using osu.Framework.Testing;
|
||||
using osu.Game.Beatmaps;
|
||||
using osu.Game.Overlays;
|
||||
using osu.Game.Screens.Footer;
|
||||
using osu.Game.Screens.Play;
|
||||
using osu.Game.Screens.SelectV2;
|
||||
using osu.Game.Tests.Beatmaps.IO;
|
||||
@@ -19,6 +22,19 @@ namespace osu.Game.Tests.Visual.Navigation
|
||||
/// </summary>
|
||||
public class TestSceneSongSelectNavigation : OsuGameTestScene
|
||||
{
|
||||
[Test]
|
||||
public void TestPushSongSelectAndPressBackButtonImmediately()
|
||||
{
|
||||
AddStep("push song select", () => Game.ScreenStack.Push(new SoloSongSelect()));
|
||||
|
||||
// TODO: without this step, a critical bug will be hit, see inline comment in `OsuGame.handleBackButton`.
|
||||
AddUntilStep("Wait for song select", () => Game.ScreenStack.CurrentScreen is SoloSongSelect select && select.IsLoaded);
|
||||
|
||||
AddStep("press back button", () => Game.ChildrenOfType<ScreenBackButton>().First().Action!.Invoke());
|
||||
|
||||
ConfirmAtMainMenu();
|
||||
}
|
||||
|
||||
[TestCase(true)]
|
||||
[TestCase(false)]
|
||||
public void TestSongContinuesAfterExitPlayer(bool withUserPause)
|
||||
|
||||
@@ -1306,6 +1306,9 @@ namespace osu.Game
|
||||
|
||||
private void handleBackButton()
|
||||
{
|
||||
// TODO: this is SUPER SUPER bad.
|
||||
// It can potentially exit the wrong screen if screens are not loaded yet.
|
||||
// ScreenFooter / ScreenBackButton should be aware of which screen it is currently being handled by.
|
||||
if (!(ScreenStack.CurrentScreen is IOsuScreen currentScreen)) return;
|
||||
|
||||
if (!((Drawable)currentScreen).IsLoaded || (currentScreen.AllowUserExit && !currentScreen.OnBackButton())) ScreenStack.Exit();
|
||||
|
||||
Reference in New Issue
Block a user