X-Git-Url: https://adrianiainlam.tk/git/?a=blobdiff_plain;ds=sidebyside;f=auto_tests%2Ftests%2Ferror_bars.js;h=e57898be27a01190d50de893059bfe256c6c49f8;hb=0b4cf8f0eefb5c3c8592843474843d57cc0494f2;hp=1ede89b46d61fbe741bd67ca5c7bbe6979ce0252;hpb=f34f95d1f2fe3adcc0bbe578368740afba513d9f;p=dygraphs.git diff --git a/auto_tests/tests/error_bars.js b/auto_tests/tests/error_bars.js index 1ede89b..e57898b 100644 --- a/auto_tests/tests/error_bars.js +++ b/auto_tests/tests/error_bars.js @@ -9,16 +9,16 @@ errorBarsTestCase.prototype.setUp = function() { document.body.innerHTML = "
"; }; -var _origFunc = Dygraph.getContext; +errorBarsTestCase._origFunc = Dygraph.getContext; errorBarsTestCase.prototype.setUp = function() { document.body.innerHTML = ""; Dygraph.getContext = function(canvas) { - return new Proxy(_origFunc(canvas)); + return new Proxy(errorBarsTestCase._origFunc(canvas)); } }; errorBarsTestCase.prototype.tearDown = function() { - Dygraph.getContext = _origFunc; + Dygraph.getContext = errorBarsTestCase._origFunc; }; errorBarsTestCase.prototype.testErrorBarsDrawn = function() { @@ -124,22 +124,8 @@ errorBarsTestCase.prototype.testErrorBarsCorrectColors = function() { // 249-299: empty (white) // TODO(danvk): test the edges of these regions. - var ctx = g.hidden_.getContext("2d"); // bypass Proxy - var imageData = ctx.getImageData(0, 0, 400, 300); - - assertEquals(400, imageData.width); - assertEquals(300, imageData.height); - - // returns an (r, g, b, alpha) tuple for the pixel. - // values are in [0, 255]. - var getPixel = function(imageData, x, y) { - var i = 4 * (x + imageData.width * y); - var d = imageData.data; - return [d[i], d[i+1], d[i+2], d[i+3]]; - }; - - assertEquals([0, 0, 255, 38], getPixel(imageData, 200, 75)); - assertEquals([0, 0, 255, 38], getPixel(imageData, 200, 125)); - assertEquals([0, 255, 0, 38], getPixel(imageData, 200, 175)); - assertEquals([0, 255, 0, 38], getPixel(imageData, 200, 225)); + assertEquals([0, 0, 255, 38], Util.samplePixel(g.hidden_, 200, 75)); + assertEquals([0, 0, 255, 38], Util.samplePixel(g.hidden_, 200, 125)); + assertEquals([0, 255, 0, 38], Util.samplePixel(g.hidden_, 200, 175)); + assertEquals([0, 255, 0, 38], Util.samplePixel(g.hidden_, 200, 225)); }