From 6dd319ca5eebe1f97b9558b5b45bbccf402eb319 Mon Sep 17 00:00:00 2001 From: Michael Williamson Date: Sat, 13 Feb 2016 23:19:28 +0000 Subject: Emit warning when reading image of unsupported content type --- .../org/zwobble/mammoth/tests/docx/BodyXmlTests.java | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) (limited to 'src/test/java') 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 62fced9..49542ec 100644 --- a/src/test/java/org/zwobble/mammoth/tests/docx/BodyXmlTests.java +++ b/src/test/java/org/zwobble/mammoth/tests/docx/BodyXmlTests.java @@ -432,6 +432,25 @@ public class BodyXmlTests { } } + @Test + public void warningIfImageTypeIsUnsupportedByWebBrowsers() { + XmlElement element = inlineImageXml(embeddedBlipXml("rId5"), ""); + Relationships relationships = new Relationships(map( + "rId5", new Relationship("media/hat.emf"))); + DocxFile file = new InMemoryDocxFile(map("word/media/hat.emf", "Not an image at all!")); + ContentTypes contentTypes = new ContentTypes(map("emf", "image/x-emf"), map()); + + Result result = read( + a(bodyReader, + with(RELATIONSHIPS, relationships), + with(DOCX_FILE, file), + with(CONTENT_TYPES, contentTypes)), + element); + assertThat( + result, + hasProperty("warnings", deepEquals(list(warning("Image of type image/x-emf is unlikely to display in web browsers"))))); + } + private XmlElement inlineImageXml(XmlElement blip, String description) { return element("w:drawing", list( element("wp:inline", imageXml(blip, description)))); -- cgit v1.2.3