From: Robert Konigsberg Date: Sat, 2 Feb 2013 17:21:37 +0000 (-0800) Subject: Add new test to verify that highlightCallback still works after graph resize. X-Git-Tag: v1.0.0~104^2 X-Git-Url: https://adrianiainlam.tk/git/?a=commitdiff_plain;h=24f7710ba142479e082ac909f84283c0ad8261ce;hp=-c;p=dygraphs.git Add new test to verify that highlightCallback still works after graph resize. --- 24f7710ba142479e082ac909f84283c0ad8261ce diff --git a/auto_tests/misc/local.html b/auto_tests/misc/local.html index 9ef2aa2..ea529fe 100644 --- a/auto_tests/misc/local.html +++ b/auto_tests/misc/local.html @@ -52,6 +52,7 @@ --> + diff --git a/auto_tests/tests/resize.js b/auto_tests/tests/resize.js new file mode 100644 index 0000000..d9dbbfc --- /dev/null +++ b/auto_tests/tests/resize.js @@ -0,0 +1,54 @@ +/** + * @fileoverview Test cases for resizing. + * + * @author konigsberg@google.com (Robert Konigsberg) + */ +var ResizeTestCase = TestCase("resize"); + +ResizeTestCase.prototype.setUp = function() { + document.body.innerHTML = "
"; +}; + +ResizeTestCase.prototype.tearDown = function() { +}; + +ResizeTestCase.prototype.testResizeMaintainsMouseOperations = function() { + document.body.innerHTML = + '
' + + ''; + var graph = document.getElementById("graph"); + + var callbackCount = 0; + var callback = function() { + callbackCount++; + } + + // Strum the mouse along the y-coordinate y, from 0 to x2. These are DOM values. + var strum = function(g, y, x2) { + DygraphOps.dispatchMouseDown_Point(g, 0, y); + for (var x = 0; x < x2; x++) { + DygraphOps.dispatchMouseMove_Point(g, x, y); + } + DygraphOps.dispatchMouseUp_Point(g, x2 - 1, y); + } + + g = new Dygraph(graph, + "Date,Y\n" + + "2010/01/01,100\n" + + "2010/02/01,200\n" + + "2010/03/01,300\n" + + "2010/04/01,400\n" + + "2010/05/01,300\n" + + "2010/06/01,100\n", + { highlightCallback : callback }); + + strum(g, 300, 640); + assertEquals(6, callbackCount); + + document.getElementById("graph").style.width = "500px"; + g.resize(); + + callbackCount = 0; + strum(g, 300, 500); + assertEquals(6, callbackCount); +};