mirror of
https://github.com/ppy/osu.git
synced 2025-02-13 20:33:11 +08:00
Fix audio disposal issues and share more code between visualtests.
This commit is contained in:
parent
8040d6a03f
commit
4bd85fe5cb
@ -20,7 +20,9 @@ namespace osu.Desktop.VisualTests.Tests
|
||||
{
|
||||
class TestCasePlayer : TestCase
|
||||
{
|
||||
private WorkingBeatmap beatmap;
|
||||
protected Player Player;
|
||||
private BeatmapDatabase db;
|
||||
|
||||
public override string Name => @"Player";
|
||||
|
||||
public override string Description => @"Showing everything to play the game.";
|
||||
@ -28,15 +30,19 @@ namespace osu.Desktop.VisualTests.Tests
|
||||
[BackgroundDependencyLoader]
|
||||
private void load(BeatmapDatabase db)
|
||||
{
|
||||
var beatmapInfo = db.Query<BeatmapInfo>().Where(b => b.Mode == PlayMode.Osu).FirstOrDefault();
|
||||
if (beatmapInfo != null)
|
||||
beatmap = db.GetWorkingBeatmap(beatmapInfo);
|
||||
this.db = db;
|
||||
}
|
||||
|
||||
public override void Reset()
|
||||
{
|
||||
base.Reset();
|
||||
|
||||
WorkingBeatmap beatmap = null;
|
||||
|
||||
var beatmapInfo = db.Query<BeatmapInfo>().Where(b => b.Mode == PlayMode.Osu).FirstOrDefault();
|
||||
if (beatmapInfo != null)
|
||||
beatmap = db.GetWorkingBeatmap(beatmapInfo);
|
||||
|
||||
if (beatmap?.Track == null)
|
||||
{
|
||||
var objects = new List<HitObject>();
|
||||
@ -82,16 +88,21 @@ namespace osu.Desktop.VisualTests.Tests
|
||||
Colour = Color4.Black,
|
||||
});
|
||||
|
||||
Add(new PlayerLoader(new Player
|
||||
{
|
||||
PreferredPlayMode = PlayMode.Osu,
|
||||
Beatmap = beatmap
|
||||
})
|
||||
Add(new PlayerLoader(Player = CreatePlayer(beatmap))
|
||||
{
|
||||
Beatmap = beatmap
|
||||
});
|
||||
}
|
||||
|
||||
protected virtual Player CreatePlayer(WorkingBeatmap beatmap)
|
||||
{
|
||||
return new Player
|
||||
{
|
||||
PreferredPlayMode = PlayMode.Osu,
|
||||
Beatmap = beatmap
|
||||
};
|
||||
}
|
||||
|
||||
class TestWorkingBeatmap : WorkingBeatmap
|
||||
{
|
||||
public TestWorkingBeatmap(Beatmap beatmap)
|
||||
|
@ -24,32 +24,20 @@ using SharpCompress.Readers;
|
||||
|
||||
namespace osu.Desktop.VisualTests.Tests
|
||||
{
|
||||
class TestCaseReplay : TestCase
|
||||
class TestCaseReplay : TestCasePlayer
|
||||
{
|
||||
private WorkingBeatmap beatmap;
|
||||
|
||||
private LegacyReplayInputHandler replay;
|
||||
|
||||
public override string Name => @"Replay";
|
||||
|
||||
public override string Description => @"Testing replay playback.";
|
||||
|
||||
[BackgroundDependencyLoader]
|
||||
private void load(BeatmapDatabase db)
|
||||
{
|
||||
var beatmapInfo = db.Query<BeatmapInfo>().Where(b => b.Mode == PlayMode.Osu).FirstOrDefault();
|
||||
if (beatmapInfo != null)
|
||||
beatmap = db.GetWorkingBeatmap(beatmapInfo);
|
||||
}
|
||||
|
||||
public override void Reset()
|
||||
{
|
||||
base.Reset();
|
||||
|
||||
Add(new Box
|
||||
{
|
||||
RelativeSizeAxes = Framework.Graphics.Axes.Both,
|
||||
Colour = Color4.Black,
|
||||
});
|
||||
|
||||
|
||||
var list = new List<LegacyReplayInputHandler.LegacyReplayFrame>();
|
||||
|
||||
float lastTime = 0;
|
||||
@ -70,7 +58,7 @@ namespace osu.Desktop.VisualTests.Tests
|
||||
}
|
||||
|
||||
|
||||
var replay = new LegacyReplayInputHandler(list);
|
||||
replay = new LegacyReplayInputHandler(list);
|
||||
|
||||
//var data = File.ReadAllBytes(@"C:\Users\Dean\.osu\Replays\Tao - O2i3 - Ooi [Game Edit] [Advanced] (2016-08-08) Osu.osr");
|
||||
//using (MemoryStream dataStream = new MemoryStream(data))
|
||||
@ -80,28 +68,13 @@ namespace osu.Desktop.VisualTests.Tests
|
||||
|
||||
// Console.WriteLine(obj);
|
||||
//}
|
||||
|
||||
|
||||
Add(new PlayerLoader(new Player
|
||||
{
|
||||
PreferredPlayMode = PlayMode.Osu,
|
||||
ReplayInputHandler = replay,
|
||||
Beatmap = beatmap
|
||||
})
|
||||
{
|
||||
Beatmap = beatmap
|
||||
});
|
||||
}
|
||||
|
||||
class TestWorkingBeatmap : WorkingBeatmap
|
||||
protected override Player CreatePlayer(WorkingBeatmap beatmap)
|
||||
{
|
||||
public TestWorkingBeatmap(Beatmap beatmap)
|
||||
: base(beatmap.BeatmapInfo, beatmap.BeatmapInfo.BeatmapSet)
|
||||
{
|
||||
Beatmap = beatmap;
|
||||
}
|
||||
|
||||
protected override ArchiveReader GetReader() => null;
|
||||
var player = base.CreatePlayer(beatmap);
|
||||
player.ReplayInputHandler = replay;
|
||||
return player;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user