Added code to make tests easier to repeat by specifying them as part of the URL.
authorRobert Konigsberg <konigsberg@google.com>
Tue, 14 Jun 2011 15:03:51 +0000 (11:03 -0400)
committerRobert Konigsberg <konigsberg@google.com>
Tue, 14 Jun 2011 15:03:51 +0000 (11:03 -0400)
auto_tests/misc/local.html

index a451f8e..74e308e 100644 (file)
   <script type="text/javascript" src="../tests/multi_csv.js"></script>
   <script type="text/javascript" src="../tests/to_dom_coords.js"></script>
   <script type="text/javascript" src="../tests/interaction_model.js"></script>
+  <script type="text/javascript" src="../tests/scrolling_div.js"></script>
+  <script type="text/javascript">
+  var tc = null;
+  function processVariables() {
+    var splitVariables = function() { // http://www.idealog.us/2006/06/javascript_to_p.html
+      var query = window.location.search.substring(1); 
+      var args = {};
+      var vars = query.split("&"); 
+      for (var i = 0;i < vars.length; i++) { 
+        var pair = vars[i].split("="); 
+        args[pair[0]] = pair[1];
+      }
+      return args;
+    }
+
+    var args = splitVariables();
+    var test = args.test;
+    var command = args.command;
+
+    if (args.testCase) {
+      eval("tc = new " + args.testCase + "()");
+      if (args.command) {
+        if (args.command == "runAllTests") {
+          console.log("Running all tests for " + args.testCase);
+          tc.runAllTests();
+        }
+        if (args.command == "runTest") {
+          console.log("Running test " + args.testCase + "." + args.test);
+          tc.runTest(args.test);
+        }
+      }
+    }
+  }
+  </script>
 </head>
 <body>
   <div id='graph'></div>
   instance,<br>
   <code>tc = new SimpleDrawingTestCase() ;<br>
     tc.runTest("testDrawSimpleRangePlusOne")</code>
+
+  <p>Alternatively you can use query args: <ul>
+  <li>testCase - for the name of the test case
+  <li>test - for the name of the test (use command=runTest)
+  <li>command - either runTest or runAllTests.
+  </ul>
+  Example: <code>local.html?testCase=ScrollingDivTestCase&test=testNestedDiv_Scrolled&command=runTest</code>
 </body>
+<script>
+processVariables();
+</script>
 </html>