1
0
mirror of https://github.com/ppy/osu.git synced 2024-11-06 06:17:23 +08:00

Merge pull request #20507 from smoogipoo/fix-multiplayer-tests

Fix failing multiplayer tests
This commit is contained in:
Dean Herbert 2022-09-28 17:41:55 +09:00 committed by GitHub
commit 9b3778f226
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 40 additions and 29 deletions

View File

@ -9,27 +9,25 @@ namespace osu.Game.Online.API.Requests
{
public class GetBeatmapRequest : APIRequest<APIBeatmap>
{
private readonly IBeatmapInfo beatmapInfo;
private readonly string filename;
public readonly IBeatmapInfo BeatmapInfo;
public readonly string Filename;
public GetBeatmapRequest(IBeatmapInfo beatmapInfo)
{
this.beatmapInfo = beatmapInfo;
filename = (beatmapInfo as BeatmapInfo)?.Path ?? string.Empty;
BeatmapInfo = beatmapInfo;
Filename = (beatmapInfo as BeatmapInfo)?.Path ?? string.Empty;
}
protected override WebRequest CreateWebRequest()
{
var request = base.CreateWebRequest();
if (beatmapInfo.OnlineID > 0)
request.AddParameter(@"id", beatmapInfo.OnlineID.ToString());
if (!string.IsNullOrEmpty(beatmapInfo.MD5Hash))
request.AddParameter(@"checksum", beatmapInfo.MD5Hash);
if (!string.IsNullOrEmpty(filename))
request.AddParameter(@"filename", filename);
if (BeatmapInfo.OnlineID > 0)
request.AddParameter(@"id", BeatmapInfo.OnlineID.ToString());
if (!string.IsNullOrEmpty(BeatmapInfo.MD5Hash))
request.AddParameter(@"checksum", BeatmapInfo.MD5Hash);
if (!string.IsNullOrEmpty(Filename))
request.AddParameter(@"filename", Filename);
return request;
}

View File

@ -54,6 +54,8 @@ namespace osu.Game.Screens.OnlinePlay.Multiplayer.Match
{
private const float disabled_alpha = 0.2f;
public override bool IsPresent => base.IsPresent || Scheduler.HasPendingTasks;
public Action? SettingsApplied;
public OsuTextBox NameField = null!;

View File

@ -135,25 +135,15 @@ namespace osu.Game.Tests.Visual.OnlinePlay
});
return true;
case GetBeatmapRequest getBeatmapRequest:
{
getBeatmapRequest.TriggerSuccess(createResponseBeatmaps(getBeatmapRequest.BeatmapInfo.OnlineID).Single());
return true;
}
case GetBeatmapsRequest getBeatmapsRequest:
{
var result = new List<APIBeatmap>();
foreach (int id in getBeatmapsRequest.BeatmapIds)
{
var baseBeatmap = beatmapManager.QueryBeatmap(b => b.OnlineID == id);
if (baseBeatmap == null)
{
baseBeatmap = new TestBeatmap(new RulesetInfo { OnlineID = 0 }).BeatmapInfo;
baseBeatmap.OnlineID = id;
baseBeatmap.BeatmapSet!.OnlineID = id;
}
result.Add(OsuTestScene.CreateAPIBeatmap(baseBeatmap));
}
getBeatmapsRequest.TriggerSuccess(new GetBeatmapsResponse { Beatmaps = result });
getBeatmapsRequest.TriggerSuccess(new GetBeatmapsResponse { Beatmaps = createResponseBeatmaps(getBeatmapsRequest.BeatmapIds.ToArray()) });
return true;
}
@ -175,6 +165,27 @@ namespace osu.Game.Tests.Visual.OnlinePlay
}
}
List<APIBeatmap> createResponseBeatmaps(params int[] beatmapIds)
{
var result = new List<APIBeatmap>();
foreach (int id in beatmapIds)
{
var baseBeatmap = beatmapManager.QueryBeatmap(b => b.OnlineID == id);
if (baseBeatmap == null)
{
baseBeatmap = new TestBeatmap(new RulesetInfo { OnlineID = 0 }).BeatmapInfo;
baseBeatmap.OnlineID = id;
baseBeatmap.BeatmapSet!.OnlineID = id;
}
result.Add(OsuTestScene.CreateAPIBeatmap(baseBeatmap));
}
return result;
}
return false;
}