Search in sources :

Example 6 with Screenshot

use of ru.yandex.qatools.ashot.Screenshot in project ashot by yandex-qatools.

the class IndentCropper method cropScreenshot.

@Override
public Screenshot cropScreenshot(BufferedImage image, Set<Coords> coordsToCompare) {
    Coords cropArea = createCropArea(coordsToCompare);
    Coords indentMask = createIndentMask(cropArea, image);
    Coords coordsWithIndent = applyIndentMask(cropArea, indentMask);
    Screenshot croppedShot = super.cropScreenshot(image, Collections.singleton(coordsWithIndent));
    croppedShot.setOriginShift(coordsWithIndent);
    croppedShot.setCoordsToCompare(setReferenceCoords(coordsWithIndent, coordsToCompare));
    List<NoFilteringArea> noFilteringAreas = createNotFilteringAreas(croppedShot);
    croppedShot.setImage(applyFilters(croppedShot.getImage()));
    pasteAreasToCompare(croppedShot.getImage(), noFilteringAreas);
    return croppedShot;
}
Also used : Screenshot(ru.yandex.qatools.ashot.Screenshot) Coords.setReferenceCoords(ru.yandex.qatools.ashot.coordinates.Coords.setReferenceCoords) Coords(ru.yandex.qatools.ashot.coordinates.Coords)

Example 7 with Screenshot

use of ru.yandex.qatools.ashot.Screenshot in project ashot by yandex-qatools.

the class SerializeScreenshotTest method serializeWithoutIgnoredAreas.

@Test
public void serializeWithoutIgnoredAreas() throws IOException, ClassNotFoundException {
    Screenshot screenshot = new Screenshot(IMAGE_A_SMALL);
    try (ObjectOutputStream objectOutputStream = new ObjectOutputStream(new FileOutputStream(serializedFile))) {
        objectOutputStream.writeObject(screenshot);
    }
    try (ObjectInputStream objectInputStream = new ObjectInputStream(new FileInputStream(serializedFile))) {
        Screenshot deserialized = (Screenshot) objectInputStream.readObject();
        checkDeserializedScreenshot(screenshot, deserialized);
    }
}
Also used : FileOutputStream(java.io.FileOutputStream) Screenshot(ru.yandex.qatools.ashot.Screenshot) ObjectOutputStream(java.io.ObjectOutputStream) FileInputStream(java.io.FileInputStream) ObjectInputStream(java.io.ObjectInputStream) Test(org.junit.Test)

Example 8 with Screenshot

use of ru.yandex.qatools.ashot.Screenshot in project ashot by yandex-qatools.

the class CroppersTest method testElementOutsideImageDefCropper.

@Test
public void testElementOutsideImageDefCropper() throws Exception {
    Screenshot screenshot = new DefaultCropper().cropScreenshot(IMAGE_A_SMALL, OUTSIDE_IMAGE);
    assertThat(screenshot.getImage(), ImageTool.equalImage(loadImage("img/expected/outside_dc.png")));
}
Also used : DefaultCropper(ru.yandex.qatools.ashot.cropper.DefaultCropper) Screenshot(ru.yandex.qatools.ashot.Screenshot) Test(org.junit.Test)

Example 9 with Screenshot

use of ru.yandex.qatools.ashot.Screenshot in project ashot by yandex-qatools.

the class DifferTest method createScreenshotWithIgnoredAreas.

private Screenshot createScreenshotWithIgnoredAreas(BufferedImage image, Set<Coords> ignored) {
    Screenshot screenshot = new Screenshot(image);
    screenshot.setIgnoredAreas(ignored);
    return screenshot;
}
Also used : Screenshot(ru.yandex.qatools.ashot.Screenshot)

Example 10 with Screenshot

use of ru.yandex.qatools.ashot.Screenshot in project ashot by yandex-qatools.

the class DifferTest method testIgnoredCoordsSame.

@Test
public void testIgnoredCoordsSame() throws Exception {
    Screenshot a = createScreenshotWithSameIgnoredAreas(IMAGE_A_SMALL);
    Screenshot b = createScreenshotWithSameIgnoredAreas(IMAGE_B_SMALL);
    ImageDiff diff = imageDiffer.makeDiff(a, b);
    assertThat(diff.getMarkedImage(), ImageTool.equalImage(loadImage("img/expected/ignore_coords_same.png")));
}
Also used : ImageDiff(ru.yandex.qatools.ashot.comparison.ImageDiff) Screenshot(ru.yandex.qatools.ashot.Screenshot) Test(org.junit.Test)

Aggregations

Screenshot (ru.yandex.qatools.ashot.Screenshot)15 Test (org.junit.Test)9 TakesScreenshot (org.openqa.selenium.TakesScreenshot)4 Coords (ru.yandex.qatools.ashot.coordinates.Coords)4 ImageDiff (ru.yandex.qatools.ashot.comparison.ImageDiff)3 FileInputStream (java.io.FileInputStream)2 FileOutputStream (java.io.FileOutputStream)2 ObjectInputStream (java.io.ObjectInputStream)2 ObjectOutputStream (java.io.ObjectOutputStream)2 WebElement (org.openqa.selenium.WebElement)2 Test (org.testng.annotations.Test)2 AShot (ru.yandex.qatools.ashot.AShot)2 Coords.setReferenceCoords (ru.yandex.qatools.ashot.coordinates.Coords.setReferenceCoords)2 IndentCropper (ru.yandex.qatools.ashot.cropper.indent.IndentCropper)2 BufferedImage (java.awt.image.BufferedImage)1 DefaultCropper (ru.yandex.qatools.ashot.cropper.DefaultCropper)1 ScalingDecorator (ru.yandex.qatools.ashot.shooting.ScalingDecorator)1 ShootingStrategy (ru.yandex.qatools.ashot.shooting.ShootingStrategy)1 SimpleShootingStrategy (ru.yandex.qatools.ashot.shooting.SimpleShootingStrategy)1