use of com.seleniumtests.util.imaging.StepReferenceComparator in project seleniumRobot by bhecquet.
the class ErrorCauseFinder method compareReferenceToStepSnapshot.
private int compareReferenceToStepSnapshot(File stepSnapshot, File referenceSnapshot, List<Label> missingLabels, List<Field> missingFields) {
StepReferenceComparator stepReferenceComparator = new StepReferenceComparator(stepSnapshot, referenceSnapshot);
int matching = stepReferenceComparator.compare();
missingLabels.addAll(stepReferenceComparator.getMissingLabels());
missingFields.addAll(stepReferenceComparator.getMissingFields());
return matching;
}
use of com.seleniumtests.util.imaging.StepReferenceComparator in project seleniumRobot by bhecquet.
the class TestStepReferenceComparator method testCompareNoFieldNoLabel.
@Test(groups = { "ut" })
public void testCompareNoFieldNoLabel() throws Exception {
PowerMockito.whenNew(ImageFieldDetector.class).withAnyArguments().thenReturn(stepImageFieldDetector, refImageFieldDetector);
StepReferenceComparator comparator = new StepReferenceComparator(File.createTempFile("img", ".png"), File.createTempFile("img", ".png"));
Assert.assertEquals(comparator.compare(), 100);
}
use of com.seleniumtests.util.imaging.StepReferenceComparator in project seleniumRobot by bhecquet.
the class TestStepReferenceComparator method testComparePartialMatch.
@Test(groups = { "ut" })
public void testComparePartialMatch() throws Exception {
List<Label> stepLabels = new ArrayList<>();
stepLabels.add(new Label(0, 100, 20, 50, "a text"));
stepLabels.add(new Label(0, 100, 100, 120, "other text"));
List<Label> referenceLabels = new ArrayList<>();
referenceLabels.add(new Label(0, 100, 0, 20, "a text"));
referenceLabels.add(new Label(5, 105, 100, 120, "other text"));
List<Field> stepFields = new ArrayList<>();
stepFields.add(new Field(0, 100, 0, 20, "", "field"));
stepFields.add(new Field(0, 100, 200, 220, "", "field"));
List<Field> referenceFields = new ArrayList<>();
referenceFields.add(new Field(0, 100, 0, 20, "", "field"));
referenceFields.add(new Field(5, 105, 100, 120, "", "field"));
PowerMockito.whenNew(ImageFieldDetector.class).withAnyArguments().thenReturn(stepImageFieldDetector, refImageFieldDetector);
when(stepImageFieldDetector.detectLabels()).thenReturn(stepLabels);
when(refImageFieldDetector.detectLabels()).thenReturn(referenceLabels);
when(stepImageFieldDetector.detectFields()).thenReturn(stepFields);
when(refImageFieldDetector.detectFields()).thenReturn(referenceFields);
StepReferenceComparator comparator = new StepReferenceComparator(File.createTempFile("img", ".png"), File.createTempFile("img", ".png"));
Assert.assertEquals(comparator.compare(), 50);
}
use of com.seleniumtests.util.imaging.StepReferenceComparator in project seleniumRobot by bhecquet.
the class TestStepReferenceComparator method testCompareNoLabel.
/**
* List of fields are the same, comparison is successful (no labels)
* @throws Exception
*/
@Test(groups = { "ut" })
public void testCompareNoLabel() throws Exception {
List<Field> stepFields = new ArrayList<>();
stepFields.add(new Field(0, 100, 0, 20, "", "field"));
stepFields.add(new Field(0, 100, 100, 120, "", "field"));
List<Field> referenceFields = new ArrayList<>();
referenceFields.add(new Field(0, 100, 0, 20, "", "field"));
referenceFields.add(new Field(5, 105, 100, 120, "", "field"));
PowerMockito.whenNew(ImageFieldDetector.class).withAnyArguments().thenReturn(stepImageFieldDetector, refImageFieldDetector);
when(stepImageFieldDetector.detectFields()).thenReturn(stepFields);
when(refImageFieldDetector.detectFields()).thenReturn(referenceFields);
StepReferenceComparator comparator = new StepReferenceComparator(File.createTempFile("img", ".png"), File.createTempFile("img", ".png"));
int matching = comparator.compare();
Assert.assertEquals(matching, 100);
PowerMockito.verifyNew(ImageFieldDetector.class, times(2)).withArguments(any(File.class), anyDouble(), eq(FieldType.ALL_FORM_FIELDS));
}
use of com.seleniumtests.util.imaging.StepReferenceComparator in project seleniumRobot by bhecquet.
the class TestStepReferenceComparator method testCompareNoField.
@Test(groups = { "ut" })
public void testCompareNoField() throws Exception {
List<Label> stepLabels = new ArrayList<>();
stepLabels.add(new Label(0, 100, 0, 20, "a text"));
stepLabels.add(new Label(0, 100, 100, 120, "other text"));
List<Label> referenceLabels = new ArrayList<>();
referenceLabels.add(new Label(0, 100, 0, 20, "a text"));
referenceLabels.add(new Label(5, 105, 100, 120, "other text"));
PowerMockito.whenNew(ImageFieldDetector.class).withAnyArguments().thenReturn(stepImageFieldDetector, refImageFieldDetector);
when(stepImageFieldDetector.detectLabels()).thenReturn(stepLabels);
when(refImageFieldDetector.detectLabels()).thenReturn(referenceLabels);
StepReferenceComparator comparator = new StepReferenceComparator(File.createTempFile("img", ".png"), File.createTempFile("img", ".png"));
Assert.assertEquals(comparator.compare(), 100);
}
Aggregations