feat(D.2b): UiMeter vital bar + fill-geometry tests
Adds UiMeter, the horizontal vital-bar widget for the D.2b retail-look UI toolkit. Solid-color fill for Spec 1; the retail orb sprite + scissor crop path is reserved for a later sub-phase. Five unit tests (1 Fact + 4 Theory) cover half-fill geometry and clamping at -1/0/1/2 fractions. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
This commit is contained in:
parent
0bf790c8bf
commit
064ef41ce4
2 changed files with 65 additions and 0 deletions
25
tests/AcDream.App.Tests/UI/UiMeterTests.cs
Normal file
25
tests/AcDream.App.Tests/UI/UiMeterTests.cs
Normal file
|
|
@ -0,0 +1,25 @@
|
|||
using AcDream.App.UI;
|
||||
|
||||
namespace AcDream.App.Tests.UI;
|
||||
|
||||
public class UiMeterTests
|
||||
{
|
||||
[Fact]
|
||||
public void ComputeFillRect_HalfFillIsHalfWidth()
|
||||
{
|
||||
var (x, y, w, h) = UiMeter.ComputeFillRect(0.5f, 200f, 12f);
|
||||
Assert.Equal(0f, x); Assert.Equal(0f, y);
|
||||
Assert.Equal(100f, w); Assert.Equal(12f, h);
|
||||
}
|
||||
|
||||
[Theory]
|
||||
[InlineData(-1f, 0f)] // clamps below 0
|
||||
[InlineData(2f, 200f)] // clamps above 1
|
||||
[InlineData(0f, 0f)]
|
||||
[InlineData(1f, 200f)]
|
||||
public void ComputeFillRect_ClampsFraction(float pct, float expectedW)
|
||||
{
|
||||
var (_, _, w, _) = UiMeter.ComputeFillRect(pct, 200f, 12f);
|
||||
Assert.Equal(expectedW, w);
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue