[Libreoffice-commits] core.git: include/unotest sw/qa unotest/source
Miklos Vajna
vmiklos at collabora.co.uk
Tue Dec 17 11:52:54 PST 2013
include/unotest/filters-test.hxx | 18 ++++++++++-
sw/qa/core/exportdata/rtf/pass/abi10201.rtf | 3 +
sw/qa/core/filters-test.cxx | 43 +++++++++++++++++++++++++++-
sw/qa/extras/rtfexport/data/abi10201.rtf | 3 -
sw/qa/extras/rtfexport/rtfexport.cxx | 5 ---
unotest/source/cpp/filters-test.cxx | 21 ++++++++-----
6 files changed, 74 insertions(+), 19 deletions(-)
New commits:
commit 73a808f6b300fddcaab1d3c916d92785a1801d63
Author: Miklos Vajna <vmiklos at collabora.co.uk>
Date: Tue Dec 17 18:17:33 2013 +0100
test::FiltersTest: add support for export tests
For now, this is only implemented for the Writer RTF filter.
Change-Id: I0c7ae5b0e544bd4738652a38474f4d262ce65661
diff --git a/include/unotest/filters-test.hxx b/include/unotest/filters-test.hxx
index 64e368c..3bcdf07 100644
--- a/include/unotest/filters-test.hxx
+++ b/include/unotest/filters-test.hxx
@@ -43,7 +43,9 @@ public:
//Clipboard id for SfxFilter
unsigned int nClipboardID = 0,
//additional filter version for SfxFilter
- unsigned int nFilterVersion = 0);
+ unsigned int nFilterVersion = 0,
+ //export or import?
+ bool bExport = false);
virtual bool load(
const OUString &rFilter,
@@ -53,6 +55,17 @@ public:
unsigned int nClipboardID,
unsigned int nFilterVersion) = 0;
+ virtual bool save(
+ const OUString &/*rFilter*/,
+ const OUString &/*rURL*/,
+ const OUString &/*rUserData*/,
+ unsigned int /*nFilterFlags*/,
+ unsigned int /*nClipboardID*/,
+ unsigned int /*nFilterVersion*/)
+ {
+ return true;
+ }
+
protected:
~FiltersTest() {}
@@ -63,7 +76,8 @@ protected:
const OUString &rUserData,
unsigned int nFilterFlags,
unsigned int nClipboardID,
- unsigned int nFilterVersion);
+ unsigned int nFilterVersion,
+ bool bExport);
};
}
diff --git a/sw/qa/core/exportdata/rtf/fail/.gitignore b/sw/qa/core/exportdata/rtf/fail/.gitignore
new file mode 100644
index 0000000..e69de29
diff --git a/sw/qa/core/exportdata/rtf/indeterminate/.gitignore b/sw/qa/core/exportdata/rtf/indeterminate/.gitignore
new file mode 100644
index 0000000..e69de29
diff --git a/sw/qa/extras/rtfexport/data/abi10201.rtf b/sw/qa/core/exportdata/rtf/pass/abi10201.rtf
similarity index 100%
rename from sw/qa/extras/rtfexport/data/abi10201.rtf
rename to sw/qa/core/exportdata/rtf/pass/abi10201.rtf
diff --git a/sw/qa/core/filters-test.cxx b/sw/qa/core/filters-test.cxx
index b47abb4..7c811a4 100644
--- a/sw/qa/core/filters-test.cxx
+++ b/sw/qa/core/filters-test.cxx
@@ -21,6 +21,7 @@
#include <sfx2/sfxsids.hrc>
#include <svl/stritem.hxx>
+#include <unotools/tempfile.hxx>
#include "init.hxx"
#include "iodetect.hxx"
@@ -45,6 +46,9 @@ public:
virtual bool load( const OUString &rFilter, const OUString &rURL,
const OUString &rUserData, unsigned int nFilterFlags,
unsigned int nClipboardID, unsigned int nFilterVersion);
+ virtual bool save( const OUString &rFilter, const OUString &rURL,
+ const OUString &rUserData, unsigned int nFilterFlags,
+ unsigned int nClipboardID, unsigned int nFilterVersion) SAL_OVERRIDE;
virtual void setUp();
// Ensure CVEs remain unbroken
@@ -55,6 +59,9 @@ public:
CPPUNIT_TEST_SUITE_END();
private:
+ bool filter( const OUString &rFilter, const OUString &rURL,
+ const OUString &rUserData, unsigned int nFilterFlags,
+ unsigned int nClipboardID, unsigned int nFilterVersion, bool bExport);
uno::Reference<uno::XInterface> m_xWriterComponent;
};
@@ -62,6 +69,20 @@ bool SwFiltersTest::load(const OUString &rFilter, const OUString &rURL,
const OUString &rUserData, unsigned int nFilterFlags,
unsigned int nClipboardID, unsigned int nFilterVersion)
{
+ return filter(rFilter, rURL, rUserData, nFilterFlags, nClipboardID, nFilterVersion, false);
+}
+
+bool SwFiltersTest::save(const OUString &rFilter, const OUString &rURL,
+ const OUString &rUserData, unsigned int nFilterFlags,
+ unsigned int nClipboardID, unsigned int nFilterVersion)
+{
+ return filter(rFilter, rURL, rUserData, nFilterFlags, nClipboardID, nFilterVersion, true);
+}
+
+bool SwFiltersTest::filter(const OUString &rFilter, const OUString &rURL,
+ const OUString &rUserData, unsigned int nFilterFlags,
+ unsigned int nClipboardID, unsigned int nFilterVersion, bool bExport)
+{
SfxFilter* pFilter = new SfxFilter(
rFilter, OUString(), nFilterFlags,
nClipboardID, OUString(), 0, OUString(),
@@ -79,9 +100,21 @@ bool SwFiltersTest::load(const OUString &rFilter, const OUString &rURL,
}
bool bLoaded = xDocShRef->DoLoad(pSrcMed);
+ if (!bExport)
+ {
+ if (xDocShRef.Is())
+ xDocShRef->DoClose();
+ return bLoaded;
+ }
+
+ utl::TempFile aTempFile;
+ aTempFile.EnableKillingFile();
+ SfxMedium aDstMed(aTempFile.GetURL(), STREAM_STD_WRITE);
+ aDstMed.SetFilter(pFilter);
+ bool bSaved = xDocShRef->DoSaveAs(aDstMed);
if (xDocShRef.Is())
xDocShRef->DoClose();
- return bLoaded;
+ return bSaved;
}
#define isstorage 1
@@ -125,6 +158,14 @@ void SwFiltersTest::testCVEs()
testDir(OUString("HTML"),
getURLFromSrc("/sw/qa/core/data/html/"),
OUString(sHTML));
+
+ testDir("Rich Text Format",
+ getURLFromSrc("/sw/qa/core/exportdata/rtf/"),
+ OUString(),
+ SFX_FILTER_STARONEFILTER,
+ 0,
+ 0,
+ /*bExport=*/true);
}
void SwFiltersTest::setUp()
diff --git a/sw/qa/extras/rtfexport/rtfexport.cxx b/sw/qa/extras/rtfexport/rtfexport.cxx
index 6a483b7..b4d7254 100644
--- a/sw/qa/extras/rtfexport/rtfexport.cxx
+++ b/sw/qa/extras/rtfexport/rtfexport.cxx
@@ -579,11 +579,6 @@ DECLARE_RTFEXPORT_TEST(testFdo66743, "fdo66743.rtf")
CPPUNIT_ASSERT_EQUAL(sal_Int32(0xd8d8d8), getProperty<sal_Int32>(xCell, "BackColor"));
}
-DECLARE_RTFEXPORT_TEST(testAbi10201, "abi10201.rtf")
-{
- // crashtest
-}
-
DECLARE_RTFEXPORT_TEST(testI23357, "i23357.odt")
{
// crashtest
diff --git a/unotest/source/cpp/filters-test.cxx b/unotest/source/cpp/filters-test.cxx
index 3b613f3..2b07ff8 100644
--- a/unotest/source/cpp/filters-test.cxx
+++ b/unotest/source/cpp/filters-test.cxx
@@ -53,7 +53,7 @@ void decode(const OUString& rIn, const OUString &rOut)
void FiltersTest::recursiveScan(filterStatus nExpected,
const OUString &rFilter, const OUString &rURL,
const OUString &rUserData, unsigned int nFilterFlags,
- unsigned int nClipboardID, unsigned int nFilterVersion)
+ unsigned int nClipboardID, unsigned int nFilterVersion, bool bExport)
{
osl::Directory aDir(rURL);
@@ -67,7 +67,7 @@ void FiltersTest::recursiveScan(filterStatus nExpected,
if (aFileStatus.getFileType() == osl::FileStatus::Directory)
{
recursiveScan(nExpected, rFilter, sURL, rUserData,
- nFilterFlags, nClipboardID, nFilterVersion);
+ nFilterFlags, nClipboardID, nFilterVersion, bExport);
}
else
{
@@ -106,8 +106,13 @@ void FiltersTest::recursiveScan(filterStatus nExpected,
//the hanging input file is visible
fprintf(stderr, "%s,", aRes.getStr());
sal_uInt32 nStartTime = osl_getGlobalTimer();
- bool bRes = load(rFilter, sURL, rUserData, nFilterFlags,
- nClipboardID, nFilterVersion);
+ bool bRes;
+ if (!bExport)
+ bRes = load(rFilter, sURL, rUserData, nFilterFlags,
+ nClipboardID, nFilterVersion);
+ else
+ bRes = save(rFilter, sURL, rUserData, nFilterFlags,
+ nClipboardID, nFilterVersion);
sal_uInt32 nEndTime = osl_getGlobalTimer();
if (bEncrypted)
@@ -126,18 +131,18 @@ void FiltersTest::recursiveScan(filterStatus nExpected,
void FiltersTest::testDir(const OUString &rFilter,
const OUString &rURL, const OUString &rUserData,
unsigned int nFilterFlags, unsigned int nClipboardID,
- unsigned int nFilterVersion)
+ unsigned int nFilterVersion, bool bExport)
{
fprintf(stderr, "File tested,Test Result,Execution Time (ms)\n");
recursiveScan(test::pass, rFilter,
rURL + "pass",
- rUserData, nFilterFlags, nClipboardID, nFilterVersion);
+ rUserData, nFilterFlags, nClipboardID, nFilterVersion, bExport);
recursiveScan(test::fail, rFilter,
rURL + "fail",
- rUserData, nFilterFlags, nClipboardID, nFilterVersion);
+ rUserData, nFilterFlags, nClipboardID, nFilterVersion, bExport);
recursiveScan(test::indeterminate, rFilter,
rURL + "indeterminate",
- rUserData, nFilterFlags, nClipboardID, nFilterVersion);
+ rUserData, nFilterFlags, nClipboardID, nFilterVersion, bExport);
}
}
More information about the Libreoffice-commits
mailing list