Kaydet (Commit) 70ad8ec6 authored tarafından Miklos Vajna's avatar Miklos Vajna

Make CppunitTest_sw_htmlexport use DECLARE_SW_ROUNDTRIP_TEST()

Change-Id: Idc524ce084e117a9cfe816e5012ef33ea774fef6
üst f15efcb0
...@@ -8,6 +8,9 @@ ...@@ -8,6 +8,9 @@
*/ */
#include <swmodeltestbase.hxx> #include <swmodeltestbase.hxx>
#if !defined(MACOSX) && !defined(WNT)
#include <com/sun/star/awt/Gradient.hpp> #include <com/sun/star/awt/Gradient.hpp>
#include <com/sun/star/drawing/FillStyle.hpp> #include <com/sun/star/drawing/FillStyle.hpp>
#include <swmodule.hxx> #include <swmodule.hxx>
...@@ -16,56 +19,55 @@ ...@@ -16,56 +19,55 @@
class Test : public SwModelTestBase class Test : public SwModelTestBase
{ {
public: public:
void testFdo62336(); Test()
void testCharacterBorder(); : SwModelTestBase("/sw/qa/extras/htmlexport/data/", "HTML (StarWriter)"),
m_eUnit(FUNIT_NONE)
CPPUNIT_TEST_SUITE(Test); {
#if !defined(MACOSX) && !defined(WNT) }
CPPUNIT_TEST(run);
#endif
CPPUNIT_TEST_SUITE_END();
private: private:
void run(); bool mustCalcLayoutOf(const char* filename) SAL_OVERRIDE
}; {
return OString(filename) != "fdo62336.docx";
}
void Test::run() bool mustTestImportOf(const char* filename) const SAL_OVERRIDE
{
MethodEntry<Test> aMethods[] = {
{"fdo62336.docx", &Test::testFdo62336},
{"charborder.odt", &Test::testCharacterBorder},
};
header();
for (unsigned int i = 0; i < SAL_N_ELEMENTS(aMethods); ++i)
{ {
MethodEntry<Test>& rEntry = aMethods[i]; return OString(filename) != "fdo62336.docx";
FieldUnit eUnit = FUNIT_NONE; }
if (OString(rEntry.pName) == "charborder.odt")
void preTest(const char* filename) SAL_OVERRIDE
{
if (OString(filename) == "charborder.odt")
{ {
// FIXME if padding-top gets exported as inches, not cms, we get rounding errors. // FIXME if padding-top gets exported as inches, not cms, we get rounding errors.
SwMasterUsrPref* pPref = const_cast<SwMasterUsrPref*>(SW_MOD()->GetUsrPref(false)); SwMasterUsrPref* pPref = const_cast<SwMasterUsrPref*>(SW_MOD()->GetUsrPref(false));
eUnit = pPref->GetMetric(); m_eUnit = pPref->GetMetric();
pPref->SetMetric(FUNIT_CM); pPref->SetMetric(FUNIT_CM);
} }
load("/sw/qa/extras/htmlexport/data/", rEntry.pName, }
false /* not doing layout is required for this test */);
reload("HTML (StarWriter)"); void postTest(const char* filename) SAL_OVERRIDE
if (OString(rEntry.pName) == "charborder.odt") {
if (OString(filename) == "charborder.odt")
{ {
SwMasterUsrPref* pPref = const_cast<SwMasterUsrPref*>(SW_MOD()->GetUsrPref(false)); SwMasterUsrPref* pPref = const_cast<SwMasterUsrPref*>(SW_MOD()->GetUsrPref(false));
pPref->SetMetric(eUnit); pPref->SetMetric(m_eUnit);
} }
(this->*rEntry.pMethod)();
finish();
} }
}
void Test::testFdo62336() FieldUnit m_eUnit;
};
#define DECLARE_HTMLEXPORT_TEST(TestName, filename) DECLARE_SW_ROUNDTRIP_TEST(TestName, filename, Test)
DECLARE_HTMLEXPORT_TEST(testFdo62336, "fdo62336.docx")
{ {
// The problem was essentially a crash during table export as docx/rtf/html // The problem was essentially a crash during table export as docx/rtf/html
// If either of no-calc-layout or no-test-import is enabled, the crash does not occur
} }
void Test::testCharacterBorder() DECLARE_HTMLEXPORT_TEST(testCharacterBorder, "charborder.odt")
{ {
uno::Reference<beans::XPropertySet> xRun(getRun(getParagraph(1),1), uno::UNO_QUERY); uno::Reference<beans::XPropertySet> xRun(getRun(getParagraph(1),1), uno::UNO_QUERY);
...@@ -88,7 +90,7 @@ void Test::testCharacterBorder() ...@@ -88,7 +90,7 @@ void Test::testCharacterBorder()
// No shadow // No shadow
} }
CPPUNIT_TEST_SUITE_REGISTRATION(Test); #endif
CPPUNIT_PLUGIN_IMPLEMENT(); CPPUNIT_PLUGIN_IMPLEMENT();
......
...@@ -139,8 +139,10 @@ protected: ...@@ -139,8 +139,10 @@ protected:
void executeImportExportImportTest(const char* filename) void executeImportExportImportTest(const char* filename)
{ {
header(); header();
preTest(filename);
load(mpTestDocumentPath, filename); load(mpTestDocumentPath, filename);
reload(mpFilter); reload(mpFilter, filename);
postTest(filename);
verify(); verify();
finish(); finish();
} }
...@@ -174,6 +176,14 @@ protected: ...@@ -174,6 +176,14 @@ protected:
{ {
} }
/**
* Override this function if not calcing layout is needed
*/
virtual bool mustCalcLayoutOf(const char* /*filename*/)
{
return true;
}
private: private:
void dumpLayout() void dumpLayout()
{ {
...@@ -391,7 +401,7 @@ protected: ...@@ -391,7 +401,7 @@ protected:
std::cerr << "File tested,Execution Time (ms)" << std::endl; std::cerr << "File tested,Execution Time (ms)" << std::endl;
} }
void load(const char* pDir, const char* pName, bool bCalcLayout = true) void load(const char* pDir, const char* pName)
{ {
if (mxComponent.is()) if (mxComponent.is())
mxComponent->dispose(); mxComponent->dispose();
...@@ -399,11 +409,11 @@ protected: ...@@ -399,11 +409,11 @@ protected:
std::cerr << pName << ","; std::cerr << pName << ",";
m_nStartTime = osl_getGlobalTimer(); m_nStartTime = osl_getGlobalTimer();
mxComponent = loadFromDesktop(getURLFromSrc(pDir) + OUString::createFromAscii(pName), "com.sun.star.text.TextDocument"); mxComponent = loadFromDesktop(getURLFromSrc(pDir) + OUString::createFromAscii(pName), "com.sun.star.text.TextDocument");
if (bCalcLayout) if (mustCalcLayoutOf(pName))
calcLayout(); calcLayout();
} }
void reload(const char* pFilter) void reload(const char* pFilter, const char* filename)
{ {
uno::Reference<frame::XStorable> xStorable(mxComponent, uno::UNO_QUERY); uno::Reference<frame::XStorable> xStorable(mxComponent, uno::UNO_QUERY);
uno::Sequence<beans::PropertyValue> aArgs(1); uno::Sequence<beans::PropertyValue> aArgs(1);
...@@ -420,7 +430,8 @@ protected: ...@@ -420,7 +430,8 @@ protected:
xmlBufferFree(mpXmlBuffer); xmlBufferFree(mpXmlBuffer);
mpXmlBuffer = 0; mpXmlBuffer = 0;
} }
calcLayout(); if (mustCalcLayoutOf(filename))
calcLayout();
} }
/// Save the loaded document to a tempfile. Can be used to check the resulting docx/odt directly as a ZIP file. /// Save the loaded document to a tempfile. Can be used to check the resulting docx/odt directly as a ZIP file.
......
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