async function runTest(languages, preference, expectedIndex) {
      // A manifest we can use to test language selection.
      manifest = shaka.test.ManifestGenerator.generate((manifest) => {
        for (let i = 0; i < languages.length; i++) {
          const lang = languages[i];
          if (lang.charAt(0) == '*') {
            manifest.addVariant(i, (variant) => {
              variant.primary = true;
              variant.language = lang.substr(1);
              variant.addAudio(i);
            });
          } else {
            manifest.addVariant(i, (variant) => {
              variant.language = lang;
              variant.addAudio(i);
            });
          }
        }
      });

      // Set the user preferences, which must happen before load().
      player.configure({
        preferredAudioLanguage: preference,
      });

      await player.load(fakeManifestUri, 0, fakeMimeType);
      expect(getActiveVariantTrack().id).toBe(expectedIndex);
    }
@param {!Array<string>} languages
@param {string} preference
@param {number} expectedIndex
@return {!Promise}