feat(ui): D.2b-B — UiMeter vertical fill (burden bar, retail m_eDirection 2/4)

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
This commit is contained in:
Erik 2026-06-21 08:58:37 +02:00
parent fb050aed4d
commit 5e75d2ac76
2 changed files with 96 additions and 8 deletions

View file

@ -0,0 +1,35 @@
using AcDream.App.UI;
using Xunit;
namespace AcDream.App.Tests.UI;
public class UiMeterVerticalTests
{
[Fact]
public void Vertical_fill_from_bottom_occupies_lower_fraction()
{
// 11x58 bar, 50% → fill rect is the bottom 29px.
var (x, y, w, h) = UiMeter.ComputeVFillRect(0.5f, 11f, 58f, fromBottom: true);
Assert.Equal(0f, x);
Assert.Equal(29f, y, 3); // h - h*p = 58 - 29
Assert.Equal(11f, w);
Assert.Equal(29f, h, 3);
}
[Fact]
public void Vertical_fill_from_top_starts_at_zero()
{
var (_, y, _, h) = UiMeter.ComputeVFillRect(0.25f, 11f, 58f, fromBottom: false);
Assert.Equal(0f, y);
Assert.Equal(14.5f, h, 3);
}
[Theory]
[InlineData(-1f, 0f)]
[InlineData(2f, 58f)]
public void Vertical_fill_clamps_fraction(float pct, float expectedH)
{
var (_, _, _, h) = UiMeter.ComputeVFillRect(pct, 11f, 58f, fromBottom: true);
Assert.Equal(expectedH, h, 3);
}
}