Merge pull request #3550 from tschaub/fewer-differences

Reduce differences between the rendering test runner and the standard test runner.
This commit is contained in:
Tim Schaub
2015-04-17 10:16:00 -06:00
2 changed files with 10 additions and 17 deletions
+10 -4
View File
@@ -3,6 +3,12 @@
// helper functions for async testing and other utility functions. // helper functions for async testing and other utility functions.
(function(global) { (function(global) {
// show generated maps for rendering tests
var showMap = (global.location.search.indexOf('generate') >= 0);
// show a diff when rendering tests fail
var showDiff = (global.location.search.indexOf('showdiff') >= 0);
/** /**
* The default tolerance for image comparisons. * The default tolerance for image comparisons.
*/ */
@@ -358,8 +364,8 @@
}; };
function resembleCanvas(canvas, referenceImage, tolerance, done) { function resembleCanvas(canvas, referenceImage, tolerance, done) {
if (window.showMap) { if (showMap) {
document.getElementById('debug').appendChild(canvas); document.body.appendChild(canvas);
} }
resemble(referenceImage) resemble(referenceImage)
@@ -373,10 +379,10 @@
} }
if (data.misMatchPercentage > tolerance) { if (data.misMatchPercentage > tolerance) {
if (window.showDiff) { if (showDiff) {
var diffImage = new Image(); var diffImage = new Image();
diffImage.src = data.getImageDataUrl(); diffImage.src = data.getImageDataUrl();
document.getElementById('debug').appendChild(diffImage); document.body.appendChild(diffImage);
} }
expect(data.misMatchPercentage).to.be.below(tolerance); expect(data.misMatchPercentage).to.be.below(tolerance);
} }
-13
View File
@@ -51,18 +51,6 @@
} }
}); });
window.showDiff = false;
if (window.location.search.indexOf('showdiff') >= 0) {
// show a difference image if '?showdiff' is in the URL
window.showDiff = true;
}
window.showMap = false;
if (window.location.search.indexOf('generate') >= 0) {
// show the canvas of the test map if '?generate' is in the URL
window.showMap = true;
}
if (window.console && console.log) { if (window.console && console.log) {
// write stacks to the console for failed tests // write stacks to the console for failed tests
runner.on('fail', function(test, err) { runner.on('fail', function(test, err) {
@@ -88,6 +76,5 @@
Tests should not depend on any specific markup and should instead create Tests should not depend on any specific markup and should instead create
whatever elements are needed (cleaning up when done). whatever elements are needed (cleaning up when done).
--> -->
<div id="debug"></div>
</body> </body>
</html> </html>