2020-02-20 18:47:50 +08:00
|
|
|
// 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.
|
|
|
|
|
2022-06-17 15:37:17 +08:00
|
|
|
#nullable disable
|
|
|
|
|
2020-02-20 18:47:50 +08:00
|
|
|
using NUnit.Framework;
|
|
|
|
using osu.Framework.Graphics;
|
|
|
|
using osu.Framework.Graphics.Containers;
|
|
|
|
using osu.Framework.Graphics.Shapes;
|
2021-01-05 17:10:39 +08:00
|
|
|
using osu.Framework.Utils;
|
2020-02-20 18:47:50 +08:00
|
|
|
using osu.Game.Graphics.Sprites;
|
|
|
|
using osu.Game.Graphics.UserInterface;
|
2022-11-24 15:26:57 +08:00
|
|
|
using osu.Game.Graphics.UserInterfaceV2;
|
2020-02-20 18:47:50 +08:00
|
|
|
using osuTK;
|
|
|
|
using osuTK.Graphics;
|
|
|
|
|
|
|
|
namespace osu.Game.Tests.Visual.UserInterface
|
|
|
|
{
|
2022-11-24 13:32:20 +08:00
|
|
|
public partial class TestSceneLoadingLayer : OsuTestScene
|
2020-02-20 18:47:50 +08:00
|
|
|
{
|
2021-01-05 17:10:39 +08:00
|
|
|
private TestLoadingLayer overlay;
|
2020-02-21 14:31:40 +08:00
|
|
|
|
2020-02-21 15:20:17 +08:00
|
|
|
private Container content;
|
|
|
|
|
2020-02-20 18:47:50 +08:00
|
|
|
[SetUp]
|
|
|
|
public void SetUp() => Schedule(() =>
|
|
|
|
{
|
|
|
|
Children = new[]
|
|
|
|
{
|
2020-02-21 15:20:17 +08:00
|
|
|
content = new Container
|
2020-02-20 18:47:50 +08:00
|
|
|
{
|
|
|
|
Size = new Vector2(300),
|
|
|
|
Anchor = Anchor.Centre,
|
|
|
|
Origin = Anchor.Centre,
|
2021-01-04 21:42:39 +08:00
|
|
|
Children = new Drawable[]
|
2020-02-20 18:47:50 +08:00
|
|
|
{
|
|
|
|
new Box
|
|
|
|
{
|
|
|
|
Colour = Color4.SlateGray,
|
|
|
|
RelativeSizeAxes = Axes.Both,
|
|
|
|
},
|
2021-01-04 21:42:39 +08:00
|
|
|
new FillFlowContainer
|
2020-02-20 18:47:50 +08:00
|
|
|
{
|
|
|
|
Anchor = Anchor.Centre,
|
|
|
|
Origin = Anchor.Centre,
|
|
|
|
Direction = FillDirection.Vertical,
|
|
|
|
Spacing = new Vector2(10),
|
|
|
|
RelativeSizeAxes = Axes.Both,
|
|
|
|
Size = new Vector2(0.9f),
|
|
|
|
Children = new Drawable[]
|
|
|
|
{
|
|
|
|
new OsuSpriteText { Text = "Sample content" },
|
2022-11-24 15:26:57 +08:00
|
|
|
new RoundedButton { Text = "can't puush me", Width = 200, },
|
|
|
|
new RoundedButton { Text = "puush me", Width = 200, Action = () => { } },
|
2020-02-20 18:47:50 +08:00
|
|
|
}
|
|
|
|
},
|
2021-01-05 17:10:39 +08:00
|
|
|
overlay = new TestLoadingLayer(true),
|
2020-02-20 18:47:50 +08:00
|
|
|
}
|
|
|
|
},
|
|
|
|
};
|
|
|
|
});
|
|
|
|
|
|
|
|
[Test]
|
2020-02-21 15:20:17 +08:00
|
|
|
public void TestShowHide()
|
2020-02-20 18:47:50 +08:00
|
|
|
{
|
|
|
|
AddAssert("not visible", () => !overlay.IsPresent);
|
|
|
|
|
|
|
|
AddStep("show", () => overlay.Show());
|
|
|
|
|
2021-01-05 17:10:39 +08:00
|
|
|
AddUntilStep("wait for content dim", () => overlay.BackgroundDimLayer.Alpha > 0);
|
2020-02-20 18:47:50 +08:00
|
|
|
|
|
|
|
AddStep("hide", () => overlay.Hide());
|
|
|
|
|
2021-01-05 17:10:39 +08:00
|
|
|
AddUntilStep("wait for content restore", () => Precision.AlmostEquals(overlay.BackgroundDimLayer.Alpha, 0));
|
2020-02-20 18:47:50 +08:00
|
|
|
}
|
2020-02-21 15:20:17 +08:00
|
|
|
|
|
|
|
[Test]
|
|
|
|
public void TestLargeArea()
|
|
|
|
{
|
|
|
|
AddStep("show", () =>
|
|
|
|
{
|
|
|
|
content.RelativeSizeAxes = Axes.Both;
|
|
|
|
content.Size = new Vector2(1);
|
|
|
|
|
|
|
|
overlay.Show();
|
|
|
|
});
|
|
|
|
|
|
|
|
AddStep("hide", () => overlay.Hide());
|
|
|
|
}
|
2021-01-05 17:10:39 +08:00
|
|
|
|
2022-11-24 13:32:20 +08:00
|
|
|
private partial class TestLoadingLayer : LoadingLayer
|
2021-01-05 17:10:39 +08:00
|
|
|
{
|
|
|
|
public new Box BackgroundDimLayer => base.BackgroundDimLayer;
|
|
|
|
|
|
|
|
public TestLoadingLayer(bool dimBackground = false, bool withBox = true)
|
|
|
|
: base(dimBackground, withBox)
|
|
|
|
{
|
|
|
|
}
|
|
|
|
}
|
2020-02-20 18:47:50 +08:00
|
|
|
}
|
|
|
|
}
|