private void tryStartPreview() { if (previewTrack?.Start() == false) { Playing.Value = false; } }
public void TestCancelFromOwner() { PreviewTrack track = null; AddStep("get track", () => track = getOwnedTrack()); AddStep("start", () => track.Start()); AddStep("stop by owner", () => trackManager.StopAnyPlaying(this)); AddAssert("stopped", () => !track.IsRunning); }
public void TestStartStop() { PreviewTrack track = null; AddStep("get track", () => track = getOwnedTrack()); AddStep("start", () => track.Start()); AddAssert("started", () => track.IsRunning); AddStep("stop", () => track.Stop()); AddAssert("stopped", () => !track.IsRunning); }
public void TestCancelFromNonOwner() { TestTrackOwner owner = null; PreviewTrack track = null; AddStep("get track", () => Add(owner = new TestTrackOwner(track = getTrack()))); AddStep("start", () => track.Start()); AddStep("attempt stop", () => trackManager.StopAnyPlaying(this)); AddAssert("not stopped", () => track.IsRunning); AddStep("stop by true owner", () => trackManager.StopAnyPlaying(owner)); AddAssert("stopped", () => !track.IsRunning); }
public void TestStartMultipleTracks() { PreviewTrack track1 = null; PreviewTrack track2 = null; AddStep("get tracks", () => { track1 = getOwnedTrack(); track2 = getOwnedTrack(); }); AddUntilStep("wait loaded", () => track1.IsLoaded && track2.IsLoaded); AddStep("start track 1", () => track1.Start()); AddStep("start track 2", () => track2.Start()); AddAssert("track 1 stopped", () => !track1.IsRunning); AddAssert("track 2 started", () => track2.IsRunning); AddStep("start track 1", () => track1.Start()); AddAssert("track 2 stopped", () => !track2.IsRunning); AddAssert("track 1 started", () => track1.IsRunning); }
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); }
public void TestCurrentTrackChanges() { PreviewTrack track = null; TestTrackOwner owner = null; AddStep("get track", () => Add(owner = new TestTrackOwner(track = getTrack()))); AddUntilStep("wait loaded", () => track.IsLoaded); AddStep("start track", () => track.Start()); AddAssert("current is track", () => trackManager.CurrentTrack == track); AddStep("pause manager updates", () => trackManager.AllowUpdate = false); AddStep("stop any playing", () => trackManager.StopAnyPlaying(owner)); AddAssert("current not changed", () => trackManager.CurrentTrack == track); AddStep("resume manager updates", () => trackManager.AllowUpdate = true); AddAssert("current is null", () => trackManager.CurrentTrack == null); }
public void TestEnsureMutingCorrectly(bool stopAnyPlaying) { PreviewTrack track = null; TestTrackOwner owner = null; AddStep("ensure volume not zero", () => { if (audio.Volume.Value == 0) { audio.Volume.Value = 1; } if (audio.VolumeTrack.Value == 0) { audio.VolumeTrack.Value = 1; } }); AddAssert("game not muted", () => audio.Tracks.AggregateVolume.Value != 0); AddStep("get track", () => Add(owner = new TestTrackOwner(track = getTrack()))); AddUntilStep("wait loaded", () => track.IsLoaded); AddStep("start track", () => track.Start()); AddAssert("game is muted", () => audio.Tracks.AggregateVolume.Value == 0); if (stopAnyPlaying) { AddStep("stop any playing", () => trackManager.StopAnyPlaying(owner)); } else { AddStep("stop track", () => track.Stop()); } AddAssert("game not muted", () => audio.Tracks.AggregateVolume.Value != 0); }