From 59ee91ea1a5c2b7e261fb6ff331b79502a7e79d1 Mon Sep 17 00:00:00 2001 From: nein09 Date: Wed, 15 Oct 2014 12:22:52 -0700 Subject: [PATCH] add test for windowToImageCoordinates --- test/viewport.js | 28 +++++++++++++++------------- 1 file changed, 15 insertions(+), 13 deletions(-) diff --git a/test/viewport.js b/test/viewport.js index c5ef7612..5d822abd 100644 --- a/test/viewport.js +++ b/test/viewport.js @@ -47,22 +47,24 @@ viewer.open('/test/data/testpattern.dzi'); }); */ -/* asyncTest('windowToImageCoordinates', function() { + asyncTest('windowToImageCoordinates', function() { var openHandler = function(event) { viewer.removeHandler('open', openHandler); var viewport = viewer.viewport; - // do stuff here - var orig = ; - var expected = ; - var actual = ; - equal(expected, actual, "what are you testing"); + var orig = new OpenSeadragon.Point( + getRandom(100, 3000), getRandom(100, 3000) + ); + // 500 is the viewer 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); + propEqual(actual, expected, "Coordinates converted correctly for " + orig); start(); }; viewer.addHandler('open', openHandler); viewer.open('/test/data/testpattern.dzi'); - });*/ + }); /* Need imagetoViewerElementCoordinates first to figure out this one asyncTest('imageToWindowCoordinates', function() { @@ -91,9 +93,9 @@ 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( + getRandom(100, 3000), getRandom(100, 3000) + ); // 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) ); @@ -111,9 +113,9 @@ viewer.removeHandler('open', openHandler); var viewport = viewer.viewport; - var orig_x = getRandom(0, 1000); - var orig_y = getRandom(0, 1000); - var orig = new OpenSeadragon.Point(orig_x, orig_y); + var orig = new OpenSeadragon.Point( + getRandom(0, 1000), getRandom(0, 1000) + ); // 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);