diff --git a/osu.Game.Tests/Visual/Online/TestSceneBeatmapNotAvailable.cs b/osu.Game.Tests/Visual/Online/TestSceneBeatmapNotAvailable.cs index 22e3e63c28..553b081f28 100644 --- a/osu.Game.Tests/Visual/Online/TestSceneBeatmapNotAvailable.cs +++ b/osu.Game.Tests/Visual/Online/TestSceneBeatmapNotAvailable.cs @@ -1,51 +1,97 @@ // Copyright (c) ppy Pty Ltd . Licensed under the MIT Licence. // See the LICENCE file in the repository root for full licence text. +using NUnit.Framework; using osu.Game.Beatmaps; using osu.Game.Overlays.BeatmapSet; namespace osu.Game.Tests.Visual.Online { + [TestFixture] public class TestSceneBeatmapNotAvailable : OsuTestScene { + BeatmapNotAvailable container; + public TestSceneBeatmapNotAvailable() { - var container = new BeatmapNotAvailable(); + Add(container = new BeatmapNotAvailable()); + } - Add(container); - - AddStep("set undownloadable beatmapset", () => container.BeatmapSet = new BeatmapSetInfo + [Test] + public void TestUndownloadableWithLink() + { + AddStep("set undownloadable beatmapset with link", () => container.BeatmapSet = new BeatmapSetInfo { OnlineInfo = new BeatmapSetOnlineInfo { Availability = new BeatmapSetOnlineAvailability { DownloadDisabled = true, - ExternalLink = @"https://gist.githubusercontent.com/peppy/99e6959772083cdfde8a/raw", + ExternalLink = @"https://osu.ppy.sh", }, }, }); - AddAssert("is container visible", () => container.Alpha == 1); - AddStep("set downloadable beatmapset", () => container.BeatmapSet = new BeatmapSetInfo + visiblityAssert(true); + } + + [Test] + public void TestUndownloadableNoLink() + { + AddStep("set undownloadable beatmapset without link", () => container.BeatmapSet = new BeatmapSetInfo + { + OnlineInfo = new BeatmapSetOnlineInfo + { + Availability = new BeatmapSetOnlineAvailability + { + DownloadDisabled = true, + }, + }, + }); + + visiblityAssert(true); + } + + + + [Test] + public void TestPartsRemovedWithLink() + { + AddStep("set parts-removed beatmapset with link", () => container.BeatmapSet = new BeatmapSetInfo { OnlineInfo = new BeatmapSetOnlineInfo { Availability = new BeatmapSetOnlineAvailability { DownloadDisabled = false, - ExternalLink = @"https://gist.githubusercontent.com/peppy/99e6959772083cdfde8a/raw", + ExternalLink = @"https://osu.ppy.sh", }, }, }); - AddAssert("is container still visible", () => container.Alpha == 1); + visiblityAssert(true); + } + + [Test] + public void TestNormal() + { AddStep("set normal beatmapset", () => container.BeatmapSet = new BeatmapSetInfo { - OnlineInfo = new BeatmapSetOnlineInfo(), + OnlineInfo = new BeatmapSetOnlineInfo + { + Availability = new BeatmapSetOnlineAvailability + { + DownloadDisabled = false, + }, + }, }); - AddAssert("is container hidden", () => container.Alpha == 0); + visiblityAssert(false); + } + + private void visiblityAssert(bool shown) + { + AddAssert($"is container {(shown ? "visible" : "hidden")}", () => container.Alpha == (shown ? 1 : 0)); } } } diff --git a/osu.Game.Tests/Visual/Online/TestSceneBeatmapSetOverlay.cs b/osu.Game.Tests/Visual/Online/TestSceneBeatmapSetOverlay.cs index 2e68be981c..e365368c18 100644 --- a/osu.Game.Tests/Visual/Online/TestSceneBeatmapSetOverlay.cs +++ b/osu.Game.Tests/Visual/Online/TestSceneBeatmapSetOverlay.cs @@ -565,7 +565,7 @@ namespace osu.Game.Tests.Visual.Online downloadAssert(true); - AddStep(@"show undownloadable", () => + AddStep(@"show undownloadable (no link)", () => { overlay.ShowBeatmapSet(new BeatmapSetInfo { @@ -586,7 +586,6 @@ namespace osu.Game.Tests.Visual.Online Availability = new BeatmapSetOnlineAvailability { DownloadDisabled = true, - ExternalLink = @"https://gist.githubusercontent.com/peppy/99e6959772083cdfde8a/raw", }, Preview = @"https://b.ppy.sh/preview/53853.mp3", PlayCount = 436213, diff --git a/osu.Game/Overlays/BeatmapSet/BeatmapNotAvailable.cs b/osu.Game/Overlays/BeatmapSet/BeatmapNotAvailable.cs index cb9284a295..55ad70aec0 100644 --- a/osu.Game/Overlays/BeatmapSet/BeatmapNotAvailable.cs +++ b/osu.Game/Overlays/BeatmapSet/BeatmapNotAvailable.cs @@ -26,7 +26,7 @@ namespace osu.Game.Overlays.BeatmapSet beatmapSet = value; - bool unavailable = BeatmapSet?.OnlineInfo.Availability != null; + bool unavailable = (BeatmapSet?.OnlineInfo.Availability?.DownloadDisabled ?? false) || (BeatmapSet?.OnlineInfo.Availability?.ExternalLink != null); this.FadeTo(unavailable ? 1 : 0); linkContainer.Clear(); @@ -56,23 +56,22 @@ namespace osu.Game.Overlays.BeatmapSet RelativeSizeAxes = Axes.X, AutoSizeAxes = Axes.Y, Direction = FillDirection.Vertical, - Margin = new MarginPadding { Top = 10, Left = 5, Right = 20 }, + Padding = new MarginPadding(10), Children = new Drawable[] { - textContainer = new TextFlowContainer(t => { t.Font = OsuFont.GetFont(size: 20, weight: FontWeight.Medium); t.Margin = new MarginPadding { Horizontal = 5 }; }) + textContainer = new TextFlowContainer(t => t.Font = OsuFont.GetFont(size: 20, weight: FontWeight.Medium)) { Direction = FillDirection.Full, RelativeSizeAxes = Axes.X, AutoSizeAxes = Axes.Y, - Margin = new MarginPadding { Bottom = 10 }, Colour = Color4.Orange, }, - linkContainer = new LinkFlowContainer(t => { t.Font = OsuFont.GetFont(size: 14); t.Margin = new MarginPadding { Horizontal = 5 }; }) + linkContainer = new LinkFlowContainer(t => t.Font = OsuFont.GetFont(size: 14)) { Direction = FillDirection.Full, RelativeSizeAxes = Axes.X, AutoSizeAxes = Axes.Y, - Margin = new MarginPadding { Bottom = 10 }, + Padding = new MarginPadding { Top = 10 }, }, }, },