feat: configure duration-aware progress in compact titles

This commit is contained in:
2026-10-12 15:45:22 +02:00
parent 1f5e9541e7
commit 35fa89e492
5 changed files with 96 additions and 8 deletions
+8
View File
@@ -116,6 +116,12 @@ struct ConfigurationChecks {
"printed TOML is directly usable and preserves all default behavior and bindings")
try require(!defaults.showBufferInfo && !defaults.automaticQuality && defaults.snapToEdges,
"built-in defaults hide buffer info, disable automatic quality, and enable snapping")
for (value, expected) in [("time", CompactTitleProgress.time), ("percentage", .percentage), ("none", .none)] {
let progress = root.appendingPathComponent("compact-progress-\(value).toml")
try Data("[ui]\ncompact_title_progress = \"\(value)\"\n".utf8).write(to: progress)
try require(try PlayerConfiguration.load(from: progress).compactTitleProgress == expected,
"compact title format \(value) loads from a partial UI section")
}
try require(PlayerConfiguration.fileURL(environment: ["XDG_CONFIG_HOME": xdg.path], homeDirectory: home) == config,
"absolute XDG_CONFIG_HOME selects terebi/config.toml")
for environment in [[:], ["XDG_CONFIG_HOME": ""], ["XDG_CONFIG_HOME": "relative/config"]] {
@@ -219,6 +225,8 @@ struct ConfigurationChecks {
("string", "[ui]\nbuffer_info = \"true\"\n", []),
("integer", "[playback]\nautomatic_quality = 1\n", []),
("array", "[ui]\ncompact_snap_to_edges = [true]\n", []),
("progress-value", "[ui]\ncompact_title_progress = \"unknown\"\n", ["compact_title_progress", "unknown"]),
("progress-bool", "[ui]\ncompact_title_progress = false\n", ["compact_title_progress"]),
("table", "[playback.automatic_quality]\nenabled = true\n", ["automatic_quality"]),
("ui-scalar", "ui = true\n", ["ui"]),
("keys-scalar", "keys = true\n", ["keys"]),
+33
View File
@@ -17,7 +17,40 @@ struct SystemPlaybackChecks {
require(condition(), message)
}
static func checkCompactProgress() {
let times: [(Double, Double, String)] = [
(12.9, 45.9, "12 / 45 s"),
(59, 59.999, "59 / 59 s"),
(0, 60, "00:00 / 01:00 min"),
(312, 2528, "05:12 / 42:08 min"),
(3599, 3599.999, "59:59 / 59:59 min"),
(59, 3600, "00:00 / 01:00 h"),
(4980, 7800, "01:23 / 02:10 h"),
(-5, 45, "0 / 45 s"),
(80, 45, "45 / 45 s"),
]
for (position, duration, expected) in times {
require(compactProgressText(position: position, duration: duration, format: .time) == expected,
"compact time uses total-duration units, truncation and bounded progress: \(expected)")
}
for (position, expected) in [(59.9, "59"), (100.0, "100"), (105.0, "100"), (-1.0, "0")] {
require(compactProgressText(position: position, duration: 100, format: .percentage) == expected,
"compact percentage is a bounded integer: \(expected)")
}
for duration in [0.0, -1.0, .nan, .infinity] {
require(compactProgressText(position: 10, duration: duration, format: .time) == nil &&
compactProgressText(position: 10, duration: duration, format: .percentage) == nil,
"unknown/invalid duration has no compact progress")
}
require(compactProgressText(position: .nan, duration: 100, format: .time) == nil &&
compactProgressText(position: .infinity, duration: 100, format: .percentage) == nil,
"nonfinite positions never appear as compact progress")
require(compactProgressText(position: 59, duration: 100, format: .none) == nil,
"disabled compact progress leaves only the title")
}
static func main() {
checkCompactProgress()
_ = NSApplication.shared
NSApp.setActivationPolicy(.prohibited)
let suite = "terebi.system-playback-check.\(UUID().uuidString)"