2021-10-24 00:05:30 +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.
|
|
|
|
|
2021-10-24 00:41:31 +08:00
|
|
|
using System.Linq;
|
2021-10-24 00:05:30 +08:00
|
|
|
using NUnit.Framework;
|
|
|
|
using osu.Framework.Allocation;
|
|
|
|
using osu.Framework.Graphics;
|
2021-10-24 00:41:31 +08:00
|
|
|
using osu.Framework.Graphics.Sprites;
|
|
|
|
using osu.Framework.Testing;
|
2021-10-24 00:05:30 +08:00
|
|
|
using osu.Game.Beatmaps.Drawables.Cards;
|
2021-10-24 00:41:31 +08:00
|
|
|
using osu.Game.Beatmaps.Drawables.Cards.Buttons;
|
2021-10-24 00:05:30 +08:00
|
|
|
using osu.Game.Overlays;
|
|
|
|
using osuTK;
|
2021-10-24 00:41:31 +08:00
|
|
|
using osuTK.Input;
|
2021-10-24 00:05:30 +08:00
|
|
|
|
|
|
|
namespace osu.Game.Tests.Visual.Beatmaps
|
|
|
|
{
|
2021-10-24 00:41:31 +08:00
|
|
|
public class TestSceneBeatmapCardThumbnail : OsuManualInputManagerTestScene
|
2021-10-24 00:05:30 +08:00
|
|
|
{
|
2021-10-24 00:41:31 +08:00
|
|
|
private PlayButton playButton => this.ChildrenOfType<PlayButton>().Single();
|
|
|
|
|
2021-10-24 00:05:30 +08:00
|
|
|
[Cached]
|
|
|
|
private OverlayColourProvider colourProvider = new OverlayColourProvider(OverlayColourScheme.Blue);
|
|
|
|
|
|
|
|
[Test]
|
|
|
|
public void TestThumbnailPreview()
|
|
|
|
{
|
|
|
|
BeatmapCardThumbnail thumbnail = null;
|
|
|
|
|
|
|
|
AddStep("create thumbnail", () => Child = thumbnail = new BeatmapCardThumbnail(CreateAPIBeatmapSet(Ruleset.Value))
|
|
|
|
{
|
|
|
|
Anchor = Anchor.Centre,
|
|
|
|
Origin = Anchor.Centre,
|
|
|
|
Size = new Vector2(200)
|
|
|
|
});
|
2021-10-24 00:41:31 +08:00
|
|
|
AddStep("enable dim", () => thumbnail.Dimmed.Value = true);
|
|
|
|
AddUntilStep("button visible", () => playButton.IsPresent);
|
|
|
|
|
|
|
|
AddStep("click button", () =>
|
|
|
|
{
|
|
|
|
InputManager.MoveMouseTo(playButton);
|
|
|
|
InputManager.Click(MouseButton.Left);
|
|
|
|
});
|
|
|
|
iconIs(FontAwesome.Solid.Stop);
|
|
|
|
|
|
|
|
AddStep("click again", () =>
|
|
|
|
{
|
|
|
|
InputManager.MoveMouseTo(playButton);
|
|
|
|
InputManager.Click(MouseButton.Left);
|
|
|
|
});
|
|
|
|
iconIs(FontAwesome.Solid.Play);
|
|
|
|
|
|
|
|
AddStep("click again", () =>
|
|
|
|
{
|
|
|
|
InputManager.MoveMouseTo(playButton);
|
|
|
|
InputManager.Click(MouseButton.Left);
|
|
|
|
});
|
|
|
|
iconIs(FontAwesome.Solid.Stop);
|
|
|
|
|
|
|
|
AddStep("disable dim", () => thumbnail.Dimmed.Value = false);
|
|
|
|
AddWaitStep("wait some", 3);
|
|
|
|
AddAssert("button still visible", () => playButton.IsPresent);
|
|
|
|
|
|
|
|
AddStep("end track playback", () => playButton.Playing.Value = false);
|
|
|
|
AddUntilStep("button hidden", () => !playButton.IsPresent);
|
2021-10-24 00:05:30 +08:00
|
|
|
}
|
2021-10-24 00:41:31 +08:00
|
|
|
|
|
|
|
private void iconIs(IconUsage usage) => AddAssert("icon is correct", () => playButton.ChildrenOfType<SpriteIcon>().Single().Icon.Equals(usage));
|
2021-10-24 00:05:30 +08:00
|
|
|
}
|
|
|
|
}
|