1
0
mirror of https://github.com/ppy/osu.git synced 2024-11-16 00:37:26 +08:00
osu-lazer/osu.Game.Tests/Visual/Ranking/TestSceneCollectionButton.cs

68 lines
2.3 KiB
C#
Raw Normal View History

2024-07-22 07:14:26 +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.
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.Input;
namespace osu.Game.Tests.Visual.Ranking
{
public partial class TestSceneCollectionButton : OsuManualInputManagerTestScene
{
2024-07-22 14:46:04 +08:00
private CollectionButton? collectionButton;
2024-07-22 08:32:48 +08:00
private readonly BeatmapInfo beatmapInfo = new BeatmapInfo { OnlineID = 88 };
2024-07-22 07:14:26 +08:00
[SetUpSteps]
public void SetUpSteps()
{
AddStep("create button", () => Child = new PopoverContainer
{
RelativeSizeAxes = Axes.Both,
Anchor = Anchor.Centre,
Origin = Anchor.Centre,
Child = collectionButton = new CollectionButton(beatmapInfo)
{
2024-07-28 09:32:35 +08:00
Anchor = Anchor.Centre,
Origin = Anchor.Centre,
},
2024-07-22 07:14:26 +08:00
});
}
[Test]
public void TestCollectionButton()
{
AddStep("click collection button", () =>
{
2024-07-22 14:46:04 +08:00
InputManager.MoveMouseTo(collectionButton!);
2024-07-22 07:14:26 +08:00
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", () =>
{
2024-07-22 14:46:04 +08:00
InputManager.MoveMouseTo(collectionButton!);
2024-07-22 07:14:26 +08:00
InputManager.Click(MouseButton.Left);
});
AddStep("press escape", () => InputManager.Key(Key.Escape));
AddAssert("collection popover is hidden", () => this.ChildrenOfType<CollectionPopover>().Single().State.Value == Visibility.Hidden);
}
}
}