1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
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)
|