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
+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)"