2021-10-17 00:12:02 +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.
|
|
|
|
|
|
2023-12-06 03:50:05 +08:00
|
|
|
|
using System.Linq;
|
|
|
|
|
using NUnit.Framework;
|
2021-10-17 00:12:02 +08:00
|
|
|
|
using osu.Framework.Graphics;
|
2023-12-06 03:50:05 +08:00
|
|
|
|
using osu.Framework.Graphics.Containers;
|
|
|
|
|
using osu.Framework.Graphics.UserInterface;
|
|
|
|
|
using osu.Framework.Input.Events;
|
|
|
|
|
using osu.Framework.Input.States;
|
|
|
|
|
using osu.Framework.Testing;
|
2021-10-17 00:12:02 +08:00
|
|
|
|
using osu.Game.Beatmaps;
|
|
|
|
|
using osu.Game.Graphics.UserInterface;
|
2023-12-06 03:50:05 +08:00
|
|
|
|
using osu.Game.Input.Bindings;
|
2021-10-17 00:12:02 +08:00
|
|
|
|
|
|
|
|
|
namespace osu.Game.Tests.Visual.UserInterface
|
|
|
|
|
{
|
|
|
|
|
public partial class TestSceneOsuDropdown : ThemeComparisonTestScene
|
|
|
|
|
{
|
|
|
|
|
protected override Drawable CreateContent() =>
|
2021-11-24 17:42:47 +08:00
|
|
|
|
new OsuEnumDropdown<BeatmapOnlineStatus>
|
2021-10-17 00:12:02 +08:00
|
|
|
|
{
|
|
|
|
|
Anchor = Anchor.Centre,
|
2023-12-06 03:50:05 +08:00
|
|
|
|
Origin = Anchor.TopCentre,
|
2021-10-17 00:12:02 +08:00
|
|
|
|
Width = 150
|
|
|
|
|
};
|
2023-12-06 03:50:05 +08:00
|
|
|
|
|
|
|
|
|
[Test]
|
|
|
|
|
// todo: this can be written much better if ThemeComparisonTestScene has a manual input manager
|
|
|
|
|
public void TestBackAction()
|
|
|
|
|
{
|
|
|
|
|
AddStep("open", () => dropdown().ChildrenOfType<Menu>().Single().Open());
|
|
|
|
|
AddStep("press back", () => dropdown().OnPressed(new KeyBindingPressEvent<GlobalAction>(new InputState(), GlobalAction.Back)));
|
|
|
|
|
AddAssert("closed", () => dropdown().ChildrenOfType<Menu>().Single().State == MenuState.Closed);
|
|
|
|
|
|
|
|
|
|
AddStep("open", () => dropdown().ChildrenOfType<Menu>().Single().Open());
|
|
|
|
|
AddStep("type something", () => dropdown().ChildrenOfType<DropdownSearchBar>().Single().SearchTerm.Value = "something");
|
|
|
|
|
AddAssert("search bar visible", () => dropdown().ChildrenOfType<DropdownSearchBar>().Single().State.Value == Visibility.Visible);
|
|
|
|
|
AddStep("press back", () => dropdown().OnPressed(new KeyBindingPressEvent<GlobalAction>(new InputState(), GlobalAction.Back)));
|
|
|
|
|
AddAssert("text clear", () => dropdown().ChildrenOfType<DropdownSearchBar>().Single().SearchTerm.Value == string.Empty);
|
|
|
|
|
AddAssert("search bar hidden", () => dropdown().ChildrenOfType<DropdownSearchBar>().Single().State.Value == Visibility.Hidden);
|
|
|
|
|
AddAssert("still open", () => dropdown().ChildrenOfType<Menu>().Single().State == MenuState.Open);
|
|
|
|
|
AddStep("press back", () => dropdown().OnPressed(new KeyBindingPressEvent<GlobalAction>(new InputState(), GlobalAction.Back)));
|
|
|
|
|
AddAssert("closed", () => dropdown().ChildrenOfType<Menu>().Single().State == MenuState.Closed);
|
|
|
|
|
|
|
|
|
|
OsuEnumDropdown<BeatmapOnlineStatus> dropdown() => this.ChildrenOfType<OsuEnumDropdown<BeatmapOnlineStatus>>().First();
|
|
|
|
|
}
|
2021-10-17 00:12:02 +08:00
|
|
|
|
}
|
|
|
|
|
}
|