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.
|
2018-09-10 03:51:38 +08:00
|
|
|
|
|
2023-07-17 14:59:15 +08:00
|
|
|
|
#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;
|
2023-07-17 14:59:15 +08:00
|
|
|
|
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;
|
2018-09-10 03:51:38 +08:00
|
|
|
|
|
2019-06-18 14:28:36 +08:00
|
|
|
|
namespace osu.Game.Tournament.Tests.Screens
|
2018-09-10 03:51:38 +08:00
|
|
|
|
{
|
2020-06-24 15:57:17 +08:00
|
|
|
|
public partial class TestSceneLadderEditorScreen : TournamentTestScene
|
2018-09-10 03:51:38 +08:00
|
|
|
|
{
|
2023-07-17 14:59:15 +08:00
|
|
|
|
private LadderEditorScreen ladderEditorScreen;
|
|
|
|
|
private OsuContextMenuContainer osuContextMenuContainer;
|
|
|
|
|
|
|
|
|
|
[SetUp]
|
|
|
|
|
public void Setup() => Schedule(() =>
|
2018-09-10 03:51:38 +08:00
|
|
|
|
{
|
2023-07-17 14:59:15 +08:00
|
|
|
|
Add(osuContextMenuContainer = new OsuContextMenuContainer
|
2018-09-21 18:58:47 +08:00
|
|
|
|
{
|
|
|
|
|
RelativeSizeAxes = Axes.Both,
|
2023-07-17 14:59:15 +08:00
|
|
|
|
Child = ladderEditorScreen = new LadderEditorScreen()
|
|
|
|
|
});
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
[Test]
|
2023-07-17 15:11:28 +08:00
|
|
|
|
public void TestResetBracketTeamsCancelled()
|
2023-07-17 14:59:15 +08:00
|
|
|
|
{
|
|
|
|
|
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);
|
2023-07-17 15:11:28 +08:00
|
|
|
|
AddStep("click cancel", () =>
|
2023-07-17 14:59:15 +08:00
|
|
|
|
{
|
2023-07-17 15:11:28 +08:00
|
|
|
|
InputManager.MoveMouseTo(dialogOverlay.CurrentDialog.ChildrenOfType<PopupDialogButton>().Last());
|
|
|
|
|
InputManager.Click(MouseButton.Left);
|
2023-07-17 14:59:15 +08:00
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
AddUntilStep("dialog dismissed", () => dialogOverlay.CurrentDialog is not LadderResetTeamsDialog);
|
|
|
|
|
|
2023-07-17 15:11:28 +08:00
|
|
|
|
AddAssert("assert ladder teams unchanged", () =>
|
2023-07-17 14:59:15 +08:00
|
|
|
|
{
|
2023-07-17 15:11:28 +08:00
|
|
|
|
return !Ladder.Matches.Any(m => m.Team1.Value == null && m.Team2.Value == null);
|
2023-07-17 14:59:15 +08:00
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
[Test]
|
2023-07-17 15:11:28 +08:00
|
|
|
|
public void TestResetBracketTeams()
|
2023-07-17 14:59:15 +08:00
|
|
|
|
{
|
|
|
|
|
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);
|
2023-07-17 15:11:28 +08:00
|
|
|
|
|
|
|
|
|
AddStep("click confirmation", () =>
|
2023-07-17 14:59:15 +08:00
|
|
|
|
{
|
2023-07-17 15:11:28 +08:00
|
|
|
|
InputManager.MoveMouseTo(dialogOverlay.CurrentDialog.ChildrenOfType<PopupDialogButton>().First());
|
|
|
|
|
InputManager.PressButton(MouseButton.Left);
|
2023-07-17 14:59:15 +08:00
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
AddUntilStep("dialog dismissed", () => dialogOverlay.CurrentDialog is not LadderResetTeamsDialog);
|
|
|
|
|
|
2023-07-17 15:11:28 +08:00
|
|
|
|
AddStep("release mouse button", () => InputManager.ReleaseButton(MouseButton.Left));
|
|
|
|
|
|
|
|
|
|
AddAssert("assert ladder teams reset", () =>
|
2023-07-17 14:59:15 +08:00
|
|
|
|
{
|
2023-07-17 15:11:28 +08:00
|
|
|
|
return Ladder.Matches.All(m => m.Team1.Value == null && m.Team2.Value == null);
|
2018-10-13 06:09:33 +08:00
|
|
|
|
});
|
2018-09-10 03:51:38 +08:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|