diff options
Diffstat (limited to 'src/LivingVillage.Desktop.Tests')
| -rw-r--r-- | src/LivingVillage.Desktop.Tests/LivingVillage.Desktop.Tests.fsproj | 1 | ||||
| -rw-r--r-- | src/LivingVillage.Desktop.Tests/P75HudStripTests.fs | 59 |
2 files changed, 60 insertions, 0 deletions
diff --git a/src/LivingVillage.Desktop.Tests/LivingVillage.Desktop.Tests.fsproj b/src/LivingVillage.Desktop.Tests/LivingVillage.Desktop.Tests.fsproj index fb7ecb7..dc2cb23 100644 --- a/src/LivingVillage.Desktop.Tests/LivingVillage.Desktop.Tests.fsproj +++ b/src/LivingVillage.Desktop.Tests/LivingVillage.Desktop.Tests.fsproj @@ -46,6 +46,7 @@ <Compile Include="P72CharacterWalkTests.fs" /> <Compile Include="P73LightingTierTests.fs" /> <Compile Include="P74LaunchTransitionTests.fs" /> + <Compile Include="P75HudStripTests.fs" /> <Compile Include="SampleTests.fs" /> </ItemGroup> diff --git a/src/LivingVillage.Desktop.Tests/P75HudStripTests.fs b/src/LivingVillage.Desktop.Tests/P75HudStripTests.fs new file mode 100644 index 0000000..e80d91f --- /dev/null +++ b/src/LivingVillage.Desktop.Tests/P75HudStripTests.fs @@ -0,0 +1,59 @@ +namespace LivingVillage.Desktop.Tests + +open Microsoft.VisualStudio.TestTools.UnitTesting +open LivingVillage.Desktop +open LivingVillage.Kernel +open LivingVillage.Kernel.Sim + +/// P75 回归:HUD 顶部条改为紧凑半透明药丸(去整宽深色带),信息不遮挡、文字可读。 +[<TestClass>] +type P75HudStripTests () = + + let world = Sim.initialWorldN 42UL 4 + let control = SimulationControl.initial + let placed = HudLayout.layout (HudLayout.segments world control) + + [<TestMethod>] + member _.TopBandIsRemovedForDayAndNight () = + for mode in [ Day; Night ] do + let palette = HudLayout.palette mode + Assert.AreEqual<byte>(0uy, palette.BarTop.A) + Assert.AreEqual<byte>(0uy, palette.BarBottom.A) + Assert.AreEqual<byte>(0uy, HudLayout.bandAlpha) + + [<TestMethod>] + member _.PillsAreCompactInsideTheStrip () = + Assert.IsTrue(HudLayout.pillHeight < HudLayout.barHeight, "药丸须比窄条矮,留出上下留白") + for (x, width, _) in placed do + let pill = HudLayout.segmentBackdrop x width + Assert.IsTrue(pill.Y >= 0 && pill.Y + pill.Height <= HudLayout.barHeight, "药丸须在窄条内") + let hair = HudLayout.pillHairline x width + Assert.IsTrue(hair.Height = 1, "发丝线为 1px") + Assert.IsTrue(hair.X >= pill.X && hair.X + hair.Width <= pill.X + pill.Width, "发丝线须在药丸内") + Assert.AreEqual<int>(max 1 (pill.Width - 2), hair.Width) + + [<TestMethod>] + member _.StripLeavesWhitespaceAndDoesNotOverlapDateCard () = + Assert.IsTrue(placed.Length > 0) + let firstX = placed |> List.head |> fun (x, _, _) -> x + Assert.AreEqual<int>(HudLayout.paddingX, firstX) + let lastEnd = placed |> List.last |> fun (x, width, _) -> x + width + // 药丸总跨度远小于通栏宽度,右侧留白充足(不再铺满整宽)。 + Assert.IsTrue(lastEnd < 1280 / 2, sprintf "HUD 只占左半,右侧留白;lastEnd=%d" lastEnd) + let reading = HudLayout.calendarReading world.Tick + let cal = HudLayout.calendarCardRect 1280 reading + Assert.IsTrue(cal.Y >= HudLayout.barHeight + HudLayout.accentHeight, "日历卡不压顶部条") + + [<TestMethod>] + member _.TextStaysReadableOnTranslucentPills () = + for mode in [ Day; Night ] do + let palette = HudLayout.palette mode + Assert.IsTrue(palette.SegmentBackdrop.A > 0uy && palette.SegmentBackdrop.A < 255uy, "药丸半透明") + let valueLuma = int palette.Value.R + int palette.Value.G + int palette.Value.B + let outlineLuma = int palette.Outline.R + int palette.Outline.G + int palette.Outline.B + Assert.IsTrue(valueLuma > 600, "数值色须够亮") + Assert.IsTrue(valueLuma > outlineLuma + 400, "亮字 vs 深描边对比须足够") + // 图标与数值并排:文本起始在图标右侧。 + for (x, _, segment) in placed do + Assert.AreEqual<int>(x + HudLayout.iconWidth + HudLayout.iconGap, HudLayout.textOrigin x) + Assert.IsFalse(System.String.IsNullOrEmpty segment.Value) |
