A game framework written with osu! in mind.
0
fork

Configure Feed

Select the types of activity you want to include in your feed.

Add failing assertion

+15 -2
+15 -2
osu.Framework.Tests/Visual/Sprites/TestSceneSpriteTextMaxWidth.cs
··· 7 7 using osu.Framework.Graphics.Containers; 8 8 using osu.Framework.Graphics.Shapes; 9 9 using osu.Framework.Graphics.Sprites; 10 + using osu.Framework.Text; 10 11 using osuTK.Graphics; 11 12 12 13 namespace osu.Framework.Tests.Visual.Sprites ··· 70 71 [Test] 71 72 public void TestMaxWidthWithRelativeSize() 72 73 { 74 + float textWidth = 0; 75 + 73 76 createTest(s => 74 77 { 75 78 s.RelativeSizeAxes = Axes.X; ··· 77 80 s.Text = "some very long text that should exceed the max width"; 78 81 s.Truncate = true; 79 82 }, Axes.Y); 83 + AddStep("store text width", () => textWidth = display.Text.TextBuilder.Bounds.X); 80 84 81 85 AddStep("set parent size", () => display.Width = 100); 82 86 AddAssert("size <= max", () => display.Text.DrawWidth <= 50); 87 + AddAssert("width increased", () => display.Text.TextBuilder.Bounds.X > textWidth); 83 88 } 84 89 85 90 private void createTest(Action<SpriteText> initFunc, Axes autoSizeAxes = Axes.Both) ··· 93 98 94 99 private class VisualDisplay : CompositeDrawable 95 100 { 96 - public readonly SpriteText Text; 101 + public readonly TestSpriteText Text; 97 102 98 103 public VisualDisplay(Action<SpriteText> initFunc, Axes autoSizeAxes = Axes.Both) 99 104 { ··· 109 114 Alpha = 0.2f, 110 115 Colour = Color4.Pink 111 116 }, 112 - Text = new SpriteText { AllowMultiline = false } 117 + Text = new TestSpriteText { AllowMultiline = false } 113 118 }; 114 119 115 120 initFunc?.Invoke(Text); 116 121 } 122 + } 123 + 124 + private class TestSpriteText : SpriteText 125 + { 126 + public TextBuilder TextBuilder { get; private set; } 127 + 128 + protected override TextBuilder CreateTextBuilder(ITexturedGlyphLookupStore store) 129 + => TextBuilder = base.CreateTextBuilder(store); 117 130 } 118 131 } 119 132 }