From 13045e2ac44cd06e6ca673d4f797d7fae3ffc1b8 Mon Sep 17 00:00:00 2001 From: nein09 Date: Wed, 15 Oct 2014 11:45:19 -0700 Subject: [PATCH] Use propEqual to verify Point values, add a stub test for imageToWindowCoordinates --- test/viewport.js | 60 ++++++++++++++++++++++++++++++++++++++++-------- 1 file changed, 51 insertions(+), 9 deletions(-) diff --git a/test/viewport.js b/test/viewport.js index d9788b3c..c5ef7612 100644 --- a/test/viewport.js +++ b/test/viewport.js @@ -46,19 +46,59 @@ viewer.addHandler('open', openHandler); viewer.open('/test/data/testpattern.dzi'); }); -*/ asyncTest('WindowToWViewportCoordinates', function() { +*/ +/* asyncTest('windowToImageCoordinates', function() { var openHandler = function(event) { viewer.removeHandler('open', openHandler); var viewport = viewer.viewport; - var orig_x = getRandom(500, 10000); - var orig_y = getRandom(500, 10000); + // do stuff here + 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); // 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 actual = viewport.windowToViewportCoordinates(orig); - ok(actual.equals(expected), "Coordinates converted correctly for " + orig); + propEqual(actual, expected, "Coordinates converted correctly for " + orig); start(); }; @@ -78,7 +118,7 @@ // 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 actual = viewport.viewportToWindowCoordinates(orig); - ok(actual.equals(expected), "Coordinates converted correctly for " + orig); + propEqual(actual, expected, "Coordinates converted correctly for " + orig); start(); }; @@ -92,9 +132,10 @@ var viewport = viewer.viewport; 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); - equal(expected, actual, "Expected " + expected + ", got " + actual); + equal(expected, actual, "Coordinates converted correctly for " + orig); start(); }; @@ -108,9 +149,10 @@ var viewport = viewer.viewport; 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); - equal(expected, actual, "Expected " + expected + ", got " + actual); + equal(expected, actual, "Coordinates converted correctly for " + orig); start(); };