X-Git-Url: https://adrianiainlam.tk/git/?a=blobdiff_plain;f=auto_tests%2Ftests%2Fsimple_drawing.js;h=dde41b8647752c234bf759a540080729d6ec890d;hb=c715be428d83d80c0a26fd60dc5bc36fb4c908d9;hp=a4acd2830cf619ea452ebc220b10d40a922380a7;hpb=3bdeeb9b9d123e9e45159a6801b6e7fe74f08690;p=dygraphs.git diff --git a/auto_tests/tests/simple_drawing.js b/auto_tests/tests/simple_drawing.js index a4acd28..dde41b8 100644 --- a/auto_tests/tests/simple_drawing.js +++ b/auto_tests/tests/simple_drawing.js @@ -27,16 +27,16 @@ var ZERO_TO_FIFTY = [[ 10, 0 ] , [ 20, 50 ]]; var SimpleDrawingTestCase = TestCase("simple-drawing"); -var _origFunc = Dygraph.getContext; +SimpleDrawingTestCase._origFunc = Dygraph.getContext; SimpleDrawingTestCase.prototype.setUp = function() { document.body.innerHTML = "
"; Dygraph.getContext = function(canvas) { - return new Proxy(_origFunc(canvas)); + return new Proxy(SimpleDrawingTestCase._origFunc(canvas)); } }; SimpleDrawingTestCase.prototype.tearDown = function() { - Dygraph.getContext = _origFunc; + Dygraph.getContext = SimpleDrawingTestCase._origFunc; }; SimpleDrawingTestCase.prototype.testDrawSimpleRangePlusOne = function() { @@ -55,6 +55,7 @@ SimpleDrawingTestCase.prototype.testDrawSimpleRangePlusOne = function() { strokeStyle: "#008080", lineWidth: 1 }); + g.destroy(); // to balance context saves and destroys. CanvasAssertions.assertBalancedSaveRestore(htx); }; @@ -76,6 +77,7 @@ SimpleDrawingTestCase.prototype.testDrawSimpleRangeZeroToFifty = function() { lineWidth: 1 }); assertEquals(1, lines.length); + g.destroy(); // to balance context saves and destroys. CanvasAssertions.assertBalancedSaveRestore(htx); }; @@ -84,6 +86,7 @@ SimpleDrawingTestCase.prototype.testDrawWithAxis = function() { var g = new Dygraph(graph, ZERO_TO_FIFTY); var htx = g.hidden_ctx_; + g.destroy(); // to balance context saves and destroys. CanvasAssertions.assertBalancedSaveRestore(htx); }; @@ -93,12 +96,20 @@ SimpleDrawingTestCase.prototype.testDrawWithAxis = function() { */ SimpleDrawingTestCase.prototype.testDrawSimpleDash = function() { var opts = { - drawXGrid: false, - drawYGrid: false, - drawXAxis: false, - drawYAxis: false, + axes: { + x: { + drawGrid: false, + drawAxis: false + }, + y: { + drawGrid: false, + drawAxis: false + } + }, + series: { 'Y1': {strokePattern: [25, 7, 7, 7]}, - colors: ['#ff0000'] + }, + colors: ['#ff0000'] }; var graph = document.getElementById("graph"); @@ -110,6 +121,7 @@ SimpleDrawingTestCase.prototype.testDrawSimpleDash = function() { // TODO(danvk): figure out a good way to restore this test. // assertEquals(29, CanvasAssertions.numLinesDrawn(htx, "#ff0000")); + g.destroy(); // to balance context saves and destroys. CanvasAssertions.assertBalancedSaveRestore(htx); }; @@ -146,5 +158,6 @@ SimpleDrawingTestCase.prototype.testDrawThickLine = function() { // TODO(danvk): figure out a good way to restore this test. // assertEquals(29, CanvasAssertions.numLinesDrawn(htx, "#ff0000")); + g.destroy(); // to balance context saves and destroys. CanvasAssertions.assertBalancedSaveRestore(htx); };