mirror of
https://github.com/bilawalsidhu/gods-eye-view.git
synced 2026-11-17 00:32:21 +00:00
Four test files built the same widget on CesiumWidget.prototype, viewer proxy, store and notice; renderLoopFixture.mjs now does it once. The notice test drives Cesium.Event instead of a hand-made double. frameEvents() drops tileset.tileLoad, which Cesium raises inside its own error handling, and the notice no longer guards a viewer without a canvas or requestRender.
47 lines
1.6 KiB
JavaScript
47 lines
1.6 KiB
JavaScript
// Errors thrown in the render loop outside Scene's tryAndCatchError. Drives
|
|
// Cesium's real startRenderLoop through the useDefaultRenderLoop setter.
|
|
import test from 'node:test';
|
|
import assert from 'node:assert/strict';
|
|
import * as Cesium from 'cesium';
|
|
import { renderLoopFixture } from './renderLoopFixture.mjs';
|
|
|
|
function runLoop(render) {
|
|
const scene = {
|
|
renderError: new Cesium.Event(),
|
|
preUpdate: new Cesium.Event(),
|
|
postRender: new Cesium.Event(),
|
|
requestRender() {},
|
|
initializeFrame() {},
|
|
render,
|
|
};
|
|
const fixture = renderLoopFixture(scene);
|
|
fixture.viewer.useDefaultRenderLoop = true;
|
|
fixture.runFrames(3);
|
|
return { ...fixture, uninstall: fixture.restore };
|
|
}
|
|
|
|
test('an error thrown outside tryAndCatchError still shows the notice', () => {
|
|
// Scene.render raises preRender outside tryAndCatchError (Scene.js:4439),
|
|
// so a listener's exception propagates.
|
|
const { widget, store, logged, uninstall } = runLoop(function () {
|
|
this.preUpdate.raiseEvent(this);
|
|
throw new TypeError("Cannot read properties of undefined (reading 'x')");
|
|
});
|
|
assert.equal(widget.useDefaultRenderLoop, false);
|
|
assert.equal(store.renderFailure?.reason, 'render-error');
|
|
assert.equal(logged.length, 1);
|
|
uninstall();
|
|
});
|
|
|
|
test('an error Scene raised and threw on with rethrowRenderErrors is reported once', () => {
|
|
const { store, logged, uninstall } = runLoop(function () {
|
|
this.preUpdate.raiseEvent(this);
|
|
const error = new Error('boom');
|
|
this.renderError.raiseEvent(this, error);
|
|
throw error;
|
|
});
|
|
assert.equal(store.renderFailure?.detail, 'boom');
|
|
assert.equal(logged.length, 1);
|
|
uninstall();
|
|
});
|