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;
|
|
|
|
|
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
|
|
|
|
|
{
|
|
|
|
|
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", () =>
|
|
|
|
|
{
|
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);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|