From ff3c2265967ef633bdf91ba616d95f5bd9f3a60e Mon Sep 17 00:00:00 2001 From: David Zhao Date: Wed, 8 May 2019 13:37:03 +0900 Subject: [PATCH 1/7] Give ZoomableScrollContainer an initial width --- .../Editor/TestCaseZoomableScrollContainer.cs | 60 +++++++++++-------- .../Timeline/ZoomableScrollContainer.cs | 8 +++ 2 files changed, 44 insertions(+), 24 deletions(-) diff --git a/osu.Game.Tests/Visual/Editor/TestCaseZoomableScrollContainer.cs b/osu.Game.Tests/Visual/Editor/TestCaseZoomableScrollContainer.cs index e2cf1ef28a..55c978ae06 100644 --- a/osu.Game.Tests/Visual/Editor/TestCaseZoomableScrollContainer.cs +++ b/osu.Game.Tests/Visual/Editor/TestCaseZoomableScrollContainer.cs @@ -8,6 +8,7 @@ using osu.Framework.Graphics.Containers; using osu.Framework.Graphics.Primitives; using osu.Framework.Graphics.Shapes; using osu.Framework.MathUtils; +using osu.Framework.Testing; using osu.Game.Graphics; using osu.Game.Graphics.Cursor; using osu.Game.Screens.Edit.Compose.Components.Timeline; @@ -18,38 +19,49 @@ namespace osu.Game.Tests.Visual.Editor { public class TestCaseZoomableScrollContainer : ManualInputManagerTestCase { - private readonly ZoomableScrollContainer scrollContainer; - private readonly Drawable innerBox; + private ZoomableScrollContainer scrollContainer; + private Drawable innerBox; - public TestCaseZoomableScrollContainer() + [SetUpSteps] + public void SetUpSteps() { - Children = new Drawable[] + AddStep("Add new scroll container", () => { - new Container + Children = new Drawable[] { - Anchor = Anchor.Centre, - Origin = Anchor.Centre, - RelativeSizeAxes = Axes.X, - Height = 250, - Width = 0.75f, - Children = new Drawable[] + new Container { - new Box + Anchor = Anchor.Centre, + Origin = Anchor.Centre, + RelativeSizeAxes = Axes.X, + Height = 250, + Width = 0.75f, + Children = new Drawable[] { - RelativeSizeAxes = Axes.Both, - Colour = OsuColour.Gray(30) - }, - scrollContainer = new ZoomableScrollContainer { RelativeSizeAxes = Axes.Both } - } - }, - new MenuCursor() - }; + new Box + { + RelativeSizeAxes = Axes.Both, + Colour = OsuColour.Gray(30) + }, + scrollContainer = new ZoomableScrollContainer { RelativeSizeAxes = Axes.Both } + } + }, + new MenuCursor() + }; - scrollContainer.Add(innerBox = new Box - { - RelativeSizeAxes = Axes.Both, - Colour = ColourInfo.GradientHorizontal(new Color4(0.8f, 0.6f, 0.4f, 1f), new Color4(0.4f, 0.6f, 0.8f, 1f)) + scrollContainer.Add(innerBox = new Box + { + RelativeSizeAxes = Axes.Both, + Colour = ColourInfo.GradientHorizontal(new Color4(0.8f, 0.6f, 0.4f, 1f), new Color4(0.4f, 0.6f, 0.8f, 1f)) + }); }); + AddUntilStep("Scroll container is loaded", () => scrollContainer.LoadState >= LoadState.Loaded); + } + + [Test] + public void TestWidthInitialization() + { + AddAssert("Inner container width was initialized", () => innerBox.DrawWidth > 0); } [Test] diff --git a/osu.Game/Screens/Edit/Compose/Components/Timeline/ZoomableScrollContainer.cs b/osu.Game/Screens/Edit/Compose/Components/Timeline/ZoomableScrollContainer.cs index 9b00a3998d..ee6e29c92e 100644 --- a/osu.Game/Screens/Edit/Compose/Components/Timeline/ZoomableScrollContainer.cs +++ b/osu.Game/Screens/Edit/Compose/Components/Timeline/ZoomableScrollContainer.cs @@ -102,6 +102,14 @@ namespace osu.Game.Screens.Edit.Compose.Components.Timeline return true; } + protected override void LoadComplete() + { + base.LoadComplete(); + + // This width only gets updated on the application of a transform, so this needs to be initialized here. + zoomedContent.Width = DrawWidth * currentZoom; + } + private float zoomTarget = 1; private void setZoomTarget(float newZoom, float focusPoint) From 5b1ae1210ad01387a7ddf7996e17bfad1a455d95 Mon Sep 17 00:00:00 2001 From: Dean Herbert Date: Thu, 9 May 2019 11:31:40 +0900 Subject: [PATCH 2/7] Add more asserts to pause test in an attempt to track down intermittent test failures --- osu.Game.Tests/Visual/Gameplay/TestCasePause.cs | 2 ++ 1 file changed, 2 insertions(+) diff --git a/osu.Game.Tests/Visual/Gameplay/TestCasePause.cs b/osu.Game.Tests/Visual/Gameplay/TestCasePause.cs index b9c7fd14bd..14be10b65c 100644 --- a/osu.Game.Tests/Visual/Gameplay/TestCasePause.cs +++ b/osu.Game.Tests/Visual/Gameplay/TestCasePause.cs @@ -157,6 +157,8 @@ namespace osu.Game.Tests.Visual.Gameplay private void confirmPaused() { confirmClockRunning(false); + AddAssert("player not exited", () => Player.IsCurrentScreen()); + AddAssert("player not failed", () => !Player.HasFailed); AddAssert("pause overlay shown", () => Player.PauseOverlayVisible); } From d625f3c104df120ffeed7ed8f9a1203fb2504e90 Mon Sep 17 00:00:00 2001 From: David Zhao Date: Thu, 9 May 2019 13:16:56 +0900 Subject: [PATCH 3/7] Private method --- .../Compose/Components/Timeline/ZoomableScrollContainer.cs | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/osu.Game/Screens/Edit/Compose/Components/Timeline/ZoomableScrollContainer.cs b/osu.Game/Screens/Edit/Compose/Components/Timeline/ZoomableScrollContainer.cs index ee6e29c92e..eb78e827f0 100644 --- a/osu.Game/Screens/Edit/Compose/Components/Timeline/ZoomableScrollContainer.cs +++ b/osu.Game/Screens/Edit/Compose/Components/Timeline/ZoomableScrollContainer.cs @@ -92,6 +92,8 @@ namespace osu.Game.Screens.Edit.Compose.Components.Timeline } } + private void updateZoomedContentWidth() => zoomedContent.Width = DrawWidth * currentZoom; + protected override bool OnScroll(ScrollEvent e) { if (e.IsPrecise) @@ -107,7 +109,7 @@ namespace osu.Game.Screens.Edit.Compose.Components.Timeline base.LoadComplete(); // This width only gets updated on the application of a transform, so this needs to be initialized here. - zoomedContent.Width = DrawWidth * currentZoom; + updateZoomedContentWidth(); } private float zoomTarget = 1; @@ -171,7 +173,7 @@ namespace osu.Game.Screens.Edit.Compose.Components.Timeline d.currentZoom = newZoom; - d.zoomedContent.Width = d.DrawWidth * d.currentZoom; + d.updateZoomedContentWidth(); // Temporarily here to make sure ScrollTo gets the correct DrawSize for scrollable area. // TODO: Make sure draw size gets invalidated properly on the framework side, and remove this once it is. d.Invalidate(Invalidation.DrawSize); From c69d813745ae55b66548d82e291215a1024ebe9f Mon Sep 17 00:00:00 2001 From: smoogipoo Date: Thu, 9 May 2019 13:32:18 +0900 Subject: [PATCH 4/7] Fix bindable potentially being set from background thread --- osu.Game/Online/API/APIAccess.cs | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/osu.Game/Online/API/APIAccess.cs b/osu.Game/Online/API/APIAccess.cs index d62b53088a..70cd21b2db 100644 --- a/osu.Game/Online/API/APIAccess.cs +++ b/osu.Game/Online/API/APIAccess.cs @@ -352,10 +352,12 @@ namespace osu.Game.Online.API public void Logout() { flushQueue(); + password = null; authentication.Clear(); - LocalUser.Value = createGuestUser(); State = APIState.Offline; + + Schedule(() => LocalUser.Value = createGuestUser()); } private static User createGuestUser() => new GuestUser(); From 3fed165b749221af2c019885168030b1b4654f13 Mon Sep 17 00:00:00 2001 From: smoogipoo Date: Thu, 9 May 2019 13:33:18 +0900 Subject: [PATCH 5/7] Cleanup some schedules --- osu.Game/Online/API/APIAccess.cs | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/osu.Game/Online/API/APIAccess.cs b/osu.Game/Online/API/APIAccess.cs index 70cd21b2db..08bb9472c1 100644 --- a/osu.Game/Online/API/APIAccess.cs +++ b/osu.Game/Online/API/APIAccess.cs @@ -77,13 +77,13 @@ namespace osu.Game.Online.API /// public void Register(IOnlineComponent component) { - Scheduler.Add(delegate { components.Add(component); }); + Schedule(() => components.Add(component)); component.APIStateChanged(this, state); } public void Unregister(IOnlineComponent component) { - Scheduler.Add(delegate { components.Remove(component); }); + Schedule(() => components.Remove(component)); } public string AccessToken => authentication.RequestAccessToken(); @@ -274,7 +274,7 @@ namespace osu.Game.Online.API state = value; log.Add($@"We just went {state}!"); - Scheduler.Add(delegate + Schedule(() => { components.ForEach(c => c.APIStateChanged(this, state)); OnStateChange?.Invoke(oldState, state); From 35624a5d1cd5969cf12770bda40dab3a5343c9c7 Mon Sep 17 00:00:00 2001 From: smoogipoo Date: Thu, 9 May 2019 13:42:04 +0900 Subject: [PATCH 6/7] Invert scheduling order --- osu.Game/Online/API/APIAccess.cs | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/osu.Game/Online/API/APIAccess.cs b/osu.Game/Online/API/APIAccess.cs index 08bb9472c1..594bc1e3ca 100644 --- a/osu.Game/Online/API/APIAccess.cs +++ b/osu.Game/Online/API/APIAccess.cs @@ -355,9 +355,11 @@ namespace osu.Game.Online.API password = null; authentication.Clear(); - State = APIState.Offline; + // Scheduled prior to state change such that the state changed event is invoked with the correct user present Schedule(() => LocalUser.Value = createGuestUser()); + + State = APIState.Offline; } private static User createGuestUser() => new GuestUser(); From 5c6b4d923f04d63eaaf7a7c0978ba0bbf95cf977 Mon Sep 17 00:00:00 2001 From: smoogipoo Date: Thu, 9 May 2019 13:53:53 +0900 Subject: [PATCH 7/7] Reorder methods --- .../Timeline/ZoomableScrollContainer.cs | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/osu.Game/Screens/Edit/Compose/Components/Timeline/ZoomableScrollContainer.cs b/osu.Game/Screens/Edit/Compose/Components/Timeline/ZoomableScrollContainer.cs index eb78e827f0..829437d599 100644 --- a/osu.Game/Screens/Edit/Compose/Components/Timeline/ZoomableScrollContainer.cs +++ b/osu.Game/Screens/Edit/Compose/Components/Timeline/ZoomableScrollContainer.cs @@ -92,7 +92,13 @@ namespace osu.Game.Screens.Edit.Compose.Components.Timeline } } - private void updateZoomedContentWidth() => zoomedContent.Width = DrawWidth * currentZoom; + protected override void LoadComplete() + { + base.LoadComplete(); + + // This width only gets updated on the application of a transform, so this needs to be initialized here. + updateZoomedContentWidth(); + } protected override bool OnScroll(ScrollEvent e) { @@ -104,13 +110,7 @@ namespace osu.Game.Screens.Edit.Compose.Components.Timeline return true; } - protected override void LoadComplete() - { - base.LoadComplete(); - - // This width only gets updated on the application of a transform, so this needs to be initialized here. - updateZoomedContentWidth(); - } + private void updateZoomedContentWidth() => zoomedContent.Width = DrawWidth * currentZoom; private float zoomTarget = 1;