2019-11-30 00:01:07 +00:00
|
|
|
|
// 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.
|
|
|
|
|
|
2022-06-17 07:37:17 +00:00
|
|
|
|
#nullable disable
|
|
|
|
|
|
2019-11-30 00:01:07 +00:00
|
|
|
|
using NUnit.Framework;
|
2019-12-05 06:53:25 +00:00
|
|
|
|
using osu.Framework.Bindables;
|
2021-08-23 10:53:03 +00:00
|
|
|
|
using osu.Framework.Graphics.Containers;
|
|
|
|
|
using osu.Game.Overlays;
|
2019-12-05 06:53:25 +00:00
|
|
|
|
using osu.Game.Overlays.Rankings;
|
2021-08-23 10:53:03 +00:00
|
|
|
|
using osu.Game.Rulesets.Catch;
|
2021-08-23 18:08:59 +00:00
|
|
|
|
using osu.Game.Rulesets.Mania;
|
|
|
|
|
using osu.Game.Rulesets.Osu;
|
2021-08-23 10:53:03 +00:00
|
|
|
|
using osu.Game.Users;
|
2019-11-30 00:01:07 +00:00
|
|
|
|
|
|
|
|
|
namespace osu.Game.Tests.Visual.Online
|
|
|
|
|
{
|
|
|
|
|
public class TestSceneRankingsOverlay : OsuTestScene
|
|
|
|
|
{
|
|
|
|
|
protected override bool UseOnlineAPI => true;
|
|
|
|
|
|
2021-08-23 10:53:03 +00:00
|
|
|
|
private TestRankingsOverlay rankingsOverlay;
|
2019-11-30 00:01:07 +00:00
|
|
|
|
|
2022-07-18 05:40:34 +00:00
|
|
|
|
private readonly Bindable<CountryCode> countryBindable = new Bindable<CountryCode>();
|
2019-12-05 06:53:25 +00:00
|
|
|
|
private readonly Bindable<RankingsScope> scope = new Bindable<RankingsScope>();
|
|
|
|
|
|
2021-08-23 10:53:03 +00:00
|
|
|
|
[SetUp]
|
|
|
|
|
public void SetUp() => Schedule(loadRankingsOverlay);
|
2019-11-30 00:01:07 +00:00
|
|
|
|
|
|
|
|
|
[Test]
|
2021-08-23 18:08:59 +00:00
|
|
|
|
public void TestParentRulesetDecoupledAfterInitialShow()
|
2019-11-30 00:01:07 +00:00
|
|
|
|
{
|
2021-08-23 18:08:59 +00:00
|
|
|
|
AddStep("enable global ruleset", () => Ruleset.Disabled = false);
|
|
|
|
|
AddStep("set global ruleset to osu!catch", () => Ruleset.Value = new CatchRuleset().RulesetInfo);
|
2021-08-23 10:53:03 +00:00
|
|
|
|
AddStep("reload rankings overlay", loadRankingsOverlay);
|
2021-08-23 18:08:59 +00:00
|
|
|
|
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);
|
2019-11-30 00:01:07 +00:00
|
|
|
|
}
|
|
|
|
|
|
2019-12-05 06:53:25 +00:00
|
|
|
|
[Test]
|
|
|
|
|
public void TestFlagScopeDependency()
|
|
|
|
|
{
|
|
|
|
|
AddStep("Set scope to Score", () => scope.Value = RankingsScope.Score);
|
2022-07-16 01:40:37 +00:00
|
|
|
|
AddAssert("Check country is default", () => countryBindable.Value == default);
|
2022-07-18 05:40:34 +00:00
|
|
|
|
AddStep("Set country", () => countryBindable.Value = CountryCode.US);
|
2019-12-05 06:53:25 +00:00
|
|
|
|
AddAssert("Check scope is Performance", () => scope.Value == RankingsScope.Performance);
|
|
|
|
|
}
|
|
|
|
|
|
2019-11-30 00:01:07 +00:00
|
|
|
|
[Test]
|
|
|
|
|
public void TestShowCountry()
|
|
|
|
|
{
|
2022-07-18 05:40:34 +00:00
|
|
|
|
AddStep("Show US", () => rankingsOverlay.ShowCountry(CountryCode.US));
|
2019-11-30 00:01:07 +00:00
|
|
|
|
}
|
|
|
|
|
|
2021-08-23 10:53:03 +00:00
|
|
|
|
private void loadRankingsOverlay()
|
2019-11-30 00:01:07 +00:00
|
|
|
|
{
|
2021-08-23 10:53:03 +00:00
|
|
|
|
Child = rankingsOverlay = new TestRankingsOverlay
|
|
|
|
|
{
|
|
|
|
|
Country = { BindTarget = countryBindable },
|
|
|
|
|
Header = { Current = { BindTarget = scope } },
|
|
|
|
|
State = { Value = Visibility.Visible },
|
|
|
|
|
};
|
2019-11-30 00:01:07 +00:00
|
|
|
|
}
|
2019-12-05 06:53:25 +00:00
|
|
|
|
|
|
|
|
|
private class TestRankingsOverlay : RankingsOverlay
|
|
|
|
|
{
|
2022-07-18 05:40:34 +00:00
|
|
|
|
public new Bindable<CountryCode> Country => base.Country;
|
2019-12-05 06:53:25 +00:00
|
|
|
|
}
|
2019-11-30 00:01:07 +00:00
|
|
|
|
}
|
|
|
|
|
}
|