2022-01-17 14:59:14 +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.
|
|
|
|
|
2022-06-17 15:37:17 +08:00
|
|
|
#nullable disable
|
|
|
|
|
2022-01-17 14:59:14 +08:00
|
|
|
using System.Linq;
|
|
|
|
using NUnit.Framework;
|
|
|
|
using osu.Framework.Allocation;
|
|
|
|
using osu.Framework.Extensions;
|
|
|
|
using osu.Framework.Input.Bindings;
|
|
|
|
using osu.Framework.Testing;
|
|
|
|
using osu.Game.Database;
|
|
|
|
using osu.Game.Graphics.UserInterface;
|
|
|
|
using osu.Game.Input.Bindings;
|
|
|
|
using osu.Game.Overlays.Settings.Sections.Input;
|
|
|
|
using osu.Game.Screens.Play;
|
2023-03-07 15:28:54 +08:00
|
|
|
using osu.Game.Screens.Play.HUD;
|
2022-01-17 14:59:14 +08:00
|
|
|
using osu.Game.Screens.Select;
|
|
|
|
using osu.Game.Tests.Beatmaps.IO;
|
|
|
|
using osuTK.Input;
|
|
|
|
|
|
|
|
namespace osu.Game.Tests.Visual.Navigation
|
|
|
|
{
|
2022-11-24 13:32:20 +08:00
|
|
|
public partial class TestSceneChangeAndUseGameplayBindings : OsuGameTestScene
|
2022-01-17 14:59:14 +08:00
|
|
|
{
|
|
|
|
[Test]
|
|
|
|
public void TestGameplayKeyBindings()
|
|
|
|
{
|
|
|
|
AddAssert("databased key is default", () => firstOsuRulesetKeyBindings.KeyCombination.Keys.SequenceEqual(new[] { InputKey.Z }));
|
|
|
|
|
|
|
|
AddStep("open settings", () => { Game.Settings.Show(); });
|
|
|
|
|
|
|
|
// Until step requires as settings has a delayed load.
|
|
|
|
AddUntilStep("wait for button", () => configureBindingsButton?.Enabled.Value == true);
|
|
|
|
AddStep("scroll to section", () => Game.Settings.SectionsContainer.ScrollTo(configureBindingsButton));
|
|
|
|
AddStep("press button", () => configureBindingsButton.TriggerClick());
|
|
|
|
AddUntilStep("wait for panel", () => keyBindingPanel?.IsLoaded == true);
|
|
|
|
AddUntilStep("wait for osu subsection", () => osuBindingSubsection?.IsLoaded == true);
|
|
|
|
AddStep("scroll to section", () => keyBindingPanel.SectionsContainer.ScrollTo(osuBindingSubsection));
|
|
|
|
AddWaitStep("wait for scroll to end", 3);
|
|
|
|
AddStep("start rebinding first osu! key", () =>
|
|
|
|
{
|
|
|
|
var button = osuBindingSubsection.ChildrenOfType<KeyBindingRow>().First();
|
|
|
|
|
|
|
|
InputManager.MoveMouseTo(button);
|
|
|
|
InputManager.Click(MouseButton.Left);
|
|
|
|
});
|
|
|
|
|
|
|
|
AddStep("Press 's'", () => InputManager.Key(Key.S));
|
|
|
|
|
|
|
|
AddUntilStep("wait for database updated", () => firstOsuRulesetKeyBindings.KeyCombination.Keys.SequenceEqual(new[] { InputKey.S }));
|
|
|
|
|
|
|
|
AddStep("close settings", () => Game.Settings.Hide());
|
|
|
|
|
2022-01-18 14:00:27 +08:00
|
|
|
AddStep("import beatmap", () => BeatmapImportHelper.LoadQuickOszIntoOsu(Game).WaitSafely());
|
2022-01-25 13:30:00 +08:00
|
|
|
|
2022-01-17 14:59:14 +08:00
|
|
|
PushAndConfirm(() => new PlaySongSelect());
|
|
|
|
|
2022-01-25 13:30:00 +08:00
|
|
|
AddUntilStep("wait for selection", () => !Game.Beatmap.IsDefault);
|
2022-11-12 13:16:46 +08:00
|
|
|
AddUntilStep("wait for carousel load", () => songSelect.BeatmapSetsLoaded);
|
2022-01-25 13:30:00 +08:00
|
|
|
|
2022-01-17 14:59:14 +08:00
|
|
|
AddStep("enter gameplay", () => InputManager.Key(Key.Enter));
|
|
|
|
|
2022-01-26 02:37:11 +08:00
|
|
|
AddUntilStep("wait for player", () =>
|
|
|
|
{
|
2022-04-24 04:14:14 +08:00
|
|
|
DismissAnyNotifications();
|
2022-01-26 02:37:11 +08:00
|
|
|
return player != null;
|
|
|
|
});
|
|
|
|
|
2022-01-17 14:59:14 +08:00
|
|
|
AddUntilStep("wait for gameplay", () => player?.IsBreakTime.Value == false);
|
|
|
|
|
|
|
|
AddStep("press 'z'", () => InputManager.Key(Key.Z));
|
2023-02-17 06:20:34 +08:00
|
|
|
AddAssert("key counter didn't increase", () => keyCounter.CountPresses.Value == 0);
|
2022-01-17 14:59:14 +08:00
|
|
|
|
|
|
|
AddStep("press 's'", () => InputManager.Key(Key.S));
|
2023-02-17 06:20:34 +08:00
|
|
|
AddAssert("key counter did increase", () => keyCounter.CountPresses.Value == 1);
|
2022-01-17 14:59:14 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
private KeyBindingsSubsection osuBindingSubsection => keyBindingPanel
|
|
|
|
.ChildrenOfType<VariantBindingsSubsection>()
|
|
|
|
.FirstOrDefault(s => s.Ruleset.ShortName == "osu");
|
|
|
|
|
|
|
|
private OsuButton configureBindingsButton => Game.Settings
|
|
|
|
.ChildrenOfType<BindingSettings>().SingleOrDefault()?
|
2023-06-25 01:04:05 +08:00
|
|
|
.ChildrenOfType<OsuButton>()
|
2022-01-17 14:59:14 +08:00
|
|
|
.First(b => b.Text.ToString() == "Configure");
|
|
|
|
|
|
|
|
private KeyBindingPanel keyBindingPanel => Game.Settings
|
|
|
|
.ChildrenOfType<KeyBindingPanel>().SingleOrDefault();
|
|
|
|
|
|
|
|
private RealmKeyBinding firstOsuRulesetKeyBindings => Game.Dependencies
|
2022-01-24 19:11:36 +08:00
|
|
|
.Get<RealmAccess>().Realm
|
2022-01-17 14:59:14 +08:00
|
|
|
.All<RealmKeyBinding>()
|
|
|
|
.AsEnumerable()
|
|
|
|
.First(k => k.RulesetName == "osu" && k.ActionInt == 0);
|
|
|
|
|
2022-11-12 13:16:46 +08:00
|
|
|
private Screens.Select.SongSelect songSelect => Game.ScreenStack.CurrentScreen as Screens.Select.SongSelect;
|
|
|
|
|
2022-01-17 14:59:14 +08:00
|
|
|
private Player player => Game.ScreenStack.CurrentScreen as Player;
|
|
|
|
|
|
|
|
private KeyCounter keyCounter => player.ChildrenOfType<KeyCounter>().First();
|
|
|
|
}
|
|
|
|
}
|