OLD | NEW |
---|---|
1 library AudioContextTest; | 1 library AudioContextTest; |
2 import 'package:unittest/unittest.dart'; | 2 import 'package:unittest/unittest.dart'; |
3 import 'package:unittest/html_individual_config.dart'; | 3 import 'package:unittest/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 |
11 useHtmlIndividualConfiguration(); | 11 useHtmlIndividualConfiguration(); |
12 | 12 |
13 var isAudioContext = | 13 var isAudioContext = |
14 predicate((x) => x is AudioContext, 'is an AudioContext'); | 14 predicate((x) => x is AudioContext, 'is an AudioContext'); |
15 | 15 |
16 group('supported', () { | 16 group('supported', () { |
17 test('supported', () { | 17 test('supported', () { |
18 expect(AudioContext.supported, true); | 18 expect(AudioContext.supported, true); |
19 }); | 19 }); |
20 }); | 20 }); |
21 | 21 |
22 group('functional', () { | 22 group('functional', () { |
23 var context; | |
terry
2015/01/23 19:58:09
This doesn't need to be broken out? Assumed this
Alan Knight
2015/01/23 20:15:01
When I made too many different tests you started g
| |
24 if (AudioContext.supported) { | |
25 context = new AudioContext(); | |
26 } | |
27 | |
23 test('constructorTest', () { | 28 test('constructorTest', () { |
24 if(AudioContext.supported) { | 29 if(AudioContext.supported) { |
25 var ctx = new AudioContext(); | 30 expect(context, isNotNull); |
26 expect(ctx, isNotNull); | 31 expect(context, isAudioContext); |
27 expect(ctx, isAudioContext); | |
28 } | 32 } |
29 }); | 33 }); |
30 | 34 |
31 test('audioRenames', () { | 35 test('audioRenames', () { |
32 if(AudioContext.supported) { | 36 if(AudioContext.supported) { |
33 AudioContext context = new AudioContext(); | |
34 GainNode gainNode = context.createGain(); | 37 GainNode gainNode = context.createGain(); |
35 gainNode.connectNode(context.destination); | 38 gainNode.connectNode(context.destination); |
36 expect(gainNode is GainNode, isTrue); | 39 expect(gainNode is GainNode, isTrue); |
37 | 40 |
38 expect(context.createAnalyser() is AnalyserNode, isTrue); | 41 expect(context.createAnalyser() is AnalyserNode, isTrue); |
39 expect(context.createChannelMerger() is AudioNode, isTrue); | 42 expect(context.createChannelMerger() is AudioNode, isTrue); |
40 expect(context.createChannelSplitter() is AudioNode, isTrue); | 43 expect(context.createChannelSplitter() is AudioNode, isTrue); |
41 expect(context.createOscillator() is OscillatorNode, isTrue); | 44 expect(context.createOscillator() is OscillatorNode, isTrue); |
42 expect(context.createPanner() is PannerNode, isTrue); | 45 expect(context.createPanner() is PannerNode, isTrue); |
43 expect(context.createScriptProcessor(4096) is ScriptProcessorNode, | 46 expect(context.createScriptProcessor(4096) is ScriptProcessorNode, |
(...skipping 16 matching lines...) Expand all Loading... | |
60 } | 63 } |
61 alreadyCalled = true; | 64 alreadyCalled = true; |
62 }); | 65 }); |
63 return completer.future; | 66 return completer.future; |
64 } | 67 } |
65 }); | 68 }); |
66 */ | 69 */ |
67 | 70 |
68 test('oscillatorTypes', () { | 71 test('oscillatorTypes', () { |
69 if(AudioContext.supported) { | 72 if(AudioContext.supported) { |
70 AudioContext context = new AudioContext(); | |
71 OscillatorNode oscillator = context.createOscillator(); | 73 OscillatorNode oscillator = context.createOscillator(); |
72 oscillator.connectNode(context.destination); | 74 oscillator.connectNode(context.destination); |
73 | 75 |
74 oscillator.type = 'sawtooth'; | 76 oscillator.type = 'sawtooth'; |
75 expect(oscillator.type, equals('sawtooth')); | 77 expect(oscillator.type, equals('sawtooth')); |
76 | 78 |
77 oscillator.type = 'sine'; | 79 oscillator.type = 'sine'; |
78 expect(oscillator.type, equals('sine')); | 80 expect(oscillator.type, equals('sine')); |
79 | 81 |
80 oscillator.type = 'square'; | 82 oscillator.type = 'square'; |
81 expect(oscillator.type, equals('square')); | 83 expect(oscillator.type, equals('square')); |
82 | 84 |
83 oscillator.type = 'triangle'; | 85 oscillator.type = 'triangle'; |
84 expect(oscillator.type, equals('triangle')); | 86 expect(oscillator.type, equals('triangle')); |
85 | 87 |
86 //expect(() => oscillator.type = 7, throws); Firefox does not throw, it | 88 //expect(() => oscillator.type = 7, throws); Firefox does not throw, it |
87 //simply ignores this value. | 89 //simply ignores this value. |
88 expect(oscillator.type, equals('triangle')); | 90 expect(oscillator.type, equals('triangle')); |
89 | 91 |
90 // Firefox does not throw when it receives invalid values; it simply | 92 // Firefox does not throw when it receives invalid values; it simply |
91 // ignores them. | 93 // ignores them. |
92 //expect(() => oscillator.type = ['heap object not a string'], throws); | 94 //expect(() => oscillator.type = ['heap object not a string'], throws); |
93 expect(oscillator.type, equals('triangle')); | 95 expect(oscillator.type, equals('triangle')); |
94 } | 96 } |
95 }); | 97 }); |
96 }); | 98 }); |
97 } | 99 } |
OLD | NEW |