diff --git a/osu.Game.Tests/Beatmaps/TestSceneBeatmapDifficultyCache.cs b/osu.Game.Tests/Beatmaps/TestSceneBeatmapDifficultyCache.cs index fc986d0a60..efb78b6004 100644 --- a/osu.Game.Tests/Beatmaps/TestSceneBeatmapDifficultyCache.cs +++ b/osu.Game.Tests/Beatmaps/TestSceneBeatmapDifficultyCache.cs @@ -65,6 +65,7 @@ namespace osu.Game.Tests.Beatmaps } [Test] + [FlakyTest] // one fix attempted in https://github.com/ppy/osu/pull/37178, didn't work public void TestInvalidationFlow() { BeatmapInfo postEditBeatmapInfo = null; diff --git a/osu.Game.Tests/Database/BackgroundDataStoreProcessorTests.cs b/osu.Game.Tests/Database/BackgroundDataStoreProcessorTests.cs index bae8e7c76a..1a9afe0c03 100644 --- a/osu.Game.Tests/Database/BackgroundDataStoreProcessorTests.cs +++ b/osu.Game.Tests/Database/BackgroundDataStoreProcessorTests.cs @@ -187,6 +187,7 @@ namespace osu.Game.Tests.Database } [Test] + [FlakyTest] public void TestCustomRulesetScoreNotSubjectToUpgrades([Values] bool available) { RulesetInfo rulesetInfo = null!; diff --git a/osu.Game.Tests/Visual/Editing/TestSceneEditorSaving.cs b/osu.Game.Tests/Visual/Editing/TestSceneEditorSaving.cs index 4ab7571636..a50f1cca29 100644 --- a/osu.Game.Tests/Visual/Editing/TestSceneEditorSaving.cs +++ b/osu.Game.Tests/Visual/Editing/TestSceneEditorSaving.cs @@ -128,6 +128,7 @@ namespace osu.Game.Tests.Visual.Editing } [Test] + [FlakyTest] public void TestLengthAndStarRatingUpdated() { WorkingBeatmap working = null; diff --git a/osu.Game.Tests/Visual/Editing/TestSceneLocallyModifyingOnlineBeatmaps.cs b/osu.Game.Tests/Visual/Editing/TestSceneLocallyModifyingOnlineBeatmaps.cs index 7ded3467c6..b89d33ebde 100644 --- a/osu.Game.Tests/Visual/Editing/TestSceneLocallyModifyingOnlineBeatmaps.cs +++ b/osu.Game.Tests/Visual/Editing/TestSceneLocallyModifyingOnlineBeatmaps.cs @@ -24,6 +24,7 @@ namespace osu.Game.Tests.Visual.Editing } [Test] + [FlakyTest] public void TestLocallyModifyingOnlineBeatmap() { string initialHash = string.Empty; diff --git a/osu.Game.Tests/Visual/Editing/TestSceneOpenEditorTimestamp.cs b/osu.Game.Tests/Visual/Editing/TestSceneOpenEditorTimestamp.cs index 46f47f6a92..d080e2806b 100644 --- a/osu.Game.Tests/Visual/Editing/TestSceneOpenEditorTimestamp.cs +++ b/osu.Game.Tests/Visual/Editing/TestSceneOpenEditorTimestamp.cs @@ -4,7 +4,6 @@ using System.Linq; using NUnit.Framework; using osu.Framework.Extensions; -using osu.Framework.Extensions.ObjectExtensions; using osu.Framework.Testing; using osu.Game.Beatmaps; using osu.Game.Database; @@ -140,14 +139,16 @@ namespace osu.Game.Tests.Visual.Editing private void setUpEditor(RulesetInfo ruleset) { - BeatmapSetInfo beatmapSet = null!; + BeatmapSetInfo? beatmapSet = null; AddStep("Import test beatmap", () => Game.BeatmapManager.Import(TestResources.GetTestBeatmapForImport()).WaitSafely() ); - AddStep("Retrieve beatmap", () => - beatmapSet = Game.BeatmapManager.QueryBeatmapSet(set => !set.Protected).AsNonNull().Value.Detach() - ); + AddUntilStep("Retrieve beatmap", () => + { + beatmapSet = Game.BeatmapManager.QueryBeatmapSet(set => !set.Protected)?.Value.Detach(); + return beatmapSet != null; + }); AddStep("Present beatmap", () => Game.PresentBeatmap(beatmapSet)); AddUntilStep("Wait for song select", () => Game.Beatmap.Value.BeatmapSetInfo.Equals(beatmapSet) @@ -157,7 +158,7 @@ namespace osu.Game.Tests.Visual.Editing AddStep("Switch ruleset", () => Game.Ruleset.Value = ruleset); AddStep("Open editor for ruleset", () => ((SoloSongSelect)Game.ScreenStack.CurrentScreen) - .Edit(beatmapSet.Beatmaps.Last(beatmap => beatmap.Ruleset.Name == ruleset.Name)) + .Edit(beatmapSet!.Beatmaps.Last(beatmap => beatmap.Ruleset.Name == ruleset.Name)) ); AddUntilStep("Wait for editor open", () => editor?.ReadyForUse == true); } diff --git a/osu.Game.Tests/Visual/Gameplay/TestSceneGameplaySamplePlayback.cs b/osu.Game.Tests/Visual/Gameplay/TestSceneGameplaySamplePlayback.cs index 84b312d5ee..8222ab9560 100644 --- a/osu.Game.Tests/Visual/Gameplay/TestSceneGameplaySamplePlayback.cs +++ b/osu.Game.Tests/Visual/Gameplay/TestSceneGameplaySamplePlayback.cs @@ -20,7 +20,7 @@ namespace osu.Game.Tests.Visual.Gameplay private bool seek; [Test] - [FlakyTest] + [Ignore("Still failing even with [FlakyTest] applied.")] public void TestAllSamplesStopDuringSeek() { DrawableSlider? slider = null; diff --git a/osu.Game.Tests/Visual/Multiplayer/TestSceneMultiplayer.cs b/osu.Game.Tests/Visual/Multiplayer/TestSceneMultiplayer.cs index b424621dcb..397cd0fd38 100644 --- a/osu.Game.Tests/Visual/Multiplayer/TestSceneMultiplayer.cs +++ b/osu.Game.Tests/Visual/Multiplayer/TestSceneMultiplayer.cs @@ -662,7 +662,7 @@ namespace osu.Game.Tests.Visual.Multiplayer AddStep("invoke on back button", () => multiplayerComponents.OnBackButton()); - AddAssert("mod overlay is hidden", () => this.ChildrenOfType().Single().State.Value == Visibility.Hidden); + AddAssert("mod overlay is hidden", () => this.ChildrenOfType().All(o => o.State.Value == Visibility.Hidden)); AddAssert("dialog overlay is hidden", () => DialogOverlay.State.Value == Visibility.Hidden); diff --git a/osu.Game.Tests/Visual/Navigation/TestSceneScreenNavigation.cs b/osu.Game.Tests/Visual/Navigation/TestSceneScreenNavigation.cs index 68aaba6c68..af77477143 100644 --- a/osu.Game.Tests/Visual/Navigation/TestSceneScreenNavigation.cs +++ b/osu.Game.Tests/Visual/Navigation/TestSceneScreenNavigation.cs @@ -653,6 +653,7 @@ namespace osu.Game.Tests.Visual.Navigation } [Test] + [FlakyTest] public void TestDeleteScoreAfterPlaying() { playToResults(); diff --git a/osu.Game.Tests/Visual/Ranking/TestSceneResultsScreen.cs b/osu.Game.Tests/Visual/Ranking/TestSceneResultsScreen.cs index 4758b70526..1e49763cbb 100644 --- a/osu.Game.Tests/Visual/Ranking/TestSceneResultsScreen.cs +++ b/osu.Game.Tests/Visual/Ranking/TestSceneResultsScreen.cs @@ -277,13 +277,18 @@ namespace osu.Game.Tests.Visual.Ranking ScorePanel expandedPanel = null; ScorePanel contractedPanel = null; + AddUntilStep("retrieve expanded panel", + () => expandedPanel = this.ChildrenOfType().Single(p => p.State == PanelState.Expanded), + () => Is.Not.Null); + AddUntilStep("retrieve contracted panel", + () => contractedPanel = this.ChildrenOfType().First(p => p.State == PanelState.Contracted && p.ScreenSpaceDrawQuad.TopLeft.X > screen.ScreenSpaceDrawQuad.TopLeft.X), + () => Is.Not.Null); + AddStep("click expanded panel then contracted panel", () => { - expandedPanel = this.ChildrenOfType().Single(p => p.State == PanelState.Expanded); InputManager.MoveMouseTo(expandedPanel); InputManager.Click(MouseButton.Left); - contractedPanel = this.ChildrenOfType().First(p => p.State == PanelState.Contracted && p.ScreenSpaceDrawQuad.TopLeft.X > screen.ScreenSpaceDrawQuad.TopLeft.X); InputManager.MoveMouseTo(contractedPanel); InputManager.Click(MouseButton.Left); }); diff --git a/osu.Game.Tests/Visual/Ranking/TestSceneSoloResultsScreen.cs b/osu.Game.Tests/Visual/Ranking/TestSceneSoloResultsScreen.cs index 266adf1ee8..4a4891f7f9 100644 --- a/osu.Game.Tests/Visual/Ranking/TestSceneSoloResultsScreen.cs +++ b/osu.Game.Tests/Visual/Ranking/TestSceneSoloResultsScreen.cs @@ -132,6 +132,7 @@ namespace osu.Game.Tests.Visual.Ranking } [Test] + [FlakyTest] public void TestOnlineLeaderboardWithLessThan50Scores() { ScoreInfo localScore = null!; diff --git a/osu.Game.Tests/Visual/SongSelect/TestSceneBeatmapCarouselFiltering.cs b/osu.Game.Tests/Visual/SongSelect/TestSceneBeatmapCarouselFiltering.cs index 73596a768d..6741b24b87 100644 --- a/osu.Game.Tests/Visual/SongSelect/TestSceneBeatmapCarouselFiltering.cs +++ b/osu.Game.Tests/Visual/SongSelect/TestSceneBeatmapCarouselFiltering.cs @@ -34,11 +34,11 @@ namespace osu.Game.Tests.Visual.SongSelect AddBeatmaps(10, 3); WaitForDrawablePanels(); - AddAssert("invocation count correct", () => NewItemsPresentedInvocationCount, () => Is.EqualTo(1)); + AddUntilStep("invocation count correct", () => NewItemsPresentedInvocationCount, () => Is.EqualTo(1)); ApplyToFilterAndWaitForFilter("filter", c => c.SearchText = BeatmapSets[2].Metadata.Title); - AddAssert("invocation count correct", () => NewItemsPresentedInvocationCount, () => Is.EqualTo(2)); + AddUntilStep("invocation count correct", () => NewItemsPresentedInvocationCount, () => Is.EqualTo(2)); CheckDisplayedBeatmapSetsCount(1); CheckDisplayedBeatmapsCount(3); @@ -53,7 +53,7 @@ namespace osu.Game.Tests.Visual.SongSelect ApplyToFilterAndWaitForFilter("remove filter", c => c.SearchText = string.Empty); - AddAssert("invocation count correct", () => NewItemsPresentedInvocationCount, () => Is.EqualTo(3)); + AddUntilStep("invocation count correct", () => NewItemsPresentedInvocationCount, () => Is.EqualTo(3)); CheckDisplayedBeatmapSetsCount(10); CheckDisplayedBeatmapsCount(30); diff --git a/osu.Game.Tests/Visual/SongSelect/TestSceneBeatmapCarouselSetsSplitApart.cs b/osu.Game.Tests/Visual/SongSelect/TestSceneBeatmapCarouselSetsSplitApart.cs index 12d70702d5..d6318c66de 100644 --- a/osu.Game.Tests/Visual/SongSelect/TestSceneBeatmapCarouselSetsSplitApart.cs +++ b/osu.Game.Tests/Visual/SongSelect/TestSceneBeatmapCarouselSetsSplitApart.cs @@ -51,6 +51,7 @@ namespace osu.Game.Tests.Visual.SongSelect } [Test] + [FlakyTest] public void TestSetTraversal() { AddBeatmaps(3, splitApart: true); diff --git a/osu.Game.Tests/Visual/SongSelect/TestSceneBeatmapRecommendations.cs b/osu.Game.Tests/Visual/SongSelect/TestSceneBeatmapRecommendations.cs index f2b4e41470..9f3c0fb2df 100644 --- a/osu.Game.Tests/Visual/SongSelect/TestSceneBeatmapRecommendations.cs +++ b/osu.Game.Tests/Visual/SongSelect/TestSceneBeatmapRecommendations.cs @@ -127,6 +127,7 @@ namespace osu.Game.Tests.Visual.SongSelect } [Test] + [FlakyTest] public void TestBestRulesetIsRecommended() { BeatmapSetInfo osuSet = null, mixedSet = null; diff --git a/osu.Game/Screens/OnlinePlay/Matchmaking/RankedPlay/Components/BackgroundMusicManager.cs b/osu.Game/Screens/OnlinePlay/Matchmaking/RankedPlay/Components/BackgroundMusicManager.cs index f4789797b5..e7aba74945 100644 --- a/osu.Game/Screens/OnlinePlay/Matchmaking/RankedPlay/Components/BackgroundMusicManager.cs +++ b/osu.Game/Screens/OnlinePlay/Matchmaking/RankedPlay/Components/BackgroundMusicManager.cs @@ -21,6 +21,8 @@ namespace osu.Game.Screens.OnlinePlay.Matchmaking.RankedPlay.Components private DrawableTrack bgm = null!; + private bool shouldBePlaying; + private Bindable isPlayingPreview = null!; [Resolved] @@ -46,48 +48,64 @@ namespace osu.Game.Screens.OnlinePlay.Matchmaking.RankedPlay.Components }); } - public void Play() + public void Play() => shouldBePlaying = true; + + public void Stop() => shouldBePlaying = false; + + protected override void Update() { - if (bgm.IsRunning) - return; + base.Update(); - const int track_fade_duration = 3000; - - // remove music control from player, to prevent overlapping music - musicController.AllowTrackControl.Value = false; - globalTrackFadeDelegate?.Cancel(); - - // cross-fade if global track is playing something - if (musicController.IsPlaying) - { - var globalTrack = musicController.CurrentTrack; - - globalTrack.VolumeTo(0, track_fade_duration, Easing.OutCubic); - globalTrackFadeDelegate = Scheduler.AddDelayed(() => - { - musicController.Stop(); - globalTrack.VolumeTo(1); - }, track_fade_duration); - } - - bgm.VolumeTo(0) - .VolumeTo(1, track_fade_duration, Easing.InCubic); - - bgm.Looping = true; - bgm.Start(); + updatePlayingState(); } - public void Stop() + private void updatePlayingState() { - globalTrackFadeDelegate?.Cancel(); + if (!bgm.IsLoaded) + return; - bgm.Stop(); - bgm.Reset(); + if (shouldBePlaying == bgm.IsRunning) + return; - // return control of music to player and reset volume - musicController.AllowTrackControl.Value = true; - musicController.CurrentTrack.Volume.Value = 1; - musicController.EnsurePlayingSomething(); + if (shouldBePlaying) + { + const int track_fade_duration = 3000; + + // remove music control from player, to prevent overlapping music + musicController.AllowTrackControl.Value = false; + globalTrackFadeDelegate?.Cancel(); + + // cross-fade if global track is playing something + if (musicController.IsPlaying) + { + var globalTrack = musicController.CurrentTrack; + + globalTrack.VolumeTo(0, track_fade_duration, Easing.OutCubic); + globalTrackFadeDelegate = Scheduler.AddDelayed(() => + { + musicController.Stop(); + globalTrack.VolumeTo(1); + }, track_fade_duration); + } + + bgm.VolumeTo(0) + .VolumeTo(1, track_fade_duration, Easing.InCubic); + + bgm.Looping = true; + bgm.Start(); + } + else + { + globalTrackFadeDelegate?.Cancel(); + + bgm.Stop(); + bgm.Reset(); + + // return control of music to player and reset volume + musicController.AllowTrackControl.Value = true; + musicController.CurrentTrack.Volume.Value = 1; + musicController.EnsurePlayingSomething(); + } } } }