regression test for dense setSelection bug; currently fails
authorDan Vanderkam <dan@dygraphs.com>
Tue, 26 Jul 2011 03:28:45 +0000 (23:28 -0400)
committerDan Vanderkam <dan@dygraphs.com>
Tue, 26 Jul 2011 03:28:45 +0000 (23:28 -0400)
auto_tests/misc/local.html
auto_tests/tests/selection.js [new file with mode: 0644]

index 3480130..0d10bb6 100644 (file)
@@ -26,6 +26,9 @@
   <script type="text/javascript" src="../tests/scrolling_div.js"></script>
   <script type="text/javascript" src="../tests/custom_bars.js"></script>
   <script type="text/javascript" src="../tests/css.js"></script>
+  <script type="text/javascript" src="../tests/selection.js"></script>
+
+
   <script type="text/javascript">
   var tc = null;
   function processVariables() {
diff --git a/auto_tests/tests/selection.js b/auto_tests/tests/selection.js
new file mode 100644 (file)
index 0000000..2e68c1f
--- /dev/null
@@ -0,0 +1,50 @@
+// Copyright 2011 Google Inc. All Rights Reserved.
+
+/**
+ * @fileoverview Regression test based on an optimization w/
+ * unforeseen consequences.
+ * @author danvk@google.com (Dan Vanderkam)
+ */
+
+var SelectionTestCase = TestCase("selection");
+
+SelectionTestCase.prototype.setUp = function() {
+  document.body.innerHTML = "<div id='graph'></div>";
+};
+
+SelectionTestCase.prototype.testSetGetSelection = function() {
+  var graph = document.getElementById("graph");
+  var g = new Dygraph(graph,
+    "X,Y\n" +
+    "1,1\n" +
+    "50,50\n" +
+    "100,100\n"
+  );
+
+  g.setSelection(0);
+  assertEquals(0, g.getSelection());
+  g.setSelection(1);
+  assertEquals(1, g.getSelection());
+  g.setSelection(2);
+  assertEquals(2, g.getSelection());
+};
+
+SelectionTestCase.prototype.testSetGetSelectionDense = function() {
+  var graph = document.getElementById("graph");
+  var g = new Dygraph(graph,
+    "X,Y\n" +
+    "1,1\n" +
+    "50,50\n" +
+    "50.0001,50.0001\n" +
+    "100,100\n"
+  );
+
+  g.setSelection(0);
+  assertEquals(0, g.getSelection());
+  g.setSelection(1);
+  assertEquals(1, g.getSelection());
+  g.setSelection(2);
+  assertEquals(2, g.getSelection());
+  g.setSelection(3);
+  assertEquals(3, g.getSelection());
+};