mirror of
https://github.com/ppy/osu.git
synced 2025-01-28 07:23:14 +08:00
Merge pull request #21465 from peppy/fix-replay-download-button-tests
Fix flaky test conditions in `TestSceneReplayDownloadButton`
This commit is contained in:
commit
59001205cf
@ -107,7 +107,7 @@ namespace osu.Game.Tests.Visual.Gameplay
|
|||||||
|
|
||||||
AddUntilStep("wait for load", () => downloadButton.IsLoaded);
|
AddUntilStep("wait for load", () => downloadButton.IsLoaded);
|
||||||
|
|
||||||
AddAssert("state is available", () => downloadButton.State.Value == DownloadState.NotDownloaded);
|
checkState(DownloadState.NotDownloaded);
|
||||||
|
|
||||||
AddStep("click button", () =>
|
AddStep("click button", () =>
|
||||||
{
|
{
|
||||||
@ -133,7 +133,7 @@ namespace osu.Game.Tests.Visual.Gameplay
|
|||||||
|
|
||||||
AddUntilStep("wait for load", () => downloadButton.IsLoaded);
|
AddUntilStep("wait for load", () => downloadButton.IsLoaded);
|
||||||
|
|
||||||
AddAssert("state is not downloaded", () => downloadButton.State.Value == DownloadState.NotDownloaded);
|
checkState(DownloadState.NotDownloaded);
|
||||||
AddAssert("button is not enabled", () => !downloadButton.ChildrenOfType<DownloadButton>().First().Enabled.Value);
|
AddAssert("button is not enabled", () => !downloadButton.ChildrenOfType<DownloadButton>().First().Enabled.Value);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -155,7 +155,7 @@ namespace osu.Game.Tests.Visual.Gameplay
|
|||||||
|
|
||||||
AddUntilStep("wait for load", () => downloadButton.IsLoaded);
|
AddUntilStep("wait for load", () => downloadButton.IsLoaded);
|
||||||
|
|
||||||
AddUntilStep("state is not downloaded", () => downloadButton.State.Value == DownloadState.NotDownloaded);
|
checkState(DownloadState.NotDownloaded);
|
||||||
AddAssert("button is not enabled", () => !downloadButton.ChildrenOfType<DownloadButton>().First().Enabled.Value);
|
AddAssert("button is not enabled", () => !downloadButton.ChildrenOfType<DownloadButton>().First().Enabled.Value);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -174,17 +174,16 @@ namespace osu.Game.Tests.Visual.Gameplay
|
|||||||
});
|
});
|
||||||
|
|
||||||
AddUntilStep("wait for load", () => downloadButton.IsLoaded);
|
AddUntilStep("wait for load", () => downloadButton.IsLoaded);
|
||||||
|
checkState(DownloadState.NotDownloaded);
|
||||||
AddUntilStep("state is not downloaded", () => downloadButton.State.Value == DownloadState.NotDownloaded);
|
|
||||||
|
|
||||||
AddStep("import score", () => imported = scoreManager.Import(getScoreInfo(true)));
|
AddStep("import score", () => imported = scoreManager.Import(getScoreInfo(true)));
|
||||||
|
|
||||||
AddUntilStep("state is available", () => downloadButton.State.Value == DownloadState.LocallyAvailable);
|
checkState(DownloadState.LocallyAvailable);
|
||||||
AddAssert("button is enabled", () => downloadButton.ChildrenOfType<DownloadButton>().First().Enabled.Value);
|
AddAssert("button is enabled", () => downloadButton.ChildrenOfType<DownloadButton>().First().Enabled.Value);
|
||||||
|
|
||||||
AddStep("delete score", () => scoreManager.Delete(imported.Value));
|
AddStep("delete score", () => scoreManager.Delete(imported.Value));
|
||||||
|
|
||||||
AddUntilStep("state is not downloaded", () => downloadButton.State.Value == DownloadState.NotDownloaded);
|
checkState(DownloadState.NotDownloaded);
|
||||||
AddAssert("button is not enabled", () => !downloadButton.ChildrenOfType<DownloadButton>().First().Enabled.Value);
|
AddAssert("button is not enabled", () => !downloadButton.ChildrenOfType<DownloadButton>().First().Enabled.Value);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -202,10 +201,13 @@ namespace osu.Game.Tests.Visual.Gameplay
|
|||||||
|
|
||||||
AddUntilStep("wait for load", () => downloadButton.IsLoaded);
|
AddUntilStep("wait for load", () => downloadButton.IsLoaded);
|
||||||
|
|
||||||
AddAssert("state is unknown", () => downloadButton.State.Value == DownloadState.Unknown);
|
checkState(DownloadState.Unknown);
|
||||||
AddAssert("button is not enabled", () => !downloadButton.ChildrenOfType<DownloadButton>().First().Enabled.Value);
|
AddAssert("button is not enabled", () => !downloadButton.ChildrenOfType<DownloadButton>().First().Enabled.Value);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void checkState(DownloadState expectedState) =>
|
||||||
|
AddUntilStep($"state is {expectedState}", () => downloadButton.State.Value, () => Is.EqualTo(expectedState));
|
||||||
|
|
||||||
private ScoreInfo getScoreInfo(bool replayAvailable, bool hasOnlineId = true) => new ScoreInfo
|
private ScoreInfo getScoreInfo(bool replayAvailable, bool hasOnlineId = true) => new ScoreInfo
|
||||||
{
|
{
|
||||||
OnlineID = hasOnlineId ? online_score_id : 0,
|
OnlineID = hasOnlineId ? online_score_id : 0,
|
||||||
|
Loading…
Reference in New Issue
Block a user