1
0
mirror of https://github.com/ppy/osu.git synced 2024-12-27 11:42:58 +08:00
osu-lazer/osu.Game.Tests/Visual/Online/TestSceneWikiSidebar.cs

68 lines
1.9 KiB
C#
Raw Normal View History

2021-06-04 14:11:37 +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
2021-06-04 14:11:37 +08:00
using Markdig.Parsers;
using Markdig.Syntax;
2021-06-04 16:51:23 +08:00
using Markdig.Syntax.Inlines;
2021-06-04 14:11:37 +08:00
using NUnit.Framework;
using osu.Framework.Allocation;
2021-06-04 16:51:23 +08:00
using osu.Game.Graphics.Containers.Markdown;
2021-06-04 14:11:37 +08: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 16:51:23 +08:00
addTitle($"This is a very long title {i + 1}");
2021-06-04 14:11:37 +08:00
});
}
[Test]
public void TestWithSubtitle()
{
AddStep("Add TOC", () =>
{
for (int i = 0; i < 10; i++)
2021-06-04 16:51:23 +08:00
addTitle($"This is a very long title {i + 1}", i % 4 != 0);
2021-06-04 14:11:37 +08:00
});
}
2021-06-04 16:51:23 +08:00
private void addTitle(string text, bool subtitle = false)
{
2021-06-04 17:00:26 +08: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-05 00:32:42 +08:00
sidebar.AddEntry(headingBlock, heading);
2021-06-04 16:51:23 +08:00
}
2021-06-04 14:11:37 +08:00
}
}