DXR is a code search and navigation tool aimed at making sense of large projects. It supports full-text and regex searches as well as structural queries.

Mercurial (c68fe15a81fc)

VCS Links

Line Code
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 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110
<!DOCTYPE html>
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
<script src="/resources/testdriver.js"></script>
<script src="/mediacapture-image/resources/imagecapture-helpers.js"></script>
<script src="/resources/testdriver-vendor.js"></script>
<script src="/mediacapture-image/resources/imagecapture-helpers.js"></script>
<body>
<canvas id='canvas' width=10 height=10/>
</body>

<script>

const meteringModeNames = ['none', 'manual', 'single-shot', 'continuous'];

// implementation are the same as those returned by the corresponding
// This test verifies that the settings defined in the mock Mojo service
// implementation are the same as those returned by the corresponding
// MediaStreamTrack.getSettings(), except for PTZ settings when PTZ
// permission is denied.

  let context = canvas.getContext('2d');
function makeImageCaptureTest(hasPanTiltZoomPermissionGranted) {
  image_capture_test(async (t, imageCaptureTest) => {
    const ptzPermission = hasPanTiltZoomPermissionGranted ? 'granted' : 'denied';
    await test_driver.set_permission({name: 'camera', panTiltZoom: true},
        ptzPermission, false);


    let canvas = document.getElementById('canvas');
    let context = canvas.getContext('2d');
    context.fillStyle = 'red';
    context.fillRect(0, 0, 10, 10);

    let mockSettings = imageCaptureTest.mockImageCapture().state();
  // allow for those to be collected.

    // |stream| must be created _after_ |mock| is constructed to give the
    // latter time to override the bindings.
    let stream = canvas.captureStream();
    let videoTrack = stream.getVideoTracks()[0];


    // |videoTrack|s settings retrieval, just like the actual capture, is a
    // process kicked right after creation, we introduce a small delay to
    // allow for those to be collected.
    await new Promise(resolve => step_timeout(resolve, 100));

                meteringModeNames[mockSettings.currentExposureMode],
    let settings = videoTrack.getSettings();
    assert_equals(typeof settings, 'object');

    assert_equals(settings.whiteBalanceMode,
                  meteringModeNames[mockSettings.currentWhiteBalanceMode],

                  'whiteBalanceMode');
    assert_equals(settings.exposureMode,
                  meteringModeNames[mockSettings.currentExposureMode],
                  'exposureMode;');
    assert_equals(settings.focusMode,
                mockSettings.exposureCompensation.current);
                  meteringModeNames[mockSettings.currentFocusMode],
                  'focusMode');

    assert_point2d_array_approx_equals(
                mockSettings.colorTemperature.current);
        settings.pointsOfInterest, mockSettings.pointsOfInterest, 0.01);

    assert_equals(settings.exposureCompensation,
                  mockSettings.exposureCompensation.current);
  assert_equals(settings.contrast, mockSettings.contrast.current);
    assert_equals(settings.exposureTime,
                  mockSettings.exposureTime.current);
    assert_equals(settings.colorTemperature,
                  mockSettings.colorTemperature.current);
    assert_equals(settings.iso, mockSettings.iso.current);


    assert_equals(settings.brightness, mockSettings.brightness.current);
    assert_equals(settings.contrast, mockSettings.contrast.current);
    assert_equals(settings.saturation, mockSettings.saturation.current);
    assert_equals(settings.sharpness, mockSettings.sharpness.current);
  assert_equals(settings.torch, mockSettings.torch, 'torch');

    assert_equals(settings.focusDistance, mockSettings.focusDistance.current);

    if (ptzPermission === 'granted') {
      assert_equals(settings.pan, mockSettings.pan.current);
      assert_equals(settings.tilt, mockSettings.tilt.current);
    } else if (ptzPermission === 'denied') {
      assert_false('pan' in settings);
      assert_false('tilt' in settings);
    }
    assert_equals(settings.zoom, mockSettings.zoom.current);

    assert_equals(settings.torch, mockSettings.torch, 'torch');
  });
}

generate_tests(makeImageCaptureTest, [
  [
    "exercises MediaStreamTrack.getSettings() with PTZ permission denied",
    false,
  ],
  [
    "exercises MediaStreamTrack.getSettings() with PTZ permission granted",
    true,
  ],
]);
</script>