diff options
Diffstat (limited to 'src/LivingVillage.Desktop.Tests')
| -rw-r--r-- | src/LivingVillage.Desktop.Tests/PrototypeTests.fs | 23 |
1 files changed, 23 insertions, 0 deletions
diff --git a/src/LivingVillage.Desktop.Tests/PrototypeTests.fs b/src/LivingVillage.Desktop.Tests/PrototypeTests.fs index c85287f..77d2530 100644 --- a/src/LivingVillage.Desktop.Tests/PrototypeTests.fs +++ b/src/LivingVillage.Desktop.Tests/PrototypeTests.fs @@ -219,6 +219,29 @@ type PrototypeTests () = Assert.AreEqual<SimulationControl>(original, restoredControl) [<TestMethod>] + member _.ControlsPageKeyColumnIsUniformAndNeverOverprintsActions () = + let layout = TitleScreen.layout 1280 720 + let rows = MenuState.controlRows + + // Every row: key-name rectangle and action rectangle must be disjoint. + for rowIndex in 0 .. rows.Length - 1 do + let keyRect, actionRect = TitleScreen.controlRowRects layout rowIndex + Assert.IsTrue(TitleScreen.rectsDisjoint keyRect actionRect, sprintf "row %d key overlaps action" rowIndex) + + // The key column is uniform: every row shares the same x and width. + let keyRects = [ 0 .. rows.Length - 1 ] |> List.map (fun index -> TitleScreen.controlRowRects layout index |> fst) + Assert.AreEqual<int>(1, keyRects |> List.map (fun rect -> rect.X) |> List.distinct |> List.length) + Assert.AreEqual<int>(1, keyRects |> List.map (fun rect -> rect.Width) |> List.distinct |> List.length) + + // The key column fits the longest key name (latin glyph: 6px * scale 2 per char). + let longestKey = rows |> List.maxBy (fun row -> row.Keys.Length) + Assert.IsTrue(layout.ControlsKeyWidth >= longestKey.Keys.Length * 12, sprintf "key width %d too small for %s" layout.ControlsKeyWidth longestKey.Keys) + + // The controls panel holds every row plus the footer inside the viewport. + let panelBottom = layout.ControlsPanelY + 60 + rows.Length * layout.ControlsRowHeight + 48 + Assert.IsTrue(panelBottom <= 720, sprintf "controls panel bottom %d overflows" panelBottom) + + [<TestMethod>] member _.CornerStatusShowsDayMoneyAndEnergyFromRealData () = let world = Sim.initialWorldN 42UL 0 let lines = M5Interaction.cornerStatusLines world |
