mirror of
https://github.com/bilawalsidhu/gods-eye-view.git
synced 2026-11-22 03:02:20 +00:00
Every layer draws on both engines, so the per-engine availability machinery always answered yes. The renderer manifest is now the id to display map plus the wind flow backend; the catalog filter, the voice and QA-probe refusals and the engine-kind checks go with it. The Navara notice lists the same layers in the same words. Paths that read the Cesium viewer behind an engine that is always there are gone: the Recent Imagery viewer fallbacks, the shell's imagery-host service (one shared host module remains), the engineless map controller, viewer gates in voice actions, world packets and camera verbs, the orientation controls' tracked-entity fallback, and the Bhote Koshi and FIRMS Cesium-shaped paths. setCameraInputs, which nothing called, leaves the contract; suspensions remain. Smaller duplicates go too: one tracker-release helper for navigation and location, the no-op frame latch, missing-engine guards, one name for the injected display, flat bikeshare and installations displays, one overlay host and binder, one name per world-overlay method, and stub-viewer guards in the Cesium engine. Layers that still read the viewer keep the shared init(viewer, context) entry. Behaviour is unchanged on both engines. Viewer lines fall from 849 to 750 and engine-name literals from 32 to 27.
99 lines
3.4 KiB
JavaScript
99 lines
3.4 KiB
JavaScript
import test, { after, before } from 'node:test';
|
|
import assert from 'node:assert/strict';
|
|
import { readFileSync } from 'node:fs';
|
|
import * as Cesium from 'cesium';
|
|
import '../testSupport/stubMgrs.mjs';
|
|
import { installVueDom } from '../testSupport/vueDom.mjs';
|
|
import { MAXIMUM_ZOOM_DISTANCE_M } from '../globe/cesium/zoomOutGuard.js';
|
|
|
|
const { createApplicationControls } = await import('./controls.js');
|
|
|
|
// controls.js and the shell import browser-only UI modules, so these read the
|
|
// source: the scene engine is threaded to the shell, which hands it (not the
|
|
// viewer) to the world overlay. The overlay itself is tested on the fake
|
|
// engine without a viewer (src/overlays/worldOverlay.test.mjs).
|
|
const read = (relative) =>
|
|
readFileSync(new URL(relative, import.meta.url), 'utf8');
|
|
|
|
test('the controls pass the scene engine to the shell', () => {
|
|
const controls = read('./controls.js');
|
|
assert.match(
|
|
controls,
|
|
/const \{ viewer, engine, mapStackController, operations \} = scene;/,
|
|
);
|
|
assert.match(controls, /new Controls\(viewer, \{[\s\S]*?\n\s+engine,\n/);
|
|
// A later globe reaches the shell with its own engine.
|
|
assert.match(
|
|
read('./shellPart.js'),
|
|
/styleManager\.attachScene\(\s*\{\s+viewer: next\.viewer,\s+engine: next\.engine,/,
|
|
);
|
|
});
|
|
|
|
test('the shell initializes the world overlay on its engine', () => {
|
|
const shell = read('../ui/applicationShell.js') + read('../ui/shellScene.js');
|
|
assert.match(shell, /\{\n\s+engine = null,\n\s+mapStackController = null,/);
|
|
assert.match(shell, /worldOverlayFor\(engine\)\.init\(\);/);
|
|
assert.doesNotMatch(shell, /worldOverlayFor\(viewer\)/);
|
|
});
|
|
|
|
let uninstallDom;
|
|
before(() => {
|
|
uninstallDom = installVueDom();
|
|
});
|
|
after(() => uninstallDom());
|
|
|
|
test('application controls install the zoom-out guard and remove it on teardown', async () => {
|
|
const canvas = document.createElement('canvas');
|
|
const controller = { maximumZoomDistance: Infinity };
|
|
const scene = {
|
|
mode: Cesium.SceneMode.SCENE3D,
|
|
screenSpaceCameraController: controller,
|
|
preRender: new Cesium.Event(),
|
|
postUpdate: new Cesium.Event(),
|
|
};
|
|
const camera = {
|
|
position: Cesium.Cartesian3.fromDegrees(0, 0, 1_000_000),
|
|
positionCartographic: { height: 1_000_000 },
|
|
};
|
|
const viewer = { scene, camera, canvas };
|
|
const handoffs = new Set();
|
|
class Controls {
|
|
hasShareState = true;
|
|
orbitController = { stop() {} };
|
|
hud = { destroy() {} };
|
|
dispose() {}
|
|
detachScene() {}
|
|
subscribeCameraHandoff(listener) {
|
|
handoffs.add(listener);
|
|
return () => handoffs.delete(listener);
|
|
}
|
|
}
|
|
const cleanups = [];
|
|
await createApplicationControls({
|
|
scene: {
|
|
viewer,
|
|
mapStackController: {},
|
|
operations: {
|
|
surface: { controlServices: {} },
|
|
searchAndFlyTo() {},
|
|
requests: { regional: {}, weather: {} },
|
|
},
|
|
},
|
|
loaderStatus: {},
|
|
Controls,
|
|
catalog: { get: (id) => ({ id }) },
|
|
defer: (cleanup) => cleanups.push(cleanup),
|
|
});
|
|
|
|
assert.equal(controller.maximumZoomDistance, MAXIMUM_ZOOM_DISTANCE_M);
|
|
assert.equal(scene.preRender.numberOfListeners, 1);
|
|
assert.equal(scene.postUpdate.numberOfListeners, 1);
|
|
assert.equal(handoffs.size, 1);
|
|
|
|
for (const cleanup of cleanups.reverse()) await cleanup();
|
|
assert.equal(controller.maximumZoomDistance, Infinity);
|
|
assert.equal(scene.preRender.numberOfListeners, 0);
|
|
assert.equal(scene.postUpdate.numberOfListeners, 0);
|
|
assert.equal(handoffs.size, 0);
|
|
});
|