1
0
mirror of https://github.com/ppy/osu.git synced 2024-12-26 03:43:22 +08:00
osu-lazer/osu.Game.Tests/Visual/UserInterface/TestSceneLabelledColourPalette.cs

71 lines
2.2 KiB
C#
Raw Normal View History

2021-04-19 01:29:04 +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 NUnit.Framework;
using osu.Framework.Graphics;
using osu.Framework.Graphics.Containers;
using osu.Framework.Utils;
2021-04-19 01:29:04 +08:00
using osu.Game.Graphics.UserInterfaceV2;
using osuTK.Graphics;
namespace osu.Game.Tests.Visual.UserInterface
{
public class TestSceneLabelledColourPalette : OsuTestScene
{
private LabelledColourPalette component;
[Test]
public void TestPalette([Values] bool hasDescription)
{
createColourPalette(hasDescription);
AddRepeatStep("add random colour", () => component.Colours.Add(randomColour()), 4);
AddStep("set custom prefix", () => component.ColourNamePrefix = "Combo");
AddRepeatStep("remove random colour", () =>
{
if (component.Colours.Count > 0)
component.Colours.RemoveAt(RNG.Next(component.Colours.Count));
}, 8);
}
2021-04-19 01:29:04 +08:00
private void createColourPalette(bool hasDescription = false)
{
AddStep("create component", () =>
{
Child = new Container
{
Anchor = Anchor.Centre,
Origin = Anchor.Centre,
Width = 500,
AutoSizeAxes = Axes.Y,
Child = component = new LabelledColourPalette
{
Anchor = Anchor.Centre,
Origin = Anchor.Centre,
2021-04-19 01:56:03 +08:00
ColourNamePrefix = "My colour #"
2021-04-19 01:29:04 +08:00
}
};
component.Label = "a sample component";
component.Description = hasDescription ? "this text describes the component" : string.Empty;
component.Colours.AddRange(new[]
{
Color4.DarkRed,
Color4.Aquamarine,
Color4.Goldenrod,
Color4.Gainsboro
});
});
}
private Color4 randomColour() => new Color4(
RNG.NextSingle(),
RNG.NextSingle(),
RNG.NextSingle(),
1);
2021-04-19 01:29:04 +08:00
}
}