mirror of
https://github.com/ppy/osu.git
synced 2025-02-21 15:43:36 +08: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.
|
// 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 NUnit.Framework;
|
using NUnit.Framework;
|
||||||
using osu.Framework.Graphics;
|
using osu.Framework.Graphics;
|
||||||
using osu.Framework.Graphics.Containers;
|
using osu.Framework.Graphics.Containers;
|
||||||
using osu.Framework.Graphics.Shapes;
|
using osu.Framework.Graphics.Shapes;
|
||||||
|
using osu.Framework.Utils;
|
||||||
using osu.Game.Graphics.Sprites;
|
using osu.Game.Graphics.Sprites;
|
||||||
using osu.Game.Graphics.UserInterface;
|
using osu.Game.Graphics.UserInterface;
|
||||||
using osuTK;
|
using osuTK;
|
||||||
@ -15,12 +15,10 @@ namespace osu.Game.Tests.Visual.UserInterface
|
|||||||
{
|
{
|
||||||
public class TestSceneLoadingLayer : OsuTestScene
|
public class TestSceneLoadingLayer : OsuTestScene
|
||||||
{
|
{
|
||||||
private LoadingLayer overlay;
|
private TestLoadingLayer overlay;
|
||||||
|
|
||||||
private Container content;
|
private Container content;
|
||||||
|
|
||||||
private Drawable dimContent => overlay.Children.OfType<Box>().First();
|
|
||||||
|
|
||||||
[SetUp]
|
[SetUp]
|
||||||
public void SetUp() => Schedule(() =>
|
public void SetUp() => Schedule(() =>
|
||||||
{
|
{
|
||||||
@ -53,7 +51,7 @@ namespace osu.Game.Tests.Visual.UserInterface
|
|||||||
new TriangleButton { Text = "puush me", Width = 200, Action = () => { } },
|
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());
|
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());
|
AddStep("hide", () => overlay.Hide());
|
||||||
|
|
||||||
AddUntilStep("wait for content restore", () => dimContent.Colour == Color4.White);
|
AddUntilStep("wait for content restore", () => Precision.AlmostEquals(overlay.BackgroundDimLayer.Alpha, 0));
|
||||||
}
|
|
||||||
|
|
||||||
[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);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
[Test]
|
[Test]
|
||||||
@ -100,5 +84,15 @@ namespace osu.Game.Tests.Visual.UserInterface
|
|||||||
|
|
||||||
AddStep("hide", () => overlay.Hide());
|
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>
|
/// </summary>
|
||||||
public class LoadingLayer : LoadingSpinner
|
public class LoadingLayer : LoadingSpinner
|
||||||
{
|
{
|
||||||
private readonly Box backgroundDimLayer;
|
protected Box BackgroundDimLayer { get; private set; }
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Construct a new loading spinner.
|
/// Construct a new loading spinner.
|
||||||
@ -34,7 +34,7 @@ namespace osu.Game.Graphics.UserInterface
|
|||||||
|
|
||||||
if (dimBackground)
|
if (dimBackground)
|
||||||
{
|
{
|
||||||
AddInternal(backgroundDimLayer = new Box
|
AddInternal(BackgroundDimLayer = new Box
|
||||||
{
|
{
|
||||||
Depth = float.MaxValue,
|
Depth = float.MaxValue,
|
||||||
Colour = Color4.Black,
|
Colour = Color4.Black,
|
||||||
@ -65,13 +65,13 @@ namespace osu.Game.Graphics.UserInterface
|
|||||||
|
|
||||||
protected override void PopIn()
|
protected override void PopIn()
|
||||||
{
|
{
|
||||||
backgroundDimLayer?.FadeTo(0.5f, TRANSITION_DURATION * 2, Easing.OutQuint);
|
BackgroundDimLayer?.FadeTo(0.5f, TRANSITION_DURATION * 2, Easing.OutQuint);
|
||||||
base.PopIn();
|
base.PopIn();
|
||||||
}
|
}
|
||||||
|
|
||||||
protected override void PopOut()
|
protected override void PopOut()
|
||||||
{
|
{
|
||||||
backgroundDimLayer?.FadeOut(TRANSITION_DURATION, Easing.OutQuint);
|
BackgroundDimLayer?.FadeOut(TRANSITION_DURATION, Easing.OutQuint);
|
||||||
base.PopOut();
|
base.PopOut();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user