Kaydet (Commit) 73a808f6 authored tarafından Miklos Vajna's avatar Miklos Vajna

test::FiltersTest: add support for export tests

For now, this is only implemented for the Writer RTF filter.

Change-Id: I0c7ae5b0e544bd4738652a38474f4d262ce65661
üst 25dc9aaf
......@@ -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);
};
}
......
......@@ -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,12 +59,29 @@ 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;
};
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,
......@@ -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()
......
......@@ -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
......
......@@ -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);
}
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment