diff options
author | Markus Mohrhard <markus.mohrhard@googlemail.com> | 2015-08-15 01:22:34 +0200 |
---|---|---|
committer | Markus Mohrhard <markus.mohrhard@googlemail.com> | 2015-09-10 02:12:37 +0200 |
commit | 5e4c27820176976771429ad21d7420902597ccb2 (patch) | |
tree | f1565e67d8aad4688ce33a3932e818935fe8311a | |
parent | eaab276fbb2939d6f315a9e491ff7925edfc6fd8 (diff) |
add first vba compression test
Change-Id: I9e3abebb0ac932b46f7fc96cd37d39023b783af2
-rw-r--r-- | include/oox/ole/vbaexport.hxx | 2 | ||||
-rw-r--r-- | oox/Module_oox.mk | 1 | ||||
-rw-r--r-- | oox/qa/unit/data/vba/reference/simple1.bin | bin | 0 -> 50 bytes | |||
-rw-r--r-- | oox/qa/unit/data/vba/simple1.bin | 1 | ||||
-rw-r--r-- | oox/qa/unit/vba_compression.cxx | 81 |
5 files changed, 84 insertions, 1 deletions
diff --git a/include/oox/ole/vbaexport.hxx b/include/oox/ole/vbaexport.hxx index 146bb88b5149..3217e1b8b9b1 100644 --- a/include/oox/ole/vbaexport.hxx +++ b/include/oox/ole/vbaexport.hxx @@ -90,7 +90,7 @@ private: sal_uInt16 handleHeader(bool bCompressed); }; -class VBACompression +class OOX_DLLPUBLIC VBACompression { public: VBACompression(SvStream& rCompressedStream, diff --git a/oox/Module_oox.mk b/oox/Module_oox.mk index 361054da884e..1c8edf04ed72 100644 --- a/oox/Module_oox.mk +++ b/oox/Module_oox.mk @@ -18,6 +18,7 @@ $(eval $(call gb_Module_add_targets,oox,\ $(eval $(call gb_Module_add_check_targets,oox,\ CppunitTest_oox_tokenmap \ + CppunitTest_oox_vba_compression \ )) # vim: set noet sw=4 ts=4: diff --git a/oox/qa/unit/data/vba/reference/simple1.bin b/oox/qa/unit/data/vba/reference/simple1.bin Binary files differnew file mode 100644 index 000000000000..bd55e2ef5f19 --- /dev/null +++ b/oox/qa/unit/data/vba/reference/simple1.bin diff --git a/oox/qa/unit/data/vba/simple1.bin b/oox/qa/unit/data/vba/simple1.bin new file mode 100644 index 000000000000..61dbbebf1c3f --- /dev/null +++ b/oox/qa/unit/data/vba/simple1.bin @@ -0,0 +1 @@ +00000000:0001 0203 0405 0607 0809 1011 1213 . diff --git a/oox/qa/unit/vba_compression.cxx b/oox/qa/unit/vba_compression.cxx new file mode 100644 index 000000000000..b526a3c1e073 --- /dev/null +++ b/oox/qa/unit/vba_compression.cxx @@ -0,0 +1,81 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/* + * This file is part of the LibreOffice project. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + */ + +#include <unotest/bootstrapfixturebase.hxx> + +#include <cppunit/plugin/TestPlugIn.h> +#include <cppunit/extensions/HelperMacros.h> +#include <cppunit/TestFixture.h> + +#include <oox/ole/vbaexport.hxx> + +class TestVbaCompression : public test::BootstrapFixtureBase +{ +public: + + void testSimple1(); + + // avoid the BootstrapFixtureBase::setUp and tearDown + virtual void setUp() SAL_OVERRIDE; + virtual void tearDown() SAL_OVERRIDE; + + CPPUNIT_TEST_SUITE(TestVbaCompression); + CPPUNIT_TEST(testSimple1); + CPPUNIT_TEST_SUITE_END(); + +private: +}; + +void TestVbaCompression::testSimple1() +{ + OUString aTestFile = getPathFromSrc("/oox/qa/unit/data/vba/simple1.bin"); + OUString aReference = getPathFromSrc("/oox/qa/unit/data/vba/reference/simple1.bin"); + + SvFileStream aInputStream(aTestFile, StreamMode::READ); + SvMemoryStream aInputMemoryStream(4096, 4096); + aInputMemoryStream.WriteStream(aInputStream); + + SvMemoryStream aOutputMemoryStream(4096, 4096); + VBACompression aCompression(aOutputMemoryStream, aInputMemoryStream); + aCompression.write(); + + SvFileStream aReferenceStream(aReference, StreamMode::READ); + SvMemoryStream aReferenceMemoryStream(4096, 4096); + aReferenceMemoryStream.WriteStream(aReferenceStream); + + aOutputMemoryStream.Seek(0); + SvFileStream aDebugStream("/tmp/vba_debug.bin", StreamMode::WRITE); + aDebugStream.WriteStream(aOutputMemoryStream); + + // CPPUNIT_ASSERT_EQUAL(aReferenceMemoryStream.GetSize(), aOutputMemoryStream.GetSize()); + + const sal_uInt8* pReferenceData = (const sal_uInt8*) aReferenceMemoryStream.GetData(); + const sal_uInt8* pData = (const sal_uInt8*)aOutputMemoryStream.GetData(); + + size_t nSize = std::min(aReferenceMemoryStream.GetSize(), + aOutputMemoryStream.GetSize()); + for (size_t i = 0; i < nSize; ++i) + { + CPPUNIT_ASSERT_EQUAL((int)pReferenceData[i], (int)pData[i]); + } +} + +void TestVbaCompression::setUp() +{ +} + +void TestVbaCompression::tearDown() +{ +} + +CPPUNIT_TEST_SUITE_REGISTRATION(TestVbaCompression); + +CPPUNIT_PLUGIN_IMPLEMENT(); + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ |