1
0
mirror of https://github.com/ppy/osu.git synced 2024-09-21 20:47:28 +08:00
osu-lazer/osu.Game.Tournament.Tests/Screens/TestSceneLadderEditorScreen.cs

Ignoring revisions in .git-blame-ignore-revs. Click here to bypass and see the normal blame view.

101 lines
3.6 KiB
C#
Raw Normal View History

2019-03-04 12:24:19 +08:00
// 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.
#nullable disable
using System.Linq;
using NUnit.Framework;
2018-09-21 18:58:47 +08:00
using osu.Framework.Graphics;
using osu.Game.Graphics.Cursor;
2019-06-18 14:28:36 +08:00
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;
2019-06-18 14:28:36 +08:00
namespace osu.Game.Tournament.Tests.Screens
{
public partial class TestSceneLadderEditorScreen : TournamentTestScene
{
private LadderEditorScreen ladderEditorScreen;
private OsuContextMenuContainer osuContextMenuContainer;
[SetUp]
public void Setup() => Schedule(() =>
{
Add(osuContextMenuContainer = new OsuContextMenuContainer
2018-09-21 18:58:47 +08:00
{
RelativeSizeAxes = Axes.Both,
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);
});
}
}
}