using AcDream.App.UI; namespace AcDream.App.Tests.UI; public sealed class UiScrollablePanelTests { [Fact] public void LayoutScrollableChildren_ClipsRowsOutsideViewport() { var panel = new UiScrollablePanel { Width = 100, Height = 40, LineHeight = 20 }; for (int i = 0; i < 4; i++) panel.AddChild(new UiPanel { Top = i * 20, Width = 100, Height = 20 }); panel.LayoutScrollableChildren(); Assert.True(panel.Children[0].Visible); Assert.True(panel.Children[1].Visible); Assert.False(panel.Children[2].Visible); panel.Scroll.SetScrollY(20); panel.LayoutScrollableChildren(); Assert.False(panel.Children[0].Visible); Assert.True(panel.Children[1].Visible); Assert.True(panel.Children[2].Visible); } [Fact] public void ScrollEvent_MovesByLineHeight() { var panel = new UiScrollablePanel { Width = 100, Height = 40, LineHeight = 20 }; for (int i = 0; i < 4; i++) panel.AddChild(new UiPanel { Top = i * 20, Width = 100, Height = 20 }); panel.LayoutScrollableChildren(); var e = new UiEvent(0u, panel, UiEventType.Scroll, Data0: -1); Assert.True(panel.OnEvent(in e)); Assert.Equal(20, panel.Scroll.ScrollY); } }