mirror of
https://github.com/ppy/osu.git
synced 2024-11-06 14:37:25 +08:00
Merge pull request #16214 from bdach/beatmap-listing-overlay-flaky-hide
Fix placeholder drawables on beatmap listing not always showing correctly
This commit is contained in:
commit
c0add5661e
@ -7,6 +7,7 @@ using System.Linq;
|
|||||||
using NUnit.Framework;
|
using NUnit.Framework;
|
||||||
using osu.Framework.Graphics.Containers;
|
using osu.Framework.Graphics.Containers;
|
||||||
using osu.Framework.Testing;
|
using osu.Framework.Testing;
|
||||||
|
using osu.Game.Beatmaps.Drawables.Cards;
|
||||||
using osu.Game.Graphics.UserInterface;
|
using osu.Game.Graphics.UserInterface;
|
||||||
using osu.Game.Online.API;
|
using osu.Game.Online.API;
|
||||||
using osu.Game.Online.API.Requests;
|
using osu.Game.Online.API.Requests;
|
||||||
@ -110,17 +111,25 @@ namespace osu.Game.Tests.Visual.Online
|
|||||||
public void TestNoBeatmapsPlaceholder()
|
public void TestNoBeatmapsPlaceholder()
|
||||||
{
|
{
|
||||||
AddStep("fetch for 0 beatmaps", () => fetchFor());
|
AddStep("fetch for 0 beatmaps", () => fetchFor());
|
||||||
AddUntilStep("placeholder shown", () => overlay.ChildrenOfType<BeatmapListingOverlay.NotFoundDrawable>().SingleOrDefault()?.IsPresent == true);
|
placeholderShown();
|
||||||
|
|
||||||
AddStep("fetch for 1 beatmap", () => fetchFor(CreateAPIBeatmapSet(Ruleset.Value)));
|
AddStep("show many results", () => fetchFor(Enumerable.Repeat(CreateAPIBeatmapSet(Ruleset.Value), 100).ToArray()));
|
||||||
|
AddUntilStep("wait for loaded", () => this.ChildrenOfType<BeatmapCard>().Count() == 100);
|
||||||
AddUntilStep("placeholder hidden", () => !overlay.ChildrenOfType<BeatmapListingOverlay.NotFoundDrawable>().Any(d => d.IsPresent));
|
AddUntilStep("placeholder hidden", () => !overlay.ChildrenOfType<BeatmapListingOverlay.NotFoundDrawable>().Any(d => d.IsPresent));
|
||||||
|
|
||||||
AddStep("fetch for 0 beatmaps", () => fetchFor());
|
AddStep("fetch for 0 beatmaps", () => fetchFor());
|
||||||
AddUntilStep("placeholder shown", () => overlay.ChildrenOfType<BeatmapListingOverlay.NotFoundDrawable>().SingleOrDefault()?.IsPresent == true);
|
placeholderShown();
|
||||||
|
|
||||||
// fetch once more to ensure nothing happens in displaying placeholder again when it already is present.
|
// fetch once more to ensure nothing happens in displaying placeholder again when it already is present.
|
||||||
AddStep("fetch for 0 beatmaps again", () => fetchFor());
|
AddStep("fetch for 0 beatmaps again", () => fetchFor());
|
||||||
AddUntilStep("placeholder shown", () => overlay.ChildrenOfType<BeatmapListingOverlay.NotFoundDrawable>().SingleOrDefault()?.IsPresent == true);
|
placeholderShown();
|
||||||
|
|
||||||
|
void placeholderShown() =>
|
||||||
|
AddUntilStep("placeholder shown", () =>
|
||||||
|
{
|
||||||
|
var notFoundDrawable = overlay.ChildrenOfType<BeatmapListingOverlay.NotFoundDrawable>().SingleOrDefault();
|
||||||
|
return notFoundDrawable != null && notFoundDrawable.IsPresent && notFoundDrawable.Parent.DrawHeight > 0;
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
[Test]
|
[Test]
|
||||||
|
@ -217,6 +217,10 @@ namespace osu.Game.Overlays
|
|||||||
|
|
||||||
public class NotFoundDrawable : CompositeDrawable
|
public class NotFoundDrawable : CompositeDrawable
|
||||||
{
|
{
|
||||||
|
// required for scheduled tasks to complete correctly
|
||||||
|
// (see `addContentToPlaceholder()` and the scheduled `BypassAutoSizeAxes` set during fade-out in outer class above)
|
||||||
|
public override bool IsPresent => base.IsPresent || Scheduler.HasPendingTasks;
|
||||||
|
|
||||||
public NotFoundDrawable()
|
public NotFoundDrawable()
|
||||||
{
|
{
|
||||||
RelativeSizeAxes = Axes.X;
|
RelativeSizeAxes = Axes.X;
|
||||||
@ -261,6 +265,10 @@ namespace osu.Game.Overlays
|
|||||||
// (https://github.com/ppy/osu-framework/issues/4530)
|
// (https://github.com/ppy/osu-framework/issues/4530)
|
||||||
public class SupporterRequiredDrawable : CompositeDrawable
|
public class SupporterRequiredDrawable : CompositeDrawable
|
||||||
{
|
{
|
||||||
|
// required for scheduled tasks to complete correctly
|
||||||
|
// (see `addContentToPlaceholder()` and the scheduled `BypassAutoSizeAxes` set during fade-out in outer class above)
|
||||||
|
public override bool IsPresent => base.IsPresent || Scheduler.HasPendingTasks;
|
||||||
|
|
||||||
private LinkFlowContainer supporterRequiredText;
|
private LinkFlowContainer supporterRequiredText;
|
||||||
|
|
||||||
public SupporterRequiredDrawable()
|
public SupporterRequiredDrawable()
|
||||||
|
Loading…
Reference in New Issue
Block a user