1
0
mirror of https://github.com/ppy/osu.git synced 2024-12-14 07:42:57 +08:00

Add texts to make test more visually confirmable, add no parallax screen.

This commit is contained in:
David Zhao 2019-03-22 15:08:47 +09:00
parent dcae86e39a
commit 9a466d97ed

View File

@ -2,32 +2,35 @@
// 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 NUnit.Framework; using NUnit.Framework;
using osu.Framework.Allocation;
using osu.Framework.Graphics; using osu.Framework.Graphics;
using osu.Framework.Graphics.Sprites;
using osu.Framework.Screens; using osu.Framework.Screens;
using osu.Framework.Testing; using osu.Framework.Testing;
using osu.Game.Graphics.Containers; using osu.Game.Graphics.Containers;
using osu.Game.Screens; using osu.Game.Screens;
using osu.Game.Screens.Play; using osu.Game.Screens.Play;
using osuTK.Graphics;
namespace osu.Game.Tests.Visual namespace osu.Game.Tests.Visual
{ {
[TestFixture] [TestFixture]
public class TestCaseOsuScreenStack : OsuTestCase public class TestCaseOsuScreenStack : OsuTestCase
{ {
private TestScreen baseScreen; private NoParallaxTestScreen baseScreen;
private TestOsuScreenStack stack; private TestOsuScreenStack stack;
[SetUpSteps] [SetUpSteps]
public void Setup() public void Setup()
{ {
AddStep("Create new screen stack", () => { Child = stack = new TestOsuScreenStack { RelativeSizeAxes = Axes.Both }; }); AddStep("Create new screen stack", () => { Child = stack = new TestOsuScreenStack { RelativeSizeAxes = Axes.Both }; });
AddStep("Push new base screen", () => stack.Push(baseScreen = new TestScreen())); AddStep("Push new base screen", () => stack.Push(baseScreen = new NoParallaxTestScreen("THIS IS SCREEN 1. THIS SCREEN SHOULD HAVE NO PARALLAX.")));
} }
[Test] [Test]
public void ParallaxAssignmentTest() public void ParallaxAssignmentTest()
{ {
AddStep("Push new screen to base screen", () => baseScreen.Push(new TestScreen())); AddStep("Push new screen to base screen", () => baseScreen.Push(new TestScreen("THIS IS SCREEN 2. THIS SCREEN SHOULD HAVE PARALLAX.")));
AddAssert("Parallax is correct", () => stack.IsParallaxSet); AddAssert("Parallax is correct", () => stack.IsParallaxSet);
AddStep("Exit from new screen", () => { baseScreen.MakeCurrent(); }); AddStep("Exit from new screen", () => { baseScreen.MakeCurrent(); });
AddAssert("Parallax is correct", () => stack.IsParallaxSet); AddAssert("Parallax is correct", () => stack.IsParallaxSet);
@ -35,6 +38,32 @@ namespace osu.Game.Tests.Visual
private class TestScreen : ScreenWithBeatmapBackground private class TestScreen : ScreenWithBeatmapBackground
{ {
private readonly string screenText;
public TestScreen(string screenText)
{
this.screenText = screenText;
}
[BackgroundDependencyLoader]
private void load()
{
AddInternal(new SpriteText
{
Text = screenText,
Colour = Color4.White
});
}
}
private class NoParallaxTestScreen : TestScreen
{
public NoParallaxTestScreen(string screenText)
: base(screenText)
{
}
public override float BackgroundParallaxAmount => 0.0f;
} }
private class TestOsuScreenStack : OsuScreenStack private class TestOsuScreenStack : OsuScreenStack