diff --git a/java-accessibility-checker/src/main/java/com/ibm/able/equalaccess/report/BaselineManager.java b/java-accessibility-checker/src/main/java/com/ibm/able/equalaccess/report/BaselineManager.java index b45010d3e..4739487c7 100644 --- a/java-accessibility-checker/src/main/java/com/ibm/able/equalaccess/report/BaselineManager.java +++ b/java-accessibility-checker/src/main/java/com/ibm/able/equalaccess/report/BaselineManager.java @@ -208,10 +208,10 @@ public static DiffResult[] diffResultsWithExpected(ACReport actual, ACReport exp DiffResult[] differences = diff(actual, expected); if (differences != null && differences.length > 0) { differences = Arrays.stream(differences).filter(difference -> { - return "E".equals(difference.kind) + return !("E".equals(difference.kind) && difference.path.length == 4 && difference.path.length > 2 && "bounds".equals(difference.path[2]) - && Math.abs((Integer)difference.lhs-(Integer)difference.rhs) <= 1; + && Math.abs((Integer)difference.lhs-(Integer)difference.rhs) <= 1); }).toArray(size -> new DiffResult[size]); if (differences.length == 0) return null; } diff --git a/java-accessibility-checker/src/test/java/com/ibm/able/equalaccess/AccessibilityCheckerSeleniumTest.java b/java-accessibility-checker/src/test/java/com/ibm/able/equalaccess/AccessibilityCheckerSeleniumTest.java index 4ffb91c12..61512824f 100644 --- a/java-accessibility-checker/src/test/java/com/ibm/able/equalaccess/AccessibilityCheckerSeleniumTest.java +++ b/java-accessibility-checker/src/test/java/com/ibm/able/equalaccess/AccessibilityCheckerSeleniumTest.java @@ -18,7 +18,10 @@ import org.junit.Test; import static org.junit.Assert.*; +import java.io.BufferedReader; +import java.io.BufferedWriter; import java.io.File; +import java.io.FileReader; import java.io.FileWriter; import java.io.IOException; import java.nio.file.Paths; @@ -122,15 +125,50 @@ public static class UnitTestInfo { @Test public void baselines() throws IOException { Paths.get("baselines", "Selenium_getComplianceTest3.json").toFile().delete(); + Paths.get("baselines", "Selenium_getComplianceTest3_1.json").toFile().delete(); AccessibilityCheckerSeleniumTest.driver.get("https://altoromutual.12mc9fdq8fib.us-south.codeengine.appdomain.cloud/"); ACReport report = AccessibilityChecker.getCompliance(driver, "Selenium_getComplianceTest2"); assertEquals(eAssertResult.FAIL, AccessibilityChecker.assertCompliance(report)); new File("baselines").mkdirs(); Files.copy(Paths.get("results", "Selenium_getComplianceTest2.json").toFile(), Paths.get("baselines", "Selenium_getComplianceTest3.json").toFile()); + Files.copy(Paths.get("results", "Selenium_getComplianceTest2.json").toFile(), Paths.get("baselines", "Selenium_getComplianceTest3_1.json").toFile()); report = AccessibilityChecker.getCompliance(driver, "Selenium_getComplianceTest3"); - assertEquals(eAssertResult.PASS, AccessibilityChecker.assertCompliance(report)); + assertEquals(eAssertResult.PASS, AccessibilityChecker.assertCompliance(report)); + + removeFirstItemFromBaseline(Paths.get("baselines", "Selenium_getComplianceTest3_1.json").toFile()); + report = AccessibilityChecker.getCompliance(driver, "Selenium_getComplianceTest3_1"); + assertEquals(eAssertResult.BASELINE_MISMATCH, AccessibilityChecker.assertCompliance(report)); Paths.get("baselines", "Selenium_getComplianceTest3.json").toFile().delete(); + Paths.get("baselines", "Selenium_getComplianceTest3_1.json").toFile().delete(); + } + + private static void removeFirstItemFromBaseline(File f1) { + List lines = new ArrayList(); + String line = null; + + try { + FileReader fr = new FileReader(f1); + BufferedReader br = new BufferedReader(fr); + int idx=1; + while ((line = br.readLine()) != null) { + if (idx <= 2 || idx >= 30) { + lines.add(line); + } + ++idx; + } + fr.close(); + br.close(); + + FileWriter fw = new FileWriter(f1); + BufferedWriter out = new BufferedWriter(fw); + for(String s : lines) + out.write(s+"\n"); + out.flush(); + out.close(); + } catch (Exception ex) { + ex.printStackTrace(); + } } // @Test public void getComplianceLong() {