1
0
mirror of https://github.com/ppy/osu.git synced 2024-12-14 14:32:55 +08:00

Add tests for undownloadable / parts-removed beatmapsets

This commit is contained in:
KingLuigi4932 2019-06-12 20:42:52 +03:00
parent 744f32ab35
commit 1a50544c94
3 changed files with 342 additions and 8 deletions

View File

@ -39,6 +39,7 @@ namespace osu.Game.Tests.Visual.Online
typeof(Info),
typeof(PreviewButton),
typeof(SuccessRate),
typeof(BeatmapNotAvailable),
};
public TestSceneBeatmapSetOverlay()
@ -49,6 +50,7 @@ namespace osu.Game.Tests.Visual.Online
[BackgroundDependencyLoader]
private void load(RulesetStore rulesets)
{
var osu = rulesets.GetRuleset(0);
var mania = rulesets.GetRuleset(3);
var taiko = rulesets.GetRuleset(1);
@ -225,7 +227,7 @@ namespace osu.Game.Tests.Visual.Online
},
},
},
});
}, false);
});
AddStep(@"show second", () =>
@ -396,9 +398,309 @@ namespace osu.Game.Tests.Visual.Online
},
},
},
});
}, false);
});
AddStep(@"show parts-removed", () =>
{
overlay.ShowBeatmapSet(new BeatmapSetInfo
{
Metadata = new BeatmapMetadata
{
Title = @"Sakura Kagetsu",
Artist = @"AKITO",
Source = @"DJMAX",
Tags = @"J-Trance Pasonia",
Author = new User
{
Username = @"Kharl",
Id = 452,
},
},
OnlineInfo = new BeatmapSetOnlineInfo
{
Availability = new BeatmapSetOnlineAvailability
{
DownloadDisabled = false,
ExternalLink = @"https://gist.githubusercontent.com/peppy/079dc3f77e316f9cd40077d411319a72/raw",
},
Preview = @"https://b.ppy.sh/preview/119.mp3",
PlayCount = 626927,
FavouriteCount = 157,
Submitted = new DateTime(2007, 10, 24),
Ranked = new DateTime(2008, 4, 21),
Status = BeatmapSetOnlineStatus.Ranked,
BPM = 138,
Covers = new BeatmapSetOnlineCovers
{
Cover = @"https://assets.ppy.sh/beatmaps/119/covers/cover.jpg?1539847784",
},
},
Beatmaps = new List<BeatmapInfo>
{
new BeatmapInfo
{
StarDifficulty = 1.51,
Version = "Easy",
Ruleset = osu,
BaseDifficulty = new BeatmapDifficulty
{
CircleSize = 4,
DrainRate = 2,
OverallDifficulty = 1,
ApproachRate = 1,
},
OnlineInfo = new BeatmapOnlineInfo
{
Length = 126000,
CircleCount = 371,
SliderCount = 35,
PlayCount = 84498,
PassCount = 37482,
},
Metrics = new BeatmapMetrics
{
Ratings = Enumerable.Range(0, 11),
Fails = Enumerable.Range(1, 100).Select(i => i % 12 - 6),
Retries = Enumerable.Range(-2, 100).Select(i => i % 12 - 6),
},
},
new BeatmapInfo
{
StarDifficulty = 2.23,
Version = "Normal",
Ruleset = osu,
BaseDifficulty = new BeatmapDifficulty
{
CircleSize = 5,
DrainRate = 4,
OverallDifficulty = 3,
ApproachRate = 3,
},
OnlineInfo = new BeatmapOnlineInfo
{
Length = 126000,
CircleCount = 98,
SliderCount = 28,
PlayCount = 86427,
PassCount = 23273,
},
Metrics = new BeatmapMetrics
{
Ratings = Enumerable.Range(0, 11),
Fails = Enumerable.Range(1, 100).Select(i => i % 12 - 6),
Retries = Enumerable.Range(-2, 100).Select(i => i % 12 - 6),
},
},
new BeatmapInfo
{
StarDifficulty = 2.83,
Version = "Hard",
Ruleset = osu,
BaseDifficulty = new BeatmapDifficulty
{
CircleSize = 6,
DrainRate = 6,
OverallDifficulty = 6,
ApproachRate = 6,
},
OnlineInfo = new BeatmapOnlineInfo
{
Length = 126000,
CircleCount = 139,
SliderCount = 37,
PlayCount = 206523,
PassCount = 44366,
},
Metrics = new BeatmapMetrics
{
Ratings = Enumerable.Range(0, 11),
Fails = Enumerable.Range(1, 100).Select(i => i % 12 - 6),
Retries = Enumerable.Range(-2, 100).Select(i => i % 12 - 6),
},
},
new BeatmapInfo
{
StarDifficulty = 4.26,
Version = "Pasonia's Insane",
Ruleset = osu,
BaseDifficulty = new BeatmapDifficulty
{
CircleSize = 6,
DrainRate = 6,
OverallDifficulty = 6,
ApproachRate = 6,
},
OnlineInfo = new BeatmapOnlineInfo
{
Length = 126000,
CircleCount = 371,
SliderCount = 35,
PlayCount = 249479,
PassCount = 14042,
},
Metrics = new BeatmapMetrics
{
Ratings = Enumerable.Range(0, 11),
Fails = Enumerable.Range(1, 100).Select(i => i % 12 - 6),
Retries = Enumerable.Range(-2, 100).Select(i => i % 12 - 6),
},
},
},
}, false);
});
AddStep(@"show undownloadable", () =>
{
overlay.ShowBeatmapSet(new BeatmapSetInfo
{
Metadata = new BeatmapMetadata
{
Title = @"China Express",
Artist = @"Ryu*",
Source = @"REFLEC BEAT",
Tags = @"konami bemani lincle link iidx iidx18 iidx19 resort anthem plus la cataline mmzz",
Author = new User
{
Username = @"yeahyeahyeahhh",
Id = 58042,
},
},
OnlineInfo = new BeatmapSetOnlineInfo
{
Availability = new BeatmapSetOnlineAvailability
{
DownloadDisabled = true,
ExternalLink = @"https://gist.githubusercontent.com/peppy/99e6959772083cdfde8a/raw",
},
Preview = @"https://b.ppy.sh/preview/53853.mp3",
PlayCount = 436213,
FavouriteCount = 105,
Submitted = new DateTime(2012, 7, 1),
Ranked = new DateTime(2012, 7, 18),
Status = BeatmapSetOnlineStatus.Ranked,
BPM = 171,
Covers = new BeatmapSetOnlineCovers
{
Cover = @"https://assets.ppy.sh/beatmaps/53853/covers/cover.jpg?1456498562",
},
},
Beatmaps = new List<BeatmapInfo>
{
new BeatmapInfo
{
StarDifficulty = 1.85,
Version = "Easy",
Ruleset = osu,
BaseDifficulty = new BeatmapDifficulty
{
CircleSize = 3,
DrainRate = 2,
OverallDifficulty = 2,
ApproachRate = 3,
},
OnlineInfo = new BeatmapOnlineInfo
{
Length = 95000,
CircleCount = 49,
SliderCount = 60,
PlayCount = 20308,
PassCount = 10233,
},
Metrics = new BeatmapMetrics
{
Ratings = Enumerable.Range(0, 11),
Fails = Enumerable.Range(1, 100).Select(i => i % 12 - 6),
Retries = Enumerable.Range(-2, 100).Select(i => i % 12 - 6),
},
},
new BeatmapInfo
{
StarDifficulty = 2.36,
Version = "Normal",
Ruleset = osu,
BaseDifficulty = new BeatmapDifficulty
{
CircleSize = 3,
DrainRate = 2,
OverallDifficulty = 2,
ApproachRate = 5,
},
OnlineInfo = new BeatmapOnlineInfo
{
Length = 96000,
CircleCount = 86,
SliderCount = 67,
PlayCount = 54015,
PassCount = 25603,
},
Metrics = new BeatmapMetrics
{
Ratings = Enumerable.Range(0, 11),
Fails = Enumerable.Range(1, 100).Select(i => i % 12 - 6),
Retries = Enumerable.Range(-2, 100).Select(i => i % 12 - 6),
},
},
new BeatmapInfo
{
StarDifficulty = 4.42,
Version = "Hyper",
Ruleset = osu,
BaseDifficulty = new BeatmapDifficulty
{
CircleSize = 4,
DrainRate = 7,
OverallDifficulty = 6,
ApproachRate = 8,
},
OnlineInfo = new BeatmapOnlineInfo
{
Length = 96000,
CircleCount = 215,
SliderCount = 120,
PlayCount = 111400,
PassCount = 12583,
},
Metrics = new BeatmapMetrics
{
Ratings = Enumerable.Range(0, 11),
Fails = Enumerable.Range(1, 100).Select(i => i % 12 - 6),
Retries = Enumerable.Range(-2, 100).Select(i => i % 12 - 6),
},
},
new BeatmapInfo
{
StarDifficulty = 5.05,
Version = "Another",
Ruleset = osu,
BaseDifficulty = new BeatmapDifficulty
{
CircleSize = 4,
DrainRate = 7,
OverallDifficulty = 9,
ApproachRate = 9,
},
OnlineInfo = new BeatmapOnlineInfo
{
Length = 96000,
CircleCount = 250,
SliderCount = 75,
PlayCount = 228253,
PassCount = 53037,
},
Metrics = new BeatmapMetrics
{
Ratings = Enumerable.Range(0, 11),
Fails = Enumerable.Range(1, 100).Select(i => i % 12 - 6),
Retries = Enumerable.Range(-2, 100).Select(i => i % 12 - 6),
},
},
},
}, false);
});
AddAssert(@"is download button removed", () => overlay.Header.DownloadButtonsContainer.Count == 0);
AddStep(@"hide", overlay.Hide);
AddStep(@"show without reload", overlay.Show);
}

View File

@ -6,7 +6,9 @@ using System.Collections.Generic;
using osu.Framework.Allocation;
using osu.Framework.Graphics;
using osu.Framework.Graphics.Containers;
using osu.Game.Beatmaps;
using osu.Game.Overlays.Direct;
using osu.Game.Rulesets;
using osu.Game.Rulesets.Osu;
using osuTK;
@ -21,12 +23,34 @@ namespace osu.Game.Tests.Visual.Online
typeof(IconPill)
};
private BeatmapSetInfo getBeatmapSet(RulesetInfo ruleset, bool downloadable)
{
var beatmap = CreateWorkingBeatmap(ruleset).BeatmapSetInfo;
beatmap.OnlineInfo.HasVideo = true;
beatmap.OnlineInfo.HasStoryboard = true;
beatmap.OnlineInfo.Availability = new BeatmapSetOnlineAvailability
{
DownloadDisabled = !downloadable,
ExternalLink = "http://localhost",
};
return beatmap;
}
[BackgroundDependencyLoader]
private void load()
{
var beatmap = CreateWorkingBeatmap(new OsuRuleset().RulesetInfo);
beatmap.BeatmapSetInfo.OnlineInfo.HasVideo = true;
beatmap.BeatmapSetInfo.OnlineInfo.HasStoryboard = true;
var ruleset = new OsuRuleset().RulesetInfo;
var normal = CreateWorkingBeatmap(ruleset).BeatmapSetInfo;
normal.OnlineInfo.HasVideo = true;
normal.OnlineInfo.HasStoryboard = true;
var downloadable = getBeatmapSet(ruleset, true);
var undownloadable = getBeatmapSet(ruleset, false);
DirectPanel undownloadableGridPanel, undownloadableListPanel;
Child = new FillFlowContainer
{
@ -37,10 +61,17 @@ namespace osu.Game.Tests.Visual.Online
Spacing = new Vector2(0, 20),
Children = new Drawable[]
{
new DirectGridPanel(beatmap.BeatmapSetInfo),
new DirectListPanel(beatmap.BeatmapSetInfo)
}
new DirectGridPanel(normal),
new DirectGridPanel(downloadable),
undownloadableGridPanel = new DirectGridPanel(undownloadable),
new DirectListPanel(normal),
new DirectListPanel(downloadable),
undownloadableListPanel = new DirectListPanel(undownloadable),
},
};
AddAssert("is download button disabled on last grid panel", () => !undownloadableGridPanel.DownloadButton.Enabled.Value);
AddAssert("is download button disabled on last list panel", () => !undownloadableListPanel.DownloadButton.Enabled.Value);
}
}
}

View File

@ -27,6 +27,7 @@ namespace osu.Game.Overlays.BeatmapSet
beatmapSet = value;
removeLinks();
if (beatmapSet?.OnlineInfo.Availability != null)
{
Header?.ResizeHeightTo(450, 500);