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

Side by Side Diff: third_party/WebKit/LayoutTests/webaudio/OfflineAudioContext/offlineaudiocontext-constructor.html

Issue 2680033002: Convert OfflineAudioContext tests to testharness (Closed)
Patch Set: Reindent. 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 <script src="../../resources/js-test.js"></script> 4 <script src="../../resources/testharness.js"></script>
5 <script src="../../resources/testharnessreport.js"></script>
6 <script src="../resources/audit.js"></script>
5 </head> 7 </head>
6 <body> 8 <body>
7 <script> 9 <script>
8 description("Tests the OfflineAudioContext constructor"); 10 let audit = Audit.createTaskRunner();
9 11
10 var context; 12 audit.define('test', (task, should) => {
11 // Make sure we don't crash when giving 0 as number of frames. 13 task.describe('OfflineAudioContext constructor');
12 shouldThrow("new OfflineAudioContext(1, 0, 44100)"); 14 let context;
13 // Make sure we don't throw exceptions for supported ranges of sample rates for an OfflineAudioContext. 15 // Make sure we don't crash when giving 0 as number of frames.
14 shouldThrow("context = new OfflineAudioContext(2, 512, 2999)"); 16 should(
15 shouldNotThrow("context = new OfflineAudioContext(2, 512, 3000)"); 17 () => new OfflineAudioContext(1, 0, 44100),
16 shouldBeEqualToNumber("context.length", 512); 18 'new OfflineAudioContext(1, 0, 44100)')
17 shouldNotThrow("context = new OfflineAudioContext(2, 1024, 384000)"); 19 .throw();
18 shouldBeEqualToNumber("context.length", 1024); 20 // Make sure we don't throw exceptions for supported ranges of sample rates
19 shouldThrow("context = new OfflineAudioContext(2, 1024, 384001)"); 21 // for an OfflineAudioContext.
20 shouldNotThrow("context = new OfflineAudioContext(2, 2048, 8000)"); 22 should(
21 shouldBeEqualToNumber("context.length", 2048); 23 () => context = new OfflineAudioContext(2, 512, 2999),
22 shouldNotThrow("context = new OfflineAudioContext(2, 4096, 11025)"); 24 'context = new OfflineAudioContext(2, 512, 2999)')
23 shouldBeEqualToNumber("context.length", 4096); 25 .throw();
24 shouldNotThrow("context = new OfflineAudioContext(2, 512, 22050)"); 26 should(
25 shouldBeEqualToNumber("context.length", 512); 27 () => context = new OfflineAudioContext(2, 512, 3000),
26 shouldNotThrow("context = new OfflineAudioContext(2, 512, 44100)"); 28 'context = new OfflineAudioContext(2, 512, 3000)')
27 shouldBeEqualToNumber("context.length", 512); 29 .notThrow();
28 shouldNotThrow("context = new OfflineAudioContext(2, 512, 48000)"); 30 should(context.length, 'context.length').beEqualTo(512);
29 shouldBeEqualToNumber("context.length", 512); 31 should(
30 shouldNotThrow("context = new OfflineAudioContext(2, 512, 88200)"); 32 () => context = new OfflineAudioContext(2, 1024, 384000),
31 shouldBeEqualToNumber("context.length", 512); 33 'context = new OfflineAudioContext(2, 1024, 384000)')
32 // Make sure length is read-only. 34 .notThrow();
33 shouldNotThrow("context.length = 99"); 35 should(context.length, 'context.length').beEqualTo(1024);
34 shouldBeEqualToNumber("context.length", 512); 36 should(
35 shouldNotThrow("context = new OfflineAudioContext(2, 512, 96000)"); 37 () => context = new OfflineAudioContext(2, 1024, 384001),
36 // Make sure we throw exceptions for non-finite sample rates. 38 'context = new OfflineAudioContext(2, 1024, 384001)')
37 shouldThrow("context = new OfflineAudioContext(1, 0, NaN)"); 39 .throw();
38 shouldThrow("context = new OfflineAudioContext(1, 0, Infinity)"); 40 should(
39 // Verify channel counts and other destination attributes are set correctly. 41 () => context = new OfflineAudioContext(2, 2048, 8000),
40 shouldNotThrow("context = new OfflineAudioContext(7, 512, 48000)"); 42 'context = new OfflineAudioContext(2, 2048, 8000)')
41 shouldBeEqualToNumber("context.destination.channelCount", 7); 43 .notThrow();
42 shouldBeEqualToNumber("context.destination.maxChannelCount", 7); 44 should(context.length, 'context.length').beEqualTo(2048);
43 shouldBeEqualToString("context.destination.channelCountMode", "explicit"); 45 should(
44 shouldBeEqualToString("context.destination.channelInterpretation", "speakers"); 46 () => context = new OfflineAudioContext(2, 4096, 11025),
47 'context = new OfflineAudioContext(2, 4096, 11025)')
48 .notThrow();
49 should(context.length, 'context.length').beEqualTo(4096);
50 should(
51 () => context = new OfflineAudioContext(2, 512, 22050),
52 'context = new OfflineAudioContext(2, 512, 22050)')
53 .notThrow();
54 should(context.length, 'context.length').beEqualTo(512);
55 should(
56 () => context = new OfflineAudioContext(2, 512, 44100),
57 'context = new OfflineAudioContext(2, 512, 44100)')
58 .notThrow();
59 should(context.length, 'context.length').beEqualTo(512);
60 should(
61 () => context = new OfflineAudioContext(2, 512, 48000),
62 'context = new OfflineAudioContext(2, 512, 48000)')
63 .notThrow();
64 should(context.length, 'context.length').beEqualTo(512);
65
66 should(
67 () => context = new OfflineAudioContext(2, 512, 88200),
68 'context = new OfflineAudioContext(2, 512, 88200)')
69 .notThrow();
70 should(context.length, 'context.length').beEqualTo(512);
71
72 // Make sure length is read-only.
73 should(() => context.length = 99, 'context.length = 99').notThrow();
74 should(context.length, 'context.length').beEqualTo(512);
75 should(
76 () => context = new OfflineAudioContext(2, 512, 96000),
77 'context = new OfflineAudioContext(2, 512, 96000)')
78 .notThrow();
79 // Make sure we throw exceptions for non-finite sample rates.
80 should(
81 () => context = new OfflineAudioContext(1, 0, NaN),
82 'context = new OfflineAudioContext(1, 0, NaN)')
83 .throw();
84 should(
85 () => context = new OfflineAudioContext(1, 0, Infinity),
86 'context = new OfflineAudioContext(1, 0, Infinity)')
87 .throw();
88 // Verify channel counts and other destination attributes are set correctly.
89 should(
90 () => context = new OfflineAudioContext(7, 512, 48000),
91 'context = new OfflineAudioContext(7, 512, 48000)')
92 .notThrow();
93 should(context.destination.channelCount, 'context.destination.channelCount')
94 .beEqualTo(7);
95 should(
96 context.destination.maxChannelCount,
97 'context.destination.maxChannelCount')
98 .beEqualTo(7);
99 should(
100 context.destination.channelCountMode,
101 'context.destination.channelCountMode')
102 .beEqualTo('explicit');
103 should(
104 context.destination.channelInterpretation,
105 'context.destination.channelInterpretation')
106 .beEqualTo('speakers');
107
108 task.done();
109 });
110
111 audit.run();
45 </script> 112 </script>
46 </body> 113 </body>
47 </html> 114 </html>
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698