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

Side by Side Diff: ManualTests/webaudio/suspend-resume-2.html

Issue 1123603002: Process suspend() and resume() in call order (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Update according to review Created 5 years, 7 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 | Annotate | Revision Log
« no previous file with comments | « no previous file | Source/modules/webaudio/AudioContext.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
1 <!doctype html>
2 <html>
3 <head>
4 <title>Test suspend()resume()</title>
5 <style type="text/css">
6 header {
7 margin: 20px 0;
8 }
9 #results {
10 white-space: pre;
11 font-family: monospace;
12 }
13 </style>
14 </head>
15
16 <body>
17 <h1>Test suspend()/resume()</h1>
18
19 <p>
20 The functionality of suspend()/resume() can't currently be tested with an OfflineAudioContext,
21 so they need to be tested manually here.
22 </p>
23 <p>
24 You may want to open up a console window to see the messages, in addition to viewing the
25 messages in the Results area below.
26 </p>
27
28 <h2>Test 1</h2>
29 <p>
30 Test for <a href="crbug.com/483002">issue 483002</a>
31 </p>
32 <p>
33 Perform the following steps
34 <ol>
35 <li>
36 Start Test: you should hear a tone.
37 </li>
38 <li>
39 Run Test: This runs the test. You may press this multiple times. Eac h press should cause
40 "suspended" and "running" to be printed out in the Results section bel ow and in the
41 console.
42 </li>
43 <li>
44 End Test: Press this to end the test and stop the audio.
45 </li>
46 </ol>
47 </p>
48 <button onclick="test1Start()">Test 1: Start Test</button>
49 <button onclick="test1Run()">Test 1: Run Test</button>
50 <button onclick="test1End()">Test 1: End Test</button>
51 <br></br>
52
53 <h2>Test 2</h2>
54 <p>
55 Test for <a href="crbug.com/483269">issue 483269</a>
56 </p>
57 <p>
58 Perform the following steps
59 <ol>
60 <li>
61 Start Test: you should hear a tone. Wait a little bit before proceedi ng.
62 </li>
63 <li>
64 Run Test: You may press this multiple times. This calls suspend()/resu me() multiple times.
65 The tone should stop momentarily, but restart very quickly. You should still hear the
66 tone.
67 </li>
68 <li>
69 End Test: Stops the tone.
70 </li>
71 </ol>
72 </p>
73 <p>
74 If you do not hear a tone after running the test (but before ending), the test has failed.
75 </p>
76 <button onclick="test2Start()">Test 2: Start Test</button>
77 <button onclick="test2Run()">Test 2: Run Test </button>
78 <button onclick="test2End()">Test 2: End Test </button>
79
80 <header>Results</header>
81 <div id="results"></div>
82
83 <script>
84 var context = new AudioContext();
85 var testCount = 0;
86 var oscillator;
87
88 function test1Start() {
89 oscillator = context.createOscillator();
90 oscillator.connect(context.destination);
91 oscillator.start();
92 log("Test 1 Start");
93 }
94
95 function test1Run() {
96 testCount += 1;
97 context.suspend().then(function () {
98 log(context.state, testCount);
99 return context.resume().then(function () {
100 log(context.state, testCount);
101 }, function (e) {
102 log("Failed to resume context: " + e, testCount);
103 });
104 }, function (e) {
105 log("Failed to suspend context: " + e, testCount);
106 }).then(function () {;
107 log("Test 1 Run: should should be audible");
108 });
109 }
110
111 function test1End() {
112 oscillator.stop();
113 log("Test 1 End");
114 }
115
116 function test2Start() {
117 if (context.state === "suspended") {
118 context.resume().then(function () {},
119 function (e) { log("Failed to resume context: " + e); })
120 }
121
122 oscillator = context.createOscillator();
123 oscillator.connect(context.destination);
124 oscillator.start();
125 log("Test 2 Start");
126 }
127
128 function test2Run() {
129 context.suspend();
130 context.resume();
131 context.suspend();
132 context.suspend();
133 context.resume().then(function () {
134 if (context.state === "running") {
135 log("Test 2 Run: sound should be audible");
136 } else {
137 log("Test 2 Run: FAIL: context not running!");
138 }
139 });
140 }
141
142 function test2End() {
143 oscillator.stop();
144 log("Test 2 End");
145 }
146
147 function log(message, count) {
148 var prefix = count + ": ";
149
150 if (count === undefined)
151 prefix = "";
152 else
153 prefix = count + ": ";
154 console.log(prefix + message);
155 var results = document.querySelector("#results");
156 results.textContent += prefix + message + "\n";
157 }
158 </script>
159
160 </body>
161 </html>
OLDNEW
« no previous file with comments | « no previous file | Source/modules/webaudio/AudioContext.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698