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>
25 lines
684 B
C#
25 lines
684 B
C#
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);
|
|
}
|
|
}
|