summaryrefslogtreecommitdiffstats
path: root/testing/web-platform/tests/webaudio/the-audio-api/the-biquadfilternode-interface/biquadfilternode-basic.html
blob: 7e71d073024cb2040b7a4d7ea5ff681f803e21b0 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
<!DOCTYPE html>
<html>
  <head>
    <title>
      biquadfilternode-basic.html
    </title>
    <script src="/resources/testharness.js"></script>
    <script src="/resources/testharnessreport.js"></script>
    <script src="/webaudio/resources/audit-util.js"></script>
    <script src="/webaudio/resources/audit.js"></script>
  </head>
  <body>
    <script id="layout-test-code">
      let audit = Audit.createTaskRunner();

      audit.define(
          {label: 'test', description: 'Basic tests for BiquadFilterNode'},
          function(task, should) {

            let context = new AudioContext();
            let filter = context.createBiquadFilter();

            should(filter.numberOfInputs, 'Number of inputs').beEqualTo(1);

            should(filter.numberOfOutputs, 'Number of outputs').beEqualTo(1);

            should(filter.type, 'Default filter type').beEqualTo('lowpass');

            should(filter.frequency.value, 'Default frequency value')
                .beEqualTo(350);

            should(filter.Q.value, 'Default Q value').beEqualTo(1);

            should(filter.gain.value, 'Default gain value').beEqualTo(0);

            // Check that all legal filter types can be set.
            let filterTypeArray = [
              {type: 'lowpass'}, {type: 'highpass'}, {type: 'bandpass'},
              {type: 'lowshelf'}, {type: 'highshelf'}, {type: 'peaking'},
              {type: 'notch'}, {type: 'allpass'}
            ];

            for (let i = 0; i < filterTypeArray.length; ++i) {
              should(
                  () => filter.type = filterTypeArray[i].type,
                  'Setting filter.type to ' + filterTypeArray[i].type)
                  .notThrow();
              should(filter.type, 'Filter type is')
                  .beEqualTo(filterTypeArray[i].type);
            }


            // Check that numerical values are no longer supported
            filter.type = 99;
            should(filter.type, 'Setting filter.type to (invalid) 99')
                .notBeEqualTo(99);

            task.done();
          });

      audit.run();
    </script>
  </body>
</html>