mirror of
https://github.com/ppy/osu.git
synced 2025-02-16 03:42:54 +08:00
Add failing assertions to demonstrate autosize failure
This commit is contained in:
parent
c0e5f11c90
commit
923d9a4e5f
@ -3,9 +3,13 @@
|
|||||||
|
|
||||||
#nullable disable
|
#nullable disable
|
||||||
|
|
||||||
|
using System.Linq;
|
||||||
using NUnit.Framework;
|
using NUnit.Framework;
|
||||||
using osu.Framework.Allocation;
|
using osu.Framework.Allocation;
|
||||||
using osu.Framework.Graphics;
|
using osu.Framework.Graphics;
|
||||||
|
using osu.Framework.Graphics.Sprites;
|
||||||
|
using osu.Framework.Testing;
|
||||||
|
using osu.Framework.Utils;
|
||||||
using osu.Game.Graphics.UserInterface;
|
using osu.Game.Graphics.UserInterface;
|
||||||
using osu.Game.Overlays;
|
using osu.Game.Overlays;
|
||||||
using osuTK.Input;
|
using osuTK.Input;
|
||||||
@ -99,7 +103,10 @@ namespace osu.Game.Tests.Visual.UserInterface
|
|||||||
Origin = Anchor.Centre,
|
Origin = Anchor.Centre,
|
||||||
Text = "Fixed width"
|
Text = "Fixed width"
|
||||||
});
|
});
|
||||||
|
AddAssert("draw width is 200", () => toggleButton.DrawWidth, () => Is.EqualTo(200).Within(Precision.FLOAT_EPSILON));
|
||||||
|
|
||||||
AddStep("change text", () => toggleButton.Text = "New text");
|
AddStep("change text", () => toggleButton.Text = "New text");
|
||||||
|
AddAssert("draw width is 200", () => toggleButton.DrawWidth, () => Is.EqualTo(200).Within(Precision.FLOAT_EPSILON));
|
||||||
|
|
||||||
AddStep("create auto-sizing button", () => Child = toggleButton = new ShearedToggleButton
|
AddStep("create auto-sizing button", () => Child = toggleButton = new ShearedToggleButton
|
||||||
{
|
{
|
||||||
@ -107,7 +114,14 @@ namespace osu.Game.Tests.Visual.UserInterface
|
|||||||
Origin = Anchor.Centre,
|
Origin = Anchor.Centre,
|
||||||
Text = "This button autosizes to its text!"
|
Text = "This button autosizes to its text!"
|
||||||
});
|
});
|
||||||
|
AddAssert("button is wider than text", () => toggleButton.DrawWidth, () => Is.GreaterThan(toggleButton.ChildrenOfType<SpriteText>().Single().DrawWidth));
|
||||||
|
|
||||||
|
float originalDrawWidth = 0;
|
||||||
|
AddStep("store button width", () => originalDrawWidth = toggleButton.DrawWidth);
|
||||||
|
|
||||||
AddStep("change text", () => toggleButton.Text = "New text");
|
AddStep("change text", () => toggleButton.Text = "New text");
|
||||||
|
AddAssert("button is wider than text", () => toggleButton.DrawWidth, () => Is.GreaterThan(toggleButton.ChildrenOfType<SpriteText>().Single().DrawWidth));
|
||||||
|
AddAssert("button width decreased", () => toggleButton.DrawWidth, () => Is.LessThan(originalDrawWidth));
|
||||||
}
|
}
|
||||||
|
|
||||||
[Test]
|
[Test]
|
||||||
|
Loading…
Reference in New Issue
Block a user