X-Git-Url: https://adrianiainlam.tk/git/?a=blobdiff_plain;f=auto_tests%2Ftests%2Fgrid_per_axis.js;h=3173cf3d617736ee6a705616d84d81a33fd1bed9;hb=319d0361d2e512ed8049dfedffd79254e491201c;hp=3dd2a89e6268dbb55f7636f0d111e8bb7674f67d;hpb=86b5007bd4e11a9c57280ecbbbb70391cde7735f;p=dygraphs.git diff --git a/auto_tests/tests/grid_per_axis.js b/auto_tests/tests/grid_per_axis.js index 3dd2a89..3173cf3 100644 --- a/auto_tests/tests/grid_per_axis.js +++ b/auto_tests/tests/grid_per_axis.js @@ -10,17 +10,17 @@ GridPerAxisTestCase.prototype.setUp = function() { document.body.innerHTML = "
"; }; -GridPerAxisTestCase.origFunc = Dygraph.getContext; +var origFunc = Dygraph.getContext; GridPerAxisTestCase.prototype.setUp = function() { document.body.innerHTML = "
"; Dygraph.getContext = function(canvas) { - return new Proxy(GridPerAxisTestCase.origFunc(canvas)); + return new Proxy(origFunc(canvas)); }; }; GridPerAxisTestCase.prototype.tearDown = function() { - Dygraph.getContext = GridPerAxisTestCase.origFunc; + Dygraph.getContext = origFunc; }; GridPerAxisTestCase.prototype.testIndependentGrids = function() { @@ -198,6 +198,8 @@ GridPerAxisTestCase.prototype.testPerAxisGridWidth = function() { for ( var i = 0; i < gridlines[axis].length; i++) { y = halfDown(g.toDomYCoord(gridlines[axis][i], axis)); // Ignore the alpha value + + // FIXME(pholden): this test fails with a context pixel ratio of 2. var drawnPixeldown2 = Util.samplePixel(g.hidden_, x, y - 2).slice(0, 3); var drawnPixeldown1 = Util.samplePixel(g.hidden_, x, y - 1).slice(0, 3); var drawnPixel = Util.samplePixel(g.hidden_, x, y).slice(0, 3); @@ -249,14 +251,12 @@ GridPerAxisTestCase.prototype.testPerAxisGridWidth = function() { emptyColor, Util.samplePixel(g.hidden_, x + 2, y).slice(0, 3)); } }; + GridPerAxisTestCase.prototype.testGridLinePattern = function() { var opts = { - width : 480, + width : 120, height : 320, errorBars : false, - drawXGrid : false, - drawXAxis : false, - drawYAxis : false, labels : [ "X", "Left", "Right" ], colors : [ "rgba(0,0,0,0)", "rgba(0,0,0,0)" ], series : { @@ -268,9 +268,14 @@ GridPerAxisTestCase.prototype.testGridLinePattern = function() { } }, axes : { + x : { + drawGrid: false, + drawAxis: false, + }, y : { + drawAxis : false, gridLineColor : "#0000ff", - gridLinePattern : [ 4, 4 ] + gridLinePattern : [ 10, 10 ] } } }; @@ -290,22 +295,25 @@ GridPerAxisTestCase.prototype.testGridLinePattern = function() { return Math.round(y) - 1; } var x, y; - x = halfUp(g.plotter_.area.x); // Step through all gridlines of the axis - for ( var i = 0; i < yGridlines.length; i++) { + for (var i = 0; i < yGridlines.length; i++) { y = halfDown(g.toDomYCoord(yGridlines[i], 0)); // Step through the pixels of the line and test the pattern. - for (x; x < g.plotter_.area.w; x++) { + for (x = halfUp(g.plotter_.area.x); x < g.plotter_.area.w; x++) { + // avoid checking the edge pixels since they differ depending on the OS. + var pixelpos = x % 10; + if(pixelpos < 1 || pixelpos > 8) continue; + // Ignore alpha var drawnPixel = Util.samplePixel(g.hidden_, x, y).slice(0,3); - var pattern = (Math.floor((x) / 4)) % 2; + var pattern = (Math.floor((x) / 10)) % 2; switch (pattern) { case 0: // fill - assertEquals("Unexpected filled grid-pattern color found at pixel: x: " + x + "y: " + assertEquals("Unexpected filled grid-pattern color found at pixel: x: " + x + " y: " + y, [ 0, 0, 255 ], drawnPixel); break; case 1: // no fill - assertEquals("Unexpected empty grid-pattern color found at pixel: x: " + x + "y: " + assertEquals("Unexpected empty grid-pattern color found at pixel: x: " + x + " y: " + y, [ 0, 0, 0 ], drawnPixel); break; }