added visual tests

This commit is contained in:
JimmyC7834 2021-06-20 17:17:07 +08:00
parent 27da3dc75a
commit 42fdfbb9a1
2 changed files with 83 additions and 23 deletions

View File

@ -14,6 +14,7 @@
using osu.Game.Overlays;
using osu.Game.Overlays.BeatmapListing;
using osu.Game.Rulesets;
using osu.Game.Users;
namespace osu.Game.Tests.Visual.Online
{
@ -58,6 +59,79 @@ public void TestNoBeatmapsPlaceholder()
AddUntilStep("placeholder shown", () => overlay.ChildrenOfType<BeatmapListingOverlay.NotFoundDrawable>().SingleOrDefault()?.IsPresent == true);
}
[Test]
public void TestSupporterOnlyFiltersPlaceholder() {
AddStep("toggle non-supporter", () =>
{
// non-supporter user
((DummyAPIAccess)API).LocalUser.Value = new User
{
Username = API.LocalUser.Value.Username,
Id = API.LocalUser.Value.Id + 1,
IsSupporter = false,
};
});
AddStep("fetch for 1 beatmap", () => fetchFor(CreateBeatmap(Ruleset.Value).BeatmapInfo.BeatmapSet));
AddStep("toggle Random Rank Achieved filter", () => {
overlay.ChildrenOfType<BeatmapListingSearchControl>().Single().Ranks.Clear();
Scoring.ScoreRank r = (Scoring.ScoreRank)(TestContext.CurrentContext.Random.NextShort() % 8);
overlay.ChildrenOfType<BeatmapListingSearchControl>().Single().Ranks.Add(r);
// overlay.ChildrenOfType<BeatmapListingSearchControl>().Single().Ranks.
});
AddUntilStep("supporter-placeholder show", () => overlay.ChildrenOfType<BeatmapListingOverlay.SupporterRequiredDrawable>().SingleOrDefault()?.IsPresent == true);
AddStep("Clear Rank Achieved filter", () => {
overlay.ChildrenOfType<BeatmapListingSearchControl>().Single().Ranks.Clear();
});
AddUntilStep("supporter-placeholder hidden", () => !overlay.ChildrenOfType<BeatmapListingOverlay.SupporterRequiredDrawable>().Any());
AddStep("toggle Random Played filter", () => {
SearchPlayed r = (SearchPlayed)(TestContext.CurrentContext.Random.NextShort() % 2 + 1);
overlay.ChildrenOfType<BeatmapListingSearchControl>().Single().Played.Value = r;
});
AddUntilStep("supporter-placeholder show", () => overlay.ChildrenOfType<BeatmapListingOverlay.SupporterRequiredDrawable>().SingleOrDefault()?.IsPresent == true);
AddStep("Clear Played filter", () => {
overlay.ChildrenOfType<BeatmapListingSearchControl>().Single().Played.Value = SearchPlayed.Any;
});
AddUntilStep("supporter-placeholder hidden", () => !overlay.ChildrenOfType<BeatmapListingOverlay.SupporterRequiredDrawable>().Any());
AddStep("toggle supporter", () =>
{
// supporter user
((DummyAPIAccess)API).LocalUser.Value.IsSupporter = true;
});
AddStep("toggle Random Rank Achieved filter", () => {
overlay.ChildrenOfType<BeatmapListingSearchControl>().Single().Ranks.Clear();
Scoring.ScoreRank r = (Scoring.ScoreRank)(TestContext.CurrentContext.Random.NextShort() % 8);
overlay.ChildrenOfType<BeatmapListingSearchControl>().Single().Ranks.Add(r);
});
AddUntilStep("supporter-placeholder hidden", () => !overlay.ChildrenOfType<BeatmapListingOverlay.SupporterRequiredDrawable>().Any());
AddStep("Clear Rank Achieved filter", () => {
overlay.ChildrenOfType<BeatmapListingSearchControl>().Single().Ranks.Clear();
});
AddUntilStep("supporter-placeholder hidden", () => !overlay.ChildrenOfType<BeatmapListingOverlay.SupporterRequiredDrawable>().Any());
AddStep("toggle Random Played filter", () => {
SearchPlayed r = (SearchPlayed)(TestContext.CurrentContext.Random.NextShort() % 2 + 1);
overlay.ChildrenOfType<BeatmapListingSearchControl>().Single().Played.Value = r;
});
AddUntilStep("supporter-placeholder hidden", () => !overlay.ChildrenOfType<BeatmapListingOverlay.SupporterRequiredDrawable>().Any());
AddStep("Clear Played filter", () => {
overlay.ChildrenOfType<BeatmapListingSearchControl>().Single().Played.Value = SearchPlayed.Any;
});
AddUntilStep("supporter-placeholder hidden", () => !overlay.ChildrenOfType<BeatmapListingOverlay.SupporterRequiredDrawable>().Any());
}
private void fetchFor(params BeatmapSetInfo[] beatmaps)
{
setsForResponse.Clear();

View File

@ -181,11 +181,16 @@ private void addContentToPlaceholder(Drawable content)
{
var transform = lastContent.FadeOut(100, Easing.OutQuint);
if (lastContent == notFoundContent || lastContent == supporterRequiredContent)
if (lastContent == notFoundContent)
{
// not found display may be used multiple times, so don't expire/dispose it.
transform.Schedule(() => panelTarget.Remove(lastContent));
}
else if (lastContent == supporterRequiredContent)
{
// supporter required display may be used multiple times, so don't expire/dispose it.
transform.Schedule(() => panelTarget.Remove(supporterRequiredContent));
}
else
{
// Consider the case when the new content is smaller than the last content.
@ -256,9 +261,8 @@ public class SupporterRequiredDrawable : CompositeDrawable
public SupporterRequiredDrawable()
{
RelativeSizeAxes = Axes.X;
Height = 250;
Height = 225;
Alpha = 0;
Margin = new MarginPadding { Top = 15 };
}
[BackgroundDependencyLoader]
@ -271,7 +275,6 @@ private void load(TextureStore textures)
RelativeSizeAxes = Axes.Y,
AutoSizeAxes = Axes.X,
Direction = FillDirection.Horizontal,
Spacing = new Vector2(10, 0),
Children = new Drawable[]
{
new Sprite
@ -290,24 +293,7 @@ private void load(TextureStore textures)
private Drawable createSupportRequiredText()
{
LinkFlowContainer linkFlowContainer;
string[] text = BeatmapsStrings.ListingSearchSupporterFilterQuoteDefault(
BeatmapsStrings.ListingSearchFiltersRank.ToString(),
"{1}"
).ToString().Split("{1}");
// var titleContainer = new Container
// {
// RelativeSizeAxes = Axes.X,
// Margin = new MarginPadding { Vertical = 5 },
// Children = new Drawable[]
// {
// linkFlowContainer = new LinkFlowContainer
// {
// Anchor = Anchor.Centre,
// Origin = Anchor.Centre,
// }
// }
// };
string[] text = BeatmapsStrings.ListingSearchSupporterFilterQuoteDefault(BeatmapsStrings.ListingSearchFiltersRank.ToString(), "{1}").ToString().Split("{1}");
linkFlowContainer = new LinkFlowContainer
{
@ -335,7 +321,7 @@ private Drawable createSupportRequiredText()
t =>
{
t.Font = OsuFont.GetFont(size: 16);
t.Colour = Colour4.AliceBlue;
t.Colour = Colour4.FromHex("#A6C8D9");
}
);