mirror of
https://github.com/ppy/osu.git
synced 2024-12-14 14:25:05 +08:00
Add test coverage for new ownerless behaviour
This commit is contained in:
parent
199043f677
commit
6b38bb9d76
@ -167,6 +167,21 @@ namespace osu.Game.Tests.Visual.Components
|
|||||||
AddAssert("game not muted", () => audio.Tracks.AggregateVolume.Value != 0);
|
AddAssert("game not muted", () => audio.Tracks.AggregateVolume.Value != 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
[Test]
|
||||||
|
public void TestOwnerNotRegistered()
|
||||||
|
{
|
||||||
|
PreviewTrack track = null;
|
||||||
|
|
||||||
|
AddStep("get track", () => Add(new TestTrackOwner(track = getTrack(), registerAsOwner: false)));
|
||||||
|
AddUntilStep("wait for loaded", () => track.IsLoaded);
|
||||||
|
|
||||||
|
AddStep("start track", () => track.Start());
|
||||||
|
AddUntilStep("track is running", () => track.IsRunning);
|
||||||
|
|
||||||
|
AddStep("cancel from anyone", () => trackManager.StopAnyPlaying(this));
|
||||||
|
AddAssert("track stopped", () => !track.IsRunning);
|
||||||
|
}
|
||||||
|
|
||||||
private TestPreviewTrack getTrack() => (TestPreviewTrack)trackManager.Get(null);
|
private TestPreviewTrack getTrack() => (TestPreviewTrack)trackManager.Get(null);
|
||||||
|
|
||||||
private TestPreviewTrack getOwnedTrack()
|
private TestPreviewTrack getOwnedTrack()
|
||||||
@ -181,10 +196,12 @@ namespace osu.Game.Tests.Visual.Components
|
|||||||
private class TestTrackOwner : CompositeDrawable, IPreviewTrackOwner
|
private class TestTrackOwner : CompositeDrawable, IPreviewTrackOwner
|
||||||
{
|
{
|
||||||
private readonly PreviewTrack track;
|
private readonly PreviewTrack track;
|
||||||
|
private readonly bool registerAsOwner;
|
||||||
|
|
||||||
public TestTrackOwner(PreviewTrack track)
|
public TestTrackOwner(PreviewTrack track, bool registerAsOwner = true)
|
||||||
{
|
{
|
||||||
this.track = track;
|
this.track = track;
|
||||||
|
this.registerAsOwner = registerAsOwner;
|
||||||
}
|
}
|
||||||
|
|
||||||
[BackgroundDependencyLoader]
|
[BackgroundDependencyLoader]
|
||||||
@ -196,6 +213,7 @@ namespace osu.Game.Tests.Visual.Components
|
|||||||
protected override IReadOnlyDependencyContainer CreateChildDependencies(IReadOnlyDependencyContainer parent)
|
protected override IReadOnlyDependencyContainer CreateChildDependencies(IReadOnlyDependencyContainer parent)
|
||||||
{
|
{
|
||||||
var dependencies = new DependencyContainer(base.CreateChildDependencies(parent));
|
var dependencies = new DependencyContainer(base.CreateChildDependencies(parent));
|
||||||
|
if (registerAsOwner)
|
||||||
dependencies.CacheAs<IPreviewTrackOwner>(this);
|
dependencies.CacheAs<IPreviewTrackOwner>(this);
|
||||||
return dependencies;
|
return dependencies;
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user