From e64c7c5620dc39696324f8680c38c463a7e7f4b8 Mon Sep 17 00:00:00 2001 From: Romain Deltour Date: Mon, 21 Nov 2022 01:00:45 +0100 Subject: [PATCH] feat: allow 1s tolerance for media overlays duration sum check Fix #1328 --- .../com/adobe/epubcheck/opf/OPFChecker30.java | 2 +- ...verlays-duration-total-not-sum-warning.opf | 2 +- ...-duration-total-within-tolerance-valid.opf | 22 +++++++++++++++++++ .../09-media-overlays/media-overlays.feature | 6 +++++ 4 files changed, 30 insertions(+), 2 deletions(-) create mode 100644 src/test/resources/epub3/09-media-overlays/files/mediaoverlays-duration-total-within-tolerance-valid.opf diff --git a/src/main/java/com/adobe/epubcheck/opf/OPFChecker30.java b/src/main/java/com/adobe/epubcheck/opf/OPFChecker30.java index f249a1193..a8b7fd963 100644 --- a/src/main/java/com/adobe/epubcheck/opf/OPFChecker30.java +++ b/src/main/java/com/adobe/epubcheck/opf/OPFChecker30.java @@ -439,7 +439,7 @@ private void checkMediaOverlaysDuration() } } // report if the sum and total don't match - if (!totalDuration.equals(sumDuration)) + if (!totalDuration.eqWithinTolerance(sumDuration, 1000)) { report.message(MessageId.MED_016, EPUBLocation.of(context)); } diff --git a/src/test/resources/epub3/09-media-overlays/files/mediaoverlays-duration-total-not-sum-warning.opf b/src/test/resources/epub3/09-media-overlays/files/mediaoverlays-duration-total-not-sum-warning.opf index 42b376cb2..85f9f0d6d 100644 --- a/src/test/resources/epub3/09-media-overlays/files/mediaoverlays-duration-total-not-sum-warning.opf +++ b/src/test/resources/epub3/09-media-overlays/files/mediaoverlays-duration-total-not-sum-warning.opf @@ -9,7 +9,7 @@ 10min 5min - 0:05:00.200 + 0:05:01.100 diff --git a/src/test/resources/epub3/09-media-overlays/files/mediaoverlays-duration-total-within-tolerance-valid.opf b/src/test/resources/epub3/09-media-overlays/files/mediaoverlays-duration-total-within-tolerance-valid.opf new file mode 100644 index 000000000..bc7106cc4 --- /dev/null +++ b/src/test/resources/epub3/09-media-overlays/files/mediaoverlays-duration-total-within-tolerance-valid.opf @@ -0,0 +1,22 @@ + + + + Title + en + NOID + 2019-01-01T12:00:00Z + + 10min + 5min + 0:05:00.500 + + + + + + + + + + \ No newline at end of file diff --git a/src/test/resources/epub3/09-media-overlays/media-overlays.feature b/src/test/resources/epub3/09-media-overlays/media-overlays.feature index 0e9eb7a48..472730378 100644 --- a/src/test/resources/epub3/09-media-overlays/media-overlays.feature +++ b/src/test/resources/epub3/09-media-overlays/media-overlays.feature @@ -316,7 +316,13 @@ Feature: EPUB 3 — Media Overlays And the message contains "item media:duration meta element not set" And no other errors or warnings are reported + @spec @xref:sec-mo-package-metadata Scenario: the total duration should be the sum of all Media Overlay durations When checking file 'mediaoverlays-duration-total-not-sum-warning.opf' Then warning MED-016 is reported And no other errors or warnings are reported + + @spec @xref:sec-mo-package-metadata + Scenario: the total duration has a 1s tolerance + When checking file 'mediaoverlays-duration-total-within-tolerance-valid.opf' + Then no errors or warnings are reported