Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Writing shorthand tests #2

Closed
dauwhe opened this issue Nov 20, 2020 · 1 comment
Closed

Writing shorthand tests #2

dauwhe opened this issue Nov 20, 2020 · 1 comment

Comments

@dauwhe
Copy link
Contributor

dauwhe commented Nov 20, 2020

Brady mentioned the idea of a JSON file for test structure and metadata that would be processed into a test EPUB.

I wonder if XML might be more appropriate, just because almost all EPUB documents are XML-based. I was playing around with a test for a package version attribute less than three.

The idea here is you can specify exactly what you want to test, but some script will fill in all the boilerplate.

<package xmlns="http://www.idpf.org/2007/opf" version="0" xml:lang="en" unique-identifier="q">
  <metadata xmlns:dc="http://purl.org/dc/elements/1.1/">
    <dc:title>Package Version Zero 001</dc:title>
    <meta name="assert" content="This test checks if a reading system will open an EPUB with package version attribute less than 3" />
    <meta name="test" content="test passes if this text is visible" />
    <meta name="help" href="https://w3c.github.io/epub-specs/epub33/rs/#confreq-rs-backward-epub"/>
    &date;
    &identifier;
    &language;
  </metadata>
  &manifest;
  &spine;
</package>

Here, dc:title is the name of the test. The entities can be expanded to create the needed boilerplate.

meta name="assert" describes the test (this is the syntax used by CSSWG tests).

meta name="test" describes the criteria for the test passing--in this case, just that the EPUB opened. This text would be put in the HTML file for the EPUB.

meta name="help" is the link to the statement in the specification we are testing (this is the syntax used by CSSWG tests).

Similarly, we could use the same idea for HTML-based tests. Create the file we need to test with the relevant metadata, and then script into an EPUB. Example soon.

@dauwhe
Copy link
Contributor Author

dauwhe commented Nov 20, 2020

Same idea. Script can turn this into an EPUB, as we don't need a customized package file.

<html xmlns="http://www.w3.org/1999/xhtml" xmlns:epub="http://www.idpf.org/2007/ops" xml:lang="en">
<head>
<title>CMT Images PNG 001</title>
<meta name="help" href="https://w3c.github.io/epub-specs/epub33/core/#sec-cmt-supported"/>
<meta name="flags" content="image"/>
<meta name="assert" content="This test checks if a reading system supports PNG as a core media type" />
</head>
<body>
  <img src="support/green-square.png" alt="green square"/>
  <p>Test passes if a green square is visible above</p>
</body>
</html>

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant