mirror of
https://github.com/ppy/osu.git
synced 2026-05-16 10:22:53 +08:00
Add failing tests showing carousel incorrectly requesting start when traversing single items
This commit is contained in:
@@ -191,6 +191,12 @@ namespace osu.Game.Tests.Visual.SongSelectV2
|
||||
protected void CheckNoSelection() => AddAssert("has no selection", () => Carousel.CurrentSelection, () => Is.Null);
|
||||
protected void CheckHasSelection() => AddAssert("has selection", () => Carousel.CurrentSelection, () => Is.Not.Null);
|
||||
|
||||
protected void CheckRequestPresentCount(int expected) =>
|
||||
AddAssert($"check present count is {expected}", () => Carousel.RequestPresentBeatmapCount, () => Is.EqualTo(expected));
|
||||
|
||||
protected void CheckActivationCount(int expected) =>
|
||||
AddAssert($"check activation count is {expected}", () => Carousel.ActivationCount, () => Is.EqualTo(expected));
|
||||
|
||||
protected void CheckDisplayedBeatmapsCount(int expected)
|
||||
{
|
||||
AddAssert($"{expected} diffs displayed", () => Carousel.MatchedBeatmapsCount, () => Is.EqualTo(expected));
|
||||
@@ -375,6 +381,9 @@ namespace osu.Game.Tests.Visual.SongSelectV2
|
||||
|
||||
public partial class TestBeatmapCarousel : BeatmapCarousel
|
||||
{
|
||||
public int ActivationCount { get; private set; }
|
||||
public int RequestPresentBeatmapCount { get; private set; }
|
||||
|
||||
public int FilterDelay = 0;
|
||||
|
||||
public IEnumerable<BeatmapInfo> PostFilterBeatmaps = null!;
|
||||
@@ -385,6 +394,17 @@ namespace osu.Game.Tests.Visual.SongSelectV2
|
||||
public new BeatmapSetInfo? ExpandedBeatmapSet => base.ExpandedBeatmapSet;
|
||||
public new GroupDefinition? ExpandedGroup => base.ExpandedGroup;
|
||||
|
||||
public TestBeatmapCarousel()
|
||||
{
|
||||
RequestPresentBeatmap = _ => RequestPresentBeatmapCount++;
|
||||
}
|
||||
|
||||
protected override void HandleItemActivated(CarouselItem item)
|
||||
{
|
||||
ActivationCount++;
|
||||
base.HandleItemActivated(item);
|
||||
}
|
||||
|
||||
protected override async Task<IEnumerable<CarouselItem>> FilterAsync(bool clearExistingPanels = false)
|
||||
{
|
||||
var items = await base.FilterAsync(clearExistingPanels);
|
||||
|
||||
@@ -190,6 +190,58 @@ namespace osu.Game.Tests.Visual.SongSelectV2
|
||||
WaitForSelection(4, 0);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void TestSingleItemTraversal()
|
||||
{
|
||||
CheckNoSelection();
|
||||
AddBeatmaps(1, 3);
|
||||
|
||||
WaitForSelection(0, 0);
|
||||
CheckActivationCount(0);
|
||||
|
||||
SelectNextGroup();
|
||||
WaitForSelection(0, 0);
|
||||
|
||||
// In the case of a grouped beatmap set, the header gets activated and re-selects the recommended difficulty.
|
||||
// This is probably fine.
|
||||
CheckActivationCount(1);
|
||||
// We don't want it to request present though, which would start gameplay.
|
||||
CheckRequestPresentCount(0);
|
||||
|
||||
SelectPrevGroup();
|
||||
WaitForSelection(0, 0);
|
||||
|
||||
CheckActivationCount(1);
|
||||
CheckRequestPresentCount(0);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void TestSingleItemTraversal_DifficultySplit()
|
||||
{
|
||||
SortBy(SortMode.Difficulty);
|
||||
|
||||
CheckNoSelection();
|
||||
AddBeatmaps(1, 1);
|
||||
|
||||
WaitForSelection(0, 0);
|
||||
CheckActivationCount(0);
|
||||
|
||||
SelectNextGroup();
|
||||
WaitForSelection(0, 0);
|
||||
|
||||
// In the case of a grouped beatmap set, the header gets activated and re-selects the recommended difficulty.
|
||||
// This is probably fine.
|
||||
CheckActivationCount(0);
|
||||
// We don't want it to request present though, which would start gameplay.
|
||||
CheckRequestPresentCount(0);
|
||||
|
||||
SelectPrevGroup();
|
||||
WaitForSelection(0, 0);
|
||||
|
||||
CheckActivationCount(0);
|
||||
CheckRequestPresentCount(0);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void TestEmptyTraversal()
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user