osu/osu.Game.Tests/Visual/UserInterface/TestSceneCommentRepliesButton.cs

68 lines
2.1 KiB
C#
Raw Normal View History

2020-07-11 04:47:17 +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 osu.Game.Overlays.Comments.Buttons;
using osu.Framework.Graphics;
using osu.Framework.Allocation;
using osu.Game.Overlays;
using osu.Framework.Graphics.Containers;
using osuTK;
2020-07-12 10:19:28 +00:00
using NUnit.Framework;
using System.Linq;
using osu.Framework.Graphics.Sprites;
2020-07-12 10:36:42 +00:00
using osu.Framework.Testing;
2020-07-11 04:47:17 +00:00
namespace osu.Game.Tests.Visual.UserInterface
{
public class TestSceneCommentRepliesButton : OsuTestScene
{
[Cached]
private readonly OverlayColourProvider colourProvider = new OverlayColourProvider(OverlayColourScheme.Blue);
2020-07-12 10:19:28 +00:00
private readonly TestButton button;
2020-07-11 04:47:17 +00:00
public TestSceneCommentRepliesButton()
{
Child = new FillFlowContainer
{
Anchor = Anchor.Centre,
Origin = Anchor.Centre,
AutoSizeAxes = Axes.Both,
Direction = FillDirection.Vertical,
Spacing = new Vector2(0, 10),
Children = new Drawable[]
{
2020-07-12 10:19:28 +00:00
button = new TestButton(),
new LoadRepliesButton
{
Action = () => { }
},
2020-07-11 05:13:11 +00:00
new ShowRepliesButton(1),
2020-07-11 04:47:17 +00:00
new ShowRepliesButton(2)
}
};
}
2020-07-12 10:19:28 +00:00
[Test]
2020-07-14 00:01:14 +00:00
public void TestArrowDirection()
2020-07-12 10:19:28 +00:00
{
2020-07-14 00:01:14 +00:00
AddStep("Set upwards", () => button.SetIconDirection(true));
2020-07-12 10:19:28 +00:00
AddAssert("Icon facing upwards", () => button.Icon.Scale.Y == -1);
2020-07-14 00:01:14 +00:00
AddStep("Set downwards", () => button.SetIconDirection(false));
2020-07-12 10:19:28 +00:00
AddAssert("Icon facing downwards", () => button.Icon.Scale.Y == 1);
}
2020-07-11 04:47:17 +00:00
private class TestButton : CommentRepliesButton
{
2020-07-12 10:36:42 +00:00
public SpriteIcon Icon => this.ChildrenOfType<SpriteIcon>().First();
2020-07-12 10:19:28 +00:00
2020-07-12 09:27:26 +00:00
public TestButton()
{
Text = "sample text";
}
2020-07-12 10:19:28 +00:00
2020-07-14 00:01:14 +00:00
public new void SetIconDirection(bool upwards) => base.SetIconDirection(upwards);
2020-07-11 04:47:17 +00:00
}
}
}