mirror of
https://github.com/ppy/osu.git
synced 2025-02-22 00:43:25 +08:00
Expose test helper for switching between difficulties
This commit is contained in:
parent
f8a681d810
commit
22fa9a303e
@ -7,14 +7,11 @@ using NUnit.Framework;
|
|||||||
using osu.Framework.Allocation;
|
using osu.Framework.Allocation;
|
||||||
using osu.Framework.Testing;
|
using osu.Framework.Testing;
|
||||||
using osu.Game.Beatmaps;
|
using osu.Game.Beatmaps;
|
||||||
using osu.Game.Graphics.UserInterface;
|
|
||||||
using osu.Game.Overlays.Dialog;
|
using osu.Game.Overlays.Dialog;
|
||||||
using osu.Game.Rulesets;
|
using osu.Game.Rulesets;
|
||||||
using osu.Game.Rulesets.Osu;
|
using osu.Game.Rulesets.Osu;
|
||||||
using osu.Game.Screens.Edit;
|
using osu.Game.Screens.Edit;
|
||||||
using osu.Game.Screens.Edit.Components.Menus;
|
|
||||||
using osu.Game.Tests.Beatmaps.IO;
|
using osu.Game.Tests.Beatmaps.IO;
|
||||||
using osuTK.Input;
|
|
||||||
|
|
||||||
namespace osu.Game.Tests.Visual.Editing
|
namespace osu.Game.Tests.Visual.Editing
|
||||||
{
|
{
|
||||||
@ -116,34 +113,7 @@ namespace osu.Game.Tests.Visual.Editing
|
|||||||
AddAssert("stack empty", () => Stack.CurrentScreen == null);
|
AddAssert("stack empty", () => Stack.CurrentScreen == null);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void switchToDifficulty(Func<BeatmapInfo> difficulty)
|
private void switchToDifficulty(Func<BeatmapInfo> difficulty) => AddStep("switch to difficulty", () => Editor.SwitchToDifficulty(difficulty.Invoke()));
|
||||||
{
|
|
||||||
AddUntilStep("wait for menubar to load", () => Editor.ChildrenOfType<EditorMenuBar>().Any());
|
|
||||||
AddStep("open file menu", () =>
|
|
||||||
{
|
|
||||||
var menuBar = Editor.ChildrenOfType<EditorMenuBar>().Single();
|
|
||||||
var fileMenu = menuBar.ChildrenOfType<DrawableOsuMenuItem>().First();
|
|
||||||
InputManager.MoveMouseTo(fileMenu);
|
|
||||||
InputManager.Click(MouseButton.Left);
|
|
||||||
});
|
|
||||||
|
|
||||||
AddStep("open difficulty menu", () =>
|
|
||||||
{
|
|
||||||
var difficultySelector =
|
|
||||||
Editor.ChildrenOfType<DrawableOsuMenuItem>().Single(item => item.Item.Text.Value.ToString().Contains("Change difficulty"));
|
|
||||||
InputManager.MoveMouseTo(difficultySelector);
|
|
||||||
});
|
|
||||||
AddWaitStep("wait for open", 3);
|
|
||||||
|
|
||||||
AddStep("switch to target difficulty", () =>
|
|
||||||
{
|
|
||||||
var difficultyMenuItem =
|
|
||||||
Editor.ChildrenOfType<DrawableOsuMenuItem>()
|
|
||||||
.Last(item => item.Item is DifficultyMenuItem difficultyItem && difficultyItem.Beatmap.Equals(difficulty.Invoke()));
|
|
||||||
InputManager.MoveMouseTo(difficultyMenuItem);
|
|
||||||
InputManager.Click(MouseButton.Left);
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
private void confirmEditingBeatmap(Func<BeatmapInfo> targetDifficulty)
|
private void confirmEditingBeatmap(Func<BeatmapInfo> targetDifficulty)
|
||||||
{
|
{
|
||||||
|
@ -737,10 +737,10 @@ namespace osu.Game.Screens.Edit
|
|||||||
private DifficultyMenuItem createDifficultyMenuItem(BeatmapInfo beatmapInfo)
|
private DifficultyMenuItem createDifficultyMenuItem(BeatmapInfo beatmapInfo)
|
||||||
{
|
{
|
||||||
bool isCurrentDifficulty = playableBeatmap.BeatmapInfo.Equals(beatmapInfo);
|
bool isCurrentDifficulty = playableBeatmap.BeatmapInfo.Equals(beatmapInfo);
|
||||||
return new DifficultyMenuItem(beatmapInfo, isCurrentDifficulty, switchToDifficulty);
|
return new DifficultyMenuItem(beatmapInfo, isCurrentDifficulty, SwitchToDifficulty);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void switchToDifficulty(BeatmapInfo beatmapInfo) => loader?.ScheduleDifficultySwitch(beatmapInfo);
|
protected void SwitchToDifficulty(BeatmapInfo beatmapInfo) => loader?.ScheduleDifficultySwitch(beatmapInfo);
|
||||||
|
|
||||||
private void cancelExit() => loader?.CancelPendingDifficultySwitch();
|
private void cancelExit() => loader?.CancelPendingDifficultySwitch();
|
||||||
|
|
||||||
|
@ -103,6 +103,8 @@ namespace osu.Game.Tests.Visual
|
|||||||
|
|
||||||
public new void Paste() => base.Paste();
|
public new void Paste() => base.Paste();
|
||||||
|
|
||||||
|
public new void SwitchToDifficulty(BeatmapInfo beatmapInfo) => base.SwitchToDifficulty(beatmapInfo);
|
||||||
|
|
||||||
public new bool HasUnsavedChanges => base.HasUnsavedChanges;
|
public new bool HasUnsavedChanges => base.HasUnsavedChanges;
|
||||||
|
|
||||||
public TestEditor(EditorLoader loader = null)
|
public TestEditor(EditorLoader loader = null)
|
||||||
|
Loading…
Reference in New Issue
Block a user