2020-02-20 10:47:50 +00: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.
|
|
|
|
|
|
|
|
using NUnit.Framework;
|
|
|
|
using osu.Framework.Graphics;
|
|
|
|
using osu.Framework.Graphics.Containers;
|
|
|
|
using osu.Framework.Graphics.Shapes;
|
|
|
|
using osu.Game.Graphics.Sprites;
|
|
|
|
using osu.Game.Graphics.UserInterface;
|
|
|
|
using osuTK;
|
|
|
|
using osuTK.Graphics;
|
|
|
|
|
|
|
|
namespace osu.Game.Tests.Visual.UserInterface
|
|
|
|
{
|
2020-02-21 06:31:40 +00:00
|
|
|
public class TestSceneLoadingLayer : OsuTestScene
|
2020-02-20 10:47:50 +00:00
|
|
|
{
|
|
|
|
private Drawable dimContent;
|
2020-02-21 06:31:40 +00:00
|
|
|
private LoadingLayer overlay;
|
|
|
|
|
2020-02-21 07:20:17 +00:00
|
|
|
private Container content;
|
|
|
|
|
2020-02-20 10:47:50 +00:00
|
|
|
[SetUp]
|
|
|
|
public void SetUp() => Schedule(() =>
|
|
|
|
{
|
|
|
|
Children = new[]
|
|
|
|
{
|
2020-02-21 07:20:17 +00:00
|
|
|
content = new Container
|
2020-02-20 10:47:50 +00:00
|
|
|
{
|
|
|
|
Size = new Vector2(300),
|
|
|
|
Anchor = Anchor.Centre,
|
|
|
|
Origin = Anchor.Centre,
|
|
|
|
Children = new[]
|
|
|
|
{
|
|
|
|
new Box
|
|
|
|
{
|
|
|
|
Colour = Color4.SlateGray,
|
|
|
|
RelativeSizeAxes = Axes.Both,
|
|
|
|
},
|
|
|
|
dimContent = new FillFlowContainer
|
|
|
|
{
|
|
|
|
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" },
|
|
|
|
new TriangleButton { Text = "can't puush me", Width = 200, },
|
|
|
|
new TriangleButton { Text = "puush me", Width = 200, Action = () => { } },
|
|
|
|
}
|
|
|
|
},
|
2020-02-21 06:31:40 +00:00
|
|
|
overlay = new LoadingLayer(dimContent),
|
2020-02-20 10:47:50 +00:00
|
|
|
}
|
|
|
|
},
|
|
|
|
};
|
|
|
|
});
|
|
|
|
|
|
|
|
[Test]
|
2020-02-21 07:20:17 +00:00
|
|
|
public void TestShowHide()
|
2020-02-20 10:47:50 +00:00
|
|
|
{
|
|
|
|
AddAssert("not visible", () => !overlay.IsPresent);
|
|
|
|
|
|
|
|
AddStep("show", () => overlay.Show());
|
|
|
|
|
|
|
|
AddUntilStep("wait for content dim", () => dimContent.Colour != Color4.White);
|
|
|
|
|
|
|
|
AddStep("hide", () => overlay.Hide());
|
|
|
|
|
|
|
|
AddUntilStep("wait for content restore", () => dimContent.Colour == Color4.White);
|
|
|
|
}
|
|
|
|
|
|
|
|
[Test]
|
2020-02-21 07:20:17 +00:00
|
|
|
public void TestContentRestoreOnDispose()
|
2020-02-20 10:47:50 +00:00
|
|
|
{
|
|
|
|
AddAssert("not visible", () => !overlay.IsPresent);
|
|
|
|
|
|
|
|
AddStep("show", () => overlay.Show());
|
|
|
|
|
|
|
|
AddUntilStep("wait for content dim", () => dimContent.Colour != Color4.White);
|
|
|
|
|
2020-02-21 07:20:17 +00:00
|
|
|
AddStep("expire", () => overlay.Expire());
|
2020-02-20 10:47:50 +00:00
|
|
|
|
|
|
|
AddUntilStep("wait for content restore", () => dimContent.Colour == Color4.White);
|
|
|
|
}
|
2020-02-21 07:20:17 +00:00
|
|
|
|
|
|
|
[Test]
|
|
|
|
public void TestLargeArea()
|
|
|
|
{
|
|
|
|
AddStep("show", () =>
|
|
|
|
{
|
|
|
|
content.RelativeSizeAxes = Axes.Both;
|
|
|
|
content.Size = new Vector2(1);
|
|
|
|
|
|
|
|
overlay.Show();
|
|
|
|
});
|
|
|
|
|
|
|
|
AddStep("hide", () => overlay.Hide());
|
|
|
|
}
|
2020-02-20 10:47:50 +00:00
|
|
|
}
|
|
|
|
}
|