mirror of
https://github.com/ppy/osu.git
synced 2025-01-28 05:22:54 +08:00
Fix tests potentially selecting a deleted beatmap
This commit is contained in:
parent
06f58dd3e3
commit
81889e0034
@ -774,6 +774,9 @@ namespace osu.Game.Tests.Visual.SongSelect
|
|||||||
[Test]
|
[Test]
|
||||||
public void TestChangeRulesetWhilePresentingScore()
|
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);
|
changeRuleset(0);
|
||||||
|
|
||||||
createSongSelect();
|
createSongSelect();
|
||||||
@ -783,55 +786,52 @@ namespace osu.Game.Tests.Visual.SongSelect
|
|||||||
|
|
||||||
AddStep("present score", () =>
|
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.
|
// this ruleset change should be overridden by the present.
|
||||||
Ruleset.Value = switchBeatmap.Ruleset;
|
Ruleset.Value = getSwitchBeatmap().Ruleset;
|
||||||
|
|
||||||
songSelect.PresentScore(new ScoreInfo
|
songSelect.PresentScore(new ScoreInfo
|
||||||
{
|
{
|
||||||
User = new User { Username = "woo" },
|
User = new User { Username = "woo" },
|
||||||
Beatmap = presentBeatmap,
|
Beatmap = getPresentBeatmap(),
|
||||||
Ruleset = presentBeatmap.Ruleset
|
Ruleset = getPresentBeatmap().Ruleset
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
AddUntilStep("wait for results screen presented", () => !songSelect.IsCurrentScreen());
|
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);
|
AddAssert("check ruleset is correct for score", () => Ruleset.Value.ID == 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
[Test]
|
[Test]
|
||||||
public void TestChangeBeatmapWhilePresentingScore()
|
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(0);
|
||||||
addRulesetImportStep(1);
|
addRulesetImportStep(1);
|
||||||
|
|
||||||
|
createSongSelect();
|
||||||
|
|
||||||
AddStep("present score", () =>
|
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.
|
// this beatmap change should be overridden by the present.
|
||||||
Beatmap.Value = manager.GetWorkingBeatmap(switchBeatmap);
|
Beatmap.Value = manager.GetWorkingBeatmap(getSwitchBeatmap());
|
||||||
|
|
||||||
songSelect.PresentScore(new ScoreInfo
|
songSelect.PresentScore(new ScoreInfo
|
||||||
{
|
{
|
||||||
User = new User { Username = "woo" },
|
User = new User { Username = "woo" },
|
||||||
Beatmap = presentBeatmap,
|
Beatmap = getPresentBeatmap(),
|
||||||
Ruleset = presentBeatmap.Ruleset
|
Ruleset = getPresentBeatmap().Ruleset
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
AddUntilStep("wait for results screen presented", () => !songSelect.IsCurrentScreen());
|
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);
|
AddAssert("check ruleset is correct for score", () => Ruleset.Value.ID == 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user