X-Git-Url: https://adrianiainlam.tk/git/?a=blobdiff_plain;f=auto_tests%2Ftests%2Fhidpi.js;h=ceb3a49dcaaee1eb08252c8e212ad7f9f99a5f0b;hb=64f1c4dfd7425931fcd1bd9949157c0ba6958656;hp=1dd131c7b48d1fedc5da453f4d04787eafd73b98;hpb=ce31caf22475e3e1fd6d9fea192d61ff4fcd7fac;p=dygraphs.git diff --git a/auto_tests/tests/hidpi.js b/auto_tests/tests/hidpi.js index 1dd131c..ceb3a49 100644 --- a/auto_tests/tests/hidpi.js +++ b/auto_tests/tests/hidpi.js @@ -45,5 +45,36 @@ it('testDoesntCreateScrollbars', function() { assert.equal(sw, document.body.scrollWidth); }); +it('should be influenced by options.pixelRatio', function () { + var graph = document.getElementById("graph"); + + // make sure devicePixelRatio is still setup to not 1. + assert(devicePixelRatio > 1.5, 'devicePixelRatio is not much greater than 1.'); + + var data = "X,Y\n" + + "0,-1\n" + + "1,0\n" + + "2,1\n" + + "3,0\n"; + + // first try a default one + var g1 = new Dygraph(graph, data, {}); + var area1 = g1.getArea(); + + var g2 = new Dygraph(graph, data, { pixelRatio: 1 }); + var area2 = g2.getArea(); + + var g3 = new Dygraph(graph, data, { pixelRatio: 3 }); + var area3 = g3.getArea(); + + assert.deepEqual(area1, area2, 'areas 1 and 2 are not the same'); + assert.deepEqual(area2, area3, 'areas 2 and 3 are not the same'); + + assert.notEqual(g1.canvas_.width, g2.canvas_.width, + 'Expected, for devicePixelRatio != 1, ' + + 'that setting options.pixelRatio would change the canvas width'); + assert.equal(g2.canvas_.width * 3, g3.canvas_.width, + 'Expected that pixelRatio of 3 vs 1 would triple the canvas width.'); +}); });