feature: pure volume model, graph state reducer and view model
Cubic percent <-> linear channelVolumes conversions (pavucontrol scale, up to 150%), dB formatting, balance-preserving linked slider, a reducer applying WirePlumber node/link/default events and per-tab view rows, all covered by moon tests that run on any target. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
1 parent
13a1de9b2c
commit
7b2b45067f
10 files changed
+1027
No files matched your search
@@ -0,0 +1,77 @@
|
||||
///|
|
||||
test "playback rows" {
|
||||
let s = sample_state()
|
||||
let rows = @model.rows(s, Playback)
|
||||
assert_eq(rows.length(), 1)
|
||||
let r = rows[0]
|
||||
assert_eq(r.title, "Firefox")
|
||||
assert_eq(r.subtitle, "Big Buck Bunny")
|
||||
assert_eq(r.volume_text, "100% (0.00 dB)")
|
||||
assert_eq(r.choices.map(fn(c) { c.id }), [40, 41])
|
||||
assert_eq(r.current_choice, 1)
|
||||
assert_eq(r.choices[1].name, "bluez_output.headphones")
|
||||
}
|
||||
|
||||
///|
|
||||
test "recording rows route to sources" {
|
||||
let s = sample_state()
|
||||
let r = @model.rows(s, Recording)[0]
|
||||
assert_eq(r.title, "OBS")
|
||||
assert_eq(r.choices.map(fn(c) { c.id }), [50])
|
||||
assert_eq(r.current_choice, 0)
|
||||
}
|
||||
|
||||
///|
|
||||
test "device rows" {
|
||||
let s = sample_state()
|
||||
let outs = @model.rows(s, OutputDevices)
|
||||
assert_eq(outs.map(fn(r) { r.is_default }), [true, false])
|
||||
assert_eq(outs[1].volume_text, "50% (-18.06 dB)")
|
||||
assert_eq(outs[0].subtitle, "alsa_output.pci.analog-stereo")
|
||||
assert_eq(outs[0].choices, [])
|
||||
let ins = @model.rows(s, InputDevices)
|
||||
assert_eq(ins.length(), 1)
|
||||
assert_true(ins[0].mute)
|
||||
assert_true(ins[0].is_default)
|
||||
assert_eq(ins[0].icon_name, "audio-input-microphone-symbolic")
|
||||
}
|
||||
|
||||
///|
|
||||
test "stream without app name falls back" {
|
||||
let s = @model.State::new()
|
||||
let _ = s.apply(Upsert(@model.Node::new(7, "Stream/Output/Audio")))
|
||||
let r = @model.rows(s, Playback)[0]
|
||||
assert_eq(r.title, "Stream 7")
|
||||
assert_eq(r.current_choice, -1)
|
||||
assert_false(r.has_volume)
|
||||
assert_eq(r.volume_text, "")
|
||||
}
|
||||
|
||||
///|
|
||||
test "diff rows" {
|
||||
let s = sample_state()
|
||||
let before = @model.rows(s, OutputDevices)
|
||||
let _ = s.apply(Remove(41))
|
||||
let _ = s.apply(
|
||||
Upsert(@model.Node::new(42, "Audio/Sink", description="HDMI")),
|
||||
)
|
||||
let _ = s.apply(Upsert({ ..s.nodes.get(40).unwrap(), mute: true, }))
|
||||
let after = @model.rows(s, OutputDevices)
|
||||
assert_eq(@model.diff_rows(before, after), {
|
||||
removed: [41],
|
||||
added: [42],
|
||||
updated: [40],
|
||||
})
|
||||
assert_eq(@model.diff_rows(after, after), {
|
||||
removed: [],
|
||||
added: [],
|
||||
updated: [],
|
||||
})
|
||||
}
|
||||
|
||||
///|
|
||||
test "tab labels" {
|
||||
assert_eq(@model.Tab::all().map(fn(t) { t.label() }), [
|
||||
"Playback", "Recording", "Output Devices", "Input Devices",
|
||||
])
|
||||
}
|
||||
Reference in new issue
Block a user