2022-05-09 18:25:22 +08:00
|
|
|
// Copyright (c) ppy Pty Ltd <contact@ppy.sh>. Licensed under the MIT Licence.
|
2019-01-24 16:43:03 +08:00
|
|
|
// See the LICENCE file in the repository root for full licence text.
|
2018-04-13 17:19:50 +08:00
|
|
|
|
2022-05-09 18:44:18 +08:00
|
|
|
using System.Linq;
|
2018-03-02 14:34:31 +08:00
|
|
|
using NUnit.Framework;
|
2017-09-18 21:32:49 +08:00
|
|
|
using osu.Framework.Graphics;
|
2019-10-28 17:37:58 +08:00
|
|
|
using osu.Framework.Graphics.Containers;
|
2022-05-09 18:44:18 +08:00
|
|
|
using osu.Framework.Testing;
|
2017-09-18 21:32:49 +08:00
|
|
|
using osu.Game.Graphics.UserInterface;
|
2022-05-09 18:44:18 +08:00
|
|
|
using osu.Game.Overlays;
|
2017-10-03 00:33:58 +08:00
|
|
|
using osu.Game.Screens.Play.HUD;
|
2018-01-14 03:25:09 +08:00
|
|
|
using osu.Game.Screens.Play.PlayerSettings;
|
2022-05-09 18:44:18 +08:00
|
|
|
using osuTK.Input;
|
2018-04-13 17:19:50 +08:00
|
|
|
|
2022-05-09 18:25:22 +08:00
|
|
|
namespace osu.Game.Tests.Visual.UserInterface
|
2017-09-18 21:32:49 +08:00
|
|
|
{
|
2018-03-02 14:34:31 +08:00
|
|
|
[TestFixture]
|
2022-05-09 18:44:18 +08:00
|
|
|
public class TestSceneSettingsToolboxGroup : OsuManualInputManagerTestScene
|
2017-09-18 21:32:49 +08:00
|
|
|
{
|
2022-05-09 18:25:22 +08:00
|
|
|
public TestSceneSettingsToolboxGroup()
|
2017-09-18 21:32:49 +08:00
|
|
|
{
|
|
|
|
ExampleContainer container;
|
2018-04-13 17:19:50 +08:00
|
|
|
|
2018-01-14 03:25:09 +08:00
|
|
|
Add(new PlayerSettingsOverlay
|
2017-09-18 21:32:49 +08:00
|
|
|
{
|
|
|
|
Anchor = Anchor.TopRight,
|
|
|
|
Origin = Anchor.TopRight,
|
2019-10-28 17:37:58 +08:00
|
|
|
State = { Value = Visibility.Visible }
|
2017-09-18 21:32:49 +08:00
|
|
|
});
|
2018-04-13 17:19:50 +08:00
|
|
|
|
2017-09-18 21:32:49 +08:00
|
|
|
Add(container = new ExampleContainer());
|
2018-04-13 17:19:50 +08:00
|
|
|
|
2017-11-26 00:52:52 +08:00
|
|
|
AddStep(@"Add button", () => container.Add(new TriangleButton
|
2017-09-18 21:32:49 +08:00
|
|
|
{
|
|
|
|
RelativeSizeAxes = Axes.X,
|
|
|
|
Text = @"Button",
|
|
|
|
}));
|
2018-04-13 17:19:50 +08:00
|
|
|
|
2018-01-14 03:25:09 +08:00
|
|
|
AddStep(@"Add checkbox", () => container.Add(new PlayerCheckbox
|
2017-09-18 21:32:49 +08:00
|
|
|
{
|
|
|
|
LabelText = "Checkbox",
|
|
|
|
}));
|
2018-04-13 17:19:50 +08:00
|
|
|
|
2017-09-18 21:32:49 +08:00
|
|
|
AddStep(@"Add textbox", () => container.Add(new FocusedTextBox
|
|
|
|
{
|
|
|
|
RelativeSizeAxes = Axes.X,
|
|
|
|
Height = 30,
|
|
|
|
PlaceholderText = "Textbox",
|
|
|
|
HoldFocus = false,
|
|
|
|
}));
|
|
|
|
}
|
2018-04-13 17:19:50 +08:00
|
|
|
|
2022-05-09 18:44:18 +08:00
|
|
|
[Test]
|
|
|
|
public void TestClickExpandButtonMultipleTimes()
|
|
|
|
{
|
|
|
|
SettingsToolboxGroup group = null;
|
|
|
|
|
|
|
|
AddAssert("group expanded by default", () => (group = this.ChildrenOfType<SettingsToolboxGroup>().First()).Expanded.Value);
|
|
|
|
AddStep("click expand button multiple times", () =>
|
|
|
|
{
|
|
|
|
InputManager.MoveMouseTo(group.ChildrenOfType<IconButton>().Single());
|
|
|
|
Scheduler.AddDelayed(() => InputManager.Click(MouseButton.Left), 100);
|
|
|
|
Scheduler.AddDelayed(() => InputManager.Click(MouseButton.Left), 200);
|
|
|
|
Scheduler.AddDelayed(() => InputManager.Click(MouseButton.Left), 300);
|
|
|
|
});
|
|
|
|
AddAssert("group contracted", () => !group.Expanded.Value);
|
|
|
|
}
|
|
|
|
|
2018-01-16 01:52:52 +08:00
|
|
|
private class ExampleContainer : PlayerSettingsGroup
|
2017-09-18 21:32:49 +08:00
|
|
|
{
|
2020-09-09 17:48:02 +08:00
|
|
|
public ExampleContainer()
|
|
|
|
: base("example")
|
|
|
|
{
|
|
|
|
}
|
2017-09-18 21:32:49 +08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|