diff options
Diffstat (limited to 'src/test')
-rw-r--r-- | src/test/Makefile.am | 2 | ||||
-rw-r--r-- | src/test/data/bitmaps.vsd | bin | 0 -> 206336 bytes | |||
-rw-r--r-- | src/test/data/bitmaps2.vsd | bin | 0 -> 87040 bytes | |||
-rw-r--r-- | src/test/importtest.cpp | 51 | ||||
-rw-r--r-- | src/test/xmldrawinggenerator.cpp | 1 |
5 files changed, 54 insertions, 0 deletions
diff --git a/src/test/Makefile.am b/src/test/Makefile.am index 54fbf78..7791453 100644 --- a/src/test/Makefile.am +++ b/src/test/Makefile.am @@ -21,6 +21,8 @@ test_SOURCES = \ EXTRA_DIST = \ data/bgcolor.vsdx \ + data/bitmaps.vsd \ + data/bitmaps2.vsd \ data/color-boxes.vsdx \ data/fdo86664.vsdx \ data/fdo86729-ms1252.vsd \ diff --git a/src/test/data/bitmaps.vsd b/src/test/data/bitmaps.vsd Binary files differnew file mode 100644 index 0000000..8b14f2e --- /dev/null +++ b/src/test/data/bitmaps.vsd diff --git a/src/test/data/bitmaps2.vsd b/src/test/data/bitmaps2.vsd Binary files differnew file mode 100644 index 0000000..810d30e --- /dev/null +++ b/src/test/data/bitmaps2.vsd diff --git a/src/test/importtest.cpp b/src/test/importtest.cpp index 1cbfc9d..418551f 100644 --- a/src/test/importtest.cpp +++ b/src/test/importtest.cpp @@ -94,6 +94,21 @@ void assertXPathNoAttribute(xmlDocPtr doc, const librevenge::RVNGString &xpath, xmlXPathFreeObject(xpathobject); } +void assertBmpDataOffset(xmlDocPtr doc, const librevenge::RVNGString &xpath, const unsigned expectedValue) +{ + const librevenge::RVNGBinaryData bitmap(getXPath(doc, xpath, "binary-data")); + librevenge::RVNGString message("BMP at '"); + message.append(xpath); + message.append("': wrong data offset."); + librevenge::RVNGInputStream *const input = bitmap.getDataStream(); + CPPUNIT_ASSERT(input); + CPPUNIT_ASSERT_EQUAL(0, input->seek(10, librevenge::RVNG_SEEK_SET)); + unsigned long numBytesRead = 0; + const unsigned char *const bytes = input->read(4, numBytesRead); + CPPUNIT_ASSERT_EQUAL(4ul, numBytesRead); + const unsigned actualValue = bytes[0] | (bytes[1] << 8) | (bytes[2] << 16) | (bytes[3] << 24); + CPPUNIT_ASSERT_EQUAL_MESSAGE(message.cstr(), expectedValue, actualValue); +} #if 0 // keep for future use /// Same as the assertXPathContent(), but don't assert: return the string instead. @@ -164,6 +179,8 @@ class ImportTest : public CPPUNIT_NS::TestFixture CPPUNIT_TEST(testVsdxCharBgColor); #endif CPPUNIT_TEST(testVsdTextBlockWithoutBgColor); + CPPUNIT_TEST(testBmpFileHeader); + CPPUNIT_TEST(testBmpFileHeader2); CPPUNIT_TEST_SUITE_END(); void testVsdxMetadataTitle(); @@ -174,6 +191,8 @@ class ImportTest : public CPPUNIT_NS::TestFixture void testVsdxImportBgColorFromTheme(); void testVsdxCharBgColor(); void testVsdTextBlockWithoutBgColor(); + void testBmpFileHeader(); + void testBmpFileHeader2(); xmlBufferPtr m_buffer; xmlDocPtr m_doc; @@ -294,6 +313,38 @@ void ImportTest::testVsdTextBlockWithoutBgColor() assertXPathNoAttribute(m_doc, "/document/page/layer[5]/textObject/paragraph[1]/span", "background-color"); } +void ImportTest::testBmpFileHeader() +{ + m_doc = parse("bitmaps.vsd", m_buffer); + assertBmpDataOffset(m_doc, "/document/page/drawGraphicObject[1]", 62); + assertBmpDataOffset(m_doc, "/document/page/drawGraphicObject[2]", 62); + assertBmpDataOffset(m_doc, "/document/page/drawGraphicObject[3]", 62); + assertBmpDataOffset(m_doc, "/document/page/drawGraphicObject[4]", 118); + assertBmpDataOffset(m_doc, "/document/page/drawGraphicObject[5]", 118); + assertBmpDataOffset(m_doc, "/document/page/drawGraphicObject[6]", 54); + assertBmpDataOffset(m_doc, "/document/page/drawGraphicObject[7]", 1078); + assertBmpDataOffset(m_doc, "/document/page/drawGraphicObject[8]", 1078); + assertBmpDataOffset(m_doc, "/document/page/drawGraphicObject[9]", 1078); + assertBmpDataOffset(m_doc, "/document/page/drawGraphicObject[10]", 54); + assertBmpDataOffset(m_doc, "/document/page/drawGraphicObject[11]", 1078); + assertBmpDataOffset(m_doc, "/document/page/drawGraphicObject[12]", 1078); + assertBmpDataOffset(m_doc, "/document/page/drawGraphicObject[13]", 1078); + assertBmpDataOffset(m_doc, "/document/page/drawGraphicObject[14]", 54); + assertBmpDataOffset(m_doc, "/document/page/drawGraphicObject[15]", 54); + assertBmpDataOffset(m_doc, "/document/page/drawGraphicObject[16]", 54); + assertBmpDataOffset(m_doc, "/document/page/drawGraphicObject[17]", 54); + assertBmpDataOffset(m_doc, "/document/page/drawGraphicObject[18]", 54); + assertBmpDataOffset(m_doc, "/document/page/drawGraphicObject[19]", 54); + assertBmpDataOffset(m_doc, "/document/page/drawGraphicObject[20]", 54); +} + +void ImportTest::testBmpFileHeader2() +{ + m_doc = parse("bitmaps2.vsd", m_buffer); + assertBmpDataOffset(m_doc, "/document/page/drawGraphicObject[1]", 62); + assertBmpDataOffset(m_doc, "/document/page/layer/drawGraphicObject[1]", 330); +} + CPPUNIT_TEST_SUITE_REGISTRATION(ImportTest); /* vim:set shiftwidth=2 softtabstop=2 expandtab: */ diff --git a/src/test/xmldrawinggenerator.cpp b/src/test/xmldrawinggenerator.cpp index 771caff..cad7e2e 100644 --- a/src/test/xmldrawinggenerator.cpp +++ b/src/test/xmldrawinggenerator.cpp @@ -35,6 +35,7 @@ void XmlDrawingGenerator::startDocument(const librevenge::RVNGPropertyList &prop xmlTextWriterWriteAttribute(m_writer, BAD_CAST("xmlns:draw"), BAD_CAST("urn:oasis:names:tc:opendocument:xmlns:drawing:1.0")); xmlTextWriterWriteAttribute(m_writer, BAD_CAST("xmlns:fo"), BAD_CAST("urn:oasis:names:tc:opendocument:xmlns:xsl-fo-compatible:1.0")); xmlTextWriterWriteAttribute(m_writer, BAD_CAST("xmlns:librevenge"), BAD_CAST("urn:x-documentliberation:xmlns:librevenge:0.0")); + xmlTextWriterWriteAttribute(m_writer, BAD_CAST("xmlns:office"), BAD_CAST("urn:oasis:names:tc:opendocument:xmlns:office:1.0")); xmlTextWriterWriteAttribute(m_writer, BAD_CAST("xmlns:style"), BAD_CAST("urn:oasis:names:tc:opendocument:xmlns:style:1.0")); xmlTextWriterWriteAttribute(m_writer, BAD_CAST("xmlns:svg"), BAD_CAST("urn:oasis:names:tc:opendocument:xmlns:svg-compatible:1.0")); xmlTextWriterWriteAttribute(m_writer, BAD_CAST("xmlns:meta"), BAD_CAST("urn:oasis:names:tc:opendocument:xmlns:meta:1.0")); |