Add test coverage for new changes

This commit is contained in:
Salman Ahmed
2021-08-23 13:53:03 +03:00
parent f8a7e0bdb6
commit e33c3fcdbf
2 changed files with 18 additions and 40 deletions

View File

@ -1,12 +1,13 @@
// 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.Users;
namespace osu.Game.Tests.Visual.Online
{
@ -14,25 +15,20 @@ 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 TestParentRulesetCopiedOnInitialShow()
{
AddStep("Show", rankingsOverlay.Show);
AddStep("set ruleset", () => Ruleset.Value = new CatchRuleset().RulesetInfo);
AddStep("reload rankings overlay", loadRankingsOverlay);
AddAssert("catch ruleset selected", () => Ruleset.Value.Equals(new CatchRuleset().RulesetInfo));
}
[Test]
@ -50,10 +46,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