mirror of
https://github.com/openseadragon/openseadragon.git
synced 2025-01-19 17:21:50 +03:00
Fix viewport.fitBounds tests.
This commit is contained in:
parent
66ffa03132
commit
3106d8f85b
@ -405,26 +405,7 @@
|
|||||||
viewer.open(DZI_PATH);
|
viewer.open(DZI_PATH);
|
||||||
});
|
});
|
||||||
|
|
||||||
asyncTest('fitBounds', function(){
|
// Fit bounds tests
|
||||||
var openHandler = function(event) {
|
|
||||||
viewer.removeHandler('open', openHandler);
|
|
||||||
var viewport = viewer.viewport;
|
|
||||||
|
|
||||||
for(var i = 0; i < testRects.length; i++){
|
|
||||||
var rect = testRects[i].times(viewport.getContainerSize());
|
|
||||||
viewport.fitBounds(rect, true);
|
|
||||||
propEqual(
|
|
||||||
viewport.getBounds(),
|
|
||||||
rect,
|
|
||||||
"Fit bounds correctly."
|
|
||||||
);
|
|
||||||
}
|
|
||||||
start();
|
|
||||||
};
|
|
||||||
viewer.addHandler('open', openHandler);
|
|
||||||
viewer.open(DZI_PATH);
|
|
||||||
});
|
|
||||||
|
|
||||||
var testRectsFitBounds = [
|
var testRectsFitBounds = [
|
||||||
new OpenSeadragon.Rect(0, -0.75, 0.5, 1),
|
new OpenSeadragon.Rect(0, -0.75, 0.5, 1),
|
||||||
new OpenSeadragon.Rect(0.5, 0, 0.5, 0.8),
|
new OpenSeadragon.Rect(0.5, 0, 0.5, 0.8),
|
||||||
@ -433,12 +414,39 @@
|
|||||||
];
|
];
|
||||||
|
|
||||||
var expectedRectsFitBounds = [
|
var expectedRectsFitBounds = [
|
||||||
|
new OpenSeadragon.Rect(-0.25, -0.75, 1, 1),
|
||||||
|
new OpenSeadragon.Rect(0.35, 0, 0.8, 0.8),
|
||||||
|
new OpenSeadragon.Rect(0.75, 0.75, 0.5, 0.5),
|
||||||
|
new OpenSeadragon.Rect(-0.3, -0.3, 0.5, 0.5)
|
||||||
|
];
|
||||||
|
|
||||||
|
var expectedRectsFitBoundsWithConstraints = [
|
||||||
new OpenSeadragon.Rect(-0.25, -0.5, 1, 1),
|
new OpenSeadragon.Rect(-0.25, -0.5, 1, 1),
|
||||||
new OpenSeadragon.Rect(0.35, 0, 0.8, 0.8),
|
new OpenSeadragon.Rect(0.35, 0, 0.8, 0.8),
|
||||||
new OpenSeadragon.Rect(0.75, 0.75, 0.5, 0.5),
|
new OpenSeadragon.Rect(0.75, 0.75, 0.5, 0.5),
|
||||||
new OpenSeadragon.Rect(-0.25, -0.25, 0.5, 0.5)
|
new OpenSeadragon.Rect(-0.25, -0.25, 0.5, 0.5)
|
||||||
];
|
];
|
||||||
|
|
||||||
|
asyncTest('fitBounds', function(){
|
||||||
|
var openHandler = function(event) {
|
||||||
|
viewer.removeHandler('open', openHandler);
|
||||||
|
var viewport = viewer.viewport;
|
||||||
|
|
||||||
|
for(var i = 0; i < testRectsFitBounds.length; i++){
|
||||||
|
var rect = testRectsFitBounds[i];
|
||||||
|
viewport.fitBounds(rect, true);
|
||||||
|
propEqual(
|
||||||
|
viewport.getBounds(),
|
||||||
|
expectedRectsFitBounds[i],
|
||||||
|
"Fit bounds correctly."
|
||||||
|
);
|
||||||
|
}
|
||||||
|
start();
|
||||||
|
};
|
||||||
|
viewer.addHandler('open', openHandler);
|
||||||
|
viewer.open(DZI_PATH);
|
||||||
|
});
|
||||||
|
|
||||||
asyncTest('fitBoundsWithConstraints', function(){
|
asyncTest('fitBoundsWithConstraints', function(){
|
||||||
var openHandler = function(event) {
|
var openHandler = function(event) {
|
||||||
viewer.removeHandler('open', openHandler);
|
viewer.removeHandler('open', openHandler);
|
||||||
@ -450,7 +458,7 @@
|
|||||||
viewport.fitBoundsWithConstraints(rect, true);
|
viewport.fitBoundsWithConstraints(rect, true);
|
||||||
propEqual(
|
propEqual(
|
||||||
viewport.getBounds(),
|
viewport.getBounds(),
|
||||||
expectedRectsFitBounds[i],
|
expectedRectsFitBoundsWithConstraints[i],
|
||||||
"Fit bounds correctly."
|
"Fit bounds correctly."
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
@ -491,6 +499,7 @@
|
|||||||
viewer.addHandler('open', openHandler);
|
viewer.addHandler('open', openHandler);
|
||||||
viewer.open(WIDE_PATH);
|
viewer.open(WIDE_PATH);
|
||||||
});
|
});
|
||||||
|
// End fitBounds tests.
|
||||||
|
|
||||||
asyncTest('panBy', function(){
|
asyncTest('panBy', function(){
|
||||||
var openHandler = function(event) {
|
var openHandler = function(event) {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user