mirror of https://github.com/ppy/osu
Add new options test
This commit is contained in:
parent
980686f6bf
commit
351b6e6259
|
@ -5,7 +5,6 @@
|
|||
using System.Linq;
|
||||
using NUnit.Framework;
|
||||
using osu.Framework.Allocation;
|
||||
using osu.Framework.Audio;
|
||||
using osu.Framework.Graphics;
|
||||
using osu.Framework.Graphics.Containers;
|
||||
using osu.Framework.Graphics.Shapes;
|
||||
|
@ -13,15 +12,12 @@
|
|||
using osu.Framework.Platform;
|
||||
using osu.Framework.Screens;
|
||||
using osu.Framework.Testing;
|
||||
using osu.Game.Beatmaps;
|
||||
using osu.Game.Configuration;
|
||||
using osu.Game.Graphics.UserInterface;
|
||||
using osu.Game.Overlays;
|
||||
using osu.Game.Overlays.Mods;
|
||||
using osu.Game.Rulesets;
|
||||
using osu.Game.Screens;
|
||||
using osu.Game.Screens.Menu;
|
||||
using osu.Game.Screens.Select;
|
||||
using osu.Game.Tests.Resources;
|
||||
using osuTK;
|
||||
using osuTK.Graphics;
|
||||
using osuTK.Input;
|
||||
|
@ -35,6 +31,8 @@ public class TestSceneScreenNavigation : ManualInputManagerTestScene
|
|||
|
||||
private Vector2 backButtonPosition => osuGame.ToScreenSpace(new Vector2(25, osuGame.LayoutRectangle.Bottom - 25));
|
||||
|
||||
private Vector2 optionsButtonPosition => osuGame.ToScreenSpace(new Vector2(25, 25));
|
||||
|
||||
[BackgroundDependencyLoader]
|
||||
private void load(GameHost gameHost)
|
||||
{
|
||||
|
@ -110,6 +108,17 @@ public void TestExitMultiWithBackButton()
|
|||
exitViaBackButtonAndConfirm();
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void TestOpenOptionsAndExitWithEscape()
|
||||
{
|
||||
AddStep("Enter menu", () => pressAndRelease(Key.Enter));
|
||||
AddStep("Move mouse to options overlay", () => InputManager.MoveMouseTo(optionsButtonPosition));
|
||||
AddStep("Click options overlay", () => InputManager.Click(MouseButton.Left));
|
||||
AddAssert("Options overlay was opened", () => osuGame.Settings.State.Value == Visibility.Visible);
|
||||
AddStep("Hide options overlay using escape", () => pressAndRelease(Key.Escape));
|
||||
AddAssert("Options overlay was closed", () => osuGame.Settings.State.Value == Visibility.Hidden);
|
||||
}
|
||||
|
||||
private void pushAndConfirm(Func<Screen> newScreen, string screenName)
|
||||
{
|
||||
Screen screen = null;
|
||||
|
@ -148,6 +157,8 @@ private class TestOsuGame : OsuGame
|
|||
|
||||
public new BackButton BackButton => base.BackButton;
|
||||
|
||||
public new SettingsPanel Settings => base.Settings;
|
||||
|
||||
protected override Loader CreateLoader() => new TestLoader();
|
||||
}
|
||||
|
||||
|
|
|
@ -82,8 +82,11 @@ public class OsuGame : OsuGameBase, IKeyBindingHandler<GlobalAction>
|
|||
public readonly Bindable<OverlayActivation> OverlayActivationMode = new Bindable<OverlayActivation>();
|
||||
|
||||
protected OsuScreenStack ScreenStack;
|
||||
|
||||
protected BackButton BackButton;
|
||||
|
||||
protected SettingsPanel Settings;
|
||||
|
||||
private VolumeOverlay volume;
|
||||
private OsuLogo osuLogo;
|
||||
|
||||
|
@ -97,8 +100,6 @@ public class OsuGame : OsuGameBase, IKeyBindingHandler<GlobalAction>
|
|||
|
||||
private readonly string[] args;
|
||||
|
||||
private SettingsPanel settings;
|
||||
|
||||
private readonly List<OverlayContainer> overlays = new List<OverlayContainer>();
|
||||
|
||||
private readonly List<OverlayContainer> toolbarElements = new List<OverlayContainer>();
|
||||
|
@ -483,7 +484,7 @@ protected override void LoadComplete()
|
|||
loadComponentSingleFile(social = new SocialOverlay(), overlayContent.Add, true);
|
||||
loadComponentSingleFile(channelManager = new ChannelManager(), AddInternal, true);
|
||||
loadComponentSingleFile(chatOverlay = new ChatOverlay(), overlayContent.Add, true);
|
||||
loadComponentSingleFile(settings = new SettingsOverlay { GetToolbarHeight = () => ToolbarOffset }, leftFloatingOverlayContent.Add, true);
|
||||
loadComponentSingleFile(Settings = new SettingsOverlay { GetToolbarHeight = () => ToolbarOffset }, leftFloatingOverlayContent.Add, true);
|
||||
var changelogOverlay = loadComponentSingleFile(new ChangelogOverlay(), overlayContent.Add, true);
|
||||
loadComponentSingleFile(userProfile = new UserProfileOverlay(), overlayContent.Add, true);
|
||||
loadComponentSingleFile(beatmapSetOverlay = new BeatmapSetOverlay(), overlayContent.Add, true);
|
||||
|
@ -514,7 +515,7 @@ protected override void LoadComplete()
|
|||
|
||||
Add(externalLinkOpener = new ExternalLinkOpener());
|
||||
|
||||
var singleDisplaySideOverlays = new OverlayContainer[] { settings, notifications };
|
||||
var singleDisplaySideOverlays = new OverlayContainer[] { Settings, notifications };
|
||||
overlays.AddRange(singleDisplaySideOverlays);
|
||||
|
||||
foreach (var overlay in singleDisplaySideOverlays)
|
||||
|
@ -567,7 +568,7 @@ void updateScreenOffset()
|
|||
{
|
||||
float offset = 0;
|
||||
|
||||
if (settings.State.Value == Visibility.Visible)
|
||||
if (Settings.State.Value == Visibility.Visible)
|
||||
offset += ToolbarButton.WIDTH / 2;
|
||||
if (notifications.State.Value == Visibility.Visible)
|
||||
offset -= ToolbarButton.WIDTH / 2;
|
||||
|
@ -575,7 +576,7 @@ void updateScreenOffset()
|
|||
screenContainer.MoveToX(offset, SettingsPanel.TRANSITION_LENGTH, Easing.OutQuint);
|
||||
}
|
||||
|
||||
settings.State.ValueChanged += _ => updateScreenOffset();
|
||||
Settings.State.ValueChanged += _ => updateScreenOffset();
|
||||
notifications.State.ValueChanged += _ => updateScreenOffset();
|
||||
}
|
||||
|
||||
|
@ -720,7 +721,7 @@ public bool OnPressed(GlobalAction action)
|
|||
return true;
|
||||
|
||||
case GlobalAction.ToggleSettings:
|
||||
settings.ToggleVisibility();
|
||||
Settings.ToggleVisibility();
|
||||
return true;
|
||||
|
||||
case GlobalAction.ToggleDirect:
|
||||
|
|
Loading…
Reference in New Issue