Merge pull request #13778 from Henry-YSLin/fix-unimplemented-mod-test

Use a mock ruleset and mod to test unimplemented mods in mod select overlay
This commit is contained in:
Dean Herbert 2021-07-05 13:54:14 +09:00 committed by GitHub
commit b7180f16c5
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 38 additions and 5 deletions

View File

@ -103,14 +103,11 @@ public void TestOsuMods()
var easierMods = osu.GetModsFor(ModType.DifficultyReduction); var easierMods = osu.GetModsFor(ModType.DifficultyReduction);
var harderMods = osu.GetModsFor(ModType.DifficultyIncrease); var harderMods = osu.GetModsFor(ModType.DifficultyIncrease);
var conversionMods = osu.GetModsFor(ModType.Conversion);
var noFailMod = osu.GetModsFor(ModType.DifficultyReduction).FirstOrDefault(m => m is OsuModNoFail); var noFailMod = osu.GetModsFor(ModType.DifficultyReduction).FirstOrDefault(m => m is OsuModNoFail);
var doubleTimeMod = harderMods.OfType<MultiMod>().FirstOrDefault(m => m.Mods.Any(a => a is OsuModDoubleTime)); var doubleTimeMod = harderMods.OfType<MultiMod>().FirstOrDefault(m => m.Mods.Any(a => a is OsuModDoubleTime));
var targetMod = conversionMods.FirstOrDefault(m => m is OsuModTarget);
var easy = easierMods.FirstOrDefault(m => m is OsuModEasy); var easy = easierMods.FirstOrDefault(m => m is OsuModEasy);
var hardRock = harderMods.FirstOrDefault(m => m is OsuModHardRock); var hardRock = harderMods.FirstOrDefault(m => m is OsuModHardRock);
@ -118,8 +115,6 @@ public void TestOsuMods()
testMultiMod(doubleTimeMod); testMultiMod(doubleTimeMod);
testIncompatibleMods(easy, hardRock); testIncompatibleMods(easy, hardRock);
testDeselectAll(easierMods.Where(m => !(m is MultiMod))); testDeselectAll(easierMods.Where(m => !(m is MultiMod)));
testUnimplementedMod(targetMod);
} }
[Test] [Test]
@ -249,6 +244,19 @@ public void TestChangeIsValidPreservesSelection()
AddAssert("DT + HD still selected", () => modSelect.ChildrenOfType<ModButton>().Count(b => b.Selected) == 2); AddAssert("DT + HD still selected", () => modSelect.ChildrenOfType<ModButton>().Count(b => b.Selected) == 2);
} }
[Test]
public void TestUnimplementedModIsUnselectable()
{
var testRuleset = new TestUnimplementedModOsuRuleset();
changeTestRuleset(testRuleset.RulesetInfo);
var conversionMods = testRuleset.GetModsFor(ModType.Conversion);
var unimplementedMod = conversionMods.FirstOrDefault(m => m is TestUnimplementedMod);
testUnimplementedMod(unimplementedMod);
}
private void testSingleMod(Mod mod) private void testSingleMod(Mod mod)
{ {
selectNext(mod); selectNext(mod);
@ -343,6 +351,12 @@ private void changeRuleset(int? id)
waitForLoad(); waitForLoad();
} }
private void changeTestRuleset(RulesetInfo rulesetInfo)
{
AddStep($"change ruleset to {rulesetInfo.Name}", () => { Ruleset.Value = rulesetInfo; });
waitForLoad();
}
private void waitForLoad() => private void waitForLoad() =>
AddUntilStep("wait for icons to load", () => modSelect.AllLoaded); AddUntilStep("wait for icons to load", () => modSelect.AllLoaded);
@ -401,5 +415,24 @@ private class TestNonStackedModSelectOverlay : TestModSelectOverlay
{ {
protected override bool Stacked => false; protected override bool Stacked => false;
} }
private class TestUnimplementedMod : Mod
{
public override string Name => "Unimplemented mod";
public override string Acronym => "UM";
public override string Description => "A mod that is not implemented.";
public override double ScoreMultiplier => 1;
public override ModType Type => ModType.Conversion;
}
private class TestUnimplementedModOsuRuleset : OsuRuleset
{
public override IEnumerable<Mod> GetModsFor(ModType type)
{
if (type == ModType.Conversion) return base.GetModsFor(type).Concat(new[] { new TestUnimplementedMod() });
return base.GetModsFor(type);
}
}
} }
} }