OLD | NEW |
1 library AudioContextTest; | 1 library AudioContextTest; |
2 import '../../pkg/unittest/lib/unittest.dart'; | 2 import '../../pkg/unittest/lib/unittest.dart'; |
3 import '../../pkg/unittest/lib/html_config.dart'; | 3 import '../../pkg/unittest/lib/html_config.dart'; |
4 import 'dart:html'; | 4 import 'dart:html'; |
5 import 'dart:web_audio'; | 5 import 'dart:web_audio'; |
6 | 6 |
7 main() { | 7 main() { |
8 | 8 |
9 useHtmlConfiguration(); | 9 useHtmlConfiguration(); |
10 | 10 |
11 var isAudioContext = | 11 var isAudioContext = |
12 predicate((x) => x is AudioContext, 'is an AudioContext'); | 12 predicate((x) => x is AudioContext, 'is an AudioContext'); |
13 | 13 |
14 test('constructorTest', () { | 14 test('constructorTest', () { |
15 var ctx = new AudioContext(); | 15 var ctx = new AudioContext(); |
16 expect(ctx, isNotNull); | 16 expect(ctx, isNotNull); |
17 expect(ctx, isAudioContext); | 17 expect(ctx, isAudioContext); |
18 }); | 18 }); |
19 test('createBuffer', () { | 19 test('createBuffer', () { |
20 var ctx = new AudioContext(); | 20 var ctx = new AudioContext(); |
21 ArrayBufferView arrayBufferView = new Float32Array.fromList([]); | 21 ArrayBufferView arrayBufferView = new Float32Array.fromList([]); |
22 try { | 22 try { |
23 // Test that native overload is chosen correctly. Native implementation | 23 // Test that native overload is chosen correctly. Native implementation |
24 // should throw 'SYNTAX_ERR' DOMException because the buffer is empty. | 24 // should throw 'SYNTAX_ERR' DomException because the buffer is empty. |
25 AudioBuffer buffer = ctx.createBuffer(arrayBufferView.buffer, false); | 25 AudioBuffer buffer = ctx.createBuffer(arrayBufferView.buffer, false); |
26 } catch (e) { | 26 } catch (e) { |
27 expect(e.code, equals(DOMException.SYNTAX_ERR)); | 27 expect(e.code, equals(DomException.SYNTAX_ERR)); |
28 } | 28 } |
29 }); | 29 }); |
30 | 30 |
31 test('audioRenames', () { | 31 test('audioRenames', () { |
32 AudioContext context = new AudioContext(); | 32 AudioContext context = new AudioContext(); |
33 GainNode gainNode = context.createGain(); | 33 GainNode gainNode = context.createGain(); |
34 gainNode.connect(context.destination, 0, 0); | 34 gainNode.connect(context.destination, 0, 0); |
35 expect(gainNode is GainNode, isTrue); | 35 expect(gainNode is GainNode, isTrue); |
36 | 36 |
37 expect(context.createAnalyser() is AnalyserNode, isTrue); | 37 expect(context.createAnalyser() is AnalyserNode, isTrue); |
38 expect(context.createChannelMerger() is ChannelMergerNode, isTrue); | 38 expect(context.createChannelMerger() is ChannelMergerNode, isTrue); |
39 expect(context.createChannelSplitter() is ChannelSplitterNode, isTrue); | 39 expect(context.createChannelSplitter() is ChannelSplitterNode, isTrue); |
40 expect(context.createOscillator() is OscillatorNode, isTrue); | 40 expect(context.createOscillator() is OscillatorNode, isTrue); |
41 expect(context.createPanner() is PannerNode, isTrue); | 41 expect(context.createPanner() is PannerNode, isTrue); |
42 expect(context.createScriptProcessor(4096) is ScriptProcessorNode, isTrue); | 42 expect(context.createScriptProcessor(4096) is ScriptProcessorNode, isTrue); |
43 }); | 43 }); |
44 } | 44 } |
OLD | NEW |