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.
9 <title>All Tracing Tests</title>
10 <script src="/src/base.js"></script>
12 base.require('base.unittest');
13 base.require('base.settings');
15 <link rel="shortcut icon" href="data:image/x-icon;base64," type="image/x-icon">
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) {
26 console.log('Failed to load ' + url);
34 function launchTests(suite, tests, testType) {
35 var stats = document.getElementById('stats');
36 base.unittest.testType(testType);
38 // Perf tests should never have condensed results.
39 if (testType === 'perf') {
40 base.unittest.showCondensed(false);
42 var val = localStorage.getItem('testing::short-format') === 'true';
43 base.unittest.showCondensed(val);
46 if (suite !== undefined) {
47 base.unittest.Suites(['/src/' + suite + '_test.js'], tests);
49 getAsync('/json/tests', function(data) {
50 base.unittest.Suites(JSON.parse(data), tests);
55 function launchTestsIfAvailable() {
56 if (base.unittest === undefined ||
57 base.unittest.showCondensed === undefined ||
58 base.unittest.testType === undefined) {
59 window.setTimeout(launchTestsIfAvailable, 100);
63 var suite = undefined;
65 var testType = 'unit';
67 // Note, this is nieve, but works for our purposes. Would explode on
69 var queryParams = window.location.search.substring(1).split('&');
70 queryParams.forEach(function(param) {
71 var parts = param.split('=');
72 if (parts[0] === 'suite')
74 else if (parts[0] === 'test')
76 else if (parts[0] === 'type')
77 testType = (parts[1] === 'perf' ? 'perf' : 'unit');
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);
85 if (testType === 'perf')
88 base.unittest.showCondensed(ev.target.checked);
89 base.unittest.runSuites();
91 base.unittest.showCondensed(format.checked);
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;
98 testTypeInputs[i].addEventListener('click', function(ev) {
99 testType = ev.target.value;
101 var loc = window.location.protocol + '//' + window.location.host +
102 window.location.pathname + '?';
104 if (suite !== undefined)
105 loc += 'suite=' + suite + '&';
106 if (tests.length !== 0)
107 loc += 'test=' + tests.join(',') + '&';
108 loc += 'type=' + testType;
110 window.location = loc;
114 launchTests(suite, tests, testType);
117 document.addEventListener('DOMContentLoaded', function() {
118 launchTestsIfAvailable();
124 box-sizing: border-box;
134 <div id="test-harness">
135 <h1><a href='/src/tests.html'>Trace-Viewer Tests</a></h1>
141 <div id='individual-tests'>
142 <div class="unittest">
144 <a href="/examples/trace_viewer.html"
145 class="unittest-error-link">Trace viewer</a>
147 <div class="unittest">
149 <a href="/examples/skia_debugger.html"
150 class="unittest-error-link">Skia Debugger</a>
152 <div class="unittest">
153 <input type="radio" name="test-type" value="unit" />
156 <input type="radio" name="test-type" value="perf" />
159 <div class="unittest">
160 <input type="checkbox" id="short-format" /> Short format
166 <ul id='message-list'></ul>
169 <div id='test-results'>
172 <div id='exceptions'>
174 <ol id="exception-list"></ol>