More changes and improvements

This commit is contained in:
KingLuigi4932 2019-06-19 17:55:36 +03:00
parent a6c268ef5c
commit 9f25d3cd72
3 changed files with 63 additions and 19 deletions

View File

@ -1,51 +1,97 @@
// Copyright (c) ppy Pty Ltd <contact@ppy.sh>. 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));
}
}
}

View File

@ -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,

View File

@ -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 },
},
},
},