+
+/**
+ * Tests that a graph created in a not-displayed div works as expected
+ * if the graph options include height and width. Resize not needed.
+ */
+ResizeTestCase.prototype.testHiddenDivWithSizedGraph = function() {
+ var div = document.getElementById("graph");
+
+ div.style.display = 'none';
+ var g = new Dygraph(div, ResizeTestCase.data, {width: 400, height: 300});
+ div.style.display = '';
+
+ var area = g.getArea();
+ assertTrue(area.w > 0);
+ assertTrue(area.h > 0);
+};
+
+/**
+ * Tests that a graph created in a not-displayed div with
+ * CSS-specified size but no graph height or width options works as
+ * expected. The user needs to call resize() on it after displaying
+ * it.
+ */
+ResizeTestCase.prototype.testHiddenDivWithResize = function() {
+ var div = document.getElementById("graph");
+
+ div.style.display = 'none';
+ div.style.width = '400px';
+ div.style.height = '300px';
+
+ // Setting strokeWidth 3 removes any ambiguitiy from the pixel sampling
+ // request, below.
+ var g = new Dygraph(div, ResizeTestCase.data, {strokeWidth: 3});
+ div.style.display = '';
+
+ g.resize();
+ area = g.getArea();
+ assertTrue(area.w > 0);
+ assertTrue(area.h > 0);
+
+ // Regression test: check that graph remains visible after no-op resize.
+ g.resize();
+ var x = Math.floor(g.toDomXCoord(2));
+ var y = Math.floor(g.toDomYCoord(200));
+ assertEquals("Unexpected grid color found at pixel: x: " + x + " y: " + y,
+ [0, 128, 128, 255], Util.samplePixel(g.hidden_, x, y));
+};