osu/osu.Game.Tests/Visual/Online/TestSceneWikiSidebar.cs

66 lines
1.9 KiB
C#
Raw Normal View History

2021-06-04 06:11:37 +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.
using Markdig.Parsers;
using Markdig.Syntax;
2021-06-04 08:51:23 +00:00
using Markdig.Syntax.Inlines;
2021-06-04 06:11:37 +00:00
using NUnit.Framework;
using osu.Framework.Allocation;
2021-06-04 08:51:23 +00:00
using osu.Game.Graphics.Containers.Markdown;
2021-06-04 06:11:37 +00:00
using osu.Game.Overlays;
using osu.Game.Overlays.Wiki;
namespace osu.Game.Tests.Visual.Online
{
public class TestSceneWikiSidebar : OsuTestScene
{
[Cached]
private readonly OverlayColourProvider colourProvider = new OverlayColourProvider(OverlayColourScheme.Orange);
[Cached]
private readonly OverlayScrollContainer scrollContainer = new OverlayScrollContainer();
private WikiSidebar sidebar;
[SetUp]
public void SetUp() => Schedule(() => Child = sidebar = new WikiSidebar());
[Test]
public void TestNoContent()
{
AddStep("No Content", () => { });
}
[Test]
public void TestOnlyMainTitle()
{
AddStep("Add TOC", () =>
{
for (int i = 0; i < 10; i++)
2021-06-04 08:51:23 +00:00
addTitle($"This is a very long title {i + 1}");
2021-06-04 06:11:37 +00:00
});
}
[Test]
public void TestWithSubtitle()
{
AddStep("Add TOC", () =>
{
for (int i = 0; i < 10; i++)
2021-06-04 08:51:23 +00:00
addTitle($"This is a very long title {i + 1}", i % 4 != 0);
2021-06-04 06:11:37 +00:00
});
}
2021-06-04 08:51:23 +00:00
private void addTitle(string text, bool subtitle = false)
{
2021-06-04 09:00:26 +00:00
var headingBlock = new HeadingBlock(new HeadingBlockParser())
{
Inline = new ContainerInline().AppendChild(new LiteralInline(text)),
Level = subtitle ? 3 : 2,
};
var heading = new OsuMarkdownHeading(headingBlock);
2021-06-04 16:32:42 +00:00
sidebar.AddEntry(headingBlock, heading);
2021-06-04 08:51:23 +00:00
}
2021-06-04 06:11:37 +00:00
}
}