mirror of
https://github.com/ppy/osu.git
synced 2025-02-02 04:03:16 +08:00
Update tests and delay push animation until loader is done disappearing
This commit is contained in:
parent
4012e878b0
commit
ec88f7a712
@ -1,12 +1,15 @@
|
|||||||
// Copyright (c) ppy Pty Ltd <contact@ppy.sh>. Licensed under the MIT Licence.
|
// Copyright (c) ppy Pty Ltd <contact@ppy.sh>. Licensed under the MIT Licence.
|
||||||
// See the LICENCE file in the repository root for full licence text.
|
// See the LICENCE file in the repository root for full licence text.
|
||||||
|
|
||||||
|
using System.Linq;
|
||||||
using System.Threading;
|
using System.Threading;
|
||||||
using NUnit.Framework;
|
using NUnit.Framework;
|
||||||
using osu.Framework.Allocation;
|
using osu.Framework.Allocation;
|
||||||
using osu.Framework.Graphics;
|
using osu.Framework.Graphics;
|
||||||
using osu.Framework.Graphics.Shapes;
|
using osu.Framework.Graphics.Shapes;
|
||||||
using osu.Framework.Screens;
|
using osu.Framework.Screens;
|
||||||
|
using osu.Framework.Testing;
|
||||||
|
using osu.Game.Graphics.UserInterface;
|
||||||
using osu.Game.Screens;
|
using osu.Game.Screens;
|
||||||
using osu.Game.Screens.Menu;
|
using osu.Game.Screens.Menu;
|
||||||
using osuTK.Graphics;
|
using osuTK.Graphics;
|
||||||
@ -42,33 +45,33 @@ namespace osu.Game.Tests.Visual.Menus
|
|||||||
|
|
||||||
LoadScreen(loader);
|
LoadScreen(loader);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
AddAssert("spinner did not display", () => loader.LoadingSpinner.Alpha == 0);
|
||||||
|
|
||||||
|
AddUntilStep("loaded", () => loader.ScreenLoaded);
|
||||||
|
AddUntilStep("not current", () => !loader.IsCurrentScreen());
|
||||||
}
|
}
|
||||||
|
|
||||||
[Test]
|
[Test]
|
||||||
public void TestDelayedLoad()
|
public void TestDelayedLoad()
|
||||||
{
|
{
|
||||||
AddStep("begin loading", () => LoadScreen(loader = new TestLoader()));
|
AddStep("begin loading", () => LoadScreen(loader = new TestLoader()));
|
||||||
AddUntilStep("wait for logo visible", () => loader.Logo?.Alpha > 0);
|
AddUntilStep("wait for spinner visible", () => loader.LoadingSpinner?.Alpha > 0);
|
||||||
AddStep("finish loading", () => loader.AllowLoad.Set());
|
AddStep("finish loading", () => loader.AllowLoad.Set());
|
||||||
AddUntilStep("loaded", () => loader.Logo != null && loader.ScreenLoaded);
|
AddUntilStep("spinner gone", () => loader.LoadingSpinner?.Alpha == 0);
|
||||||
AddUntilStep("logo gone", () => loader.Logo?.Alpha == 0);
|
AddUntilStep("loaded", () => loader.ScreenLoaded);
|
||||||
|
AddUntilStep("not current", () => !loader.IsCurrentScreen());
|
||||||
}
|
}
|
||||||
|
|
||||||
private class TestLoader : Loader
|
private class TestLoader : Loader
|
||||||
{
|
{
|
||||||
public readonly ManualResetEventSlim AllowLoad = new ManualResetEventSlim();
|
public readonly ManualResetEventSlim AllowLoad = new ManualResetEventSlim();
|
||||||
|
|
||||||
public OsuLogo Logo;
|
public LoadingSpinner LoadingSpinner => this.ChildrenOfType<LoadingSpinner>().Single();
|
||||||
private TestScreen screen;
|
private TestScreen screen;
|
||||||
|
|
||||||
public bool ScreenLoaded => screen.IsCurrentScreen();
|
public bool ScreenLoaded => screen.IsCurrentScreen();
|
||||||
|
|
||||||
protected override void LogoArriving(OsuLogo logo, bool resuming)
|
|
||||||
{
|
|
||||||
Logo = logo;
|
|
||||||
base.LogoArriving(logo, resuming);
|
|
||||||
}
|
|
||||||
|
|
||||||
protected override OsuScreen CreateLoadableScreen() => screen = new TestScreen();
|
protected override OsuScreen CreateLoadableScreen() => screen = new TestScreen();
|
||||||
protected override ShaderPrecompiler CreateShaderPrecompiler() => new TestShaderPrecompiler(AllowLoad);
|
protected override ShaderPrecompiler CreateShaderPrecompiler() => new TestShaderPrecompiler(AllowLoad);
|
||||||
|
|
||||||
|
@ -19,7 +19,7 @@ namespace osu.Game.Graphics.UserInterface
|
|||||||
|
|
||||||
protected Container MainContents;
|
protected Container MainContents;
|
||||||
|
|
||||||
protected const float TRANSITION_DURATION = 500;
|
public const float TRANSITION_DURATION = 500;
|
||||||
|
|
||||||
private const float spin_duration = 900;
|
private const float spin_duration = 900;
|
||||||
|
|
||||||
|
@ -5,6 +5,7 @@ using System.Collections.Generic;
|
|||||||
using System.Linq;
|
using System.Linq;
|
||||||
using osu.Framework.Allocation;
|
using osu.Framework.Allocation;
|
||||||
using osu.Framework.Graphics;
|
using osu.Framework.Graphics;
|
||||||
|
using osu.Framework.Graphics.Containers;
|
||||||
using osu.Framework.Graphics.Shaders;
|
using osu.Framework.Graphics.Shaders;
|
||||||
using osu.Framework.Utils;
|
using osu.Framework.Utils;
|
||||||
using osu.Game.Screens.Menu;
|
using osu.Game.Screens.Menu;
|
||||||
@ -87,8 +88,14 @@ namespace osu.Game.Screens
|
|||||||
}
|
}
|
||||||
|
|
||||||
spinnerShow?.Cancel();
|
spinnerShow?.Cancel();
|
||||||
spinner.Hide();
|
|
||||||
this.Push(loadableScreen);
|
if (spinner.State.Value == Visibility.Visible)
|
||||||
|
{
|
||||||
|
spinner.Hide();
|
||||||
|
Scheduler.AddDelayed(() => this.Push(loadableScreen), LoadingSpinner.TRANSITION_DURATION);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
this.Push(loadableScreen);
|
||||||
}
|
}
|
||||||
|
|
||||||
[BackgroundDependencyLoader]
|
[BackgroundDependencyLoader]
|
||||||
|
Loading…
Reference in New Issue
Block a user