Pin Chrome's shortcut to the Win10 Start menu on install and OS upgrade.
[chromium-blink-merge.git] / chrome / test / data / extensions / hangout_services_test.html
blobed1fcc57e422686fc584fc4b0a4cffecec00ef5c
1 <!--
2 Copyright 2013 The Chromium Authors. All rights reserved.
3 Use of this source code is governed by a BSD-style license that can be
4 found in the LICENSE file.
6 A web page intended for both manual and automated end-to-end testing of
7 the Hangout Services component extension and the APIs it uses.
8 -->
9 <html>
10 <head>
11 <title>Hangout Services Test Page</title>
12 <script src="hangout_services_test.js">
13 </script>
14 <script>
16 // UI glue and other code that needs to use the document. Leaving in
17 // HTML file with the UI elements it is using.
20 // Populates UI elements with initial contents.
21 function populate() {
22 populateSinks();
23 MediaStreamTrack.getSources(populateSources);
26 // Populates the select box with information on all sinks and the
27 // currently selected sink.
28 function populateSinks() {
29 var select = document.getElementById('select');
30 while (select.length > 0)
31 select.remove(0);
32 getSinks(function(sinks) {
33 for (var i = 0; i < sinks.length; ++i) {
34 var option = document.createElement('option');
35 option.value = sinks[i].sinkId;
36 option.text = sinks[i].sinkLabel + ' (' + sinks[i].sinkId + ')';
37 select.add(option);
39 getActiveSink(function(sinkId) {
40 select.value = sinkId;
41 });
42 });
45 function populateSources(sources) {
46 var select = document.getElementById('selectSource');
47 for (var i = 0; i < sources.length; ++i) {
48 var source = sources[i];
49 if (source.kind == 'audio') {
50 var option = document.createElement('option');
51 option.value = source.id;
52 option.text = source.label + ' (' + source.id + ')';
53 select.add(option);
58 // Sets the currently active sink to the one selected in the select
59 // box.
60 function setActiveSinkFromSelection() {
61 var select = document.getElementById('select');
62 setActiveSink(select.value, function() {
63 populateSinks();
64 });
67 function getAssociatedDeviceFromSelection() {
68 var select = document.getElementById('selectSource');
69 getAssociatedSink(select.value, function(sinkId) {
70 alert('Associated sink ID: ' + sinkId);
71 });
75 // Manual tests.
78 function manualTestChooseDesktopMedia() {
79 chooseDesktopMedia(function(results) {
80 alert('Cancel ID: ' + results.cancelId +
81 ', stream ID: ' + results.streamId);
82 });
85 function manualTestListenForSinksChangedEvent() {
86 listenForSinksChangedEvent(function(msg) {
87 if (msg['eventName'] && msg['eventName'] == 'onSinksChanged')
88 alert('Got onSinksChanged event.');
89 });
92 // Browser test scaffolding. Starts the test run from a browser
93 // test. Sets the document title to 'success' or 'failure' when the
94 // test completes.
95 function browsertestRunAllTests() {
96 runAllTests(function(results) {
97 if (results == '') {
98 document.title = 'success';
99 } else {
100 console.log('Test failed:');
101 console.log(results);
102 document.title = 'failure';
106 </script>
107 </head>
108 <body onload="populate()">
109 <audio id="audio" src="long_audio.ogg" controls autoplay></audio>
110 <br/>
112 Audio output devices, along with currently selected device. Click to change:<br/>
113 <select style="width:100%" id="select" size=10
114 onClick="setActiveSinkFromSelection()"></select>
115 <br/>
117 Audio input devices. Click to get associated output device ID:<br/>
118 <select size=10 id="selectSource" onClick="getAssociatedDeviceFromSelection()">
119 </select>
122 Run all automated tests manually (empty results indicate success):
123 <input type="submit" value="Run"
124 onclick="runAllTests(function(results) { alert('Results:\n' +
125 results); });"><br/>
126 Manually test choosing desktop media:
127 <input type="submit" value="Choose Media"
128 onclick="manualTestChooseDesktopMedia();"><br/>
129 Start listening for onSinksChanged event (manual test):
130 <input type="submit" value="Start listening"
131 onclick="manualTestListenForSinksChangedEvent();"><br/>
132 </body>
133 </html>