From d05b9b1734bf9734ce9434721ef5ee990ef6dd38 Mon Sep 17 00:00:00 2001 From: David Zhao Date: Thu, 1 Aug 2019 14:19:45 +0900 Subject: [PATCH] Use dummyAPI and move load check into MusicController --- .../Visual/Menus/TestSceneScreenNavigation.cs | 26 +++++++++++++------ osu.Game/OsuGame.cs | 2 +- osu.Game/Overlays/MusicController.cs | 4 +++ osu.Game/Screens/Multi/Multiplayer.cs | 2 +- 4 files changed, 24 insertions(+), 10 deletions(-) diff --git a/osu.Game.Tests/Visual/Menus/TestSceneScreenNavigation.cs b/osu.Game.Tests/Visual/Menus/TestSceneScreenNavigation.cs index f71e8dc2ce..88dac8d0ff 100644 --- a/osu.Game.Tests/Visual/Menus/TestSceneScreenNavigation.cs +++ b/osu.Game.Tests/Visual/Menus/TestSceneScreenNavigation.cs @@ -8,11 +8,11 @@ using osu.Framework.Allocation; using osu.Framework.Graphics; using osu.Framework.Graphics.Containers; using osu.Framework.Graphics.Shapes; -using osu.Framework.Logging; using osu.Framework.Platform; using osu.Framework.Screens; using osu.Framework.Testing; using osu.Game.Graphics.UserInterface; +using osu.Game.Online.API; using osu.Game.Overlays; using osu.Game.Overlays.Mods; using osu.Game.Screens; @@ -111,6 +111,7 @@ namespace osu.Game.Tests.Visual.Menus [Test] public void TestOpenOptionsAndExitWithEscape() { + AddUntilStep("Wait for options to load", () => osuGame.Settings.IsLoaded); AddStep("Enter menu", () => pressAndRelease(Key.Enter)); AddStep("Move mouse to options overlay", () => InputManager.MoveMouseTo(optionsButtonPosition)); AddStep("Click options overlay", () => InputManager.Click(MouseButton.Left)); @@ -122,13 +123,7 @@ namespace osu.Game.Tests.Visual.Menus private void pushAndConfirm(Func newScreen, string screenName) { Screen screen = null; - AddStep($"Push new {screenName}", () => - { - if (screenName == "song select") - Logger.Log("fuck"); - - osuGame.ScreenStack.Push(screen = newScreen()); - }); + AddStep($"Push new {screenName}", () => osuGame.ScreenStack.Push(screen = newScreen())); AddUntilStep($"Wait for new {screenName}", () => osuGame.ScreenStack.CurrentScreen == screen && screen.IsLoaded); } @@ -160,6 +155,21 @@ namespace osu.Game.Tests.Visual.Menus public new SettingsPanel Settings => base.Settings; protected override Loader CreateLoader() => new TestLoader(); + + private DependencyContainer dependencies; + + private DummyAPIAccess dummyAPI; + + protected override IReadOnlyDependencyContainer CreateChildDependencies(IReadOnlyDependencyContainer parent) => + dependencies = new DependencyContainer(base.CreateChildDependencies(parent)); + + protected override void LoadComplete() + { + base.LoadComplete(); + dependencies.CacheAs(dummyAPI = new DummyAPIAccess()); + + dummyAPI.Login("Rhythm Champion", "osu!"); + } } private class TestSongSelect : PlaySongSelect diff --git a/osu.Game/OsuGame.cs b/osu.Game/OsuGame.cs index e7c0d01f31..63ec349d3d 100644 --- a/osu.Game/OsuGame.cs +++ b/osu.Game/OsuGame.cs @@ -318,7 +318,7 @@ namespace osu.Game private void currentTrackCompleted() { - if (!Beatmap.Value.Track.Looping && !Beatmap.Disabled && musicController.IsLoaded) + if (!Beatmap.Value.Track.Looping && !Beatmap.Disabled) musicController.NextTrack(); } diff --git a/osu.Game/Overlays/MusicController.cs b/osu.Game/Overlays/MusicController.cs index abbcec5094..91ae92320a 100644 --- a/osu.Game/Overlays/MusicController.cs +++ b/osu.Game/Overlays/MusicController.cs @@ -316,6 +316,10 @@ namespace osu.Game.Overlays private void next(bool instant = false) { + // beatmapSets doesn't get populated until loading has completed. + if (!IsLoaded) + return; + if (!instant) queuedDirection = TransformDirection.Next; diff --git a/osu.Game/Screens/Multi/Multiplayer.cs b/osu.Game/Screens/Multi/Multiplayer.cs index 3d9997e236..9550d883fd 100644 --- a/osu.Game/Screens/Multi/Multiplayer.cs +++ b/osu.Game/Screens/Multi/Multiplayer.cs @@ -168,7 +168,7 @@ namespace osu.Game.Screens.Multi public void APIStateChanged(IAPIProvider api, APIState state) { - if (RequireOnline && state != APIState.Online) + if (state != APIState.Online) forcefullyExit(); }