Rename assert.imageEqualsFile

This commit is contained in:
Raul Ochoa 2016-02-22 16:36:06 +01:00
parent da680ec2a8
commit 495fdaf8ec
14 changed files with 78 additions and 50 deletions

View File

@ -292,7 +292,8 @@ describe('render limits', function() {
if (err) { if (err) {
done(err); done(err);
} }
assert.imageEqualsFile(res.body, './test/fixtures/render-timeout-fallback.png', 25, var referenceImagePath = './test/fixtures/render-timeout-fallback.png';
assert.imageBufferIsSimilarToFile(res.body, referenceImagePath, 25,
function(imgErr/*, similarity*/) { function(imgErr/*, similarity*/) {
done(imgErr); done(imgErr);
} }

View File

@ -122,7 +122,7 @@ describe(suiteName, function() {
' WHERE m.tabname = any ((SELECT tablenames from querytables)::regclass[])'); ' WHERE m.tabname = any ((SELECT tablenames from querytables)::regclass[])');
} }
assert.imageEqualsFile(res.body, 'test/fixtures/test_table_0_0_0_multilayer1.png', assert.imageBufferIsSimilarToFile(res.body, 'test/fixtures/test_table_0_0_0_multilayer1.png',
IMAGE_EQUALS_HIGHER_TOLERANCE_PER_MIL, function(err/*, similarity*/) { IMAGE_EQUALS_HIGHER_TOLERANCE_PER_MIL, function(err/*, similarity*/) {
next(err); next(err);
} }
@ -404,7 +404,8 @@ describe(suiteName, function() {
' WHERE m.tabname = any ((SELECT tablenames from querytables)::regclass[])'); ' WHERE m.tabname = any ((SELECT tablenames from querytables)::regclass[])');
} }
assert.imageEqualsFile(res.body, 'test/fixtures/test_multilayer_bbox.png', IMAGE_EQUALS_TOLERANCE_PER_MIL, var referenceImagePath = 'test/fixtures/test_multilayer_bbox.png';
assert.imageBufferIsSimilarToFile(res.body, referenceImagePath, IMAGE_EQUALS_TOLERANCE_PER_MIL,
function(err/*, similarity*/) { function(err/*, similarity*/) {
next(err); next(err);
}); });
@ -443,7 +444,8 @@ describe(suiteName, function() {
' WHERE m.tabname = any ((SELECT tablenames from querytables)::regclass[])'); ' WHERE m.tabname = any ((SELECT tablenames from querytables)::regclass[])');
} }
assert.imageEqualsFile(res.body, 'test/fixtures/test_multilayer_bbox.png', IMAGE_EQUALS_TOLERANCE_PER_MIL, var referenceImagePath = 'test/fixtures/test_multilayer_bbox.png';
assert.imageBufferIsSimilarToFile(res.body, referenceImagePath, IMAGE_EQUALS_TOLERANCE_PER_MIL,
function(err/*, similarity*/) { function(err/*, similarity*/) {
next(err); next(err);
}); });
@ -1019,7 +1021,7 @@ describe(suiteName, function() {
}, {}, function(res) { }, {}, function(res) {
assert.equal(res.statusCode, 200, res.body); assert.equal(res.statusCode, 200, res.body);
assert.equal(res.headers['content-type'], "image/png"); assert.equal(res.headers['content-type'], "image/png");
assert.imageEqualsFile(res.body, windshaft_fixtures + '/test_default_mapnik_point.png', assert.imageBufferIsSimilarToFile(res.body, windshaft_fixtures + '/test_default_mapnik_point.png',
IMAGE_EQUALS_TOLERANCE_PER_MIL, function(err/*, similarity*/) { IMAGE_EQUALS_TOLERANCE_PER_MIL, function(err/*, similarity*/) {
next(err); next(err);
} }

View File

@ -30,7 +30,8 @@ describe('overviews_queries', function() {
if (err) { if (err) {
return done(err); return done(err);
} }
assert.imageEqualsFile(tile.body, './test/fixtures/' + fixture, IMAGE_EQUALS_TOLERANCE_PER_MIL, done); var referenceImagePath = './test/fixtures/' + fixture;
assert.imageBufferIsSimilarToFile(tile.body, referenceImagePath, IMAGE_EQUALS_TOLERANCE_PER_MIL, done);
}; };
} }

View File

@ -95,10 +95,12 @@ describe('blend png renderer', function() {
var zxy = [tileRequest.z, tileRequest.x, tileRequest.y]; var zxy = [tileRequest.z, tileRequest.x, tileRequest.y];
it('tile all/' + zxy.join('/') + '.png', function (done) { it('tile all/' + zxy.join('/') + '.png', function (done) {
testClient.getTileLayer(plainTorqueMapConfig(testScenario.plainColor), tileRequest, function(err, res) { testClient.getTileLayer(plainTorqueMapConfig(testScenario.plainColor), tileRequest, function(err, res) {
assert.imageEqualsFile(res.body, blendPngFixture(zxy), IMAGE_TOLERANCE_PER_MIL, function(err) { assert.imageBufferIsSimilarToFile(res.body, blendPngFixture(zxy), IMAGE_TOLERANCE_PER_MIL,
assert.ok(!err); function(err) {
done(); assert.ok(!err);
}); done();
}
);
}); });
}); });
}); });

View File

@ -156,10 +156,12 @@ describe('blend layer filtering', function() {
it('should filter on ' + layerFilter + '/1/0/0.png', function (done) { it('should filter on ' + layerFilter + '/1/0/0.png', function (done) {
testClient.getTileLayer(mapConfig, tileRequest, function(err, res) { testClient.getTileLayer(mapConfig, tileRequest, function(err, res) {
assert.imageEqualsFile(res.body, blendPngFixture(filteredLayers), IMG_TOLERANCE_PER_MIL, function(err) { assert.imageBufferIsSimilarToFile(res.body, blendPngFixture(filteredLayers), IMG_TOLERANCE_PER_MIL,
assert.ok(!err); function(err) {
done(); assert.ok(!err);
}); done();
}
);
}); });
}); });
}); });

View File

@ -111,10 +111,12 @@ describe('blend http fallback', function() {
it('should fallback on http error while blending layers ' + layerFilter + '/1/0/0.png', function (done) { it('should fallback on http error while blending layers ' + layerFilter + '/1/0/0.png', function (done) {
testClient.getTileLayer(mapConfig, tileRequest, function(err, res) { testClient.getTileLayer(mapConfig, tileRequest, function(err, res) {
assert.imageEqualsFile(res.body, blendPngFixture(filteredLayers), IMG_TOLERANCE_PER_MIL, function(err) { assert.imageBufferIsSimilarToFile(res.body, blendPngFixture(filteredLayers), IMG_TOLERANCE_PER_MIL,
assert.ok(!err, err); function(err) {
done(); assert.ok(!err, err);
}); done();
}
);
}); });
}); });
}); });

View File

@ -57,7 +57,8 @@ describe('external resources', function() {
if (err) { if (err) {
return done(err); return done(err);
} }
assert.imageEqualsFile(res.body, './test/fixtures/' + fixture, IMAGE_EQUALS_TOLERANCE_PER_MIL, done); var referenceImagePath = './test/fixtures/' + fixture;
assert.imageBufferIsSimilarToFile(res.body, referenceImagePath, IMAGE_EQUALS_TOLERANCE_PER_MIL, done);
}; };
} }

View File

@ -84,11 +84,13 @@ describe.skip('render limits', function() {
testClient.withLayergroup(slowQueryMapConfig, options, function(err, requestTile, finish) { testClient.withLayergroup(slowQueryMapConfig, options, function(err, requestTile, finish) {
var tileUrl = '/0/0/0.png'; var tileUrl = '/0/0/0.png';
requestTile(tileUrl, options, function(err, res) { requestTile(tileUrl, options, function(err, res) {
assert.imageEqualsFile(res.body, fixtureImage, IMAGE_EQUALS_TOLERANCE_PER_MIL, function(err) { assert.imageBufferIsSimilarToFile(res.body, fixtureImage, IMAGE_EQUALS_TOLERANCE_PER_MIL,
finish(function(finishErr) { function(err) {
done(err || finishErr); finish(function(finishErr) {
}); done(err || finishErr);
}); });
}
);
}); });
}); });
}); });

View File

@ -117,7 +117,8 @@ describe('multilayer', function() {
assert.equal(res.statusCode, 200, res.body); assert.equal(res.statusCode, 200, res.body);
assert.equal(res.headers['content-type'], "image/png"); assert.equal(res.headers['content-type'], "image/png");
checkCORSHeaders(res); checkCORSHeaders(res);
assert.imageEqualsFile(res.body, './test/fixtures/test_bigpoint_red.png', IMAGE_EQUALS_TOLERANCE_PER_MIL, var referenceImagePath = './test/fixtures/test_bigpoint_red.png';
assert.imageBufferIsSimilarToFile(res.body, referenceImagePath, IMAGE_EQUALS_TOLERANCE_PER_MIL,
function(err) { function(err) {
next(err); next(err);
}); });
@ -191,7 +192,8 @@ describe('multilayer', function() {
}, {}, function(res) { }, {}, function(res) {
assert.equal(res.statusCode, 200, res.body); assert.equal(res.statusCode, 200, res.body);
assert.equal(res.headers['content-type'], "image/png"); assert.equal(res.headers['content-type'], "image/png");
assert.imageEqualsFile(res.body, './test/acceptance/ported/fixtures/test_table_0_0_0_multilayer1.png', var referenceImagePath = './test/acceptance/ported/fixtures/test_table_0_0_0_multilayer1.png';
assert.imageBufferIsSimilarToFile(res.body, referenceImagePath,
IMAGE_EQUALS_TOLERANCE_PER_MIL, function(err) { IMAGE_EQUALS_TOLERANCE_PER_MIL, function(err) {
next(err); next(err);
}); });
@ -302,7 +304,8 @@ describe('multilayer', function() {
}, {}, function(res) { }, {}, function(res) {
assert.equal(res.statusCode, 200, res.body); assert.equal(res.statusCode, 200, res.body);
assert.equal(res.headers['content-type'], "image/png"); assert.equal(res.headers['content-type'], "image/png");
assert.imageEqualsFile(res.body, './test/acceptance/ported/fixtures/test_table_0_0_0_multilayer1.png', var referenceImagePath = './test/acceptance/ported/fixtures/test_table_0_0_0_multilayer1.png';
assert.imageBufferIsSimilarToFile(res.body, referenceImagePath,
IMAGE_EQUALS_TOLERANCE_PER_MIL, function(err) { IMAGE_EQUALS_TOLERANCE_PER_MIL, function(err) {
next(err); next(err);
}); });
@ -425,7 +428,8 @@ describe('multilayer', function() {
}, {}, function(res) { }, {}, function(res) {
assert.equal(res.statusCode, 200, res.body); assert.equal(res.statusCode, 200, res.body);
assert.equal(res.headers['content-type'], "image/png"); assert.equal(res.headers['content-type'], "image/png");
assert.imageEqualsFile(res.body, './test/acceptance/ported/fixtures/test_table_0_0_0_multilayer1.png', var referenceImagePath = './test/acceptance/ported/fixtures/test_table_0_0_0_multilayer1.png';
assert.imageBufferIsSimilarToFile(res.body, referenceImagePath,
IMAGE_EQUALS_TOLERANCE_PER_MIL, function(err) { IMAGE_EQUALS_TOLERANCE_PER_MIL, function(err) {
next(err); next(err);
}); });
@ -541,7 +545,8 @@ describe('multilayer', function() {
}, {}, function(res) { }, {}, function(res) {
assert.equal(res.statusCode, 200, res.body); assert.equal(res.statusCode, 200, res.body);
assert.equal(res.headers['content-type'], "image/png"); assert.equal(res.headers['content-type'], "image/png");
assert.imageEqualsFile(res.body, './test/acceptance/ported/fixtures/test_table_0_0_0_multilayer1.png', var referenceImagePath = './test/acceptance/ported/fixtures/test_table_0_0_0_multilayer1.png';
assert.imageBufferIsSimilarToFile(res.body, referenceImagePath,
IMAGE_EQUALS_TOLERANCE_PER_MIL, function(err) { IMAGE_EQUALS_TOLERANCE_PER_MIL, function(err) {
next(err); next(err);
}); });
@ -727,7 +732,8 @@ describe('multilayer', function() {
}, {}, function(res) { }, {}, function(res) {
assert.equal(res.statusCode, 200, res.body); assert.equal(res.statusCode, 200, res.body);
assert.equal(res.headers['content-type'], "image/png"); assert.equal(res.headers['content-type'], "image/png");
assert.imageEqualsFile(res.body, './test/acceptance/ported/fixtures/test_table_0_0_0_multilayer2.png', var referenceImagePath = './test/acceptance/ported/fixtures/test_table_0_0_0_multilayer2.png';
assert.imageBufferIsSimilarToFile(res.body, referenceImagePath,
IMAGE_EQUALS_TOLERANCE_PER_MIL, function(err) { IMAGE_EQUALS_TOLERANCE_PER_MIL, function(err) {
next(err); next(err);
}); });
@ -761,7 +767,8 @@ describe('multilayer', function() {
}, {}, function(res) { }, {}, function(res) {
assert.equal(res.statusCode, 200, res.body); assert.equal(res.statusCode, 200, res.body);
assert.equal(res.headers['content-type'], "image/png"); assert.equal(res.headers['content-type'], "image/png");
assert.imageEqualsFile(res.body, './test/acceptance/ported/fixtures/test_table_0_0_0_multilayer3.png', var referenceImagePath = './test/acceptance/ported/fixtures/test_table_0_0_0_multilayer3.png';
assert.imageBufferIsSimilarToFile(res.body, referenceImagePath,
IMAGE_EQUALS_TOLERANCE_PER_MIL, function(err) { IMAGE_EQUALS_TOLERANCE_PER_MIL, function(err) {
next(err); next(err);
}); });
@ -856,7 +863,8 @@ describe('multilayer', function() {
}, {}, function(res) { }, {}, function(res) {
assert.equal(res.statusCode, 200, res.body); assert.equal(res.statusCode, 200, res.body);
assert.equal(res.headers['content-type'], "image/png"); assert.equal(res.headers['content-type'], "image/png");
assert.imageEqualsFile(res.body, './test/acceptance/ported/fixtures/test_table_0_0_0_multilayer4.png', var referenceImagePath = './test/acceptance/ported/fixtures/test_table_0_0_0_multilayer4.png';
assert.imageBufferIsSimilarToFile(res.body, referenceImagePath,
IMAGE_EQUALS_TOLERANCE_PER_MIL, function(err) { IMAGE_EQUALS_TOLERANCE_PER_MIL, function(err) {
next(err); next(err);
}); });
@ -1259,7 +1267,7 @@ describe('multilayer', function() {
assert.equal(res.statusCode, 200, res.body); assert.equal(res.statusCode, 200, res.body);
assert.equal(res.headers['content-type'], "image/png"); assert.equal(res.headers['content-type'], "image/png");
checkCORSHeaders(res); checkCORSHeaders(res);
assert.imageEqualsFile(res.body, './test/fixtures/test_bigpoint_red.png', assert.imageBufferIsSimilarToFile(res.body, './test/fixtures/test_bigpoint_red.png',
IMAGE_EQUALS_TOLERANCE_PER_MIL, function(err) { IMAGE_EQUALS_TOLERANCE_PER_MIL, function(err) {
next(err); next(err);
}); });

View File

@ -87,7 +87,7 @@ describe('raster', function() {
assert.equal(res.statusCode, 200, res.body); assert.equal(res.statusCode, 200, res.body);
assert.deepEqual(res.headers['content-type'], "image/png"); assert.deepEqual(res.headers['content-type'], "image/png");
var next = this; var next = this;
assert.imageEqualsFile(res.body, assert.imageBufferIsSimilarToFile(res.body,
'./test/fixtures/raster_gray_rect.png', './test/fixtures/raster_gray_rect.png',
IMAGE_EQUALS_TOLERANCE_PER_MIL, function(err) { IMAGE_EQUALS_TOLERANCE_PER_MIL, function(err) {
try { try {

View File

@ -34,7 +34,9 @@ describe('server_gettile', function() {
if (err) { if (err) {
return done(err); return done(err);
} }
assert.imageEqualsFile(res.body, './test/fixtures/' + fixture, IMAGE_EQUALS_TOLERANCE_PER_MIL, done); assert.imageBufferIsSimilarToFile(
res.body, './test/fixtures/' + fixture, IMAGE_EQUALS_TOLERANCE_PER_MIL, done
);
}; };
} }
@ -113,12 +115,13 @@ describe('server_gettile', function() {
assert.ok(res.headers.hasOwnProperty('x-windshaft-cache'), "Did not hit renderer cache on second time"); assert.ok(res.headers.hasOwnProperty('x-windshaft-cache'), "Did not hit renderer cache on second time");
assert.ok(res.headers['x-windshaft-cache'] >= 0); assert.ok(res.headers['x-windshaft-cache'] >= 0);
assert.imageEqualsFile(res.body, imageFixture, IMAGE_EQUALS_TOLERANCE_PER_MIL, function(err) { assert.imageBufferIsSimilarToFile(res.body, imageFixture, IMAGE_EQUALS_TOLERANCE_PER_MIL,
function(err) {
finish(function(finishErr) { finish(function(finishErr) {
done(err || finishErr); done(err || finishErr);
}); });
}); }
);
}); });
}); });
}); });

View File

@ -83,10 +83,12 @@ describe('torque png renderer', function() {
var zxy = [z, x, y]; var zxy = [z, x, y];
it('tile ' + zxy.join('/') + '.torque.png', function (done) { it('tile ' + zxy.join('/') + '.torque.png', function (done) {
testClient.getTileLayer(torquePngPointsMapConfig, tileRequest, function(err, res) { testClient.getTileLayer(torquePngPointsMapConfig, tileRequest, function(err, res) {
assert.imageEqualsFile(res.body, torquePngFixture(zxy), IMAGE_TOLERANCE_PER_MIL, function(err) { assert.imageBufferIsSimilarToFile(res.body, torquePngFixture(zxy), IMAGE_TOLERANCE_PER_MIL,
assert.ok(!err); function(err) {
done(); assert.ok(!err);
}); done();
}
);
}); });
}); });
}); });

View File

@ -107,10 +107,12 @@ describe('wrap x coordinate', function() {
var fixtureZxy = [testScenario.fixture.z, testScenario.fixture.x, testScenario.fixture.y]; var fixtureZxy = [testScenario.fixture.z, testScenario.fixture.x, testScenario.fixture.y];
it('tile all/' + zxy.join('/') + '.png', function (done) { it('tile all/' + zxy.join('/') + '.png', function (done) {
testClient.getTileLayer(plainTorqueMapConfig(testScenario.plainColor), tileRequest, function(err, res) { testClient.getTileLayer(plainTorqueMapConfig(testScenario.plainColor), tileRequest, function(err, res) {
assert.imageEqualsFile(res.body, blendPngFixture(fixtureZxy), IMG_TOLERANCE_PER_MIL, function(err) { assert.imageBufferIsSimilarToFile(res.body, blendPngFixture(fixtureZxy), IMG_TOLERANCE_PER_MIL,
assert.ok(!err); function(err) {
done(); assert.ok(!err);
}); done();
}
);
}); });
}); });
}); });

View File

@ -21,7 +21,7 @@ var assert = module.exports = exports = require('assert');
* @param {function} callback Will call to home with null in case there is no error, otherwise with the error itself * @param {function} callback Will call to home with null in case there is no error, otherwise with the error itself
* @see FUZZY in http://www.imagemagick.org/script/command-line-options.php#metric * @see FUZZY in http://www.imagemagick.org/script/command-line-options.php#metric
*/ */
assert.imageEqualsFile = function(buffer, referenceImageRelativeFilePath, tolerance, callback) { assert.imageBufferIsSimilarToFile = function(buffer, referenceImageRelativeFilePath, tolerance, callback) {
callback = callback || function(err) { assert.ifError(err); }; callback = callback || function(err) { assert.ifError(err); };
var referenceImageFilePath = path.resolve(referenceImageRelativeFilePath); var referenceImageFilePath = path.resolve(referenceImageRelativeFilePath);