feat: group playback settings under a TOML section
This commit is contained in:
@@ -107,7 +107,7 @@ def check_cli_instances(root, app, fixtures):
|
||||
events=[{"key": "p", "code": 35}])
|
||||
|
||||
config.parent.mkdir(parents=True)
|
||||
config_text = ('automatic_quality = true\n[ui]\n"buffer_info" = true # optional display\n'
|
||||
config_text = ('[playback]\nautomatic_quality = true\n[ui]\n"buffer_info" = true # optional display\n'
|
||||
'compact_snap_to_edges = false\n[keys]\nplay = ["cmd+8", "cmd+x", "x"]\n'
|
||||
'pause = ["cmd+8", "cmd+x", "x"]\nshow_buffer_info = "b"\nhide_buffer_info = "b"\n')
|
||||
config.write_text(config_text)
|
||||
|
||||
@@ -129,7 +129,8 @@ struct ConfigurationChecks {
|
||||
|
||||
try files.createDirectory(at: config.deletingLastPathComponent(), withIntermediateDirectories: true)
|
||||
let original = Data("""
|
||||
# Root and nested keys can be quoted, with comments and whitespace.
|
||||
# Sections and nested keys can be quoted, with comments and whitespace.
|
||||
['playback']
|
||||
'automatic_quality' = true
|
||||
[ui]
|
||||
"buffer_info" = true # session display default
|
||||
@@ -151,7 +152,7 @@ struct ConfigurationChecks {
|
||||
try require(try PlayerConfiguration.load(from: config) == configured, "a fresh load resets session overrides to file values")
|
||||
|
||||
let partial = root.appendingPathComponent("partial.toml")
|
||||
try Data("automatic_quality = true\n".utf8).write(to: partial)
|
||||
try Data("[playback]\nautomatic_quality = true\n".utf8).write(to: partial)
|
||||
try require(try PlayerConfiguration.load(from: partial) == PlayerConfiguration(automaticQuality: true),
|
||||
"partial configuration retains defaults for omitted settings")
|
||||
let empty = root.appendingPathComponent("empty.toml")
|
||||
@@ -175,7 +176,7 @@ struct ConfigurationChecks {
|
||||
""".utf8).write(to: nested)
|
||||
let nestedConfiguration = try PlayerConfiguration.load(from: nested)
|
||||
try require(nestedConfiguration.showBufferInfo && nestedConfiguration.snapToEdges && !nestedConfiguration.automaticQuality,
|
||||
"partial nested UI keeps omitted root and UI defaults")
|
||||
"partial nested UI keeps omitted playback and UI defaults")
|
||||
let expectedKeys = try KeyBindings(overrides: ["play": ["x"], "pause": ["x", "ctrl+x"], "mute": [],
|
||||
"quality_1080p": ["alt+1"], "show_buffer_info": ["alt+b"],
|
||||
"hide_buffer_info": ["alt+b"]])
|
||||
@@ -185,21 +186,40 @@ struct ConfigurationChecks {
|
||||
try require(try PlayerConfiguration.load(from: nested).keys == expectedKeys && keySession.keys == defaults.keys,
|
||||
"key session overrides never persist")
|
||||
let emptySections = root.appendingPathComponent("empty-sections.toml")
|
||||
try Data("[ui]\n[keys]\n".utf8).write(to: emptySections)
|
||||
try Data("[ui]\n[keys]\n[playback]\n".utf8).write(to: emptySections)
|
||||
try require(try PlayerConfiguration.load(from: emptySections) == defaults, "empty nested sections use defaults")
|
||||
let reordered = root.appendingPathComponent("reordered.toml")
|
||||
try Data("""
|
||||
[keys]
|
||||
play = "x"
|
||||
pause = "x"
|
||||
[ui]
|
||||
buffer_info = true
|
||||
compact_snap_to_edges = false
|
||||
[playback]
|
||||
automatic_quality = true
|
||||
""".utf8).write(to: reordered)
|
||||
try require(try PlayerConfiguration.load(from: reordered) ==
|
||||
PlayerConfiguration(showBufferInfo: true, automaticQuality: true, snapToEdges: false,
|
||||
keys: KeyBindings(overrides: ["play": ["x"], "pause": ["x"]])),
|
||||
"playback after keys and UI retains every section's settings and bindings")
|
||||
|
||||
let invalid: [(String, String, [String])] = [
|
||||
("syntax", "automatic_quality = [\n", ["automatic_quality"]),
|
||||
("duplicate", "automatic_quality = true\n\"automatic_quality\" = false\n", ["automatic_quality"]),
|
||||
("syntax", "[playback]\nautomatic_quality = [\n", ["automatic_quality"]),
|
||||
("duplicate", "[playback]\nautomatic_quality = true\n\"automatic_quality\" = false\n", ["automatic_quality"]),
|
||||
("unknown", "unknown_setting = true\n", ["unknown_setting"]),
|
||||
("legacy-buffer", "show_buffer_info = true\n", ["show_buffer_info"]),
|
||||
("legacy-snap", "snap_to_edges = false\n", ["snap_to_edges"]),
|
||||
("legacy-quality", "automatic_quality = true\n", ["automatic_quality"]),
|
||||
("playback-scalar", "playback = true\n", ["playback"]),
|
||||
("playback-unknown", "[playback]\nunknown_setting = true\n", ["playback.unknown_setting"]),
|
||||
("playback-misplaced", "[ui]\nautomatic_quality = true\n", ["ui.automatic_quality"]),
|
||||
("ui-unknown", "[ui]\nunknown_setting = true\n", ["ui.unknown_setting"]),
|
||||
("ui-legacy", "[ui]\nshow_buffer_info = true\n", ["ui.show_buffer_info"]),
|
||||
("string", "[ui]\nbuffer_info = \"true\"\n", []),
|
||||
("integer", "automatic_quality = 1\n", []),
|
||||
("integer", "[playback]\nautomatic_quality = 1\n", []),
|
||||
("array", "[ui]\ncompact_snap_to_edges = [true]\n", []),
|
||||
("table", "[automatic_quality]\nenabled = true\n", ["automatic_quality"]),
|
||||
("table", "[playback.automatic_quality]\nenabled = true\n", ["automatic_quality"]),
|
||||
("ui-scalar", "ui = true\n", ["ui"]),
|
||||
("keys-scalar", "keys = true\n", ["keys"]),
|
||||
("key-bool", "[keys]\nplay = true\n", ["keys.play"]),
|
||||
|
||||
Reference in New Issue
Block a user