chromium/third_party/blink/web_tests/webaudio/AudioListener/audiolistener-set-position.html

<!doctype html>
<html>
  <head>
    <title>
      Test AudioListener.setPosition and AudioListener.setOrientation Errors
    </title>
    <script src="../../resources/testharness.js"></script>
    <script src="../../resources/testharnessreport.js"></script>
    <script src="../resources/audit-util.js"></script>
    <script src="../resources/audit.js"></script>
    <script src="../resources/set-position-vs-curve-test.js"></script>
  </head>
  <body>
    <script id="layout-test-code">
      // Fairly arbitrary rate
      let sampleRate = 16000;

      // For the tests we need to render for at least two render quanta.
      // Otherwise, pretty arbitrary.
      let renderFrames = 256;
      let renderDuration = renderFrames / sampleRate;

      // The curve duration for the test.  Anything less than one render quantum
      // is fine.  Arbitrarily choose something small.
      let curveDurationFrames = 8;
      let curveDuration = curveDurationFrames / sampleRate;

      // When to call setPosition, after the setValueCurve has ended.  Any value
      // after the end of the first render quantum is fine.
      let suspendFrame = 129;

      let audit = Audit.createTaskRunner();

      // Array of tests to do.  Each element of this array is used to create a
      // task to test the entry.
      let tests = [
        // Test |setPosition| against |positionX|, |positionY|, and |positionZ|
        // setValueCurves.  Include test where there's overlap and where there
        // isn't.
        {
          name: 'Listener setPosition X error',
          options: {paramName: 'positionX', curveDuration: renderDuration}
        },
        {
          name: 'Listener setPosition X no error',
          options: {
            paramName: 'positionX',
            curveDuration: curveDuration,
            suspendFrame: suspendFrame
          }
        },
        {
          name: 'Listener setPosition Y error',
          options: {paramName: 'positionY', curveDuration: renderDuration}
        },
        {
          name: 'Listener setPosition Y no error',
          options: {
            paramName: 'positionY',
            curveDuration: curveDuration,
            suspendFrame: suspendFrame
          }
        },
        {
          name: 'Listener setPosition Z error',
          options: {paramName: 'positionZ', curveDuration: renderDuration}
        },
        {
          name: 'Listener setPosition Z no error',
          options: {
            paramName: 'positionZ',
            curveDuration: curveDuration,
            suspendFrame: suspendFrame
          }
        },
        // Now do the same with |setOrientation|, for forward and up vectors.
        {
          name: 'Listener setOrientation forward X error',
          options: {paramName: 'forwardX', curveDuration: renderDuration}
        },
        {
          name: 'Listener setOrientation forward X no error',
          options: {
            paramName: 'forwardX',
            curveDuration: curveDuration,
            suspendFrame: suspendFrame
          }
        },
        {
          name: 'Listener setOrientation forward Y error',
          options: {paramName: 'forwardY', curveDuration: renderDuration}
        },
        {
          name: 'Listener setOrientation forward Y no error',
          options: {
            paramName: 'forwardY',
            curveDuration: curveDuration,
            suspendFrame: suspendFrame
          }
        },
        {
          name: 'Listener setOrientation forward Z error',
          options: {paramName: 'forwardZ', curveDuration: renderDuration}
        },
        {
          name: 'Listener setOrientation forward Z no error',
          options: {
            paramName: 'forwardZ',
            curveDuration: curveDuration,
            suspendFrame: suspendFrame
          }
        },
        {
          name: 'Listener setOrientation up X error',
          options: {paramName: 'upX', curveDuration: renderDuration}
        },
        {
          name: 'Listener setOrientation up X no error',
          options: {
            paramName: 'upX',
            curveDuration: curveDuration,
            suspendFrame: suspendFrame
          }
        },
        {
          name: 'Listener setOrientation up Y error',
          options: {paramName: 'upY', curveDuration: renderDuration}
        },
        {
          name: 'Listener setOrientation up Y no error',
          options: {
            paramName: 'upY',
            curveDuration: curveDuration,
            suspendFrame: suspendFrame
          }
        },
        {
          name: 'Listener setOrientation up Z error',
          options: {paramName: 'upZ', curveDuration: renderDuration}
        },
        {
          name: 'Listener setOrientation up Z no error',
          options: {
            paramName: 'upZ',
            curveDuration: curveDuration,
            suspendFrame: suspendFrame
          }
        },
      ];

      // Create an audit test for each entry in |tests|.
      tests.forEach(test => {
        audit.define(test.name, (task, should) => {
          let context = new OfflineAudioContext(1, renderFrames, sampleRate);
          testPositionSetterVsCurve(
              should, context,
              Object.assign(
                  {testName: test.name, nodeName: 'listener'}, test.options))
              .then(() => task.done());
        });
      });

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