org.w3c.mwi.mobileok.basic
Class AbstractCSSTestImplementation

java.lang.Object
  extended by org.w3c.mwi.mobileok.basic.AbstractTestImplementation
      extended by org.w3c.mwi.mobileok.basic.AbstractCSSTestImplementation
All Implemented Interfaces:
TestImplementation
Direct Known Subclasses:
MeasuresTest, StyleSheetsSupportTest

abstract class AbstractCSSTestImplementation
extends AbstractTestImplementation

Abstract implementation of AbstractTestImplementation that provides helper methods to parse the CSS styles (whether inline, embedded or external) defined in the Web resource under test.

Version:
$Revision: 1.1 $
Author:
The W3C mobileOK Checker Task Force

Nested Class Summary
(package private) static class AbstractCSSTestImplementation.TestErrorInfo
           
 
Field Summary
private static javax.xml.xpath.XPathExpression DOC_CONTENT_EXPR
          XPath expression to extract the content of the (potentially tidied) XHTML resource under test in a moki representation of a resource.
private static javax.xml.xpath.XPathExpression EMBEDDED_STYLESHEETS_EXPR
          XPath expression to extract the content of the embedded CSS styles in a moki representation of a resource.
private static javax.xml.xpath.XPathExpression EXTERNAL_STYLESHEETS_EXPR
          XPath expression to extract the content of the external CSS stylesheets in a moki representation of a resource.
private static javax.xml.xpath.XPathExpression EXTERNAL_STYLESHEETS_URI_EXPR
          XPath expression to extract the final URI of the external CSS stylesheets in a moki representation of a resource.
private static javax.xml.xpath.XPathExpression INLINE_STYLE_EXPR
          XPath expression to extract the content of the CSS styles declared inline in a moki representation of a resource.
private static javax.xml.xpath.XPathExpression PRIMARY_DOC_URI_EXPR
          XPath expression to extract the final URI of the primary document in a moki representation of a resource.
 
Constructor Summary
AbstractCSSTestImplementation()
           
 
Method Summary
(package private) abstract  void addSubResultsToResultsDocument(org.w3c.dom.Document testResults, org.w3c.dom.Element test, java.util.List<AbstractCSSTestImplementation.TestErrorInfo> measuresErrors)
           
(package private)  void addSubResultsToResultsDocument(org.w3c.dom.Document testResults, org.w3c.dom.Node test, java.lang.Iterable<AbstractCSSTestImplementation.TestErrorInfo> cssErrors, java.lang.String resultName, java.lang.String resultOutcome, java.lang.String infoString)
           
private  java.util.List<AbstractCSSTestImplementation.TestErrorInfo> evaluateCSSErrors(java.lang.String cssContent, java.lang.String uri, int lineOffset)
          Parses given CSS styles searching for test errors.
(package private) abstract  java.util.List<AbstractCSSTestImplementation.TestErrorInfo> findTestErrors(java.lang.String line)
           
private  org.w3c.dom.Document generateResultsOnCSSContent(PreprocessorResults results)
           
private static int getDocContentLineNumber(org.w3c.dom.Document moki)
           
 TestResult runTest(PreprocessorResults results)
           
 
Methods inherited from class org.w3c.mwi.mobileok.basic.AbstractTestImplementation
convertToTestResult, toString
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 
Methods inherited from interface org.w3c.mwi.mobileok.basic.TestImplementation
getTestType
 

Field Detail

EXTERNAL_STYLESHEETS_EXPR

private static final javax.xml.xpath.XPathExpression EXTERNAL_STYLESHEETS_EXPR
XPath expression to extract the content of the external CSS stylesheets in a moki representation of a resource.


EXTERNAL_STYLESHEETS_URI_EXPR

private static final javax.xml.xpath.XPathExpression EXTERNAL_STYLESHEETS_URI_EXPR
XPath expression to extract the final URI of the external CSS stylesheets in a moki representation of a resource.


PRIMARY_DOC_URI_EXPR

private static final javax.xml.xpath.XPathExpression PRIMARY_DOC_URI_EXPR
XPath expression to extract the final URI of the primary document in a moki representation of a resource.


EMBEDDED_STYLESHEETS_EXPR

private static final javax.xml.xpath.XPathExpression EMBEDDED_STYLESHEETS_EXPR
XPath expression to extract the content of the embedded CSS styles in a moki representation of a resource.


INLINE_STYLE_EXPR

private static final javax.xml.xpath.XPathExpression INLINE_STYLE_EXPR
XPath expression to extract the content of the CSS styles declared inline in a moki representation of a resource.


DOC_CONTENT_EXPR

private static final javax.xml.xpath.XPathExpression DOC_CONTENT_EXPR
XPath expression to extract the content of the (potentially tidied) XHTML resource under test in a moki representation of a resource.

Constructor Detail

AbstractCSSTestImplementation

AbstractCSSTestImplementation()
Method Detail

runTest

public TestResult runTest(PreprocessorResults results)
                   throws TestException
Throws:
TestException

generateResultsOnCSSContent

private org.w3c.dom.Document generateResultsOnCSSContent(PreprocessorResults results)
                                                  throws TestException
Throws:
TestException

getDocContentLineNumber

private static int getDocContentLineNumber(org.w3c.dom.Document moki)
                                    throws TestException
Throws:
TestException

evaluateCSSErrors

private java.util.List<AbstractCSSTestImplementation.TestErrorInfo> evaluateCSSErrors(java.lang.String cssContent,
                                                                                      java.lang.String uri,
                                                                                      int lineOffset)
                                                                               throws TestException
Parses given CSS styles searching for test errors.

Parameters:
cssContent - CSS styles to parse.
uri - URI of the resource that contains the CSS styles being parsed.
lineOffset - line offset of the starting line of the CSS styles in the resource.
Returns:
a list of detailed test errors.
Throws:
TestException - an unexpected error occurred.

findTestErrors

abstract java.util.List<AbstractCSSTestImplementation.TestErrorInfo> findTestErrors(java.lang.String line)

addSubResultsToResultsDocument

abstract void addSubResultsToResultsDocument(org.w3c.dom.Document testResults,
                                             org.w3c.dom.Element test,
                                             java.util.List<AbstractCSSTestImplementation.TestErrorInfo> measuresErrors)

addSubResultsToResultsDocument

void addSubResultsToResultsDocument(org.w3c.dom.Document testResults,
                                    org.w3c.dom.Node test,
                                    java.lang.Iterable<AbstractCSSTestImplementation.TestErrorInfo> cssErrors,
                                    java.lang.String resultName,
                                    java.lang.String resultOutcome,
                                    java.lang.String infoString)