1
0
mirror of https://github.com/ppy/osu.git synced 2024-11-16 14:57:25 +08:00
osu-lazer/osu.Game.Tests/Visual/Online/TestSceneNewsHeader.cs

56 lines
1.8 KiB
C#
Raw Normal View History

2020-07-12 20:57:18 +08: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 15:37:17 +08:00
#nullable disable
2020-07-12 20:57:18 +08:00
using NUnit.Framework;
using osu.Game.Overlays.News;
using osu.Framework.Graphics;
using osu.Game.Overlays;
using osu.Framework.Allocation;
namespace osu.Game.Tests.Visual.Online
{
2022-11-24 13:32:20 +08:00
public partial class TestSceneNewsHeader : OsuTestScene
2020-07-12 20:57:18 +08:00
{
[Cached]
private readonly OverlayColourProvider colourProvider = new OverlayColourProvider(OverlayColourScheme.Purple);
private TestHeader header;
[SetUp]
2020-07-12 21:13:48 +08:00
public void Setup() => Schedule(() =>
2020-07-12 20:57:18 +08:00
{
Child = header = new TestHeader
{
Anchor = Anchor.Centre,
Origin = Anchor.Centre
};
2020-07-12 21:13:48 +08:00
});
2020-07-12 20:57:18 +08:00
[Test]
public void TestControl()
{
AddAssert("Front page selected", () => header.Current.Value == NewsHeader.FrontPageString);
2020-07-12 20:57:18 +08:00
AddAssert("1 tab total", () => header.TabCount == 1);
AddStep("Set article 1", () => header.SetArticle("1"));
AddAssert("Article 1 selected", () => header.Current.Value == "1");
AddAssert("2 tabs total", () => header.TabCount == 2);
AddStep("Set article 2", () => header.SetArticle("2"));
AddAssert("Article 2 selected", () => header.Current.Value == "2");
AddAssert("2 tabs total", () => header.TabCount == 2);
AddStep("Set front page", () => header.SetFrontPage());
AddAssert("Front page selected", () => header.Current.Value == NewsHeader.FrontPageString);
2020-07-12 20:57:18 +08:00
AddAssert("1 tab total", () => header.TabCount == 1);
}
2022-11-24 13:32:20 +08:00
private partial class TestHeader : NewsHeader
2020-07-12 20:57:18 +08:00
{
public int TabCount => TabControl.Items.Count;
}
}
}