mirror of
https://github.com/ppy/osu.git
synced 2025-01-12 15:22:55 +08:00
get tests running again
This commit is contained in:
parent
f81e691bf5
commit
980686f6bf
@ -5,17 +5,23 @@ using System;
|
|||||||
using System.Linq;
|
using System.Linq;
|
||||||
using NUnit.Framework;
|
using NUnit.Framework;
|
||||||
using osu.Framework.Allocation;
|
using osu.Framework.Allocation;
|
||||||
|
using osu.Framework.Audio;
|
||||||
using osu.Framework.Graphics;
|
using osu.Framework.Graphics;
|
||||||
using osu.Framework.Graphics.Containers;
|
using osu.Framework.Graphics.Containers;
|
||||||
using osu.Framework.Graphics.Shapes;
|
using osu.Framework.Graphics.Shapes;
|
||||||
|
using osu.Framework.Logging;
|
||||||
using osu.Framework.Platform;
|
using osu.Framework.Platform;
|
||||||
using osu.Framework.Screens;
|
using osu.Framework.Screens;
|
||||||
using osu.Framework.Testing;
|
using osu.Framework.Testing;
|
||||||
|
using osu.Game.Beatmaps;
|
||||||
|
using osu.Game.Configuration;
|
||||||
using osu.Game.Graphics.UserInterface;
|
using osu.Game.Graphics.UserInterface;
|
||||||
using osu.Game.Overlays.Mods;
|
using osu.Game.Overlays.Mods;
|
||||||
|
using osu.Game.Rulesets;
|
||||||
using osu.Game.Screens;
|
using osu.Game.Screens;
|
||||||
using osu.Game.Screens.Menu;
|
using osu.Game.Screens.Menu;
|
||||||
using osu.Game.Screens.Select;
|
using osu.Game.Screens.Select;
|
||||||
|
using osu.Game.Tests.Resources;
|
||||||
using osuTK;
|
using osuTK;
|
||||||
using osuTK.Graphics;
|
using osuTK.Graphics;
|
||||||
using osuTK.Input;
|
using osuTK.Input;
|
||||||
@ -27,7 +33,7 @@ namespace osu.Game.Tests.Visual.Menus
|
|||||||
private GameHost gameHost;
|
private GameHost gameHost;
|
||||||
private TestOsuGame osuGame;
|
private TestOsuGame osuGame;
|
||||||
|
|
||||||
private Vector2 backButtonPosition => osuGame.ToScreenSpace(new Vector2(0, osuGame.LayoutRectangle.Bottom));
|
private Vector2 backButtonPosition => osuGame.ToScreenSpace(new Vector2(25, osuGame.LayoutRectangle.Bottom - 25));
|
||||||
|
|
||||||
[BackgroundDependencyLoader]
|
[BackgroundDependencyLoader]
|
||||||
private void load(GameHost gameHost)
|
private void load(GameHost gameHost)
|
||||||
@ -55,7 +61,8 @@ namespace osu.Game.Tests.Visual.Menus
|
|||||||
Add(osuGame);
|
Add(osuGame);
|
||||||
});
|
});
|
||||||
AddUntilStep("Wait for load", () => osuGame.IsLoaded);
|
AddUntilStep("Wait for load", () => osuGame.IsLoaded);
|
||||||
AddUntilStep("Wait for main menu", () => osuGame.ScreenStack.CurrentScreen is MainMenu);
|
AddUntilStep("Wait for intro", () => osuGame.ScreenStack.CurrentScreen is IntroScreen);
|
||||||
|
AddUntilStep("Wait for main menu", () => osuGame.ScreenStack.CurrentScreen is MainMenu menu && menu.IsLoaded);
|
||||||
}
|
}
|
||||||
|
|
||||||
[Test]
|
[Test]
|
||||||
@ -79,7 +86,7 @@ namespace osu.Game.Tests.Visual.Menus
|
|||||||
pushAndConfirm(() => songSelect = new TestSongSelect(), "song select");
|
pushAndConfirm(() => songSelect = new TestSongSelect(), "song select");
|
||||||
AddStep("Show mods overlay", () => songSelect.ModSelectOverlay.Show());
|
AddStep("Show mods overlay", () => songSelect.ModSelectOverlay.Show());
|
||||||
AddAssert("Overlay was shown", () => songSelect.ModSelectOverlay.State.Value == Visibility.Visible);
|
AddAssert("Overlay was shown", () => songSelect.ModSelectOverlay.State.Value == Visibility.Visible);
|
||||||
AddStep("Move mouse to backButton", () => InputManager.MoveMouseTo(osuGame.BackButton));
|
AddStep("Move mouse to backButton", () => InputManager.MoveMouseTo(backButtonPosition));
|
||||||
|
|
||||||
// BackButton handles hover using its child button, so this checks whether or not any of BackButton's children are hovered.
|
// BackButton handles hover using its child button, so this checks whether or not any of BackButton's children are hovered.
|
||||||
AddUntilStep("Back button is hovered", () => InputManager.HoveredDrawables.Any(d => d.Parent == osuGame.BackButton));
|
AddUntilStep("Back button is hovered", () => InputManager.HoveredDrawables.Any(d => d.Parent == osuGame.BackButton));
|
||||||
@ -92,22 +99,28 @@ namespace osu.Game.Tests.Visual.Menus
|
|||||||
[Test]
|
[Test]
|
||||||
public void TestExitMultiWithEscape()
|
public void TestExitMultiWithEscape()
|
||||||
{
|
{
|
||||||
pushAndConfirm(() => new Screens.Multi.Multiplayer(), "multiplayer");
|
pushAndConfirm(() => new TestMultiplayer(), "multiplayer");
|
||||||
exitViaEscapeAndConfirm();
|
exitViaEscapeAndConfirm();
|
||||||
}
|
}
|
||||||
|
|
||||||
[Test]
|
[Test]
|
||||||
public void TestExitMultiWithBackButton()
|
public void TestExitMultiWithBackButton()
|
||||||
{
|
{
|
||||||
pushAndConfirm(() => new Screens.Multi.Multiplayer(), "multiplayer");
|
pushAndConfirm(() => new TestMultiplayer(), "multiplayer");
|
||||||
exitViaBackButtonAndConfirm();
|
exitViaBackButtonAndConfirm();
|
||||||
}
|
}
|
||||||
|
|
||||||
private void pushAndConfirm(Func<Screen> newScreen, string screenName)
|
private void pushAndConfirm(Func<Screen> newScreen, string screenName)
|
||||||
{
|
{
|
||||||
Screen screen = null;
|
Screen screen = null;
|
||||||
AddStep($"Push new {screenName}", () => osuGame.ScreenStack.Push(screen = newScreen()));
|
AddStep($"Push new {screenName}", () =>
|
||||||
AddUntilStep($"Wait for new {screenName}", () => osuGame.ScreenStack.CurrentScreen == screen);
|
{
|
||||||
|
if (screenName == "song select")
|
||||||
|
Logger.Log("fuck");
|
||||||
|
|
||||||
|
osuGame.ScreenStack.Push(screen = newScreen());
|
||||||
|
});
|
||||||
|
AddUntilStep($"Wait for new {screenName}", () => osuGame.ScreenStack.CurrentScreen == screen && screen.IsLoaded);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void exitViaEscapeAndConfirm()
|
private void exitViaEscapeAndConfirm()
|
||||||
@ -118,7 +131,7 @@ namespace osu.Game.Tests.Visual.Menus
|
|||||||
|
|
||||||
private void exitViaBackButtonAndConfirm()
|
private void exitViaBackButtonAndConfirm()
|
||||||
{
|
{
|
||||||
AddStep("Move mouse to backButton", () => InputManager.MoveMouseTo(osuGame.BackButton));
|
AddStep("Move mouse to backButton", () => InputManager.MoveMouseTo(backButtonPosition));
|
||||||
AddStep("Click back button", () => InputManager.Click(MouseButton.Left));
|
AddStep("Click back button", () => InputManager.Click(MouseButton.Left));
|
||||||
AddUntilStep("Wait for main menu", () => osuGame.ScreenStack.CurrentScreen is MainMenu);
|
AddUntilStep("Wait for main menu", () => osuGame.ScreenStack.CurrentScreen is MainMenu);
|
||||||
}
|
}
|
||||||
@ -143,6 +156,11 @@ namespace osu.Game.Tests.Visual.Menus
|
|||||||
public ModSelectOverlay ModSelectOverlay => ModSelect;
|
public ModSelectOverlay ModSelectOverlay => ModSelect;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private class TestMultiplayer : Screens.Multi.Multiplayer
|
||||||
|
{
|
||||||
|
protected override bool RequireOnline => false;
|
||||||
|
}
|
||||||
|
|
||||||
private class TestLoader : Loader
|
private class TestLoader : Loader
|
||||||
{
|
{
|
||||||
protected override ShaderPrecompiler CreateShaderPrecompiler() => new TestShaderPrecompiler();
|
protected override ShaderPrecompiler CreateShaderPrecompiler() => new TestShaderPrecompiler();
|
||||||
|
@ -317,7 +317,7 @@ namespace osu.Game
|
|||||||
|
|
||||||
private void currentTrackCompleted()
|
private void currentTrackCompleted()
|
||||||
{
|
{
|
||||||
if (!Beatmap.Value.Track.Looping && !Beatmap.Disabled)
|
if (!Beatmap.Value.Track.Looping && !Beatmap.Disabled && musicController.IsLoaded)
|
||||||
musicController.NextTrack();
|
musicController.NextTrack();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -316,7 +316,7 @@ namespace osu.Game.Screens.Menu
|
|||||||
logoDelayedAction = Scheduler.AddDelayed(() =>
|
logoDelayedAction = Scheduler.AddDelayed(() =>
|
||||||
{
|
{
|
||||||
if (impact)
|
if (impact)
|
||||||
logo?.Impact();
|
logo.Impact();
|
||||||
|
|
||||||
game?.Toolbar.Show();
|
game?.Toolbar.Show();
|
||||||
}, 200);
|
}, 200);
|
||||||
|
@ -34,6 +34,8 @@ namespace osu.Game.Screens.Multi
|
|||||||
|
|
||||||
public override bool DisallowExternalBeatmapRulesetChanges => true;
|
public override bool DisallowExternalBeatmapRulesetChanges => true;
|
||||||
|
|
||||||
|
protected virtual bool RequireOnline => true;
|
||||||
|
|
||||||
private readonly MultiplayerWaveContainer waves;
|
private readonly MultiplayerWaveContainer waves;
|
||||||
|
|
||||||
private readonly OsuButton createButton;
|
private readonly OsuButton createButton;
|
||||||
@ -166,7 +168,7 @@ namespace osu.Game.Screens.Multi
|
|||||||
|
|
||||||
public void APIStateChanged(IAPIProvider api, APIState state)
|
public void APIStateChanged(IAPIProvider api, APIState state)
|
||||||
{
|
{
|
||||||
if (state != APIState.Online)
|
if (RequireOnline && state != APIState.Online)
|
||||||
forcefullyExit();
|
forcefullyExit();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user