mirror of
https://github.com/ppy/osu.git
synced 2025-01-12 17:43:05 +08:00
Add test coverage of SkinnableSound
not updating in time when not present
This commit is contained in:
parent
297e7d6542
commit
159c8833c7
@ -23,6 +23,8 @@ namespace osu.Game.Tests.Visual.Gameplay
|
|||||||
private TestSkinSourceContainer skinSource = null!;
|
private TestSkinSourceContainer skinSource = null!;
|
||||||
private PausableSkinnableSound skinnableSound = null!;
|
private PausableSkinnableSound skinnableSound = null!;
|
||||||
|
|
||||||
|
private const string sample_lookup = "Gameplay/normal-sliderslide";
|
||||||
|
|
||||||
[SetUpSteps]
|
[SetUpSteps]
|
||||||
public void SetUpSteps()
|
public void SetUpSteps()
|
||||||
{
|
{
|
||||||
@ -34,7 +36,7 @@ namespace osu.Game.Tests.Visual.Gameplay
|
|||||||
};
|
};
|
||||||
|
|
||||||
// has to be added after the hierarchy above else the `ISkinSource` dependency won't be cached.
|
// has to be added after the hierarchy above else the `ISkinSource` dependency won't be cached.
|
||||||
skinSource.Add(skinnableSound = new PausableSkinnableSound(new SampleInfo("Gameplay/normal-sliderslide")));
|
skinSource.Add(skinnableSound = new PausableSkinnableSound(new SampleInfo(sample_lookup)));
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -97,6 +99,27 @@ namespace osu.Game.Tests.Visual.Gameplay
|
|||||||
AddAssert("sample not playing", () => !skinnableSound.IsPlaying);
|
AddAssert("sample not playing", () => !skinnableSound.IsPlaying);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
[Test]
|
||||||
|
public void TestSampleUpdatedBeforePlaybackWhenNotPresent()
|
||||||
|
{
|
||||||
|
AddStep("make sample non-present", () => skinnableSound.Hide());
|
||||||
|
AddUntilStep("ensure not present", () => skinnableSound.IsPresent, () => Is.False);
|
||||||
|
|
||||||
|
AddUntilStep("ensure sample loaded", () => skinnableSound.ChildrenOfType<DrawableSample>().Single().Name, () => Is.EqualTo(sample_lookup));
|
||||||
|
|
||||||
|
AddStep("Change source", () =>
|
||||||
|
{
|
||||||
|
skinSource.OverridingSample = new SampleVirtual("new skin");
|
||||||
|
skinSource.TriggerSourceChanged();
|
||||||
|
});
|
||||||
|
|
||||||
|
// Samples are nulled on source change immediately
|
||||||
|
AddUntilStep("wait for sample null", () => skinnableSound.ChildrenOfType<DrawableSample>().Count(), () => Is.Zero);
|
||||||
|
|
||||||
|
AddStep("start sample", () => skinnableSound.Play());
|
||||||
|
AddUntilStep("sample updated", () => skinnableSound.ChildrenOfType<DrawableSample>().Single().Name, () => Is.EqualTo("new skin"));
|
||||||
|
}
|
||||||
|
|
||||||
[Test]
|
[Test]
|
||||||
public void TestSkinChangeDoesntPlayOnPause()
|
public void TestSkinChangeDoesntPlayOnPause()
|
||||||
{
|
{
|
||||||
@ -138,11 +161,13 @@ namespace osu.Game.Tests.Visual.Gameplay
|
|||||||
|
|
||||||
public Bindable<bool> SamplePlaybackDisabled { get; } = new Bindable<bool>();
|
public Bindable<bool> SamplePlaybackDisabled { get; } = new Bindable<bool>();
|
||||||
|
|
||||||
|
public ISample? OverridingSample;
|
||||||
|
|
||||||
IBindable<bool> ISamplePlaybackDisabler.SamplePlaybackDisabled => SamplePlaybackDisabled;
|
IBindable<bool> ISamplePlaybackDisabler.SamplePlaybackDisabled => SamplePlaybackDisabled;
|
||||||
|
|
||||||
public Drawable? GetDrawableComponent(ISkinComponentLookup lookup) => source.GetDrawableComponent(lookup);
|
public Drawable? GetDrawableComponent(ISkinComponentLookup lookup) => source.GetDrawableComponent(lookup);
|
||||||
public Texture? GetTexture(string componentName, WrapMode wrapModeS, WrapMode wrapModeT) => source.GetTexture(componentName, wrapModeS, wrapModeT);
|
public Texture? GetTexture(string componentName, WrapMode wrapModeS, WrapMode wrapModeT) => source.GetTexture(componentName, wrapModeS, wrapModeT);
|
||||||
public ISample? GetSample(ISampleInfo sampleInfo) => source.GetSample(sampleInfo);
|
public ISample? GetSample(ISampleInfo sampleInfo) => OverridingSample ?? source.GetSample(sampleInfo);
|
||||||
|
|
||||||
public IBindable<TValue>? GetConfig<TLookup, TValue>(TLookup lookup)
|
public IBindable<TValue>? GetConfig<TLookup, TValue>(TLookup lookup)
|
||||||
where TLookup : notnull
|
where TLookup : notnull
|
||||||
|
Loading…
Reference in New Issue
Block a user