mirror of
https://github.com/ppy/osu.git
synced 2024-12-13 07:43:00 +08:00
add ladder editor reset teams confirmation dialog test
This commit is contained in:
parent
e7795296e2
commit
3510394699
@ -1,22 +1,99 @@
|
||||
// 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;
|
||||
#nullable disable
|
||||
|
||||
using System.Linq;
|
||||
using NUnit.Framework;
|
||||
using osu.Framework.Graphics;
|
||||
using osu.Game.Graphics.Cursor;
|
||||
using osu.Game.Tournament.Screens.Editors;
|
||||
using osu.Framework.Testing;
|
||||
using osu.Game.Graphics.UserInterface;
|
||||
using osu.Game.Overlays.Dialog;
|
||||
using osu.Game.Tournament.Screens.Ladder.Components;
|
||||
using osuTK;
|
||||
using osuTK.Input;
|
||||
|
||||
namespace osu.Game.Tournament.Tests.Screens
|
||||
{
|
||||
public partial class TestSceneLadderEditorScreen : TournamentTestScene
|
||||
{
|
||||
[BackgroundDependencyLoader]
|
||||
private void load()
|
||||
private LadderEditorScreen ladderEditorScreen;
|
||||
private OsuContextMenuContainer osuContextMenuContainer;
|
||||
|
||||
[SetUp]
|
||||
public void Setup() => Schedule(() =>
|
||||
{
|
||||
Add(new OsuContextMenuContainer
|
||||
Add(osuContextMenuContainer = new OsuContextMenuContainer
|
||||
{
|
||||
RelativeSizeAxes = Axes.Both,
|
||||
Child = new LadderEditorScreen()
|
||||
Child = ladderEditorScreen = new LadderEditorScreen()
|
||||
});
|
||||
});
|
||||
|
||||
[Test]
|
||||
public void TestResetBracketTeams()
|
||||
{
|
||||
AddStep("pull up context menu", () =>
|
||||
{
|
||||
InputManager.MoveMouseTo(ladderEditorScreen);
|
||||
InputManager.Click(MouseButton.Right);
|
||||
});
|
||||
|
||||
AddStep("click Reset teams button", () =>
|
||||
{
|
||||
InputManager.MoveMouseTo(osuContextMenuContainer.ChildrenOfType<DrawableOsuMenuItem>().Last(p =>
|
||||
((OsuMenuItem)p.Item).Type == MenuItemType.Destructive), new Vector2(5, 0));
|
||||
InputManager.Click(MouseButton.Left);
|
||||
});
|
||||
|
||||
AddAssert("dialog displayed", () => dialogOverlay.CurrentDialog is LadderResetTeamsDialog);
|
||||
|
||||
AddStep("click confirmation", () =>
|
||||
{
|
||||
InputManager.MoveMouseTo(dialogOverlay.CurrentDialog.ChildrenOfType<PopupDialogButton>().First());
|
||||
InputManager.PressButton(MouseButton.Left);
|
||||
});
|
||||
|
||||
AddUntilStep("dialog dismissed", () => dialogOverlay.CurrentDialog is not LadderResetTeamsDialog);
|
||||
|
||||
AddStep("release mouse button", () => InputManager.ReleaseButton(MouseButton.Left));
|
||||
|
||||
AddAssert("assert ladder teams reset", () =>
|
||||
{
|
||||
return Ladder.Matches.All(m => m.Team1.Value == null && m.Team2.Value == null);
|
||||
});
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void TestResetBracketTeamsCancelled()
|
||||
{
|
||||
AddStep("pull up context menu", () =>
|
||||
{
|
||||
InputManager.MoveMouseTo(ladderEditorScreen);
|
||||
InputManager.Click(MouseButton.Right);
|
||||
});
|
||||
|
||||
AddStep("click Reset teams button", () =>
|
||||
{
|
||||
InputManager.MoveMouseTo(osuContextMenuContainer.ChildrenOfType<DrawableOsuMenuItem>().Last(p =>
|
||||
((OsuMenuItem)p.Item).Type == MenuItemType.Destructive), new Vector2(5, 0));
|
||||
InputManager.Click(MouseButton.Left);
|
||||
});
|
||||
|
||||
AddAssert("dialog displayed", () => dialogOverlay.CurrentDialog is LadderResetTeamsDialog);
|
||||
AddStep("click cancel", () =>
|
||||
{
|
||||
InputManager.MoveMouseTo(dialogOverlay.CurrentDialog.ChildrenOfType<PopupDialogButton>().Last());
|
||||
InputManager.Click(MouseButton.Left);
|
||||
});
|
||||
|
||||
AddUntilStep("dialog dismissed", () => dialogOverlay.CurrentDialog is not LadderResetTeamsDialog);
|
||||
|
||||
AddAssert("assert ladder teams unchanged", () =>
|
||||
{
|
||||
return !Ladder.Matches.Any(m => m.Team1.Value == null && m.Team2.Value == null);
|
||||
});
|
||||
}
|
||||
}
|
||||
|
@ -10,6 +10,7 @@ using osu.Framework.Platform;
|
||||
using osu.Framework.Testing;
|
||||
using osu.Framework.Utils;
|
||||
using osu.Game.Beatmaps;
|
||||
using osu.Game.Overlays;
|
||||
using osu.Game.Rulesets;
|
||||
using osu.Game.Tests.Visual;
|
||||
using osu.Game.Tournament.IO;
|
||||
@ -18,9 +19,10 @@ using osu.Game.Tournament.Models;
|
||||
|
||||
namespace osu.Game.Tournament.Tests
|
||||
{
|
||||
public abstract partial class TournamentTestScene : OsuTestScene
|
||||
public abstract partial class TournamentTestScene : OsuManualInputManagerTestScene
|
||||
{
|
||||
private TournamentMatch match;
|
||||
protected DialogOverlay dialogOverlay;
|
||||
|
||||
[Cached]
|
||||
protected LadderInfo Ladder { get; private set; } = new LadderInfo();
|
||||
@ -45,6 +47,10 @@ namespace osu.Game.Tournament.Tests
|
||||
|
||||
Ruleset.BindTo(Ladder.Ruleset);
|
||||
Dependencies.CacheAs(new StableInfo(storage));
|
||||
|
||||
Add(dialogOverlay = new DialogOverlay { Depth = -1 });
|
||||
|
||||
Dependencies.CacheAs<IDialogOverlay>(dialogOverlay);
|
||||
}
|
||||
|
||||
[SetUpSteps]
|
||||
|
Loading…
Reference in New Issue
Block a user