From fdbcf803b82b984eca9928d83155e21f5cddb1f9 Mon Sep 17 00:00:00 2001 From: andy840119 Date: Thu, 2 Jul 2020 22:02:43 +0900 Subject: [PATCH] Remove unused case and clean-up code. --- .../Ranking/TestKaraokeScoreInfo.cs | 2 +- .../Ranking/TestSceneResultsScreen.cs | 210 +----------------- .../Ranking/TestSceneStatisticsPanel.cs | 4 +- 3 files changed, 6 insertions(+), 210 deletions(-) diff --git a/osu.Game.Rulesets.Karaoke.Tests/Ranking/TestKaraokeScoreInfo.cs b/osu.Game.Rulesets.Karaoke.Tests/Ranking/TestKaraokeScoreInfo.cs index 6d7c6f547..f759905c8 100644 --- a/osu.Game.Rulesets.Karaoke.Tests/Ranking/TestKaraokeScoreInfo.cs +++ b/osu.Game.Rulesets.Karaoke.Tests/Ranking/TestKaraokeScoreInfo.cs @@ -19,7 +19,7 @@ public TestKaraokeScoreInfo() User = new User { - Id = 11111, + Id = 1030492, Username = "andy840119", CoverUrl = "https://osu.ppy.sh/images/headers/profile-covers/c3.jpg", }; diff --git a/osu.Game.Rulesets.Karaoke.Tests/Ranking/TestSceneResultsScreen.cs b/osu.Game.Rulesets.Karaoke.Tests/Ranking/TestSceneResultsScreen.cs index 2c56af853..633d8ee6f 100644 --- a/osu.Game.Rulesets.Karaoke.Tests/Ranking/TestSceneResultsScreen.cs +++ b/osu.Game.Rulesets.Karaoke.Tests/Ranking/TestSceneResultsScreen.cs @@ -4,14 +4,12 @@ using System; using System.Collections.Generic; using System.Linq; -using System.Threading.Tasks; using NUnit.Framework; using osu.Framework.Allocation; using osu.Framework.Graphics; using osu.Framework.Graphics.Containers; using osu.Framework.Screens; using osu.Framework.Testing; -using osu.Framework.Utils; using osu.Game.Beatmaps; using osu.Game.Online.API; using osu.Game.Rulesets.Karaoke.Tests.Beatmaps; @@ -20,9 +18,7 @@ using osu.Game.Screens.Play; using osu.Game.Screens.Ranking; using osu.Game.Screens.Ranking.Statistics; -using osu.Game.Tests; using osu.Game.Tests.Visual; -using osuTK; using osuTK.Input; namespace osu.Game.Rulesets.Karaoke.Tests.Ranking @@ -32,126 +28,10 @@ public class TestSceneResultsScreen : OsuManualInputManagerTestScene { protected override IBeatmap CreateBeatmap(RulesetInfo ruleset) => new TestKaraokeBeatmap(ruleset); - private TestResultsScreen createResultsScreen() => new TestResultsScreen(new TestScoreInfo(new KaraokeRuleset().RulesetInfo)); - - private UnrankedSoloResultsScreen createUnrankedSoloResultsScreen() => new UnrankedSoloResultsScreen(new TestScoreInfo(new KaraokeRuleset().RulesetInfo)); - - [Test] - public void TestResultsWithoutPlayer() - { - TestResultsScreen screen = null; - OsuScreenStack stack; - - AddStep("load results", () => - { - Child = stack = new OsuScreenStack - { - RelativeSizeAxes = Axes.Both - }; - - stack.Push(screen = createResultsScreen()); - }); - AddUntilStep("wait for loaded", () => screen.IsLoaded); - AddAssert("retry overlay not present", () => screen.RetryOverlay == null); - } - - [Test] - public void TestResultsWithPlayer() - { - TestResultsScreen screen = null; - - AddStep("load results", () => Child = new TestResultsContainer(screen = createResultsScreen())); - AddUntilStep("wait for loaded", () => screen.IsLoaded); - AddAssert("retry overlay present", () => screen.RetryOverlay != null); - } - - [Test] - public void TestResultsForUnranked() + private TestResultsScreen createResultsScreen() => new TestResultsScreen(new TestKaraokeScoreInfo { - UnrankedSoloResultsScreen screen = null; - - AddStep("load results", () => Child = new TestResultsContainer(screen = createUnrankedSoloResultsScreen())); - AddUntilStep("wait for loaded", () => screen.IsLoaded); - AddAssert("retry overlay present", () => screen.RetryOverlay != null); - } - - [Test] - public void TestShowHideStatisticsViaOutsideClick() - { - TestResultsScreen screen = null; - - AddStep("load results", () => Child = new TestResultsContainer(screen = createResultsScreen())); - AddUntilStep("wait for loaded", () => screen.IsLoaded); - - AddStep("click expanded panel", () => - { - var expandedPanel = this.ChildrenOfType().Single(p => p.State == PanelState.Expanded); - InputManager.MoveMouseTo(expandedPanel); - InputManager.Click(MouseButton.Left); - }); - - AddAssert("statistics shown", () => this.ChildrenOfType().Single().State.Value == Visibility.Visible); - - AddUntilStep("expanded panel at the left of the screen", () => - { - var expandedPanel = this.ChildrenOfType().Single(p => p.State == PanelState.Expanded); - return expandedPanel.ScreenSpaceDrawQuad.TopLeft.X - screen.ScreenSpaceDrawQuad.TopLeft.X < 150; - }); - - AddStep("click to right of panel", () => - { - var expandedPanel = this.ChildrenOfType().Single(p => p.State == PanelState.Expanded); - InputManager.MoveMouseTo(expandedPanel.ScreenSpaceDrawQuad.TopRight + new Vector2(100, 0)); - InputManager.Click(MouseButton.Left); - }); - - AddAssert("statistics hidden", () => this.ChildrenOfType().Single().State.Value == Visibility.Hidden); - - AddUntilStep("expanded panel in centre of screen", () => - { - var expandedPanel = this.ChildrenOfType().Single(p => p.State == PanelState.Expanded); - return Precision.AlmostEquals(expandedPanel.ScreenSpaceDrawQuad.Centre.X, screen.ScreenSpaceDrawQuad.Centre.X, 1); - }); - } - - [Test] - public void TestShowHideStatistics() - { - TestResultsScreen screen = null; - - AddStep("load results", () => Child = new TestResultsContainer(screen = createResultsScreen())); - AddUntilStep("wait for loaded", () => screen.IsLoaded); - - AddStep("click expanded panel", () => - { - var expandedPanel = this.ChildrenOfType().Single(p => p.State == PanelState.Expanded); - InputManager.MoveMouseTo(expandedPanel); - InputManager.Click(MouseButton.Left); - }); - - AddAssert("statistics shown", () => this.ChildrenOfType().Single().State.Value == Visibility.Visible); - - AddUntilStep("expanded panel at the left of the screen", () => - { - var expandedPanel = this.ChildrenOfType().Single(p => p.State == PanelState.Expanded); - return expandedPanel.ScreenSpaceDrawQuad.TopLeft.X - screen.ScreenSpaceDrawQuad.TopLeft.X < 150; - }); - - AddStep("click expanded panel", () => - { - var expandedPanel = this.ChildrenOfType().Single(p => p.State == PanelState.Expanded); - InputManager.MoveMouseTo(expandedPanel); - InputManager.Click(MouseButton.Left); - }); - - AddAssert("statistics hidden", () => this.ChildrenOfType().Single().State.Value == Visibility.Hidden); - - AddUntilStep("expanded panel in centre of screen", () => - { - var expandedPanel = this.ChildrenOfType().Single(p => p.State == PanelState.Expanded); - return Precision.AlmostEquals(expandedPanel.ScreenSpaceDrawQuad.Centre.X, screen.ScreenSpaceDrawQuad.Centre.X, 1); - }); - } + HitEvents = TestSceneHitEventTimingDistributionGraph.CreateDistributedHitEvents() + }); [Test] public void TestShowStatisticsAndClickOtherPanel() @@ -181,24 +61,6 @@ public void TestShowStatisticsAndClickOtherPanel() AddAssert("expanded panel still expanded", () => expandedPanel.State == PanelState.Expanded); } - [Test] - public void TestFetchScoresAfterShowingStatistics() - { - DelayedFetchResultsScreen screen = null; - - AddStep("load results", () => Child = new TestResultsContainer(screen = new DelayedFetchResultsScreen(new TestScoreInfo(new KaraokeRuleset().RulesetInfo), 3000))); - AddUntilStep("wait for loaded", () => screen.IsLoaded); - AddStep("click expanded panel", () => - { - var expandedPanel = this.ChildrenOfType().Single(p => p.State == PanelState.Expanded); - InputManager.MoveMouseTo(expandedPanel); - InputManager.Click(MouseButton.Left); - }); - - AddUntilStep("wait for fetch", () => screen.FetchCompleted); - AddAssert("expanded panel still on screen", () => this.ChildrenOfType().Single(p => p.State == PanelState.Expanded).ScreenSpaceDrawQuad.TopLeft.X > 0); - } - private class TestResultsContainer : Container { [Cached(typeof(Player))] @@ -220,27 +82,18 @@ public TestResultsContainer(IScreen screen) private class TestResultsScreen : ResultsScreen { - public HotkeyRetryOverlay RetryOverlay; - public TestResultsScreen(ScoreInfo score) : base(score) { } - protected override void LoadComplete() - { - base.LoadComplete(); - - RetryOverlay = InternalChildren.OfType().SingleOrDefault(); - } - protected override APIRequest FetchScores(Action> scoresCallback) { var scores = new List(); for (int i = 0; i < 20; i++) { - var score = new TestScoreInfo(new KaraokeRuleset().RulesetInfo); + var score = new TestKaraokeScoreInfo(); score.TotalScore += 10 - i; scores.Add(score); } @@ -250,60 +103,5 @@ protected override APIRequest FetchScores(Action> scoresC return null; } } - - private class DelayedFetchResultsScreen : TestResultsScreen - { - public bool FetchCompleted { get; private set; } - - private readonly double delay; - - public DelayedFetchResultsScreen(ScoreInfo score, double delay) - : base(score) - { - this.delay = delay; - } - - protected override APIRequest FetchScores(Action> scoresCallback) - { - Task.Run(async () => - { - await Task.Delay(TimeSpan.FromMilliseconds(delay)); - - var scores = new List(); - - for (int i = 0; i < 20; i++) - { - var score = new TestScoreInfo(new KaraokeRuleset().RulesetInfo); - score.TotalScore += 10 - i; - scores.Add(score); - } - - scoresCallback?.Invoke(scores); - - Schedule(() => FetchCompleted = true); - }); - - return null; - } - } - - private class UnrankedSoloResultsScreen : SoloResultsScreen - { - public HotkeyRetryOverlay RetryOverlay; - - public UnrankedSoloResultsScreen(ScoreInfo score) - : base(score) - { - Score.Beatmap.OnlineBeatmapID = 0; - Score.Beatmap.Status = BeatmapSetOnlineStatus.Pending; - } - - protected override void LoadComplete() - { - base.LoadComplete(); - - RetryOverlay = InternalChildren.OfType().SingleOrDefault(); - } - } } } diff --git a/osu.Game.Rulesets.Karaoke.Tests/Ranking/TestSceneStatisticsPanel.cs b/osu.Game.Rulesets.Karaoke.Tests/Ranking/TestSceneStatisticsPanel.cs index ed26e270a..0cde64945 100644 --- a/osu.Game.Rulesets.Karaoke.Tests/Ranking/TestSceneStatisticsPanel.cs +++ b/osu.Game.Rulesets.Karaoke.Tests/Ranking/TestSceneStatisticsPanel.cs @@ -4,11 +4,9 @@ using NUnit.Framework; using osu.Framework.Graphics; using osu.Framework.Graphics.Containers; -using osu.Game.Rulesets.Scoring; using osu.Game.Scoring; using osu.Game.Screens.Ranking.Statistics; using osu.Game.Tests.Visual; -using System.Collections.Generic; namespace osu.Game.Rulesets.Karaoke.Tests.Ranking { @@ -17,7 +15,7 @@ public class TestSceneStatisticsPanel : OsuTestScene [Test] public void TestScoreWithStatistics() { - var score = new TestKaraokeScoreInfo() + var score = new TestKaraokeScoreInfo { HitEvents = TestSceneHitEventTimingDistributionGraph.CreateDistributedHitEvents() };