mirror of
https://github.com/ppy/osu
synced 2024-12-23 23:33:36 +00:00
Fix test (and remove no longer valid test)
This commit is contained in:
parent
0b1ee2e267
commit
0639429a23
@ -1,11 +1,11 @@
|
||||
// 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.
|
||||
|
||||
using System.Linq;
|
||||
using NUnit.Framework;
|
||||
using osu.Framework.Graphics;
|
||||
using osu.Framework.Graphics.Containers;
|
||||
using osu.Framework.Graphics.Shapes;
|
||||
using osu.Framework.Utils;
|
||||
using osu.Game.Graphics.Sprites;
|
||||
using osu.Game.Graphics.UserInterface;
|
||||
using osuTK;
|
||||
@ -15,12 +15,10 @@ namespace osu.Game.Tests.Visual.UserInterface
|
||||
{
|
||||
public class TestSceneLoadingLayer : OsuTestScene
|
||||
{
|
||||
private LoadingLayer overlay;
|
||||
private TestLoadingLayer overlay;
|
||||
|
||||
private Container content;
|
||||
|
||||
private Drawable dimContent => overlay.Children.OfType<Box>().First();
|
||||
|
||||
[SetUp]
|
||||
public void SetUp() => Schedule(() =>
|
||||
{
|
||||
@ -53,7 +51,7 @@ namespace osu.Game.Tests.Visual.UserInterface
|
||||
new TriangleButton { Text = "puush me", Width = 200, Action = () => { } },
|
||||
}
|
||||
},
|
||||
overlay = new LoadingLayer(true),
|
||||
overlay = new TestLoadingLayer(true),
|
||||
}
|
||||
},
|
||||
};
|
||||
@ -66,25 +64,11 @@ namespace osu.Game.Tests.Visual.UserInterface
|
||||
|
||||
AddStep("show", () => overlay.Show());
|
||||
|
||||
AddUntilStep("wait for content dim", () => dimContent.Colour != Color4.White);
|
||||
AddUntilStep("wait for content dim", () => overlay.BackgroundDimLayer.Alpha > 0);
|
||||
|
||||
AddStep("hide", () => overlay.Hide());
|
||||
|
||||
AddUntilStep("wait for content restore", () => dimContent.Colour == Color4.White);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void TestContentRestoreOnDispose()
|
||||
{
|
||||
AddAssert("not visible", () => !overlay.IsPresent);
|
||||
|
||||
AddStep("show", () => overlay.Show());
|
||||
|
||||
AddUntilStep("wait for content dim", () => dimContent.Colour != Color4.White);
|
||||
|
||||
AddStep("expire", () => overlay.Expire());
|
||||
|
||||
AddUntilStep("wait for content restore", () => dimContent.Colour == Color4.White);
|
||||
AddUntilStep("wait for content restore", () => Precision.AlmostEquals(overlay.BackgroundDimLayer.Alpha, 0));
|
||||
}
|
||||
|
||||
[Test]
|
||||
@ -100,5 +84,15 @@ namespace osu.Game.Tests.Visual.UserInterface
|
||||
|
||||
AddStep("hide", () => overlay.Hide());
|
||||
}
|
||||
|
||||
private class TestLoadingLayer : LoadingLayer
|
||||
{
|
||||
public new Box BackgroundDimLayer => base.BackgroundDimLayer;
|
||||
|
||||
public TestLoadingLayer(bool dimBackground = false, bool withBox = true)
|
||||
: base(dimBackground, withBox)
|
||||
{
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -17,7 +17,7 @@ namespace osu.Game.Graphics.UserInterface
|
||||
/// </summary>
|
||||
public class LoadingLayer : LoadingSpinner
|
||||
{
|
||||
private readonly Box backgroundDimLayer;
|
||||
protected Box BackgroundDimLayer { get; private set; }
|
||||
|
||||
/// <summary>
|
||||
/// Construct a new loading spinner.
|
||||
@ -34,7 +34,7 @@ namespace osu.Game.Graphics.UserInterface
|
||||
|
||||
if (dimBackground)
|
||||
{
|
||||
AddInternal(backgroundDimLayer = new Box
|
||||
AddInternal(BackgroundDimLayer = new Box
|
||||
{
|
||||
Depth = float.MaxValue,
|
||||
Colour = Color4.Black,
|
||||
@ -65,13 +65,13 @@ namespace osu.Game.Graphics.UserInterface
|
||||
|
||||
protected override void PopIn()
|
||||
{
|
||||
backgroundDimLayer?.FadeTo(0.5f, TRANSITION_DURATION * 2, Easing.OutQuint);
|
||||
BackgroundDimLayer?.FadeTo(0.5f, TRANSITION_DURATION * 2, Easing.OutQuint);
|
||||
base.PopIn();
|
||||
}
|
||||
|
||||
protected override void PopOut()
|
||||
{
|
||||
backgroundDimLayer?.FadeOut(TRANSITION_DURATION, Easing.OutQuint);
|
||||
BackgroundDimLayer?.FadeOut(TRANSITION_DURATION, Easing.OutQuint);
|
||||
base.PopOut();
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user