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_individual_config.dart'; | 3 import '../../pkg/unittest/lib/html_individual_config.dart'; |
4 import 'dart:html'; | 4 import 'dart:html'; |
5 import 'dart:typed_data'; | 5 import 'dart:typed_data'; |
6 import 'dart:web_audio'; | 6 import 'dart:web_audio'; |
7 import 'dart:async'; | 7 import 'dart:async'; |
8 | 8 |
9 main() { | 9 main() { |
10 | 10 |
(...skipping 18 matching lines...) Expand all Loading... |
29 }); | 29 }); |
30 | 30 |
31 test('createBuffer', () { | 31 test('createBuffer', () { |
32 if(AudioContext.supported) { | 32 if(AudioContext.supported) { |
33 var ctx = new AudioContext(); | 33 var ctx = new AudioContext(); |
34 Float32List view = new Float32List.fromList([]); | 34 Float32List view = new Float32List.fromList([]); |
35 try { | 35 try { |
36 // Test that native overload is chosen correctly. Native | 36 // Test that native overload is chosen correctly. Native |
37 // implementation should throw 'SyntaxError' DomException because the | 37 // implementation should throw 'SyntaxError' DomException because the |
38 // buffer is empty. | 38 // buffer is empty. |
39 AudioBuffer buffer = ctx.createBuffer(view.buffer, false); | 39 AudioBuffer buffer = ctx.createBufferFromBuffer(view.buffer, false); |
40 } catch (e) { | 40 } catch (e) { |
41 expect(e.name, DomException.SYNTAX); | 41 expect(e.name, DomException.SYNTAX); |
42 } | 42 } |
43 } | 43 } |
44 }); | 44 }); |
45 | 45 |
46 test('audioRenames', () { | 46 test('audioRenames', () { |
47 if(AudioContext.supported) { | 47 if(AudioContext.supported) { |
48 AudioContext context = new AudioContext(); | 48 AudioContext context = new AudioContext(); |
49 GainNode gainNode = context.createGain(); | 49 GainNode gainNode = context.createGain(); |
50 gainNode.connect(context.destination, 0, 0); | 50 gainNode.connectNode(context.destination); |
51 expect(gainNode is GainNode, isTrue); | 51 expect(gainNode is GainNode, isTrue); |
52 | 52 |
53 expect(context.createAnalyser() is AnalyserNode, isTrue); | 53 expect(context.createAnalyser() is AnalyserNode, isTrue); |
54 expect(context.createChannelMerger() is AudioNode, isTrue); | 54 expect(context.createChannelMerger() is AudioNode, isTrue); |
55 expect(context.createChannelSplitter() is AudioNode, isTrue); | 55 expect(context.createChannelSplitter() is AudioNode, isTrue); |
56 expect(context.createOscillator() is OscillatorNode, isTrue); | 56 expect(context.createOscillator() is OscillatorNode, isTrue); |
57 expect(context.createPanner() is PannerNode, isTrue); | 57 expect(context.createPanner() is PannerNode, isTrue); |
58 expect(context.createScriptProcessor(4096) is ScriptProcessorNode, | 58 expect(context.createScriptProcessor(4096) is ScriptProcessorNode, |
59 isTrue); | 59 isTrue); |
60 } | 60 } |
61 }); | 61 }); |
62 | 62 |
63 test('onAudioProcess', () { | 63 test('onAudioProcess', () { |
64 if(AudioContext.supported) { | 64 if(AudioContext.supported) { |
65 var completer = new Completer<bool>(); | 65 var completer = new Completer<bool>(); |
66 var context = new AudioContext(); | 66 var context = new AudioContext(); |
67 var scriptProcessor = context.createScriptProcessor(1024, 1, 2); | 67 var scriptProcessor = context.createScriptProcessor(1024, 1, 2); |
68 scriptProcessor.connect(context.destination, 0, 0); | 68 scriptProcessor.connectNode(context.destination); |
69 bool alreadyCalled = false; | 69 bool alreadyCalled = false; |
70 scriptProcessor.onAudioProcess.listen((event) { | 70 scriptProcessor.onAudioProcess.listen((event) { |
71 if (!alreadyCalled) { | 71 if (!alreadyCalled) { |
72 completer.complete(true); | 72 completer.complete(true); |
73 } | 73 } |
74 alreadyCalled = true; | 74 alreadyCalled = true; |
75 }); | 75 }); |
76 return completer.future; | 76 return completer.future; |
77 } | 77 } |
78 }); | 78 }); |
79 }); | 79 }); |
80 } | 80 } |
OLD | NEW |