1
0
mirror of https://github.com/ppy/osu.git synced 2024-12-14 12:33:01 +08:00

Merge pull request #18642 from Joehuu/fix-play-button-touch

Fix beatmap card play button not working with touch inputs when not hovered
This commit is contained in:
Dean Herbert 2022-09-09 19:41:05 +09:00 committed by GitHub
commit 8f9df9c7b4
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 25 additions and 3 deletions

View File

@ -15,12 +15,14 @@ using osu.Framework.Testing;
using osu.Game.Beatmaps;
using osu.Game.Beatmaps.Drawables;
using osu.Game.Beatmaps.Drawables.Cards;
using osu.Game.Beatmaps.Drawables.Cards.Buttons;
using osu.Game.Graphics.Containers;
using osu.Game.Online.API;
using osu.Game.Online.API.Requests;
using osu.Game.Online.API.Requests.Responses;
using osu.Game.Overlays;
using osuTK;
using osuTK.Input;
namespace osu.Game.Tests.Visual.Beatmaps
{
@ -295,5 +297,22 @@ namespace osu.Game.Tests.Visual.Beatmaps
BeatmapCardNormal firstCard() => this.ChildrenOfType<BeatmapCardNormal>().First();
}
[Test]
public void TestPlayButtonByTouchInput()
{
AddStep("create cards", () => Child = createContent(OverlayColourScheme.Blue, beatmapSetInfo => new BeatmapCardNormal(beatmapSetInfo)));
// mimics touch input
AddStep("touch play button area on first card", () =>
{
InputManager.MoveMouseTo(firstCard().ChildrenOfType<PlayButton>().Single());
InputManager.Click(MouseButton.Left);
});
AddAssert("first card is playing", () => firstCard().ChildrenOfType<PlayButton>().Single().Playing.Value);
BeatmapCardNormal firstCard() => this.ChildrenOfType<BeatmapCardNormal>().First();
}
}
}

View File

@ -42,7 +42,7 @@ namespace osu.Game.Tests.Visual.Beatmaps
};
});
AddStep("enable dim", () => thumbnail.Dimmed.Value = true);
AddUntilStep("button visible", () => playButton.IsPresent);
AddUntilStep("button visible", () => playButton.Alpha == 1);
AddStep("click button", () =>
{
@ -70,7 +70,7 @@ namespace osu.Game.Tests.Visual.Beatmaps
AddStep("disable dim", () => thumbnail.Dimmed.Value = false);
AddWaitStep("wait some", 3);
AddAssert("button still visible", () => playButton.IsPresent);
AddAssert("button still visible", () => playButton.Alpha == 1);
// The track plays in real-time, so we need to check for progress in increments to avoid timeout.
AddUntilStep("progress > 0.25", () => thumbnail.ChildrenOfType<PlayButton>().Single().Progress.Value > 0.25);
@ -78,7 +78,7 @@ namespace osu.Game.Tests.Visual.Beatmaps
AddUntilStep("progress > 0.75", () => thumbnail.ChildrenOfType<PlayButton>().Single().Progress.Value > 0.75);
AddUntilStep("wait for track to end", () => !playButton.Playing.Value);
AddUntilStep("button hidden", () => !playButton.IsPresent);
AddUntilStep("button hidden", () => playButton.Alpha == 0);
}
private void iconIs(IconUsage usage) => AddUntilStep("icon is correct", () => playButton.ChildrenOfType<SpriteIcon>().Any(icon => icon.Icon.Equals(usage)));

View File

@ -41,6 +41,9 @@ namespace osu.Game.Beatmaps.Drawables.Cards.Buttons
Anchor = Origin = Anchor.Centre;
// needed for touch input to work when card is not hovered/expanded
AlwaysPresent = true;
Children = new Drawable[]
{
icon = new SpriteIcon