1
0
mirror of https://github.com/ppy/osu.git synced 2025-03-22 21:00:33 +08:00

Fix usage of DI before it's ready in combo colour tests

This commit is contained in:
Dean Herbert 2021-05-31 19:57:31 +09:00
parent 46b6f49a92
commit e78391db7a
3 changed files with 20 additions and 16 deletions

View File

@ -34,7 +34,7 @@ namespace osu.Game.Rulesets.Catch.Tests
[TestCase(false, false)]
public override void TestBeatmapComboColours(bool userHasCustomColours, bool useBeatmapSkin)
{
TestBeatmap = new CatchCustomSkinWorkingBeatmap(audio, true);
PrepareBeatmap(() => new CatchCustomSkinWorkingBeatmap(audio, true));
base.TestBeatmapComboColours(userHasCustomColours, useBeatmapSkin);
AddAssert("is beatmap skin colours", () => TestPlayer.UsableComboColours.SequenceEqual(TestBeatmapSkin.Colours));
}
@ -43,7 +43,7 @@ namespace osu.Game.Rulesets.Catch.Tests
[TestCase(false)]
public override void TestBeatmapComboColoursOverride(bool useBeatmapSkin)
{
TestBeatmap = new CatchCustomSkinWorkingBeatmap(audio, true);
PrepareBeatmap(() => new CatchCustomSkinWorkingBeatmap(audio, true));
base.TestBeatmapComboColoursOverride(useBeatmapSkin);
AddAssert("is user custom skin colours", () => TestPlayer.UsableComboColours.SequenceEqual(TestSkin.Colours));
}
@ -52,7 +52,7 @@ namespace osu.Game.Rulesets.Catch.Tests
[TestCase(false)]
public override void TestBeatmapComboColoursOverrideWithDefaultColours(bool useBeatmapSkin)
{
TestBeatmap = new CatchCustomSkinWorkingBeatmap(audio, true);
PrepareBeatmap(() => new CatchCustomSkinWorkingBeatmap(audio, true));
base.TestBeatmapComboColoursOverrideWithDefaultColours(useBeatmapSkin);
AddAssert("is default user skin colours", () => TestPlayer.UsableComboColours.SequenceEqual(SkinConfiguration.DefaultComboColours));
}
@ -63,7 +63,7 @@ namespace osu.Game.Rulesets.Catch.Tests
[TestCase(false, false)]
public override void TestBeatmapNoComboColours(bool useBeatmapSkin, bool useBeatmapColour)
{
TestBeatmap = new CatchCustomSkinWorkingBeatmap(audio, false);
PrepareBeatmap(() => new CatchCustomSkinWorkingBeatmap(audio, false));
base.TestBeatmapNoComboColours(useBeatmapSkin, useBeatmapColour);
AddAssert("is default user skin colours", () => TestPlayer.UsableComboColours.SequenceEqual(SkinConfiguration.DefaultComboColours));
}
@ -74,7 +74,7 @@ namespace osu.Game.Rulesets.Catch.Tests
[TestCase(false, false)]
public override void TestBeatmapNoComboColoursSkinOverride(bool useBeatmapSkin, bool useBeatmapColour)
{
TestBeatmap = new CatchCustomSkinWorkingBeatmap(audio, false);
PrepareBeatmap(() => new CatchCustomSkinWorkingBeatmap(audio, false));
base.TestBeatmapNoComboColoursSkinOverride(useBeatmapSkin, useBeatmapColour);
AddAssert("is custom user skin colours", () => TestPlayer.UsableComboColours.SequenceEqual(TestSkin.Colours));
}
@ -83,7 +83,7 @@ namespace osu.Game.Rulesets.Catch.Tests
[TestCase(false)]
public void TestBeatmapHyperDashColours(bool useBeatmapSkin)
{
TestBeatmap = new CatchCustomSkinWorkingBeatmap(audio, true);
PrepareBeatmap(() => new CatchCustomSkinWorkingBeatmap(audio, true));
ConfigureTest(useBeatmapSkin, true, true);
AddAssert("is custom hyper dash colours", () => ((CatchExposedPlayer)TestPlayer).UsableHyperDashColour == TestBeatmapSkin.HYPER_DASH_COLOUR);
AddAssert("is custom hyper dash after image colours", () => ((CatchExposedPlayer)TestPlayer).UsableHyperDashAfterImageColour == TestBeatmapSkin.HYPER_DASH_AFTER_IMAGE_COLOUR);
@ -94,7 +94,7 @@ namespace osu.Game.Rulesets.Catch.Tests
[TestCase(false)]
public void TestBeatmapHyperDashColoursOverride(bool useBeatmapSkin)
{
TestBeatmap = new CatchCustomSkinWorkingBeatmap(audio, true);
PrepareBeatmap(() => new CatchCustomSkinWorkingBeatmap(audio, true));
ConfigureTest(useBeatmapSkin, false, true);
AddAssert("is custom hyper dash colours", () => ((CatchExposedPlayer)TestPlayer).UsableHyperDashColour == TestSkin.HYPER_DASH_COLOUR);
AddAssert("is custom hyper dash after image colours", () => ((CatchExposedPlayer)TestPlayer).UsableHyperDashAfterImageColour == TestSkin.HYPER_DASH_AFTER_IMAGE_COLOUR);

View File

@ -32,7 +32,7 @@ namespace osu.Game.Rulesets.Osu.Tests
[TestCase(false, false)]
public override void TestBeatmapComboColours(bool userHasCustomColours, bool useBeatmapSkin)
{
TestBeatmap = new OsuCustomSkinWorkingBeatmap(audio, true);
PrepareBeatmap(() => new OsuCustomSkinWorkingBeatmap(audio, true));
base.TestBeatmapComboColours(userHasCustomColours, useBeatmapSkin);
AddAssert("is beatmap skin colours", () => TestPlayer.UsableComboColours.SequenceEqual(TestBeatmapSkin.Colours));
}
@ -41,7 +41,7 @@ namespace osu.Game.Rulesets.Osu.Tests
[TestCase(false)]
public override void TestBeatmapComboColoursOverride(bool useBeatmapSkin)
{
TestBeatmap = new OsuCustomSkinWorkingBeatmap(audio, true);
PrepareBeatmap(() => new OsuCustomSkinWorkingBeatmap(audio, true));
base.TestBeatmapComboColoursOverride(useBeatmapSkin);
AddAssert("is user custom skin colours", () => TestPlayer.UsableComboColours.SequenceEqual(TestSkin.Colours));
}
@ -50,7 +50,7 @@ namespace osu.Game.Rulesets.Osu.Tests
[TestCase(false)]
public override void TestBeatmapComboColoursOverrideWithDefaultColours(bool useBeatmapSkin)
{
TestBeatmap = new OsuCustomSkinWorkingBeatmap(audio, true);
PrepareBeatmap(() => new OsuCustomSkinWorkingBeatmap(audio, true));
base.TestBeatmapComboColoursOverrideWithDefaultColours(useBeatmapSkin);
AddAssert("is default user skin colours", () => TestPlayer.UsableComboColours.SequenceEqual(SkinConfiguration.DefaultComboColours));
}
@ -61,7 +61,7 @@ namespace osu.Game.Rulesets.Osu.Tests
[TestCase(false, false)]
public override void TestBeatmapNoComboColours(bool useBeatmapSkin, bool useBeatmapColour)
{
TestBeatmap = new OsuCustomSkinWorkingBeatmap(audio, false);
PrepareBeatmap(() => new OsuCustomSkinWorkingBeatmap(audio, false));
base.TestBeatmapNoComboColours(useBeatmapSkin, useBeatmapColour);
AddAssert("is default user skin colours", () => TestPlayer.UsableComboColours.SequenceEqual(SkinConfiguration.DefaultComboColours));
}
@ -72,7 +72,7 @@ namespace osu.Game.Rulesets.Osu.Tests
[TestCase(false, false)]
public override void TestBeatmapNoComboColoursSkinOverride(bool useBeatmapSkin, bool useBeatmapColour)
{
TestBeatmap = new OsuCustomSkinWorkingBeatmap(audio, false);
PrepareBeatmap(() => new OsuCustomSkinWorkingBeatmap(audio, false));
base.TestBeatmapNoComboColoursSkinOverride(useBeatmapSkin, useBeatmapColour);
AddAssert("is custom user skin colours", () => TestPlayer.UsableComboColours.SequenceEqual(TestSkin.Colours));
}

View File

@ -21,8 +21,10 @@ namespace osu.Game.Tests.Beatmaps
{
protected readonly Bindable<bool> BeatmapSkins = new Bindable<bool>();
protected readonly Bindable<bool> BeatmapColours = new Bindable<bool>();
protected ExposedPlayer TestPlayer;
protected WorkingBeatmap TestBeatmap;
private WorkingBeatmap testBeatmap;
public virtual void TestBeatmapComboColours(bool userHasCustomColours, bool useBeatmapSkin) => ConfigureTest(useBeatmapSkin, true, userHasCustomColours);
@ -34,10 +36,12 @@ namespace osu.Game.Tests.Beatmaps
public virtual void TestBeatmapNoComboColoursSkinOverride(bool useBeatmapSkin, bool useBeatmapColour) => ConfigureTest(useBeatmapSkin, useBeatmapColour, true);
protected virtual void ConfigureTest(bool useBeatmapSkin, bool useBeatmapColours, bool userHasCustomColours)
protected void PrepareBeatmap(Func<WorkingBeatmap> createBeatmap) => AddStep("prepare beatmap", () => testBeatmap = createBeatmap());
protected void ConfigureTest(bool useBeatmapSkin, bool useBeatmapColours, bool userHasCustomColours)
{
configureSettings(useBeatmapSkin, useBeatmapColours);
AddStep($"load {(((CustomSkinWorkingBeatmap)TestBeatmap).HasColours ? "coloured " : "")} beatmap", () => TestPlayer = LoadBeatmap(userHasCustomColours));
AddStep("load beatmap", () => TestPlayer = LoadBeatmap(userHasCustomColours));
AddUntilStep("wait for player load", () => TestPlayer.IsLoaded);
}
@ -57,7 +61,7 @@ namespace osu.Game.Tests.Beatmaps
{
ExposedPlayer player;
Beatmap.Value = TestBeatmap;
Beatmap.Value = testBeatmap;
LoadScreen(player = CreateTestPlayer(userHasCustomColours));