mirror of
https://github.com/ppy/osu.git
synced 2024-11-11 11:28:00 +08:00
Consider shader manager for ruleset dependencies disposal testing
This commit is contained in:
parent
67f0344c0c
commit
eabcbd1d42
@ -13,6 +13,7 @@ using osu.Framework.Bindables;
|
||||
using osu.Framework.Graphics;
|
||||
using osu.Framework.Graphics.Containers;
|
||||
using osu.Framework.Graphics.OpenGL.Textures;
|
||||
using osu.Framework.Graphics.Shaders;
|
||||
using osu.Framework.Graphics.Shapes;
|
||||
using osu.Framework.Graphics.Textures;
|
||||
using osu.Framework.Testing;
|
||||
@ -31,12 +32,14 @@ namespace osu.Game.Tests.Rulesets
|
||||
DrawableWithDependencies drawable = null;
|
||||
TestTextureStore textureStore = null;
|
||||
TestSampleStore sampleStore = null;
|
||||
TestShaderManager shaderManager = null;
|
||||
|
||||
AddStep("add dependencies", () =>
|
||||
{
|
||||
Child = drawable = new DrawableWithDependencies();
|
||||
textureStore = drawable.ParentTextureStore;
|
||||
sampleStore = drawable.ParentSampleStore;
|
||||
shaderManager = drawable.ParentShaderManager;
|
||||
});
|
||||
|
||||
AddStep("clear children", Clear);
|
||||
@ -52,12 +55,14 @@ namespace osu.Game.Tests.Rulesets
|
||||
|
||||
AddAssert("parent texture store not disposed", () => !textureStore.IsDisposed);
|
||||
AddAssert("parent sample store not disposed", () => !sampleStore.IsDisposed);
|
||||
AddAssert("parent shader manager not disposed", () => !shaderManager.IsDisposed);
|
||||
}
|
||||
|
||||
private class DrawableWithDependencies : CompositeDrawable
|
||||
{
|
||||
public TestTextureStore ParentTextureStore { get; private set; }
|
||||
public TestSampleStore ParentSampleStore { get; private set; }
|
||||
public TestShaderManager ParentShaderManager { get; private set; }
|
||||
|
||||
public DrawableWithDependencies()
|
||||
{
|
||||
@ -70,6 +75,7 @@ namespace osu.Game.Tests.Rulesets
|
||||
|
||||
dependencies.CacheAs<TextureStore>(ParentTextureStore = new TestTextureStore());
|
||||
dependencies.CacheAs<ISampleStore>(ParentSampleStore = new TestSampleStore());
|
||||
dependencies.CacheAs<ShaderManager>(ParentShaderManager = new TestShaderManager());
|
||||
|
||||
return new DrawableRulesetDependencies(new OsuRuleset(), dependencies);
|
||||
}
|
||||
@ -135,5 +141,18 @@ namespace osu.Game.Tests.Rulesets
|
||||
|
||||
public int PlaybackConcurrency { get; set; }
|
||||
}
|
||||
|
||||
private class TestShaderManager : ShaderManager
|
||||
{
|
||||
public override byte[] LoadRaw(string name) => null;
|
||||
|
||||
public bool IsDisposed { get; private set; }
|
||||
|
||||
protected override void Dispose(bool disposing)
|
||||
{
|
||||
base.Dispose(disposing);
|
||||
IsDisposed = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user