From 1a50544c9465ec75278420b8d0c22666612be8c1 Mon Sep 17 00:00:00 2001 From: KingLuigi4932 Date: Wed, 12 Jun 2019 20:42:52 +0300 Subject: [PATCH] Add tests for undownloadable / parts-removed beatmapsets --- .../Online/TestSceneBeatmapSetOverlay.cs | 306 +++++++++++++++++- .../Visual/Online/TestSceneDirectPanel.cs | 43 ++- .../BeatmapSet/BeatmapNotAvailable.cs | 1 + 3 files changed, 342 insertions(+), 8 deletions(-) diff --git a/osu.Game.Tests/Visual/Online/TestSceneBeatmapSetOverlay.cs b/osu.Game.Tests/Visual/Online/TestSceneBeatmapSetOverlay.cs index 5910da7b88..5e7ccc7ed4 100644 --- a/osu.Game.Tests/Visual/Online/TestSceneBeatmapSetOverlay.cs +++ b/osu.Game.Tests/Visual/Online/TestSceneBeatmapSetOverlay.cs @@ -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 + { + 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 + { + 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); } diff --git a/osu.Game.Tests/Visual/Online/TestSceneDirectPanel.cs b/osu.Game.Tests/Visual/Online/TestSceneDirectPanel.cs index 8b67892fbb..a2767611ac 100644 --- a/osu.Game.Tests/Visual/Online/TestSceneDirectPanel.cs +++ b/osu.Game.Tests/Visual/Online/TestSceneDirectPanel.cs @@ -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); } } } diff --git a/osu.Game/Overlays/BeatmapSet/BeatmapNotAvailable.cs b/osu.Game/Overlays/BeatmapSet/BeatmapNotAvailable.cs index b9c0a1af39..31ed0d9396 100644 --- a/osu.Game/Overlays/BeatmapSet/BeatmapNotAvailable.cs +++ b/osu.Game/Overlays/BeatmapSet/BeatmapNotAvailable.cs @@ -27,6 +27,7 @@ namespace osu.Game.Overlays.BeatmapSet beatmapSet = value; removeLinks(); + if (beatmapSet?.OnlineInfo.Availability != null) { Header?.ResizeHeightTo(450, 500);