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.
11 <title>Hangout Services Test Page
</title>
12 <script src=
"hangout_services_test.js">
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.
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)
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
+ ')';
39 getActiveSink(function(sinkId
) {
40 select
.value
= sinkId
;
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
+ ')';
58 // Sets the currently active sink to the one selected in the select
60 function setActiveSinkFromSelection() {
61 var select
= document
.getElementById('select');
62 setActiveSink(select
.value
, function() {
67 function getAssociatedDeviceFromSelection() {
68 var select
= document
.getElementById('selectSource');
69 getAssociatedSink(select
.value
, function(sinkId
) {
70 alert('Associated sink ID: ' + sinkId
);
78 function manualTestChooseDesktopMedia() {
79 chooseDesktopMedia(function(results
) {
80 alert('Cancel ID: ' + results
.cancelId
+
81 ', stream ID: ' + results
.streamId
);
85 function manualTestListenForSinksChangedEvent() {
86 listenForSinksChangedEvent(function(msg
) {
87 if (msg
['eventName'] && msg
['eventName'] == 'onSinksChanged')
88 alert('Got onSinksChanged event.');
92 // Browser test scaffolding. Starts the test run from a browser
93 // test. Sets the document title to 'success' or 'failure' when the
95 function browsertestRunAllTests() {
96 runAllTests(function(results
) {
98 document
.title
= 'success';
100 console
.log('Test failed:');
101 console
.log(results
);
102 document
.title
= 'failure';
108 <body onload=
"populate()">
109 <audio id=
"audio" src=
"long_audio.ogg" controls autoplay
></audio>
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>
117 Audio input devices. Click to get associated output device ID:
<br/>
118 <select size=
10 id=
"selectSource" onClick=
"getAssociatedDeviceFromSelection()">
122 Run all automated tests manually (empty results indicate success):
123 <input type=
"submit" value=
"Run"
124 onclick=
"runAllTests(function(results) { alert('Results:\n' +
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/>