mirror of
https://github.com/ppy/osu.git
synced 2024-11-15 22:37:26 +08:00
72 lines
2.4 KiB
C#
72 lines
2.4 KiB
C#
// 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;
|
|
using osu.Framework.Graphics;
|
|
using osu.Framework.Graphics.Containers;
|
|
using osu.Framework.Graphics.Cursor;
|
|
using osu.Framework.Testing;
|
|
using osu.Game.Beatmaps;
|
|
using osu.Game.Screens.Ranking;
|
|
using osuTK;
|
|
using osuTK.Input;
|
|
|
|
namespace osu.Game.Tests.Visual.Ranking
|
|
{
|
|
public partial class TestSceneCollectionButton : OsuManualInputManagerTestScene
|
|
{
|
|
private CollectionButton collectionButton;
|
|
private BeatmapInfo beatmapInfo = new BeatmapInfo { OnlineID = 88 };
|
|
|
|
[SetUpSteps]
|
|
public void SetUpSteps()
|
|
{
|
|
AddStep("create button", () => Child = new PopoverContainer
|
|
{
|
|
Depth = -1,
|
|
RelativeSizeAxes = Axes.Both,
|
|
Anchor = Anchor.Centre,
|
|
Origin = Anchor.Centre,
|
|
Child = collectionButton = new CollectionButton(beatmapInfo)
|
|
{
|
|
RelativeSizeAxes = Axes.None,
|
|
Size = new Vector2(50),
|
|
}
|
|
});
|
|
}
|
|
|
|
[Test]
|
|
public void TestCollectionButton()
|
|
{
|
|
AddStep("click collection button", () =>
|
|
{
|
|
InputManager.MoveMouseTo(collectionButton);
|
|
InputManager.Click(MouseButton.Left);
|
|
});
|
|
|
|
AddAssert("collection popover is visible", () => this.ChildrenOfType<CollectionPopover>().Single().State.Value == Visibility.Visible);
|
|
|
|
AddStep("click outside popover", () =>
|
|
{
|
|
InputManager.MoveMouseTo(ScreenSpaceDrawQuad.TopLeft);
|
|
InputManager.Click(MouseButton.Left);
|
|
});
|
|
|
|
AddAssert("collection popover is hidden", () => this.ChildrenOfType<CollectionPopover>().Single().State.Value == Visibility.Hidden);
|
|
|
|
AddStep("click collection button", () =>
|
|
{
|
|
InputManager.MoveMouseTo(collectionButton);
|
|
InputManager.Click(MouseButton.Left);
|
|
});
|
|
|
|
AddStep("press escape", () => InputManager.Key(Key.Escape));
|
|
|
|
AddAssert("collection popover is hidden", () => this.ChildrenOfType<CollectionPopover>().Single().State.Value == Visibility.Hidden);
|
|
}
|
|
}
|
|
}
|