Updated tests for #524

This commit is contained in:
Ian Gilman 2015-10-29 13:31:33 -07:00
parent fb8e19b50d
commit 4e168d734e

View File

@ -98,7 +98,6 @@
viewer.removeHandler('open', openHandler); viewer.removeHandler('open', openHandler);
var viewport = viewer.viewport; var viewport = viewer.viewport;
viewport.zoomTo(ZOOM_FACTOR, null, true); viewport.zoomTo(ZOOM_FACTOR, null, true);
viewport.update(); // need to call this even with immediately=true
var orig, expected, actual; var orig, expected, actual;
for (var i = 0; i < config.testArray.length; i++){ for (var i = 0; i < config.testArray.length; i++){
@ -125,7 +124,6 @@
viewer.removeHandler('open', openHandler); viewer.removeHandler('open', openHandler);
var viewport = viewer.viewport; var viewport = viewer.viewport;
viewport.zoomTo(ZOOM_FACTOR, null, true); viewport.zoomTo(ZOOM_FACTOR, null, true);
viewport.update(); // need to call this even with immediately=true
propEqual(viewport.getContainerSize(), new OpenSeadragon.Point(500, 500), "Test container size"); propEqual(viewport.getContainerSize(), new OpenSeadragon.Point(500, 500), "Test container size");
start(); start();
@ -139,7 +137,6 @@
viewer.removeHandler('open', openHandler); viewer.removeHandler('open', openHandler);
var viewport = viewer.viewport; var viewport = viewer.viewport;
viewport.zoomTo(ZOOM_FACTOR, null, true); viewport.zoomTo(ZOOM_FACTOR, null, true);
viewport.update(); // need to call this even with immediately=true
equal(viewport.getAspectRatio(), 1, "Test aspect ratio"); equal(viewport.getAspectRatio(), 1, "Test aspect ratio");
start(); start();
@ -243,7 +240,6 @@
viewer.removeHandler('open', openHandler); viewer.removeHandler('open', openHandler);
var viewport = viewer.viewport; var viewport = viewer.viewport;
viewport.zoomTo(ZOOM_FACTOR, null, true); viewport.zoomTo(ZOOM_FACTOR, null, true);
viewport.update(); // need to call this even with immediately=true
// Special cases for oddball levels // Special cases for oddball levels
if (level === -1) { if (level === -1) {
@ -288,7 +284,6 @@
for(var i = 0; i < testRects.length; i++){ for(var i = 0; i < testRects.length; i++){
var rect = testRects[i].times(viewport.getContainerSize()); var rect = testRects[i].times(viewport.getContainerSize());
viewport.resetContentSize(rect.getSize()); viewport.resetContentSize(rect.getSize());
viewport.update();
propEqual( propEqual(
viewport.contentSize, viewport.contentSize,
rect.getSize(), rect.getSize(),
@ -308,10 +303,8 @@
// zoom/pan somewhere // zoom/pan somewhere
viewport.zoomTo(ZOOM_FACTOR, true); viewport.zoomTo(ZOOM_FACTOR, true);
viewport.update();
viewport.goHome(true); viewport.goHome(true);
viewport.update();
propEqual( propEqual(
viewport.getBounds(), viewport.getBounds(),
viewport.getHomeBounds(), viewport.getHomeBounds(),
@ -331,10 +324,8 @@
// zoom/pan so that the image is out of view // zoom/pan so that the image is out of view
viewport.zoomTo(ZOOM_FACTOR * -50, true); viewport.zoomTo(ZOOM_FACTOR * -50, true);
viewport.panBy(new OpenSeadragon.Point(5000, 5000), null, true); viewport.panBy(new OpenSeadragon.Point(5000, 5000), null, true);
viewport.update();
viewport.ensureVisible(true); viewport.ensureVisible(true);
viewport.update();
var bounds = viewport.getBounds(); var bounds = viewport.getBounds();
ok(bounds.getSize().x > 1 && bounds.getSize().y > 1, "Moved viewport so that image is visible."); ok(bounds.getSize().x > 1 && bounds.getSize().y > 1, "Moved viewport so that image is visible.");
start(); start();
@ -351,7 +342,6 @@
for(var i = 0; i < testRects.length; i++){ for(var i = 0; i < testRects.length; i++){
var rect = testRects[i].times(viewport.getContainerSize()); var rect = testRects[i].times(viewport.getContainerSize());
viewport.fitBounds(rect, true); viewport.fitBounds(rect, true);
viewport.update();
propEqual( propEqual(
viewport.getBounds(), viewport.getBounds(),
rect, rect,
@ -383,12 +373,10 @@
viewer.removeHandler('open', openHandler); viewer.removeHandler('open', openHandler);
var viewport = viewer.viewport; var viewport = viewer.viewport;
viewport.zoomTo(ZOOM_FACTOR, null, true); viewport.zoomTo(ZOOM_FACTOR, null, true);
viewport.update();
for(var i = 0; i < testRectsFitBounds.length; i++){ for(var i = 0; i < testRectsFitBounds.length; i++){
var rect = testRectsFitBounds[i]; var rect = testRectsFitBounds[i];
viewport.fitBoundsWithConstraints(rect, true); viewport.fitBoundsWithConstraints(rect, true);
viewport.update();
propEqual( propEqual(
viewport.getBounds(), viewport.getBounds(),
expectedRectsFitBounds[i], expectedRectsFitBounds[i],
@ -406,7 +394,6 @@
viewer.removeHandler('open', openHandler); viewer.removeHandler('open', openHandler);
var viewport = viewer.viewport; var viewport = viewer.viewport;
viewport.fitHorizontally(true); viewport.fitHorizontally(true);
viewport.update();
propEqual( propEqual(
viewport.getBounds(), viewport.getBounds(),
new OpenSeadragon.Rect(0, 1.5, 1, 1), new OpenSeadragon.Rect(0, 1.5, 1, 1),
@ -423,7 +410,6 @@
viewer.removeHandler('open', openHandler); viewer.removeHandler('open', openHandler);
var viewport = viewer.viewport; var viewport = viewer.viewport;
viewport.fitVertically(true); viewport.fitVertically(true);
viewport.update();
propEqual( propEqual(
viewport.getBounds(), viewport.getBounds(),
new OpenSeadragon.Rect(0.375, 0, 0.25, 0.25), new OpenSeadragon.Rect(0.375, 0, 0.25, 0.25),
@ -443,7 +429,6 @@
for (var i = 0; i < testPoints.length; i++){ for (var i = 0; i < testPoints.length; i++){
var expected = viewport.getCenter().plus(testPoints[i]); var expected = viewport.getCenter().plus(testPoints[i]);
viewport.panBy(testPoints[i], true); viewport.panBy(testPoints[i], true);
viewport.update(); // need to call this even with immediately=true
propEqual( propEqual(
viewport.getCenter(), viewport.getCenter(),
expected, expected,
@ -464,7 +449,6 @@
for (var i = 0; i < testPoints.length; i++){ for (var i = 0; i < testPoints.length; i++){
viewport.panTo(testPoints[i], true); viewport.panTo(testPoints[i], true);
viewport.update(); // need to call this even with immediately=true
propEqual( propEqual(
viewport.getCenter(), viewport.getCenter(),
testPoints[i], testPoints[i],
@ -485,7 +469,6 @@
for (var i = 0; i < testZoomLevels.length; i++){ for (var i = 0; i < testZoomLevels.length; i++){
viewport.zoomBy(testZoomLevels[i], null, true); viewport.zoomBy(testZoomLevels[i], null, true);
viewport.update(); // need to call this even with immediately=true
propEqual( propEqual(
viewport.getZoom(), viewport.getZoom(),
testZoomLevels[i], testZoomLevels[i],
@ -495,7 +478,6 @@
// now use a ref point // now use a ref point
// TODO: check the ending position due to ref point // TODO: check the ending position due to ref point
viewport.zoomBy(testZoomLevels[i], testPoints[i], true); viewport.zoomBy(testZoomLevels[i], testPoints[i], true);
viewport.update();
propEqual( propEqual(
viewport.getZoom(), viewport.getZoom(),
testZoomLevels[i], testZoomLevels[i],
@ -516,7 +498,6 @@
for (var i = 0; i < testZoomLevels.length; i++){ for (var i = 0; i < testZoomLevels.length; i++){
viewport.zoomTo(testZoomLevels[i], null, true); viewport.zoomTo(testZoomLevels[i], null, true);
viewport.update(); // need to call this even with immediately=true
propEqual( propEqual(
viewport.getZoom(), viewport.getZoom(),
testZoomLevels[i], testZoomLevels[i],
@ -526,7 +507,6 @@
// now use a ref point // now use a ref point
// TODO: check the ending position due to ref point // TODO: check the ending position due to ref point
viewport.zoomTo(testZoomLevels[i], testPoints[i], true); viewport.zoomTo(testZoomLevels[i], testPoints[i], true);
viewport.update(); // need to call this even with immediately=true
propEqual( propEqual(
viewport.getZoom(), viewport.getZoom(),
testZoomLevels[i], testZoomLevels[i],
@ -565,7 +545,6 @@
for(var i = 0; i < testPoints.length; i++){ for(var i = 0; i < testPoints.length; i++){
var new_size = testPoints[i].times(viewer.source.dimensions.x); var new_size = testPoints[i].times(viewer.source.dimensions.x);
viewport.resize(new_size); viewport.resize(new_size);
viewport.update();
propEqual(viewport.getContainerSize(), new_size, "Viewport resized successfully."); propEqual(viewport.getContainerSize(), new_size, "Viewport resized successfully.");
} }
start(); start();