| <!-- |
| Copyright 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. |
| |
| A web page intended for both manual and automated end-to-end testing of |
| the Hangout Services component extension and the APIs it uses. |
| --> |
| <html> |
| <head> |
| <title>Hangout Services Test Page</title> |
| <script src="hangout_services_test.js"> |
| </script> |
| <script> |
| // |
| // UI glue and other code that needs to use the document. Leaving in |
| // HTML file with the UI elements it is using. |
| // |
| |
| // Populates UI elements with initial contents. |
| function populate() { |
| populateSinks(); |
| MediaStreamTrack.getSources(populateSources); |
| } |
| |
| // Populates the select box with information on all sinks and the |
| // currently selected sink. |
| function populateSinks() { |
| var select = document.getElementById('select'); |
| while (select.length > 0) |
| select.remove(0); |
| getSinks(function(sinks) { |
| for (var i = 0; i < sinks.length; ++i) { |
| var option = document.createElement('option'); |
| option.value = sinks[i].sinkId; |
| option.text = sinks[i].sinkLabel + ' (' + sinks[i].sinkId + ')'; |
| select.add(option); |
| } |
| getActiveSink(function(sinkId) { |
| select.value = sinkId; |
| }); |
| }); |
| } |
| |
| function populateSources(sources) { |
| var select = document.getElementById('selectSource'); |
| for (var i = 0; i < sources.length; ++i) { |
| var source = sources[i]; |
| if (source.kind == 'audio') { |
| var option = document.createElement('option'); |
| option.value = source.id; |
| option.text = source.label + ' (' + source.id + ')'; |
| select.add(option); |
| } |
| } |
| } |
| |
| // Sets the currently active sink to the one selected in the select |
| // box. |
| function setActiveSinkFromSelection() { |
| var select = document.getElementById('select'); |
| setActiveSink(select.value, function() { |
| populateSinks(); |
| }); |
| } |
| |
| function getAssociatedDeviceFromSelection() { |
| var select = document.getElementById('selectSource'); |
| getAssociatedSink(select.value, function(sinkId) { |
| alert('Associated sink ID: ' + sinkId); |
| }); |
| } |
| |
| // |
| // Manual tests. |
| // |
| |
| function manualTestChooseDesktopMedia() { |
| chooseDesktopMedia(function(results) { |
| alert('Cancel ID: ' + results.cancelId + |
| ', stream ID: ' + results.streamId); |
| }); |
| } |
| |
| function manualTestListenForSinksChangedEvent() { |
| listenForSinksChangedEvent(function(msg) { |
| if (msg['eventName'] && msg['eventName'] == 'onSinksChanged') |
| alert('Got onSinksChanged event.'); |
| }); |
| } |
| |
| // Browser test scaffolding. Starts the test run from a browser |
| // test. Sets the document title to 'success' or 'failure' when the |
| // test completes. |
| function browsertestRunAllTests() { |
| runAllTests(function(results) { |
| if (results == '') { |
| document.title = 'success'; |
| } else { |
| console.log('Test failed:'); |
| console.log(results); |
| document.title = 'failure'; |
| } |
| }); |
| } |
| </script> |
| </head> |
| <body onload="populate()"> |
| <audio id="audio" src="long_audio.ogg" controls autoplay></audio> |
| <br/> |
| |
| Audio output devices, along with currently selected device. Click to change:<br/> |
| <select style="width:100%" id="select" size=10 |
| onClick="setActiveSinkFromSelection()"></select> |
| <br/> |
| |
| Audio input devices. Click to get associated output device ID:<br/> |
| <select size=10 id="selectSource" onClick="getAssociatedDeviceFromSelection()"> |
| </select> |
| |
| <p> |
| Run all automated tests manually (empty results indicate success): |
| <input type="submit" value="Run" |
| onclick="runAllTests(function(results) { alert('Results:\n' + |
| results); });"><br/> |
| Manually test choosing desktop media: |
| <input type="submit" value="Choose Media" |
| onclick="manualTestChooseDesktopMedia();"><br/> |
| Start listening for onSinksChanged event (manual test): |
| <input type="submit" value="Start listening" |
| onclick="manualTestListenForSinksChangedEvent();"><br/> |
| </body> |
| </html> |