mirror of
https://github.com/openseadragon/openseadragon.git
synced 2024-11-29 00:26:10 +03:00
Use propEqual to verify Point values, add a stub test for imageToWindowCoordinates
This commit is contained in:
parent
e8d4c00c5f
commit
13045e2ac4
@ -46,19 +46,59 @@
|
|||||||
viewer.addHandler('open', openHandler);
|
viewer.addHandler('open', openHandler);
|
||||||
viewer.open('/test/data/testpattern.dzi');
|
viewer.open('/test/data/testpattern.dzi');
|
||||||
});
|
});
|
||||||
*/ asyncTest('WindowToWViewportCoordinates', function() {
|
*/
|
||||||
|
/* asyncTest('windowToImageCoordinates', function() {
|
||||||
var openHandler = function(event) {
|
var openHandler = function(event) {
|
||||||
viewer.removeHandler('open', openHandler);
|
viewer.removeHandler('open', openHandler);
|
||||||
var viewport = viewer.viewport;
|
var viewport = viewer.viewport;
|
||||||
|
|
||||||
var orig_x = getRandom(500, 10000);
|
// do stuff here
|
||||||
var orig_y = getRandom(500, 10000);
|
var orig = ;
|
||||||
|
var expected = ;
|
||||||
|
var actual = ;
|
||||||
|
equal(expected, actual, "what are you testing");
|
||||||
|
|
||||||
|
start();
|
||||||
|
};
|
||||||
|
viewer.addHandler('open', openHandler);
|
||||||
|
viewer.open('/test/data/testpattern.dzi');
|
||||||
|
});*/
|
||||||
|
|
||||||
|
/* Need imagetoViewerElementCoordinates first to figure out this one
|
||||||
|
asyncTest('imageToWindowCoordinates', function() {
|
||||||
|
var openHandler = function(event) {
|
||||||
|
viewer.removeHandler('open', openHandler);
|
||||||
|
var viewport = viewer.viewport;
|
||||||
|
|
||||||
|
// test image is 1000 x 1000
|
||||||
|
var orig = new OpenSeadragon.Point(
|
||||||
|
getRandom(0, 1000), getRandom(0, 1000)
|
||||||
|
);
|
||||||
|
var expected = orig.plus( new OpenSeadragon.Point(20, 20) );
|
||||||
|
console.log(expected);
|
||||||
|
var actual = viewport.imageToWindowCoordinates(orig);
|
||||||
|
console.log(actual);
|
||||||
|
ok(actual.equals(expected), "Coordinates converted correctly for " + orig);
|
||||||
|
|
||||||
|
start();
|
||||||
|
};
|
||||||
|
viewer.addHandler('open', openHandler);
|
||||||
|
viewer.open('/test/data/testpattern.dzi');
|
||||||
|
});*/
|
||||||
|
|
||||||
|
asyncTest('WindowToViewportCoordinates', function() {
|
||||||
|
var openHandler = function(event) {
|
||||||
|
viewer.removeHandler('open', openHandler);
|
||||||
|
var viewport = viewer.viewport;
|
||||||
|
|
||||||
|
var orig_x = getRandom(100, 3000);
|
||||||
|
var orig_y = getRandom(100, 3000);
|
||||||
var orig = new OpenSeadragon.Point(orig_x, orig_y);
|
var orig = new OpenSeadragon.Point(orig_x, orig_y);
|
||||||
|
|
||||||
// 500 is the viewport container size; there's 20 px of padding (I think)
|
// 500 is the viewport container size; there's 20 px of padding (I think)
|
||||||
var expected = orig.divide(500).plus( new OpenSeadragon.Point(20, 20) );
|
var expected = orig.divide(500).plus( new OpenSeadragon.Point(20, 20) );
|
||||||
var actual = viewport.windowToViewportCoordinates(orig);
|
var actual = viewport.windowToViewportCoordinates(orig);
|
||||||
ok(actual.equals(expected), "Coordinates converted correctly for " + orig);
|
propEqual(actual, expected, "Coordinates converted correctly for " + orig);
|
||||||
|
|
||||||
start();
|
start();
|
||||||
};
|
};
|
||||||
@ -78,7 +118,7 @@
|
|||||||
// 500 is the viewport container size; there's 20 px of padding (I think)
|
// 500 is the viewport container size; there's 20 px of padding (I think)
|
||||||
var expected = orig.minus( new OpenSeadragon.Point(20, 20) ).times(500);
|
var expected = orig.minus( new OpenSeadragon.Point(20, 20) ).times(500);
|
||||||
var actual = viewport.viewportToWindowCoordinates(orig);
|
var actual = viewport.viewportToWindowCoordinates(orig);
|
||||||
ok(actual.equals(expected), "Coordinates converted correctly for " + orig);
|
propEqual(actual, expected, "Coordinates converted correctly for " + orig);
|
||||||
|
|
||||||
start();
|
start();
|
||||||
};
|
};
|
||||||
@ -92,9 +132,10 @@
|
|||||||
var viewport = viewer.viewport;
|
var viewport = viewer.viewport;
|
||||||
|
|
||||||
var orig = getRandom(0, 4);
|
var orig = getRandom(0, 4);
|
||||||
var expected = orig / 2; // because the container is 500 x 500
|
// because the container is 500 x 500 and the image is 1000 x 1000
|
||||||
|
var expected = orig / 2;
|
||||||
var actual = viewport.viewportToImageZoom(orig);
|
var actual = viewport.viewportToImageZoom(orig);
|
||||||
equal(expected, actual, "Expected " + expected + ", got " + actual);
|
equal(expected, actual, "Coordinates converted correctly for " + orig);
|
||||||
start();
|
start();
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -108,9 +149,10 @@
|
|||||||
var viewport = viewer.viewport;
|
var viewport = viewer.viewport;
|
||||||
|
|
||||||
var orig = getRandom(0, 4);
|
var orig = getRandom(0, 4);
|
||||||
var expected = orig * 2; // because the container is 500 x 500
|
// because the container is 500 x 500 and the image is 1000 x 1000
|
||||||
|
var expected = orig * 2;
|
||||||
var actual = viewport.imageToViewportZoom(orig);
|
var actual = viewport.imageToViewportZoom(orig);
|
||||||
equal(expected, actual, "Expected " + expected + ", got " + actual);
|
equal(expected, actual, "Coordinates converted correctly for " + orig);
|
||||||
start();
|
start();
|
||||||
};
|
};
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user