summaryrefslogtreecommitdiff
path: root/unotest
diff options
context:
space:
mode:
authorCaolán McNamara <caolanm@redhat.com>2012-11-01 13:12:21 +0000
committerCaolán McNamara <caolanm@redhat.com>2012-11-01 13:14:09 +0000
commitc2913591d895666c7b8019e3307355511a7a5f95 (patch)
treef782e6cee3de6fba62e8c3b62d88fd52d85c227c /unotest
parent2ffd82c350efb7d04ea0019fc1845f314940f995 (diff)
rework filters test to squeeze through extra flags
that are needed to load .odt, .sxw etc files, and add a regression test for CVE-2012-4233 Change-Id: Ie178725ded3d76942030d12f23074de519cf62de
Diffstat (limited to 'unotest')
-rw-r--r--unotest/inc/unotest/filters-test.hxx19
-rw-r--r--unotest/source/cpp/filters-test.cxx34
2 files changed, 39 insertions, 14 deletions
diff --git a/unotest/inc/unotest/filters-test.hxx b/unotest/inc/unotest/filters-test.hxx
index d26c7f7b834f..390ad05230a3 100644
--- a/unotest/inc/unotest/filters-test.hxx
+++ b/unotest/inc/unotest/filters-test.hxx
@@ -27,6 +27,7 @@
* instead of those above.
*/
+#include <comphelper/documentconstants.hxx>
#include <rtl/ustring.hxx>
#include "unotest/detail/unotestdllapi.hxx"
@@ -56,21 +57,33 @@ public:
//root dir of test files, must contain pass, fail, indeterminate
const rtl::OUString &rURL,
//additional filter data for SfxFilter
- const rtl::OUString &rUserData);
+ const rtl::OUString &rUserData = rtl::OUString(),
+ //SfxFilterFlags for SfxFilter
+ unsigned int nFilterFlags = SFX_FILTER_IMPORT,
+ //Clipboard id for SfxFilter
+ unsigned int nClipboardID = 0,
+ //additional filter version for SfxFilter
+ unsigned int nFilterVersion = 0);
virtual bool load(
const rtl::OUString &rFilter,
const rtl::OUString &rURL,
- const rtl::OUString &rUserData) = 0;
+ const rtl::OUString &rUserData,
+ unsigned int nFilterFlags,
+ unsigned int nClipboardID,
+ unsigned int nFilterVersion) = 0;
protected:
~FiltersTest() {}
void recursiveScan(
+ filterStatus nExpected,
const rtl::OUString &rFilter,
const rtl::OUString &rURL,
const rtl::OUString &rUserData,
- filterStatus nExpected);
+ unsigned int nFilterFlags,
+ unsigned int nClipboardID,
+ unsigned int nFilterVersion);
};
}
diff --git a/unotest/source/cpp/filters-test.cxx b/unotest/source/cpp/filters-test.cxx
index 64c6159bfffb..07467a37f415 100644
--- a/unotest/source/cpp/filters-test.cxx
+++ b/unotest/source/cpp/filters-test.cxx
@@ -70,8 +70,10 @@ void decode(const rtl::OUString& rIn, const rtl::OUString &rOut)
rtl_cipher_destroy(cipher);
}
-void FiltersTest::recursiveScan(const rtl::OUString &rFilter, const rtl::OUString &rURL, const rtl::OUString &rUserData,
- filterStatus nExpected)
+void FiltersTest::recursiveScan(filterStatus nExpected,
+ const rtl::OUString &rFilter, const rtl::OUString &rURL,
+ const rtl::OUString &rUserData, unsigned int nFilterFlags,
+ unsigned int nClipboardID, unsigned int nFilterVersion)
{
osl::Directory aDir(rURL);
@@ -83,7 +85,10 @@ void FiltersTest::recursiveScan(const rtl::OUString &rFilter, const rtl::OUStrin
aItem.getFileStatus(aFileStatus);
rtl::OUString sURL = aFileStatus.getFileURL();
if (aFileStatus.getFileType() == osl::FileStatus::Directory)
- recursiveScan(rFilter, sURL, rUserData, nExpected);
+ {
+ recursiveScan(nExpected, rFilter, sURL, rUserData,
+ nFilterFlags, nClipboardID, nFilterVersion);
+ }
else
{
rtl::OUString sTmpFile;
@@ -121,7 +126,8 @@ void FiltersTest::recursiveScan(const rtl::OUString &rFilter, const rtl::OUStrin
//the hanging input file is visible
fprintf(stderr, "%s,", aRes.getStr());
sal_uInt32 nStartTime = osl_getGlobalTimer();
- bool bRes = load(rFilter, sURL, rUserData);
+ bool bRes = load(rFilter, sURL, rUserData, nFilterFlags,
+ nClipboardID, nFilterVersion);
sal_uInt32 nEndTime = osl_getGlobalTimer();
if (bEncrypted)
@@ -137,15 +143,21 @@ void FiltersTest::recursiveScan(const rtl::OUString &rFilter, const rtl::OUStrin
CPPUNIT_ASSERT(osl::FileBase::E_None == aDir.close());
}
-void FiltersTest::testDir(const rtl::OUString &rFilter, const rtl::OUString &rURL, const rtl::OUString &rUserData)
+void FiltersTest::testDir(const rtl::OUString &rFilter,
+ const rtl::OUString &rURL, const rtl::OUString &rUserData,
+ unsigned int nFilterFlags, unsigned int nClipboardID,
+ unsigned int nFilterVersion)
{
fprintf(stderr, "File tested,Test Result,Execution Time (ms)\n");
- recursiveScan(rFilter, rURL + rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("pass")),
- rUserData, test::pass);
- recursiveScan(rFilter, rURL + rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("fail")),
- rUserData, test::fail);
- recursiveScan(rFilter, rURL + rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("indeterminate")),
- rUserData, test::indeterminate);
+ recursiveScan(test::pass, rFilter,
+ rURL + rtl::OUString("pass"),
+ rUserData, nFilterFlags, nClipboardID, nFilterVersion);
+ recursiveScan(test::fail, rFilter,
+ rURL + rtl::OUString("fail"),
+ rUserData, nFilterFlags, nClipboardID, nFilterVersion);
+ recursiveScan(test::indeterminate, rFilter,
+ rURL + rtl::OUString("indeterminate"),
+ rUserData, nFilterFlags, nClipboardID, nFilterVersion);
}
}