1
0
mirror of https://github.com/ppy/osu.git synced 2025-01-12 20:22:55 +08:00

Update framework with new DI changes.

This commit is contained in:
Dean Herbert 2017-05-02 15:32:47 +09:00
parent 3604c3562a
commit d06b3c898f
2 changed files with 19 additions and 19 deletions

@ -1 +1 @@
Subproject commit b25ed4291bb8a8a38faf404c68b3f97efc9d3413 Subproject commit 58c108309f72462d8dc45aa488ab78cd6db08cf1

View File

@ -26,15 +26,15 @@ namespace osu.Game.Tests.Beatmaps.IO
//unfortunately for the time being we need to reference osu.Framework.Desktop for a game host here. //unfortunately for the time being we need to reference osu.Framework.Desktop for a game host here.
using (HeadlessGameHost host = new HeadlessGameHost()) using (HeadlessGameHost host = new HeadlessGameHost())
{ {
var osu = loadOsu(host); loadOsu(host);
var temp = prepareTempCopy(osz_path); var temp = prepareTempCopy(osz_path);
Assert.IsTrue(File.Exists(temp)); Assert.IsTrue(File.Exists(temp));
osu.Dependencies.Get<BeatmapDatabase>().Import(temp); host.Dependencies.Get<BeatmapDatabase>().Import(temp);
ensureLoaded(osu); ensureLoaded(host);
Assert.IsFalse(File.Exists(temp)); Assert.IsFalse(File.Exists(temp));
} }
@ -49,7 +49,7 @@ namespace osu.Game.Tests.Beatmaps.IO
Assert.IsTrue(host.IsPrimaryInstance); Assert.IsTrue(host.IsPrimaryInstance);
Assert.IsTrue(!client.IsPrimaryInstance); Assert.IsTrue(!client.IsPrimaryInstance);
var osu = loadOsu(host); loadOsu(host);
var temp = prepareTempCopy(osz_path); var temp = prepareTempCopy(osz_path);
@ -59,7 +59,7 @@ namespace osu.Game.Tests.Beatmaps.IO
if (!importer.ImportAsync(temp).Wait(5000)) if (!importer.ImportAsync(temp).Wait(5000))
Assert.Fail(@"IPC took too long to send"); Assert.Fail(@"IPC took too long to send");
ensureLoaded(osu); ensureLoaded(host);
Assert.IsFalse(File.Exists(temp)); Assert.IsFalse(File.Exists(temp));
} }
@ -71,16 +71,16 @@ namespace osu.Game.Tests.Beatmaps.IO
//unfortunately for the time being we need to reference osu.Framework.Desktop for a game host here. //unfortunately for the time being we need to reference osu.Framework.Desktop for a game host here.
using (HeadlessGameHost host = new HeadlessGameHost()) using (HeadlessGameHost host = new HeadlessGameHost())
{ {
var osu = loadOsu(host); loadOsu(host);
var temp = prepareTempCopy(osz_path); var temp = prepareTempCopy(osz_path);
Assert.IsTrue(File.Exists(temp)); Assert.IsTrue(File.Exists(temp));
using (File.OpenRead(temp)) using (File.OpenRead(temp))
osu.Dependencies.Get<BeatmapDatabase>().Import(temp); host.Dependencies.Get<BeatmapDatabase>().Import(temp);
ensureLoaded(osu); ensureLoaded(host);
Assert.IsTrue(File.Exists(temp)); Assert.IsTrue(File.Exists(temp));
@ -105,19 +105,19 @@ namespace osu.Game.Tests.Beatmaps.IO
Thread.Sleep(1); Thread.Sleep(1);
//reset beatmap database (sqlite and storage backing) //reset beatmap database (sqlite and storage backing)
osu.Dependencies.Get<RulesetDatabase>().Reset(); host.Dependencies.Get<RulesetDatabase>().Reset();
osu.Dependencies.Get<BeatmapDatabase>().Reset(); host.Dependencies.Get<BeatmapDatabase>().Reset();
return osu; return osu;
} }
private void ensureLoaded(OsuGameBase osu, int timeout = 10000) private void ensureLoaded(GameHost host, int timeout = 10000)
{ {
IEnumerable<BeatmapSetInfo> resultSets = null; IEnumerable<BeatmapSetInfo> resultSets = null;
Action waitAction = () => Action waitAction = () =>
{ {
while (!(resultSets = osu.Dependencies.Get<BeatmapDatabase>() while (!(resultSets = host.Dependencies.Get<BeatmapDatabase>()
.Query<BeatmapSetInfo>().Where(s => s.OnlineBeatmapSetID == 241526)).Any()) .Query<BeatmapSetInfo>().Where(s => s.OnlineBeatmapSetID == 241526)).Any())
Thread.Sleep(50); Thread.Sleep(50);
}; };
@ -134,7 +134,7 @@ namespace osu.Game.Tests.Beatmaps.IO
//if we don't re-check here, the set will be inserted but the beatmaps won't be present yet. //if we don't re-check here, the set will be inserted but the beatmaps won't be present yet.
waitAction = () => waitAction = () =>
{ {
while ((resultBeatmaps = osu.Dependencies.Get<BeatmapDatabase>() while ((resultBeatmaps = host.Dependencies.Get<BeatmapDatabase>()
.Query<BeatmapInfo>().Where(s => s.OnlineBeatmapSetID == 241526 && s.BaseDifficultyID > 0)).Count() != 12) .Query<BeatmapInfo>().Where(s => s.OnlineBeatmapSetID == 241526 && s.BaseDifficultyID > 0)).Count() != 12)
Thread.Sleep(50); Thread.Sleep(50);
}; };
@ -143,7 +143,7 @@ namespace osu.Game.Tests.Beatmaps.IO
@"Beatmaps did not import to the database in allocated time"); @"Beatmaps did not import to the database in allocated time");
//fetch children and check we can load from the post-storage path... //fetch children and check we can load from the post-storage path...
var set = osu.Dependencies.Get<BeatmapDatabase>().GetChildren(resultSets.First()); var set = host.Dependencies.Get<BeatmapDatabase>().GetChildren(resultSets.First());
Assert.IsTrue(set.Beatmaps.Count == resultBeatmaps.Count(), Assert.IsTrue(set.Beatmaps.Count == resultBeatmaps.Count(),
$@"Incorrect database beatmap count post-import ({resultBeatmaps.Count()} but should be {set.Beatmaps.Count})."); $@"Incorrect database beatmap count post-import ({resultBeatmaps.Count()} but should be {set.Beatmaps.Count}).");
@ -153,16 +153,16 @@ namespace osu.Game.Tests.Beatmaps.IO
Assert.IsTrue(set.Beatmaps.Count > 0); Assert.IsTrue(set.Beatmaps.Count > 0);
var beatmap = osu.Dependencies.Get<BeatmapDatabase>().GetWorkingBeatmap(set.Beatmaps.First(b => b.RulesetID == 0))?.Beatmap; var beatmap = host.Dependencies.Get<BeatmapDatabase>().GetWorkingBeatmap(set.Beatmaps.First(b => b.RulesetID == 0))?.Beatmap;
Assert.IsTrue(beatmap?.HitObjects.Count > 0); Assert.IsTrue(beatmap?.HitObjects.Count > 0);
beatmap = osu.Dependencies.Get<BeatmapDatabase>().GetWorkingBeatmap(set.Beatmaps.First(b => b.RulesetID == 1))?.Beatmap; beatmap = host.Dependencies.Get<BeatmapDatabase>().GetWorkingBeatmap(set.Beatmaps.First(b => b.RulesetID == 1))?.Beatmap;
Assert.IsTrue(beatmap?.HitObjects.Count > 0); Assert.IsTrue(beatmap?.HitObjects.Count > 0);
beatmap = osu.Dependencies.Get<BeatmapDatabase>().GetWorkingBeatmap(set.Beatmaps.First(b => b.RulesetID == 2))?.Beatmap; beatmap = host.Dependencies.Get<BeatmapDatabase>().GetWorkingBeatmap(set.Beatmaps.First(b => b.RulesetID == 2))?.Beatmap;
Assert.IsTrue(beatmap?.HitObjects.Count > 0); Assert.IsTrue(beatmap?.HitObjects.Count > 0);
beatmap = osu.Dependencies.Get<BeatmapDatabase>().GetWorkingBeatmap(set.Beatmaps.First(b => b.RulesetID == 3))?.Beatmap; beatmap = host.Dependencies.Get<BeatmapDatabase>().GetWorkingBeatmap(set.Beatmaps.First(b => b.RulesetID == 3))?.Beatmap;
Assert.IsTrue(beatmap?.HitObjects.Count > 0); Assert.IsTrue(beatmap?.HitObjects.Count > 0);
} }
} }