mirror of
https://github.com/ppy/osu.git
synced 2024-11-11 12:57:36 +08:00
Merge pull request #16341 from bdach/score-submission-test-failures
Fix intermittent failure in score submission test
This commit is contained in:
commit
f440aadcbc
@ -57,7 +57,7 @@ namespace osu.Game.Tests.Visual.Gameplay
|
||||
[Test]
|
||||
public void TestNoSubmissionOnResultsWithNoToken()
|
||||
{
|
||||
prepareTokenResponse(false);
|
||||
prepareTestAPI(false);
|
||||
|
||||
createPlayerTest();
|
||||
|
||||
@ -77,7 +77,7 @@ namespace osu.Game.Tests.Visual.Gameplay
|
||||
[Test]
|
||||
public void TestSubmissionOnResults()
|
||||
{
|
||||
prepareTokenResponse(true);
|
||||
prepareTestAPI(true);
|
||||
|
||||
createPlayerTest();
|
||||
|
||||
@ -96,7 +96,7 @@ namespace osu.Game.Tests.Visual.Gameplay
|
||||
[Test]
|
||||
public void TestSubmissionForDifferentRuleset()
|
||||
{
|
||||
prepareTokenResponse(true);
|
||||
prepareTestAPI(true);
|
||||
|
||||
createPlayerTest(createRuleset: () => new TaikoRuleset());
|
||||
|
||||
@ -116,7 +116,7 @@ namespace osu.Game.Tests.Visual.Gameplay
|
||||
[Test]
|
||||
public void TestSubmissionForConvertedBeatmap()
|
||||
{
|
||||
prepareTokenResponse(true);
|
||||
prepareTestAPI(true);
|
||||
|
||||
createPlayerTest(createRuleset: () => new ManiaRuleset(), createBeatmap: _ => createTestBeatmap(new OsuRuleset().RulesetInfo));
|
||||
|
||||
@ -136,7 +136,7 @@ namespace osu.Game.Tests.Visual.Gameplay
|
||||
[Test]
|
||||
public void TestNoSubmissionOnExitWithNoToken()
|
||||
{
|
||||
prepareTokenResponse(false);
|
||||
prepareTestAPI(false);
|
||||
|
||||
createPlayerTest();
|
||||
|
||||
@ -153,7 +153,7 @@ namespace osu.Game.Tests.Visual.Gameplay
|
||||
[Test]
|
||||
public void TestNoSubmissionOnEmptyFail()
|
||||
{
|
||||
prepareTokenResponse(true);
|
||||
prepareTestAPI(true);
|
||||
|
||||
createPlayerTest(true);
|
||||
|
||||
@ -168,7 +168,7 @@ namespace osu.Game.Tests.Visual.Gameplay
|
||||
[Test]
|
||||
public void TestSubmissionOnFail()
|
||||
{
|
||||
prepareTokenResponse(true);
|
||||
prepareTestAPI(true);
|
||||
|
||||
createPlayerTest(true);
|
||||
|
||||
@ -185,7 +185,7 @@ namespace osu.Game.Tests.Visual.Gameplay
|
||||
[Test]
|
||||
public void TestNoSubmissionOnEmptyExit()
|
||||
{
|
||||
prepareTokenResponse(true);
|
||||
prepareTestAPI(true);
|
||||
|
||||
createPlayerTest();
|
||||
|
||||
@ -198,7 +198,7 @@ namespace osu.Game.Tests.Visual.Gameplay
|
||||
[Test]
|
||||
public void TestSubmissionOnExit()
|
||||
{
|
||||
prepareTokenResponse(true);
|
||||
prepareTestAPI(true);
|
||||
|
||||
createPlayerTest();
|
||||
|
||||
@ -213,7 +213,7 @@ namespace osu.Game.Tests.Visual.Gameplay
|
||||
[Test]
|
||||
public void TestSubmissionOnExitDuringImport()
|
||||
{
|
||||
prepareTokenResponse(true);
|
||||
prepareTestAPI(true);
|
||||
|
||||
createPlayerTest();
|
||||
AddStep("block imports", () => Player.AllowImportCompletion.Wait());
|
||||
@ -226,13 +226,13 @@ namespace osu.Game.Tests.Visual.Gameplay
|
||||
|
||||
AddStep("exit", () => Player.Exit());
|
||||
AddStep("allow import to proceed", () => Player.AllowImportCompletion.Release(1));
|
||||
AddAssert("ensure submission", () => Player.SubmittedScore != null && Player.ImportedScore != null);
|
||||
AddUntilStep("ensure submission", () => Player.SubmittedScore != null && Player.ImportedScore != null);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void TestNoSubmissionOnLocalBeatmap()
|
||||
{
|
||||
prepareTokenResponse(true);
|
||||
prepareTestAPI(true);
|
||||
|
||||
createPlayerTest(false, r =>
|
||||
{
|
||||
@ -253,7 +253,7 @@ namespace osu.Game.Tests.Visual.Gameplay
|
||||
[TestCase(10)]
|
||||
public void TestNoSubmissionOnCustomRuleset(int? rulesetId)
|
||||
{
|
||||
prepareTokenResponse(true);
|
||||
prepareTestAPI(true);
|
||||
|
||||
createPlayerTest(false, createRuleset: () => new OsuRuleset { RulesetInfo = { OnlineID = rulesetId ?? -1 } });
|
||||
|
||||
@ -275,7 +275,7 @@ namespace osu.Game.Tests.Visual.Gameplay
|
||||
}));
|
||||
}
|
||||
|
||||
private void prepareTokenResponse(bool validToken)
|
||||
private void prepareTestAPI(bool validToken)
|
||||
{
|
||||
AddStep("Prepare test API", () =>
|
||||
{
|
||||
@ -289,6 +289,31 @@ namespace osu.Game.Tests.Visual.Gameplay
|
||||
else
|
||||
tokenRequest.TriggerFailure(new APIException("something went wrong!", null));
|
||||
return true;
|
||||
|
||||
case SubmitSoloScoreRequest submissionRequest:
|
||||
if (validToken)
|
||||
{
|
||||
var requestScore = submissionRequest.Score;
|
||||
|
||||
submissionRequest.TriggerSuccess(new MultiplayerScore
|
||||
{
|
||||
ID = 1234,
|
||||
User = dummyAPI.LocalUser.Value,
|
||||
Rank = requestScore.Rank,
|
||||
TotalScore = requestScore.TotalScore,
|
||||
Accuracy = requestScore.Accuracy,
|
||||
MaxCombo = requestScore.MaxCombo,
|
||||
Mods = requestScore.Mods,
|
||||
Statistics = requestScore.Statistics,
|
||||
Passed = requestScore.Passed,
|
||||
EndedAt = DateTimeOffset.Now,
|
||||
Position = 1
|
||||
});
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
break;
|
||||
}
|
||||
|
||||
return false;
|
||||
|
@ -12,17 +12,17 @@ namespace osu.Game.Online.Solo
|
||||
{
|
||||
public class SubmitSoloScoreRequest : APIRequest<MultiplayerScore>
|
||||
{
|
||||
public readonly SubmittableScore Score;
|
||||
|
||||
private readonly long scoreId;
|
||||
|
||||
private readonly int beatmapId;
|
||||
|
||||
private readonly SubmittableScore score;
|
||||
|
||||
public SubmitSoloScoreRequest(int beatmapId, long scoreId, ScoreInfo scoreInfo)
|
||||
{
|
||||
this.beatmapId = beatmapId;
|
||||
this.scoreId = scoreId;
|
||||
score = new SubmittableScore(scoreInfo);
|
||||
Score = new SubmittableScore(scoreInfo);
|
||||
}
|
||||
|
||||
protected override WebRequest CreateWebRequest()
|
||||
@ -33,7 +33,7 @@ namespace osu.Game.Online.Solo
|
||||
req.Method = HttpMethod.Put;
|
||||
req.Timeout = 30000;
|
||||
|
||||
req.AddRaw(JsonConvert.SerializeObject(score, new JsonSerializerSettings
|
||||
req.AddRaw(JsonConvert.SerializeObject(Score, new JsonSerializerSettings
|
||||
{
|
||||
ReferenceLoopHandling = ReferenceLoopHandling.Ignore
|
||||
}));
|
||||
|
Loading…
Reference in New Issue
Block a user