Chromium Code Reviews| Index: third_party/WebKit/LayoutTests/webaudio/MediaStreamAudioSource/mediastreamaudiosourcenode.html |
| diff --git a/third_party/WebKit/LayoutTests/webaudio/MediaStreamAudioSource/mediastreamaudiosourcenode.html b/third_party/WebKit/LayoutTests/webaudio/MediaStreamAudioSource/mediastreamaudiosourcenode.html |
| index 588ba862661d1d8c2efa7e34a0836edbe134560f..795a7c8cc969b4d638a0d0d82becfa6a95fd5138 100644 |
| --- a/third_party/WebKit/LayoutTests/webaudio/MediaStreamAudioSource/mediastreamaudiosourcenode.html |
| +++ b/third_party/WebKit/LayoutTests/webaudio/MediaStreamAudioSource/mediastreamaudiosourcenode.html |
| @@ -2,93 +2,75 @@ |
| <html> |
| <head> |
| -<script src="../../resources/js-test.js"></script> |
| +<script src="../../resources/testharness.js"></script> |
| +<script src="../../resources/testharnessreport.js"></script> |
| <script src="../resources/audit-util.js"></script> |
| -<script src="../resources/audio-testing.js"></script> |
| +<script src="../resources/audit.js"></script> |
| </head> |
| <body> |
| -<div id="description"></div> |
| -<div id="console"></div> |
| - |
| <script> |
| -description("Basic tests for MediaStreamAudioSourceNode API."); |
| - |
| -var context = 0; |
| - |
| -function error() { |
| - testFailed('Stream generation failed.'); |
| - finishJSTest(); |
| -} |
| - |
| -function getUserMedia(dictionary, callback) { |
| - try { |
| - navigator.webkitGetUserMedia(dictionary, callback, error); |
| - } catch (e) { |
| - testFailed('webkitGetUserMedia threw exception :' + e); |
| - finishJSTest(); |
| - } |
| -} |
| - |
| -function gotStream(stream) { |
| - s = stream; |
| - testPassed('{audio:true} generated stream'); |
| - shouldBe('s.getAudioTracks().length', '1'); |
| - shouldBe('s.getVideoTracks().length', '0'); |
| - |
| - context = new AudioContext(); |
| - |
| - // Create an AudioNode from the stream. |
| - var mediaStreamSource = context.createMediaStreamSource(stream); |
| - |
| - // Check number of inputs and outputs. |
| - if (mediaStreamSource.numberOfInputs == 0) |
| - testPassed("Source AudioNode has no inputs."); |
| - else |
| - testFailed("Source AudioNode should not have inputs."); |
| - |
| - if (mediaStreamSource.numberOfOutputs == 1) |
| - testPassed("Source AudioNode has one output."); |
| - else |
| - testFailed("Source AudioNode should have one output."); |
| - |
| - // Try calling connect() method with illegal values. |
| - |
| - try { |
| - mediaStreamSource.connect(0, 0, 0); |
| - testFailed("connect() exception should be thrown for illegal destination AudioNode."); |
| - } catch(e) { |
| - testPassed("connect() exception thrown for illegal destination AudioNode."); |
| - } |
| - |
| - try { |
| - mediaStreamSource.connect(context.destination, 5, 0); |
| - testFailed("connect() exception should be thrown for illegal output index."); |
| - } catch(e) { |
| - testPassed("connect() exception thrown for illegal output index."); |
| - } |
| - |
| - try { |
| - mediaStreamSource.connect(context.destination, 0, 5); |
| - testFailed("connect() exception should be thrown for illegal input index."); |
| - } catch(e) { |
| - testPassed("connect() exception thrown for illegal input index."); |
| - } |
| - |
| - // Try calling connect() with proper values. |
| - try { |
| - mediaStreamSource.connect(context.destination, 0, 0); |
| - testPassed("mediaStreamSource.connect(context.destination) succeeded."); |
| - } catch(e) { |
| - testFailed("mediaStreamSource.connect(context.destination) failed."); |
| - } |
| - |
| - finishJSTest(); |
| +let audit = Audit.createTaskRunner(); |
| + |
| +audit.define( |
| + { |
| + label: 'test', |
| + description: 'Basic tests for MediaStreamAudioSourceNode API' |
| + }, |
| + (task, should) => { |
| + should( |
| + () => {navigator.webkitGetUserMedia( |
| + {audio: true}, |
| + (stream) => { |
| + gotStream(stream, should); |
| + task.done(); |
| + }, |
| + () => { |
| + should(false, 'Stream generation') |
| + .message('succeeded', 'failed'); |
| + task.done(); |
| + })}, |
| + 'getUserMedia()') |
| + .notThrow(); |
|
hongchan
2017/02/24 23:28:09
If clang-format did this, it is really bad. I woul
Raymond Toy
2017/02/24 23:35:30
I think it's really ugly too, but we discussed thi
hongchan
2017/02/24 23:48:18
Yes, but this getUserMedia() part really threw me
|
| + }); |
| + |
| +audit.run(); |
| + |
| +function gotStream(stream, should) { |
| + should(true, '{audio:true} generated stream').message('correctly', ''); |
| + |
| + let context = new AudioContext(); |
| + |
| + // Create an AudioNode from the stream. |
| + let mediaStreamSource = context.createMediaStreamSource(stream); |
| + |
| + // Check number of inputs and outputs. |
| + should(mediaStreamSource.numberOfInputs, 'mediaStreamSource.numberOfInputs') |
| + .beEqualTo(0); |
| + should(mediaStreamSource.numberOfOutputs, 'mediaStreamSource.numberOfOutputs') |
| + .beEqualTo(1); |
| + |
| + // Try calling connect() method with illegal values. |
| + should( |
| + () => mediaStreamSource.connect(0, 0, 0), |
| + 'mediaStreamSource.connect(0, 0, 0)') |
| + .throw(); |
| + should( |
| + () => mediaStreamSource.connect(context.destination, 5, 0), |
| + 'mediaStreamSource.connect(context.destination, 5, 0)') |
| + .throw(); |
| + should( |
| + () => mediaStreamSource.connect(context.destination, 0, 5), |
| + 'mediaStreamSource.connect(context.destination, 0, 5)') |
| + .throw(); |
| + |
| + // Try calling connect() with proper values. |
| + should( |
| + () => mediaStreamSource.connect(context.destination, 0, 0), |
| + 'mediaStreamSource.connect(context.destination, 0, 0)') |
| + .notThrow(); |
| } |
| -getUserMedia({audio:true}, gotStream); |
| -window.jsTestIsAsync = true; |
| -window.successfullyParsed = true; |
| </script> |