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