mirror of
https://github.com/ksyasuda/SubMiner.git
synced 2026-05-02 16:19:25 -07:00
- return a cancel handle from the Linux refresh burst scheduler - clear pending refresh bursts when overlays hide or windows close - tighten the burst test polling to wait for the async refresh
51 lines
1.7 KiB
TypeScript
51 lines
1.7 KiB
TypeScript
import assert from 'node:assert/strict';
|
|
import test from 'node:test';
|
|
import {
|
|
clearLinuxMpvFullscreenOverlayRefreshTimeouts,
|
|
scheduleLinuxVisibleOverlayFullscreenRefreshBurst,
|
|
} from './linux-mpv-fullscreen-overlay-refresh';
|
|
|
|
test('linux mpv fullscreen overlay refresh burst schedules overlay refresh work on linux', async () => {
|
|
const originalPlatformDescriptor = Object.getOwnPropertyDescriptor(process, 'platform');
|
|
Object.defineProperty(process, 'platform', {
|
|
configurable: true,
|
|
value: 'linux',
|
|
});
|
|
|
|
const calls: string[] = [];
|
|
|
|
try {
|
|
scheduleLinuxVisibleOverlayFullscreenRefreshBurst({
|
|
overlayManager: {
|
|
getMainWindow: () =>
|
|
({
|
|
hide: () => calls.push('hide'),
|
|
isDestroyed: () => false,
|
|
isVisible: () => true,
|
|
showInactive: () => calls.push('showInactive'),
|
|
}) as never,
|
|
getVisibleOverlayVisible: () => true,
|
|
},
|
|
overlayVisibilityRuntime: {
|
|
updateVisibleOverlayVisibility: () => calls.push('updateVisibleOverlayVisibility'),
|
|
},
|
|
ensureOverlayWindowLevel: () => calls.push('ensureOverlayWindowLevel'),
|
|
});
|
|
|
|
const deadline = Date.now() + 200;
|
|
while (!calls.includes('updateVisibleOverlayVisibility') && Date.now() < deadline) {
|
|
await new Promise((resolve) => setTimeout(resolve, 5));
|
|
}
|
|
|
|
assert.ok(calls.includes('updateVisibleOverlayVisibility'));
|
|
assert.ok(calls.includes('hide'));
|
|
assert.ok(calls.includes('showInactive'));
|
|
assert.ok(calls.includes('ensureOverlayWindowLevel'));
|
|
} finally {
|
|
clearLinuxMpvFullscreenOverlayRefreshTimeouts();
|
|
if (originalPlatformDescriptor) {
|
|
Object.defineProperty(process, 'platform', originalPlatformDescriptor);
|
|
}
|
|
}
|
|
});
|