Fix a bug involving calls to updateOptions() while panning.
[dygraphs.git] / auto_tests / misc / local.html
CommitLineData
7165f97b 1<!-- A local source file that allows dygraph developers to test locally. -->
644eff8b
RK
2<html>
3<head>
7165f97b
RK
4 <!-- Standard Dygraph scripts -->
5 <meta http-equiv="X-UA-Compatible" content="IE=EmulateIE7; IE=EmulateIE9">
6 <!--[if IE]>
7 <script type="text/javascript" src="../../excanvas.js"></script>
8 <![endif]-->
8d3d15af 9 <script type="text/javascript" src="../../dygraph-dev.js"></script>
7165f97b
RK
10
11 <!-- Scripts for automated tests -->
12 <script type="text/javascript" src="../lib/jquery-1.4.2.js"></script>
13 <script type="text/javascript" src="../lib/Asserts.js"></script>
14 <script type="text/javascript" src="fake-jstestdriver.js"></script>
15 <script type="text/javascript" src="../tests/Proxy.js"></script>
16 <script type="text/javascript" src="../tests/CanvasAssertions.js"></script>
72a74f04 17 <script type="text/javascript" src="../tests/DygraphOps.js"></script>
7165f97b
RK
18 <script type="text/javascript" src="../tests/sanity.js"></script>
19 <script type="text/javascript" src="../tests/simple_drawing.js"></script>
72a74f04 20 <script type="text/javascript" src="../tests/range_tests.js"></script>
f3cbe61e
DV
21 <script type="text/javascript" src="../tests/axis_labels.js"></script>
22 <script type="text/javascript" src="../tests/multi_csv.js"></script>
063e83ba 23 <script type="text/javascript" src="../tests/to_dom_coords.js"></script>
9c831431 24 <script type="text/javascript" src="../tests/interaction_model.js"></script>
0842b24b 25 <!--
48e614ac 26 <script type="text/javascript" src="../tests/tickers.js"></script>
0842b24b 27 -->
6788e30b 28 <script type="text/javascript" src="../tests/scrolling_div.js"></script>
502d5996 29 <script type="text/javascript" src="../tests/custom_bars.js"></script>
0cb9bd91 30 <script type="text/javascript" src="../tests/css.js"></script>
87bbdb4d 31 <script type="text/javascript" src="../tests/selection.js"></script>
77b5e09d 32 <script type="text/javascript" src="../tests/rolling_average.js"></script>
f35016e8 33 <script type="text/javascript" src="../tests/error_bars.js"></script>
c9faeafd 34 <script type="text/javascript" src="../tests/annotations.js"></script>
0842b24b 35 <script type="text/javascript" src="../tests/scientific_notation.js"></script>
395e98a3 36 <script type="text/javascript" src="../tests/pathological_cases.js"></script>
769e8bc7 37 <script type="text/javascript" src="../tests/date_formats.js"></script>
36d4fabf 38 <script type="text/javascript" src="../tests/formats.js"></script>
97583b90 39 <script type="text/javascript" src="../tests/update_while_panning.js"></script>
9ca829f2 40 <script type="text/javascript" src="../tests/update_options.js"></script>
48e614ac
DV
41 <script type="text/javascript" src="../tests/utils_test.js"></script>
42 <script type="text/javascript" src="../tests/multiple_axes.js"></script>
1c6b239c 43 <script type="text/javascript" src="../tests/callback.js"></script>
87bbdb4d
DV
44
45
6788e30b
RK
46 <script type="text/javascript">
47 var tc = null;
0c393397 48 var name = null;
6788e30b
RK
49 function processVariables() {
50 var splitVariables = function() { // http://www.idealog.us/2006/06/javascript_to_p.html
51 var query = window.location.search.substring(1);
52 var args = {};
53 var vars = query.split("&");
3d8093fa
RK
54 for (var i = 0; i < vars.length; i++) {
55 if (vars[i].length > 0) {
56 var pair = vars[i].split("=");
57 args[pair[0]] = pair[1];
58 }
6788e30b
RK
59 }
60 return args;
61 }
62
63 var args = splitVariables();
64 var test = args.test;
65 var command = args.command;
66
ef13835b 67 // args.testCaseName uses the string name of the test.
357f7a8a
RK
68 if (args.testCaseName) {
69 var testCases = getAllTestCases();
0c393397 70 name = args.testCaseName;
357f7a8a
RK
71 for (var idx in testCases) {
72 var entry = testCases[idx];
73 if (entry.name == args.testCaseName) {
74 var prototype = entry.testCase;
75 tc = new entry.testCase();
76 break;
77 }
78 }
ef13835b 79 } else if (args.testCase) { // The class name of the test.
0c393397 80 name = args.testCase;
6788e30b 81 eval("tc = new " + args.testCase + "()");
357f7a8a 82 }
ef13835b
RK
83
84 // If the test class is defined.
357f7a8a 85 if (tc != null) {
ef13835b
RK
86 if (args.command == "runAllTests") {
87 console.log("Running all tests for " + args.testCase);
88 postResults(tc.runAllTests());
89 }
90 if (args.command == "runTest") {
91 console.log("Running test " + args.testCase + "." + args.test);
92 postResults(tc.runTest(args.test));
93 }
94 } else {
95 if (args.command == "runAllTests") {
96 console.log("Running all tests for all test cases");
97 var testCases = getAllTestCases();
98 var results = {};
99 for (var idx in testCases) {
100 var entry = testCases[idx];
101 var prototype = entry.testCase;
102 tc = new entry.testCase();
103 results[entry.name] = tc.runAllTests();
6788e30b 104 }
ef13835b 105 postResults(results);
6788e30b
RK
106 }
107 }
108 }
da11a9a7 109
ef13835b
RK
110 function postResults(results, title, div) {
111 var first = false;
112 if (div == null) {
113 var body = document.getElementsByTagName("body")[0];
114 div = document.createElement("div");
115 div.innerHTML = "Test results:";
116 if (typeof(results) != "boolean"); {
117 div.innerHTML = "Test results:<br/>";
118 }
119 body.insertBefore(div, body.firstChild);
120 first = true;
121 }
da11a9a7
RK
122
123 var resultToHtml = function(result) {
124 return result ?
125 "<span style='color:green;'>pass</span>" :
126 "<span style='color:red;'>fail</span>";
127 }
128
129 if (typeof(results) == "boolean") {
ef13835b
RK
130 var elem = document.createElement("div");
131 if (title) {
132 elem.innerHTML = title + ": " + resultToHtml(results);
133 } else {
134 elem.innerHTML = resultToHtml(results);
135 }
136 div.appendChild(elem);
da11a9a7
RK
137 } else { // hash
138 var html = "";
139 for (var key in results) {
140 if (results.hasOwnProperty(key)) {
ef13835b
RK
141 var elem = results[key];
142 if (typeof(elem) == "boolean" && title) {
143 postResults(results[key], title + "." + key, div);
144 } else {
145 postResults(results[key], key, div);
146 }
da11a9a7
RK
147 }
148 }
da11a9a7 149 }
ef13835b
RK
150 if (first) {
151 div.appendChild(document.createElement("hr"));
152 }
da11a9a7 153 }
6788e30b 154 </script>
644eff8b
RK
155</head>
156<body>
157 <div id='graph'></div>
33933283 158 <div id="selector"></div>
3914c8e1 159 <p>This file is really nothing more than all the tests coalesced into a single
33933283
RK
160 HTML file. To run a test, use the selector above, or
161 open a Javascript console and execute, for instance,</p>
3914c8e1 162 <code>testDrawSimpleRangePlusOne()</code>
6788e30b
RK
163
164 <p>Alternatively you can use query args: <ul>
33933283
RK
165 <li>testCase - for the name of the test case prototype
166 <li>testCaseName - for the name of the test case
6788e30b
RK
167 <li>test - for the name of the test (use command=runTest)
168 <li>command - either runTest or runAllTests.
169 </ul>
170 Example: <code>local.html?testCase=ScrollingDivTestCase&test=testNestedDiv_Scrolled&command=runTest</code>
357f7a8a 171 <p/>
644eff8b 172</body>
6788e30b
RK
173<script>
174processVariables();
3914c8e1 175addGlobalTestSymbols();
357f7a8a 176
357f7a8a 177var selector = document.getElementById("selector");
0c393397 178
357f7a8a 179if (selector != null) { // running a test
da11a9a7
RK
180 var createAttached = function(name, parent) {
181 var elem = document.createElement(name);
182 parent.appendChild(elem);
183 return elem;
184 }
185
357f7a8a
RK
186 var description = createAttached("div", selector);
187 var list = createAttached("ul", selector);
188 var parent = list.parentElement;
da11a9a7
RK
189 var createLink = function(parent, text, url) {
190 var li = createAttached("li", parent);
191 var a = createAttached("a", li);
192 a.innerText = text;
193 a.href = url;
194 }
357f7a8a
RK
195 if (tc == null) {
196 description.innerHTML = "Test cases:";
197 var testCases = getAllTestCases();
ef13835b 198 createLink(list, "(run all tests)", document.URL + "?command=runAllTests");
357f7a8a 199 for (var idx in testCases) {
da11a9a7
RK
200 var entryName = testCases[idx].name;
201 createLink(list, entryName, document.URL + "?testCaseName=" + entryName);
357f7a8a
RK
202 }
203 } else {
204 description.innerHTML = "Tests for " + name;
205 var names = tc.getTestNames();
da11a9a7 206 createLink(list, "Run All Tests", document.URL + "&command=runAllTests");
357f7a8a
RK
207 for (var idx in names) {
208 var name = names[idx];
da11a9a7 209 createLink(list, name, document.URL + "&test=" + name + "&command=runTest");
357f7a8a
RK
210 }
211 }
212}
6788e30b 213</script>
644eff8b 214</html>