1
0
mirror of https://github.com/ppy/osu.git synced 2024-12-14 18:33:20 +08:00

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

View File

@ -103,14 +103,11 @@ namespace osu.Game.Tests.Visual.UserInterface
var easierMods = osu.GetModsFor(ModType.DifficultyReduction);
var harderMods = osu.GetModsFor(ModType.DifficultyIncrease);
var conversionMods = osu.GetModsFor(ModType.Conversion);
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 targetMod = conversionMods.FirstOrDefault(m => m is OsuModTarget);
var easy = easierMods.FirstOrDefault(m => m is OsuModEasy);
var hardRock = harderMods.FirstOrDefault(m => m is OsuModHardRock);
@ -118,8 +115,6 @@ namespace osu.Game.Tests.Visual.UserInterface
testMultiMod(doubleTimeMod);
testIncompatibleMods(easy, hardRock);
testDeselectAll(easierMods.Where(m => !(m is MultiMod)));
testUnimplementedMod(targetMod);
}
[Test]
@ -249,6 +244,19 @@ namespace osu.Game.Tests.Visual.UserInterface
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)
{
selectNext(mod);
@ -343,6 +351,12 @@ namespace osu.Game.Tests.Visual.UserInterface
waitForLoad();
}
private void changeTestRuleset(RulesetInfo rulesetInfo)
{
AddStep($"change ruleset to {rulesetInfo.Name}", () => { Ruleset.Value = rulesetInfo; });
waitForLoad();
}
private void waitForLoad() =>
AddUntilStep("wait for icons to load", () => modSelect.AllLoaded);
@ -401,5 +415,24 @@ namespace osu.Game.Tests.Visual.UserInterface
{
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);
}
}
}
}