Skip to content

Commit

Permalink
chore(functional-test): reorganization
Browse files Browse the repository at this point in the history
  • Loading branch information
ftoromanoff committed Feb 21, 2024
1 parent 48388f8 commit 51aae20
Show file tree
Hide file tree
Showing 38 changed files with 114 additions and 25 deletions.
2 changes: 1 addition & 1 deletion examples/config.json
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@

"FileSource": {
"source_file_geojson_raster": "GeoJSON to raster",
"source_file_geojson_raster_2": "USGS GeoJSON flux to raster (planar view)",
"source_file_geojson_raster_usgs": "USGS GeoJSON flux to raster (planar view)",
"source_file_geojson_3d": "GeoJSON to 3D objects",
"source_file_kml_raster": "KML to raster",
"source_file_kml_raster_usgs": "USGS KML flux to raster",
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
"test": "npm run lint -- --max-warnings=0 && npm run build && npm run test-with-coverage && npm run test-functional",
"test-dev": "npm run lint -- --max-warnings=0 && npm run build-dev && npm run test-with-coverage && npm run test-functional",
"test-unit": "npm run base-test-unit test/unit",
"test-functional": "mocha -t 100000 --require test/hooks_functional.js --recursive test/functional",
"test-functional": "mocha -t 100000 --require test/functional/hooks_functional.js test/functional",
"test-with-coverage": "nyc -n src -r html cross-env npm run test-unit",
"test-with-coverage_lcov": "nyc -n src --reporter=lcov cross-env npm run test-unit",
"base-test-unit": "cross-env BABEL_DISABLE_CACHE=1 mocha --require @babel/register --file test/unit/bootstrap.js",
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
87 changes: 87 additions & 0 deletions test/functional/examples.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,87 @@
/* View */
require('./view/view_2d_map');
require('./view/view_25d_map');
require('./view/view_3d_map');
require('./view/view_multiglobe');
require('./view/view_multi_25d');
// require('./view/view_immersive');
// require('./view/view_3d_mns_map');

/* Geoid */
// require('./geoid/geoid_geoidLayer');

/* 3d Tiles */
require('./3dTiles/3dtiles_basic');
require('./3dTiles/3dtiles_25d');
require('./3dTiles/3dtiles_batch_table');
require('./3dTiles/3dtiles_ion');
require('./3dTiles/3dtiles_pointcloud');

/* Pointcloud */
require('./pointCloud/potree_25d_map');
require('./pointCloud/potree_3d_map');
// require('./pointCloud/laz_dragndrop');
// require('./pointCloud/entwine_simple_loader');
// require('./pointCloud/entwine_3d_loader');

/* Vector tiles */
require('./vectorTiles/vector_tile_raster_3d');
require('./vectorTiles/vector_tile_raster_2d');
// require('./vectorTiles/vector_tile_3d_mesh');
require('./vectorTiles/vector_tile_3d_mesh_mapbox');
// require('./vectorTiles/vector_tile_dragndrop');

/* WFS source */
require('./wfsSource/source_stream_wfs_25d');
require('./wfsSource/source_stream_wfs_3d');
require('./wfsSource/source_stream_wfs_raster');

/* Specific source options */
// require('./speSourceOptions/source_file_from_format');
// require('./speSourceOptions/source_file_from_methods');

/* FileSource */
require('./fileSource/source_file_geojson_raster');
// require('./fileSource/source_file_geojson_raster_usgs');
// require('./fileSource/source_file_geojson_3d');
require('./fileSource/source_file_kml_raster');
require('./fileSource/source_file_kml_raster_usgs');
// require('./fileSource/source_file_gpx_raster');
require('./fileSource/source_file_gpx_3d');

/* Customize FileSource */
// require('./customFileSource/source_file_from_fetched_data');
// require('./customFileSource/source_file_from_parsed_data');
// require('./customFileSource/source_file_shapefile');

/* Effects */
require('./effect/effects_postprocessing');
require('./effect/effects_split');
require('./effect/effects_stereo');
// require('./effect/mars');
// require('./effect/customColorLayerEffect');

/* Miscellaneous */
require('./misc/misc_colorlayer_visibility');
require('./misc/misc_collada');
require('./misc/misc_clamp_ground');
// require('./misc/misc_camera_animation');
// require('./misc/misc_compare_25d_3d');
require('./misc/misc_georeferenced_images');
// require('./misc/misc_orthographic_camera');
// require('./misc/misc_custom_controls');
// require('./misc/misc_custom_label');
// require('./misc/misc_camera_traveling');
require('./misc/misc_instancing');

/* Widgets */
// require('./widget/widgets_navigation');
// require('./widget/widgets_minimap');
// require('./widget/widgets_scale');
// require('./widget/widgets_searchbar');
require('./widget/widgets_3dtiles_style');

/* Plugins */
// require('./plugin/plugins_drag_n_drop');
// require('./plugin/plugins_pyramidal_tiff');
// require('./plugin/plugins_vrt');
File renamed without changes.
File renamed without changes.
46 changes: 23 additions & 23 deletions test/hooks_functional.js → test/functional/hooks_functional.js
Original file line number Diff line number Diff line change
Expand Up @@ -79,10 +79,10 @@ function waitServerReady(port) {
}

const layersInitialization = async (forceTimeOut = false) => {
await page.waitForFunction(forceTimeOut => (view.mainLoop.scheduler.commandsWaitingExecutionCount() === 0
await page.waitForFunction(timingOut => (view.mainLoop.scheduler.commandsWaitingExecutionCount() === 0
&& view.mainLoop.renderingState === 0
&& view.getLayers().every(layer => layer.ready)
&& !forceTimeOut), { timeout: 50000 }, forceTimeOut);
&& !timingOut), { timeout: 50000 }, forceTimeOut);
};

const waitNextRender = async page => page.evaluate(() => new Promise((resolve) => {
Expand All @@ -105,18 +105,32 @@ const waitNextRender = async page => page.evaluate(() => new Promise((resolve) =
view.notifyChange();
}));

async function saveInitialPosition() {
global.initialPosition = await page.evaluate(() => {
let promise;
if (view.isGlobeView && view.controls) {
promise = Promise.resolve(itowns.CameraUtils.getTransformCameraLookingAtTarget(view, view.controls.camera));
} else if (view.isPlanarView) {
// TODO: make the controls accessible from PlanarView before doing
// anything more here
promise = Promise.resolve();
}
return promise;
});
}

// Helper function: returns true if there are no errors on the page
// and when all layers are ready and rendering has been done
const loadExample = async (url, screenshotName) => {
url = `http://localhost:${itownsPort}/${url}`;
localUrl = `http://localhost:${itownsPort}/${url}`;

const pageErrors = [];
page.on('pageerror', (e) => { pageErrors.push(e); });

try {
await page.goto(url);
await page.goto(localUrl);
} catch (e) {
throw new Error(`page ${url} couldn't load`, { cause: e });
throw new Error(`page ${localUrl} couldn't load`, { cause: e });
}

if (pageErrors.length > 0) {
Expand All @@ -132,8 +146,8 @@ const loadExample = async (url, screenshotName) => {

try {
await layersInitialization();
} catch (e) {
if (e instanceof Error && e.name === 'TimeoutError') {
} catch (err) {
if (err instanceof Error && err.name === 'TimeoutError') {
console.warn(' *** Warning: layersInitialization timed out -> it got stopped ***');
await page.evaluate(() => {
itowns.CameraUtils.stop(view, view.camera3D);
Expand All @@ -160,18 +174,6 @@ const loadExample = async (url, screenshotName) => {
return true;
};

async function saveInitialPosition() {
global.initialPosition = await page.evaluate(() => {
if (view.isGlobeView && view.controls) {
return Promise.resolve(itowns.CameraUtils.getTransformCameraLookingAtTarget(view, view.controls.camera));
} else if (view.isPlanarView) {
// TODO: make the controls accessible from PlanarView before doing
// anything more here
return Promise.resolve();
}
});
}

// Use waitUntilItownsIsIdle to wait until itowns has finished all its work (= layer updates)
const waitUntilItownsIsIdle = async (screenshotName) => {
const result = await page.evaluate(() => new Promise((resolve) => {
Expand Down Expand Up @@ -251,7 +253,7 @@ exports.mochaHooks = {
// reset browser state instead of closing it
afterEach: async () => {
await page.evaluate((init) => {
if (view?.isGlobeView && view.controls) {
if (view && view.isGlobeView && view.controls) {
// eslint-disable-next-line no-param-reassign
init.coord = new itowns.Coordinates(
init.coord.crs,
Expand All @@ -261,7 +263,7 @@ exports.mochaHooks = {
);
view.controls.lookAtCoordinate(init, false);
view.notifyChange();
} else if (view?.isPlanarView) {
} else if (view && view.isPlanarView) {
// TODO: make the controls accessible from PlanarView before doing
// anything more here
}
Expand All @@ -273,5 +275,3 @@ exports.mochaHooks = {

global.loadExample = loadExample;
global.waitUntilItownsIsIdle = waitUntilItownsIsIdle;


File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
2 changes: 2 additions & 0 deletions test/functional/others.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
require('./others/CameraUtils');
require('./others/GlobeControls');
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.

0 comments on commit 51aae20

Please sign in to comment.