Trait xray::ScreenshotIo[][src]

pub trait ScreenshotIo {
    fn prepare_output(&self) -> Result<(), XrayError>;
fn load_reference(&self) -> Result<DynamicImage, XrayError>;
fn write_actual(&self, _: &DynamicImage) -> Result<(), XrayError>;
fn write_expected(&self, _: &DynamicImage) -> Result<(), XrayError>;
fn write_diff(&self, _: &DynamicImage) -> Result<(), XrayError>; fn default(test_name: &str) -> FsScreenshotIo { ... } }

Load reference images for comparison and store image output in the event of a failed test.

xray ships with one implementation of ScreenshotIo by default, FsScreenshotIo which reads and writes screenshots from the filesystem.

Required Methods

Performs any work needed to prepare to store output (e.g. creating directories) This gets called once per test, before any output is written.

Loads a reference image to compare to the screenshot taken by xray. The actual method used to load the image depends on your chosen implementation.

Writes out the screenshot taken during the test in the event of a failed test.

Writes out the screenshot that was expected during the test in the event of a failed test.

Writes out an image containing only those pixels that were present in the newly captured image but not present in the reference image.

Provided Methods

Returns a default implementation of ScreenshotIo.

This implementation will look for reference images in references/<test_name>.png at the top level of your crate.

In the event of a failed test, it will write out three screenshots.

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

Implementors