1
0
mirror of https://github.com/ppy/osu.git synced 2024-12-14 13:22:55 +08:00

Add test coverage of original fail case and improve test reliability and code quality

This commit is contained in:
Dean Herbert 2022-06-20 13:45:50 +09:00
parent 243806e810
commit 329f1a0822
2 changed files with 39 additions and 10 deletions

View File

@ -8,7 +8,9 @@ using NUnit.Framework;
using osu.Framework.Extensions;
using osu.Framework.Graphics.Containers;
using osu.Framework.Graphics.UserInterface;
using osu.Framework.Screens;
using osu.Framework.Testing;
using osu.Framework.Threading;
using osu.Game.Overlays.Settings;
using osu.Game.Rulesets.Mods;
using osu.Game.Rulesets.Osu.Mods;
@ -16,6 +18,7 @@ using osu.Game.Screens.Play;
using osu.Game.Screens.Play.HUD.HitErrorMeters;
using osu.Game.Skinning.Editor;
using osu.Game.Tests.Beatmaps.IO;
using osuTK;
using osuTK.Input;
using static osu.Game.Tests.Visual.Navigation.TestSceneScreenNavigation;
@ -66,11 +69,14 @@ namespace osu.Game.Tests.Visual.Navigation
}
[Test]
public void TestHideSkinEditorWhileDragging()
public void TestComponentsDeselectedOnSkinEditorHide()
{
advanceToSongSelect();
openSkinEditor();
switchToGameplayScene();
AddUntilStep("wait for components", () => skinEditor.ChildrenOfType<SkinBlueprint>().Any());
AddStep("select all components", () =>
{
InputManager.PressKey(Key.ControlLeft);
@ -78,27 +84,50 @@ namespace osu.Game.Tests.Visual.Navigation
InputManager.ReleaseKey(Key.ControlLeft);
});
AddUntilStep("components selected", () => skinEditor.SelectedComponents.Count > 0);
toggleSkinEditor();
AddUntilStep("no components selected", () => skinEditor.SelectedComponents.Count == 0);
}
[Test]
public void TestComponentsDeselectedOnSkinEditorHide()
public void TestSwitchScreenWhileDraggingComponent()
{
Vector2 firstBlueprintCentre = Vector2.Zero;
ScheduledDelegate movementDelegate = null;
advanceToSongSelect();
openSkinEditor();
switchToGameplayScene();
AddStep("select all components", () =>
AddStep("add skinnable component", () =>
{
InputManager.PressKey(Key.ControlLeft);
InputManager.Key(Key.A);
InputManager.ReleaseKey(Key.ControlLeft);
skinEditor.ChildrenOfType<SkinComponentToolbox.ToolboxComponentButton>().First().TriggerClick();
});
toggleSkinEditor();
AddUntilStep("newly added component selected", () => skinEditor.SelectedComponents.Count == 1);
AddUntilStep("no components selected", () => skinEditor.SelectedComponents.Count == 0);
AddStep("start drag", () =>
{
firstBlueprintCentre = skinEditor.ChildrenOfType<SkinBlueprint>().First().ScreenSpaceDrawQuad.Centre;
InputManager.MoveMouseTo(firstBlueprintCentre);
InputManager.PressButton(MouseButton.Left);
});
AddStep("start movement", () => movementDelegate = Scheduler.AddDelayed(() => { InputManager.MoveMouseTo(firstBlueprintCentre += new Vector2(1)); }, 10, true));
toggleSkinEditor();
AddStep("exit song select", () => songSelect.Exit());
AddUntilStep("wait for blueprints removed", () => !skinEditor.ChildrenOfType<SkinBlueprint>().Any());
AddStep("stop drag", () =>
{
InputManager.ReleaseButton(MouseButton.Left);
movementDelegate?.Cancel();
});
}
[Test]

View File

@ -88,7 +88,7 @@ namespace osu.Game.Skinning.Editor
}
}
private class ToolboxComponentButton : OsuButton
public class ToolboxComponentButton : OsuButton
{
protected override bool ShouldBeConsideredForInput(Drawable child) => false;