1
0
mirror of https://github.com/ppy/osu.git synced 2024-12-14 08:52:55 +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.

76 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.
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
{
2024-09-21 00:07:26 +08:00
private SettingsColour? component;
2024-09-19 22:04:42 +08:00
[Test]
public void TestColour()
{
createContent();
2024-09-21 00:07:26 +08:00
AddRepeatStep("set random colour", () => component!.Current.Value = randomColour(), 4);
2024-09-19 22:04:42 +08:00
}
[Test]
public void TestUserInteractions()
{
createContent();
AddStep("click colour", () =>
{
2024-09-21 00:07:26 +08:00
InputManager.MoveMouseTo(component!);
2024-09-19 22:04:42 +08:00
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);
}
}