Package org.xwiki.test.ui
Class WCAGContext
- java.lang.Object
-
- org.xwiki.test.ui.WCAGContext
-
public class WCAGContext extends Object
Context related to WCAG (accessibility) validation with axe-core.- Since:
- 15.2RC1
- Version:
- $Id: d8625aac8f9e44f88546d9b8e59ea98d024eb0a6 $
-
-
Constructor Summary
Constructors Constructor Description WCAGContext()
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description void
addWCAGResults(String url, String className, com.deque.html.axecore.results.Results axeResults)
Appends WCAG results to the current context.void
addWCAGTime(long time)
String
buildFailsReport()
String
buildIncompleteReport()
String
buildOverview()
Build the content of the wcag analysis overview.String
buildWarningsReport()
com.deque.html.axecore.selenium.AxeBuilder
getAxeBuilder()
Instantiate and initialize an axe builder with context options.protected Map<String,Integer>
getIncompleteCountPerRule()
protected Map<String,Integer>
getPassCountPerRule()
protected String
getTestClassName()
protected String
getTestMethodName()
protected Map<String,Integer>
getViolationCountPerRule()
long
getWCAGFailCount()
long
getWCAGIncompleteCount()
long
getWCAGTime()
long
getWCAGWarnCount()
boolean
hasWCAGFails()
boolean
hasWCAGIncomplete()
boolean
hasWCAGWarnings()
protected Boolean
isFailing(String ruleID)
boolean
isNotCached(String url, String className)
boolean
isWCAGEnabled()
void
setTestClassName(String testClassName)
Sets the current test class name.void
setTestMethodName(String testMethodName)
Sets the current test method name.void
setWCAGEnabled(boolean wcag)
void
setWCAGStopOnError(boolean stopOnError)
boolean
shouldWCAGStopOnError()
static void
writeWCAGReportToFile(File outputFile, String output)
Writes a WCAG report to a file for proper accessibility warnings and failures examination.
-
-
-
Method Detail
-
setTestClassName
public void setTestClassName(String testClassName)
Sets the current test class name. This name is the string representation of the TestUI class in which the current wcag validation happens.- Parameters:
testClassName
- the test class name to be set
-
getTestClassName
protected String getTestClassName()
-
setTestMethodName
public void setTestMethodName(String testMethodName)
Sets the current test method name. This name is the string representation of a Test method in a testUI class in which the current wcag validation happens.- Parameters:
testMethodName
- the test method name to be set
-
getTestMethodName
protected String getTestMethodName()
-
getAxeBuilder
public com.deque.html.axecore.selenium.AxeBuilder getAxeBuilder()
Instantiate and initialize an axe builder with context options.- Returns:
- a ready-to-use AxeBuilder instance
-
isNotCached
public boolean isNotCached(String url, String className)
- Parameters:
url
- the URL of the page to analyzeclassName
- the class of the page to analyze- Returns:
- true if there's a need to perform an accessibility analysis of a basePage or false otherwise
-
addWCAGResults
public void addWCAGResults(String url, String className, com.deque.html.axecore.results.Results axeResults)
Appends WCAG results to the current context.- Parameters:
url
- the URL of the page analyzedclassName
- the class of the page analyzedaxeResults
- results found on the page to append to the WCAGContext aggregated result
-
addWCAGTime
public void addWCAGTime(long time)
- Parameters:
time
- the amount of time to count up, in ms.
-
getWCAGTime
public long getWCAGTime()
- Returns:
- the accumulated time spent validating accessibility.
-
getWCAGFailCount
public long getWCAGFailCount()
- Returns:
- the total count of failing wcag violations.
-
getWCAGWarnCount
public long getWCAGWarnCount()
- Returns:
- the total count of non failing wcag violations.
-
getWCAGIncompleteCount
public long getWCAGIncompleteCount()
- Returns:
- the total count of incomplete wcag checks.
-
setWCAGEnabled
public void setWCAGEnabled(boolean wcag)
- Parameters:
wcag
- validation enabled setup parameter to use in the test suite.
-
isWCAGEnabled
public boolean isWCAGEnabled()
- Returns:
- true if WCAG validation is enabled, false otherwise
-
setWCAGStopOnError
public void setWCAGStopOnError(boolean stopOnError)
- Parameters:
stopOnError
-false
if WCAG validation should ignore errors,true
otherwise.
-
shouldWCAGStopOnError
public boolean shouldWCAGStopOnError()
- Returns:
false
if WCAG validation should ignore errors,true
otherwise.
-
hasWCAGIncomplete
public boolean hasWCAGIncomplete()
- Returns:
- any of the validations found an incomplete check.
-
hasWCAGFails
public boolean hasWCAGFails()
- Returns:
- any of the validations found a failing violation.
-
hasWCAGWarnings
public boolean hasWCAGWarnings()
- Returns:
- any of the validations found a warning violation.
-
buildIncompleteReport
public String buildIncompleteReport()
- Returns:
- a readable report of WCAG incomplete tests found so far.
-
buildFailsReport
public String buildFailsReport()
- Returns:
- a readable report of WCAG failures found so far.
-
buildWarningsReport
public String buildWarningsReport()
- Returns:
- a readable report of WCAG violations (non failing) found so far.
-
buildOverview
public String buildOverview()
Build the content of the wcag analysis overview. This overview contains stats on all the checks done in this test suite.- Returns:
- a readable overview of WCAG results.
-
writeWCAGReportToFile
public static void writeWCAGReportToFile(File outputFile, String output) throws IOException
Writes a WCAG report to a file for proper accessibility warnings and failures examination.- Parameters:
outputFile
- the file to write the test results tooutput
- the test results to write- Throws:
IOException
-
-