mirror of https://github.com/ppy/osu
added visual tests
This commit is contained in:
parent
27da3dc75a
commit
42fdfbb9a1
|
@ -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();
|
||||
|
|
|
@ -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");
|
||||
}
|
||||
);
|
||||
|
||||
|
|
Loading…
Reference in New Issue