From 250c7403e87f88c65139a55792902dc8d173a995 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bart=C5=82omiej=20Dach?= Date: Sat, 17 Apr 2021 13:50:00 +0200 Subject: [PATCH 1/2] Fix idle tracker assuming time starts at 0 `IdleTracker` in its construction quietly assumed that the clock it receives from its parent starts ticking from 0 at the point at which it is passed down. This is not necessarily the case when headless executions are involved, which means that the initial state of the tracker could be computed as idle incorrectly. Resolve by explicitly reading the clock time at the point of `LoadComplete()`. --- osu.Game/Input/IdleTracker.cs | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/osu.Game/Input/IdleTracker.cs b/osu.Game/Input/IdleTracker.cs index 63a6348b57..2d6a21d1cf 100644 --- a/osu.Game/Input/IdleTracker.cs +++ b/osu.Game/Input/IdleTracker.cs @@ -42,6 +42,12 @@ namespace osu.Game.Input RelativeSizeAxes = Axes.Both; } + protected override void LoadComplete() + { + base.LoadComplete(); + updateLastInteractionTime(); + } + protected override void Update() { base.Update(); From f3ea51eeedc8113ac83c79e5f0daaa241e755f20 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bart=C5=82omiej=20Dach?= Date: Sat, 17 Apr 2021 14:23:32 +0200 Subject: [PATCH 2/2] Adjust tests to not rely on invalid assumption --- osu.Game.Tests/Visual/Components/TestSceneIdleTracker.cs | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/osu.Game.Tests/Visual/Components/TestSceneIdleTracker.cs b/osu.Game.Tests/Visual/Components/TestSceneIdleTracker.cs index 4d64c7d35d..fdee53f0be 100644 --- a/osu.Game.Tests/Visual/Components/TestSceneIdleTracker.cs +++ b/osu.Game.Tests/Visual/Components/TestSceneIdleTracker.cs @@ -81,6 +81,13 @@ namespace osu.Game.Tests.Visual.Components [Test] public void TestMovement() { + checkIdleStatus(1, false); + checkIdleStatus(2, false); + checkIdleStatus(3, false); + checkIdleStatus(4, false); + + waitForAllIdle(); + AddStep("move to top right", () => InputManager.MoveMouseTo(box2)); checkIdleStatus(1, true); @@ -102,6 +109,8 @@ namespace osu.Game.Tests.Visual.Components [Test] public void TestTimings() { + waitForAllIdle(); + AddStep("move to centre", () => InputManager.MoveMouseTo(Content)); checkIdleStatus(1, false);