Skip to content

Commit

Permalink
Add examples image check
Browse files Browse the repository at this point in the history
  • Loading branch information
sbrunner committed Jul 5, 2019
1 parent 72f623d commit d68766b
Show file tree
Hide file tree
Showing 91 changed files with 62 additions and 44 deletions.
25 changes: 12 additions & 13 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -201,7 +201,6 @@ examples-hosted-apps: .build/gmf-apps.timestamp

.build/gmf-apps.timestamp: $(GMF_APPS_ALL_SRC_FILES) $(WEBPACK_CONFIG_FILES) \
.build/node_modules.timestamp \
.build/build-dll.timestamp \
.build/examples-hosted/dist \
.build/examples-hosted-gmf-apps-deps.timestamp
npm run build-gmf-apps
Expand All @@ -224,7 +223,9 @@ gh-pages: .build/python-venv.timestamp
touch $@

.build/examples-hosted/dist: .build/build-dll.timestamp
mkdir -p .build/examples-hosted/
cp -r dist .build/examples-hosted/
touch $@

.build/examples-hosted-gmf-apps-deps.timestamp: \
$(addprefix contribs/gmf/build/gmf-, $(addsuffix .json, $(LANGUAGES))) \
Expand Down Expand Up @@ -261,41 +262,38 @@ gh-pages: .build/python-venv.timestamp
'An example application for editing an object.' \
$< $(GMF_EXAMPLES_HTML_FILES) > $@

.build/test-check-example/%.check.timestamp: test/check-example/%.html \
.build/node_modules.timestamp \
buildtools/check-example.js \
.build/httpserver.timestamp
mkdir -p $(dir $@)
node buildtools/check-example.js $<
touch $@

.build/httpserver.timestamp:
python3 -m http.server 3000 &
touch $@

.build/%.check.timestamp: .build/examples-ngeo.timestamp \
.build/node_modules.timestamp \
buildtools/check-example.js \
.build/httpserver.timestamp
mkdir -p $(dir $@)
node buildtools/check-example.js .build/examples-hosted/$*.html
#[ `compare -metric RMSE $<.png example/$*-ref.png /$<-diff.png 2>&1 | sed 's/^.*(\(.*\))/\1/g'` \< 0.05 ]
[ "$$(gm compare -metric RMSE -highlight-style xor .build/examples-hosted/$*.html.png \
examples/$*-ref.png -file .build/examples-hosted/$*.html.png-diff.png 2>&1 | \
tail --lines=1 | sed 's/.* \([0-9\.]\+\) .*/\1/g')" \< 0.005 ]
touch $@

.build/contribs/gmf/%.check.timestamp: .build/examples-gmf.timestamp \
.build/examples-hosted/contribs/gmf/%.js \
.build/node_modules.timestamp \
buildtools/check-example.js \
.build/httpserver.timestamp
mkdir -p $(dir $@)
node buildtools/check-example.js .build/examples-hosted/contribs/gmf/$*.html
[ "$$(gm compare -metric RMSE -highlight-style xor .build/examples-hosted/contribs/gmf/$*.html.png \
contribs/gmf/examples/$*-ref.png -file .build/examples-hosted/contribs/gmf/$*-diff.png 2>&1 | \
tail --lines=1 | sed 's/.* \([0-9\.]\+\) .*/\1/g')" \< 0.005 ]
touch $@

.build/contribs/gmf/apps/%.check.timestamp: .build/gmf-apps.timestamp \
buildtools/check-example.js \
.build/httpserver.timestamp
mkdir -p $(dir $@)
node buildtools/check-example.js .build/examples-hosted/contribs/gmf/apps/$*.html
[ "$$(gm compare -metric RMSE -highlight-style xor .build/examples-hosted/contribs/gmf/apps/$*.html.png \
contribs/gmf/apps/$*-ref.png -file .build/examples-hosted/contribs/gmf/apps/$*-diff.png 2>&1 | \
tail --lines=1 | sed 's/.* \([0-9\.]\+\) .*/\1/g')" \< 0.005 ]
touch $@

.build/node_modules.timestamp: package.json
Expand Down Expand Up @@ -437,6 +435,7 @@ clean:

.PHONY: cleanall
cleanall: clean
rm -rf dist
rm -rf .build
rm -rf node_modules
rm -f .tx/config
Expand Down
73 changes: 46 additions & 27 deletions buildtools/check-example.js
Original file line number Diff line number Diff line change
@@ -1,14 +1,17 @@
'use strict';

const path = require('path');
const fs = require('fs');
const puppeteer = require('puppeteer');

const arg = process.argv[2];
const screenshotPath = `${arg}.png`;
const url = `http://localhost:3000/${arg}`;
if (!arg) {
throw new Error('Please provide a HTML file as the first argument');
}
const screenshotPath = `${arg}.png`;
const url = `http://localhost:3000/${arg}`;

const OSMImage = fs.readFileSync(path.resolve(__dirname, 'osm.png'));

const requestsURL = new Set();
const start = new Date();
Expand All @@ -19,71 +22,87 @@ function loaded(page, browser) {
}
timeout = setTimeout(() => {
if (requestsURL.size) {
console.log('Pending requests:');
requestsURL.forEach((request) => console.log(request));
process.exit(2);
// @ts-ignore
if ((new Date() - start) > 60000) {
// The page take more than 60s. to load ...
console.log('Pending requests:');
requestsURL.forEach((request) => console.log(request));
process.exit(2);
} else {
timeout = undefined;
loaded(page, browser);
}
} else {
// @ts-ignore
console.log(`Check finished in ${new Date() - start} seconds`);
console.log(`Check finished in ${(new Date() - start) / 1000} seconds`);
page.screenshot({
path: screenshotPath
}).then(() => {
console.log(`Screenshot saved at: ${screenshotPath}`);
browser.close();
}, (e) => {
}, e => {
console.log(`Screenshot error: ${e}`);
process.exit(2);
});
}
}, 2000);
}, 500);
}
(async () => {
const browser = await puppeteer.launch();
const page = await browser.newPage();
await page.setViewport({width: 1920, height: 1080});
page.on('load', () => console.log(`Page loaded: ${page.url()}`));
page.on('pageerror', (e) => {
await page.setRequestInterception(true);
page.on('pageerror', e => {
console.log('Page error');
console.log(e);
process.exit(2);
});
page.on('dialog', (e) => {
page.on('dialog', e => {
console.log('Unexpected alert message');
console.log(e);
process.exit(2);
});
page.on('request', (request) => {
page.on('request', request => {
const url = request.url();
requestsURL.add(url);
loaded(page, browser);
if (url.startsWith('http://localhost:3000/') ||
url.startsWith('https://geomapfish-demo-2-5.camptocamp.com/') ||
url.startsWith('https://wms.geo.admin.ch/')) {
requestsURL.add(url);
request.continue();
} else if (url.includes('tile.openstreetmap.org')) {
request.respond({
status: 200,
headers: {
'content-type': 'image/png',
},
body: OSMImage,
});
} else {
request.abort();
}
});
page.on('requestfinished', (request) => {
page.on('requestfinished', request => {
const url = request.url();
requestsURL.delete(url);
loaded(page, browser);
});
page.on('requestfailed', (request) => {
page.on('requestfailed', request => {
const url = request.url();
requestsURL.delete(url);
if (url.includes('tile.openstreetmap.org')) {
console.warn('Ignoring resource error from OpenStreetMap');
} else if (url.includes('https://maps.googleapis.com/maps/api/js')) {
console.warn('Ignoring resource error from Google');
} else if (url.includes('https://csi.gstatic.com/')) {
console.warn('Ignoring resource error from Google static');
} else if (url.includes('cdn.polyfill.io')) {
console.warn('Ignoring resource error from polyfill.io');
} else {
if (url.startsWith('http://localhost:3000/') ||
url.startsWith('https://geomapfish-demo-2-5.camptocamp.com/') ||
url.startsWith('https://wms.geo.admin.ch/')) {
console.log(`Request failed on: ${url}`);
process.exit(2);
}
loaded(page, browser);
});
page.on('console', (message) => {
page.on('console', message => {
const type = message.type();
const location = message.location();
if (type !== 'log' && type !== 'debug' && type !== 'info' && type !== 'warning' &&
location.url != 'http://localhost:3000/.build/examples-hosted/dist/vendor.js?dev'
!location.url.startsWith('http://localhost:3000/.build/examples-hosted/dist/vendor.js') &&
location.url.startsWith('http://localhost:3000/')
) {
console.log(`Console ${type}`);
console.log(`On: ${location.url} ${location.lineNumber}:${location.columnNumber}.`);
Expand Down
Binary file added buildtools/osm.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added contribs/gmf/apps/desktop-ref.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added contribs/gmf/apps/desktop_alt-ref.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added contribs/gmf/apps/iframe_api-ref.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added contribs/gmf/apps/mobile-ref.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added contribs/gmf/apps/mobile_alt-ref.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added contribs/gmf/apps/oeedit-ref.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added contribs/gmf/examples/authentication-ref.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added contribs/gmf/examples/contextualdata-ref.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added contribs/gmf/examples/datepicker-ref.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added contribs/gmf/examples/displayquerygrid-ref.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
1 change: 0 additions & 1 deletion contribs/gmf/examples/displayquerygrid.html
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@
<meta name="viewport"
content="initial-scale=1.0, user-scalable=no, width=device-width">
<meta name="apple-mobile-web-app-capable" content="yes">
<link href="./gmf-hidden.inc.css" rel="stylesheet" />
</head>
<body ng-controller="MainController as ctrl">

Expand Down
1 change: 1 addition & 0 deletions contribs/gmf/examples/displayquerygrid.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import angular from 'angular';
import appURL from './url.js';
import './displayquerygrid.css';
import './gmf-hidden.inc.css';
import gmfDatasourceManager from 'gmf/datasource/Manager.js';

import gmfLayertreeComponent from 'gmf/layertree/component.js';
Expand Down
Binary file added contribs/gmf/examples/displayquerywindow-ref.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
1 change: 0 additions & 1 deletion contribs/gmf/examples/displayquerywindow.html
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@
<meta name="viewport"
content="initial-scale=1.0, user-scalable=no, width=device-width">
<meta name="apple-mobile-web-app-capable" content="yes">
<link href="./gmf-hidden.inc.css" rel="stylesheet" />
</head>
<body ng-controller="MainController as ctrl">

Expand Down
1 change: 1 addition & 0 deletions contribs/gmf/examples/displayquerywindow.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import angular from 'angular';
import appURL from './url.js';
import './displayquerywindow.css';
import './gmf-hidden.inc.css';
import gmfDatasourceManager from 'gmf/datasource/Manager.js';

import gmfLayertreeComponent from 'gmf/layertree/component.js';
Expand Down
Binary file added contribs/gmf/examples/drawfeature-ref.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added contribs/gmf/examples/editfeature-ref.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
1 change: 0 additions & 1 deletion contribs/gmf/examples/editfeatureselector.html
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@
<meta name="viewport"
content="initial-scale=1.0, user-scalable=no, width=device-width">
<meta name="mobile-web-app-capable" content="yes">
<link href="./gmf-hidden.inc.css" rel="stylesheet" />
</head>
<body ng-controller="MainController as ctrl">
<gmf-map gmf-map-map="ctrl.map"></gmf-map>
Expand Down
1 change: 1 addition & 0 deletions contribs/gmf/examples/editfeatureselector.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import angular from 'angular';
import appURL from './url.js';
import './editfeatureselector.css';
import './gmf-hidden.inc.css';
import 'bootstrap/js/src/tooltip.js';
import gmfAuthenticationModule from 'gmf/authentication/module.js';

Expand Down
Binary file added contribs/gmf/examples/elevation-ref.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added contribs/gmf/examples/featurestyle-ref.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added contribs/gmf/examples/filterselector-ref.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added contribs/gmf/examples/importdatasource-ref.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added contribs/gmf/examples/layertree-ref.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added contribs/gmf/examples/layertreeadd-ref.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added contribs/gmf/examples/lidarprofile-ref.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added contribs/gmf/examples/mobilemeasure-ref.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added contribs/gmf/examples/mouseposition-ref.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added contribs/gmf/examples/objectediting-ref.png
Binary file added contribs/gmf/examples/objecteditinghub-ref.png
Binary file added contribs/gmf/examples/permalink-ref.png
Binary file added contribs/gmf/examples/print-ref.png
1 change: 0 additions & 1 deletion contribs/gmf/examples/print.html
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@
<meta name="viewport"
content="initial-scale=1.0, user-scalable=no, width=device-width">
<meta name="apple-mobile-web-app-capable" content="yes">
<link href="./gmf-hidden.inc.css" rel="stylesheet" />
</head>
<body ng-controller="MainController as ctrl">

Expand Down
1 change: 1 addition & 0 deletions contribs/gmf/examples/print.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import angular from 'angular';
import appURL from './url.js';
import './print.css';
import './gmf-hidden.inc.css';
import gmfLayertreeComponent from 'gmf/layertree/component.js';

import gmfMapComponent from 'gmf/map/component.js';
Expand Down
Binary file added contribs/gmf/examples/profile-ref.png
Binary file added contribs/gmf/examples/search-ref.png
Binary file added contribs/gmf/examples/share-ref.png
Binary file added contribs/gmf/examples/simple-ref.png
Binary file added contribs/gmf/examples/themeselector-ref.png
Binary file added contribs/gmf/examples/timeslider-ref.png
Binary file added contribs/gmf/examples/wfspermalink-ref.png
Binary file added contribs/gmf/examples/xsdattributes-ref.png
Binary file added examples/animation-ref.png
Binary file added examples/asitvd-ref.png
Binary file added examples/attributes-ref.png
Binary file added examples/backgroundlayer-ref.png
File renamed without changes.
Binary file added examples/bboxquery-ref.png
File renamed without changes.
Binary file added examples/colorpicker-ref.png
Binary file added examples/control-ref.png
Binary file added examples/createfeature-ref.png
Binary file added examples/datepicker-ref.png
Binary file added examples/datetimepicker-ref.png
Binary file added examples/desktopgeolocation-ref.png
Binary file added examples/disclaimer-ref.png
Binary file added examples/displaywindow-ref.png
Binary file added examples/drawfeature-ref.png
Binary file added examples/elevationProfile-ref.png
Binary file added examples/googlestreetview-ref.png
Binary file added examples/grid-ref.png
Binary file added examples/importfeatures-ref.png
Binary file added examples/interactionbtngroup-ref.png
Binary file added examples/layerorder-ref.png
File renamed without changes.
Binary file added examples/locationsearch-ref.png
Binary file added examples/mapfishprint-ref.png
Binary file added examples/mapquery-ref.png
Binary file added examples/measure-ref.png
Binary file added examples/mobilegeolocation-ref.png
Binary file added examples/modal-ref.png
Binary file added examples/modifycircle-ref.png
Binary file added examples/modifyrectangle-ref.png
Binary file added examples/notification-ref.png
File renamed without changes.
Binary file added examples/permalink-ref.png
Binary file added examples/popover-ref.png
Binary file added examples/popupservice-ref.png
Binary file added examples/recenter-ref.png
Binary file added examples/rotate-ref.png
Binary file added examples/routing-ref.png
Binary file added examples/scaleselector-ref.png
Binary file added examples/search-ref.png
Binary file added examples/simple-ref.png
Binary file added examples/simple3d-ref.png
Binary file added examples/toolActivate-ref.png

0 comments on commit d68766b

Please sign in to comment.