Function xray::gl_screenshot_test[][src]

pub fn gl_screenshot_test(
    test_name: &str,
    x: i32,
    y: i32,
    width: u32,
    height: u32
)

Takes a screenshot using OpenGL and panics if it does not match a reference image.

The image of the given region is taken using OpenGL's gl::ReadImage.

This screenshot is compared to references/<test_name>.png

If the images do not match, or could not be taken, the call panics and the following three screenshots are written out:

  • test_output/<test_name>/actual.png containing the screenshot taken during the test
  • test_output/<test_name>/expected.png containing the reference image the screenshot was compared against.
  • test_output/<test_name>/diff.png containing the pixels from the screenshot that did not match the pixels in the reference image.

To customise any of this behaviour, create a custom ScreenshotCaptor and ScreenshotIo and pass them to screenshot_test (returns a Result<(), ScreenshotError>) or assert_screenshot_test (panics on fail)