Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(4)

Side by Side Diff: third_party/WebKit/LayoutTests/webaudio/AudioNode/audionode.html

Issue 2651623004: Convert more AudioNode tests to use testharness (Closed)
Patch Set: Rebase Created 3 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « no previous file | third_party/WebKit/LayoutTests/webaudio/AudioNode/audionode-channel-rules.html » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 <!DOCTYPE html> 1 <!DOCTYPE html>
2 2
3 <html> 3 <html>
4 <head> 4 <head>
5 <script src="../../resources/js-test.js"></script> 5 <script src="../../resources/testharness.js"></script>
6 <script src="../../resources/testharnessreport.js"></script>
6 <script src="../resources/audit-util.js"></script> 7 <script src="../resources/audit-util.js"></script>
7 <script src="../resources/audio-testing.js"></script> 8 <script src="../resources/audit.js"></script>
8 </head> 9 </head>
9 10
10 <body> 11 <body>
11 <div id="description"></div> 12 <div id="description"></div>
12 <div id="console"></div> 13 <div id="console"></div>
13 14
14 <script> 15 <script>
15 description("Basic tests for AudioNode API."); 16 let audit = Audit.createTaskRunner();
16 17
17 var context = 0; 18 let context = 0;
18 var context2 = 0; 19 let context2 = 0;
19 var context3 = 0; 20 let context3 = 0;
20 21
21 function runTest() { 22 audit.define("test", function (task, should) {
22 if (window.testRunner) { 23 task.describe("Basic tests for AudioNode API.");
23 testRunner.dumpAsText();
24 testRunner.waitUntilDone();
25 }
26
27 window.jsTestIsAsync = true;
28 24
29 context = new AudioContext(); 25 context = new AudioContext();
30 window.audioNode = context.createBufferSource(); 26 window.audioNode = context.createBufferSource();
31 27
32 // Check input and output numbers of AudioSourceNode. 28 // Check input and output numbers of AudioSourceNode.
33 if (audioNode.numberOfInputs === 0) 29 should(audioNode.numberOfInputs,
34 testPassed("Source AudioNode has no inputs."); 30 "AudioBufferSource.numberOfInputs")
hongchan 2017/01/23 21:50:56 Sorry to be picky, but the indentation is not alig
Raymond Toy 2017/01/23 22:14:42 You are supposed to be picky. This is what js-bea
35 else 31 .beEqualTo(0);
36 testFailed("Source AudioNode should not have inputs."); 32 should(audioNode.numberOfOutputs,
37 33 "AudioBufferSource.numberOfOutputs")
38 if (audioNode.numberOfOutputs === 1) 34 .beEqualTo(1);
39 testPassed("Source AudioNode has one output.");
40 else
41 testFailed("Source AudioNode should have one output.");
42 35
43 // Check input and output numbers of AudioDestinationNode 36 // Check input and output numbers of AudioDestinationNode
44 if (context.destination.numberOfInputs === 1) 37 should(context.destination.numberOfInputs,
45 testPassed("Destination AudioNode has one input."); 38 "AudioContext.destination.numberOfInputs")
46 else 39 .beEqualTo(1);
47 testFailed("Destination AudioNode should have one input."); 40 should(context.destination.numberOfOutputs,
48 41 "AudioContext.destination.numberOfOutputs")
49 if (context.destination.numberOfOutputs === 0) 42 .beEqualTo(0);
50 testPassed("Destination AudioNode has no outputs.");
51 else
52 testFailed("Destination AudioNode should have no outputs.");
53 43
54 // Try calling connect() method with illegal values. 44 // Try calling connect() method with illegal values.
55 shouldThrow('audioNode.connect(0, 0, 0)'); 45 should(() => audioNode.connect(0, 0, 0),
56 shouldThrow('audioNode.connect(null, 0, 0)'); 46 "audioNode.connect(0, 0, 0)")
57 shouldThrow('audioNode.connect(context.destination, 5, 0)'); 47 .throw("TypeError");
58 shouldThrow('audioNode.connect(context.destination, 0, 5)'); 48 should(() => audioNode.connect(null, 0, 0),
59 49 "audioNode.connect(null, 0, 0)")
60 shouldNotThrow('audioNode.connect(context.destination, 0, 0)'); 50 .throw("TypeError");
61 51 should(() => audioNode.connect(context.destination, 5, 0),
52 "audioNode.connect(context.destination, 5, 0)")
53 .throw("IndexSizeError");
54 should(() => audioNode.connect(context.destination, 0, 5),
55 "audioNode.connect(context.destination, 0, 5)")
56 .throw("IndexSizeError");
57
58 should(() => audioNode.connect(context.destination, 0, 0),
59 "audioNode.connect(context.destination, 0, 0)")
60 .notThrow();
61
62 // Create a new context and try to connect the other context's node to this one. 62 // Create a new context and try to connect the other context's node to this one.
63 try { 63 context2 = new AudioContext();
64 context2 = new AudioContext(); 64 should(() => window.audioNode.connect(context2.destination),
65 window.audioNode.connect(context2.destination); 65 "Connecting a node to a different context")
66 testFailed("exception should be thrown when connecting to other context' s node."); 66 .throw("InvalidAccessError");
67 } catch(e) {
68 testPassed("exception thrown when connecting to other context's node.");
69 }
70 67
71 // 3-arg AudioContext doesn't create an offline context anymore. 68 should(() =>
72 shouldNotThrow("context3 = new AudioContext(1, 44100, 44100)"); 69 context3 = new AudioContext(1, 44100, 44100),
hongchan 2017/01/23 21:50:56 This line needs to go up.
Raymond Toy 2017/01/23 22:14:42 Another js-beautify issue, so same comment as abov
73 if (context3 instanceof OfflineAudioContext) 70 "context3 = new AudioContext(1, 44100, 44100)")
74 testFailed("context3 should not be an OfflineAudioContext"); 71 .notThrow();
75 else 72 should(context3 instanceof OfflineAudioContext,
76 testPassed("context3 is not an OfflineAudioContext"); 73 "context3 instanceof OfflineAudioContext")
74 .beFalse();
77 75
78 // Ensure it is an EventTarget 76 // Ensure it is an EventTarget
79 try { 77 should(audioNode instanceof EventTarget,
80 audioNode.addEventListener('testEvent', function(){ 78 "AudioNode is an EventTarget")
81 testPassed("AudioNode is an EventTarget"); 79 .beTrue();
82 });
83 audioNode.dispatchEvent(new Event('testEvent'));
84 } catch(e) {
85 testFailed("exception shouldn't be thrown when testing whether audio nod e is an event target");
86 }
87 80
88 finishJSTest(); 81 task.done();
89 } 82 });
90 83
91 runTest(); 84 audit.run();
92 85
93 </script> 86 </script>
94 87
95 </body> 88 </body>
96 </html> 89 </html>
OLDNEW
« no previous file with comments | « no previous file | third_party/WebKit/LayoutTests/webaudio/AudioNode/audionode-channel-rules.html » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698