Adds some more tests and tries to solve some code bugs.

A new variance parameter was added to assertPointsEquals function.

Variance value was set on loopingTestHelper function (1e-15).

The following tests were modified to execute tests on flipped viewport:
* 'panBy'
* 'panTo'
* 'zoomBy with ref point'
This commit is contained in:
Nelson Campos 2018-06-06 17:03:40 +01:00
parent a31587df2f
commit 3615ad412f

View File

@ -118,6 +118,7 @@
assert, assert,
actual, actual,
expected, expected,
1e-15,
"Correctly converted coordinates " + orig "Correctly converted coordinates " + orig
); );
} else { } else {
@ -136,8 +137,8 @@
viewer.open(DZI_PATH); viewer.open(DZI_PATH);
}; };
function assertPointsEquals(assert, actual, expected, message) { function assertPointsEquals(assert, actual, expected, variance, message) {
Util.assertPointsEquals(assert, actual, expected, 1e-15, message); Util.assertPointsEquals(assert, actual, expected, variance, message);
} }
// Tests start here. // Tests start here.
@ -736,6 +737,19 @@
); );
} }
viewport = viewer.viewport; // Get viewport original state
viewport.setFlip(true);
for (var i = 0; i < testPoints.length; i++){
var expected = viewport.getCenter().plus(testPoints[i]);
viewport.panBy(testPoints[i], true);
assert.propEqual(
viewport.getCenter(),
expected,
"Panned flipped by the correct amount."
);
}
done(); done();
}; };
viewer.addHandler('open', openHandler); viewer.addHandler('open', openHandler);
@ -757,6 +771,18 @@
); );
} }
viewport = viewer.viewport; // Get viewport original state
viewport.setFlip(true);
for (var i = 0; i < testPoints.length; i++){
viewport.panTo(testPoints[i], true);
assert.propEqual(
viewport.getCenter(),
testPoints[i],
"Panned flipped to the correct location."
);
}
done(); done();
}; };
viewer.addHandler('open', openHandler); viewer.addHandler('open', openHandler);
@ -815,6 +841,34 @@
); );
} }
viewport = viewer.viewport; // Get viewport original state
viewport.setFlip(true);
var expectedFlippedCenters = [
new OpenSeadragon.Point(12.121, 11.871),
new OpenSeadragon.Point(14.117, 13.867),
new OpenSeadragon.Point(14.367, 13.867),
new OpenSeadragon.Point(14.367, 13.867),
new OpenSeadragon.Point(14.742, 14.242),
new OpenSeadragon.Point(14.742, 14.242),
];
for (var i = 0; i < testZoomLevels.length; i++) {
viewport.zoomBy(testZoomLevels[i], testPoints[i], true);
assert.propEqual(
testZoomLevels[i],
viewport.getZoom(),
"Zoomed flipped by the correct amount."
);
assertPointsEquals(
assert,
expectedFlippedCenters[i],
viewport.getCenter(),
1e-6,
"Panned flipped to the correct location."
);
}
done(); done();
}; };
viewer.addHandler('open', openHandler); viewer.addHandler('open', openHandler);
@ -1179,4 +1233,5 @@
viewer.addHandler('open', openHandler); viewer.addHandler('open', openHandler);
viewer.open(DZI_PATH); viewer.open(DZI_PATH);
}); });
})(); })();