mirror of
https://github.com/osukey/osukey.git
synced 2025-05-30 01:47:30 +09: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
|
class TestCasePlayer : TestCase
|
||||||
{
|
{
|
||||||
private WorkingBeatmap beatmap;
|
protected Player Player;
|
||||||
|
private BeatmapDatabase db;
|
||||||
|
|
||||||
public override string Name => @"Player";
|
public override string Name => @"Player";
|
||||||
|
|
||||||
public override string Description => @"Showing everything to play the game.";
|
public override string Description => @"Showing everything to play the game.";
|
||||||
@ -28,15 +30,19 @@ namespace osu.Desktop.VisualTests.Tests
|
|||||||
[BackgroundDependencyLoader]
|
[BackgroundDependencyLoader]
|
||||||
private void load(BeatmapDatabase db)
|
private void load(BeatmapDatabase db)
|
||||||
{
|
{
|
||||||
var beatmapInfo = db.Query<BeatmapInfo>().Where(b => b.Mode == PlayMode.Osu).FirstOrDefault();
|
this.db = db;
|
||||||
if (beatmapInfo != null)
|
|
||||||
beatmap = db.GetWorkingBeatmap(beatmapInfo);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public override void Reset()
|
public override void Reset()
|
||||||
{
|
{
|
||||||
base.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)
|
if (beatmap?.Track == null)
|
||||||
{
|
{
|
||||||
var objects = new List<HitObject>();
|
var objects = new List<HitObject>();
|
||||||
@ -82,16 +88,21 @@ namespace osu.Desktop.VisualTests.Tests
|
|||||||
Colour = Color4.Black,
|
Colour = Color4.Black,
|
||||||
});
|
});
|
||||||
|
|
||||||
Add(new PlayerLoader(new Player
|
Add(new PlayerLoader(Player = CreatePlayer(beatmap))
|
||||||
{
|
|
||||||
PreferredPlayMode = PlayMode.Osu,
|
|
||||||
Beatmap = beatmap
|
|
||||||
})
|
|
||||||
{
|
{
|
||||||
Beatmap = beatmap
|
Beatmap = beatmap
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
protected virtual Player CreatePlayer(WorkingBeatmap beatmap)
|
||||||
|
{
|
||||||
|
return new Player
|
||||||
|
{
|
||||||
|
PreferredPlayMode = PlayMode.Osu,
|
||||||
|
Beatmap = beatmap
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
class TestWorkingBeatmap : WorkingBeatmap
|
class TestWorkingBeatmap : WorkingBeatmap
|
||||||
{
|
{
|
||||||
public TestWorkingBeatmap(Beatmap beatmap)
|
public TestWorkingBeatmap(Beatmap beatmap)
|
||||||
|
@ -24,32 +24,20 @@ using SharpCompress.Readers;
|
|||||||
|
|
||||||
namespace osu.Desktop.VisualTests.Tests
|
namespace osu.Desktop.VisualTests.Tests
|
||||||
{
|
{
|
||||||
class TestCaseReplay : TestCase
|
class TestCaseReplay : TestCasePlayer
|
||||||
{
|
{
|
||||||
private WorkingBeatmap beatmap;
|
private WorkingBeatmap beatmap;
|
||||||
|
|
||||||
|
private LegacyReplayInputHandler replay;
|
||||||
|
|
||||||
public override string Name => @"Replay";
|
public override string Name => @"Replay";
|
||||||
|
|
||||||
public override string Description => @"Testing replay playback.";
|
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()
|
public override void Reset()
|
||||||
{
|
{
|
||||||
base.Reset();
|
base.Reset();
|
||||||
|
|
||||||
Add(new Box
|
|
||||||
{
|
|
||||||
RelativeSizeAxes = Framework.Graphics.Axes.Both,
|
|
||||||
Colour = Color4.Black,
|
|
||||||
});
|
|
||||||
|
|
||||||
|
|
||||||
var list = new List<LegacyReplayInputHandler.LegacyReplayFrame>();
|
var list = new List<LegacyReplayInputHandler.LegacyReplayFrame>();
|
||||||
|
|
||||||
float lastTime = 0;
|
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");
|
//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))
|
//using (MemoryStream dataStream = new MemoryStream(data))
|
||||||
@ -80,28 +68,13 @@ namespace osu.Desktop.VisualTests.Tests
|
|||||||
|
|
||||||
// Console.WriteLine(obj);
|
// 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)
|
var player = base.CreatePlayer(beatmap);
|
||||||
: base(beatmap.BeatmapInfo, beatmap.BeatmapInfo.BeatmapSet)
|
player.ReplayInputHandler = replay;
|
||||||
{
|
return player;
|
||||||
Beatmap = beatmap;
|
|
||||||
}
|
|
||||||
|
|
||||||
protected override ArchiveReader GetReader() => null;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user