Bug fix for horizontal scrolling on hidpi devices
[dygraphs.git] / auto_tests / tests / hidpi.js
1 /**
2 * @fileoverview Tests for window.devicePixelRatio > 1.
3 *
4 * @author danvdk@gmail.com (Dan Vanderkam)
5 */
6 var hidpiTestCase = TestCase("hidpi");
7
8 var savePixelRatio;
9 hidpiTestCase.prototype.setUp = function() {
10 savePixelRatio = window.devicePixelRatio;
11 window.devicePixelRatio = 2;
12
13 document.body.innerHTML = "<div id='graph'></div>";
14 };
15
16 hidpiTestCase.prototype.tearDown = function() {
17 window.devicePixelRatio = savePixelRatio;
18 };
19
20 hidpiTestCase.prototype.testNameGoesHere = function() {
21 var graph = document.getElementById("graph");
22 graph.style.width = "70%"; // more than half.
23 graph.style.height = "200px";
24
25 var opts = {};
26 var data = "X,Y\n" +
27 "0,-1\n" +
28 "1,0\n" +
29 "2,1\n" +
30 "3,0\n"
31 ;
32
33 var g = new Dygraph(graph, data, opts);
34
35 // See http://stackoverflow.com/a/2146905/388951
36 var hasHorizontalScrollbar = (document.body.scrollWidth > document.body.clientWidth);
37 assertEquals(false, hasHorizontalScrollbar);
38 };
39