1
0
mirror of https://github.com/ppy/osu.git synced 2025-01-14 03:25:11 +08:00

Fix failing tests

This commit is contained in:
Dean Herbert 2020-10-13 17:09:54 +09:00
parent b536f571fd
commit 1f0aa974dd
2 changed files with 39 additions and 16 deletions

View File

@ -427,7 +427,7 @@ namespace osu.Game.Tests.Visual.SongSelect
for (int i = 0; i < 3; i++)
{
var set = createTestBeatmapSet(i, 3);
var set = createTestBeatmapSet(i);
set.Beatmaps[0].StarDifficulty = 3 - i;
set.Beatmaps[2].StarDifficulty = 6 + i;
sets.Add(set);
@ -822,7 +822,7 @@ namespace osu.Game.Tests.Visual.SongSelect
AddAssert("Selection is visible", selectedBeatmapVisible);
}
private BeatmapSetInfo createTestBeatmapSet(int id, int minimumDifficulties = 1)
private BeatmapSetInfo createTestBeatmapSet(int id, bool randomDifficultyCount = false)
{
return new BeatmapSetInfo
{
@ -836,7 +836,7 @@ namespace osu.Game.Tests.Visual.SongSelect
Title = $"test set #{id}!",
AuthorString = string.Concat(Enumerable.Repeat((char)('z' - Math.Min(25, id - 1)), 5))
},
Beatmaps = getBeatmaps(RNG.Next(minimumDifficulties, 20)).ToList()
Beatmaps = getBeatmaps(randomDifficultyCount ? RNG.Next(1, 20) : 3).ToList()
};
}
@ -846,14 +846,22 @@ namespace osu.Game.Tests.Visual.SongSelect
for (int i = 0; i < count; i++)
{
float diff = (float)i / count * 10;
string version = "Normal";
if (diff > 6.6)
version = "Insane";
else if (diff > 3.3)
version = "Hard";
yield return new BeatmapInfo
{
OnlineBeatmapID = id++ * 10,
Version = "Normal",
StarDifficulty = RNG.NextSingle() * 10,
Version = version,
StarDifficulty = diff,
BaseDifficulty = new BeatmapDifficulty
{
OverallDifficulty = RNG.NextSingle() * 10,
OverallDifficulty = diff,
}
};
}
@ -899,7 +907,22 @@ namespace osu.Game.Tests.Visual.SongSelect
{
public bool PendingFilterTask => PendingFilter != null;
public IEnumerable<DrawableCarouselItem> Items => InternalChildren.OfType<DrawableCarouselItem>();
public IEnumerable<DrawableCarouselItem> Items
{
get
{
foreach (var item in ScrollableContent)
{
yield return item;
if (item is DrawableCarouselBeatmapSet set)
{
foreach (var difficulty in set.ChildItems)
yield return difficulty;
}
}
}
}
protected override IEnumerable<BeatmapSetInfo> GetLoadableBeatmaps() => Enumerable.Empty<BeatmapSetInfo>();
}

View File

@ -101,7 +101,7 @@ namespace osu.Game.Screens.Select
if (selectedBeatmapSet != null && !beatmapSets.Contains(selectedBeatmapSet.BeatmapSet))
selectedBeatmapSet = null;
scrollableContent.Clear(false);
ScrollableContent.Clear(false);
itemsCache.Invalidate();
scrollPositionCache.Invalidate();
@ -121,7 +121,7 @@ namespace osu.Game.Screens.Select
private readonly Cached itemsCache = new Cached();
private readonly Cached scrollPositionCache = new Cached();
private readonly Container<DrawableCarouselItem> scrollableContent;
protected readonly Container<DrawableCarouselItem> ScrollableContent;
public Bindable<bool> RightClickScrollingEnabled = new Bindable<bool>();
@ -151,7 +151,7 @@ namespace osu.Game.Screens.Select
Children = new Drawable[]
{
setPool,
scrollableContent = new Container<DrawableCarouselItem>
ScrollableContent = new Container<DrawableCarouselItem>
{
RelativeSizeAxes = Axes.X,
}
@ -595,7 +595,7 @@ namespace osu.Game.Screens.Select
var toDisplay = visibleItems.GetRange(displayedRange.first, displayedRange.last - displayedRange.first);
foreach (var panel in scrollableContent.Children)
foreach (var panel in ScrollableContent.Children)
{
if (toDisplay.Remove(panel.Item))
{
@ -622,7 +622,7 @@ namespace osu.Game.Screens.Select
panel.Depth = item.CarouselYPosition;
panel.Y = item.CarouselYPosition;
scrollableContent.Add(panel);
ScrollableContent.Add(panel);
}
}
@ -630,7 +630,7 @@ namespace osu.Game.Screens.Select
// This is common if a selected/collapsed state has changed.
if (revalidateItems)
{
foreach (DrawableCarouselItem panel in scrollableContent.Children)
foreach (DrawableCarouselItem panel in ScrollableContent.Children)
{
panel.MoveToY(panel.Item.CarouselYPosition, 800, Easing.OutQuint);
}
@ -638,7 +638,7 @@ namespace osu.Game.Screens.Select
// Update externally controlled state of currently visible items (e.g. x-offset and opacity).
// This is a per-frame update on all drawable panels.
foreach (DrawableCarouselItem item in scrollableContent.Children)
foreach (DrawableCarouselItem item in ScrollableContent.Children)
{
updateItem(item);
@ -786,7 +786,7 @@ namespace osu.Game.Screens.Select
}
currentY += visibleHalfHeight;
scrollableContent.Height = currentY;
ScrollableContent.Height = currentY;
if (BeatmapSetsLoaded && (selectedBeatmapSet == null || selectedBeatmap == null || selectedBeatmapSet.State.Value != CarouselItemState.Selected))
{
@ -841,7 +841,7 @@ namespace osu.Game.Screens.Select
/// <param name="parent">For nested items, the parent of the item to be updated.</param>
private void updateItem(DrawableCarouselItem item, DrawableCarouselItem parent = null)
{
Vector2 posInScroll = scrollableContent.ToLocalSpace(item.Header.ScreenSpaceDrawQuad.Centre);
Vector2 posInScroll = ScrollableContent.ToLocalSpace(item.Header.ScreenSpaceDrawQuad.Centre);
float itemDrawY = posInScroll.Y - visibleUpperBound;
float dist = Math.Abs(1f - itemDrawY / visibleHalfHeight);