mirror of
https://github.com/ppy/osu.git
synced 2025-01-26 20:23:00 +08:00
Add testing for colour palette behaviour
This commit is contained in:
parent
3f005886d6
commit
4334121e8e
@ -1,17 +1,21 @@
|
|||||||
// Copyright (c) ppy Pty Ltd <contact@ppy.sh>. Licensed under the MIT Licence.
|
// 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.
|
// See the LICENCE file in the repository root for full licence text.
|
||||||
|
|
||||||
|
using System.Linq;
|
||||||
using NUnit.Framework;
|
using NUnit.Framework;
|
||||||
using osu.Framework.Graphics;
|
using osu.Framework.Graphics;
|
||||||
using osu.Framework.Graphics.Containers;
|
using osu.Framework.Graphics.Containers;
|
||||||
|
using osu.Framework.Testing;
|
||||||
using osu.Framework.Utils;
|
using osu.Framework.Utils;
|
||||||
using osu.Game.Graphics.Cursor;
|
using osu.Game.Graphics.Cursor;
|
||||||
|
using osu.Game.Graphics.UserInterface;
|
||||||
using osu.Game.Graphics.UserInterfaceV2;
|
using osu.Game.Graphics.UserInterfaceV2;
|
||||||
using osuTK.Graphics;
|
using osuTK.Graphics;
|
||||||
|
using osuTK.Input;
|
||||||
|
|
||||||
namespace osu.Game.Tests.Visual.UserInterface
|
namespace osu.Game.Tests.Visual.UserInterface
|
||||||
{
|
{
|
||||||
public class TestSceneLabelledColourPalette : OsuTestScene
|
public class TestSceneLabelledColourPalette : OsuManualInputManagerTestScene
|
||||||
{
|
{
|
||||||
private LabelledColourPalette component;
|
private LabelledColourPalette component;
|
||||||
|
|
||||||
@ -31,6 +35,22 @@ namespace osu.Game.Tests.Visual.UserInterface
|
|||||||
}, 8);
|
}, 8);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
[Test]
|
||||||
|
public void TestUserInteractions()
|
||||||
|
{
|
||||||
|
createColourPalette();
|
||||||
|
assertColourCount(4);
|
||||||
|
|
||||||
|
clickAddColour();
|
||||||
|
assertColourCount(5);
|
||||||
|
|
||||||
|
deleteFirstColour();
|
||||||
|
assertColourCount(4);
|
||||||
|
|
||||||
|
clickFirstColour();
|
||||||
|
AddAssert("colour picker spawned", () => this.ChildrenOfType<OsuColourPicker>().Any());
|
||||||
|
}
|
||||||
|
|
||||||
private void createColourPalette(bool hasDescription = false)
|
private void createColourPalette(bool hasDescription = false)
|
||||||
{
|
{
|
||||||
AddStep("create component", () =>
|
AddStep("create component", () =>
|
||||||
@ -71,5 +91,36 @@ namespace osu.Game.Tests.Visual.UserInterface
|
|||||||
RNG.NextSingle(),
|
RNG.NextSingle(),
|
||||||
RNG.NextSingle(),
|
RNG.NextSingle(),
|
||||||
1);
|
1);
|
||||||
|
|
||||||
|
private void assertColourCount(int count) => AddAssert($"colour count is {count}", () => component.Colours.Count == count);
|
||||||
|
|
||||||
|
private void clickAddColour() => AddStep("click new colour button", () =>
|
||||||
|
{
|
||||||
|
InputManager.MoveMouseTo(this.ChildrenOfType<ColourPalette.AddColourButton>().Single());
|
||||||
|
InputManager.Click(MouseButton.Left);
|
||||||
|
});
|
||||||
|
|
||||||
|
private void clickFirstColour() => AddStep("click first colour", () =>
|
||||||
|
{
|
||||||
|
InputManager.MoveMouseTo(this.ChildrenOfType<ColourDisplay>().First());
|
||||||
|
InputManager.Click(MouseButton.Left);
|
||||||
|
});
|
||||||
|
|
||||||
|
private void deleteFirstColour()
|
||||||
|
{
|
||||||
|
AddStep("right-click first colour", () =>
|
||||||
|
{
|
||||||
|
InputManager.MoveMouseTo(this.ChildrenOfType<ColourDisplay>().First());
|
||||||
|
InputManager.Click(MouseButton.Right);
|
||||||
|
});
|
||||||
|
|
||||||
|
AddUntilStep("wait for menu", () => this.ChildrenOfType<OsuContextMenu>().Any());
|
||||||
|
|
||||||
|
AddStep("click delete", () =>
|
||||||
|
{
|
||||||
|
InputManager.MoveMouseTo(this.ChildrenOfType<DrawableOsuMenuItem>().Single());
|
||||||
|
InputManager.Click(MouseButton.Left);
|
||||||
|
});
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -116,7 +116,7 @@ namespace osu.Game.Graphics.UserInterfaceV2
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private class AddColourButton : CompositeDrawable
|
internal class AddColourButton : CompositeDrawable
|
||||||
{
|
{
|
||||||
public Action Action
|
public Action Action
|
||||||
{
|
{
|
||||||
|
Loading…
Reference in New Issue
Block a user