Unreviewed. Mark some more WTF unit tests as slow for GTK and WPE
[WebKit-https.git] / LayoutTests / webrtc / audio-peer-connection-g722.html
1 <!DOCTYPE html>
2 <html>
3 <head>
4     <meta charset="utf-8">
5     <title>Testing local audio capture playback causes "playing" event to fire</title>
6     <script src="../resources/testharness.js"></script>
7     <script src="../resources/testharnessreport.js"></script>
8     <script src ="routines.js"></script>
9     <script>
10 var context = new webkitAudioContext();
11 var remoteStream;
12
13 async function checkForHumBipBop(stream, previousResults, counter)
14 {
15     if (!previousResults)
16         previousResults = {
17             heardHum : false,
18             heardBip : false,
19             heardBop : false
20     };
21     if (!counter)
22         counter = 1;
23     else if (++counter > 4)
24         return Promise.resolve(false);
25     results = await analyseAudio(stream, 1000, context);
26     previousResults.heardHum |= results.heardHum;
27     previousResults.heardBip |= results.heardBip;
28     previousResults.heardBop |= results.heardBop;
29     if (previousResults.heardHum && previousResults.heardBip && previousResults.heardBop)
30         return Promise.resolve(true);
31     var results = await checkForHumBipBop(stream, previousResults, counter);
32     return results;
33 }
34
35 promise_test(async (test) => {
36     if (window.testRunner)
37         testRunner.setUserMediaPermission(true);
38
39     const stream = await navigator.mediaDevices.getUserMedia({audio: true});
40     const remoteStream = new Promise((resolve, reject) => {
41         createConnections((firstConnection) => {
42             firstConnection.addTrack(stream.getAudioTracks()[0], stream);
43         }, (secondConnection) => {
44             secondConnection.ontrack = (event) => { resolve(event.streams[0]); };
45         }, { observeOffer : (offer) => {
46             offer.sdp = setCodec(offer.sdp, "722");
47             return offer;
48         }
49         });
50         setTimeout(() => reject("Test timed out"), 5000);
51     });
52
53     const results = await checkForHumBipBop(stream);
54     assert_true(results, "heard hum bip bop");
55     context.close();
56 }, "Basic G722 audio playback through a peer connection");
57     </script>
58 </head>
59 <body>
60 </body>
61 </html>