Merge pull request #14444 from frenzibyte/decouple-ruleset-bindables

Decouple rankings overlay's ruleset selector from the game-wide ruleset bindable
This commit is contained in:
Dean Herbert
2021-08-24 11:58:13 +09:00
committed by GitHub
2 changed files with 46 additions and 19 deletions

View File

@ -1,12 +1,15 @@
// Copyright (c) ppy Pty Ltd <contact@ppy.sh>. Licensed under the MIT Licence.
// See the LICENCE file in the repository root for full licence text.
using osu.Framework.Allocation;
using osu.Game.Overlays;
using NUnit.Framework;
using osu.Game.Users;
using osu.Framework.Bindables;
using osu.Framework.Graphics.Containers;
using osu.Game.Overlays;
using osu.Game.Overlays.Rankings;
using osu.Game.Rulesets.Catch;
using osu.Game.Rulesets.Mania;
using osu.Game.Rulesets.Osu;
using osu.Game.Users;
namespace osu.Game.Tests.Visual.Online
{
@ -14,25 +17,29 @@ namespace osu.Game.Tests.Visual.Online
{
protected override bool UseOnlineAPI => true;
[Cached(typeof(RankingsOverlay))]
private readonly RankingsOverlay rankingsOverlay;
private TestRankingsOverlay rankingsOverlay;
private readonly Bindable<Country> countryBindable = new Bindable<Country>();
private readonly Bindable<RankingsScope> scope = new Bindable<RankingsScope>();
public TestSceneRankingsOverlay()
{
Add(rankingsOverlay = new TestRankingsOverlay
{
Country = { BindTarget = countryBindable },
Header = { Current = { BindTarget = scope } },
});
}
[SetUp]
public void SetUp() => Schedule(loadRankingsOverlay);
[Test]
public void TestShow()
public void TestParentRulesetDecoupledAfterInitialShow()
{
AddStep("Show", rankingsOverlay.Show);
AddStep("enable global ruleset", () => Ruleset.Disabled = false);
AddStep("set global ruleset to osu!catch", () => Ruleset.Value = new CatchRuleset().RulesetInfo);
AddStep("reload rankings overlay", loadRankingsOverlay);
AddAssert("rankings ruleset set to osu!catch", () => rankingsOverlay.Header.Ruleset.Value.ShortName == CatchRuleset.SHORT_NAME);
AddStep("set global ruleset to osu!", () => Ruleset.Value = new OsuRuleset().RulesetInfo);
AddAssert("rankings ruleset still osu!catch", () => rankingsOverlay.Header.Ruleset.Value.ShortName == CatchRuleset.SHORT_NAME);
AddStep("disable global ruleset", () => Ruleset.Disabled = true);
AddAssert("rankings ruleset still enabled", () => rankingsOverlay.Header.Ruleset.Disabled == false);
AddStep("set rankings ruleset to osu!mania", () => rankingsOverlay.Header.Ruleset.Value = new ManiaRuleset().RulesetInfo);
AddAssert("rankings ruleset set to osu!mania", () => rankingsOverlay.Header.Ruleset.Value.ShortName == ManiaRuleset.SHORT_NAME);
}
[Test]
@ -50,10 +57,14 @@ namespace osu.Game.Tests.Visual.Online
AddStep("Show US", () => rankingsOverlay.ShowCountry(us_country));
}
[Test]
public void TestHide()
private void loadRankingsOverlay()
{
AddStep("Hide", rankingsOverlay.Hide);
Child = rankingsOverlay = new TestRankingsOverlay
{
Country = { BindTarget = countryBindable },
Header = { Current = { BindTarget = scope } },
State = { Value = Visibility.Visible },
};
}
private static readonly Country us_country = new Country