mirror of
https://github.com/ppy/osu
synced 2025-01-01 20:02:14 +00:00
fixed filter text display, added visual tests
This commit is contained in:
parent
e7aeba8d03
commit
996503eb2d
@ -72,45 +72,56 @@ namespace osu.Game.Tests.Visual.Online
|
||||
[Test]
|
||||
public void TestSupporterOnlyFiltersPlaceholderNoBeatmaps()
|
||||
{
|
||||
AddStep("fetch for 0 beatmaps", () => fetchFor());
|
||||
AddStep("set dummy as non-supporter", () => ((DummyAPIAccess)API).LocalUser.Value.IsSupporter = false);
|
||||
|
||||
// test non-supporter on Rank Achieved filter
|
||||
toggleRandomRankFilter();
|
||||
AddUntilStep("supporter-placeholder shown", () => overlay.ChildrenOfType<BeatmapListingOverlay.SupporterRequiredDrawable>().SingleOrDefault()?.IsPresent == true);
|
||||
AddUntilStep("not-found-placeholder hidden", () => !overlay.ChildrenOfType<BeatmapListingOverlay.NotFoundDrawable>().Any());
|
||||
expectedPlaceholderShown(true, false);
|
||||
|
||||
AddStep("Clear Rank Achieved filter", () => overlay.ChildrenOfType<BeatmapListingSearchControl>().Single().Ranks.Clear());
|
||||
AddUntilStep("supporter-placeholder hidden", () => !overlay.ChildrenOfType<BeatmapListingOverlay.SupporterRequiredDrawable>().Any());
|
||||
AddUntilStep("not-found-placeholder shown", () => overlay.ChildrenOfType<BeatmapListingOverlay.NotFoundDrawable>().SingleOrDefault()?.IsPresent == true);
|
||||
expectedPlaceholderShown(false, true);
|
||||
|
||||
// test non-supporter on Played filter
|
||||
toggleRandomSupporterOnlyPlayedFilter();
|
||||
AddUntilStep("supporter-placeholder shown", () => overlay.ChildrenOfType<BeatmapListingOverlay.SupporterRequiredDrawable>().SingleOrDefault()?.IsPresent == true);
|
||||
AddUntilStep("not-found-placeholder hidden", () => !overlay.ChildrenOfType<BeatmapListingOverlay.NotFoundDrawable>().Any());
|
||||
expectedPlaceholderShown(true, false);
|
||||
|
||||
AddStep("Set Played filter to Any", () => overlay.ChildrenOfType<BeatmapListingSearchControl>().Single().Played.Value = SearchPlayed.Any);
|
||||
AddUntilStep("supporter-placeholder hidden", () => !overlay.ChildrenOfType<BeatmapListingOverlay.SupporterRequiredDrawable>().Any());
|
||||
AddUntilStep("not-found-placeholder shown", () => overlay.ChildrenOfType<BeatmapListingOverlay.NotFoundDrawable>().SingleOrDefault()?.IsPresent == true);
|
||||
expectedPlaceholderShown(false, true);
|
||||
|
||||
// test non-supporter on both Rank Achieved and Played filter
|
||||
toggleRandomRankFilter();
|
||||
toggleRandomSupporterOnlyPlayedFilter();
|
||||
expectedPlaceholderShown(true, false);
|
||||
|
||||
AddStep("Clear Rank Achieved filter", () => overlay.ChildrenOfType<BeatmapListingSearchControl>().Single().Ranks.Clear());
|
||||
AddStep("Set Played filter to Any", () => overlay.ChildrenOfType<BeatmapListingSearchControl>().Single().Played.Value = SearchPlayed.Any);
|
||||
expectedPlaceholderShown(false, true);
|
||||
|
||||
AddStep("set dummy as supporter", () => ((DummyAPIAccess)API).LocalUser.Value.IsSupporter = true);
|
||||
|
||||
// test supporter on Rank Achieved filter
|
||||
toggleRandomRankFilter();
|
||||
AddUntilStep("supporter-placeholder hidden", () => !overlay.ChildrenOfType<BeatmapListingOverlay.SupporterRequiredDrawable>().Any());
|
||||
AddUntilStep("not-found-placeholder shown", () => overlay.ChildrenOfType<BeatmapListingOverlay.NotFoundDrawable>().SingleOrDefault()?.IsPresent == true);
|
||||
expectedPlaceholderShown(false, true);
|
||||
|
||||
AddStep("Clear Rank Achieved filter", () => overlay.ChildrenOfType<BeatmapListingSearchControl>().Single().Ranks.Clear());
|
||||
AddUntilStep("supporter-placeholder hidden", () => !overlay.ChildrenOfType<BeatmapListingOverlay.SupporterRequiredDrawable>().Any());
|
||||
AddUntilStep("not-found-placeholder shown", () => overlay.ChildrenOfType<BeatmapListingOverlay.NotFoundDrawable>().SingleOrDefault()?.IsPresent == true);
|
||||
expectedPlaceholderShown(false, true);
|
||||
|
||||
// test supporter on Played filter
|
||||
toggleRandomSupporterOnlyPlayedFilter();
|
||||
AddUntilStep("supporter-placeholder hidden", () => !overlay.ChildrenOfType<BeatmapListingOverlay.SupporterRequiredDrawable>().Any());
|
||||
AddUntilStep("not-found-placeholder shown", () => overlay.ChildrenOfType<BeatmapListingOverlay.NotFoundDrawable>().SingleOrDefault()?.IsPresent == true);
|
||||
expectedPlaceholderShown(false, true);
|
||||
|
||||
AddStep("Set Played filter to Any", () => overlay.ChildrenOfType<BeatmapListingSearchControl>().Single().Played.Value = SearchPlayed.Any);
|
||||
AddUntilStep("supporter-placeholder hidden", () => !overlay.ChildrenOfType<BeatmapListingOverlay.SupporterRequiredDrawable>().Any());
|
||||
AddUntilStep("not-found-placeholder shown", () => overlay.ChildrenOfType<BeatmapListingOverlay.NotFoundDrawable>().SingleOrDefault()?.IsPresent == true);
|
||||
expectedPlaceholderShown(false, true);
|
||||
|
||||
// test supporter on both Rank Achieved and Played filter
|
||||
toggleRandomRankFilter();
|
||||
toggleRandomSupporterOnlyPlayedFilter();
|
||||
expectedPlaceholderShown(false, true);
|
||||
|
||||
AddStep("Clear Rank Achieved filter", () => overlay.ChildrenOfType<BeatmapListingSearchControl>().Single().Ranks.Clear());
|
||||
AddStep("Set Played filter to Any", () => overlay.ChildrenOfType<BeatmapListingSearchControl>().Single().Played.Value = SearchPlayed.Any);
|
||||
expectedPlaceholderShown(false, true);
|
||||
}
|
||||
|
||||
[Test]
|
||||
@ -121,41 +132,51 @@ namespace osu.Game.Tests.Visual.Online
|
||||
|
||||
// test non-supporter on Rank Achieved filter
|
||||
toggleRandomRankFilter();
|
||||
AddUntilStep("supporter-placeholder shown", () => overlay.ChildrenOfType<BeatmapListingOverlay.SupporterRequiredDrawable>().SingleOrDefault()?.IsPresent == true);
|
||||
AddUntilStep("not-found-placeholder hidden", () => !overlay.ChildrenOfType<BeatmapListingOverlay.NotFoundDrawable>().Any());
|
||||
expectedPlaceholderShown(true, false);
|
||||
|
||||
AddStep("Clear Rank Achieved filter", () => overlay.ChildrenOfType<BeatmapListingSearchControl>().Single().Ranks.Clear());
|
||||
AddUntilStep("supporter-placeholder hidden", () => !overlay.ChildrenOfType<BeatmapListingOverlay.SupporterRequiredDrawable>().Any());
|
||||
AddUntilStep("not-found-placeholder hidden", () => !overlay.ChildrenOfType<BeatmapListingOverlay.NotFoundDrawable>().Any());
|
||||
expectedPlaceholderShown(false, false);
|
||||
|
||||
// test non-supporter on Played filter
|
||||
toggleRandomSupporterOnlyPlayedFilter();
|
||||
AddUntilStep("supporter-placeholder shown", () => overlay.ChildrenOfType<BeatmapListingOverlay.SupporterRequiredDrawable>().SingleOrDefault()?.IsPresent == true);
|
||||
AddUntilStep("not-found-placeholder hidden", () => !overlay.ChildrenOfType<BeatmapListingOverlay.NotFoundDrawable>().Any());
|
||||
expectedPlaceholderShown(true, false);
|
||||
|
||||
AddStep("Set Played filter to Any", () => overlay.ChildrenOfType<BeatmapListingSearchControl>().Single().Played.Value = SearchPlayed.Any);
|
||||
AddUntilStep("supporter-placeholder hidden", () => !overlay.ChildrenOfType<BeatmapListingOverlay.SupporterRequiredDrawable>().Any());
|
||||
AddUntilStep("not-found-placeholder hidden", () => !overlay.ChildrenOfType<BeatmapListingOverlay.NotFoundDrawable>().Any());
|
||||
expectedPlaceholderShown(false, false);
|
||||
|
||||
// test non-supporter on both Rank Achieved and Played filter
|
||||
toggleRandomRankFilter();
|
||||
toggleRandomSupporterOnlyPlayedFilter();
|
||||
expectedPlaceholderShown(true, false);
|
||||
|
||||
AddStep("Clear Rank Achieved filter", () => overlay.ChildrenOfType<BeatmapListingSearchControl>().Single().Ranks.Clear());
|
||||
AddStep("Set Played filter to Any", () => overlay.ChildrenOfType<BeatmapListingSearchControl>().Single().Played.Value = SearchPlayed.Any);
|
||||
expectedPlaceholderShown(false, false);
|
||||
|
||||
AddStep("set dummy as supporter", () => ((DummyAPIAccess)API).LocalUser.Value.IsSupporter = true);
|
||||
|
||||
// test supporter on Rank Achieved filter
|
||||
toggleRandomRankFilter();
|
||||
AddUntilStep("supporter-placeholder hidden", () => !overlay.ChildrenOfType<BeatmapListingOverlay.SupporterRequiredDrawable>().Any());
|
||||
AddUntilStep("not-found-placeholder hidden", () => !overlay.ChildrenOfType<BeatmapListingOverlay.NotFoundDrawable>().Any());
|
||||
expectedPlaceholderShown(false, false);
|
||||
|
||||
AddStep("Clear Rank Achieved filter", () => overlay.ChildrenOfType<BeatmapListingSearchControl>().Single().Ranks.Clear());
|
||||
AddUntilStep("supporter-placeholder hidden", () => !overlay.ChildrenOfType<BeatmapListingOverlay.SupporterRequiredDrawable>().Any());
|
||||
AddUntilStep("not-found-placeholder hidden", () => !overlay.ChildrenOfType<BeatmapListingOverlay.NotFoundDrawable>().Any());
|
||||
expectedPlaceholderShown(false, false);
|
||||
|
||||
// test supporter on Played filter
|
||||
toggleRandomSupporterOnlyPlayedFilter();
|
||||
AddUntilStep("supporter-placeholder hidden", () => !overlay.ChildrenOfType<BeatmapListingOverlay.SupporterRequiredDrawable>().Any());
|
||||
AddUntilStep("not-found-placeholder hidden", () => !overlay.ChildrenOfType<BeatmapListingOverlay.NotFoundDrawable>().Any());
|
||||
expectedPlaceholderShown(false, false);
|
||||
|
||||
AddStep("Set Played filter to Any", () => overlay.ChildrenOfType<BeatmapListingSearchControl>().Single().Played.Value = SearchPlayed.Any);
|
||||
AddUntilStep("supporter-placeholder hidden", () => !overlay.ChildrenOfType<BeatmapListingOverlay.SupporterRequiredDrawable>().Any());
|
||||
AddUntilStep("not-found-placeholder hidden", () => !overlay.ChildrenOfType<BeatmapListingOverlay.NotFoundDrawable>().Any());
|
||||
expectedPlaceholderShown(false, false);
|
||||
|
||||
// test supporter on both Rank Achieved and Played filter
|
||||
toggleRandomRankFilter();
|
||||
toggleRandomSupporterOnlyPlayedFilter();
|
||||
expectedPlaceholderShown(false, false);
|
||||
|
||||
AddStep("Set Played filter to Any", () => overlay.ChildrenOfType<BeatmapListingSearchControl>().Single().Played.Value = SearchPlayed.Any);
|
||||
AddStep("Clear Rank Achieved filter", () => overlay.ChildrenOfType<BeatmapListingSearchControl>().Single().Ranks.Clear());
|
||||
expectedPlaceholderShown(false, false);
|
||||
}
|
||||
|
||||
|
||||
@ -184,6 +205,27 @@ namespace osu.Game.Tests.Visual.Online
|
||||
AddStep("toggle Random Played filter", () => overlay.ChildrenOfType<BeatmapListingSearchControl>().Single().Played.Value = (SearchPlayed)(r % 2 + 1));
|
||||
}
|
||||
|
||||
private void expectedPlaceholderShown(bool supporterRequiredShown, bool notFoundShown)
|
||||
{
|
||||
if (supporterRequiredShown)
|
||||
{
|
||||
AddUntilStep("supporter-placeholder shown", () => overlay.ChildrenOfType<BeatmapListingOverlay.SupporterRequiredDrawable>().SingleOrDefault()?.IsPresent == true);
|
||||
}
|
||||
else
|
||||
{
|
||||
AddUntilStep("supporter-placeholder hidden", () => !overlay.ChildrenOfType<BeatmapListingOverlay.SupporterRequiredDrawable>().Any());
|
||||
}
|
||||
|
||||
if (notFoundShown)
|
||||
{
|
||||
AddUntilStep("not-found-placeholder shown", () => overlay.ChildrenOfType<BeatmapListingOverlay.NotFoundDrawable>().SingleOrDefault()?.IsPresent == true);
|
||||
}
|
||||
else
|
||||
{
|
||||
AddUntilStep("not-found-placeholder hidden", () => !overlay.ChildrenOfType<BeatmapListingOverlay.NotFoundDrawable>().Any());
|
||||
}
|
||||
}
|
||||
|
||||
private class TestAPIBeatmapSet : APIBeatmapSet
|
||||
{
|
||||
private readonly BeatmapSetInfo beatmapSet;
|
||||
|
@ -24,9 +24,9 @@ namespace osu.Game.Overlays.BeatmapListing
|
||||
{
|
||||
/// <summary>
|
||||
/// Fired when a search finishes. Contains only new items in the case of pagination.
|
||||
/// Null when non-supporter user used supporter-only filters
|
||||
/// Fired with BeatmapListingSearchControl when non-supporter user used supporter-only filters.
|
||||
/// </summary>
|
||||
public Action<List<BeatmapSetInfo>> SearchFinished;
|
||||
public Action<List<BeatmapSetInfo>, BeatmapListingSearchControl> SearchFinished;
|
||||
|
||||
/// <summary>
|
||||
/// Fired when search criteria change.
|
||||
@ -216,11 +216,11 @@ namespace osu.Game.Overlays.BeatmapListing
|
||||
// check if an non-supporter user used supporter-only filters
|
||||
if (!api.LocalUser.Value.IsSupporter && (searchControl.Ranks.Any() || searchControl.Played.Value != SearchPlayed.Any))
|
||||
{
|
||||
SearchFinished?.Invoke(null);
|
||||
SearchFinished?.Invoke(sets, searchControl);
|
||||
}
|
||||
else
|
||||
{
|
||||
SearchFinished?.Invoke(sets);
|
||||
SearchFinished?.Invoke(sets, null);
|
||||
}
|
||||
};
|
||||
|
||||
|
@ -119,11 +119,17 @@ namespace osu.Game.Overlays
|
||||
|
||||
private Task panelLoadDelegate;
|
||||
|
||||
private void onSearchFinished(List<BeatmapSetInfo> beatmaps)
|
||||
private void onSearchFinished(List<BeatmapSetInfo> beatmaps, BeatmapListingSearchControl searchControl)
|
||||
{
|
||||
// non-supporter user used supporter-only filters
|
||||
if (beatmaps == null)
|
||||
if (searchControl != null)
|
||||
{
|
||||
// compose filter string
|
||||
List<string> filtersStrs = new List<string>();
|
||||
if (searchControl.Ranks.Any()) filtersStrs.Add(BeatmapsStrings.ListingSearchFiltersRank.ToString());
|
||||
if (searchControl.Played.Value != SearchPlayed.Any) filtersStrs.Add(BeatmapsStrings.ListingSearchFiltersPlayed.ToString());
|
||||
supporterRequiredContent.UpdateSupportRequiredText(string.Join(" and ", filtersStrs));
|
||||
|
||||
LoadComponentAsync(supporterRequiredContent, addContentToPlaceholder, (cancellationToken = new CancellationTokenSource()).Token);
|
||||
return;
|
||||
}
|
||||
@ -258,11 +264,24 @@ namespace osu.Game.Overlays
|
||||
|
||||
public class SupporterRequiredDrawable : CompositeDrawable
|
||||
{
|
||||
private LinkFlowContainer linkFlowContainer;
|
||||
|
||||
public SupporterRequiredDrawable()
|
||||
{
|
||||
RelativeSizeAxes = Axes.X;
|
||||
Height = 225;
|
||||
Alpha = 0;
|
||||
|
||||
linkFlowContainer = linkFlowContainer = new LinkFlowContainer
|
||||
{
|
||||
Anchor = Anchor.Centre,
|
||||
Origin = Anchor.Centre,
|
||||
AutoSizeAxes = Axes.Both,
|
||||
Margin = new MarginPadding
|
||||
{
|
||||
Bottom = 10,
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
[BackgroundDependencyLoader]
|
||||
@ -285,27 +304,15 @@ namespace osu.Game.Overlays
|
||||
FillMode = FillMode.Fit,
|
||||
Texture = textures.Get(@"Online/supporter-required"),
|
||||
},
|
||||
createSupportRequiredText(),
|
||||
linkFlowContainer,
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
private Drawable createSupportRequiredText()
|
||||
{
|
||||
LinkFlowContainer linkFlowContainer;
|
||||
string[] text = BeatmapsStrings.ListingSearchSupporterFilterQuoteDefault(BeatmapsStrings.ListingSearchFiltersRank.ToString(), "{1}").ToString().Split("{1}");
|
||||
|
||||
linkFlowContainer = new LinkFlowContainer
|
||||
{
|
||||
Anchor = Anchor.Centre,
|
||||
Origin = Anchor.Centre,
|
||||
AutoSizeAxes = Axes.Both,
|
||||
Margin = new MarginPadding
|
||||
{
|
||||
Bottom = 10,
|
||||
}
|
||||
};
|
||||
public void UpdateSupportRequiredText(string filtersStr) {
|
||||
string[] text = BeatmapsStrings.ListingSearchSupporterFilterQuoteDefault(filtersStr, "{1}").ToString().Split("{1}");
|
||||
|
||||
linkFlowContainer.Clear();
|
||||
linkFlowContainer.AddText(
|
||||
text[0],
|
||||
t =>
|
||||
@ -333,8 +340,6 @@ namespace osu.Game.Overlays
|
||||
t.Colour = Colour4.White;
|
||||
}
|
||||
);
|
||||
|
||||
return linkFlowContainer;
|
||||
}
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user