Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1)

Side by Side Diff: chrome/test/data/extensions/hangout_services_test.js

Issue 59113003: Add a browser test to automatically run end-to-end Hangout Services test. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Fix getSinks test for platforms with no audio sinks. Created 7 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « chrome/test/data/extensions/hangout_services_test.html ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2013 The Chromium Authors. All rights reserved. 1 // Copyright 2013 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 // 4 //
5 // JavaScript for invoking methods on APIs used by Hangouts via the 5 // JavaScript for invoking methods on APIs used by Hangouts via the
6 // Hangout Services extension, and a JavaScript-based end-to-end test 6 // Hangout Services extension, and a JavaScript-based end-to-end test
7 // of the extension. 7 // of the extension.
8 8
9 // ID of the Hangout Services component extension. 9 // ID of the Hangout Services component extension.
10 var EXTENSION_ID = "nkeimhogjdpnpccoofpliimaahmaaome"; 10 var EXTENSION_ID = "nkeimhogjdpnpccoofpliimaahmaaome";
(...skipping 101 matching lines...) Expand 10 before | Expand all | Expand 10 after
112 } 112 }
113 113
114 // Will call |callback()| on completion. If the extension you send to 114 // Will call |callback()| on completion. If the extension you send to
115 // is not loaded, the extension system will still call |callback()| 115 // is not loaded, the extension system will still call |callback()|
116 // but will set lastError. 116 // but will set lastError.
117 function isExtensionEnabled(callback) { 117 function isExtensionEnabled(callback) {
118 sendMessage({'method': 'isExtensionEnabled'}, callback); 118 sendMessage({'method': 'isExtensionEnabled'}, callback);
119 } 119 }
120 120
121 // 121 //
122 // Manual tests.
123 //
124
125 function manualTestChooseDesktopMedia() {
126 chooseDesktopMedia(function(results) {
127 alert('Cancel ID: ' + results.cancelId +
128 ', stream ID: ' + results.streamId);
129 });
130 }
131
132 function manualTestListenForSinksChangedEvent() {
133 listenForSinksChangedEvent(function(msg) {
134 if (msg['eventName'] && msg['eventName'] == 'onSinksChanged')
135 alert('Got onSinksChanged event.');
136 });
137 }
138
139 //
140 // Automated tests. 122 // Automated tests.
141 // 123 //
142 124
143 // Very micro test framework. Add all tests to |TESTS|. Each test must 125 // Very micro test framework. Add all tests to |TESTS|. Each test must
144 // call the passed-in callback eventually with a string indicating 126 // call the passed-in callback eventually with a string indicating
145 // results. Empty results indicate success. 127 // results. Empty results indicate success.
146 var TESTS = [ 128 var TESTS = [
147 testCpuGetInfo, 129 testCpuGetInfo,
148 testLogging, 130 testLogging,
149 testDisabledLogging, 131 testDisabledLogging,
150 testDisabledLoggingButUpload, 132 testDisabledLoggingButUpload,
151 testEnabledLoggingButDiscard, 133 testEnabledLoggingButDiscard,
152 testGetSinks, 134 testGetSinks,
153 testGetActiveSink, 135 testGetActiveSink,
154 testSetActiveSink, 136 testSetActiveSink,
155 testGetAssociatedSink, 137 testGetAssociatedSink,
156 testIsExtensionEnabled, 138 testIsExtensionEnabled,
157 testSendingToInvalidExtension, 139 testSendingToInvalidExtension,
158 140
159 // Uncomment to manually test timeout logic. 141 // Uncomment to manually test timeout logic.
160 //testTimeout, 142 //testTimeout,
161 ]; 143 ];
162 144
145 var TEST_TIMEOUT_MS = 3000;
146
163 function runAllTests(callback) { 147 function runAllTests(callback) {
164 var results = ''; 148 var results = '';
165 149
166 // Run one test at a time, running the next only on completion. 150 // Run one test at a time, running the next only on completion.
167 // This makes it easier to deal with timing out tests that do not 151 // This makes it easier to deal with timing out tests that do not
168 // complete successfully. 152 // complete successfully.
169 // 153 //
170 // It also seems necessary (instead of starting all the tests in 154 // It also seems necessary (instead of starting all the tests in
171 // parallel) as the webrtcLoggingPrivate API does not seem to like 155 // parallel) as the webrtcLoggingPrivate API does not seem to like
172 // certain sequences of interleaved requests (it may DCHECK in 156 // certain sequences of interleaved requests (it may DCHECK in
(...skipping 10 matching lines...) Expand all
183 167
184 // Start the test function... 168 // Start the test function...
185 test(function(currentResults) { 169 test(function(currentResults) {
186 nextTest(test.name, currentResults, false); 170 nextTest(test.name, currentResults, false);
187 }); 171 });
188 172
189 // ...and also start a timeout. 173 // ...and also start a timeout.
190 function onTimeout() { 174 function onTimeout() {
191 nextTest(test.name, '', true); 175 nextTest(test.name, '', true);
192 } 176 }
193 setTimeout(onTimeout, 3000); 177 setTimeout(onTimeout, TEST_TIMEOUT_MS);
194 } 178 }
195 179
196 function nextTest(testName, currentResults, timedOut) { 180 function nextTest(testName, currentResults, timedOut) {
197 // The check for testIndex is necessary for timeouts arriving 181 // The check for testIndex is necessary for timeouts arriving
198 // after testIndex is already past the end of the TESTS array. 182 // after testIndex is already past the end of the TESTS array.
199 if (testIndex >= TESTS.length || 183 if (testIndex >= TESTS.length ||
200 testName != TESTS[testIndex].name) { 184 testName != TESTS[testIndex].name) {
201 // Either a timeout of a function that already completed, or a 185 // Either a timeout of a function that already completed, or a
202 // function completing after a timeout. Either way we ignore. 186 // function completing after a timeout. Either way we ignore.
203 console.log('Ignoring results for ' + testName + 187 console.log('Ignoring results for ' + testName +
(...skipping 80 matching lines...) Expand 10 before | Expand all | Expand 10 after
284 loggingStop(function() { 268 loggingStop(function() {
285 loggingDiscard(function() { 269 loggingDiscard(function() {
286 callback(''); 270 callback('');
287 }); 271 });
288 }); 272 });
289 }); 273 });
290 } 274 }
291 275
292 function testGetSinks(callback) { 276 function testGetSinks(callback) {
293 getSinks(function(sinks) { 277 getSinks(function(sinks) {
294 if (sinks.length == 0) 278 // Some bots may have no audio sinks installed, in which case we
295 callback('Got no sinks.'); 279 // will get an empty list here.
296 else 280 callback('');
297 callback('');
298 }); 281 });
299 } 282 }
300 283
301 function testGetActiveSink(callback) { 284 function testGetActiveSink(callback) {
302 getActiveSink(function(sinkId) { 285 getActiveSink(function(sinkId) {
303 if (sinkId == '') 286 if (sinkId == '')
304 callback('Got empty sink ID.'); 287 callback('Got empty sink ID.');
305 else 288 else
306 callback(''); 289 callback('');
307 }); 290 });
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after
349 } else { 332 } else {
350 callback(''); 333 callback('');
351 } 334 }
352 }); 335 });
353 } 336 }
354 337
355 function testTimeout(callback) { 338 function testTimeout(callback) {
356 // Never call the callback. Used for manually testing that the 339 // Never call the callback. Used for manually testing that the
357 // timeout logic of the test framework is correct. 340 // timeout logic of the test framework is correct.
358 } 341 }
OLDNEW
« no previous file with comments | « chrome/test/data/extensions/hangout_services_test.html ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698