From 4ec064e1799ea2c0d892b7768f94f41dab00295d Mon Sep 17 00:00:00 2001 From: Dean Herbert Date: Mon, 24 Jun 2019 11:00:00 +0900 Subject: [PATCH 1/3] Fix test timing regressions due to increased step count --- .../Visual/Components/TestSceneIdleTracker.cs | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) diff --git a/osu.Game.Tests/Visual/Components/TestSceneIdleTracker.cs b/osu.Game.Tests/Visual/Components/TestSceneIdleTracker.cs index ef889e29a8..0540c1bbbb 100644 --- a/osu.Game.Tests/Visual/Components/TestSceneIdleTracker.cs +++ b/osu.Game.Tests/Visual/Components/TestSceneIdleTracker.cs @@ -5,6 +5,7 @@ using NUnit.Framework; using osu.Framework.Graphics; using osu.Framework.Graphics.Containers; using osu.Framework.Graphics.Shapes; +using osu.Framework.Testing; using osu.Game.Input; using osuTK; using osuTK.Graphics; @@ -19,11 +20,17 @@ namespace osu.Game.Tests.Visual.Components private readonly IdleTrackingBox box3; private readonly IdleTrackingBox box4; + [SetUpSteps] + public void SetUpSteps() + { + AddStep("reset mouse position", () => InputManager.MoveMouseTo(Vector2.Zero)); + } + public TestSceneIdleTracker() { Children = new Drawable[] { - box1 = new IdleTrackingBox(1000) + box1 = new IdleTrackingBox(2000) { Name = "TopLeft", RelativeSizeAxes = Axes.Both, @@ -31,7 +38,7 @@ namespace osu.Game.Tests.Visual.Components Anchor = Anchor.TopLeft, Origin = Anchor.TopLeft, }, - box2 = new IdleTrackingBox(2000) + box2 = new IdleTrackingBox(4000) { Name = "TopRight", RelativeSizeAxes = Axes.Both, @@ -39,7 +46,7 @@ namespace osu.Game.Tests.Visual.Components Anchor = Anchor.TopRight, Origin = Anchor.TopRight, }, - box3 = new IdleTrackingBox(3000) + box3 = new IdleTrackingBox(6000) { Name = "BottomLeft", RelativeSizeAxes = Axes.Both, @@ -47,7 +54,7 @@ namespace osu.Game.Tests.Visual.Components Anchor = Anchor.BottomLeft, Origin = Anchor.BottomLeft, }, - box4 = new IdleTrackingBox(4000) + box4 = new IdleTrackingBox(8000) { Name = "BottomRight", RelativeSizeAxes = Axes.Both, From da2ba5bf0995c18fa88330e22c2d51a5e57718c3 Mon Sep 17 00:00:00 2001 From: Dean Herbert Date: Mon, 24 Jun 2019 11:09:59 +0900 Subject: [PATCH 2/3] Allow tests to be run in non-sequential order --- .../Visual/Components/TestSceneIdleTracker.cs | 84 +++++++++---------- 1 file changed, 41 insertions(+), 43 deletions(-) diff --git a/osu.Game.Tests/Visual/Components/TestSceneIdleTracker.cs b/osu.Game.Tests/Visual/Components/TestSceneIdleTracker.cs index 0540c1bbbb..9eead3f9fb 100644 --- a/osu.Game.Tests/Visual/Components/TestSceneIdleTracker.cs +++ b/osu.Game.Tests/Visual/Components/TestSceneIdleTracker.cs @@ -5,7 +5,6 @@ using NUnit.Framework; using osu.Framework.Graphics; using osu.Framework.Graphics.Containers; using osu.Framework.Graphics.Shapes; -using osu.Framework.Testing; using osu.Game.Input; using osuTK; using osuTK.Graphics; @@ -15,20 +14,19 @@ namespace osu.Game.Tests.Visual.Components [TestFixture] public class TestSceneIdleTracker : ManualInputManagerTestScene { - private readonly IdleTrackingBox box1; - private readonly IdleTrackingBox box2; - private readonly IdleTrackingBox box3; - private readonly IdleTrackingBox box4; + private IdleTrackingBox box1; + private IdleTrackingBox box2; + private IdleTrackingBox box3; + private IdleTrackingBox box4; - [SetUpSteps] - public void SetUpSteps() - { - AddStep("reset mouse position", () => InputManager.MoveMouseTo(Vector2.Zero)); - } + private IdleTrackingBox[] boxes; - public TestSceneIdleTracker() + [SetUp] + public void SetUp() => Schedule(() => { - Children = new Drawable[] + InputManager.MoveMouseTo(Vector2.Zero); + + Children = boxes = new IdleTrackingBox[] { box1 = new IdleTrackingBox(2000) { @@ -63,7 +61,7 @@ namespace osu.Game.Tests.Visual.Components Origin = Anchor.BottomRight, }, }; - } + }); [Test] public void TestNudge() @@ -74,10 +72,10 @@ namespace osu.Game.Tests.Visual.Components AddStep("nudge mouse", () => InputManager.MoveMouseTo(box1.ScreenSpaceDrawQuad.Centre + new Vector2(1))); - checkIdleStatus(box1, false); - checkIdleStatus(box2, true); - checkIdleStatus(box3, true); - checkIdleStatus(box4, true); + checkIdleStatus(1, false); + checkIdleStatus(2, true); + checkIdleStatus(3, true); + checkIdleStatus(4, true); } [Test] @@ -85,18 +83,18 @@ namespace osu.Game.Tests.Visual.Components { AddStep("move to top right", () => InputManager.MoveMouseTo(box2)); - checkIdleStatus(box1, true); - checkIdleStatus(box2, false); - checkIdleStatus(box3, true); - checkIdleStatus(box4, true); + checkIdleStatus(1, true); + checkIdleStatus(2, false); + checkIdleStatus(3, true); + checkIdleStatus(4, true); AddStep("move to bottom left", () => InputManager.MoveMouseTo(box3)); AddStep("move to bottom right", () => InputManager.MoveMouseTo(box4)); - checkIdleStatus(box1, true); - checkIdleStatus(box2, false); - checkIdleStatus(box3, false); - checkIdleStatus(box4, false); + checkIdleStatus(1, true); + checkIdleStatus(2, false); + checkIdleStatus(3, false); + checkIdleStatus(4, false); waitForAllIdle(); } @@ -106,38 +104,38 @@ namespace osu.Game.Tests.Visual.Components { AddStep("move to centre", () => InputManager.MoveMouseTo(Content)); - checkIdleStatus(box1, false); - checkIdleStatus(box2, false); - checkIdleStatus(box3, false); - checkIdleStatus(box4, false); + checkIdleStatus(1, false); + checkIdleStatus(2, false); + checkIdleStatus(3, false); + checkIdleStatus(4, false); AddUntilStep("Wait for idle", () => box1.IsIdle); - checkIdleStatus(box1, true); - checkIdleStatus(box2, false); - checkIdleStatus(box3, false); - checkIdleStatus(box4, false); + checkIdleStatus(1, true); + checkIdleStatus(2, false); + checkIdleStatus(3, false); + checkIdleStatus(4, false); AddUntilStep("Wait for idle", () => box2.IsIdle); - checkIdleStatus(box1, true); - checkIdleStatus(box2, true); - checkIdleStatus(box3, false); - checkIdleStatus(box4, false); + checkIdleStatus(1, true); + checkIdleStatus(2, true); + checkIdleStatus(3, false); + checkIdleStatus(4, false); AddUntilStep("Wait for idle", () => box3.IsIdle); - checkIdleStatus(box1, true); - checkIdleStatus(box2, true); - checkIdleStatus(box3, true); - checkIdleStatus(box4, false); + checkIdleStatus(1, true); + checkIdleStatus(2, true); + checkIdleStatus(3, true); + checkIdleStatus(4, false); waitForAllIdle(); } - private void checkIdleStatus(IdleTrackingBox box, bool expectedIdle) + private void checkIdleStatus(int box, bool expectedIdle) { - AddAssert($"{box.Name} is {(expectedIdle ? "idle" : "active")}", () => box.IsIdle == expectedIdle); + AddAssert($"box {box} is {(expectedIdle ? "idle" : "active")}", () => boxes[box - 1].IsIdle == expectedIdle); } private void waitForAllIdle() From 024157b13f1a732ec8d669564213de83e8bbe8b9 Mon Sep 17 00:00:00 2001 From: Dean Herbert Date: Mon, 24 Jun 2019 11:10:29 +0900 Subject: [PATCH 3/3] Remove unnecessary type specification --- osu.Game.Tests/Visual/Components/TestSceneIdleTracker.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/osu.Game.Tests/Visual/Components/TestSceneIdleTracker.cs b/osu.Game.Tests/Visual/Components/TestSceneIdleTracker.cs index 9eead3f9fb..55aaeed8bf 100644 --- a/osu.Game.Tests/Visual/Components/TestSceneIdleTracker.cs +++ b/osu.Game.Tests/Visual/Components/TestSceneIdleTracker.cs @@ -26,7 +26,7 @@ namespace osu.Game.Tests.Visual.Components { InputManager.MoveMouseTo(Vector2.Zero); - Children = boxes = new IdleTrackingBox[] + Children = boxes = new[] { box1 = new IdleTrackingBox(2000) {