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

Side by Side Diff: third_party/WebKit/LayoutTests/webaudio/AudioContext/audiocontext-close.html

Issue 2611133003: Convert AudioContext Audit tests to testharness (Closed)
Patch Set: Address review comments. Created 3 years, 10 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/AudioContext/audiocontext-close-expected.txt » ('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 <html> 2 <html>
3 <head> 3 <head>
4 <title>Test AudioContext.close()</title> 4 <title>Test AudioContext.close()</title>
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 <script> 12 <script>
12 description("Basic functionality test of closing an AudioContext"); 13 let context;
13 window.jsTestIsAsync = true; 14 let destination;
15 let offline;
16 let osc;
17 let gain;
18 let offlinePromise;
19 let wave = new Float32Array(1);
14 20
15 var context; 21 let audit = Audit.createTaskRunner();
16 var destination;
17 var offline;
18 var osc;
19 var gain;
20 var promise1;
21 var promise2;
22 var offlinePromise;
23 var wave = new Float32Array(1);
24
25 var audit = Audit.createTaskRunner();
26 22
27 // Task: test online context (1). 23 // Task: test online context (1).
28 audit.defineTask('test-online-context-1', function (done) { 24 audit.define('test-online-context-1', function (task, should) {
29 25 task.describe("Test online context 1");
30 // Create a context and verify that the various states are correct and 26 // Create a context and verify that the various states are correct and
31 // that close() exists. 27 // that close() exists.
32 shouldNotThrow("context = new AudioContext()"); 28 should(() => context = new AudioContext(),
33 shouldBeEqualToString("context.state", "running"); 29 "context = new AudioContext()")
30 .notThrow();
31 should(context.state, "context.state")
32 .beEqualTo("running");
34 33
35 // Create gain and oscillator for testing later. 34 // Create gain and oscillator for testing later.
36 shouldNotThrow("osc = context.createOscillator()"); 35 should(() => osc = context.createOscillator(),
37 shouldNotThrow("gain = context.createGain()"); 36 "osc = context.createOscillator()")
37 .notThrow();
38 should(() => gain = context.createGain(),
39 "gain = context.createGain()")
40 .notThrow();
38 destination = context.destination; 41 destination = context.destination;
39 shouldNotThrow("gain.connect(context.destination)"); 42 should(() => gain.connect(context.destination),
43 "gain.connect(context.destination)")
44 .notThrow("");
hongchan 2017/01/23 19:42:37 Remove |""|.
Raymond Toy 2017/01/23 20:32:07 Done.
40 45
41 // Close the context. When the promise is resolved, continue the next 46 // Close the context. When the promise is resolved, continue the next
42 // test task. 47 // test task.
43 context.close().then( 48 should(context.close().then(() => {
44 function () { 49 should(() => gain.disconnect(destination),
45 testPassed("context.close() was correctly resolved"); 50 "gain.disconnect(destination) after close")
46 shouldNotThrow("gain.disconnect(destination)"); 51 .notThrow();
47 }, 52 }), "context.close()")
48 function () { 53 .beResolved()
49 testFailed("context.close() was erroneously rejected"); 54 .then(task.done.bind(this));
hongchan 2017/01/23 19:42:37 This is slightly confusing. Can we do something li
Raymond Toy 2017/01/23 20:32:07 Done.
50 }
51 ).then(done);
52
53 }); 55 });
54 56
55 // Task: test online context (2). 57 // Task: test online context (2).
56 audit.defineTask('test-online-context-2', function (done) { 58 audit.define('test-online-context-2', function (task, should) {
57 59 task.describe("Test closed online context 2");
58 // Context is closed, so verify that we cannot create any more nodes, 60 // Context is closed, so verify that we cannot create any more nodes,
59 // nor connect any. 61 // nor connect any.
60 shouldThrow("context.createAnalyser()"); 62 should(() => context.createAnalyser(), "context.createAnalyser()")
61 shouldThrow("context.createBiquadFilter()"); 63 .throw("InvalidStateError");
64 should(() => context.createBiquadFilter(),
65 "context.createBiquadFilter()")
66 .throw("InvalidStateError");
62 67
63 // createBuffer is an exception because it's not really tied in any way 68 // createBuffer is an exception because it's not really tied in any way
64 // to an audio context. And it's useful to be able to create a buffer 69 // to an audio context. And it's useful to be able to create a buffer
65 // inside the oncomplete event of an offline context to use for testing 70 // inside the oncomplete event of an offline context to use for testing
66 // purposes. 71 // purposes.
67 shouldNotThrow("context.createBuffer(1, 1, 48000)"); 72 should(() => context.createBuffer(1, 1, 48000),
73 "context.createBuffer(1, 1, 48000)")
74 .notThrow();
68 75
69 shouldThrow("context.createBufferSource()"); 76 should(() => context.createBufferSource(),
70 shouldThrow("context.createChannelMerger()"); 77 "context.createBufferSource()")
71 shouldThrow("context.createChannelSplitter()"); 78 .throw("InvalidStateError");
72 shouldThrow("context.createConvolver()"); 79 should(() => context.createChannelMerger(),
73 shouldThrow("context.createDelay()"); 80 "context.createChannelMerger()")
74 shouldThrow("context.createDynamicsCompressor()"); 81 .throw("InvalidStateError");
75 shouldThrow("context.createGain()"); 82 should(() => context.createChannelSplitter(),
76 shouldThrow("context.createOscillator()"); 83 "context.createChannelSplitter()")
77 shouldThrow("context.createPanner()"); 84 .throw("InvalidStateError");
78 shouldThrow("context.createPeriodicWave(wave, wave)"); 85 should(() => context.createConvolver(), "context.createConvolver()")
79 shouldThrow("context.createScriptProcessor()"); 86 .throw("InvalidStateError");
80 shouldThrow("context.createStereoPanner()"); 87 should(() => context.createDelay(), "context.createDelay()")
81 shouldThrow("context.createWaveShaper()"); 88 .throw("InvalidStateError");
89 should(() =>
90 context.createDynamicsCompressor(),
91 "context.createDynamicsCompressor()").throw("InvalidStateError");
92 should(() => context.createGain(), "context.createGain()").throw(
93 "InvalidStateError");
94 should(() => context.createOscillator(),
95 "context.createOscillator()")
96 .throw("InvalidStateError");
97 should(() => context.createPanner(), "context.createPanner()")
98 .throw("InvalidStateError");
99 should(() => context.createPeriodicWave(wave, wave),
100 "context.createPeriodicWave(wave, wave)")
101 .throw("InvalidStateError");
102 should(() => context.createScriptProcessor(),
103 "context.createScriptProcessor()")
104 .throw("InvalidStateError");
105 should(() =>
106 context.createStereoPanner(), "context.createStereoPanner()").throw(
107 "InvalidStateError");
108 should(() => context.createWaveShaper(),
109 "context.createWaveShaper()")
110 .throw("InvalidStateError");
82 111
83 shouldThrow("osc.connect(gain)"); 112 should(() => osc.connect(gain), "osc.connect(gain)")
84 shouldNotThrow("gain.disconnect()"); 113 .throw("InvalidStateError");
114 should(() => gain.disconnect(), "gain.disconnect()").notThrow();
85 115
86 // Can't resume a context that is closed (released). 116 // Can't resume a context that is closed (released).
87 context.resume().then( 117 should(context.resume(), "context.resume()")
88 function () { 118 .beRejected()
89 testFailed("Attempt to resume a closed context erroneously succeeded") ; 119 .then(task.done.bind(task));
90 },
91 function () {
92 testPassed("Attempt to resume a closed context was correctly rejected" );
93 }
94 ).then(done);
95 }); 120 });
96 121
97 // Task: test online context (3). 122 // Task: test online context (3).
98 audit.defineTask('test-online-context-3', function (done) { 123 audit.define('test-online-context-3', function (task, should) {
99 124 task.describe("Close an online context again");
100 // Try closing the context again. The promise should be rejected. 125 // Try closing the context again. The promise should be rejected.
101 context.close().then( 126 should(context.close(), "context.close() again")
102 function () { 127 .beRejected()
103 testFailed("Closing context again erroneously resolved successfully.") ; 128 .then(() => {
104 }, 129 // Finally, run GC. The context should be gone, but this seems
105 function () { 130 // difficult to verify.
106 testPassed("Closing context again correctly rejected promise."); 131 if (window.gc)
107 // Finally, run GC. The context should be gone, but this seems difficu lt to verify. 132 gc();
108 gc(); 133 should(context.destination, "context.destination")
109 shouldBeNull("context.destination"); 134 .beEqualTo(null);
110 } 135 })
111 ).then(done); 136 .then(task.done.bind(task));
112 }); 137 });
113 138
114 // Task: test offline context (1). 139 // Task: test offline context (1).
115 audit.defineTask('test-offline-context-1', function (done) { 140 audit.define('test-offline-context-1', function (task, should) {
116 141 task.describe("Test offline context");
117 // For an offline context, verify that close is not defined. 142 // For an offline context, verify that close is not defined.
118 shouldNotThrow("offline = new OfflineAudioContext(1, 1000, 48000)"); 143 should(() => offline = new OfflineAudioContext(1, 1000, 48000),
119 shouldBeEqualToString("offline.state", "suspended"); 144 "offline = new OfflineAudioContext(1, 1000, 48000)")
120 shouldBeUndefined("offline.close"); 145 .notThrow();
121 done(); 146 should(offline.state, "offline.state")
147 .beEqualTo("suspended");
148 should(offline.close, "offline.close")
149 .beEqualTo(undefined);
150 task.done();
122 }); 151 });
123 152
124 audit.defineTask('finish-test', function (done) { 153 audit.run();
125 done();
126 finishJSTest();
127 });
128
129 audit.runTasks();
130
131 successfullyParsed = true;
132 </script> 154 </script>
133 </body> 155 </body>
134 </html> 156 </html>
OLDNEW
« no previous file with comments | « no previous file | third_party/WebKit/LayoutTests/webaudio/AudioContext/audiocontext-close-expected.txt » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698