diff --git a/osu.Game.Tests/Visual/Gameplay/TestSceneResults.cs b/osu.Game.Tests/Visual/Gameplay/TestSceneResults.cs index bf26892539..7790126db5 100644 --- a/osu.Game.Tests/Visual/Gameplay/TestSceneResults.cs +++ b/osu.Game.Tests/Visual/Gameplay/TestSceneResults.cs @@ -3,11 +3,16 @@ using System; using System.Collections.Generic; +using System.Linq; using NUnit.Framework; using osu.Framework.Allocation; +using osu.Framework.Graphics; +using osu.Framework.Graphics.Containers; +using osu.Framework.Screens; using osu.Game.Beatmaps; using osu.Game.Rulesets.Scoring; using osu.Game.Scoring; +using osu.Game.Screens; using osu.Game.Screens.Play; using osu.Game.Screens.Ranking; using osu.Game.Screens.Ranking.Pages; @@ -27,7 +32,8 @@ namespace osu.Game.Tests.Visual.Gameplay typeof(ScoreResultsPage), typeof(RetryButton), typeof(ReplayDownloadButton), - typeof(LocalLeaderboardPage) + typeof(LocalLeaderboardPage), + typeof(TestPlayer) }; [BackgroundDependencyLoader] @@ -43,26 +49,82 @@ namespace osu.Game.Tests.Visual.Gameplay var beatmapInfo = beatmaps.QueryBeatmap(b => b.RulesetID == 0); if (beatmapInfo != null) Beatmap.Value = beatmaps.GetWorkingBeatmap(beatmapInfo); + } - LoadScreen(new SoloResults(new ScoreInfo + private TestSoloResults createResultsScreen() => new TestSoloResults(new ScoreInfo + { + TotalScore = 2845370, + Accuracy = 0.98, + MaxCombo = 123, + Rank = ScoreRank.A, + Date = DateTimeOffset.Now, + Statistics = new Dictionary { - TotalScore = 2845370, - Accuracy = 0.98, - MaxCombo = 123, - Rank = ScoreRank.A, - Date = DateTimeOffset.Now, - Statistics = new Dictionary + { HitResult.Great, 50 }, + { HitResult.Good, 20 }, + { HitResult.Meh, 50 }, + { HitResult.Miss, 1 } + }, + User = new User + { + Username = "peppy", + } + }); + + [Test] + public void ResultsWithoutPlayer() + { + TestSoloResults screen = null; + + AddStep("load results", () => Child = new OsuScreenStack(screen = createResultsScreen()) + { + RelativeSizeAxes = Axes.Both + }); + AddUntilStep("wait for loaded", () => screen.IsLoaded); + AddAssert("retry overlay not present", () => screen.RetryOverlay == null); + } + + [Test] + public void ResultsWithPlayer() + { + TestSoloResults screen = null; + + AddStep("load results", () => Child = new TestResultsContainer(screen = createResultsScreen())); + AddUntilStep("wait for loaded", () => screen.IsLoaded); + AddAssert("retry overlay present", () => screen.RetryOverlay != null); + } + + private class TestResultsContainer : Container + { + [Cached(typeof(Player))] + private readonly Player player = new TestPlayer(); + + public TestResultsContainer(IScreen screen) + { + RelativeSizeAxes = Axes.Both; + + InternalChild = new OsuScreenStack(screen) { - { HitResult.Great, 50 }, - { HitResult.Good, 20 }, - { HitResult.Meh, 50 }, - { HitResult.Miss, 1 } - }, - User = new User - { - Username = "peppy", - } - })); + RelativeSizeAxes = Axes.Both, + }; + } + } + + private class TestSoloResults : SoloResults + { + public HotkeyRetryOverlay RetryOverlay; + + public TestSoloResults(ScoreInfo score) + : base(score) + { + } + + protected override void LoadComplete() + { + base.LoadComplete(); + + RetryOverlay = InternalChildren.OfType().SingleOrDefault(); + } } } }