Search in sources :

Example 1 with Coords

use of ru.yandex.qatools.ashot.coordinates.Coords in project ashot by yandex-qatools.

the class DifferTest method testCoordsToCompareAndIgnoredCombine.

@Test
public void testCoordsToCompareAndIgnoredCombine() throws Exception {
    Screenshot a = createScreenshotWithIgnoredAreas(IMAGE_A_SMALL, new HashSet<>(asList(new Coords(60, 60))));
    a.setCoordsToCompare(new HashSet<>(asList(new Coords(50, 50, 100, 100))));
    Screenshot b = createScreenshotWithIgnoredAreas(IMAGE_B_SMALL, new HashSet<>(asList(new Coords(80, 80))));
    b.setCoordsToCompare(new HashSet<>(asList(new Coords(50, 50, 100, 100))));
    ImageDiff diff = imageDiffer.makeDiff(a, b);
    assertThat(diff.getMarkedImage(), ImageTool.equalImage(loadImage("img/expected/combined_diff.png")));
}
Also used : ImageDiff(ru.yandex.qatools.ashot.comparison.ImageDiff) Screenshot(ru.yandex.qatools.ashot.Screenshot) Coords(ru.yandex.qatools.ashot.coordinates.Coords) Test(org.junit.Test)

Example 2 with Coords

use of ru.yandex.qatools.ashot.coordinates.Coords 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 3 with Coords

use of ru.yandex.qatools.ashot.coordinates.Coords in project ashot by yandex-qatools.

the class ImageDiffer method markDiffPoints.

protected void markDiffPoints(Screenshot expected, Screenshot actual, ImageDiff diff) {
    Coords expectedImageCoords = Coords.ofImage(expected.getImage());
    Coords actualImageCoords = Coords.ofImage(actual.getImage());
    CoordsSet compareCoordsSet = new CoordsSet(CoordsSet.union(actual.getCoordsToCompare(), expected.getCoordsToCompare()));
    CoordsSet ignoreCoordsSet = new CoordsSet(CoordsSet.intersection(actual.getIgnoredAreas(), expected.getIgnoredAreas()));
    int width = Math.max(expected.getImage().getWidth(), actual.getImage().getWidth());
    int height = Math.max(expected.getImage().getHeight(), actual.getImage().getHeight());
    diff.setDiffImage(createDiffImage(expected.getImage(), actual.getImage(), width, height));
    for (int i = 0; i < width; i++) {
        for (int j = 0; j < height; j++) {
            if (ignoreCoordsSet.contains(i, j)) {
                continue;
            }
            if (!isInsideBothImages(i, j, expectedImageCoords, actualImageCoords) || compareCoordsSet.contains(i, j) && hasDiffInChannel(expected, actual, i, j)) {
                diff.addDiffPoint(i, j);
            }
        }
    }
}
Also used : Coords(ru.yandex.qatools.ashot.coordinates.Coords)

Example 4 with Coords

use of ru.yandex.qatools.ashot.coordinates.Coords in project ashot by yandex-qatools.

the class VerticalPastingShootingStrategyTest method testScreenshotCoordsZeroHeight.

@Test
public void testScreenshotCoordsZeroHeight() throws Exception {
    shootingCoords = new Coords(0, SHOOT_COORDS_OFFSET_Y, PAGE_WIDTH, 0);
    whenTakingScreenshot(shootingCoords);
    thenScreenshotIsHeight(DEFAULT_COORDS_INDENT);
}
Also used : Coords(ru.yandex.qatools.ashot.coordinates.Coords) Test(org.junit.Test)

Example 5 with Coords

use of ru.yandex.qatools.ashot.coordinates.Coords in project ashot by yandex-qatools.

the class DifferTest method testIgnoredCoordsNotSame.

@Test
public void testIgnoredCoordsNotSame() throws Exception {
    Screenshot a = createScreenshotWithIgnoredAreas(IMAGE_A_SMALL, new HashSet<>(asList(new Coords(55, 55))));
    Screenshot b = createScreenshotWithIgnoredAreas(IMAGE_B_SMALL, new HashSet<>(asList(new Coords(80, 80))));
    ImageDiff diff = imageDiffer.makeDiff(a, b);
    assertThat(diff.getMarkedImage(), ImageTool.equalImage(loadImage("img/expected/ignore_coords_not_same.png")));
}
Also used : ImageDiff(ru.yandex.qatools.ashot.comparison.ImageDiff) Screenshot(ru.yandex.qatools.ashot.Screenshot) Coords(ru.yandex.qatools.ashot.coordinates.Coords) Test(org.junit.Test)

Aggregations

Coords (ru.yandex.qatools.ashot.coordinates.Coords)9 Screenshot (ru.yandex.qatools.ashot.Screenshot)4 Coords.setReferenceCoords (ru.yandex.qatools.ashot.coordinates.Coords.setReferenceCoords)4 Test (org.junit.Test)3 ImageDiff (ru.yandex.qatools.ashot.comparison.ImageDiff)2 BufferedImage (java.awt.image.BufferedImage)1 HashSet (java.util.HashSet)1