1
0
mirror of https://github.com/ppy/osu.git synced 2024-11-16 02:11:05 +08:00
osu-lazer/osu.Game.Tests/Visual/UserInterface/TestSceneSettingsColour.cs

Ignoring revisions in .git-blame-ignore-revs. Click here to bypass and see the normal blame view.

78 lines
2.2 KiB
C#
Raw Normal View History

2024-09-19 22:04:42 +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.
#nullable disable
using System.Linq;
using NUnit.Framework;
using osu.Framework.Graphics;
using osu.Framework.Graphics.Containers;
using osu.Framework.Graphics.Cursor;
using osu.Framework.Testing;
using osu.Framework.Utils;
using osu.Game.Graphics.UserInterfaceV2;
using osu.Game.Overlays.Settings;
using osuTK.Graphics;
using osuTK.Input;
namespace osu.Game.Tests.Visual.UserInterface
{
public partial class TestSceneSettingsColour : OsuManualInputManagerTestScene
{
private SettingsColour component;
[Test]
public void TestColour()
{
createContent();
AddRepeatStep("set random colour", () => component.Current.Value = randomColour(), 4);
}
[Test]
public void TestUserInteractions()
{
createContent();
AddStep("click colour", () =>
{
InputManager.MoveMouseTo(component);
InputManager.Click(MouseButton.Left);
});
AddAssert("colour picker spawned", () => this.ChildrenOfType<OsuColourPicker>().Any());
}
private void createContent()
{
2024-09-20 03:50:59 +08:00
AddStep("create component", () =>
2024-09-19 22:04:42 +08:00
{
2024-09-20 03:50:59 +08:00
Child = new PopoverContainer
2024-09-19 22:04:42 +08:00
{
2024-09-20 03:50:59 +08:00
RelativeSizeAxes = Axes.Both,
Child = new FillFlowContainer
2024-09-19 22:04:42 +08:00
{
2024-09-20 03:50:59 +08:00
Anchor = Anchor.Centre,
Origin = Anchor.Centre,
Width = 500,
AutoSizeAxes = Axes.Y,
Children = new Drawable[]
2024-09-19 22:04:42 +08:00
{
2024-09-20 03:50:59 +08:00
component = new SettingsColour
{
LabelText = "a sample component",
},
2024-09-19 22:04:42 +08:00
},
},
2024-09-20 03:50:59 +08:00
};
});
2024-09-19 22:04:42 +08:00
}
private Colour4 randomColour() => new Color4(
RNG.NextSingle(),
RNG.NextSingle(),
RNG.NextSingle(),
1);
}
}