74 lines
2.2 KiB
Bash
Executable File
74 lines
2.2 KiB
Bash
Executable File
#!/bin/bash
|
||
|
||
set -euo pipefail
|
||
|
||
repo_dir="$(cd -- "$(dirname -- "${BASH_SOURCE[0]}")/../.." && pwd)"
|
||
model="$repo_dir/config/dot/quickshell/modules/osd/OsdModel.js"
|
||
|
||
node - "$model" <<'JS'
|
||
const assert = require('node:assert/strict')
|
||
const model = require(process.argv[2])
|
||
|
||
assert.equal(model.iconFor('volume', 0), 'audio-volume-muted-symbolic')
|
||
assert.equal(model.iconFor('volume', 0.2), 'audio-volume-low-symbolic')
|
||
assert.equal(model.iconFor('volume', 0.5), 'audio-volume-medium-symbolic')
|
||
assert.equal(model.iconFor('volume', 0.9), 'audio-volume-high-symbolic')
|
||
assert.equal(model.iconFor('microphone-muted', 0.7), 'microphone-sensitivity-muted-symbolic')
|
||
assert.equal(model.iconFor('brightness', 0.4), 'display-brightness-symbolic')
|
||
|
||
// The magnifier's OSD, posted by Accessibility.stepZoom when a zoom keybind is
|
||
// pressed. An unmapped kind falls through iconFor to the kind's own name, and
|
||
// "zoom" is not an icon -- the OSD would draw the generic fallback glyph for
|
||
// the one shortcut whose whole job is telling somebody who cannot read the
|
||
// screen what the magnification now is.
|
||
// An empty bar is 1.00 ×, which is off rather than "barely magnified", so it
|
||
// gets the reset icon: the zoom-in glyph beside an empty bar would read as a
|
||
// magnifier that had stopped working.
|
||
assert.equal(model.iconFor('zoom', 0.4), 'zoom-in-symbolic')
|
||
assert.equal(model.iconFor('zoom', 0), 'zoom-original-symbolic')
|
||
|
||
assert.deepEqual(
|
||
model.progressState('volume', 140, 100, '', 900),
|
||
{
|
||
kind: 'volume',
|
||
value: 100,
|
||
maximum: 100,
|
||
ratio: 1,
|
||
label: '100%',
|
||
icon: 'audio-volume-high-symbolic',
|
||
duration: 900,
|
||
progress: true
|
||
}
|
||
)
|
||
|
||
assert.deepEqual(
|
||
model.progressState('volume-muted', 43, 100, 'Muted', -50),
|
||
{
|
||
kind: 'volume-muted',
|
||
value: 43,
|
||
maximum: 100,
|
||
ratio: 0.43,
|
||
label: 'Muted',
|
||
icon: 'audio-volume-muted-symbolic',
|
||
duration: 0,
|
||
progress: true
|
||
}
|
||
)
|
||
|
||
assert.deepEqual(
|
||
model.messageState('media-next', 'Glass Beams', 'invalid'),
|
||
{
|
||
kind: 'media-next',
|
||
value: 0,
|
||
maximum: 100,
|
||
ratio: 0,
|
||
label: 'Glass Beams',
|
||
icon: 'media-skip-forward-symbolic',
|
||
duration: 1400,
|
||
progress: false
|
||
}
|
||
)
|
||
|
||
console.log('osd model contract: PASS')
|
||
JS
|