Upstream version 5.34.98.0
[platform/framework/web/crosswalk.git] / src / third_party / trace-viewer / src / tests.html
1 <!DOCTYPE html>
2 <html>
3 <!--
4 Copyright (c) 2013 The Chromium Authors. All rights reserved.
5 Use of this source code is governed by a BSD-style license that can be
6 found in the LICENSE file.
7 -->
8 <head>
9   <title>All Tracing Tests</title>
10   <script src="/src/base.js"></script>
11   <script>
12     base.require('base.unittest');
13     base.require('base.settings');
14   </script>
15   <link rel="shortcut icon" href="data:image/x-icon;base64," type="image/x-icon">
16   <script>
17     function getAsync(url, cb) {
18       var req = new XMLHttpRequest();
19       req.open('GET', url, true);
20       req.onreadystatechange = function(aEvt) {
21         if (req.readyState == 4) {
22           window.setTimeout(function() {
23             if (req.status == 200) {
24               cb(req.responseText);
25             } else {
26               console.log('Failed to load ' + url);
27             }
28           }, 0);
29         }
30       };
31       req.send(null);
32     }
33
34     function launchTests(suite, tests, testType) {
35       var stats = document.getElementById('stats');
36       base.unittest.testType(testType);
37
38       // Perf tests should never have condensed results.
39       if (testType === 'perf') {
40         base.unittest.showCondensed(false);
41       } else {
42         var val = localStorage.getItem('testing::short-format') === 'true';
43         base.unittest.showCondensed(val);
44       }
45
46       if (suite !== undefined) {
47         base.unittest.Suites(['/src/' + suite + '_test.js'], tests);
48       } else {
49         getAsync('/json/tests', function(data) {
50           base.unittest.Suites(JSON.parse(data), tests);
51         });
52       }
53     }
54
55     function launchTestsIfAvailable() {
56       if (base.unittest === undefined ||
57           base.unittest.showCondensed === undefined ||
58           base.unittest.testType === undefined) {
59         window.setTimeout(launchTestsIfAvailable, 100);
60         return;
61       }
62
63       var suite = undefined;
64       var tests = [];
65       var testType = 'unit';
66
67       // Note, this is nieve, but works for our purposes. Would explode on
68       // encoded &'s.
69       var queryParams = window.location.search.substring(1).split('&');
70       queryParams.forEach(function(param) {
71         var parts = param.split('=');
72         if (parts[0] === 'suite')
73           suite = parts[1];
74         else if (parts[0] === 'test')
75           tests.push(parts[1]);
76         else if (parts[0] === 'type')
77           testType = (parts[1] === 'perf' ? 'perf' : 'unit');
78       });
79
80       var format = document.getElementById('short-format');
81       format.checked = localStorage.getItem('testing::short-format') === 'true';
82       format.addEventListener('click', function(ev) {
83         localStorage.setItem('testing::short-format', ev.target.checked);
84
85         if (testType === 'perf')
86           return;
87
88         base.unittest.showCondensed(ev.target.checked);
89         base.unittest.runSuites();
90       });
91       base.unittest.showCondensed(format.checked);
92
93       var testTypeInputs = document.getElementsByName('test-type');
94       for (var i = 0; i < testTypeInputs.length; ++i) {
95         if (testTypeInputs[i].value === testType)
96           testTypeInputs[i].checked = true;
97
98         testTypeInputs[i].addEventListener('click', function(ev) {
99           testType = ev.target.value;
100
101           var loc = window.location.protocol + '//' + window.location.host +
102               window.location.pathname + '?';
103
104           if (suite !== undefined)
105             loc += 'suite=' + suite + '&';
106           if (tests.length !== 0)
107             loc += 'test=' + tests.join(',') + '&';
108           loc += 'type=' + testType;
109
110           window.location = loc;
111           return;
112         });
113       }
114       launchTests(suite, tests, testType);
115     }
116
117     document.addEventListener('DOMContentLoaded', function() {
118       launchTestsIfAvailable();
119     });
120
121   </script>
122   <style>
123     html, body {
124       box-sizing: border-box;
125       width: 100%;
126       height: 100%;
127       overflow: hidden;
128       margin: 0;
129     }
130   </style>
131 </head>
132
133 <body>
134   <div id="test-harness">
135     <h1><a href='/src/tests.html'>Trace-Viewer Tests</a></h1>
136
137     <div id="stats">
138       <br />
139     </div>
140
141     <div id='individual-tests'>
142       <div class="unittest">
143         View a trace file:
144         <a href="/examples/trace_viewer.html"
145           class="unittest-error-link">Trace viewer</a>
146       </div>
147       <div class="unittest">
148         View a skp file:
149         <a href="/examples/skia_debugger.html"
150             class="unittest-error-link">Skia Debugger</a>
151       </div>
152       <div class="unittest">
153         <input type="radio" name="test-type" value="unit" />
154         Run unit tests
155
156         <input type="radio" name="test-type" value="perf" />
157         Run perf tests
158       </div>
159       <div class="unittest">
160         <input type="checkbox" id="short-format" /> Short format
161       </div>
162     </div>
163
164     <div id='messages'>
165       <h1>Warning</h1>
166       <ul id='message-list'></ul>
167     </div>
168
169     <div id='test-results'>
170     </div>
171
172     <div id='exceptions'>
173       <h1>Exceptions</h1>
174       <ol id="exception-list"></ol>
175     </div>
176   </div>
177 </body>
178 </html>