mirror of
https://github.com/ppy/osu.git
synced 2024-12-15 14:02:55 +08:00
Add more tests and fix one remaining issue case
This commit is contained in:
parent
d7f1766ee2
commit
64ead0fdf7
@ -82,11 +82,10 @@ namespace osu.Game.Tests.Visual
|
||||
public virtual void SetUp()
|
||||
{
|
||||
manager?.Delete(manager.GetAllUsableBeatmapSets());
|
||||
|
||||
Child = songSelect = new TestSongSelect();
|
||||
}
|
||||
|
||||
//[Test]
|
||||
[Test]
|
||||
public void TestDummy()
|
||||
{
|
||||
AddAssert("dummy selected", () => songSelect.CurrentBeatmap == defaultBeatmap);
|
||||
@ -99,7 +98,7 @@ namespace osu.Game.Tests.Visual
|
||||
AddAssert("random map selected", () => songSelect.CurrentBeatmap != defaultBeatmap);
|
||||
}
|
||||
|
||||
//[Test]
|
||||
[Test]
|
||||
public void TestSorting()
|
||||
{
|
||||
addManyTestMaps();
|
||||
@ -114,24 +113,35 @@ namespace osu.Game.Tests.Visual
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void TestRulesetChange()
|
||||
public void ImportUnderDifferentRuleset()
|
||||
{
|
||||
AddStep("change ruleset", () => Ruleset.Value = rulesets.AvailableRulesets.First(r => r.ID == 2));
|
||||
|
||||
AddStep("import test maps", () =>
|
||||
{
|
||||
manager.Import(createTestBeatmapSet(0, rulesets.AvailableRulesets.Where(r => r.ID == 0).ToArray()));
|
||||
manager.Import(createTestBeatmapSet(1, rulesets.AvailableRulesets.Where(r => r.ID == 2).ToArray()));
|
||||
|
||||
});
|
||||
|
||||
AddStep("change ruleset", () => Ruleset.Value = rulesets.AvailableRulesets.First(r => r.ID == 1));
|
||||
|
||||
changeRuleset(2);
|
||||
importForRuleset(0);
|
||||
AddUntilStep(() => songSelect.Carousel.SelectedBeatmap == null, "no selection");
|
||||
|
||||
AddStep("change ruleset", () => Ruleset.Value = rulesets.AvailableRulesets.First(r => r.ID == 0));
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void ImportUnderCurrentRuleset()
|
||||
{
|
||||
changeRuleset(2);
|
||||
importForRuleset(2);
|
||||
importForRuleset(1);
|
||||
AddUntilStep(() => songSelect.Carousel.SelectedBeatmap.RulesetID == 2, "has selection");
|
||||
|
||||
changeRuleset(1);
|
||||
AddUntilStep(() => songSelect.Carousel.SelectedBeatmap.RulesetID == 1, "has selection");
|
||||
|
||||
changeRuleset(0);
|
||||
AddUntilStep(() => songSelect.Carousel.SelectedBeatmap == null, "no selection");
|
||||
}
|
||||
|
||||
private void importForRuleset(int id) => AddStep($"import test map for ruleset {id}", () => manager.Import(createTestBeatmapSet(getImportId(), rulesets.AvailableRulesets.Where(r => r.ID == id).ToArray())));
|
||||
|
||||
private static int importId;
|
||||
private int getImportId() => ++importId;
|
||||
|
||||
private void changeRuleset(int id) => AddStep($"change ruleset to {id}", () => Ruleset.Value = rulesets.AvailableRulesets.First(r => r.ID == id));
|
||||
|
||||
private void addManyTestMaps()
|
||||
{
|
||||
AddStep("import test maps", () =>
|
||||
@ -143,18 +153,16 @@ namespace osu.Game.Tests.Visual
|
||||
});
|
||||
}
|
||||
|
||||
private BeatmapSetInfo createTestBeatmapSet(int idOffset, RulesetInfo[] rulesets)
|
||||
private BeatmapSetInfo createTestBeatmapSet(int setId, RulesetInfo[] rulesets)
|
||||
{
|
||||
int j = 0;
|
||||
RulesetInfo getRuleset() => rulesets[j++ % rulesets.Length];
|
||||
|
||||
var beatmaps = new List<BeatmapInfo>();
|
||||
|
||||
int setId = 1234 + idOffset;
|
||||
|
||||
for (int i = 0; i < 6; i++)
|
||||
{
|
||||
int beatmapId = 1234 + idOffset + i;
|
||||
int beatmapId = setId * 10 + i;
|
||||
|
||||
beatmaps.Add(new BeatmapInfo
|
||||
{
|
||||
@ -169,7 +177,6 @@ namespace osu.Game.Tests.Visual
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
return new BeatmapSetInfo
|
||||
{
|
||||
OnlineBeatmapSetID = setId,
|
||||
|
@ -309,9 +309,9 @@ namespace osu.Game.Screens.Select
|
||||
var beatmap = beatmapNoDebounce;
|
||||
var ruleset = rulesetNoDebounce;
|
||||
|
||||
void performLoad()
|
||||
void run()
|
||||
{
|
||||
Logger.Log($"performLoad with b:{beatmap} r:{ruleset}");
|
||||
Logger.Log($"updating selection with beatmap:{beatmap?.ID.ToString() ?? "null"} ruleset:{ruleset?.ID.ToString() ?? "null"}");
|
||||
|
||||
WorkingBeatmap working = Beatmap.Value;
|
||||
|
||||
@ -319,19 +319,24 @@ namespace osu.Game.Screens.Select
|
||||
|
||||
if (ruleset?.Equals(Ruleset.Value) == false)
|
||||
{
|
||||
Logger.Log($"ruleset changed from {Ruleset.Value} to {ruleset}");
|
||||
Logger.Log($"ruleset changed from \"{Ruleset.Value}\" to \"{ruleset}\"");
|
||||
Ruleset.Value = ruleset;
|
||||
|
||||
// force a filter before attempting to change the beatmap.
|
||||
// we may still be in the wrong ruleset as there is a debounce delay on ruleset changes.
|
||||
Carousel.Filter(null, false);
|
||||
|
||||
// Filtering only completes after the carousel runs Update.
|
||||
// If we also have a pending beatmap change we should delay it one frame.
|
||||
selectionChangedDebounce = Schedule(run);
|
||||
return;
|
||||
}
|
||||
|
||||
// We may be arriving here due to another component changing the bindable Beatmap.
|
||||
// In these cases, the other component has already loaded the beatmap, so we don't need to do so again.
|
||||
if (!Equals(beatmap, Beatmap.Value.BeatmapInfo))
|
||||
{
|
||||
Logger.Log($"beatmap changed from {Beatmap.Value.BeatmapInfo} to {beatmap}");
|
||||
Logger.Log($"beatmap changed from \"{Beatmap.Value.BeatmapInfo}\" to \"{beatmap}\"");
|
||||
|
||||
preview = beatmap?.BeatmapSetInfoID != Beatmap.Value?.BeatmapInfo.BeatmapSetInfoID;
|
||||
working = beatmaps.GetWorkingBeatmap(beatmap, Beatmap.Value);
|
||||
@ -355,9 +360,9 @@ namespace osu.Game.Screens.Select
|
||||
selectionChangedDebounce?.Cancel();
|
||||
|
||||
if (beatmap == null)
|
||||
performLoad();
|
||||
run();
|
||||
else
|
||||
selectionChangedDebounce = Scheduler.AddDelayed(performLoad, 200);
|
||||
selectionChangedDebounce = Scheduler.AddDelayed(run, 200);
|
||||
}
|
||||
|
||||
private void triggerRandom()
|
||||
|
Loading…
Reference in New Issue
Block a user