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

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

Issue 2708953003: Move task.describe descriptions to audit.define (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
OLDNEW
1 <!doctype html> 1 <!doctype html>
2 <html> 2 <html>
3 <head> 3 <head>
4 <title>Test AudioContext.suspend() and AudioContext.resume()</title> 4 <title>Test AudioContext.suspend() and AudioContext.resume()</title>
5 <script src="../../resources/testharness.js"></script> 5 <script src="../../resources/testharness.js"></script>
6 <script src="../../resources/testharnessreport.js"></script> 6 <script src="../../resources/testharnessreport.js"></script>
7 <script src="../resources/audit-util.js"></script> 7 <script src="../resources/audit-util.js"></script>
8 <script src="../resources/audit.js"></script> 8 <script src="../resources/audit.js"></script>
9 </head> 9 </head>
10 10
11 <body> 11 <body>
12 <script> 12 <script>
13 let offlineContext; 13 let offlineContext;
14 let osc; 14 let osc;
15 let p1; 15 let p1;
16 let p2; 16 let p2;
17 let p3; 17 let p3;
18 18
19 let sampleRate = 44100; 19 let sampleRate = 44100;
20 let durationInSeconds = 1; 20 let durationInSeconds = 1;
21 21
22 let audit = Audit.createTaskRunner(); 22 let audit = Audit.createTaskRunner();
23 23
24 // Task: test suspend(). 24 // Task: test suspend().
25 audit.define('test-suspend', function (task, should) { 25 audit.define({
26 task.describe("Test suspend() for offline context"); 26 label: 'test-suspend',
27 description: "Test suspend() for offline context"
28 }, function (task, should) {
27 // Test suspend/resume. Ideally this test is best with a online 29 // Test suspend/resume. Ideally this test is best with a online
28 // AudioContext, but content shell doesn't really have a working online 30 // AudioContext, but content shell doesn't really have a working online
29 // AudioContext. Hence, use an OfflineAudioContext. Not all possible 31 // AudioContext. Hence, use an OfflineAudioContext. Not all possible
30 // scenarios can be easily checked with an offline context instead of an 32 // scenarios can be easily checked with an offline context instead of an
31 // online context. 33 // online context.
32 34
33 // Create an audio context with an oscillator. 35 // Create an audio context with an oscillator.
34 should(() => { 36 should(() => {
35 offlineContext = new OfflineAudioContext(1, durationInSeconds * 37 offlineContext = new OfflineAudioContext(1, durationInSeconds *
36 sampleRate, sampleRate); 38 sampleRate, sampleRate);
(...skipping 19 matching lines...) Expand all
56 should(p1 instanceof Promise, "p1 instanceof Promise") 58 should(p1 instanceof Promise, "p1 instanceof Promise")
57 .beTrue(); 59 .beTrue();
58 60
59 should(p1, "p1") 61 should(p1, "p1")
60 .beRejected() 62 .beRejected()
61 .then(task.done.bind(task)); 63 .then(task.done.bind(task));
62 }); 64 });
63 65
64 66
65 // Task: test resume(). 67 // Task: test resume().
66 audit.define('test-resume', function (task, should) { 68 audit.define({
67 task.describe("Test resume() for offline context"); 69 label: 'test-resume',
70 description: "Test resume() for offline context"
71 }, function (task, should) {
68 // Multiple calls to resume should not be a problem. But we can't test 72 // Multiple calls to resume should not be a problem. But we can't test
69 // that on an offline context. Thus, check that resume() on an 73 // that on an offline context. Thus, check that resume() on an
70 // OfflineAudioContext rejects the promise. 74 // OfflineAudioContext rejects the promise.
71 should(() => p2 = offlineContext.resume(), 75 should(() => p2 = offlineContext.resume(),
72 "p2 = offlineContext.resume()") 76 "p2 = offlineContext.resume()")
73 .notThrow(); 77 .notThrow();
74 should(p2 instanceof Promise, "p2 instanceof Promise") 78 should(p2 instanceof Promise, "p2 instanceof Promise")
75 .beTrue(); 79 .beTrue();
76 80
77 // Resume doesn't actually resume an offline context 81 // Resume doesn't actually resume an offline context
78 should(offlineContext.state, "offlineContext.state") 82 should(offlineContext.state, "offlineContext.state")
79 .beEqualTo("suspended"); 83 .beEqualTo("suspended");
80 should(p2, "p2") 84 should(p2, "p2")
81 .beRejected() 85 .beRejected()
82 .then(task.done.bind(task)); 86 .then(task.done.bind(task));
83 }); 87 });
84 88
85 // Task: test the state after context closed. 89 // Task: test the state after context closed.
86 audit.define('test-after-close', function (task, should) { 90 audit.define({
87 task.describe("Test state after context closed"); 91 label: 'test-after-close',
92 description: "Test state after context closed"
93 }, function (task, should) {
88 // Render the offline context. 94 // Render the offline context.
89 osc.start(); 95 osc.start();
90 96
91 // Test suspend/resume in tested promise pattern. We don't care about the 97 // Test suspend/resume in tested promise pattern. We don't care about the
92 // actual result of the offline rendering. 98 // actual result of the offline rendering.
93 should(() => p3 = offlineContext.startRendering(), 99 should(() => p3 = offlineContext.startRendering(),
94 "p3 = offlineContext.startRendering()") 100 "p3 = offlineContext.startRendering()")
95 .notThrow(); 101 .notThrow();
96 102
97 p3.then(() => { 103 p3.then(() => {
(...skipping 10 matching lines...) Expand all
108 .beRejected() 114 .beRejected()
109 .then(task.done.bind(task)); 115 .then(task.done.bind(task));
110 }) 116 })
111 }); 117 });
112 }); 118 });
113 119
114 audit.run(); 120 audit.run();
115 </script> 121 </script>
116 </body> 122 </body>
117 </html> 123 </html>
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698