Allow creating sample API models without specifying a ruleset

This commit is contained in:
Dean Herbert 2021-11-01 16:43:39 +09:00
parent e3a9fbecfe
commit 66f4516eee
4 changed files with 20 additions and 19 deletions

View File

@ -6,6 +6,7 @@ using System.Linq;
using NUnit.Framework;
using osu.Framework.Allocation;
using osu.Framework.Audio;
using osu.Framework.Extensions.IEnumerableExtensions;
using osu.Framework.Graphics;
using osu.Framework.Graphics.Containers;
using osu.Framework.Platform;
@ -202,7 +203,7 @@ namespace osu.Game.Tests.Visual.Multiplayer
[Test]
public void TestDownloadButtonHiddenWhenBeatmapExists()
{
var beatmap = new TestBeatmap(new OsuRuleset().RulesetInfo).BeatmapInfo;
var beatmap = CreateAPIBeatmapSet();
AddStep("import beatmap", () => manager.Import(beatmap.BeatmapSet).Wait());
@ -223,11 +224,11 @@ namespace osu.Game.Tests.Visual.Multiplayer
[Test]
public void TestDownloadButtonVisibleInitiallyWhenBeatmapDoesNotExist()
{
var byOnlineId = new TestBeatmap(new OsuRuleset().RulesetInfo).BeatmapInfo;
byOnlineId.BeatmapSet.OnlineBeatmapSetID = 1337; // Some random ID that does not exist locally.
var byOnlineId = CreateAPIBeatmapSet();
byOnlineId.OnlineID = 1337; // Some random ID that does not exist locally.
var byChecksum = new TestBeatmap(new OsuRuleset().RulesetInfo).BeatmapInfo;
byChecksum.MD5Hash = "1337"; // Some random checksum that does not exist locally.
var byChecksum = CreateAPIBeatmapSet();
byChecksum.Beatmaps.ForEach(b => b.Checksum = "1337"); // Some random checksum that does not exist locally.
createPlaylist(byOnlineId, byChecksum);
@ -237,8 +238,9 @@ namespace osu.Game.Tests.Visual.Multiplayer
[Test]
public void TestExplicitBeatmapItem()
{
var beatmap = new TestBeatmap(new OsuRuleset().RulesetInfo).BeatmapInfo;
beatmap.BeatmapSet.OnlineInfo.HasExplicitContent = true;
var beatmap = CreateAPIBeatmapSet();
beatmap.HasExplicitContent = true;
createPlaylist(beatmap);
}

View File

@ -9,7 +9,6 @@ using osu.Game.Beatmaps;
using osu.Game.Online;
using osu.Game.Online.API.Requests.Responses;
using osu.Game.Overlays.BeatmapListing.Panels;
using osu.Game.Rulesets.Osu;
using osu.Game.Tests.Resources;
using osuTK;
@ -110,7 +109,7 @@ namespace osu.Game.Tests.Visual.Online
private IBeatmapSetInfo getDownloadableBeatmapSet()
{
var apiBeatmapSet = CreateWorkingBeatmap(new OsuRuleset().RulesetInfo).BeatmapSetInfo.OnlineInfo;
var apiBeatmapSet = CreateAPIBeatmapSet();
apiBeatmapSet.HasVideo = true;
apiBeatmapSet.HasStoryboard = true;
@ -120,7 +119,7 @@ namespace osu.Game.Tests.Visual.Online
private IBeatmapSetInfo getUndownloadableBeatmapSet()
{
var apiBeatmapSet = CreateWorkingBeatmap(new OsuRuleset().RulesetInfo).BeatmapSetInfo.OnlineInfo;
var apiBeatmapSet = CreateAPIBeatmapSet();
apiBeatmapSet.Artist = "test";
apiBeatmapSet.Title = "undownloadable";

View File

@ -25,7 +25,7 @@ namespace osu.Game.Tests.Visual.UserInterface
{
AddStep("setup cover", () => Child = new UpdateableOnlineBeatmapSetCover(coverType)
{
OnlineInfo = CreateBeatmap(Ruleset.Value).BeatmapInfo.BeatmapSet.OnlineInfo,
OnlineInfo = CreateAPIBeatmapSet(),
RelativeSizeAxes = Axes.Both,
Masking = true,
});
@ -41,7 +41,7 @@ namespace osu.Game.Tests.Visual.UserInterface
AddStep("setup covers", () =>
{
BeatmapSetInfo setInfo = CreateBeatmap(Ruleset.Value).BeatmapInfo.BeatmapSet;
var beatmapSet = CreateAPIBeatmapSet();
FillFlowContainer fillFlow;
@ -99,7 +99,7 @@ namespace osu.Game.Tests.Visual.UserInterface
AddStep("setup cover", () => Child = updateableCover = new TestUpdateableOnlineBeatmapSetCover
{
OnlineInfo = CreateBeatmap(Ruleset.Value).BeatmapInfo.BeatmapSet.OnlineInfo,
OnlineInfo = CreateAPIBeatmapSet(),
RelativeSizeAxes = Axes.Both,
Masking = true,
});

View File

@ -178,10 +178,10 @@ namespace osu.Game.Tests.Visual
/// <summary>
/// Returns a sample API Beatmap with BeatmapSet populated.
/// </summary>
/// <param name="ruleset">The ruleset to create the sample model using.</param>
protected APIBeatmap CreateAPIBeatmap(RulesetInfo ruleset)
/// <param name="ruleset">The ruleset to create the sample model using. osu! ruleset will be used if not specified.</param>
protected APIBeatmap CreateAPIBeatmap(RulesetInfo ruleset = null)
{
var beatmapSet = CreateAPIBeatmapSet(ruleset);
var beatmapSet = CreateAPIBeatmapSet(ruleset ?? Ruleset.Value);
// Avoid circular reference.
var beatmap = beatmapSet.Beatmaps.First();
@ -196,10 +196,10 @@ namespace osu.Game.Tests.Visual
/// <summary>
/// Returns a sample API BeatmapSet with beatmaps populated.
/// </summary>
/// <param name="ruleset">The ruleset to create the sample model using.</param>
protected APIBeatmapSet CreateAPIBeatmapSet(RulesetInfo ruleset)
/// <param name="ruleset">The ruleset to create the sample model using. osu! ruleset will be used if not specified.</param>
protected APIBeatmapSet CreateAPIBeatmapSet(RulesetInfo ruleset = null)
{
var beatmap = CreateBeatmap(ruleset).BeatmapInfo;
var beatmap = CreateBeatmap(ruleset ?? Ruleset.Value).BeatmapInfo;
return new APIBeatmapSet
{