mirror of
https://github.com/osukey/osukey.git
synced 2025-06-20 18:58:05 +09:00
Modify OsuTextBox
test scene to test against colour provider
This commit is contained in:
parent
e9a35cbe7e
commit
a7f3beabe3
@ -1,39 +1,27 @@
|
|||||||
// 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.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
using NUnit.Framework;
|
using NUnit.Framework;
|
||||||
|
using osu.Framework.Extensions.IEnumerableExtensions;
|
||||||
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.Testing;
|
||||||
using osu.Game.Graphics.UserInterface;
|
using osu.Game.Graphics.UserInterface;
|
||||||
|
using osu.Game.Overlays;
|
||||||
using osuTK;
|
using osuTK;
|
||||||
using osuTK.Graphics;
|
|
||||||
|
|
||||||
namespace osu.Game.Tests.Visual.UserInterface
|
namespace osu.Game.Tests.Visual.UserInterface
|
||||||
{
|
{
|
||||||
public class TestSceneOsuTextBox : OsuTestScene
|
public class TestSceneOsuTextBox : ThemeComparisonTestScene
|
||||||
{
|
{
|
||||||
private readonly OsuNumberBox numberBox;
|
private IEnumerable<OsuNumberBox> numberBoxes => this.ChildrenOfType<OsuNumberBox>();
|
||||||
|
|
||||||
public TestSceneOsuTextBox()
|
protected override Drawable CreateContent() => new FillFlowContainer
|
||||||
{
|
{
|
||||||
Child = new Container
|
RelativeSizeAxes = Axes.X,
|
||||||
{
|
AutoSizeAxes = Axes.Y,
|
||||||
Masking = true,
|
|
||||||
CornerRadius = 10f,
|
|
||||||
AutoSizeAxes = Axes.Both,
|
|
||||||
Padding = new MarginPadding(15f),
|
|
||||||
Children = new Drawable[]
|
|
||||||
{
|
|
||||||
new Box
|
|
||||||
{
|
|
||||||
RelativeSizeAxes = Axes.Both,
|
|
||||||
Colour = Color4.DarkSlateGray,
|
|
||||||
Alpha = 0.75f,
|
|
||||||
},
|
|
||||||
new FillFlowContainer
|
|
||||||
{
|
|
||||||
AutoSizeAxes = Axes.Both,
|
|
||||||
Direction = FillDirection.Vertical,
|
Direction = FillDirection.Vertical,
|
||||||
Padding = new MarginPadding(50f),
|
Padding = new MarginPadding(50f),
|
||||||
Spacing = new Vector2(0f, 50f),
|
Spacing = new Vector2(0f, 50f),
|
||||||
@ -41,40 +29,39 @@ namespace osu.Game.Tests.Visual.UserInterface
|
|||||||
{
|
{
|
||||||
new OsuTextBox
|
new OsuTextBox
|
||||||
{
|
{
|
||||||
Width = 500f,
|
RelativeSizeAxes = Axes.X,
|
||||||
PlaceholderText = "Normal textbox",
|
PlaceholderText = "Normal textbox",
|
||||||
},
|
},
|
||||||
new OsuPasswordTextBox
|
new OsuPasswordTextBox
|
||||||
{
|
{
|
||||||
Width = 500f,
|
RelativeSizeAxes = Axes.X,
|
||||||
PlaceholderText = "Password textbox",
|
PlaceholderText = "Password textbox",
|
||||||
},
|
},
|
||||||
numberBox = new OsuNumberBox
|
new OsuNumberBox
|
||||||
{
|
{
|
||||||
Width = 500f,
|
RelativeSizeAxes = Axes.X,
|
||||||
PlaceholderText = "Number textbox"
|
PlaceholderText = "Number textbox"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
}
|
|
||||||
};
|
};
|
||||||
}
|
|
||||||
|
|
||||||
[Test]
|
[Test]
|
||||||
public void TestNumberBox()
|
public void TestNumberBox()
|
||||||
{
|
{
|
||||||
clearTextbox(numberBox);
|
AddStep("create themed content", () => CreateThemedContent(OverlayColourScheme.Red));
|
||||||
AddStep("enter numbers", () => numberBox.Text = "987654321");
|
|
||||||
expectedValue(numberBox, "987654321");
|
|
||||||
|
|
||||||
clearTextbox(numberBox);
|
clearTextboxes(numberBoxes);
|
||||||
AddStep("enter text + single number", () => numberBox.Text = "1 hello 2 world 3");
|
AddStep("enter numbers", () => numberBoxes.ForEach(numberBox => numberBox.Text = "987654321"));
|
||||||
expectedValue(numberBox, "123");
|
expectedValue(numberBoxes, "987654321");
|
||||||
|
|
||||||
clearTextbox(numberBox);
|
clearTextboxes(numberBoxes);
|
||||||
|
AddStep("enter text + single number", () => numberBoxes.ForEach(numberBox => numberBox.Text = "1 hello 2 world 3"));
|
||||||
|
expectedValue(numberBoxes, "123");
|
||||||
|
|
||||||
|
clearTextboxes(numberBoxes);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void clearTextbox(OsuTextBox textBox) => AddStep("clear textbox", () => textBox.Text = null);
|
private void clearTextboxes(IEnumerable<OsuTextBox> textBoxes) => AddStep("clear textbox", () => textBoxes.ForEach(textBox => textBox.Text = null));
|
||||||
private void expectedValue(OsuTextBox textBox, string value) => AddAssert("expected textbox value", () => textBox.Text == value);
|
private void expectedValue(IEnumerable<OsuTextBox> textBoxes, string value) => AddAssert("expected textbox value", () => textBoxes.All(textbox => textbox.Text == value));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -33,7 +33,7 @@ namespace osu.Game.Tests.Visual.UserInterface
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
private void createThemedContent(OverlayColourScheme colourScheme)
|
protected void CreateThemedContent(OverlayColourScheme colourScheme)
|
||||||
{
|
{
|
||||||
var colourProvider = new OverlayColourProvider(colourScheme);
|
var colourProvider = new OverlayColourProvider(colourScheme);
|
||||||
|
|
||||||
@ -63,7 +63,7 @@ namespace osu.Game.Tests.Visual.UserInterface
|
|||||||
public void TestAllColourSchemes()
|
public void TestAllColourSchemes()
|
||||||
{
|
{
|
||||||
foreach (var scheme in Enum.GetValues(typeof(OverlayColourScheme)).Cast<OverlayColourScheme>())
|
foreach (var scheme in Enum.GetValues(typeof(OverlayColourScheme)).Cast<OverlayColourScheme>())
|
||||||
AddStep($"set {scheme} scheme", () => createThemedContent(scheme));
|
AddStep($"set {scheme} scheme", () => CreateThemedContent(scheme));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user