Fix CCTV provider cancellation and credential-safe errors

This commit is contained in:
Said committed 2026-10-19 23:05:37 +01:00
1 parent 1bccc295f0
commit 5b4f5ed4a0
8 files changed
+293 -63

No files matched your search

+31
View File
@@ -139,3 +139,34 @@ test('same pixels at a new aspect redraw at the new fit', () => {
]);
assert.equal(runtime.canvasStamp, 2);
});
test('same pixels at a new resolution with the same fit skip the redraw', () => {
const { runtime, load } = stillHarness();
load(640, 480);
assert.deepEqual(load(1280, 960), []);
assert.equal(runtime.canvasStamp, 1);
assert.equal(runtime.drawnImageStamp, 2);
});
test('changed pixels redraw even when the fitted rectangle is unchanged', () => {
const { runtime, load } = stillHarness();
load(640, 480);
const changedPixels = new Uint8ClampedArray(
FRAME_SIGNATURE_W * FRAME_SIGNATURE_H * 4,
).fill(90);
runtime.signatureCtx.getImageData = () => ({ data: changedPixels });
const calls = load(640, 480);
assert.equal(calls[0][0], 'fillRect');
assert.deepEqual(calls[1], ['drawImage', 240, 0, 1440, 1080]);
assert.equal(runtime.canvasStamp, 2);
});
test('a failed pixel signature redraws rather than assuming equal content', () => {
const { runtime, load } = stillHarness();
load(640, 480);
runtime.signatureCtx.getImageData = () => {
throw new Error('tainted canvas');
};
assert.deepEqual(load(640, 480).at(-1), ['drawImage', 240, 0, 1440, 1080]);
assert.equal(runtime.canvasStamp, 2);
});
+53
View File
@@ -71,3 +71,56 @@ test('focus de-emphasis fades each icon from its own color', () => {
);
assert.equal(state._activeFocusStyleCount, 3);
});
test('focus release restores video hue and alpha after the style throttle', () => {
let target = {};
const records = ['mp4', 'webm'].map((feedType) => ({
camera: { id: feedType, feedType },
billboard: { show: true, color: LIVE_CAMERA_COLOR },
}));
const state = {
_enabled: true,
_viewer: { scene: {}, camera: {} },
_records: records,
_activeCameraId: null,
_activeFocusStyleCount: 0,
_lastFocusStyleAt: -Infinity,
};
const focus = {
focusNowMs: (nowMs) => nowMs,
getFocusTarget: () => target,
focusPassIsNeeded: (value, count) => !!value || count > 0,
advanceSpriteFocus: () => ({
factor: target ? FOCUS_FACTOR : 1,
active: !!target,
transitioning: false,
}),
focusAlphaNeedsWrite: (before, after) => before !== after,
};
const { refreshCctvFocusStyles } = createRendering({
state,
services: { focus },
parts: { model: { isVideoFeedType } },
source: {},
});
refreshCctvFocusStyles(1000);
for (const record of records) {
assertFadedFrom(
record.billboard.color,
LIVE_CAMERA_COLOR,
record.camera.id,
);
}
const dimmed = records.map((record) => record.billboard.color);
target = null;
refreshCctvFocusStyles(1050);
for (let i = 0; i < records.length; i += 1) {
assert.equal(records[i].billboard.color, dimmed[i]);
}
refreshCctvFocusStyles(1100);
for (const record of records) {
assert.deepEqual(record.billboard.color, LIVE_CAMERA_COLOR);
}
assert.equal(state._activeFocusStyleCount, 0);
});