From da643e4010befdc6ba1fd8cf4bff5e8cee912bc5 Mon Sep 17 00:00:00 2001 From: Romain Deltour Date: Wed, 5 Jul 2023 17:09:55 +0200 Subject: [PATCH] fix: properly set the rendition fields in the JSON report See #1515 --- .../com/adobe/epubcheck/opf/OPFHandler30.java | 74 +++++++++++++---- .../EPUB/content_001.xhtml | 12 +++ .../EPUB/content_002.xhtml | 12 +++ .../layout-orientation-item/EPUB/nav.xhtml | 14 ++++ .../layout-orientation-item/EPUB/package.opf | 19 +++++ .../META-INF/container.xml | 6 ++ .../files/layout-orientation-item/mimetype | 1 + .../layout-orientation/EPUB/content_001.xhtml | 12 +++ .../layout-orientation/EPUB/content_002.xhtml | 12 +++ .../files/layout-orientation/EPUB/nav.xhtml | 14 ++++ .../files/layout-orientation/EPUB/package.opf | 20 +++++ .../layout-orientation/META-INF/container.xml | 6 ++ .../files/layout-orientation/mimetype | 1 + .../EPUB/content_001.xhtml | 11 +++ .../EPUB/content_002.xhtml | 12 +++ .../layout-paginated-item/EPUB/nav.xhtml | 14 ++++ .../layout-paginated-item/EPUB/package.opf | 18 ++++ .../META-INF/container.xml | 6 ++ .../files/layout-paginated-item/mimetype | 1 + .../layout-paginated/EPUB/content_001.xhtml | 12 +++ .../files/layout-paginated/EPUB/nav.xhtml | 14 ++++ .../files/layout-paginated/EPUB/package.opf | 17 ++++ .../layout-paginated/META-INF/container.xml | 6 ++ .../reporting/files/layout-paginated/mimetype | 1 + .../EPUB/content_001.xhtml | 12 +++ .../EPUB/content_002.xhtml | 11 +++ .../layout-reflowable-item/EPUB/nav.xhtml | 14 ++++ .../layout-reflowable-item/EPUB/package.opf | 19 +++++ .../META-INF/container.xml | 6 ++ .../files/layout-reflowable-item/mimetype | 1 + .../layout-reflowable/EPUB/content_001.xhtml | 11 +++ .../files/layout-reflowable/EPUB/nav.xhtml | 14 ++++ .../files/layout-reflowable/EPUB/package.opf | 16 ++++ .../layout-reflowable/META-INF/container.xml | 6 ++ .../files/layout-reflowable/mimetype | 1 + .../layout-spread-item/EPUB/content_001.xhtml | 12 +++ .../layout-spread-item/EPUB/content_002.xhtml | 12 +++ .../files/layout-spread-item/EPUB/nav.xhtml | 14 ++++ .../files/layout-spread-item/EPUB/package.opf | 19 +++++ .../layout-spread-item/META-INF/container.xml | 6 ++ .../files/layout-spread-item/mimetype | 1 + .../layout-spread/EPUB/content_001.xhtml | 12 +++ .../layout-spread/EPUB/content_002.xhtml | 12 +++ .../files/layout-spread/EPUB/nav.xhtml | 14 ++++ .../files/layout-spread/EPUB/package.opf | 20 +++++ .../layout-spread/META-INF/container.xml | 6 ++ .../reporting/files/layout-spread/mimetype | 1 + .../resources/reporting/json-report.feature | 82 ++++++++++++++++++- 48 files changed, 620 insertions(+), 17 deletions(-) create mode 100644 src/test/resources/reporting/files/layout-orientation-item/EPUB/content_001.xhtml create mode 100644 src/test/resources/reporting/files/layout-orientation-item/EPUB/content_002.xhtml create mode 100644 src/test/resources/reporting/files/layout-orientation-item/EPUB/nav.xhtml create mode 100644 src/test/resources/reporting/files/layout-orientation-item/EPUB/package.opf create mode 100644 src/test/resources/reporting/files/layout-orientation-item/META-INF/container.xml create mode 100644 src/test/resources/reporting/files/layout-orientation-item/mimetype create mode 100644 src/test/resources/reporting/files/layout-orientation/EPUB/content_001.xhtml create mode 100644 src/test/resources/reporting/files/layout-orientation/EPUB/content_002.xhtml create mode 100644 src/test/resources/reporting/files/layout-orientation/EPUB/nav.xhtml create mode 100644 src/test/resources/reporting/files/layout-orientation/EPUB/package.opf create mode 100644 src/test/resources/reporting/files/layout-orientation/META-INF/container.xml create mode 100644 src/test/resources/reporting/files/layout-orientation/mimetype create mode 100644 src/test/resources/reporting/files/layout-paginated-item/EPUB/content_001.xhtml create mode 100644 src/test/resources/reporting/files/layout-paginated-item/EPUB/content_002.xhtml create mode 100644 src/test/resources/reporting/files/layout-paginated-item/EPUB/nav.xhtml create mode 100644 src/test/resources/reporting/files/layout-paginated-item/EPUB/package.opf create mode 100644 src/test/resources/reporting/files/layout-paginated-item/META-INF/container.xml create mode 100644 src/test/resources/reporting/files/layout-paginated-item/mimetype create mode 100644 src/test/resources/reporting/files/layout-paginated/EPUB/content_001.xhtml create mode 100644 src/test/resources/reporting/files/layout-paginated/EPUB/nav.xhtml create mode 100644 src/test/resources/reporting/files/layout-paginated/EPUB/package.opf create mode 100644 src/test/resources/reporting/files/layout-paginated/META-INF/container.xml create mode 100644 src/test/resources/reporting/files/layout-paginated/mimetype create mode 100644 src/test/resources/reporting/files/layout-reflowable-item/EPUB/content_001.xhtml create mode 100644 src/test/resources/reporting/files/layout-reflowable-item/EPUB/content_002.xhtml create mode 100644 src/test/resources/reporting/files/layout-reflowable-item/EPUB/nav.xhtml create mode 100644 src/test/resources/reporting/files/layout-reflowable-item/EPUB/package.opf create mode 100644 src/test/resources/reporting/files/layout-reflowable-item/META-INF/container.xml create mode 100644 src/test/resources/reporting/files/layout-reflowable-item/mimetype create mode 100644 src/test/resources/reporting/files/layout-reflowable/EPUB/content_001.xhtml create mode 100644 src/test/resources/reporting/files/layout-reflowable/EPUB/nav.xhtml create mode 100644 src/test/resources/reporting/files/layout-reflowable/EPUB/package.opf create mode 100644 src/test/resources/reporting/files/layout-reflowable/META-INF/container.xml create mode 100644 src/test/resources/reporting/files/layout-reflowable/mimetype create mode 100644 src/test/resources/reporting/files/layout-spread-item/EPUB/content_001.xhtml create mode 100644 src/test/resources/reporting/files/layout-spread-item/EPUB/content_002.xhtml create mode 100644 src/test/resources/reporting/files/layout-spread-item/EPUB/nav.xhtml create mode 100644 src/test/resources/reporting/files/layout-spread-item/EPUB/package.opf create mode 100644 src/test/resources/reporting/files/layout-spread-item/META-INF/container.xml create mode 100644 src/test/resources/reporting/files/layout-spread-item/mimetype create mode 100644 src/test/resources/reporting/files/layout-spread/EPUB/content_001.xhtml create mode 100644 src/test/resources/reporting/files/layout-spread/EPUB/content_002.xhtml create mode 100644 src/test/resources/reporting/files/layout-spread/EPUB/nav.xhtml create mode 100644 src/test/resources/reporting/files/layout-spread/EPUB/package.opf create mode 100644 src/test/resources/reporting/files/layout-spread/META-INF/container.xml create mode 100644 src/test/resources/reporting/files/layout-spread/mimetype diff --git a/src/main/java/com/adobe/epubcheck/opf/OPFHandler30.java b/src/main/java/com/adobe/epubcheck/opf/OPFHandler30.java index e625e5c2b..b7f9ab576 100644 --- a/src/main/java/com/adobe/epubcheck/opf/OPFHandler30.java +++ b/src/main/java/com/adobe/epubcheck/opf/OPFHandler30.java @@ -62,6 +62,7 @@ import com.adobe.epubcheck.api.QuietReport; import com.adobe.epubcheck.messages.LocalizedMessages; import com.adobe.epubcheck.messages.MessageId; +import com.adobe.epubcheck.opf.MetadataSet.Metadata; import com.adobe.epubcheck.opf.ResourceCollection.Roles; import com.adobe.epubcheck.util.EpubConstants; import com.adobe.epubcheck.util.FeatureEnum; @@ -96,7 +97,8 @@ public class OPFHandler30 extends OPFHandler .put(DCTERMS_PREFIX, DCTERMS_VOCAB).put(MARC_PREFIX, MARC_VOCAB).put(ONIX_PREFIX, ONIX_VOCAB) .put(SCHEMA_PREFIX, SCHEMA_VOCAB).put(XSD_PREFIX, XSD_VOCAB).build(); private static final Map RESERVED_META_VOCABS = new ImmutableMap.Builder() - .put("", AggregateVocab.of(META_VOCAB, META_VOCAB_CAMEL)).put(AccessibilityVocab.PREFIX, AccessibilityVocab.META_VOCAB) + .put("", AggregateVocab.of(META_VOCAB, META_VOCAB_CAMEL)) + .put(AccessibilityVocab.PREFIX, AccessibilityVocab.META_VOCAB) .put(MediaOverlaysVocab.PREFIX, MediaOverlaysVocab.VOCAB) .put(RenditionVocabs.PREFIX, RenditionVocabs.META_VOCAB).putAll(RESERVED_VOCABS).build(); private static final Map RESERVED_ITEM_VOCABS = new ImmutableMap.Builder() @@ -646,10 +648,28 @@ private void checkLanguageTag(String language) protected void reportMetadata() { + // Report publication rendition layout if (getMetadata().containsPrimary( RenditionVocabs.META_VOCAB.get(RenditionVocabs.META_PROPERTIES.LAYOUT), "pre-paginated")) { - report.info(null, FeatureEnum.HAS_FIXED_LAYOUT, "pre-paginated"); + report.info(null, FeatureEnum.RENDITION_LAYOUT, "pre-paginated"); + report.info(null, FeatureEnum.HAS_FIXED_LAYOUT, "true"); + } + // Report publication rendition orientation (if set) + Optional orientation = MetadataSet.tryFind(getMetadata().getAll(), + RenditionVocabs.META_VOCAB.get(RenditionVocabs.META_PROPERTIES.ORIENTATION), + Optional.absent()); + if (orientation.isPresent()) + { + report.info(null, FeatureEnum.RENDITION_ORIENTATION, orientation.get().getValue()); + } + // Report publication rendition spread (if set) + Optional spread = MetadataSet.tryFind(getMetadata().getAll(), + RenditionVocabs.META_VOCAB.get(RenditionVocabs.META_PROPERTIES.SPREAD), + Optional.absent()); + if (spread.isPresent()) + { + report.info(null, FeatureEnum.RENDITION_SPREAD, spread.get().getValue()); } } @@ -657,21 +677,43 @@ protected void reportMetadata() protected void reportItem(OPFItem item) { super.reportItem(item); - boolean isFixed = getMetadata().containsPrimary( - RenditionVocabs.META_VOCAB.get(RenditionVocabs.META_PROPERTIES.LAYOUT), "pre-paginated"); - if (item.getProperties().contains( - RenditionVocabs.ITEMREF_VOCAB.get(RenditionVocabs.ITEMREF_PROPERTIES.LAYOUT_PRE_PAGINATED))) - { - isFixed = true; - } - else if (item.getProperties().contains( - RenditionVocabs.ITEMREF_VOCAB.get(RenditionVocabs.ITEMREF_PROPERTIES.LAYOUT_REFLOWABLE))) - { - isFixed = false; - } - if (isFixed) + + // Report rendition properties overrides + Set properties = Property.filter(item.getProperties(), + RenditionVocabs.ITEMREF_PROPERTIES.class); + for (RenditionVocabs.ITEMREF_PROPERTIES property : properties) { - report.info(item.getPath(), FeatureEnum.HAS_FIXED_LAYOUT, String.valueOf(true)); + switch (property) + { + // Rendition layout properties + case LAYOUT_PRE_PAGINATED: + report.info(item.getPath(), FeatureEnum.RENDITION_LAYOUT, "pre-paginated"); + report.info(item.getPath(), FeatureEnum.HAS_FIXED_LAYOUT, "true"); + break; + case LAYOUT_REFLOWABLE: + report.info(item.getPath(), FeatureEnum.RENDITION_LAYOUT, "reflowable"); + report.info(item.getPath(), FeatureEnum.HAS_FIXED_LAYOUT, "false"); + break; + // Orientation properties + case ORIENTATION_AUTO: + case ORIENTATION_LANDSCAPE: + case ORIENTATION_PORTRAIT: + report.info(item.getPath(), FeatureEnum.RENDITION_ORIENTATION, + property.name().substring(12).toLowerCase(Locale.ROOT)); + break; + // Spread properties + case SPREAD_AUTO: + case SPREAD_BOTH: + case SPREAD_LANDSCAPE: + case SPREAD_NONE: + case SPREAD_PORTRAIT: + report.info(item.getPath(), FeatureEnum.RENDITION_SPREAD, + property.name().substring(7).toLowerCase(Locale.ROOT)); + break; + + default: + break; + } } } } diff --git a/src/test/resources/reporting/files/layout-orientation-item/EPUB/content_001.xhtml b/src/test/resources/reporting/files/layout-orientation-item/EPUB/content_001.xhtml new file mode 100644 index 000000000..1713b79db --- /dev/null +++ b/src/test/resources/reporting/files/layout-orientation-item/EPUB/content_001.xhtml @@ -0,0 +1,12 @@ + + + + + + Minimal EPUB + + +

Loomings

+

Call me Ishmael.

+ + diff --git a/src/test/resources/reporting/files/layout-orientation-item/EPUB/content_002.xhtml b/src/test/resources/reporting/files/layout-orientation-item/EPUB/content_002.xhtml new file mode 100644 index 000000000..1713b79db --- /dev/null +++ b/src/test/resources/reporting/files/layout-orientation-item/EPUB/content_002.xhtml @@ -0,0 +1,12 @@ + + + + + + Minimal EPUB + + +

Loomings

+

Call me Ishmael.

+ + diff --git a/src/test/resources/reporting/files/layout-orientation-item/EPUB/nav.xhtml b/src/test/resources/reporting/files/layout-orientation-item/EPUB/nav.xhtml new file mode 100644 index 000000000..240745e63 --- /dev/null +++ b/src/test/resources/reporting/files/layout-orientation-item/EPUB/nav.xhtml @@ -0,0 +1,14 @@ + + + + + Minimal Nav + + + + + diff --git a/src/test/resources/reporting/files/layout-orientation-item/EPUB/package.opf b/src/test/resources/reporting/files/layout-orientation-item/EPUB/package.opf new file mode 100644 index 000000000..2851e7e66 --- /dev/null +++ b/src/test/resources/reporting/files/layout-orientation-item/EPUB/package.opf @@ -0,0 +1,19 @@ + + + + Minimal EPUB 3.0 + en + NOID + 2017-06-14T00:00:01Z + pre-paginated + + + + + + + + + + + \ No newline at end of file diff --git a/src/test/resources/reporting/files/layout-orientation-item/META-INF/container.xml b/src/test/resources/reporting/files/layout-orientation-item/META-INF/container.xml new file mode 100644 index 000000000..318782179 --- /dev/null +++ b/src/test/resources/reporting/files/layout-orientation-item/META-INF/container.xml @@ -0,0 +1,6 @@ + + + + + + diff --git a/src/test/resources/reporting/files/layout-orientation-item/mimetype b/src/test/resources/reporting/files/layout-orientation-item/mimetype new file mode 100644 index 000000000..57ef03f24 --- /dev/null +++ b/src/test/resources/reporting/files/layout-orientation-item/mimetype @@ -0,0 +1 @@ +application/epub+zip \ No newline at end of file diff --git a/src/test/resources/reporting/files/layout-orientation/EPUB/content_001.xhtml b/src/test/resources/reporting/files/layout-orientation/EPUB/content_001.xhtml new file mode 100644 index 000000000..1713b79db --- /dev/null +++ b/src/test/resources/reporting/files/layout-orientation/EPUB/content_001.xhtml @@ -0,0 +1,12 @@ + + + + + + Minimal EPUB + + +

Loomings

+

Call me Ishmael.

+ + diff --git a/src/test/resources/reporting/files/layout-orientation/EPUB/content_002.xhtml b/src/test/resources/reporting/files/layout-orientation/EPUB/content_002.xhtml new file mode 100644 index 000000000..1713b79db --- /dev/null +++ b/src/test/resources/reporting/files/layout-orientation/EPUB/content_002.xhtml @@ -0,0 +1,12 @@ + + + + + + Minimal EPUB + + +

Loomings

+

Call me Ishmael.

+ + diff --git a/src/test/resources/reporting/files/layout-orientation/EPUB/nav.xhtml b/src/test/resources/reporting/files/layout-orientation/EPUB/nav.xhtml new file mode 100644 index 000000000..240745e63 --- /dev/null +++ b/src/test/resources/reporting/files/layout-orientation/EPUB/nav.xhtml @@ -0,0 +1,14 @@ + + + + + Minimal Nav + + + + + diff --git a/src/test/resources/reporting/files/layout-orientation/EPUB/package.opf b/src/test/resources/reporting/files/layout-orientation/EPUB/package.opf new file mode 100644 index 000000000..91e4f13ae --- /dev/null +++ b/src/test/resources/reporting/files/layout-orientation/EPUB/package.opf @@ -0,0 +1,20 @@ + + + + Minimal EPUB 3.0 + en + NOID + 2017-06-14T00:00:01Z + pre-paginated + portrait + + + + + + + + + + + \ No newline at end of file diff --git a/src/test/resources/reporting/files/layout-orientation/META-INF/container.xml b/src/test/resources/reporting/files/layout-orientation/META-INF/container.xml new file mode 100644 index 000000000..318782179 --- /dev/null +++ b/src/test/resources/reporting/files/layout-orientation/META-INF/container.xml @@ -0,0 +1,6 @@ + + + + + + diff --git a/src/test/resources/reporting/files/layout-orientation/mimetype b/src/test/resources/reporting/files/layout-orientation/mimetype new file mode 100644 index 000000000..57ef03f24 --- /dev/null +++ b/src/test/resources/reporting/files/layout-orientation/mimetype @@ -0,0 +1 @@ +application/epub+zip \ No newline at end of file diff --git a/src/test/resources/reporting/files/layout-paginated-item/EPUB/content_001.xhtml b/src/test/resources/reporting/files/layout-paginated-item/EPUB/content_001.xhtml new file mode 100644 index 000000000..43a520ea2 --- /dev/null +++ b/src/test/resources/reporting/files/layout-paginated-item/EPUB/content_001.xhtml @@ -0,0 +1,11 @@ + + + + + Minimal EPUB + + +

Loomings

+

Call me Ishmael.

+ + diff --git a/src/test/resources/reporting/files/layout-paginated-item/EPUB/content_002.xhtml b/src/test/resources/reporting/files/layout-paginated-item/EPUB/content_002.xhtml new file mode 100644 index 000000000..1fb95490d --- /dev/null +++ b/src/test/resources/reporting/files/layout-paginated-item/EPUB/content_002.xhtml @@ -0,0 +1,12 @@ + + + + + Minimal EPUB + + + +

Loomings

+

Call me Ishmael.

+ + diff --git a/src/test/resources/reporting/files/layout-paginated-item/EPUB/nav.xhtml b/src/test/resources/reporting/files/layout-paginated-item/EPUB/nav.xhtml new file mode 100644 index 000000000..240745e63 --- /dev/null +++ b/src/test/resources/reporting/files/layout-paginated-item/EPUB/nav.xhtml @@ -0,0 +1,14 @@ + + + + + Minimal Nav + + + + + diff --git a/src/test/resources/reporting/files/layout-paginated-item/EPUB/package.opf b/src/test/resources/reporting/files/layout-paginated-item/EPUB/package.opf new file mode 100644 index 000000000..18af9ac76 --- /dev/null +++ b/src/test/resources/reporting/files/layout-paginated-item/EPUB/package.opf @@ -0,0 +1,18 @@ + + + + Minimal EPUB 3.0 + en + NOID + 2017-06-14T00:00:01Z + + + + + + + + + + + \ No newline at end of file diff --git a/src/test/resources/reporting/files/layout-paginated-item/META-INF/container.xml b/src/test/resources/reporting/files/layout-paginated-item/META-INF/container.xml new file mode 100644 index 000000000..318782179 --- /dev/null +++ b/src/test/resources/reporting/files/layout-paginated-item/META-INF/container.xml @@ -0,0 +1,6 @@ + + + + + + diff --git a/src/test/resources/reporting/files/layout-paginated-item/mimetype b/src/test/resources/reporting/files/layout-paginated-item/mimetype new file mode 100644 index 000000000..57ef03f24 --- /dev/null +++ b/src/test/resources/reporting/files/layout-paginated-item/mimetype @@ -0,0 +1 @@ +application/epub+zip \ No newline at end of file diff --git a/src/test/resources/reporting/files/layout-paginated/EPUB/content_001.xhtml b/src/test/resources/reporting/files/layout-paginated/EPUB/content_001.xhtml new file mode 100644 index 000000000..1713b79db --- /dev/null +++ b/src/test/resources/reporting/files/layout-paginated/EPUB/content_001.xhtml @@ -0,0 +1,12 @@ + + + + + + Minimal EPUB + + +

Loomings

+

Call me Ishmael.

+ + diff --git a/src/test/resources/reporting/files/layout-paginated/EPUB/nav.xhtml b/src/test/resources/reporting/files/layout-paginated/EPUB/nav.xhtml new file mode 100644 index 000000000..240745e63 --- /dev/null +++ b/src/test/resources/reporting/files/layout-paginated/EPUB/nav.xhtml @@ -0,0 +1,14 @@ + + + + + Minimal Nav + + + + + diff --git a/src/test/resources/reporting/files/layout-paginated/EPUB/package.opf b/src/test/resources/reporting/files/layout-paginated/EPUB/package.opf new file mode 100644 index 000000000..d16a30d60 --- /dev/null +++ b/src/test/resources/reporting/files/layout-paginated/EPUB/package.opf @@ -0,0 +1,17 @@ + + + + Minimal EPUB 3.0 + en + NOID + 2017-06-14T00:00:01Z + pre-paginated + + + + + + + + + \ No newline at end of file diff --git a/src/test/resources/reporting/files/layout-paginated/META-INF/container.xml b/src/test/resources/reporting/files/layout-paginated/META-INF/container.xml new file mode 100644 index 000000000..318782179 --- /dev/null +++ b/src/test/resources/reporting/files/layout-paginated/META-INF/container.xml @@ -0,0 +1,6 @@ + + + + + + diff --git a/src/test/resources/reporting/files/layout-paginated/mimetype b/src/test/resources/reporting/files/layout-paginated/mimetype new file mode 100644 index 000000000..57ef03f24 --- /dev/null +++ b/src/test/resources/reporting/files/layout-paginated/mimetype @@ -0,0 +1 @@ +application/epub+zip \ No newline at end of file diff --git a/src/test/resources/reporting/files/layout-reflowable-item/EPUB/content_001.xhtml b/src/test/resources/reporting/files/layout-reflowable-item/EPUB/content_001.xhtml new file mode 100644 index 000000000..1713b79db --- /dev/null +++ b/src/test/resources/reporting/files/layout-reflowable-item/EPUB/content_001.xhtml @@ -0,0 +1,12 @@ + + + + + + Minimal EPUB + + +

Loomings

+

Call me Ishmael.

+ + diff --git a/src/test/resources/reporting/files/layout-reflowable-item/EPUB/content_002.xhtml b/src/test/resources/reporting/files/layout-reflowable-item/EPUB/content_002.xhtml new file mode 100644 index 000000000..ea29a1610 --- /dev/null +++ b/src/test/resources/reporting/files/layout-reflowable-item/EPUB/content_002.xhtml @@ -0,0 +1,11 @@ + + + + + Minimal EPUB + + +

Loomings

+

Call me Ishmael.

+ + diff --git a/src/test/resources/reporting/files/layout-reflowable-item/EPUB/nav.xhtml b/src/test/resources/reporting/files/layout-reflowable-item/EPUB/nav.xhtml new file mode 100644 index 000000000..240745e63 --- /dev/null +++ b/src/test/resources/reporting/files/layout-reflowable-item/EPUB/nav.xhtml @@ -0,0 +1,14 @@ + + + + + Minimal Nav + + + + + diff --git a/src/test/resources/reporting/files/layout-reflowable-item/EPUB/package.opf b/src/test/resources/reporting/files/layout-reflowable-item/EPUB/package.opf new file mode 100644 index 000000000..0f108cc2c --- /dev/null +++ b/src/test/resources/reporting/files/layout-reflowable-item/EPUB/package.opf @@ -0,0 +1,19 @@ + + + + Minimal EPUB 3.0 + en + NOID + 2017-06-14T00:00:01Z + pre-paginated + + + + + + + + + + + \ No newline at end of file diff --git a/src/test/resources/reporting/files/layout-reflowable-item/META-INF/container.xml b/src/test/resources/reporting/files/layout-reflowable-item/META-INF/container.xml new file mode 100644 index 000000000..318782179 --- /dev/null +++ b/src/test/resources/reporting/files/layout-reflowable-item/META-INF/container.xml @@ -0,0 +1,6 @@ + + + + + + diff --git a/src/test/resources/reporting/files/layout-reflowable-item/mimetype b/src/test/resources/reporting/files/layout-reflowable-item/mimetype new file mode 100644 index 000000000..57ef03f24 --- /dev/null +++ b/src/test/resources/reporting/files/layout-reflowable-item/mimetype @@ -0,0 +1 @@ +application/epub+zip \ No newline at end of file diff --git a/src/test/resources/reporting/files/layout-reflowable/EPUB/content_001.xhtml b/src/test/resources/reporting/files/layout-reflowable/EPUB/content_001.xhtml new file mode 100644 index 000000000..43a520ea2 --- /dev/null +++ b/src/test/resources/reporting/files/layout-reflowable/EPUB/content_001.xhtml @@ -0,0 +1,11 @@ + + + + + Minimal EPUB + + +

Loomings

+

Call me Ishmael.

+ + diff --git a/src/test/resources/reporting/files/layout-reflowable/EPUB/nav.xhtml b/src/test/resources/reporting/files/layout-reflowable/EPUB/nav.xhtml new file mode 100644 index 000000000..240745e63 --- /dev/null +++ b/src/test/resources/reporting/files/layout-reflowable/EPUB/nav.xhtml @@ -0,0 +1,14 @@ + + + + + Minimal Nav + + + + + diff --git a/src/test/resources/reporting/files/layout-reflowable/EPUB/package.opf b/src/test/resources/reporting/files/layout-reflowable/EPUB/package.opf new file mode 100644 index 000000000..0d1eec6e9 --- /dev/null +++ b/src/test/resources/reporting/files/layout-reflowable/EPUB/package.opf @@ -0,0 +1,16 @@ + + + + Minimal EPUB 3.0 + en + NOID + 2017-06-14T00:00:01Z + + + + + + + + + \ No newline at end of file diff --git a/src/test/resources/reporting/files/layout-reflowable/META-INF/container.xml b/src/test/resources/reporting/files/layout-reflowable/META-INF/container.xml new file mode 100644 index 000000000..318782179 --- /dev/null +++ b/src/test/resources/reporting/files/layout-reflowable/META-INF/container.xml @@ -0,0 +1,6 @@ + + + + + + diff --git a/src/test/resources/reporting/files/layout-reflowable/mimetype b/src/test/resources/reporting/files/layout-reflowable/mimetype new file mode 100644 index 000000000..57ef03f24 --- /dev/null +++ b/src/test/resources/reporting/files/layout-reflowable/mimetype @@ -0,0 +1 @@ +application/epub+zip \ No newline at end of file diff --git a/src/test/resources/reporting/files/layout-spread-item/EPUB/content_001.xhtml b/src/test/resources/reporting/files/layout-spread-item/EPUB/content_001.xhtml new file mode 100644 index 000000000..1713b79db --- /dev/null +++ b/src/test/resources/reporting/files/layout-spread-item/EPUB/content_001.xhtml @@ -0,0 +1,12 @@ + + + + + + Minimal EPUB + + +

Loomings

+

Call me Ishmael.

+ + diff --git a/src/test/resources/reporting/files/layout-spread-item/EPUB/content_002.xhtml b/src/test/resources/reporting/files/layout-spread-item/EPUB/content_002.xhtml new file mode 100644 index 000000000..1713b79db --- /dev/null +++ b/src/test/resources/reporting/files/layout-spread-item/EPUB/content_002.xhtml @@ -0,0 +1,12 @@ + + + + + + Minimal EPUB + + +

Loomings

+

Call me Ishmael.

+ + diff --git a/src/test/resources/reporting/files/layout-spread-item/EPUB/nav.xhtml b/src/test/resources/reporting/files/layout-spread-item/EPUB/nav.xhtml new file mode 100644 index 000000000..240745e63 --- /dev/null +++ b/src/test/resources/reporting/files/layout-spread-item/EPUB/nav.xhtml @@ -0,0 +1,14 @@ + + + + + Minimal Nav + + + + + diff --git a/src/test/resources/reporting/files/layout-spread-item/EPUB/package.opf b/src/test/resources/reporting/files/layout-spread-item/EPUB/package.opf new file mode 100644 index 000000000..f31ab5885 --- /dev/null +++ b/src/test/resources/reporting/files/layout-spread-item/EPUB/package.opf @@ -0,0 +1,19 @@ + + + + Minimal EPUB 3.0 + en + NOID + 2017-06-14T00:00:01Z + pre-paginated + + + + + + + + + + + \ No newline at end of file diff --git a/src/test/resources/reporting/files/layout-spread-item/META-INF/container.xml b/src/test/resources/reporting/files/layout-spread-item/META-INF/container.xml new file mode 100644 index 000000000..318782179 --- /dev/null +++ b/src/test/resources/reporting/files/layout-spread-item/META-INF/container.xml @@ -0,0 +1,6 @@ + + + + + + diff --git a/src/test/resources/reporting/files/layout-spread-item/mimetype b/src/test/resources/reporting/files/layout-spread-item/mimetype new file mode 100644 index 000000000..57ef03f24 --- /dev/null +++ b/src/test/resources/reporting/files/layout-spread-item/mimetype @@ -0,0 +1 @@ +application/epub+zip \ No newline at end of file diff --git a/src/test/resources/reporting/files/layout-spread/EPUB/content_001.xhtml b/src/test/resources/reporting/files/layout-spread/EPUB/content_001.xhtml new file mode 100644 index 000000000..1713b79db --- /dev/null +++ b/src/test/resources/reporting/files/layout-spread/EPUB/content_001.xhtml @@ -0,0 +1,12 @@ + + + + + + Minimal EPUB + + +

Loomings

+

Call me Ishmael.

+ + diff --git a/src/test/resources/reporting/files/layout-spread/EPUB/content_002.xhtml b/src/test/resources/reporting/files/layout-spread/EPUB/content_002.xhtml new file mode 100644 index 000000000..1713b79db --- /dev/null +++ b/src/test/resources/reporting/files/layout-spread/EPUB/content_002.xhtml @@ -0,0 +1,12 @@ + + + + + + Minimal EPUB + + +

Loomings

+

Call me Ishmael.

+ + diff --git a/src/test/resources/reporting/files/layout-spread/EPUB/nav.xhtml b/src/test/resources/reporting/files/layout-spread/EPUB/nav.xhtml new file mode 100644 index 000000000..240745e63 --- /dev/null +++ b/src/test/resources/reporting/files/layout-spread/EPUB/nav.xhtml @@ -0,0 +1,14 @@ + + + + + Minimal Nav + + + + + diff --git a/src/test/resources/reporting/files/layout-spread/EPUB/package.opf b/src/test/resources/reporting/files/layout-spread/EPUB/package.opf new file mode 100644 index 000000000..7531fe377 --- /dev/null +++ b/src/test/resources/reporting/files/layout-spread/EPUB/package.opf @@ -0,0 +1,20 @@ + + + + Minimal EPUB 3.0 + en + NOID + 2017-06-14T00:00:01Z + pre-paginated + none + + + + + + + + + + + \ No newline at end of file diff --git a/src/test/resources/reporting/files/layout-spread/META-INF/container.xml b/src/test/resources/reporting/files/layout-spread/META-INF/container.xml new file mode 100644 index 000000000..318782179 --- /dev/null +++ b/src/test/resources/reporting/files/layout-spread/META-INF/container.xml @@ -0,0 +1,6 @@ + + + + + + diff --git a/src/test/resources/reporting/files/layout-spread/mimetype b/src/test/resources/reporting/files/layout-spread/mimetype new file mode 100644 index 000000000..57ef03f24 --- /dev/null +++ b/src/test/resources/reporting/files/layout-spread/mimetype @@ -0,0 +1 @@ +application/epub+zip \ No newline at end of file diff --git a/src/test/resources/reporting/json-report.feature b/src/test/resources/reporting/json-report.feature index 4a86b4e04..3d53596bb 100644 --- a/src/test/resources/reporting/json-report.feature +++ b/src/test/resources/reporting/json-report.feature @@ -12,4 +12,84 @@ When checking EPUB 'minimal' Then the JSON report is valid And JSON at '$.items' contains 5 items - And JSON at '$..checkSum' has no null values + And JSON at '$..checkSum' has no null values + + ## Layout + + Scenario: layout field defaults + When checking EPUB 'minimal' + Then the JSON report is valid + And JSON at '$.publication.renditionLayout' is "reflowable" + And JSON at '$.publication.renditionOrientation' is "auto" + And JSON at '$.publication.renditionSpread' is "auto" + And JSON at '$.publication.hasFixedFormat' is false + And JSON at '$..items[?(@.isSpineItem==true)].renditionLayout' are all "reflowable" + And JSON at '$..items[?(@.isSpineItem==true)].renditionOrientation' are all "auto" + And JSON at '$..items[?(@.isSpineItem==true)].renditionSpread' are all "auto" + And JSON at '$..items[?(@.isSpineItem==true)].isFixedFormat' are all false + + Scenario: `renditionLayout` "pre-paginated" on publication + When checking EPUB 'layout-paginated' + Then the JSON report is valid + And JSON at '$.publication.renditionLayout' is "pre-paginated" + And JSON at '$.publication.hasFixedFormat' is true + And JSON at '$..items[?(@.isSpineItem==true)].renditionLayout' are all "pre-paginated" + And JSON at '$..items[?(@.isSpineItem==true)].isFixedFormat' are all true + + Scenario: `renditionLayout` "pre-paginated" on item + When checking EPUB 'layout-paginated-item' + Then the JSON report is valid + And JSON at '$.publication.renditionLayout' is "reflowable" + And JSON at '$.publication.hasFixedFormat' is true + And JSON at '$..items[?(@.isSpineItem==true)].renditionLayout' is: + | reflowable | + | pre-paginated | + + Scenario: `renditionLayout` "reflowable" on publication + When checking EPUB 'layout-reflowable' + Then the JSON report is valid + And JSON at '$.publication.renditionLayout' is "reflowable" + And JSON at '$.publication.hasFixedFormat' is false + And JSON at '$..items[?(@.isSpineItem==true)].renditionLayout' are all "reflowable" + And JSON at '$..items[?(@.isSpineItem==true)].isFixedFormat' are all false + + Scenario: `renditionLayout` "reflowable" on item + When checking EPUB 'layout-reflowable-item' + Then the JSON report is valid + And JSON at '$.publication.renditionLayout' is "pre-paginated" + And JSON at '$.publication.hasFixedFormat' is true + And JSON at '$..items[?(@.isSpineItem==true)].renditionLayout' is: + | pre-paginated | + | reflowable | + + Scenario: `renditionOrientation` on publication + When checking EPUB 'layout-orientation' + Then the JSON report is valid + And JSON at '$.publication.renditionLayout' is "pre-paginated" + And JSON at '$.publication.renditionOrientation' is "portrait" + And JSON at '$..items[?(@.isSpineItem==true)].renditionOrientation' are all "portrait" + + Scenario: `renditionOrientation` on item + When checking EPUB 'layout-orientation-item' + Then the JSON report is valid + And JSON at '$.publication.renditionLayout' is "pre-paginated" + And JSON at '$.publication.renditionOrientation' is "auto" + And JSON at '$..items[?(@.isSpineItem==true)].renditionOrientation' is: + | auto | + | landscape | + + Scenario: `renditionSpread` on publication + When checking EPUB 'layout-spread' + Then the JSON report is valid + And JSON at '$.publication.renditionLayout' is "pre-paginated" + And JSON at '$.publication.renditionSpread' is "none" + And JSON at '$..items[?(@.isSpineItem==true)].renditionSpread' are all "none" + + Scenario: `renditionSpread` on item + When checking EPUB 'layout-spread-item' + Then the JSON report is valid + And JSON at '$.publication.renditionLayout' is "pre-paginated" + And JSON at '$.publication.renditionSpread' is "auto" + And JSON at '$..items[?(@.isSpineItem==true)].renditionSpread' is: + | auto | + | both |