From 391c4e529c4fa847385c5052e6788b1968348ef6 Mon Sep 17 00:00:00 2001 From: Salman Ahmed Date: Mon, 23 Aug 2021 11:11:15 +0300 Subject: [PATCH] Add test coverage for all added features --- .../Visual/Online/TestSceneRankingsOverlay.cs | 42 +++++++++++++++++++ .../TestSceneOverlayRulesetSelector.cs | 22 ++++++++++ 2 files changed, 64 insertions(+) diff --git a/osu.Game.Tests/Visual/Online/TestSceneRankingsOverlay.cs b/osu.Game.Tests/Visual/Online/TestSceneRankingsOverlay.cs index aff510dd95..74b8cbdfe5 100644 --- a/osu.Game.Tests/Visual/Online/TestSceneRankingsOverlay.cs +++ b/osu.Game.Tests/Visual/Online/TestSceneRankingsOverlay.cs @@ -1,12 +1,16 @@ // Copyright (c) ppy Pty Ltd . Licensed under the MIT Licence. // See the LICENCE file in the repository root for full licence text. +using System.Linq; using osu.Framework.Allocation; using osu.Game.Overlays; using NUnit.Framework; using osu.Game.Users; using osu.Framework.Bindables; +using osu.Framework.Testing; using osu.Game.Overlays.Rankings; +using osu.Game.Rulesets; +using osu.Game.Rulesets.Taiko; namespace osu.Game.Tests.Visual.Online { @@ -35,6 +39,44 @@ namespace osu.Game.Tests.Visual.Online AddStep("Show", rankingsOverlay.Show); } + [Test] + public void TestRulesetResetsOnNoFilters() + { + AddStep("Set different ruleset", () => rankingsOverlay.ChildrenOfType().Single().SwitchTab(1)); + AddAssert("Ruleset not default", () => !rankingsOverlay.Header.Ruleset.IsDefault); + AddStep("Hide overlay", () => rankingsOverlay.Hide()); + AddUntilStep("Wait for hide", () => !rankingsOverlay.IsPresent); + + AddStep("Show overlay again", () => rankingsOverlay.Show()); + AddAssert("Ruleset reverted", () => rankingsOverlay.Header.Ruleset.IsDefault); + } + + [Test] + public void TestRulesetDoesntResetOnCountryFilter() + { + AddStep("Set different ruleset", () => rankingsOverlay.ChildrenOfType().Single().SwitchTab(1)); + AddAssert("Ruleset not default", () => !rankingsOverlay.Header.Ruleset.IsDefault); + AddStep("Set country filter", () => countryBindable.Value = us_country); + AddStep("Hide overlay", () => rankingsOverlay.Hide()); + AddUntilStep("Wait for hide", () => !rankingsOverlay.IsPresent); + + AddStep("Show overlay again", () => rankingsOverlay.Show()); + AddAssert("Ruleset not reverted", () => !rankingsOverlay.Header.Ruleset.IsDefault); + } + + [Test] + public void TestRulesetDoesntResetOnScopeChange() + { + AddStep("Set ruleset to osu!taiko", () => rankingsOverlay.Header.Ruleset.Value = new TaikoRuleset().RulesetInfo); + AddAssert("Ruleset not default", () => !rankingsOverlay.Header.Ruleset.IsDefault); + AddStep("Set different scope", () => scope.Value = RankingsScope.Score); + AddStep("Hide overlay", () => rankingsOverlay.Hide()); + AddUntilStep("Wait for hide", () => !rankingsOverlay.IsPresent); + + AddStep("Show overlay again", () => rankingsOverlay.Show()); + AddAssert("Ruleset not reverted", () => !rankingsOverlay.Header.Ruleset.IsDefault); + } + [Test] public void TestFlagScopeDependency() { diff --git a/osu.Game.Tests/Visual/UserInterface/TestSceneOverlayRulesetSelector.cs b/osu.Game.Tests/Visual/UserInterface/TestSceneOverlayRulesetSelector.cs index f4fa41a3b7..ceec8b2e58 100644 --- a/osu.Game.Tests/Visual/UserInterface/TestSceneOverlayRulesetSelector.cs +++ b/osu.Game.Tests/Visual/UserInterface/TestSceneOverlayRulesetSelector.cs @@ -70,5 +70,27 @@ namespace osu.Game.Tests.Visual.UserInterface AddStep("Select catch", () => ruleset.Value = new CatchRuleset().RulesetInfo); AddAssert("Check catch selected", () => selector.Current.Value.Equals(new CatchRuleset().RulesetInfo)); } + + [Test] + public void TestUserPreferredRuleset() + { + OverlayRulesetSelector localSelector = null; + + AddStep("Set osu! preferred ruleset", () => API.LocalUser.Value.PlayMode = OsuRuleset.SHORT_NAME); + AddStep("load overlay ruleset selector", () => Child = localSelector = new OverlayRulesetSelector()); + AddAssert("Check osu! selected", () => localSelector.Current.Value.Equals(new OsuRuleset().RulesetInfo)); + + AddStep("Set osu!taiko preferred ruleset", () => API.LocalUser.Value.PlayMode = TaikoRuleset.SHORT_NAME); + AddStep("load overlay ruleset selector", () => Child = localSelector = new OverlayRulesetSelector()); + AddAssert("Check osu!taiko selected", () => localSelector.Current.Value.Equals(new TaikoRuleset().RulesetInfo)); + + AddStep("Set osu!catch preferred ruleset", () => API.LocalUser.Value.PlayMode = CatchRuleset.SHORT_NAME); + AddStep("load overlay ruleset selector", () => Child = localSelector = new OverlayRulesetSelector()); + AddAssert("Check osu!catch selected", () => localSelector.Current.Value.Equals(new CatchRuleset().RulesetInfo)); + + AddStep("Set osu!mania preferred ruleset", () => API.LocalUser.Value.PlayMode = ManiaRuleset.SHORT_NAME); + AddStep("load overlay ruleset selector", () => Child = localSelector = new OverlayRulesetSelector()); + AddAssert("Check osu!mania selected", () => localSelector.Current.Value.Equals(new ManiaRuleset().RulesetInfo)); + } } }