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

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

Issue 2616623006: Convert audiocontext-close-basic and max-contexts to testharness (Closed)
Patch Set: Clean up 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/AudioContext/audiocontext-close-basic-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() closes many contexts</title> 4 <title>Test AudioContext.close() closes many contexts</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("Test that closing a context releases the audio HW context"); 13 let audit = Audit.createTaskRunner();
13 14
14 var context = null; 15 let context = null;
15 16
16 // The number of contexts we want to create and close. 17 // The number of contexts we want to create and close.
17 var MAX_ITERATION = 100; 18 let MAX_ITERATION = 100;
18 var counter = 0; 19 let counter = 0;
19 20
20 function createContextAndClose() { 21 function createContextAndClose(task, should) {
21 // Bypass the first iteration. 22 // Bypass the first iteration.
22 if (context) { 23 if (context) {
23 if (context.state != "closed") { 24 should(context.state, "context.state for closed context " + counter)
24 testFailed("Context " + counter + " was closed but state is not clos ed: " + context.state); 25 .beEqualTo("closed");
25 }
26 context = null; 26 context = null;
27 } 27 }
28 // Create new context and close. 28 // Create new context and close.
29 context = new AudioContext(); 29 context = new AudioContext();
30 if (counter++ < MAX_ITERATION) { 30 if (counter++ < MAX_ITERATION) {
31 // Recursive promise resolution. 31 // Recursive promise resolution.
32 context.close().then(createContextAndClose, onFailure); 32 context.close().then(function () {
33 createContextAndClose(task, should);
34 }, function () {
35 onFailure(should);
36 task.done();
37 });
33 } else { 38 } else {
34 context.close() 39 context.close()
35 .then(function () { 40 .then(function () {
36 testPassed("Successfully created and closed " + MAX_ITE RATION + " contexts"); 41 // |counter| is one more than MAX_ITERATION if we
37 finishJSTest(); 42 // succeeded.
38 }); 43 should(counter - 1,
44 "Number of contexts successfully created and closed")
45 .beEqualTo(MAX_ITERATION);
46 task.done();
47 });
39 } 48 }
40 } 49 }
41 50
42 function onFailure(message) { 51 function onFailure(should) {
43 testFailed("Context " + counter + " failed to close"); 52 should(context.state, "Context " + counter + "failed to close")
44 finishJSTest(); 53 .beEqualTo("closed");
45 } 54 }
46 55
47 // Initiate iteration. 56 audit.define("test", function (task, should) {
48 function runTest() { 57 task.describe("Test that closing a context releases the audio HW context ");
49 window.jsTestIsAsync = true; 58 createContextAndClose(task, should);
50 createContextAndClose(); 59 });
51 }
52 60
53 runTest(); 61 audit.run();
54 </script> 62 </script>
55 </body> 63 </body>
56 </html> 64 </html>
OLDNEW
« no previous file with comments | « no previous file | third_party/WebKit/LayoutTests/webaudio/AudioContext/audiocontext-close-basic-expected.txt » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698