summaryrefslogtreecommitdiff
path: root/src/LivingVillage.Desktop.Tests
diff options
context:
space:
mode:
Diffstat (limited to 'src/LivingVillage.Desktop.Tests')
-rw-r--r--src/LivingVillage.Desktop.Tests/LivingVillage.Desktop.Tests.fsproj1
-rw-r--r--src/LivingVillage.Desktop.Tests/M6bTests.fs5
-rw-r--r--src/LivingVillage.Desktop.Tests/P16UiTests.fs66
-rw-r--r--src/LivingVillage.Desktop.Tests/PrototypeTests.fs9
4 files changed, 75 insertions, 6 deletions
diff --git a/src/LivingVillage.Desktop.Tests/LivingVillage.Desktop.Tests.fsproj b/src/LivingVillage.Desktop.Tests/LivingVillage.Desktop.Tests.fsproj
index a8aac24..60d9995 100644
--- a/src/LivingVillage.Desktop.Tests/LivingVillage.Desktop.Tests.fsproj
+++ b/src/LivingVillage.Desktop.Tests/LivingVillage.Desktop.Tests.fsproj
@@ -9,6 +9,7 @@
<Compile Include="DesktopTests.fs" />
<Compile Include="M6aTests.fs" />
<Compile Include="M6bTests.fs" />
+ <Compile Include="P16UiTests.fs" />
<Compile Include="PrototypeTests.fs" />
<Compile Include="M3BatchOutputTests.fs" />
<Compile Include="SampleTests.fs" />
diff --git a/src/LivingVillage.Desktop.Tests/M6bTests.fs b/src/LivingVillage.Desktop.Tests/M6bTests.fs
index 5aea9bd..1b2ef70 100644
--- a/src/LivingVillage.Desktop.Tests/M6bTests.fs
+++ b/src/LivingVillage.Desktop.Tests/M6bTests.fs
@@ -13,8 +13,9 @@ type M6bMenuTests () =
Assert.AreEqual<MenuPage>(MainMenu, state.Page)
Assert.AreEqual<MenuItem list>(
- [ NewGameItem; LoadItem; SettingsItem; ControlsItem; ExitItem ],
+ [ NewGameItem; LoadItem; ExitItem ],
MenuState.items state)
+ Assert.AreEqual<string list>([ "开始"; "读档"; "退出" ], MenuState.items state |> List.map MenuState.itemLabel)
Assert.AreEqual<int>(0, state.Selected)
[<TestMethod>]
@@ -32,7 +33,7 @@ type M6bMenuTests () =
[<TestMethod>]
member _.SettingsCanSelectEveryExistingSimulationMode () =
let initial = MenuState.create SimulationControl.initial false
- let settings, _ = MenuState.update Confirm (MenuState.move Down (MenuState.move Down initial))
+ let settings = MenuState.openSettings initial
let oneX, oneXCommand = MenuState.update Confirm settings
let twoX, twoXCommand = MenuState.update Confirm (MenuState.move Down settings)
let fiveX, fiveXCommand = MenuState.update Confirm (MenuState.move Down (MenuState.move Down settings))
diff --git a/src/LivingVillage.Desktop.Tests/P16UiTests.fs b/src/LivingVillage.Desktop.Tests/P16UiTests.fs
new file mode 100644
index 0000000..0bfdb62
--- /dev/null
+++ b/src/LivingVillage.Desktop.Tests/P16UiTests.fs
@@ -0,0 +1,66 @@
+namespace LivingVillage.Desktop.Tests
+
+open Microsoft.VisualStudio.TestTools.UnitTesting
+open LivingVillage.Kernel
+open LivingVillage.Desktop
+
+// ---- P16 启动画面 / 开始界面 ----
+
+[<TestClass>]
+type P16LaunchTests () =
+
+ [<TestMethod>]
+ member _.LaunchRevealAndVeilAreDeterministicAndComplete () =
+ Assert.AreEqual<float32>(0.0f, LaunchScreen.revealProgress 0L)
+ Assert.AreEqual<float32>(1.0f, LaunchScreen.revealProgress LaunchScreen.fadeInFrames)
+ Assert.AreEqual<float32>(1.0f, LaunchScreen.revealProgress 1000L)
+ Assert.AreEqual<float32>(1.0f, LaunchScreen.veilAlpha 0L)
+ Assert.AreEqual<float32>(0.0f, LaunchScreen.veilAlpha LaunchScreen.durationFrames)
+ Assert.IsTrue(LaunchScreen.veilAlpha 30L > LaunchScreen.veilAlpha 90L, "veil must decrease monotonically")
+ Assert.IsFalse(LaunchScreen.isComplete (LaunchScreen.durationFrames - 1L))
+ Assert.IsTrue(LaunchScreen.isComplete LaunchScreen.durationFrames)
+
+ [<TestMethod>]
+ member _.LaunchSkipIsEscOrSpaceAndTextUsesTheAtlasPath () =
+ Assert.IsTrue(LaunchScreen.skipRequested true false)
+ Assert.IsTrue(LaunchScreen.skipRequested false true)
+ Assert.IsFalse(LaunchScreen.skipRequested false false)
+ Assert.IsTrue(PixelText.isRenderable LaunchScreen.title)
+ Assert.IsTrue(PixelText.isRenderable LaunchScreen.skipHint)
+ Assert.IsTrue(PixelText.isRenderable LaunchScreen.subtitle)
+ Assert.IsTrue(ChineseText.requiredUiLabels |> List.contains LaunchScreen.skipHint)
+
+[<TestClass>]
+type P16StartMenuTests () =
+
+ [<TestMethod>]
+ member _.StartMenuIsExactlyThreeItemsWithChineseLabels () =
+ let state = MenuState.create SimulationControl.initial false
+
+ Assert.AreEqual<int>(3, MenuState.items state |> List.length)
+ Assert.AreEqual<string list>([ "开始"; "读档"; "退出" ], MenuState.items state |> List.map MenuState.itemLabel)
+
+ [<TestMethod>]
+ member _.StartMenuNavigationSelectsEachItemAndWraps () =
+ let state = MenuState.create SimulationControl.initial false
+ let down1 = MenuState.move Down state
+ let down2 = MenuState.move Down down1
+ let wrap = MenuState.move Down down2
+
+ Assert.AreEqual<MenuItem>(NewGameItem, MenuState.selectedItem state)
+ Assert.AreEqual<MenuItem>(LoadItem, MenuState.selectedItem down1)
+ Assert.AreEqual<MenuItem>(ExitItem, MenuState.selectedItem down2)
+ Assert.AreEqual<MenuItem>(NewGameItem, MenuState.selectedItem wrap)
+
+ Assert.AreEqual<MenuCommand>(StartNewGame, MenuState.update Confirm state |> snd)
+ Assert.AreEqual<MenuCommand>(LoadGame, MenuState.update Confirm down1 |> snd)
+ Assert.AreEqual<MenuCommand>(ExitGame, MenuState.update Confirm down2 |> snd)
+
+ [<TestMethod>]
+ member _.ReturningToMenuOffersContinueAsTheFirstOfThreeItems () =
+ let playing = MenuState.create SimulationControl.initial true |> MenuState.enterGame
+ let main = MenuState.openMain playing
+
+ Assert.AreEqual<MenuItem list>([ ContinueItem; LoadItem; ExitItem ], MenuState.items main)
+ Assert.AreEqual<string list>([ "继续"; "读档"; "退出" ], MenuState.items main |> List.map MenuState.itemLabel)
+ Assert.AreEqual<MenuCommand>(ContinueGame, MenuState.update Confirm main |> snd)
diff --git a/src/LivingVillage.Desktop.Tests/PrototypeTests.fs b/src/LivingVillage.Desktop.Tests/PrototypeTests.fs
index 658e2e1..036154e 100644
--- a/src/LivingVillage.Desktop.Tests/PrototypeTests.fs
+++ b/src/LivingVillage.Desktop.Tests/PrototypeTests.fs
@@ -119,10 +119,11 @@ type PrototypeTests () =
let controlLabels = MenuState.controlRows |> List.map (fun row -> row.Action)
let settingsLabels = MenuState.settings |> List.map MenuState.settingsLabel
- Assert.IsTrue(itemLabels |> List.contains "开始新游戏")
- Assert.IsTrue(itemLabels |> List.contains "读取存档")
- Assert.IsTrue(itemLabels |> List.contains "设置")
+ Assert.IsTrue(itemLabels |> List.contains "开始")
+ Assert.IsTrue(itemLabels |> List.contains "读档")
Assert.IsTrue(itemLabels |> List.contains "退出")
+ Assert.AreEqual<string>("设置", MenuState.itemLabel SettingsItem)
+ Assert.AreEqual<string>("操作说明", MenuState.itemLabel ControlsItem)
Assert.AreEqual<string list>(
[ "移动"
"互动"
@@ -945,7 +946,7 @@ type PrototypeTests () =
[<TestMethod>]
member _.CjkGlyphAtlasHasAStableCharacterTableAndGeometry () =
- Assert.AreEqual<int>(228, characters.Length)
+ Assert.AreEqual<int>(238, characters.Length)
CollectionAssert.AreEqual(characters, characters |> Array.sort)
Assert.AreEqual<int>(characters.Length, characters |> Array.distinct |> Array.length)
Assert.AreEqual<int>(16, columns)