| 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 import 'dart:async'; |
| 6 | 7 |
| 7 main() { | 8 main() { |
| 8 | 9 |
| 9 useHtmlConfiguration(); | 10 useHtmlConfiguration(); |
| 10 | 11 |
| 11 var isAudioContext = | 12 var isAudioContext = |
| 12 predicate((x) => x is AudioContext, 'is an AudioContext'); | 13 predicate((x) => x is AudioContext, 'is an AudioContext'); |
| 13 | 14 |
| 14 test('constructorTest', () { | 15 test('constructorTest', () { |
| 15 var ctx = new AudioContext(); | 16 var ctx = new AudioContext(); |
| (...skipping 18 matching lines...) Expand all Loading... |
| 34 gainNode.connect(context.destination, 0, 0); | 35 gainNode.connect(context.destination, 0, 0); |
| 35 expect(gainNode is GainNode, isTrue); | 36 expect(gainNode is GainNode, isTrue); |
| 36 | 37 |
| 37 expect(context.createAnalyser() is AnalyserNode, isTrue); | 38 expect(context.createAnalyser() is AnalyserNode, isTrue); |
| 38 expect(context.createChannelMerger() is ChannelMergerNode, isTrue); | 39 expect(context.createChannelMerger() is ChannelMergerNode, isTrue); |
| 39 expect(context.createChannelSplitter() is ChannelSplitterNode, isTrue); | 40 expect(context.createChannelSplitter() is ChannelSplitterNode, isTrue); |
| 40 expect(context.createOscillator() is OscillatorNode, isTrue); | 41 expect(context.createOscillator() is OscillatorNode, isTrue); |
| 41 expect(context.createPanner() is PannerNode, isTrue); | 42 expect(context.createPanner() is PannerNode, isTrue); |
| 42 expect(context.createScriptProcessor(4096) is ScriptProcessorNode, isTrue); | 43 expect(context.createScriptProcessor(4096) is ScriptProcessorNode, isTrue); |
| 43 }); | 44 }); |
| 45 |
| 46 test('onAudioProcess', () { |
| 47 var context = new AudioContext(); |
| 48 var scriptProcessor = context.createScriptProcessor(1024, 1, 2); |
| 49 scriptProcessor.connect(context.destination, 0, 0); |
| 50 var completer = new Completer<bool>(); |
| 51 bool alreadyCalled = false; |
| 52 scriptProcessor.onAudioProcess = (event) { |
| 53 if (!alreadyCalled) { |
| 54 completer.complete(true); |
| 55 } |
| 56 alreadyCalled = true; |
| 57 }; |
| 58 return completer.future; |
| 59 }); |
| 44 } | 60 } |
| OLD | NEW |