1
0
mirror of https://github.com/ppy/osu.git synced 2025-01-13 14:12:56 +08:00

Fix tests potentially selecting a deleted beatmap

This commit is contained in:
Dean Herbert 2020-05-04 15:19:36 +09:00
parent 06f58dd3e3
commit 81889e0034

View File

@ -774,6 +774,9 @@ namespace osu.Game.Tests.Visual.SongSelect
[Test]
public void TestChangeRulesetWhilePresentingScore()
{
BeatmapInfo getPresentBeatmap() => manager.QueryBeatmap(b => !b.BeatmapSet.DeletePending && b.RulesetID == 0);
BeatmapInfo getSwitchBeatmap() => manager.QueryBeatmap(b => !b.BeatmapSet.DeletePending && b.RulesetID == 1);
changeRuleset(0);
createSongSelect();
@ -783,55 +786,52 @@ namespace osu.Game.Tests.Visual.SongSelect
AddStep("present score", () =>
{
var presentBeatmap = manager.QueryBeatmap(b => b.RulesetID == 0);
var switchBeatmap = manager.QueryBeatmap(b => b.RulesetID == 1);
// this ruleset change should be overridden by the present.
Ruleset.Value = switchBeatmap.Ruleset;
Ruleset.Value = getSwitchBeatmap().Ruleset;
songSelect.PresentScore(new ScoreInfo
{
User = new User { Username = "woo" },
Beatmap = presentBeatmap,
Ruleset = presentBeatmap.Ruleset
Beatmap = getPresentBeatmap(),
Ruleset = getPresentBeatmap().Ruleset
});
});
AddUntilStep("wait for results screen presented", () => !songSelect.IsCurrentScreen());
AddAssert("check beatmap is correct for score", () => Beatmap.Value.BeatmapInfo.Equals(manager.QueryBeatmap(b => b.RulesetID == 0)));
AddAssert("check beatmap is correct for score", () => Beatmap.Value.BeatmapInfo.Equals(getPresentBeatmap()));
AddAssert("check ruleset is correct for score", () => Ruleset.Value.ID == 0);
}
[Test]
public void TestChangeBeatmapWhilePresentingScore()
{
changeRuleset(0);
BeatmapInfo getPresentBeatmap() => manager.QueryBeatmap(b => !b.BeatmapSet.DeletePending && b.RulesetID == 0);
BeatmapInfo getSwitchBeatmap() => manager.QueryBeatmap(b => !b.BeatmapSet.DeletePending && b.RulesetID == 1);
createSongSelect();
changeRuleset(0);
addRulesetImportStep(0);
addRulesetImportStep(1);
createSongSelect();
AddStep("present score", () =>
{
var presentBeatmap = manager.QueryBeatmap(b => b.RulesetID == 0);
var switchBeatmap = manager.QueryBeatmap(b => b.RulesetID == 1);
// this beatmap change should be overridden by the present.
Beatmap.Value = manager.GetWorkingBeatmap(switchBeatmap);
Beatmap.Value = manager.GetWorkingBeatmap(getSwitchBeatmap());
songSelect.PresentScore(new ScoreInfo
{
User = new User { Username = "woo" },
Beatmap = presentBeatmap,
Ruleset = presentBeatmap.Ruleset
Beatmap = getPresentBeatmap(),
Ruleset = getPresentBeatmap().Ruleset
});
});
AddUntilStep("wait for results screen presented", () => !songSelect.IsCurrentScreen());
AddAssert("check beatmap is correct for score", () => Beatmap.Value.BeatmapInfo.Equals(manager.QueryBeatmap(b => b.RulesetID == 0)));
AddAssert("check beatmap is correct for score", () => Beatmap.Value.BeatmapInfo.Equals(getPresentBeatmap()));
AddAssert("check ruleset is correct for score", () => Ruleset.Value.ID == 0);
}