Permalink
Browse files

Merge pull request #110 from adrianolek/match-equals-tolerance

Fix image diff corner case when misMatchPercentage equals misMatchTolerance
  • Loading branch information...
2 parents d3991df + ba0fed0 commit 2f0793a0cb9689c460bc0d378ea738cc853fa56d @christian-bromann christian-bromann committed Sep 6, 2015
Showing with 47 additions and 1 deletion.
  1. +1 −1 lib/saveImageDiff.js
  2. +1 −0 test/bootstrap.js
  3. +11 −0 test/site/four.html
  4. +34 −0 test/spec/imageComparison.js
@@ -94,7 +94,7 @@ module.exports = function(imageDiff,done) {
misMatchPercentage: misMatchTolerance,
isExactSameImage: misMatchTolerance === 0,
isSameDimensions: imageDiff.isSameDimensions,
- isWithinMisMatchTolerance: that.misMatchTolerance > misMatchTolerance
+ isWithinMisMatchTolerance: true
});
done(err);
View
@@ -13,6 +13,7 @@ capabilities = {logLevel: 'silent',desiredCapabilities:{browserName: 'phantomjs'
testurl = 'http://localhost:8080/test/site/index.html';
testurlTwo = 'http://localhost:8080/test/site/two.html';
testurlThree = 'http://localhost:8080/test/site/three.html';
+testurlFour = 'http://localhost:8080/test/site/four.html';
/**
* set some fix test variables
View
@@ -0,0 +1,11 @@
+<!DOCTYPE html>
+<html>
+<head>
+ <title>four</title>
+</head>
+<body>
+ <div id="container" style="width: 200px; height: 10px; background: white">
+ <div id="difference" style="width: 1px; height: 1px; background: red"></div>
+ </div>
+</body>
+</html>
@@ -206,6 +206,40 @@ describe('WebdriverCSS compares images and exposes information about CSS regress
});
+ describe('should match an image when match percentage is equal to tolerance', function() {
+ var resultObject = {};
+
+ before(function(done) {
+ this.browser
+ .url(testurlFour)
+ .webdrivercss('comparisonTest', {
+ elem: '#container',
+ name: 'test-equal'
+ }, function(err,res) {
+ should.not.exist(err);
+ })
+ .execute(function() {
+ document.querySelector('#difference').style.backgroundColor = 'white';
+ }, [])
+ .webdrivercss('comparisonTest', {
+ elem: '#container',
+ name: 'test-equal'
+ }, function(err,res) {
+ should.not.exist(err);
+ resultObject = res['test-equal'][0];
+ })
+ .call(done);
+ });
+
+ it('should be within tolerance', function() {
+ resultObject.misMatchPercentage.should.be.a('number');
+ resultObject.misMatchPercentage.should.equal(0.05);
+ resultObject.isExactSameImage.should.equal(false);
+ resultObject.isWithinMisMatchTolerance.should.equal(true);
+ });
+
+ });
+
after(afterHook);
});

0 comments on commit 2f0793a

Please sign in to comment.