Harden various tests.
Try to handle slow tests better by waiting for more identifiable conditions.
MODIFY
CMakeLists.txt
CMakeLists.txt
@@ -109,6 +109,8 @@ if(FFHEADLESS_TESTS)
set_property(TEST "ffheadless" APPEND PROPERTY ENVIRONMENT "TEST_SAVE_IMAGE=${TEST_SAVE_IMAGE}")
set_property(TEST "total-coverage" APPEND PROPERTY DEPENDS "ffheadless")
set_property(TEST "ffheadless" APPEND PROPERTY DEPENDS "get_data_files")
+ # We use some of the example images in the ffheadless tests
+ set_property(TEST "ffheadless" APPEND PROPERTY DEPENDS "build_examples")
add_test(
NAME "examplesheadless"

MODIFY
examples/blog-lines/main.js
examples/blog-lines/main.js
@@ -299,6 +299,7 @@ function geojsLinesTest(opts) {
var geo = libraryReference(opts);
+ $(opts.node).removeClass('ready');
// create the map
var map = geo.map({
node: opts.node,
@@ -358,6 +359,12 @@ function geojsLinesTest(opts) {
map.draw();
+ map.onIdle(function () {
+ map.scheduleAnimationFrame(function () {
+ $(opts.node).addClass('ready');
+ }, 'readyFlag');
+ });
+
// return references to the various objects
return {
map: map,

MODIFY
examples/lines/main.js
examples/lines/main.js
@@ -129,7 +129,7 @@ $(function () {
* the line.
*/
function show_lines(rawdata) {
- $('#map').removeClass('ready');
+ $('#map').removeClass('ready').attr('segments', '');
if (!rawdata) {
return;
}
@@ -146,7 +146,7 @@ $(function () {
var text = 'Shown: ' + segments;
$('#lines-shown').text(text).attr('title', text);
map.onIdle(function () {
- $('#map').addClass('ready');
+ $('#map').addClass('ready').attr('segments', maxsegments);
});
}
@@ -291,9 +291,9 @@ $(function () {
function select_preset(evt) {
var update;
var ctl = $(evt.target);
- var keys = ['antialiasing', 'lineCap', 'lineJoin', 'lines', 'miterLimit',
- 'showmap', 'strokeColor', 'strokeOffset', 'strokeOpacity',
- 'strokeWidth'];
+ var keys = [
+ 'antialiasing', 'lineCap', 'lineJoin', 'lines', 'miterLimit', 'showmap',
+ 'strokeColor', 'strokeOffset', 'strokeOpacity', 'strokeWidth'];
skipdraw = true;
$.each(keys, function (idx, key) {
var value = ctl.attr(key);

MODIFY
tests/example-cases/blog-lines.js
tests/example-cases/blog-lines.js
@@ -32,7 +32,7 @@ describe('blog-lines example', function () {
it('basic', function (done) {
$('#map').attr('src', '/examples/blog-lines/index.html?mode=select');
- imageTest.imageTest('exampleBlogLines', '#map', 0.0015, done, ready, 500, 2);
+ imageTest.imageTest('exampleBlogLines', '#map', 0.0015, done, ready, 500, 2, '.leaflet-pane');
}, 10000);
it('round line cap', function (done) {
$('#map')[0].contentWindow.scrollTo(0, 130);
@@ -41,7 +41,10 @@ describe('blog-lines example', function () {
imageTest.imageTest('exampleBlogLinesRoundCap', '#map', 0.0015, done, ready, 500, 2, '.mapboxgl-canvas');
}, 20000);
it('10,000 lines in geojs', function (done) {
+ // remove previous contents to ensure we detect new contents
+ base$ = $('iframe#map')[0].contentWindow.jQuery;
+ base$('.geojs-map.ready').remove();
$('#map').attr('src', '/examples/blog-lines/index.html?renderer=vgl&data=roads&lines=10000&x=-73.7593015&y=42.8496799&zoom=13&strokeOpacity=1&strokeWidth=2&antialiasing=2&referenceLines=false');
- imageTest.imageTest('exampleBlogLines10k', '#map', 0.0015, done, null, 1000, 2);
+ imageTest.imageTest('exampleBlogLines10k', '#map', 0.0015, done, null, 1000, 2, '.geojs-map.ready');
}, 10000);
});

MODIFY
tests/example-cases/lines.js
tests/example-cases/lines.js
@@ -15,7 +15,7 @@ describe('lines example', function () {
it('more lines', function (done) {
base$ = $('iframe#map')[0].contentWindow.jQuery;
base$('#lines').val(100000).trigger('change');
- imageTest.imageTest('exampleLines100k', '#map', 0.0015, done, null, 0, 2, '#map.ready');
+ imageTest.imageTest('exampleLines100k', '#map', 0.0015, done, null, 0, 2, '#map.ready[segments="100000"]');
}, 10000);
it('thin preset', function (done) {
base$('button.preset').eq(1).trigger('click');

MODIFY
tests/gl-cases/glLines.js
tests/gl-cases/glLines.js
@@ -142,5 +142,5 @@ describe('glLines', function () {
imageTest.imageTest('glLinesOpts', null, 0.0015, done, myMap.onIdle, 0, 2);
- });
+ }, 10000);
});

MODIFY
tests/gl-cases/glQuad.js
tests/gl-cases/glQuad.js
@@ -117,7 +117,6 @@ describe('glQuad', function () {
myMap.draw();
- // use a short delay to allow all of the images to load
imageTest.imageTest('glQuad', null, 0.0015, done, myMap.onIdle, 0, 2);
};

MODIFY
tests/gl-cases/points.js
tests/gl-cases/points.js
@@ -113,7 +113,6 @@ describe('points', function () {
feature.style('fillOpacity', 0.2)
.style('strokeOpacity', 0.2);
myMap.draw();
- // use a short delay to allow images to load
imageTest.imageTest('glPointsWithQuad', null, 0.0015, done, myMap.onIdle, 0, 2);
}, 1000);
});

Harden various tests.

Try to handle slow tests better by waiting for more identifiable conditions.