mirror of
https://github.com/ppy/osu.git
synced 2024-12-14 09:32:55 +08:00
Add test for non-present preview tracks
To avoid reverting what #6738 solved
This commit is contained in:
parent
9d61d73ced
commit
9a00898c0d
@ -7,6 +7,7 @@ using osu.Framework.Audio.Track;
|
||||
using osu.Framework.Graphics.Containers;
|
||||
using osu.Game.Audio;
|
||||
using osu.Game.Beatmaps;
|
||||
using static osu.Game.Tests.Visual.Components.TestScenePreviewTrackManager.TestPreviewTrackManager;
|
||||
|
||||
namespace osu.Game.Tests.Visual.Components
|
||||
{
|
||||
@ -91,9 +92,25 @@ namespace osu.Game.Tests.Visual.Components
|
||||
AddAssert("stopped", () => !track.IsRunning);
|
||||
}
|
||||
|
||||
private PreviewTrack getTrack() => trackManager.Get(null);
|
||||
[Test]
|
||||
public void TestNonPresentTrack()
|
||||
{
|
||||
TestPreviewTrack track = null;
|
||||
|
||||
private PreviewTrack getOwnedTrack()
|
||||
AddStep("get non-present track", () =>
|
||||
{
|
||||
Add(new TestTrackOwner(track = getTrack()));
|
||||
track.Alpha = 0;
|
||||
});
|
||||
AddUntilStep("wait loaded", () => track.IsLoaded);
|
||||
AddStep("start", () => track.Start());
|
||||
AddStep("seek to end", () => track.Track.Seek(track.Track.Length));
|
||||
AddAssert("track stopped", () => !track.IsRunning);
|
||||
}
|
||||
|
||||
private TestPreviewTrack getTrack() => (TestPreviewTrack)trackManager.Get(null);
|
||||
|
||||
private TestPreviewTrack getOwnedTrack()
|
||||
{
|
||||
var track = getTrack();
|
||||
|
||||
@ -125,14 +142,16 @@ namespace osu.Game.Tests.Visual.Components
|
||||
}
|
||||
}
|
||||
|
||||
private class TestPreviewTrackManager : PreviewTrackManager
|
||||
public class TestPreviewTrackManager : PreviewTrackManager
|
||||
{
|
||||
protected override TrackManagerPreviewTrack CreatePreviewTrack(BeatmapSetInfo beatmapSetInfo, ITrackStore trackStore) => new TestPreviewTrack(beatmapSetInfo, trackStore);
|
||||
|
||||
protected class TestPreviewTrack : TrackManagerPreviewTrack
|
||||
public class TestPreviewTrack : TrackManagerPreviewTrack
|
||||
{
|
||||
private readonly ITrackStore trackManager;
|
||||
|
||||
public new Track Track => base.Track;
|
||||
|
||||
public TestPreviewTrack(BeatmapSetInfo beatmapSetInfo, ITrackStore trackManager)
|
||||
: base(beatmapSetInfo, trackManager)
|
||||
{
|
||||
|
Loading…
Reference in New Issue
Block a user