<script type="text/javascript" src="../lib/jquery-1.4.2.js"></script>
<script type="text/javascript" src="../lib/Asserts.js"></script>
<script type="text/javascript" src="fake-jstestdriver.js"></script>
- <script type="text/javascript" src="../tests/MoreAsserts.js"></script>
<script type="text/javascript" src="../tests/Proxy.js"></script>
<script type="text/javascript" src="../tests/CanvasAssertions.js"></script>
<script type="text/javascript" src="../tests/DygraphOps.js"></script>
<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/tickers.js"></script>
+ -->
<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" src="../tests/rolling_average.js"></script>
+ <script type="text/javascript" src="../tests/error_bars.js"></script>
+ <script type="text/javascript" src="../tests/annotations.js"></script>
+ <script type="text/javascript" src="../tests/scientific_notation.js"></script>
+ <script type="text/javascript" src="../tests/pathological_cases.js"></script>
+ <script type="text/javascript" src="../tests/date_formats.js"></script>
+ <script type="text/javascript" src="../tests/formats.js"></script>
+ <script type="text/javascript" src="../tests/update_options.js"></script>
+ <script type="text/javascript" src="../tests/utils_test.js"></script>
+ <script type="text/javascript" src="../tests/multiple_axes.js"></script>
<script type="text/javascript">
var tc = null;
+ var name = 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];
+ for (var i = 0; i < vars.length; i++) {
+ if (vars[i].length > 0) {
+ var pair = vars[i].split("=");
+ args[pair[0]] = pair[1];
+ }
}
return args;
}
var test = args.test;
var command = args.command;
- if (args.testCase) {
+ // args.testCaseName uses the string name of the test.
+ if (args.testCaseName) {
+ var testCases = getAllTestCases();
+ name = args.testCaseName;
+ for (var idx in testCases) {
+ var entry = testCases[idx];
+ if (entry.name == args.testCaseName) {
+ var prototype = entry.testCase;
+ tc = new entry.testCase();
+ break;
+ }
+ }
+ } else if (args.testCase) { // The class name of the test.
+ name = 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 the test class is defined.
+ if (tc != null) {
+ if (args.command == "runAllTests") {
+ console.log("Running all tests for " + args.testCase);
+ postResults(tc.runAllTests());
+ }
+ if (args.command == "runTest") {
+ console.log("Running test " + args.testCase + "." + args.test);
+ postResults(tc.runTest(args.test));
+ }
+ } else {
+ if (args.command == "runAllTests") {
+ console.log("Running all tests for all test cases");
+ var testCases = getAllTestCases();
+ var results = {};
+ for (var idx in testCases) {
+ var entry = testCases[idx];
+ var prototype = entry.testCase;
+ tc = new entry.testCase();
+ results[entry.name] = tc.runAllTests();
}
- if (args.command == "runTest") {
- console.log("Running test " + args.testCase + "." + args.test);
- tc.runTest(args.test);
+ postResults(results);
+ }
+ }
+ }
+
+ function postResults(results, title, div) {
+ var first = false;
+ if (div == null) {
+ var body = document.getElementsByTagName("body")[0];
+ div = document.createElement("div");
+ div.innerHTML = "Test results:";
+ if (typeof(results) != "boolean"); {
+ div.innerHTML = "Test results:<br/>";
+ }
+ body.insertBefore(div, body.firstChild);
+ first = true;
+ }
+
+ var resultToHtml = function(result) {
+ return result ?
+ "<span style='color:green;'>pass</span>" :
+ "<span style='color:red;'>fail</span>";
+ }
+
+ if (typeof(results) == "boolean") {
+ var elem = document.createElement("div");
+ if (title) {
+ elem.innerHTML = title + ": " + resultToHtml(results);
+ } else {
+ elem.innerHTML = resultToHtml(results);
+ }
+ div.appendChild(elem);
+ } else { // hash
+ var html = "";
+ for (var key in results) {
+ if (results.hasOwnProperty(key)) {
+ var elem = results[key];
+ if (typeof(elem) == "boolean" && title) {
+ postResults(results[key], title + "." + key, div);
+ } else {
+ postResults(results[key], key, div);
+ }
}
}
}
+ if (first) {
+ div.appendChild(document.createElement("hr"));
+ }
}
</script>
</head>
<body>
<div id='graph'></div>
- This file is really nothing more than all the tests coalesced into a single
- HTML file. To run a test, open a Javascript console and execute, for
- instance,<br>
- <code>tc = new SimpleDrawingTestCase() ;<br>
- tc.runTest("testDrawSimpleRangePlusOne")</code>
+ <div id="selector"></div>
+ <p>This file is really nothing more than all the tests coalesced into a single
+ HTML file. To run a test, use the selector above, or
+ open a Javascript console and execute, for instance,</p>
+ <code>testDrawSimpleRangePlusOne()</code>
<p>Alternatively you can use query args: <ul>
- <li>testCase - for the name of the test case
+ <li>testCase - for the name of the test case prototype
+ <li>testCaseName - 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>
+ <p/>
</body>
<script>
processVariables();
+addGlobalTestSymbols();
+
+var selector = document.getElementById("selector");
+
+if (selector != null) { // running a test
+ var createAttached = function(name, parent) {
+ var elem = document.createElement(name);
+ parent.appendChild(elem);
+ return elem;
+ }
+
+ var description = createAttached("div", selector);
+ var list = createAttached("ul", selector);
+ var parent = list.parentElement;
+ var createLink = function(parent, text, url) {
+ var li = createAttached("li", parent);
+ var a = createAttached("a", li);
+ a.innerText = text;
+ a.href = url;
+ }
+ if (tc == null) {
+ description.innerHTML = "Test cases:";
+ var testCases = getAllTestCases();
+ createLink(list, "(run all tests)", document.URL + "?command=runAllTests");
+ for (var idx in testCases) {
+ var entryName = testCases[idx].name;
+ createLink(list, entryName, document.URL + "?testCaseName=" + entryName);
+ }
+ } else {
+ description.innerHTML = "Tests for " + name;
+ var names = tc.getTestNames();
+ createLink(list, "Run All Tests", document.URL + "&command=runAllTests");
+ for (var idx in names) {
+ var name = names[idx];
+ createLink(list, name, document.URL + "&test=" + name + "&command=runTest");
+ }
+ }
+}
</script>
</html>