mirror of
https://github.com/ppy/osu.git
synced 2025-01-12 16:02:55 +08:00
Add failing test cases
This commit is contained in:
parent
c5049b51c5
commit
c7d2ce12eb
@ -0,0 +1,10 @@
|
||||
osu file format v14
|
||||
|
||||
[General]
|
||||
Mode: 3
|
||||
|
||||
[TimingPoints]
|
||||
0,300,4,0,2,100,1,0
|
||||
|
||||
[HitObjects]
|
||||
444,320,1000,5,2,0:0:0:0:
|
@ -0,0 +1,10 @@
|
||||
osu file format v14
|
||||
|
||||
[General]
|
||||
Mode: 3
|
||||
|
||||
[TimingPoints]
|
||||
0,300,4,0,2,100,1,0
|
||||
|
||||
[HitObjects]
|
||||
444,320,1000,5,1,0:0:0:0:
|
@ -0,0 +1,49 @@
|
||||
// Copyright (c) ppy Pty Ltd <contact@ppy.sh>. Licensed under the MIT Licence.
|
||||
// See the LICENCE file in the repository root for full licence text.
|
||||
|
||||
using System.Reflection;
|
||||
using NUnit.Framework;
|
||||
using osu.Framework.IO.Stores;
|
||||
using osu.Game.Tests.Beatmaps;
|
||||
|
||||
namespace osu.Game.Rulesets.Mania.Tests
|
||||
{
|
||||
public class TestSceneManiaHitObjectSamples : HitObjectSampleTest
|
||||
{
|
||||
protected override Ruleset CreatePlayerRuleset() => new ManiaRuleset();
|
||||
protected override IResourceStore<byte[]> Resources => new DllResourceStore(Assembly.GetAssembly(typeof(TestSceneManiaHitObjectSamples)));
|
||||
|
||||
/// <summary>
|
||||
/// Tests that when a normal sample bank is used, the normal hitsound will be looked up.
|
||||
/// </summary>
|
||||
[Test]
|
||||
public void TestManiaHitObjectNormalSampleBank()
|
||||
{
|
||||
const string expected_sample = "normal-hitnormal2";
|
||||
|
||||
SetupSkins(expected_sample, expected_sample);
|
||||
|
||||
CreateTestWithBeatmap("mania-hitobject-beatmap-normal-sample-bank.osu");
|
||||
|
||||
AssertBeatmapLookup(expected_sample);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Tests that when a custom sample bank is used, layered hitsounds are not played
|
||||
/// (only the sample from the custom bank is looked up).
|
||||
/// </summary>
|
||||
[Test]
|
||||
public void TestManiaHitObjectCustomSampleBank()
|
||||
{
|
||||
const string expected_sample = "normal-hitwhistle2";
|
||||
const string unwanted_sample = "normal-hitnormal2";
|
||||
|
||||
SetupSkins(expected_sample, unwanted_sample);
|
||||
|
||||
CreateTestWithBeatmap("mania-hitobject-beatmap-custom-sample-bank.osu");
|
||||
|
||||
AssertBeatmapLookup(expected_sample);
|
||||
AssertNoLookup(unwanted_sample);
|
||||
}
|
||||
}
|
||||
}
|
@ -6,6 +6,7 @@ using osu.Framework.IO.Stores;
|
||||
using osu.Framework.Testing;
|
||||
using osu.Game.Rulesets;
|
||||
using osu.Game.Rulesets.Osu;
|
||||
using osu.Game.Skinning;
|
||||
using osu.Game.Tests.Beatmaps;
|
||||
using osu.Game.Tests.Resources;
|
||||
|
||||
@ -167,5 +168,64 @@ namespace osu.Game.Tests.Gameplay
|
||||
|
||||
AssertBeatmapLookup(expected_sample);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Tests that when a custom sample bank is used, both the normal and additional sounds will be looked up.
|
||||
/// </summary>
|
||||
[Test]
|
||||
public void TestHitObjectCustomSampleBank()
|
||||
{
|
||||
string[] expectedSamples =
|
||||
{
|
||||
"normal-hitnormal2",
|
||||
"normal-hitwhistle2"
|
||||
};
|
||||
|
||||
SetupSkins(expectedSamples[0], expectedSamples[1]);
|
||||
|
||||
CreateTestWithBeatmap("hitobject-beatmap-custom-sample-bank.osu");
|
||||
|
||||
AssertBeatmapLookup(expectedSamples[0]);
|
||||
AssertUserLookup(expectedSamples[1]);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Tests that when a custom sample bank is used, but <see cref="GlobalSkinConfiguration.LayeredHitSounds"/> is disabled,
|
||||
/// only the additional sound will be looked up.
|
||||
/// </summary>
|
||||
[Test]
|
||||
public void TestHitObjectCustomSampleBankWithoutLayered()
|
||||
{
|
||||
const string expected_sample = "normal-hitwhistle2";
|
||||
const string unwanted_sample = "normal-hitnormal2";
|
||||
|
||||
SetupSkins(expected_sample, unwanted_sample);
|
||||
disableLayeredHitSounds();
|
||||
|
||||
CreateTestWithBeatmap("hitobject-beatmap-custom-sample-bank.osu");
|
||||
|
||||
AssertBeatmapLookup(expected_sample);
|
||||
AssertNoLookup(unwanted_sample);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Tests that when a normal sample bank is used and <see cref="GlobalSkinConfiguration.LayeredHitSounds"/> is disabled,
|
||||
/// the normal sound will be looked up anyway.
|
||||
/// </summary>
|
||||
[Test]
|
||||
public void TestHitObjectNormalSampleBankWithoutLayered()
|
||||
{
|
||||
const string expected_sample = "normal-hitnormal";
|
||||
|
||||
SetupSkins(expected_sample, expected_sample);
|
||||
disableLayeredHitSounds();
|
||||
|
||||
CreateTestWithBeatmap("hitobject-beatmap-sample.osu");
|
||||
|
||||
AssertBeatmapLookup(expected_sample);
|
||||
}
|
||||
|
||||
private void disableLayeredHitSounds()
|
||||
=> AddStep("set LayeredHitSounds to false", () => Skin.Configuration.ConfigDictionary[GlobalSkinConfiguration.LayeredHitSounds.ToString()] = "0");
|
||||
}
|
||||
}
|
||||
|
@ -0,0 +1,7 @@
|
||||
osu file format v14
|
||||
|
||||
[TimingPoints]
|
||||
0,300,4,0,2,100,1,0
|
||||
|
||||
[HitObjects]
|
||||
444,320,1000,5,2,0:0:0:0:
|
@ -24,6 +24,10 @@ namespace osu.Game.Tests.Beatmaps
|
||||
public abstract class HitObjectSampleTest : PlayerTestScene
|
||||
{
|
||||
protected abstract IResourceStore<byte[]> Resources { get; }
|
||||
protected LegacySkin Skin { get; private set; }
|
||||
|
||||
[Resolved]
|
||||
private RulesetStore rulesetStore { get; set; }
|
||||
|
||||
private readonly SkinInfo userSkinInfo = new SkinInfo();
|
||||
|
||||
@ -64,6 +68,9 @@ namespace osu.Game.Tests.Beatmaps
|
||||
{
|
||||
using (var reader = new LineBufferedReader(Resources.GetStream($"Resources/SampleLookups/{filename}")))
|
||||
currentTestBeatmap = Decoder.GetDecoder<Beatmap>(reader).Decode(reader);
|
||||
|
||||
// populate ruleset for beatmap converters that require it to be present.
|
||||
currentTestBeatmap.BeatmapInfo.Ruleset = rulesetStore.GetRuleset(currentTestBeatmap.BeatmapInfo.RulesetID);
|
||||
});
|
||||
});
|
||||
}
|
||||
@ -91,7 +98,7 @@ namespace osu.Game.Tests.Beatmaps
|
||||
};
|
||||
|
||||
// Need to refresh the cached skin source to refresh the skin resource store.
|
||||
dependencies.SkinSource = new SkinProvidingContainer(new LegacySkin(userSkinInfo, userSkinResourceStore, Audio));
|
||||
dependencies.SkinSource = new SkinProvidingContainer(Skin = new LegacySkin(userSkinInfo, userSkinResourceStore, Audio));
|
||||
});
|
||||
}
|
||||
|
||||
@ -101,6 +108,9 @@ namespace osu.Game.Tests.Beatmaps
|
||||
protected void AssertUserLookup(string name) => AddAssert($"\"{name}\" looked up from user skin",
|
||||
() => !beatmapSkinResourceStore.PerformedLookups.Contains(name) && userSkinResourceStore.PerformedLookups.Contains(name));
|
||||
|
||||
protected void AssertNoLookup(string name) => AddAssert($"\"{name}\" not looked up",
|
||||
() => !beatmapSkinResourceStore.PerformedLookups.Contains(name) && !userSkinResourceStore.PerformedLookups.Contains(name));
|
||||
|
||||
private class SkinSourceDependencyContainer : IReadOnlyDependencyContainer
|
||||
{
|
||||
public ISkinSource SkinSource;
|
||||
|
Loading…
Reference in New Issue
Block a user