From 3120129edd44960570a2c2c5a0c49803397caea3 Mon Sep 17 00:00:00 2001 From: Michael Williamson Date: Mon, 1 Nov 2021 19:23:07 +0000 Subject: Reorder image tests to match mammoth.js --- .../zwobble/mammoth/tests/docx/BodyXmlTests.java | 40 +++++++++++----------- 1 file changed, 20 insertions(+), 20 deletions(-) (limited to 'src/test') diff --git a/src/test/java/org/zwobble/mammoth/tests/docx/BodyXmlTests.java b/src/test/java/org/zwobble/mammoth/tests/docx/BodyXmlTests.java index 6c04f80..5f9e900 100644 --- a/src/test/java/org/zwobble/mammoth/tests/docx/BodyXmlTests.java +++ b/src/test/java/org/zwobble/mammoth/tests/docx/BodyXmlTests.java @@ -1282,10 +1282,10 @@ public class BodyXmlTests { } @Test - public void altTextTitleIsUsedIfAltTextDescriptionIsBlank() throws IOException { + public void altTextTitleIsUsedIfAltTextDescriptionIsMissing() throws IOException { XmlElement element = inlineImageXml( embeddedBlipXml(IMAGE_RELATIONSHIP_ID), - Optional.of(" "), + Optional.empty(), Optional.of("It's a hat") ); @@ -1295,10 +1295,10 @@ public class BodyXmlTests { } @Test - public void altTextTitleIsUsedIfAltTextDescriptionIsMissing() throws IOException { + public void altTextTitleIsUsedIfAltTextDescriptionIsBlank() throws IOException { XmlElement element = inlineImageXml( embeddedBlipXml(IMAGE_RELATIONSHIP_ID), - Optional.empty(), + Optional.of(" "), Optional.of("It's a hat") ); @@ -1363,37 +1363,37 @@ public class BodyXmlTests { } @Test - public void warningIfImageTypeIsUnsupportedByWebBrowsers() { - XmlElement element = inlineImageXml(embeddedBlipXml(IMAGE_RELATIONSHIP_ID), ""); + public void canReadLinkedPictures() throws IOException { + XmlElement element = inlineImageXml(linkedBlipXml(IMAGE_RELATIONSHIP_ID), ""); Relationships relationships = new Relationships(list( - imageRelationship(IMAGE_RELATIONSHIP_ID, "media/hat.emf") + imageRelationship(IMAGE_RELATIONSHIP_ID, "file:///media/hat.png") )); - Archive file = InMemoryArchive.fromStrings(map("word/media/hat.emf", IMAGE_BYTES)); - ContentTypes contentTypes = new ContentTypes(map("emf", "image/x-emf"), map()); - InternalResult result = read( - bodyReader(relationships, file, contentTypes), + Image image = (Image) readSuccess( + bodyReader(relationships, new InMemoryFileReader(map("file:///media/hat.png", IMAGE_BYTES))), element); assertThat( - result, - hasWarnings(list("Image of type image/x-emf is unlikely to display in web browsers"))); + toString(image.open()), + equalTo(IMAGE_BYTES)); } @Test - public void canReadLinkedPictures() throws IOException { - XmlElement element = inlineImageXml(linkedBlipXml(IMAGE_RELATIONSHIP_ID), ""); + public void warningIfImageTypeIsUnsupportedByWebBrowsers() { + XmlElement element = inlineImageXml(embeddedBlipXml(IMAGE_RELATIONSHIP_ID), ""); Relationships relationships = new Relationships(list( - imageRelationship(IMAGE_RELATIONSHIP_ID, "file:///media/hat.png") + imageRelationship(IMAGE_RELATIONSHIP_ID, "media/hat.emf") )); + Archive file = InMemoryArchive.fromStrings(map("word/media/hat.emf", IMAGE_BYTES)); + ContentTypes contentTypes = new ContentTypes(map("emf", "image/x-emf"), map()); - Image image = (Image) readSuccess( - bodyReader(relationships, new InMemoryFileReader(map("file:///media/hat.png", IMAGE_BYTES))), + InternalResult result = read( + bodyReader(relationships, file, contentTypes), element); assertThat( - toString(image.open()), - equalTo(IMAGE_BYTES)); + result, + hasWarnings(list("Image of type image/x-emf is unlikely to display in web browsers"))); } private XmlElement inlineImageXml(XmlElement blip, String description) { -- cgit v1.2.3