osu/osu.Game.Tests/Visual/Online/TestSceneBeatmapAvailability.cs

97 lines
2.8 KiB
C#
Raw Normal View History

2019-06-11 11:58:46 +00:00
// 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.
2019-06-19 14:55:36 +00:00
using NUnit.Framework;
2019-06-11 11:58:46 +00:00
using osu.Game.Beatmaps;
using osu.Game.Online.API.Requests.Responses;
2019-06-11 11:58:46 +00:00
using osu.Game.Overlays.BeatmapSet;
namespace osu.Game.Tests.Visual.Online
{
2019-06-19 14:55:36 +00:00
[TestFixture]
2019-06-27 02:40:22 +00:00
public class TestSceneBeatmapAvailability : OsuTestScene
2019-06-11 11:58:46 +00:00
{
2019-06-27 02:40:22 +00:00
private readonly BeatmapAvailability container;
2019-06-19 14:55:36 +00:00
2019-06-27 02:40:22 +00:00
public TestSceneBeatmapAvailability()
2019-06-11 11:58:46 +00:00
{
2019-06-27 02:40:22 +00:00
Add(container = new BeatmapAvailability());
2019-06-19 14:55:36 +00:00
}
2019-06-11 11:58:46 +00:00
2019-06-19 14:55:36 +00:00
[Test]
public void TestUndownloadableWithLink()
{
AddStep("set undownloadable beatmapset with link", () => container.BeatmapSet = new BeatmapSetInfo
{
OnlineInfo = new APIBeatmapSet
2019-06-19 14:55:36 +00:00
{
Availability = new BeatmapSetOnlineAvailability
{
DownloadDisabled = true,
ExternalLink = @"https://osu.ppy.sh",
},
},
});
visiblityAssert(true);
}
2019-06-11 11:58:46 +00:00
2019-06-19 14:55:36 +00:00
[Test]
public void TestUndownloadableNoLink()
{
AddStep("set undownloadable beatmapset without link", () => container.BeatmapSet = new BeatmapSetInfo
2019-06-11 11:58:46 +00:00
{
OnlineInfo = new APIBeatmapSet
2019-06-11 11:58:46 +00:00
{
Availability = new BeatmapSetOnlineAvailability
{
DownloadDisabled = true,
},
},
});
2019-06-19 14:55:36 +00:00
visiblityAssert(true);
}
[Test]
public void TestPartsRemovedWithLink()
{
AddStep("set parts-removed beatmapset with link", () => container.BeatmapSet = new BeatmapSetInfo
2019-06-11 11:58:46 +00:00
{
OnlineInfo = new APIBeatmapSet
2019-06-11 11:58:46 +00:00
{
Availability = new BeatmapSetOnlineAvailability
{
DownloadDisabled = false,
2019-06-19 14:55:36 +00:00
ExternalLink = @"https://osu.ppy.sh",
2019-06-11 11:58:46 +00:00
},
},
});
2019-06-19 14:55:36 +00:00
visiblityAssert(true);
}
[Test]
public void TestNormal()
{
2019-06-11 11:58:46 +00:00
AddStep("set normal beatmapset", () => container.BeatmapSet = new BeatmapSetInfo
{
OnlineInfo = new APIBeatmapSet
2019-06-19 14:55:36 +00:00
{
Availability = new BeatmapSetOnlineAvailability
{
DownloadDisabled = false,
},
},
2019-06-11 11:58:46 +00:00
});
2019-06-19 14:55:36 +00:00
visiblityAssert(false);
}
private void visiblityAssert(bool shown)
{
AddAssert($"is container {(shown ? "visible" : "hidden")}", () => container.Alpha == (shown ? 1 : 0));
2019-06-11 11:58:46 +00:00
}
}
}