OLD | NEW |
1 <!-- | 1 <!-- |
2 Copyright 2013 The Chromium Authors. All rights reserved. | 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 | 3 Use of this source code is governed by a BSD-style license that can be |
4 found in the LICENSE file. | 4 found in the LICENSE file. |
5 | 5 |
6 A web page intended for both manual and automated end-to-end testing of | 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. | 7 the Hangout Services component extension and the APIs it uses. |
8 --> | 8 --> |
9 <html> | 9 <html> |
10 <head> | 10 <head> |
11 <title>Hangout Services Test Page</title> | 11 <title>Hangout Services Test Page</title> |
12 <script src="hangout_services_test.js"> | 12 <script src="hangout_services_test.js"> |
13 </script> | 13 </script> |
14 <script> | 14 <script> |
15 // | 15 // |
16 // UI glue and other code that needs to use the document. Leaving in | 16 // UI glue and other code that needs to use the document. Leaving in |
17 // HTML file with the UI elements it is using. | 17 // HTML file with the UI elements it is using. |
18 // | 18 // |
19 | 19 |
20 // Populates UI elements with initial contents. | 20 // Populates UI elements with initial contents. |
21 function populate() { | 21 function populate() { |
22 populateSinks(); | 22 populateSinks(); |
23 navigator.mediaDevices.enumerateDevices().then(populateSources); | 23 navigator.mediaDevices.enumerateDevices().then(populateSources); |
24 } | 24 } |
25 | 25 |
26 // Populates the select box with information on all sinks and the | 26 // Populates the select box with information on all sinks. |
27 // currently selected sink. | |
28 function populateSinks() { | 27 function populateSinks() { |
29 var select = document.getElementById('select'); | 28 var select = document.getElementById('select'); |
30 while (select.length > 0) | 29 while (select.length > 0) |
31 select.remove(0); | 30 select.remove(0); |
32 getSinks(function(sinks) { | 31 getSinks(function(sinks) { |
33 for (var i = 0; i < sinks.length; ++i) { | 32 for (var i = 0; i < sinks.length; ++i) { |
34 var option = document.createElement('option'); | 33 var option = document.createElement('option'); |
35 option.value = sinks[i].sinkId; | 34 option.value = sinks[i].sinkId; |
36 option.text = sinks[i].sinkLabel + ' (' + sinks[i].sinkId + ')'; | 35 option.text = sinks[i].sinkLabel + ' (' + sinks[i].sinkId + ')'; |
37 select.add(option); | 36 select.add(option); |
38 } | 37 } |
39 getActiveSink(function(sinkId) { | |
40 select.value = sinkId; | |
41 }); | |
42 }); | 38 }); |
43 } | 39 } |
44 | 40 |
45 function populateSources(devices) { | 41 function populateSources(devices) { |
46 var select = document.getElementById('selectSource'); | 42 var select = document.getElementById('selectSource'); |
47 for (var i = 0; i < devices.length; ++i) { | 43 for (var i = 0; i < devices.length; ++i) { |
48 var device = devices[i]; | 44 var device = devices[i]; |
49 if (device.kind == 'audioinput') { | 45 if (device.kind == 'audioinput') { |
50 var option = document.createElement('option'); | 46 var option = document.createElement('option'); |
51 option.value = device.deviceId; | 47 option.value = device.deviceId; |
52 option.text = device.label + ' (' + device.deviceId + ')'; | 48 option.text = device.label + ' (' + device.deviceId + ')'; |
53 select.add(option); | 49 select.add(option); |
54 } | 50 } |
55 } | 51 } |
56 } | 52 } |
57 | 53 |
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 }); | |
65 } | |
66 | |
67 function getAssociatedDeviceFromSelection() { | 54 function getAssociatedDeviceFromSelection() { |
68 var select = document.getElementById('selectSource'); | 55 var select = document.getElementById('selectSource'); |
69 getAssociatedSink(select.value, function(sinkId) { | 56 getAssociatedSink(select.value, function(sinkId) { |
70 alert('Associated sink ID: ' + sinkId); | 57 alert('Associated sink ID: ' + sinkId); |
71 }); | 58 }); |
72 } | 59 } |
73 | 60 |
74 // | 61 // |
75 // Manual tests. | 62 // Manual tests. |
76 // | 63 // |
(...skipping 25 matching lines...) Expand all Loading... |
102 document.title = 'failure'; | 89 document.title = 'failure'; |
103 } | 90 } |
104 }); | 91 }); |
105 } | 92 } |
106 </script> | 93 </script> |
107 </head> | 94 </head> |
108 <body onload="populate()"> | 95 <body onload="populate()"> |
109 <audio id="audio" src="long_audio.ogg" controls autoplay></audio> | 96 <audio id="audio" src="long_audio.ogg" controls autoplay></audio> |
110 <br/> | 97 <br/> |
111 | 98 |
112 Audio output devices, along with currently selected device. Click to change:<br/
> | 99 Audio output devices<br/> |
113 <select style="width:100%" id="select" size=10 | 100 <select style="width:100%" id="select" size=10></select> |
114 onClick="setActiveSinkFromSelection()"></select> | |
115 <br/> | 101 <br/> |
116 | 102 |
117 Audio input devices. Click to get associated output device ID:<br/> | 103 Audio input devices. Click to get associated output device ID:<br/> |
118 <select size=10 id="selectSource" onClick="getAssociatedDeviceFromSelection()"> | 104 <select size=10 id="selectSource" onClick="getAssociatedDeviceFromSelection()"> |
119 </select> | 105 </select> |
120 | 106 |
121 <p> | 107 <p> |
122 Run all automated tests manually (empty results indicate success): | 108 Run all automated tests manually (empty results indicate success): |
123 <input type="submit" value="Run" | 109 <input type="submit" value="Run" |
124 onclick="runAllTests(function(results) { alert('Results:\n' + | 110 onclick="runAllTests(function(results) { alert('Results:\n' + |
125 results); });"><br/> | 111 results); });"><br/> |
126 Manually test choosing desktop media: | 112 Manually test choosing desktop media: |
127 <input type="submit" value="Choose Media" | 113 <input type="submit" value="Choose Media" |
128 onclick="manualTestChooseDesktopMedia();"><br/> | 114 onclick="manualTestChooseDesktopMedia();"><br/> |
129 Start listening for onSinksChanged event (manual test): | 115 Start listening for onSinksChanged event (manual test): |
130 <input type="submit" value="Start listening" | 116 <input type="submit" value="Start listening" |
131 onclick="manualTestListenForSinksChangedEvent();"><br/> | 117 onclick="manualTestListenForSinksChangedEvent();"><br/> |
132 </body> | 118 </body> |
133 </html> | 119 </html> |
OLD | NEW |