mirror of
https://github.com/ppy/osu
synced 2024-12-25 16:22:23 +00:00
Split out IDialogOverlay
to allow for easier testing
This commit is contained in:
parent
587f1e2c4f
commit
e315313266
@ -50,7 +50,7 @@ namespace osu.Game.Tests.Visual.Collections
|
||||
});
|
||||
|
||||
Dependencies.Cache(manager);
|
||||
Dependencies.Cache(dialogOverlay);
|
||||
Dependencies.CacheAs<IDialogOverlay>(dialogOverlay);
|
||||
}
|
||||
|
||||
[SetUp]
|
||||
|
@ -49,7 +49,7 @@ namespace osu.Game.Tests.Visual.Navigation
|
||||
typeof(LoginOverlay),
|
||||
typeof(MusicController),
|
||||
typeof(AccountCreationOverlay),
|
||||
typeof(DialogOverlay),
|
||||
typeof(IDialogOverlay),
|
||||
typeof(ScreenshotManager)
|
||||
};
|
||||
|
||||
|
@ -5,6 +5,7 @@ using System.Linq;
|
||||
using NUnit.Framework;
|
||||
using osu.Framework.Allocation;
|
||||
using osu.Framework.Extensions;
|
||||
using osu.Framework.Graphics;
|
||||
using osu.Framework.Graphics.Containers;
|
||||
using osu.Framework.Screens;
|
||||
using osu.Framework.Testing;
|
||||
@ -113,12 +114,12 @@ namespace osu.Game.Tests.Visual.Navigation
|
||||
AddAssert("did not perform", () => !actionPerformed);
|
||||
AddAssert("only one exit attempt", () => blocker.ExitAttempts == 1);
|
||||
|
||||
AddUntilStep("wait for dialog display", () => Game.Dependencies.Get<DialogOverlay>().IsLoaded);
|
||||
AddUntilStep("wait for dialog display", () => ((Drawable)Game.Dependencies.Get<IDialogOverlay>()).IsLoaded);
|
||||
|
||||
if (confirmed)
|
||||
{
|
||||
AddStep("accept dialog", () => InputManager.Key(Key.Number1));
|
||||
AddUntilStep("wait for dialog dismissed", () => Game.Dependencies.Get<DialogOverlay>().CurrentDialog == null);
|
||||
AddUntilStep("wait for dialog dismissed", () => Game.Dependencies.Get<IDialogOverlay>().CurrentDialog == null);
|
||||
AddUntilStep("did perform", () => actionPerformed);
|
||||
}
|
||||
else
|
||||
@ -145,7 +146,7 @@ namespace osu.Game.Tests.Visual.Navigation
|
||||
|
||||
AddWaitStep("wait a bit", 10);
|
||||
|
||||
AddUntilStep("wait for dialog display", () => Game.Dependencies.Get<DialogOverlay>().IsLoaded);
|
||||
AddUntilStep("wait for dialog display", () => ((Drawable)Game.Dependencies.Get<IDialogOverlay>()).IsLoaded);
|
||||
|
||||
AddAssert("screen didn't change", () => Game.ScreenStack.CurrentScreen == blocker2);
|
||||
AddAssert("did not perform", () => !actionPerformed);
|
||||
@ -187,7 +188,7 @@ namespace osu.Game.Tests.Visual.Navigation
|
||||
|
||||
AddWaitStep("wait a bit", 10);
|
||||
|
||||
AddUntilStep("wait for dialog display", () => Game.Dependencies.Get<DialogOverlay>().IsLoaded);
|
||||
AddUntilStep("wait for dialog display", () => ((Drawable)Game.Dependencies.Get<IDialogOverlay>()).IsLoaded);
|
||||
|
||||
AddAssert("screen didn't change", () => Game.ScreenStack.CurrentScreen == screenWithNestedStack);
|
||||
AddAssert("nested screen didn't change", () => screenWithNestedStack.SubScreenStack.CurrentScreen == screenWithNestedStack.Blocker);
|
||||
@ -221,7 +222,7 @@ namespace osu.Game.Tests.Visual.Navigation
|
||||
public class DialogBlockingScreen : OsuScreen
|
||||
{
|
||||
[Resolved]
|
||||
private DialogOverlay dialogOverlay { get; set; }
|
||||
private IDialogOverlay dialogOverlay { get; set; }
|
||||
|
||||
private int dialogDisplayCount;
|
||||
|
||||
|
@ -6,6 +6,7 @@ using System.Linq;
|
||||
using NUnit.Framework;
|
||||
using osu.Framework.Allocation;
|
||||
using osu.Framework.Extensions;
|
||||
using osu.Framework.Graphics;
|
||||
using osu.Framework.Graphics.Containers;
|
||||
using osu.Framework.Graphics.UserInterface;
|
||||
using osu.Framework.Screens;
|
||||
@ -200,10 +201,10 @@ namespace osu.Game.Tests.Visual.Navigation
|
||||
|
||||
AddStep("choose clear all scores", () => InputManager.Key(Key.Number4));
|
||||
|
||||
AddUntilStep("wait for dialog display", () => Game.Dependencies.Get<DialogOverlay>().IsLoaded);
|
||||
AddUntilStep("wait for dialog", () => Game.Dependencies.Get<DialogOverlay>().CurrentDialog != null);
|
||||
AddUntilStep("wait for dialog display", () => ((Drawable)Game.Dependencies.Get<IDialogOverlay>()).IsLoaded);
|
||||
AddUntilStep("wait for dialog", () => Game.Dependencies.Get<IDialogOverlay>().CurrentDialog != null);
|
||||
AddStep("confirm deletion", () => InputManager.Key(Key.Number1));
|
||||
AddUntilStep("wait for dialog dismissed", () => Game.Dependencies.Get<DialogOverlay>().CurrentDialog == null);
|
||||
AddUntilStep("wait for dialog dismissed", () => Game.Dependencies.Get<IDialogOverlay>().CurrentDialog == null);
|
||||
|
||||
AddUntilStep("ensure score is pending deletion", () => Game.Realm.Run(r => r.Find<ScoreInfo>(score.ID)?.DeletePending == true));
|
||||
|
||||
@ -246,10 +247,10 @@ namespace osu.Game.Tests.Visual.Navigation
|
||||
InputManager.Click(MouseButton.Left);
|
||||
});
|
||||
|
||||
AddUntilStep("wait for dialog display", () => Game.Dependencies.Get<DialogOverlay>().IsLoaded);
|
||||
AddUntilStep("wait for dialog", () => Game.Dependencies.Get<DialogOverlay>().CurrentDialog != null);
|
||||
AddUntilStep("wait for dialog display", () => ((Drawable)Game.Dependencies.Get<IDialogOverlay>()).IsLoaded);
|
||||
AddUntilStep("wait for dialog", () => Game.Dependencies.Get<IDialogOverlay>().CurrentDialog != null);
|
||||
AddStep("confirm deletion", () => InputManager.Key(Key.Number1));
|
||||
AddUntilStep("wait for dialog dismissed", () => Game.Dependencies.Get<DialogOverlay>().CurrentDialog == null);
|
||||
AddUntilStep("wait for dialog dismissed", () => Game.Dependencies.Get<IDialogOverlay>().CurrentDialog == null);
|
||||
|
||||
AddUntilStep("ensure score is pending deletion", () => Game.Realm.Run(r => r.Find<ScoreInfo>(score.ID)?.DeletePending == true));
|
||||
|
||||
|
@ -42,7 +42,7 @@ namespace osu.Game.Tests.Visual.UserInterface
|
||||
|
||||
private BeatmapInfo beatmapInfo;
|
||||
|
||||
[Cached]
|
||||
[Cached(typeof(IDialogOverlay))]
|
||||
private readonly DialogOverlay dialogOverlay;
|
||||
|
||||
public TestSceneDeleteLocalScore()
|
||||
|
@ -11,7 +11,7 @@ using osu.Game.Overlays.Dialog;
|
||||
namespace osu.Game.Tests.Visual.UserInterface
|
||||
{
|
||||
[TestFixture]
|
||||
public class TestSceneDialogOverlay : OsuTestScene
|
||||
public class TestSceneIDialogOverlay : OsuTestScene
|
||||
{
|
||||
private DialogOverlay overlay;
|
||||
|
||||
|
@ -158,7 +158,7 @@ namespace osu.Game.Collections
|
||||
public Func<Vector2, bool> IsTextBoxHovered;
|
||||
|
||||
[Resolved(CanBeNull = true)]
|
||||
private DialogOverlay dialogOverlay { get; set; }
|
||||
private IDialogOverlay dialogOverlay { get; set; }
|
||||
|
||||
[Resolved(CanBeNull = true)]
|
||||
private CollectionManager collectionManager { get; set; }
|
||||
|
@ -40,7 +40,7 @@ namespace osu.Game.Database
|
||||
private OsuGame game { get; set; }
|
||||
|
||||
[Resolved]
|
||||
private DialogOverlay dialogOverlay { get; set; }
|
||||
private IDialogOverlay dialogOverlay { get; set; }
|
||||
|
||||
[Resolved(CanBeNull = true)]
|
||||
private DesktopGameHost desktopGameHost { get; set; }
|
||||
|
@ -17,7 +17,7 @@ namespace osu.Game.Online.Chat
|
||||
private GameHost host { get; set; }
|
||||
|
||||
[Resolved(CanBeNull = true)]
|
||||
private DialogOverlay dialogOverlay { get; set; }
|
||||
private IDialogOverlay dialogOverlay { get; set; }
|
||||
|
||||
private Bindable<bool> externalLinkWarning;
|
||||
|
||||
|
@ -64,7 +64,7 @@ namespace osu.Game.Online.Leaderboards
|
||||
private List<ScoreComponentLabel> statisticsLabels;
|
||||
|
||||
[Resolved(CanBeNull = true)]
|
||||
private DialogOverlay dialogOverlay { get; set; }
|
||||
private IDialogOverlay dialogOverlay { get; set; }
|
||||
|
||||
[Resolved(CanBeNull = true)]
|
||||
private SongSelect songSelect { get; set; }
|
||||
|
@ -216,7 +216,7 @@ namespace osu.Game.Overlays.Dialog
|
||||
};
|
||||
|
||||
// It's important we start in a visible state so our state fires on hide, even before load.
|
||||
// This is used by the DialogOverlay to know when the dialog was dismissed.
|
||||
// This is used by the IDialogOverlay to know when the dialog was dismissed.
|
||||
Show();
|
||||
}
|
||||
|
||||
|
@ -14,7 +14,7 @@ using osu.Game.Audio.Effects;
|
||||
|
||||
namespace osu.Game.Overlays
|
||||
{
|
||||
public class DialogOverlay : OsuFocusedOverlayContainer
|
||||
public class DialogOverlay : OsuFocusedOverlayContainer, IDialogOverlay
|
||||
{
|
||||
private readonly Container dialogContainer;
|
||||
|
||||
|
31
osu.Game/Overlays/IDialogOverlay.cs
Normal file
31
osu.Game/Overlays/IDialogOverlay.cs
Normal file
@ -0,0 +1,31 @@
|
||||
#nullable enable
|
||||
// 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 osu.Framework.Allocation;
|
||||
using osu.Game.Overlays.Dialog;
|
||||
|
||||
namespace osu.Game.Overlays
|
||||
{
|
||||
/// <summary>
|
||||
/// A global overlay that can show popup dialogs.
|
||||
/// </summary>
|
||||
[Cached]
|
||||
public interface IDialogOverlay
|
||||
{
|
||||
/// <summary>
|
||||
/// Push a new dialog for display.
|
||||
/// </summary>
|
||||
/// <remarks>
|
||||
/// This will immediate dismiss any already displayed dialog (cancelling the action).
|
||||
/// If the dialog instance provided is already displayed, it will be a noop.
|
||||
/// </remarks>
|
||||
/// <param name="dialog">The dialog to be presented.</param>
|
||||
void Push(PopupDialog dialog);
|
||||
|
||||
/// <summary>
|
||||
/// The currently displayed dialog, if any.
|
||||
/// </summary>
|
||||
PopupDialog? CurrentDialog { get; }
|
||||
}
|
||||
}
|
@ -30,7 +30,7 @@ namespace osu.Game.Overlays.Settings.Sections.Maintenance
|
||||
private SettingsButton undeleteButton;
|
||||
|
||||
[BackgroundDependencyLoader(permitNulls: true)]
|
||||
private void load(BeatmapManager beatmaps, ScoreManager scores, SkinManager skins, [CanBeNull] CollectionManager collectionManager, [CanBeNull] LegacyImportManager legacyImportManager, DialogOverlay dialogOverlay)
|
||||
private void load(BeatmapManager beatmaps, ScoreManager scores, SkinManager skins, [CanBeNull] CollectionManager collectionManager, [CanBeNull] LegacyImportManager legacyImportManager, IDialogOverlay dialogOverlay)
|
||||
{
|
||||
if (legacyImportManager?.SupportsImportFromStable == true)
|
||||
{
|
||||
|
@ -23,7 +23,7 @@ namespace osu.Game.Overlays.Settings.Sections.Maintenance
|
||||
private OsuGameBase game { get; set; }
|
||||
|
||||
[Resolved(canBeNull: true)]
|
||||
private DialogOverlay dialogOverlay { get; set; }
|
||||
private IDialogOverlay dialogOverlay { get; set; }
|
||||
|
||||
protected override DirectoryInfo InitialPath => new DirectoryInfo(storage.GetFullPath(string.Empty)).Parent;
|
||||
|
||||
|
@ -26,7 +26,7 @@ namespace osu.Game
|
||||
private NotificationOverlay notifications { get; set; }
|
||||
|
||||
[Resolved]
|
||||
private DialogOverlay dialogOverlay { get; set; }
|
||||
private IDialogOverlay dialogOverlay { get; set; }
|
||||
|
||||
[Resolved(canBeNull: true)]
|
||||
private OsuGame game { get; set; }
|
||||
|
@ -84,7 +84,7 @@ namespace osu.Game.Screens.Edit
|
||||
private Storage storage { get; set; }
|
||||
|
||||
[Resolved(canBeNull: true)]
|
||||
private DialogOverlay dialogOverlay { get; set; }
|
||||
private IDialogOverlay dialogOverlay { get; set; }
|
||||
|
||||
[Resolved(canBeNull: true)]
|
||||
private NotificationOverlay notifications { get; set; }
|
||||
|
@ -60,7 +60,7 @@ namespace osu.Game.Screens.Menu
|
||||
private IAPIProvider api { get; set; }
|
||||
|
||||
[Resolved(canBeNull: true)]
|
||||
private DialogOverlay dialogOverlay { get; set; }
|
||||
private IDialogOverlay dialogOverlay { get; set; }
|
||||
|
||||
private BackgroundScreenDefault background;
|
||||
|
||||
|
@ -13,7 +13,7 @@ namespace osu.Game.Screens.Menu
|
||||
public class StorageErrorDialog : PopupDialog
|
||||
{
|
||||
[Resolved]
|
||||
private DialogOverlay dialogOverlay { get; set; }
|
||||
private IDialogOverlay dialogOverlay { get; set; }
|
||||
|
||||
public StorageErrorDialog(OsuStorage storage, OsuStorageError error)
|
||||
{
|
||||
|
@ -238,7 +238,7 @@ namespace osu.Game.Screens.OnlinePlay.Multiplayer
|
||||
}
|
||||
|
||||
[Resolved(canBeNull: true)]
|
||||
private DialogOverlay dialogOverlay { get; set; }
|
||||
private IDialogOverlay dialogOverlay { get; set; }
|
||||
|
||||
private bool exitConfirmed;
|
||||
|
||||
|
@ -28,7 +28,7 @@ namespace osu.Game.Screens.Select.Carousel
|
||||
private Action<int> viewDetails;
|
||||
|
||||
[Resolved(CanBeNull = true)]
|
||||
private DialogOverlay dialogOverlay { get; set; }
|
||||
private IDialogOverlay dialogOverlay { get; set; }
|
||||
|
||||
[Resolved(CanBeNull = true)]
|
||||
private CollectionManager collectionManager { get; set; }
|
||||
|
@ -87,7 +87,7 @@ namespace osu.Game.Screens.Select
|
||||
protected Container LeftArea { get; private set; }
|
||||
|
||||
private BeatmapInfoWedge beatmapInfoWedge;
|
||||
private DialogOverlay dialogOverlay;
|
||||
private IDialogOverlay dialogOverlay;
|
||||
|
||||
[Resolved]
|
||||
private BeatmapManager beatmaps { get; set; }
|
||||
@ -114,7 +114,7 @@ namespace osu.Game.Screens.Select
|
||||
private MusicController music { get; set; }
|
||||
|
||||
[BackgroundDependencyLoader(true)]
|
||||
private void load(AudioManager audio, DialogOverlay dialog, OsuColour colours, ManageCollectionsDialog manageCollectionsDialog, DifficultyRecommender recommender)
|
||||
private void load(AudioManager audio, IDialogOverlay dialog, OsuColour colours, ManageCollectionsDialog manageCollectionsDialog, DifficultyRecommender recommender)
|
||||
{
|
||||
// initial value transfer is required for FilterControl (it uses our re-cached bindables in its async load for the initial filter).
|
||||
transferRulesetValue();
|
||||
|
@ -98,7 +98,7 @@ namespace osu.Game.Tests.Visual
|
||||
{
|
||||
[Resolved(canBeNull: true)]
|
||||
[CanBeNull]
|
||||
private DialogOverlay dialogOverlay { get; set; }
|
||||
private IDialogOverlay dialogOverlay { get; set; }
|
||||
|
||||
public new void Undo() => base.Undo();
|
||||
|
||||
|
@ -23,7 +23,7 @@ namespace osu.Game.Tests.Visual
|
||||
|
||||
protected override Container<Drawable> Content => content;
|
||||
|
||||
[Cached]
|
||||
[Cached(typeof(IDialogOverlay))]
|
||||
protected DialogOverlay DialogOverlay { get; private set; }
|
||||
|
||||
protected ScreenTestScene()
|
||||
|
Loading…
Reference in New Issue
Block a user