1
0
mirror of https://github.com/ppy/osu.git synced 2024-11-11 13:37:25 +08:00

Merge pull request #14116 from peppy/update-platform-action-triggers

Update existing test to make use of `ManualInputManager.Keys`
This commit is contained in:
Dan Balasescu 2021-08-04 19:36:39 +09:00 committed by GitHub
commit 5a6636ae5c
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
36 changed files with 55 additions and 66 deletions

View File

@ -52,7 +52,7 @@
</ItemGroup>
<ItemGroup>
<PackageReference Include="ppy.osu.Game.Resources" Version="2021.803.0" />
<PackageReference Include="ppy.osu.Framework.Android" Version="2021.803.0" />
<PackageReference Include="ppy.osu.Framework.Android" Version="2021.804.0" />
</ItemGroup>
<ItemGroup Label="Transitive Dependencies">
<!-- Realm needs to be directly referenced in all Xamarin projects, as it will not pull in its transitive dependencies otherwise. -->

View File

@ -75,7 +75,7 @@ namespace osu.Game.Tests.Visual.Editing
AddAssert("Hitcircle button not clickable", () => !hitObjectComposer.ChildrenOfType<EditorRadioButton>().First(d => d.Button.Label == "HitCircle").Enabled.Value);
AddStep("Add timing point", () => editorBeatmap.ControlPointInfo.Add(0, new TimingControlPoint()));
AddAssert("Hitcircle button is clickable", () => hitObjectComposer.ChildrenOfType<EditorRadioButton>().First(d => d.Button.Label == "HitCircle").Enabled.Value);
AddStep("Change to hitcircle", () => hitObjectComposer.ChildrenOfType<EditorRadioButton>().First(d => d.Button.Label == "HitCircle").Click());
AddStep("Change to hitcircle", () => hitObjectComposer.ChildrenOfType<EditorRadioButton>().First(d => d.Button.Label == "HitCircle").TriggerClick());
AddAssert("Tool changed", () => hitObjectComposer.ChildrenOfType<ComposeBlueprintContainer>().First().CurrentTool is HitCircleCompositionTool);
}

View File

@ -228,7 +228,7 @@ namespace osu.Game.Tests.Visual.Gameplay
var lastAction = pauseOverlay.OnRetry;
pauseOverlay.OnRetry = () => triggered = true;
getButton(1).Click();
getButton(1).TriggerClick();
pauseOverlay.OnRetry = lastAction;
});

View File

@ -42,7 +42,7 @@ namespace osu.Game.Tests.Visual.Multiplayer
AddAssert("has 2 rooms", () => container.Rooms.Count == 2);
AddAssert("first room removed", () => container.Rooms.All(r => r.Room.RoomID.Value != 0));
AddStep("select first room", () => container.Rooms.First().Click());
AddStep("select first room", () => container.Rooms.First().TriggerClick());
AddAssert("first room selected", () => checkRoomSelected(RoomManager.Rooms.First()));
}

View File

@ -209,7 +209,7 @@ namespace osu.Game.Tests.Visual.Multiplayer
DrawableRoom.PasswordEntryPopover passwordEntryPopover = null;
AddUntilStep("password prompt appeared", () => (passwordEntryPopover = InputManager.ChildrenOfType<DrawableRoom.PasswordEntryPopover>().FirstOrDefault()) != null);
AddStep("enter password in text box", () => passwordEntryPopover.ChildrenOfType<TextBox>().First().Text = "password");
AddStep("press join room button", () => passwordEntryPopover.ChildrenOfType<OsuButton>().First().Click());
AddStep("press join room button", () => passwordEntryPopover.ChildrenOfType<OsuButton>().First().TriggerClick());
AddUntilStep("wait for room open", () => this.ChildrenOfType<MultiplayerMatchSubScreen>().FirstOrDefault()?.IsLoaded == true);
AddUntilStep("wait for join", () => client.Room != null);
@ -373,7 +373,7 @@ namespace osu.Game.Tests.Visual.Multiplayer
}
});
AddStep("open mod overlay", () => this.ChildrenOfType<PurpleTriangleButton>().ElementAt(2).Click());
AddStep("open mod overlay", () => this.ChildrenOfType<PurpleTriangleButton>().ElementAt(2).TriggerClick());
AddStep("invoke on back button", () => multiplayerScreen.OnBackButton());
@ -381,7 +381,7 @@ namespace osu.Game.Tests.Visual.Multiplayer
AddAssert("dialog overlay is hidden", () => DialogOverlay.State.Value == Visibility.Hidden);
testLeave("lounge tab item", () => this.ChildrenOfType<BreadcrumbControl<IScreen>.BreadcrumbTabItem>().First().Click());
testLeave("lounge tab item", () => this.ChildrenOfType<BreadcrumbControl<IScreen>.BreadcrumbTabItem>().First().TriggerClick());
testLeave("back button", () => multiplayerScreen.OnBackButton());

View File

@ -74,7 +74,7 @@ namespace osu.Game.Tests.Visual.Multiplayer
AddStep("attempt join room", () => InputManager.Key(Key.Enter));
AddUntilStep("password prompt appeared", () => (passwordEntryPopover = InputManager.ChildrenOfType<DrawableRoom.PasswordEntryPopover>().FirstOrDefault()) != null);
AddStep("enter password in text box", () => passwordEntryPopover.ChildrenOfType<TextBox>().First().Text = "password");
AddStep("press join room button", () => passwordEntryPopover.ChildrenOfType<OsuButton>().First().Click());
AddStep("press join room button", () => passwordEntryPopover.ChildrenOfType<OsuButton>().First().TriggerClick());
AddAssert("room join requested", () => lastJoinedRoom == RoomManager.Rooms.First());
AddAssert("room join password correct", () => lastJoinedPassword == "password");

View File

@ -53,7 +53,7 @@ namespace osu.Game.Tests.Visual.Online
AddStep("show manually", () => accountCreation.Show());
AddUntilStep("overlay is visible", () => accountCreation.State.Value == Visibility.Visible);
AddStep("click button", () => accountCreation.ChildrenOfType<SettingsButton>().Single().Click());
AddStep("click button", () => accountCreation.ChildrenOfType<SettingsButton>().Single().TriggerClick());
AddUntilStep("warning screen is present", () => accountCreation.ChildrenOfType<ScreenWarning>().SingleOrDefault()?.IsPresent == true);
AddStep("log back in", () => API.Login("dummy", "password"));

View File

@ -330,22 +330,11 @@ namespace osu.Game.Tests.Visual.Online
InputManager.ReleaseKey(Key.AltLeft);
}
private void pressCloseDocumentKeys() => pressKeysFor(PlatformAction.DocumentClose);
private void pressCloseDocumentKeys() => InputManager.Keys(PlatformAction.DocumentClose);
private void pressNewTabKeys() => pressKeysFor(PlatformAction.TabNew);
private void pressNewTabKeys() => InputManager.Keys(PlatformAction.TabNew);
private void pressRestoreTabKeys() => pressKeysFor(PlatformAction.TabRestore);
private void pressKeysFor(PlatformAction type)
{
var binding = host.PlatformKeyBindings.First(b => (PlatformAction)b.Action == type);
foreach (var k in binding.KeyCombination.Keys)
InputManager.PressKey((Key)k);
foreach (var k in binding.KeyCombination.Keys)
InputManager.ReleaseKey((Key)k);
}
private void pressRestoreTabKeys() => InputManager.Keys(PlatformAction.TabRestore);
private void clickDrawable(Drawable d)
{

View File

@ -37,7 +37,7 @@ namespace osu.Game.Tests.Visual.Online
AddStep("Show", () => overlay.Show());
AddUntilStep("Show More button is visible", () => showMoreButton?.Alpha == 1);
setUpNewsResponse(responseWithNoCursor, "Set up no cursor response");
AddStep("Click Show More", () => showMoreButton?.Click());
AddStep("Click Show More", () => showMoreButton?.TriggerClick());
AddUntilStep("Show More button is hidden", () => showMoreButton?.Alpha == 0);
}

View File

@ -32,19 +32,19 @@ namespace osu.Game.Tests.Visual.Online
}
});
AddStep("click button", () => button.Click());
AddStep("click button", () => button.TriggerClick());
AddAssert("action fired once", () => fireCount == 1);
AddAssert("is in loading state", () => button.IsLoading);
AddStep("click button", () => button.Click());
AddStep("click button", () => button.TriggerClick());
AddAssert("action not fired", () => fireCount == 1);
AddAssert("is in loading state", () => button.IsLoading);
AddUntilStep("wait for loaded", () => !button.IsLoading);
AddStep("click button", () => button.Click());
AddStep("click button", () => button.TriggerClick());
AddAssert("action fired twice", () => fireCount == 2);
AddAssert("is in loading state", () => button.IsLoading);

View File

@ -45,7 +45,7 @@ namespace osu.Game.Tests.Visual.Online
AddStep("Log in", logIn);
AddStep("User comment", () => addVotePill(getUserComment()));
AddAssert("Background is transparent", () => votePill.Background.Alpha == 0);
AddStep("Click", () => votePill.Click());
AddStep("Click", () => votePill.TriggerClick());
AddAssert("Not loading", () => !votePill.IsLoading);
}
@ -56,7 +56,7 @@ namespace osu.Game.Tests.Visual.Online
AddStep("Log in", logIn);
AddStep("Random comment", () => addVotePill(getRandomComment()));
AddAssert("Background is visible", () => votePill.Background.Alpha == 1);
AddStep("Click", () => votePill.Click());
AddStep("Click", () => votePill.TriggerClick());
AddAssert("Loading", () => votePill.IsLoading);
}
@ -66,7 +66,7 @@ namespace osu.Game.Tests.Visual.Online
AddStep("Hide login overlay", () => login.Hide());
AddStep("Log out", API.Logout);
AddStep("Random comment", () => addVotePill(getRandomComment()));
AddStep("Click", () => votePill.Click());
AddStep("Click", () => votePill.TriggerClick());
AddAssert("Login overlay is visible", () => login.State.Value == Visibility.Visible);
}

View File

@ -56,7 +56,7 @@ namespace osu.Game.Tests.Visual.Playlists
AddUntilStep("first room is not masked", () => checkRoomVisible(roomsContainer.Rooms[0]));
AddStep("select last room", () => roomsContainer.Rooms[^1].Click());
AddStep("select last room", () => roomsContainer.Rooms[^1].TriggerClick());
AddUntilStep("first room is masked", () => !checkRoomVisible(roomsContainer.Rooms[0]));
AddUntilStep("last room is not masked", () => checkRoomVisible(roomsContainer.Rooms[^1]));

View File

@ -76,7 +76,7 @@ namespace osu.Game.Tests.Visual.Playlists
});
});
AddStep("start match", () => match.ChildrenOfType<PlaylistsReadyButton>().First().Click());
AddStep("start match", () => match.ChildrenOfType<PlaylistsReadyButton>().First().TriggerClick());
AddUntilStep("player loader loaded", () => Stack.CurrentScreen is PlayerLoader);
}

View File

@ -160,7 +160,7 @@ namespace osu.Game.Tests.Visual.Settings
{
var resetButton = settingsKeyBindingRow.ChildrenOfType<RestoreDefaultValueButton<bool>>().First();
resetButton.Click();
resetButton.TriggerClick();
});
AddUntilStep("restore button hidden", () => settingsKeyBindingRow.ChildrenOfType<RestoreDefaultValueButton<bool>>().First().Alpha == 0);
@ -189,7 +189,7 @@ namespace osu.Game.Tests.Visual.Settings
{
var resetButton = panel.ChildrenOfType<ResetButton>().First();
resetButton.Click();
resetButton.TriggerClick();
});
AddUntilStep("restore button hidden", () => settingsKeyBindingRow.ChildrenOfType<RestoreDefaultValueButton<bool>>().First().Alpha == 0);

View File

@ -94,10 +94,10 @@ namespace osu.Game.Tests.Visual.UserInterface
AddAssert("selected mod matches", () => (SelectedMods.Value.Single() as OsuModDoubleTime)?.SpeedChange.Value == 1.2);
AddStep("deselect", () => modSelect.DeselectAllButton.Click());
AddStep("deselect", () => modSelect.DeselectAllButton.TriggerClick());
AddAssert("selected mods empty", () => SelectedMods.Value.Count == 0);
AddStep("reselect", () => modSelect.GetModButton(osuModDoubleTime).Click());
AddStep("reselect", () => modSelect.GetModButton(osuModDoubleTime).TriggerClick());
AddAssert("selected mod has default value", () => (SelectedMods.Value.Single() as OsuModDoubleTime)?.SpeedChange.IsDefault == true);
}

View File

@ -48,7 +48,7 @@ namespace osu.Game.Tests.Visual.UserInterface
AddUntilStep("wait for button load", () => modSelect.ButtonsLoaded);
AddStep("select mod", () => modSelect.SelectMod(testCustomisableMod));
AddAssert("button enabled", () => modSelect.CustomiseButton.Enabled.Value);
AddStep("open Customisation", () => modSelect.CustomiseButton.Click());
AddStep("open Customisation", () => modSelect.CustomiseButton.TriggerClick());
AddStep("deselect mod", () => modSelect.SelectMod(testCustomisableMod));
AddAssert("controls hidden", () => modSelect.ModSettingsContainer.State.Value == Visibility.Hidden);
}

View File

@ -40,6 +40,6 @@ namespace osu.Game.Tournament.Tests.Screens
() => this.ChildrenOfType<TeamScore>().All(score => score.Alpha == (visible ? 1 : 0)));
private void toggleWarmup()
=> AddStep("toggle warmup", () => this.ChildrenOfType<TourneyButton>().First().Click());
=> AddStep("toggle warmup", () => this.ChildrenOfType<TourneyButton>().First().TriggerClick());
}
}

View File

@ -35,7 +35,7 @@ namespace osu.Game.Graphics.UserInterface
Add(receptor = new Receptor());
}
receptor.OnBackPressed = () => button.Click();
receptor.OnBackPressed = () => button.TriggerClick();
}
[BackgroundDependencyLoader]

View File

@ -63,7 +63,7 @@ namespace osu.Game.Overlays.BeatmapSet.Buttons
},
};
Action = () => playButton.Click();
Action = () => playButton.TriggerClick();
Playing.ValueChanged += playing => progress.FadeTo(playing.NewValue ? 1 : 0, 100);
}

View File

@ -153,7 +153,7 @@ namespace osu.Game.Overlays.Chat.Tabs
switch (e.Button)
{
case MouseButton.Middle:
CloseButton.Click();
CloseButton.TriggerClick();
break;
}
}

View File

@ -120,7 +120,7 @@ namespace osu.Game.Overlays.Comments
if (commitButton.IsBlocked.Value)
return;
commitButton.Click();
commitButton.TriggerClick();
};
}

View File

@ -218,7 +218,7 @@ namespace osu.Game.Overlays.Dialog
/// <summary>
/// Programmatically clicks the first <see cref="PopupDialogOkButton"/>.
/// </summary>
public void PerformOkAction() => Buttons.OfType<PopupDialogOkButton>().First().Click();
public void PerformOkAction() => Buttons.OfType<PopupDialogOkButton>().First().TriggerClick();
protected override bool OnKeyDown(KeyDownEvent e)
{
@ -265,7 +265,7 @@ namespace osu.Game.Overlays.Dialog
if (!actionInvoked && content.IsPresent)
// In the case a user did not choose an action before a hide was triggered, press the last button.
// This is presumed to always be a sane default "cancel" action.
buttonsContainer.Last().Click();
buttonsContainer.Last().TriggerClick();
content.FadeOut(EXIT_DURATION, Easing.InSine);
}
@ -273,7 +273,7 @@ namespace osu.Game.Overlays.Dialog
private void pressButtonAtIndex(int index)
{
if (index < Buttons.Count())
Buttons.Skip(index).First().Click();
Buttons.Skip(index).First().TriggerClick();
}
}
}

View File

@ -88,7 +88,7 @@ namespace osu.Game.Overlays
switch (action)
{
case GlobalAction.Select:
CurrentDialog?.Buttons.OfType<PopupDialogOkButton>().FirstOrDefault()?.Click();
CurrentDialog?.Buttons.OfType<PopupDialogOkButton>().FirstOrDefault()?.TriggerClick();
return true;
}

View File

@ -404,11 +404,11 @@ namespace osu.Game.Overlays.Mods
switch (e.Key)
{
case Key.Number1:
DeselectAllButton.Click();
DeselectAllButton.TriggerClick();
return true;
case Key.Number2:
CloseButton.Click();
CloseButton.TriggerClick();
return true;
}

View File

@ -188,7 +188,7 @@ namespace osu.Game.Overlays.Toolbar
{
if (action == Hotkey)
{
Click();
TriggerClick();
return true;
}

View File

@ -62,7 +62,7 @@ namespace osu.Game.Overlays.Toolbar
protected override bool OnClick(ClickEvent e)
{
Parent.Click();
Parent.TriggerClick();
return base.OnClick(e);
}
}

View File

@ -210,7 +210,7 @@ namespace osu.Game.Screens.Menu
{
if (buttonsTopLevel.Any(b => e.Key == b.TriggerKey))
{
logo?.Click();
logo?.TriggerClick();
return true;
}
}
@ -226,7 +226,7 @@ namespace osu.Game.Screens.Menu
return goBack();
case GlobalAction.Select:
logo?.Click();
logo?.TriggerClick();
return true;
default:
@ -248,7 +248,7 @@ namespace osu.Game.Screens.Menu
return true;
case ButtonSystemState.Play:
backButton.Click();
backButton.TriggerClick();
return true;
default:
@ -268,11 +268,11 @@ namespace osu.Game.Screens.Menu
return true;
case ButtonSystemState.TopLevel:
buttonsTopLevel.First().Click();
buttonsTopLevel.First().TriggerClick();
return false;
case ButtonSystemState.Play:
buttonsPlay.First().Click();
buttonsPlay.First().TriggerClick();
return false;
}
}

View File

@ -262,7 +262,7 @@ namespace osu.Game.Screens.OnlinePlay.Lounge.Components
switch (action)
{
case GlobalAction.Select:
Click();
TriggerClick();
return true;
}

View File

@ -42,12 +42,12 @@ namespace osu.Game.Screens.Play
/// <summary>
/// Action that is invoked when <see cref="GlobalAction.Back"/> is triggered.
/// </summary>
protected virtual Action BackAction => () => InternalButtons.Children.LastOrDefault()?.Click();
protected virtual Action BackAction => () => InternalButtons.Children.LastOrDefault()?.TriggerClick();
/// <summary>
/// Action that is invoked when <see cref="GlobalAction.Select"/> is triggered.
/// </summary>
protected virtual Action SelectAction => () => InternalButtons.Selected?.Click();
protected virtual Action SelectAction => () => InternalButtons.Selected?.TriggerClick();
public abstract string Header { get; }

View File

@ -24,7 +24,7 @@ namespace osu.Game.Screens.Play
private SkinnableSound pauseLoop;
protected override Action BackAction => () => InternalButtons.Children.First().Click();
protected override Action BackAction => () => InternalButtons.Children.First().TriggerClick();
[BackgroundDependencyLoader]
private void load(OsuColour colours)

View File

@ -148,7 +148,7 @@ namespace osu.Game.Screens.Play
if (!button.Enabled.Value)
return false;
button.Click();
button.TriggerClick();
return true;
}

View File

@ -176,7 +176,7 @@ namespace osu.Game.Screens.Select
{
if (action == Hotkey)
{
Click();
TriggerClick();
return true;
}

View File

@ -67,7 +67,7 @@ namespace osu.Game.Screens.Select
return false;
}
Click();
TriggerClick();
return true;
}

View File

@ -122,7 +122,7 @@ namespace osu.Game.Screens.Select.Options
if (found != null)
{
found.Click();
found.TriggerClick();
return true;
}
}

View File

@ -36,7 +36,7 @@
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
</PackageReference>
<PackageReference Include="Realm" Version="10.3.0" />
<PackageReference Include="ppy.osu.Framework" Version="2021.803.0" />
<PackageReference Include="ppy.osu.Framework" Version="2021.804.0" />
<PackageReference Include="ppy.osu.Game.Resources" Version="2021.803.0" />
<PackageReference Include="Sentry" Version="3.8.3" />
<PackageReference Include="SharpCompress" Version="0.28.3" />

View File

@ -70,7 +70,7 @@
<Reference Include="System.Net.Http" />
</ItemGroup>
<ItemGroup Label="Package References">
<PackageReference Include="ppy.osu.Framework.iOS" Version="2021.803.0" />
<PackageReference Include="ppy.osu.Framework.iOS" Version="2021.804.0" />
<PackageReference Include="ppy.osu.Game.Resources" Version="2021.803.0" />
</ItemGroup>
<!-- See https://github.com/dotnet/runtime/issues/35988 (can be removed after Xamarin uses net5.0 / net6.0) -->
@ -93,7 +93,7 @@
<PackageReference Include="Microsoft.EntityFrameworkCore.Sqlite" Version="2.2.6" />
<PackageReference Include="Microsoft.EntityFrameworkCore.Sqlite.Core" Version="2.2.6" />
<PackageReference Include="Newtonsoft.Json" Version="13.0.1" />
<PackageReference Include="ppy.osu.Framework" Version="2021.803.0" />
<PackageReference Include="ppy.osu.Framework" Version="2021.804.0" />
<PackageReference Include="SharpCompress" Version="0.28.3" />
<PackageReference Include="NUnit" Version="3.13.2" />
<PackageReference Include="SharpRaven" Version="2.4.0" />