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

Side by Side Diff: tests/html/audiocontext_test.dart

Issue 11510013: Making ScriptProcessorNode not an EventTarget. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 7 years, 9 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 | Annotate | Revision Log
OLDNEW
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_individual_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 useHtmlIndividualConfiguration();
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 group('supported', () {
15 var ctx = new AudioContext(); 16 test('supported', () {
16 expect(ctx, isNotNull); 17 expect(AudioContext.supported, true);
17 expect(ctx, isAudioContext); 18 });
18 });
19 test('createBuffer', () {
20 var ctx = new AudioContext();
21 ArrayBufferView arrayBufferView = new Float32Array.fromList([]);
22 try {
23 // Test that native overload is chosen correctly. Native implementation
24 // should throw 'SyntaxError' DomException because the buffer is empty.
25 AudioBuffer buffer = ctx.createBuffer(arrayBufferView.buffer, false);
26 } catch (e) {
27 expect(e.name, DomException.SYNTAX);
28 }
29 }); 19 });
30 20
31 test('audioRenames', () { 21 group('functional', () {
32 AudioContext context = new AudioContext(); 22 test('constructorTest', () {
33 GainNode gainNode = context.createGain(); 23 if(AudioContext.supported) {
34 gainNode.connect(context.destination, 0, 0); 24 var ctx = new AudioContext();
35 expect(gainNode is GainNode, isTrue); 25 expect(ctx, isNotNull);
26 expect(ctx, isAudioContext);
27 }
28 });
36 29
37 expect(context.createAnalyser() is AnalyserNode, isTrue); 30 test('createBuffer', () {
38 expect(context.createChannelMerger() is ChannelMergerNode, isTrue); 31 if(AudioContext.supported) {
39 expect(context.createChannelSplitter() is ChannelSplitterNode, isTrue); 32 var ctx = new AudioContext();
40 expect(context.createOscillator() is OscillatorNode, isTrue); 33 ArrayBufferView arrayBufferView = new Float32Array.fromList([]);
41 expect(context.createPanner() is PannerNode, isTrue); 34 try {
42 expect(context.createScriptProcessor(4096) is ScriptProcessorNode, isTrue); 35 // Test that native overload is chosen correctly. Native
36 // implementation should throw 'SyntaxError' DomException because the
37 // buffer is empty.
38 AudioBuffer buffer = ctx.createBuffer(arrayBufferView.buffer, false);
39 } catch (e) {
40 expect(e.name, DomException.SYNTAX);
41 }
42 }
43 });
44
45 test('audioRenames', () {
46 if(AudioContext.supported) {
47 AudioContext context = new AudioContext();
48 GainNode gainNode = context.createGain();
49 gainNode.connect(context.destination, 0, 0);
50 expect(gainNode is GainNode, isTrue);
51
52 expect(context.createAnalyser() is AnalyserNode, isTrue);
53 expect(context.createChannelMerger() is ChannelMergerNode, isTrue);
54 expect(context.createChannelSplitter() is ChannelSplitterNode, isTrue);
55 expect(context.createOscillator() is OscillatorNode, isTrue);
56 expect(context.createPanner() is PannerNode, isTrue);
57 expect(context.createScriptProcessor(4096) is ScriptProcessorNode,
58 isTrue);
59 }
60 });
61
62 test('onAudioProcess', () {
63 if(AudioContext.supported) {
64 var completer = new Completer<bool>();
65 var context = new AudioContext();
66 var scriptProcessor = context.createScriptProcessor(1024, 1, 2);
67 scriptProcessor.connect(context.destination, 0, 0);
68 bool alreadyCalled = false;
69 scriptProcessor.onAudioProcess.listen((event) {
70 if (!alreadyCalled) {
71 completer.complete(true);
72 }
73 alreadyCalled = true;
74 });
75 return completer.future;
76 }
77 });
43 }); 78 });
44 } 79 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698