mirror of
https://github.com/ppy/osu.git
synced 2024-11-11 13:37:25 +08:00
Add test cases for new randomizer behaviour
This commit is contained in:
parent
ce156098f6
commit
843e9c53c0
@ -128,6 +128,20 @@ namespace osu.Game.Tests.Visual
|
||||
selectedSets.Pop();
|
||||
});
|
||||
|
||||
private bool selectedBeatmapVisible()
|
||||
{
|
||||
var currentlySelected = carousel.Items.FirstOrDefault(s => s.Item is CarouselBeatmap && s.Item.State == CarouselItemState.Selected);
|
||||
if (currentlySelected == null)
|
||||
return true;
|
||||
return !currentlySelected.Item.Filtered;
|
||||
}
|
||||
|
||||
private void checkInvisibleDifficultiesUnselectable()
|
||||
{
|
||||
nextRandom();
|
||||
AddAssert("Selection is visible", selectedBeatmapVisible);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Test keyboard traversal
|
||||
/// </summary>
|
||||
@ -222,6 +236,15 @@ namespace osu.Game.Tests.Visual
|
||||
|
||||
nextRandom();
|
||||
AddAssert("ensure repeat", () => selectedSets.Contains(carousel.SelectedBeatmapSet));
|
||||
|
||||
AddStep("Add set with 100 difficulties", () => carousel.UpdateBeatmapSet(createTestBeatmapSetWith100Difficulties(set_count + 1)));
|
||||
AddStep("Filter Extra", () => carousel.Filter(new FilterCriteria { SearchText = "Extra 10" }, false));
|
||||
checkInvisibleDifficultiesUnselectable();
|
||||
checkInvisibleDifficultiesUnselectable();
|
||||
checkInvisibleDifficultiesUnselectable();
|
||||
checkInvisibleDifficultiesUnselectable();
|
||||
checkInvisibleDifficultiesUnselectable();
|
||||
AddStep("Un-filter", () => carousel.Filter(new FilterCriteria(), false));
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@ -384,6 +407,40 @@ namespace osu.Game.Tests.Visual
|
||||
};
|
||||
}
|
||||
|
||||
private BeatmapSetInfo createTestBeatmapSetWith100Difficulties(int i)
|
||||
{
|
||||
var toReturn = new BeatmapSetInfo
|
||||
{
|
||||
ID = i,
|
||||
OnlineBeatmapSetID = i,
|
||||
Hash = new MemoryStream(Encoding.UTF8.GetBytes(Guid.NewGuid().ToString())).ComputeMD5Hash(),
|
||||
Metadata = new BeatmapMetadata
|
||||
{
|
||||
OnlineBeatmapSetID = i,
|
||||
// Create random metadata, then we can check if sorting works based on these
|
||||
Artist = $"peppy{i.ToString().PadLeft(6, '0')}",
|
||||
Title = $"test set #{i}!",
|
||||
AuthorString = string.Concat(Enumerable.Repeat((char)('z' - Math.Min(25, i - 1)), 5))
|
||||
},
|
||||
Beatmaps = new List<BeatmapInfo>(),
|
||||
};
|
||||
for (int b = 1; b < 101; b++)
|
||||
{
|
||||
toReturn.Beatmaps.Add(new BeatmapInfo
|
||||
{
|
||||
OnlineBeatmapID = b * 10,
|
||||
Path = $"extra{b}.osu",
|
||||
Version = $"Extra {b}",
|
||||
StarDifficulty = 2,
|
||||
BaseDifficulty = new BeatmapDifficulty
|
||||
{
|
||||
OverallDifficulty = 3.5f,
|
||||
}
|
||||
});
|
||||
}
|
||||
return toReturn;
|
||||
}
|
||||
|
||||
private class TestBeatmapCarousel : BeatmapCarousel
|
||||
{
|
||||
public new List<DrawableCarouselItem> Items => base.Items;
|
||||
|
Loading…
Reference in New Issue
Block a user