diff --git a/osu-framework b/osu-framework index 94e887669a..921175c209 160000 --- a/osu-framework +++ b/osu-framework @@ -1 +1 @@ -Subproject commit 94e887669ab4d1784d568c564400c60ff5b865df +Subproject commit 921175c209840ba0787338be9e4aada6e95be7a5 diff --git a/osu.Game.Tests/Beatmaps/IO/ImportBeatmapTest.cs b/osu.Game.Tests/Beatmaps/IO/ImportBeatmapTest.cs index e467df0c53..24970b8dab 100644 --- a/osu.Game.Tests/Beatmaps/IO/ImportBeatmapTest.cs +++ b/osu.Game.Tests/Beatmaps/IO/ImportBeatmapTest.cs @@ -12,6 +12,7 @@ using osu.Framework.Desktop.Platform; using osu.Framework.Platform; using osu.Game.Database; using osu.Game.IPC; +using osu.Framework.Allocation; namespace osu.Game.Tests.Beatmaps.IO { @@ -26,15 +27,15 @@ namespace osu.Game.Tests.Beatmaps.IO //unfortunately for the time being we need to reference osu.Framework.Desktop for a game host here. using (HeadlessGameHost host = new HeadlessGameHost()) { - loadOsu(host); + var osu = loadOsu(host); var temp = prepareTempCopy(osz_path); Assert.IsTrue(File.Exists(temp)); - host.Dependencies.Get().Import(temp); + osu.Dependencies.Get().Import(temp); - ensureLoaded(host); + ensureLoaded(osu); Assert.IsFalse(File.Exists(temp)); } @@ -49,7 +50,7 @@ namespace osu.Game.Tests.Beatmaps.IO Assert.IsTrue(host.IsPrimaryInstance); Assert.IsTrue(!client.IsPrimaryInstance); - loadOsu(host); + var osu = loadOsu(host); var temp = prepareTempCopy(osz_path); @@ -59,7 +60,7 @@ namespace osu.Game.Tests.Beatmaps.IO if (!importer.ImportAsync(temp).Wait(10000)) Assert.Fail(@"IPC took too long to send"); - ensureLoaded(host); + ensureLoaded(osu); Assert.IsFalse(File.Exists(temp)); } @@ -71,16 +72,16 @@ namespace osu.Game.Tests.Beatmaps.IO //unfortunately for the time being we need to reference osu.Framework.Desktop for a game host here. using (HeadlessGameHost host = new HeadlessGameHost()) { - loadOsu(host); + var osu = loadOsu(host); var temp = prepareTempCopy(osz_path); Assert.IsTrue(File.Exists(temp), "Temporary file copy never substantiated"); using (File.OpenRead(temp)) - host.Dependencies.Get().Import(temp); + osu.Dependencies.Get().Import(temp); - ensureLoaded(host); + ensureLoaded(osu); File.Delete(temp); @@ -103,19 +104,19 @@ namespace osu.Game.Tests.Beatmaps.IO Thread.Sleep(1); //reset beatmap database (sqlite and storage backing) - host.Dependencies.Get().Reset(); - host.Dependencies.Get().Reset(); + osu.Dependencies.Get().Reset(); + osu.Dependencies.Get().Reset(); return osu; } - private void ensureLoaded(GameHost host, int timeout = 60000) + private void ensureLoaded(OsuGameBase osu, int timeout = 60000) { IEnumerable resultSets = null; Action waitAction = () => { - while (!(resultSets = host.Dependencies.Get() + while (!(resultSets = osu.Dependencies.Get() .Query().Where(s => s.OnlineBeatmapSetID == 241526)).Any()) Thread.Sleep(50); }; @@ -132,7 +133,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. waitAction = () => { - while ((resultBeatmaps = host.Dependencies.Get() + while ((resultBeatmaps = osu.Dependencies.Get() .GetAllWithChildren(s => s.OnlineBeatmapSetID == 241526 && s.BaseDifficultyID > 0)).Count() != 12) Thread.Sleep(50); }; @@ -140,7 +141,7 @@ namespace osu.Game.Tests.Beatmaps.IO Assert.IsTrue(waitAction.BeginInvoke(null, null).AsyncWaitHandle.WaitOne(timeout), @"Beatmaps did not import to the database in allocated time"); - var set = host.Dependencies.Get().GetChildren(resultSets.First()); + var set = osu.Dependencies.Get().GetChildren(resultSets.First()); Assert.IsTrue(set.Beatmaps.Count == resultBeatmaps.Count(), $@"Incorrect database beatmap count post-import ({resultBeatmaps.Count()} but should be {set.Beatmaps.Count})."); @@ -150,16 +151,16 @@ namespace osu.Game.Tests.Beatmaps.IO Assert.IsTrue(set.Beatmaps.Count > 0); - var beatmap = host.Dependencies.Get().GetWorkingBeatmap(set.Beatmaps.First(b => b.RulesetID == 0))?.Beatmap; + var beatmap = osu.Dependencies.Get().GetWorkingBeatmap(set.Beatmaps.First(b => b.RulesetID == 0))?.Beatmap; Assert.IsTrue(beatmap?.HitObjects.Count > 0); - beatmap = host.Dependencies.Get().GetWorkingBeatmap(set.Beatmaps.First(b => b.RulesetID == 1))?.Beatmap; + beatmap = osu.Dependencies.Get().GetWorkingBeatmap(set.Beatmaps.First(b => b.RulesetID == 1))?.Beatmap; Assert.IsTrue(beatmap?.HitObjects.Count > 0); - beatmap = host.Dependencies.Get().GetWorkingBeatmap(set.Beatmaps.First(b => b.RulesetID == 2))?.Beatmap; + beatmap = osu.Dependencies.Get().GetWorkingBeatmap(set.Beatmaps.First(b => b.RulesetID == 2))?.Beatmap; Assert.IsTrue(beatmap?.HitObjects.Count > 0); - beatmap = host.Dependencies.Get().GetWorkingBeatmap(set.Beatmaps.First(b => b.RulesetID == 3))?.Beatmap; + beatmap = osu.Dependencies.Get().GetWorkingBeatmap(set.Beatmaps.First(b => b.RulesetID == 3))?.Beatmap; Assert.IsTrue(beatmap?.HitObjects.Count > 0); } }