mirror of
https://github.com/osukey/osukey.git
synced 2025-08-07 00:23:59 +09:00
Merge pull request #14401 from frenzibyte/remove-unnecessary-queue
Refactor and fix intermittent beatmap difficulty cache tests
This commit is contained in:
@ -2,7 +2,6 @@
|
|||||||
// See the LICENCE file in the repository root for full licence text.
|
// See the LICENCE file in the repository root for full licence text.
|
||||||
|
|
||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
using System.Threading;
|
using System.Threading;
|
||||||
using System.Threading.Tasks;
|
using System.Threading.Tasks;
|
||||||
@ -32,7 +31,6 @@ namespace osu.Game.Tests.Beatmaps
|
|||||||
private TestBeatmapDifficultyCache difficultyCache;
|
private TestBeatmapDifficultyCache difficultyCache;
|
||||||
|
|
||||||
private IBindable<StarDifficulty?> starDifficultyBindable;
|
private IBindable<StarDifficulty?> starDifficultyBindable;
|
||||||
private Queue<ValueChangedEvent<StarDifficulty?>> starDifficultyChangesQueue;
|
|
||||||
|
|
||||||
[BackgroundDependencyLoader]
|
[BackgroundDependencyLoader]
|
||||||
private void load(OsuGameBase osu)
|
private void load(OsuGameBase osu)
|
||||||
@ -49,14 +47,10 @@ namespace osu.Game.Tests.Beatmaps
|
|||||||
|
|
||||||
Child = difficultyCache = new TestBeatmapDifficultyCache();
|
Child = difficultyCache = new TestBeatmapDifficultyCache();
|
||||||
|
|
||||||
starDifficultyChangesQueue = new Queue<ValueChangedEvent<StarDifficulty?>>();
|
|
||||||
starDifficultyBindable = difficultyCache.GetBindableDifficulty(importedSet.Beatmaps.First());
|
starDifficultyBindable = difficultyCache.GetBindableDifficulty(importedSet.Beatmaps.First());
|
||||||
starDifficultyBindable.BindValueChanged(starDifficultyChangesQueue.Enqueue);
|
|
||||||
});
|
});
|
||||||
|
|
||||||
AddAssert($"star difficulty -> {BASE_STARS}", () =>
|
AddUntilStep($"star difficulty -> {BASE_STARS}", () => starDifficultyBindable.Value?.Stars == BASE_STARS);
|
||||||
starDifficultyChangesQueue.Dequeue().NewValue?.Stars == BASE_STARS &&
|
|
||||||
starDifficultyChangesQueue.Count == 0);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
[Test]
|
[Test]
|
||||||
@ -65,19 +59,13 @@ namespace osu.Game.Tests.Beatmaps
|
|||||||
OsuModDoubleTime dt = null;
|
OsuModDoubleTime dt = null;
|
||||||
|
|
||||||
AddStep("change selected mod to DT", () => SelectedMods.Value = new[] { dt = new OsuModDoubleTime { SpeedChange = { Value = 1.5 } } });
|
AddStep("change selected mod to DT", () => SelectedMods.Value = new[] { dt = new OsuModDoubleTime { SpeedChange = { Value = 1.5 } } });
|
||||||
AddAssert($"star difficulty -> {BASE_STARS + 1.5}", () =>
|
AddUntilStep($"star difficulty -> {BASE_STARS + 1.5}", () => starDifficultyBindable.Value?.Stars == BASE_STARS + 1.5);
|
||||||
starDifficultyChangesQueue.Dequeue().NewValue?.Stars == BASE_STARS + 1.5 &&
|
|
||||||
starDifficultyChangesQueue.Count == 0);
|
|
||||||
|
|
||||||
AddStep("change DT speed to 1.25", () => dt.SpeedChange.Value = 1.25);
|
AddStep("change DT speed to 1.25", () => dt.SpeedChange.Value = 1.25);
|
||||||
AddAssert($"star difficulty -> {BASE_STARS + 1.25}", () =>
|
AddUntilStep($"star difficulty -> {BASE_STARS + 1.25}", () => starDifficultyBindable.Value?.Stars == BASE_STARS + 1.25);
|
||||||
starDifficultyChangesQueue.Dequeue().NewValue?.Stars == BASE_STARS + 1.25 &&
|
|
||||||
starDifficultyChangesQueue.Count == 0);
|
|
||||||
|
|
||||||
AddStep("change selected mod to NC", () => SelectedMods.Value = new[] { new OsuModNightcore { SpeedChange = { Value = 1.75 } } });
|
AddStep("change selected mod to NC", () => SelectedMods.Value = new[] { new OsuModNightcore { SpeedChange = { Value = 1.75 } } });
|
||||||
AddAssert($"star difficulty -> {BASE_STARS + 1.75}", () =>
|
AddUntilStep($"star difficulty -> {BASE_STARS + 1.75}", () => starDifficultyBindable.Value?.Stars == BASE_STARS + 1.75);
|
||||||
starDifficultyChangesQueue.Dequeue().NewValue?.Stars == BASE_STARS + 1.75 &&
|
|
||||||
starDifficultyChangesQueue.Count == 0);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
[Test]
|
[Test]
|
||||||
|
Reference in New Issue
Block a user