mirror of
https://github.com/osukey/osukey.git
synced 2025-07-02 08:49:59 +09:00
Add test coverage of original fail case and improve test reliability and code quality
This commit is contained in:
@ -8,7 +8,9 @@ using NUnit.Framework;
|
|||||||
using osu.Framework.Extensions;
|
using osu.Framework.Extensions;
|
||||||
using osu.Framework.Graphics.Containers;
|
using osu.Framework.Graphics.Containers;
|
||||||
using osu.Framework.Graphics.UserInterface;
|
using osu.Framework.Graphics.UserInterface;
|
||||||
|
using osu.Framework.Screens;
|
||||||
using osu.Framework.Testing;
|
using osu.Framework.Testing;
|
||||||
|
using osu.Framework.Threading;
|
||||||
using osu.Game.Overlays.Settings;
|
using osu.Game.Overlays.Settings;
|
||||||
using osu.Game.Rulesets.Mods;
|
using osu.Game.Rulesets.Mods;
|
||||||
using osu.Game.Rulesets.Osu.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.Screens.Play.HUD.HitErrorMeters;
|
||||||
using osu.Game.Skinning.Editor;
|
using osu.Game.Skinning.Editor;
|
||||||
using osu.Game.Tests.Beatmaps.IO;
|
using osu.Game.Tests.Beatmaps.IO;
|
||||||
|
using osuTK;
|
||||||
using osuTK.Input;
|
using osuTK.Input;
|
||||||
using static osu.Game.Tests.Visual.Navigation.TestSceneScreenNavigation;
|
using static osu.Game.Tests.Visual.Navigation.TestSceneScreenNavigation;
|
||||||
|
|
||||||
@ -66,11 +69,14 @@ namespace osu.Game.Tests.Visual.Navigation
|
|||||||
}
|
}
|
||||||
|
|
||||||
[Test]
|
[Test]
|
||||||
public void TestHideSkinEditorWhileDragging()
|
public void TestComponentsDeselectedOnSkinEditorHide()
|
||||||
{
|
{
|
||||||
advanceToSongSelect();
|
advanceToSongSelect();
|
||||||
openSkinEditor();
|
openSkinEditor();
|
||||||
switchToGameplayScene();
|
switchToGameplayScene();
|
||||||
|
|
||||||
|
AddUntilStep("wait for components", () => skinEditor.ChildrenOfType<SkinBlueprint>().Any());
|
||||||
|
|
||||||
AddStep("select all components", () =>
|
AddStep("select all components", () =>
|
||||||
{
|
{
|
||||||
InputManager.PressKey(Key.ControlLeft);
|
InputManager.PressKey(Key.ControlLeft);
|
||||||
@ -78,27 +84,50 @@ namespace osu.Game.Tests.Visual.Navigation
|
|||||||
InputManager.ReleaseKey(Key.ControlLeft);
|
InputManager.ReleaseKey(Key.ControlLeft);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
AddUntilStep("components selected", () => skinEditor.SelectedComponents.Count > 0);
|
||||||
|
|
||||||
toggleSkinEditor();
|
toggleSkinEditor();
|
||||||
|
|
||||||
AddUntilStep("no components selected", () => skinEditor.SelectedComponents.Count == 0);
|
AddUntilStep("no components selected", () => skinEditor.SelectedComponents.Count == 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
[Test]
|
[Test]
|
||||||
public void TestComponentsDeselectedOnSkinEditorHide()
|
public void TestSwitchScreenWhileDraggingComponent()
|
||||||
{
|
{
|
||||||
|
Vector2 firstBlueprintCentre = Vector2.Zero;
|
||||||
|
ScheduledDelegate movementDelegate = null;
|
||||||
|
|
||||||
advanceToSongSelect();
|
advanceToSongSelect();
|
||||||
|
|
||||||
openSkinEditor();
|
openSkinEditor();
|
||||||
switchToGameplayScene();
|
|
||||||
AddStep("select all components", () =>
|
AddStep("add skinnable component", () =>
|
||||||
{
|
{
|
||||||
InputManager.PressKey(Key.ControlLeft);
|
skinEditor.ChildrenOfType<SkinComponentToolbox.ToolboxComponentButton>().First().TriggerClick();
|
||||||
InputManager.Key(Key.A);
|
|
||||||
InputManager.ReleaseKey(Key.ControlLeft);
|
|
||||||
});
|
});
|
||||||
|
|
||||||
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]
|
[Test]
|
||||||
|
@ -88,7 +88,7 @@ namespace osu.Game.Skinning.Editor
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private class ToolboxComponentButton : OsuButton
|
public class ToolboxComponentButton : OsuButton
|
||||||
{
|
{
|
||||||
protected override bool ShouldBeConsideredForInput(Drawable child) => false;
|
protected override bool ShouldBeConsideredForInput(Drawable child) => false;
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user