mirror of
https://github.com/ppy/osu
synced 2025-01-20 13:00:54 +00:00
Add failing assertions to demonstrate autosize failure
This commit is contained in:
parent
c0e5f11c90
commit
923d9a4e5f
@ -3,9 +3,13 @@
|
||||
|
||||
#nullable disable
|
||||
|
||||
using System.Linq;
|
||||
using NUnit.Framework;
|
||||
using osu.Framework.Allocation;
|
||||
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.Overlays;
|
||||
using osuTK.Input;
|
||||
@ -99,7 +103,10 @@ namespace osu.Game.Tests.Visual.UserInterface
|
||||
Origin = Anchor.Centre,
|
||||
Text = "Fixed width"
|
||||
});
|
||||
AddAssert("draw width is 200", () => toggleButton.DrawWidth, () => Is.EqualTo(200).Within(Precision.FLOAT_EPSILON));
|
||||
|
||||
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
|
||||
{
|
||||
@ -107,7 +114,14 @@ namespace osu.Game.Tests.Visual.UserInterface
|
||||
Origin = Anchor.Centre,
|
||||
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");
|
||||
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]
|
||||
|
Loading…
Reference in New Issue
Block a user