Skip to content

Commit

Permalink
Harden various tests.
Browse files Browse the repository at this point in the history
Try to handle slow tests better by waiting for more identifiable conditions.
  • Loading branch information
manthey committed Mar 15, 2017
1 parent e114f04 commit 879e7e3
Show file tree
Hide file tree
Showing 7 changed files with 16 additions and 12 deletions.
5 changes: 5 additions & 0 deletions examples/blog-lines/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -358,6 +359,10 @@ function geojsLinesTest(opts) {

map.draw();

map.onIdle(function () {
$(opts.node).addClass('ready');
});

// return references to the various objects
return {
map: map,
Expand Down
10 changes: 5 additions & 5 deletions examples/lines/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -129,7 +129,7 @@ $(function () {
* the line.
*/
function show_lines(rawdata) {
$('#map').removeClass('ready');
$('#map').removeClass('ready').attr('segments', '');
if (!rawdata) {
return;
}
Expand All @@ -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);
});
}

Expand Down Expand Up @@ -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);
Expand Down
4 changes: 2 additions & 2 deletions tests/example-cases/blog-lines.js
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand All @@ -42,6 +42,6 @@ describe('blog-lines example', function () {
}, 20000);
it('10,000 lines in geojs', function (done) {
$('#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);
});
2 changes: 1 addition & 1 deletion tests/example-cases/lines.js
Original file line number Diff line number Diff line change
Expand Up @@ -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');
Expand Down
2 changes: 1 addition & 1 deletion tests/gl-cases/glLines.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions tests/gl-cases/glQuad.js
Original file line number Diff line number Diff line change
Expand Up @@ -117,8 +117,8 @@ 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);
// wait some extra animation cycles to allow images to appear
imageTest.imageTest('glQuad', null, 0.0015, done, myMap.onIdle, 0, 12);
};

previewImage.src = '/data/grid.jpg';
Expand Down
1 change: 0 additions & 1 deletion tests/gl-cases/points.js
Original file line number Diff line number Diff line change
Expand Up @@ -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);
});
Expand Down

0 comments on commit 879e7e3

Please sign in to comment.