Make imagesAreSimilar private

This commit is contained in:
Raul Ochoa 2016-02-22 16:07:26 +01:00
parent 7c7bec6f31
commit 3cadf7f2a2

View File

@ -29,17 +29,17 @@ assert.imageEqualsFile = function(buffer, referenceImageRelativeFilePath, tolera
var testImage = mapnik.Image.fromBytes(Buffer.isBuffer(buffer) ? buffer : new Buffer(buffer, 'binary')); var testImage = mapnik.Image.fromBytes(Buffer.isBuffer(buffer) ? buffer : new Buffer(buffer, 'binary'));
var referenceImage = mapnik.Image.fromBytes(fs.readFileSync(referenceImageFilePath, { encoding: null })); var referenceImage = mapnik.Image.fromBytes(fs.readFileSync(referenceImageFilePath, { encoding: null }));
assert.imagesAreSimilar(testImage, referenceImage, tolerance, callback); imagesAreSimilar(testImage, referenceImage, tolerance, callback);
}; };
assert.imageBuffersAreSimilar = function(bufferA, bufferB, tolerance, callback) { assert.imageBuffersAreSimilar = function(bufferA, bufferB, tolerance, callback) {
var testImage = mapnik.Image.fromBytes(Buffer.isBuffer(bufferA) ? bufferA : new Buffer(bufferA, 'binary')); var testImage = mapnik.Image.fromBytes(Buffer.isBuffer(bufferA) ? bufferA : new Buffer(bufferA, 'binary'));
var referenceImage = mapnik.Image.fromBytes(Buffer.isBuffer(bufferB) ? bufferB : new Buffer(bufferB, 'binary')); var referenceImage = mapnik.Image.fromBytes(Buffer.isBuffer(bufferB) ? bufferB : new Buffer(bufferB, 'binary'));
assert.imagesAreSimilar(testImage, referenceImage, tolerance, callback); imagesAreSimilar(testImage, referenceImage, tolerance, callback);
}; };
assert.imagesAreSimilar = function(testImage, referenceImage, tolerance, callback) { function imagesAreSimilar(testImage, referenceImage, tolerance, callback) {
if (testImage.width() !== referenceImage.width() || testImage.height() !== referenceImage.height()) { if (testImage.width() !== referenceImage.width() || testImage.height() !== referenceImage.height()) {
return callback(new Error('Images are not the same size')); return callback(new Error('Images are not the same size'));
} }
@ -57,7 +57,7 @@ assert.imagesAreSimilar = function(testImage, referenceImage, tolerance, callbac
} else { } else {
callback(null, similarity); callback(null, similarity);
} }
}; }
assert.imageIsSimilarToFile = function(testImage, referenceImageRelativeFilePath, tolerance, callback) { assert.imageIsSimilarToFile = function(testImage, referenceImageRelativeFilePath, tolerance, callback) {
callback = callback || function(err) { assert.ifError(err); }; callback = callback || function(err) { assert.ifError(err); };
@ -66,7 +66,7 @@ assert.imageIsSimilarToFile = function(testImage, referenceImageRelativeFilePath
var referenceImage = mapnik.Image.fromBytes(fs.readFileSync(referenceImageFilePath, { encoding: null })); var referenceImage = mapnik.Image.fromBytes(fs.readFileSync(referenceImageFilePath, { encoding: null }));
assert.imagesAreSimilar(testImage, referenceImage, tolerance, function(err) { imagesAreSimilar(testImage, referenceImage, tolerance, function(err) {
if (err) { if (err) {
var testImageFilePath = randomImagePath(); var testImageFilePath = randomImagePath();
testImage.save(testImageFilePath); testImage.save(testImageFilePath);