[Libreoffice-commits] core.git: 7 commits - sd/CppunitTest_sd_import_tests.mk sd/CppunitTest_sd_regression_test.mk sd/Module_sd.mk sd/qa test/source
Jan Holesovsky
kendy at suse.cz
Tue May 14 07:51:09 PDT 2013
dev/null |binary
sd/CppunitTest_sd_import_tests.mk | 121 +++++++++++++++
sd/CppunitTest_sd_regression_test.mk | 121 ---------------
sd/Module_sd.mk | 2
sd/qa/unit/data/n758621.ppt |binary
sd/qa/unit/data/smoketest.pptx |binary
sd/qa/unit/data/xml/n758621_0.xml | 31 +++
sd/qa/unit/data/xml/n758621_1.xml | 31 +++
sd/qa/unit/filters-test.cxx | 104 -------------
sd/qa/unit/import-tests.cxx | 159 ++++++++++++++++++++
sd/qa/unit/regression-test.cxx | 273 -----------------------------------
sd/qa/unit/sdmodeltestbase.hxx | 176 ++++++++++++++++++++++
test/source/diff/diff.cxx | 46 ++++-
13 files changed, 553 insertions(+), 511 deletions(-)
New commits:
commit d97732f635c0583fbeea5706399ba9197903dc83
Author: Jan Holesovsky <kendy at suse.cz>
Date: Tue May 14 16:39:14 2013 +0200
sd unittests: Fix the loading of .ppt tests, and introduce test for n#758621.
This also adds instructions how to easily add tests for which it is enough to
check the drawinglayer dump.
Change-Id: Ieaf261a9be0c8da2fa81c075dadebcac0c07def5
diff --git a/sd/qa/unit/data/n758621.ppt b/sd/qa/unit/data/n758621.ppt
new file mode 100755
index 0000000..1470efa
Binary files /dev/null and b/sd/qa/unit/data/n758621.ppt differ
diff --git a/sd/qa/unit/data/xml/n758621_0.xml b/sd/qa/unit/data/xml/n758621_0.xml
new file mode 100644
index 0000000..fe2e156
--- /dev/null
+++ b/sd/qa/unit/data/xml/n758621_0.xml
@@ -0,0 +1,31 @@
+<?xml version="1.0"?>
+<XShapes>
+ <XShape positionX="12042" positionY="1899" sizeX="12087" sizeY="9783" type="com.sun.star.presentation.TitleTextShape" textAutoGrowHeight="true" textAutoGrowWidth="false" textContourFrame="false" textFitToSize="NONE" textHorizontalAdjust="LEFT" textVerticalAdjust="CENTER" textLeftDistance="250" textRightDistance="250" textUpperDistance="130" textLowerDistance="130" textMaximumFrameHeight="0" textMaximumFrameWidth="0" textMinimumFrameHeight="9523" textMinimumFrameWidth="0" textAnimationAmount="0" textAnimationCount="0" textAnimationDelay="0" textAnimationDirection="LEFT" textAnimationKind="NONE" textAnimationStartInside="false" textAnimationStopInside="false" textWritingMode="LR_TB" fillStyle="NONE" fillColor="16777215" fillTransparence="0" fillTransparenceGradientName="">
+ <FillTransparenceGradient style="LINEAR" startColor="0" endColor="16777215" angle="0" border="0" xOffset="50" yOffset="50" startIntensity="100" endIntensity="100" stepCount="0"/>
+ <FillGradient style="LINEAR" startColor="0" endColor="16777215" angle="0" border="0" xOffset="50" yOffset="50" startIntensity="100" endIntensity="100" stepCount="0"/>
+ <FillHatch style="SINGLE" color="3433903" distance="20" angle="0"/>
+ <FillBitmap/>
+ <LineDash style="RECT" dots="1" dotLen="20" dashes="1" dashLen="20" distance="20"/>
+ <LineStart/>
+ <LineEnd/>
+ <Transformation>
+ <Line1 column1="12088.000000" column2="0.000000" column3="12042.000000"/>
+ <Line2 column1="0.000000" column2="9784.000000" column3="1899.000000"/>
+ <Line3 column1="0.000000" column2="0.000000" column3="1.000000"/>
+ </Transformation>
+ </XShape>
+ <XShape positionX="14176" positionY="13248" sizeX="9953" sizeY="3812" type="com.sun.star.presentation.SubtitleShape" textAutoGrowHeight="true" textAutoGrowWidth="false" textContourFrame="false" textFitToSize="NONE" textHorizontalAdjust="BLOCK" textVerticalAdjust="CENTER" textLeftDistance="0" textRightDistance="0" textUpperDistance="0" textLowerDistance="0" textMaximumFrameHeight="0" textMaximumFrameWidth="0" textMinimumFrameHeight="3812" textMinimumFrameWidth="0" textAnimationAmount="0" textAnimationCount="0" textAnimationDelay="0" textAnimationDirection="LEFT" textAnimationKind="NONE" textAnimationStartInside="false" textAnimationStopInside="false" textWritingMode="LR_TB" fillStyle="NONE" fillColor="16777215" fillTransparence="0" fillTransparenceGradientName="">
+ <FillTransparenceGradient style="LINEAR" startColor="0" endColor="16777215" angle="0" border="0" xOffset="50" yOffset="50" startIntensity="100" endIntensity="100" stepCount="0"/>
+ <FillGradient style="LINEAR" startColor="0" endColor="16777215" angle="0" border="0" xOffset="50" yOffset="50" startIntensity="100" endIntensity="100" stepCount="0"/>
+ <FillHatch style="SINGLE" color="3433903" distance="20" angle="0"/>
+ <FillBitmap/>
+ <LineDash style="RECT" dots="1" dotLen="20" dashes="1" dashLen="20" distance="20"/>
+ <LineStart/>
+ <LineEnd/>
+ <Transformation>
+ <Line1 column1="9954.000000" column2="0.000000" column3="14176.000000"/>
+ <Line2 column1="0.000000" column2="3813.000000" column3="13248.000000"/>
+ <Line3 column1="0.000000" column2="0.000000" column3="1.000000"/>
+ </Transformation>
+ </XShape>
+</XShapes>
diff --git a/sd/qa/unit/data/xml/n758621_1.xml b/sd/qa/unit/data/xml/n758621_1.xml
new file mode 100644
index 0000000..a76af22
--- /dev/null
+++ b/sd/qa/unit/data/xml/n758621_1.xml
@@ -0,0 +1,31 @@
+<?xml version="1.0"?>
+<XShapes>
+ <XShape positionX="1485" positionY="608" sizeX="18411" sizeY="2209" type="com.sun.star.presentation.TitleTextShape" textAutoGrowHeight="true" textAutoGrowWidth="false" textContourFrame="false" textFitToSize="NONE" textHorizontalAdjust="LEFT" textVerticalAdjust="CENTER" textLeftDistance="250" textRightDistance="250" textUpperDistance="130" textLowerDistance="130" textMaximumFrameHeight="0" textMaximumFrameWidth="0" textMinimumFrameHeight="1949" textMinimumFrameWidth="0" textAnimationAmount="0" textAnimationCount="0" textAnimationDelay="0" textAnimationDirection="LEFT" textAnimationKind="NONE" textAnimationStartInside="false" textAnimationStopInside="false" textWritingMode="LR_TB" fillStyle="NONE" fillColor="16777215" fillTransparence="0" fillTransparenceGradientName="">
+ <FillTransparenceGradient style="LINEAR" startColor="0" endColor="16777215" angle="0" border="0" xOffset="50" yOffset="50" startIntensity="100" endIntensity="100" stepCount="0"/>
+ <FillGradient style="LINEAR" startColor="0" endColor="16777215" angle="0" border="0" xOffset="50" yOffset="50" startIntensity="100" endIntensity="100" stepCount="0"/>
+ <FillHatch style="SINGLE" color="3433903" distance="20" angle="0"/>
+ <FillBitmap/>
+ <LineDash style="RECT" dots="1" dotLen="20" dashes="1" dashLen="20" distance="20"/>
+ <LineStart/>
+ <LineEnd/>
+ <Transformation>
+ <Line1 column1="18412.000000" column2="0.000000" column3="1485.000000"/>
+ <Line2 column1="0.000000" column2="2210.000000" column3="608.000000"/>
+ <Line3 column1="0.000000" column2="0.000000" column3="1.000000"/>
+ </Transformation>
+ </XShape>
+ <XShape positionX="1692" positionY="4444" sizeX="22217" sizeY="12313" type="com.sun.star.presentation.OutlinerShape" textAutoGrowHeight="false" textAutoGrowWidth="false" textContourFrame="false" textFitToSize="AUTOFIT" textHorizontalAdjust="LEFT" textVerticalAdjust="TOP" textLeftDistance="250" textRightDistance="250" textUpperDistance="130" textLowerDistance="130" textMaximumFrameHeight="0" textMaximumFrameWidth="0" textMinimumFrameHeight="12063" textMinimumFrameWidth="0" textAnimationAmount="0" textAnimationCount="0" textAnimationDelay="0" textAnimationDirection="LEFT" textAnimationKind="NONE" textAnimationStartInside="false" textAnimationStopInside="false" textWritingMode="LR_TB" fillStyle="NONE" fillColor="16777215" fillTransparence="0" fillTransparenceGradientName="">
+ <FillTransparenceGradient style="LINEAR" startColor="0" endColor="16777215" angle="0" border="0" xOffset="50" yOffset="50" startIntensity="100" endIntensity="100" stepCount="0"/>
+ <FillGradient style="LINEAR" startColor="0" endColor="16777215" angle="0" border="0" xOffset="50" yOffset="50" startIntensity="100" endIntensity="100" stepCount="0"/>
+ <FillHatch style="SINGLE" color="3433903" distance="20" angle="0"/>
+ <FillBitmap/>
+ <LineDash style="RECT" dots="1" dotLen="20" dashes="1" dashLen="20" distance="20"/>
+ <LineStart/>
+ <LineEnd/>
+ <Transformation>
+ <Line1 column1="22218.000000" column2="0.000000" column3="1692.000000"/>
+ <Line2 column1="0.000000" column2="12314.000000" column3="4444.000000"/>
+ <Line3 column1="0.000000" column2="0.000000" column3="1.000000"/>
+ </Transformation>
+ </XShape>
+</XShapes>
diff --git a/sd/qa/unit/import-tests.cxx b/sd/qa/unit/import-tests.cxx
index df3b1de..0c6d8a7 100644
--- a/sd/qa/unit/import-tests.cxx
+++ b/sd/qa/unit/import-tests.cxx
@@ -38,20 +38,32 @@ public:
/** Test document against a reference XML dump of shapes.
-TODO: add info how to create the reference XML dump.
+If you want to update one of these tests, set the nUpdateMe to the index of
+the test, the dump XML's will be created (or rewritten) instead of checking.
+Use with care - when the test is failing, first find out why, instead of just
+updating .xml's blindly.
+
+NOTE: This approach is suitable only for tests of fixes that actually change
+the layout - best to check by reverting your fix locally after having added
+the test, and re-running; it should break.
*/
void SdFiltersTest::testDocumentLayout()
{
struct { const char *pInput, *pDump; } aFilesToCompare[] =
{
{ "odp/shapes-test.odp", "xml/shapes-test_page" },
- { "pptx/fdo47434-all.pptx", "pptx/xml/fdo47434_page" }
+ { "pptx/fdo47434-all.pptx", "pptx/xml/fdo47434_page" },
+ { "n758621.ppt", "xml/n758621_" }
};
- for ( unsigned int i = 0; i < SAL_N_ELEMENTS( aFilesToCompare ); ++i )
+ for ( int i = 0; i < static_cast< int >( SAL_N_ELEMENTS( aFilesToCompare ) ); ++i )
{
+ int nUpdateMe = -1; // index of test we want to update; supposedly only when the test is created
+
::sd::DrawDocShellRef xDocShRef = loadURL( getURLFromSrc( "/sd/qa/unit/data/" ) + OUString::createFromAscii( aFilesToCompare[i].pInput ) );
- compareWithShapesDump( xDocShRef, getPathFromSrc( "/sd/qa/unit/data/" ) + OUString::createFromAscii( aFilesToCompare[i].pDump ) );
+ compareWithShapesDump( xDocShRef,
+ getPathFromSrc( "/sd/qa/unit/data/" ) + OUString::createFromAscii( aFilesToCompare[i].pDump ),
+ i == nUpdateMe );
}
}
diff --git a/sd/qa/unit/sdmodeltestbase.hxx b/sd/qa/unit/sdmodeltestbase.hxx
index 9852338..853f089 100644
--- a/sd/qa/unit/sdmodeltestbase.hxx
+++ b/sd/qa/unit/sdmodeltestbase.hxx
@@ -29,7 +29,7 @@
using namespace ::com::sun::star;
struct FileFormat {
- const char* pName; const char* pFilterName; const char* pTypeName; sal_uLong nFormatType;
+ const char* pName; const char* pFilterName; const char* pTypeName; const char* pUserData; sal_uLong nFormatType;
};
// These values are taken from "Flags" in filter/source/config/fragments/filters/*
@@ -46,10 +46,10 @@ pTypeName: <prop oor:Name="UIName">...</prop>
nFormatType: <prop oor:name="Flags">...</prop>
*/
FileFormat aFileFormats[] = {
- { "odp", "impress8", "impress8", ODP_FORMAT_TYPE },
- { "ppt", "MS PowerPoint 97", "Microsoft PowerPoint 97/2000/XP/2003", PPT_FORMAT_TYPE },
- { "pptx", "Impress MS PowerPoint 2007 XML", "MS PowerPoint 2007 XML", PPTX_FORMAT_TYPE },
- { 0, 0, 0, 0 }
+ { "odp", "impress8", "impress8", "", ODP_FORMAT_TYPE },
+ { "ppt", "MS PowerPoint 97", "Microsoft PowerPoint 97/2000/XP/2003", "sdfilt", PPT_FORMAT_TYPE },
+ { "pptx", "Impress MS PowerPoint 2007 XML", "MS PowerPoint 2007 XML", "", PPTX_FORMAT_TYPE },
+ { 0, 0, 0, 0, 0 }
};
/// Base class for filter tests loading or roundtriping a document, and asserting the document model.
@@ -97,7 +97,8 @@ protected:
OUString::createFromAscii( pFmt->pFilterName ),
OUString(), pFmt->nFormatType, nFormat,
OUString::createFromAscii( pFmt->pTypeName ),
- 0, OUString(), OUString(), /* userdata */
+ 0, OUString(),
+ OUString::createFromAscii( pFmt->pUserData ),
OUString("private:factory/simpress*") );
aFilter->SetVersion(SOFFICE_FILEFORMAT_CURRENT);
@@ -108,14 +109,17 @@ protected:
{
if (xDocShRef.Is())
xDocShRef->DoClose();
- CPPUNIT_ASSERT_MESSAGE( "failed to load", false );
+ CPPUNIT_ASSERT_MESSAGE( OUStringToOString( "failed to load " + rURL, RTL_TEXTENCODING_UTF8 ).getStr(), false );
}
return xDocShRef;
}
- /// Dump shapes in xDocShRef, and compare the dump against content of pShapesDumpFileNameBase<number>.xml.
- void compareWithShapesDump( ::sd::DrawDocShellRef xDocShRef, const OUString &rShapesDumpFileNameBase )
+ /** Dump shapes in xDocShRef, and compare the dump against content of pShapesDumpFileNameBase<number>.xml.
+
+ @param bCreate Instead of comparing to the reference file(s), create it/them.
+ */
+ void compareWithShapesDump( ::sd::DrawDocShellRef xDocShRef, const OUString &rShapesDumpFileNameBase, bool bCreate = false )
{
CPPUNIT_ASSERT_MESSAGE( "failed to load", xDocShRef.Is() );
CPPUNIT_ASSERT_MESSAGE( "not in destruction", !xDocShRef->IsInDestruction() );
@@ -143,13 +147,21 @@ protected:
OString aFileName = aFileNameBuf.makeStringAndClear();
- std::cout << aString << std::endl;
- doXMLDiff(aFileName.getStr(),
- OUStringToOString(aString, RTL_TEXTENCODING_UTF8).getStr(),
- static_cast<int>(aString.getLength()),
- OUStringToOString(
- getPathFromSrc("/sd/qa/unit/data/tolerance.xml"),
- RTL_TEXTENCODING_UTF8).getStr());
+ if ( bCreate )
+ {
+ std::ofstream aStream( aFileName.getStr(), std::ofstream::out );
+ aStream << aString;
+ aStream.close();
+ }
+ else
+ {
+ doXMLDiff(aFileName.getStr(),
+ OUStringToOString(aString, RTL_TEXTENCODING_UTF8).getStr(),
+ static_cast<int>(aString.getLength()),
+ OUStringToOString(
+ getPathFromSrc("/sd/qa/unit/data/tolerance.xml"),
+ RTL_TEXTENCODING_UTF8).getStr());
+ }
}
xDocShRef->DoClose();
}
@@ -160,3 +172,5 @@ private:
};
#endif
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
commit afdbd5099237c5f9ab4f7b2a6599fe05ce703330
Author: Jan Holesovsky <kendy at suse.cz>
Date: Tue May 14 12:13:16 2013 +0200
sd unittests: Cleanup in filters-test.
Change-Id: I4dde07c4f796fa33b23cc3e67924270bb3e45ec1
diff --git a/sd/qa/unit/filters-test.cxx b/sd/qa/unit/filters-test.cxx
index f0c3611..682f7b2 100644
--- a/sd/qa/unit/filters-test.cxx
+++ b/sd/qa/unit/filters-test.cxx
@@ -30,10 +30,9 @@
#include <osl/process.h>
#include <osl/thread.h>
-/* Implementation of Filters test */
-
using namespace ::com::sun::star;
+/// Test loading of files to assure they do not crash on load.
class SdFiltersTest
: public test::FiltersTest
, public test::BootstrapFixture
@@ -41,7 +40,6 @@ class SdFiltersTest
public:
SdFiltersTest();
- ::sd::DrawDocShellRef loadURL( const OUString &rURL );
virtual bool load( const OUString &rFilter,
const OUString &rURL, const OUString &rUserData,
unsigned int nFilterFlags, unsigned int nClipboardID,
@@ -58,58 +56,9 @@ public:
CPPUNIT_TEST_SUITE_END();
private:
- uno::Reference<document::XFilter> m_xFilter;
uno::Reference<uno::XInterface> m_xDrawComponent;
};
-#define PPTX_FORMAT_TYPE 268959811
-
-struct FileFormat {
- const char* pName; const char* pFilterName; const char* pTypeName; sal_uLong nFormatType;
-};
-
-// cf. sc/qa/unit/filters-test.cxx and filters/...*.xcu to fill out.
-FileFormat aFileFormats[] = {
- { "pptx" , "Impress MS PowerPoint 2007 XML", "MS PowerPoint 2007 XML", PPTX_FORMAT_TYPE },
- { 0, 0, 0, 0 }
-};
-
-::sd::DrawDocShellRef SdFiltersTest::loadURL( const OUString &rURL )
-{
- FileFormat *pFmt = NULL;
-
- for (size_t i = 0; i < SAL_N_ELEMENTS (aFileFormats); i++)
- {
- pFmt = aFileFormats + i;
- if (pFmt->pName && rURL.endsWithIgnoreAsciiCaseAsciiL (pFmt->pName, strlen (pFmt->pName)))
- break;
- }
- CPPUNIT_ASSERT_MESSAGE( "missing filter info", pFmt && pFmt->pName != NULL );
-
- sal_uInt32 nFormat = 0;
- if (pFmt->nFormatType)
- nFormat = SFX_FILTER_IMPORT | SFX_FILTER_USESOPTIONS;
- SfxFilter* aFilter = new SfxFilter(
- OUString::createFromAscii( pFmt->pFilterName ),
- OUString(), pFmt->nFormatType, nFormat,
- OUString::createFromAscii( pFmt->pTypeName ),
- 0, OUString(), OUString(), /* userdata */
- OUString("private:factory/sdraw*") );
- aFilter->SetVersion(SOFFICE_FILEFORMAT_CURRENT);
-
- ::sd::DrawDocShellRef xDocShRef = new ::sd::DrawDocShell();
- SfxMedium* pSrcMed = new SfxMedium(rURL, STREAM_STD_READ);
- pSrcMed->SetFilter(aFilter);
- if ( !xDocShRef->DoLoad(pSrcMed) )
- {
- if (xDocShRef.Is())
- xDocShRef->DoClose();
- CPPUNIT_ASSERT_MESSAGE( "failed to load", false );
- }
-
- return xDocShRef;
-}
-
bool SdFiltersTest::load(const OUString &rFilter, const OUString &rURL,
const OUString &rUserData, unsigned int nFilterFlags, unsigned int nClipboardID,
unsigned int nFilterVersion)
commit 7f33959d0b0c57838d5752d7053cf6c102ac5bd4
Author: Jan Holesovsky <kendy at suse.cz>
Date: Tue May 14 12:06:11 2013 +0200
sd unittests: Move Autofit test to the import tests.
Change-Id: I6c49345fa518f19c942ff0fd7849c689d0cd5db6
diff --git a/sd/qa/unit/filters-test.cxx b/sd/qa/unit/filters-test.cxx
index e51a777..f0c3611 100644
--- a/sd/qa/unit/filters-test.cxx
+++ b/sd/qa/unit/filters-test.cxx
@@ -52,10 +52,8 @@ public:
// Ensure CVEs remain unbroken
void testCVEs();
- void testN778859();
CPPUNIT_TEST_SUITE(SdFiltersTest);
- CPPUNIT_TEST(testN778859);
CPPUNIT_TEST(testCVEs);
CPPUNIT_TEST_SUITE_END();
@@ -112,24 +110,6 @@ FileFormat aFileFormats[] = {
return xDocShRef;
}
-void SdFiltersTest::testN778859()
-{
- ::sd::DrawDocShellRef xDocShRef = loadURL(getURLFromSrc("/sd/qa/unit/data/pptx/n778859.pptx"));
- CPPUNIT_ASSERT_MESSAGE( "failed to load", xDocShRef.Is() );
- CPPUNIT_ASSERT_MESSAGE( "not in destruction", !xDocShRef->IsInDestruction() );
-
- SdDrawDocument *pDoc = xDocShRef->GetDoc();
- CPPUNIT_ASSERT_MESSAGE( "no document", pDoc != NULL );
- const SdrPage *pPage = pDoc->GetPage(1);
- CPPUNIT_ASSERT_MESSAGE( "no page", pPage != NULL );
- {
- // Get the object
- SdrObject *pObj = pPage->GetObj(1);
- SdrTextObj *pTxtObj = dynamic_cast<SdrTextObj *>( pObj );
- CPPUNIT_ASSERT(!pTxtObj->IsAutoFit());
- }
-}
-
bool SdFiltersTest::load(const OUString &rFilter, const OUString &rURL,
const OUString &rUserData, unsigned int nFilterFlags, unsigned int nClipboardID,
unsigned int nFilterVersion)
diff --git a/sd/qa/unit/import-tests.cxx b/sd/qa/unit/import-tests.cxx
index 0906464..df3b1de 100644
--- a/sd/qa/unit/import-tests.cxx
+++ b/sd/qa/unit/import-tests.cxx
@@ -26,11 +26,13 @@ public:
void testDocumentLayout();
void testSmoketest();
void testN759180();
+ void testN778859();
CPPUNIT_TEST_SUITE(SdFiltersTest);
CPPUNIT_TEST(testDocumentLayout);
CPPUNIT_TEST(testSmoketest);
CPPUNIT_TEST(testN759180);
+ CPPUNIT_TEST(testN778859);
CPPUNIT_TEST_SUITE_END();
};
@@ -120,6 +122,24 @@ void SdFiltersTest::testN759180()
}
}
+void SdFiltersTest::testN778859()
+{
+ ::sd::DrawDocShellRef xDocShRef = loadURL(getURLFromSrc("/sd/qa/unit/data/pptx/n778859.pptx"));
+ CPPUNIT_ASSERT_MESSAGE( "failed to load", xDocShRef.Is() );
+ CPPUNIT_ASSERT_MESSAGE( "not in destruction", !xDocShRef->IsInDestruction() );
+
+ SdDrawDocument *pDoc = xDocShRef->GetDoc();
+ CPPUNIT_ASSERT_MESSAGE( "no document", pDoc != NULL );
+ const SdrPage *pPage = pDoc->GetPage(1);
+ CPPUNIT_ASSERT_MESSAGE( "no page", pPage != NULL );
+ {
+ // Get the object
+ SdrObject *pObj = pPage->GetObj(1);
+ SdrTextObj *pTxtObj = dynamic_cast<SdrTextObj *>( pObj );
+ CPPUNIT_ASSERT(!pTxtObj->IsAutoFit());
+ }
+}
+
CPPUNIT_TEST_SUITE_REGISTRATION(SdFiltersTest);
CPPUNIT_PLUGIN_IMPLEMENT();
commit 39ee11db03368a18bc1746a6312307c4cf1b4bdc
Author: Jan Holesovsky <kendy at suse.cz>
Date: Tue May 14 11:54:37 2013 +0200
sd unittests: Move a smoketest where it belongs.
Change-Id: I495f8698f58a2a4a11999e8e439eddd6a703b321
diff --git a/sd/qa/unit/data/a.pptx b/sd/qa/unit/data/smoketest.pptx
similarity index 100%
rename from sd/qa/unit/data/a.pptx
rename to sd/qa/unit/data/smoketest.pptx
diff --git a/sd/qa/unit/filters-test.cxx b/sd/qa/unit/filters-test.cxx
index 496fb50..e51a777 100644
--- a/sd/qa/unit/filters-test.cxx
+++ b/sd/qa/unit/filters-test.cxx
@@ -50,13 +50,11 @@ public:
virtual void setUp();
virtual void tearDown();
- void test();
// Ensure CVEs remain unbroken
void testCVEs();
void testN778859();
CPPUNIT_TEST_SUITE(SdFiltersTest);
- CPPUNIT_TEST(test);
CPPUNIT_TEST(testN778859);
CPPUNIT_TEST(testCVEs);
CPPUNIT_TEST_SUITE_END();
@@ -114,35 +112,6 @@ FileFormat aFileFormats[] = {
return xDocShRef;
}
-void SdFiltersTest::test()
-{
- ::sd::DrawDocShellRef xDocShRef = loadURL(getURLFromSrc("/sd/qa/unit/data/a.pptx"));
- CPPUNIT_ASSERT_MESSAGE( "failed to load", xDocShRef.Is() );
- CPPUNIT_ASSERT_MESSAGE( "not in destruction", !xDocShRef->IsInDestruction() );
-
- SdDrawDocument *pDoc = xDocShRef->GetDoc();
- CPPUNIT_ASSERT_MESSAGE( "no document", pDoc != NULL );
-
- // cf. SdrModel svx/svdmodel.hxx ...
-
- CPPUNIT_ASSERT_MESSAGE( "wrong page count", pDoc->GetPageCount() == 3);
-
- const SdrPage *pPage = pDoc->GetPage (1);
- CPPUNIT_ASSERT_MESSAGE( "no page", pPage != NULL );
-
- sal_uIntPtr nObjs = pPage->GetObjCount();
- for (sal_uIntPtr i = 0; i < nObjs; i++)
- {
- SdrObject *pObj = pPage->GetObj(i);
- SdrObjKind eKind = (SdrObjKind) pObj->GetObjIdentifier();
- SdrTextObj *pTxt = dynamic_cast<SdrTextObj *>( pObj );
- (void)pTxt; (void)eKind;
- }
-
- CPPUNIT_ASSERT_MESSAGE( "changed", !pDoc->IsChanged() );
- xDocShRef->DoClose();
-}
-
void SdFiltersTest::testN778859()
{
::sd::DrawDocShellRef xDocShRef = loadURL(getURLFromSrc("/sd/qa/unit/data/pptx/n778859.pptx"));
diff --git a/sd/qa/unit/import-tests.cxx b/sd/qa/unit/import-tests.cxx
index 73da840..0906464 100644
--- a/sd/qa/unit/import-tests.cxx
+++ b/sd/qa/unit/import-tests.cxx
@@ -24,10 +24,12 @@ class SdFiltersTest : public SdModelTestBase
{
public:
void testDocumentLayout();
+ void testSmoketest();
void testN759180();
CPPUNIT_TEST_SUITE(SdFiltersTest);
CPPUNIT_TEST(testDocumentLayout);
+ CPPUNIT_TEST(testSmoketest);
CPPUNIT_TEST(testN759180);
CPPUNIT_TEST_SUITE_END();
};
@@ -51,6 +53,35 @@ void SdFiltersTest::testDocumentLayout()
}
}
+void SdFiltersTest::testSmoketest()
+{
+ ::sd::DrawDocShellRef xDocShRef = loadURL(getURLFromSrc("/sd/qa/unit/data/smoketest.pptx"));
+ CPPUNIT_ASSERT_MESSAGE( "failed to load", xDocShRef.Is() );
+ CPPUNIT_ASSERT_MESSAGE( "not in destruction", !xDocShRef->IsInDestruction() );
+
+ SdDrawDocument *pDoc = xDocShRef->GetDoc();
+ CPPUNIT_ASSERT_MESSAGE( "no document", pDoc != NULL );
+
+ // cf. SdrModel svx/svdmodel.hxx ...
+
+ CPPUNIT_ASSERT_MESSAGE( "wrong page count", pDoc->GetPageCount() == 3);
+
+ const SdrPage *pPage = pDoc->GetPage (1);
+ CPPUNIT_ASSERT_MESSAGE( "no page", pPage != NULL );
+
+ sal_uIntPtr nObjs = pPage->GetObjCount();
+ for (sal_uIntPtr i = 0; i < nObjs; i++)
+ {
+ SdrObject *pObj = pPage->GetObj(i);
+ SdrObjKind eKind = (SdrObjKind) pObj->GetObjIdentifier();
+ SdrTextObj *pTxt = dynamic_cast<SdrTextObj *>( pObj );
+ (void)pTxt; (void)eKind;
+ }
+
+ CPPUNIT_ASSERT_MESSAGE( "changed", !pDoc->IsChanged() );
+ xDocShRef->DoClose();
+}
+
void SdFiltersTest::testN759180()
{
::sd::DrawDocShellRef xDocShRef = loadURL(getURLFromSrc("/sd/qa/unit/data/n759180.pptx"));
commit ab0189b2b881ee6bb324876be3311ec1942bd235
Author: Jan Holesovsky <kendy at suse.cz>
Date: Tue May 14 11:47:34 2013 +0200
sd unittests: Reorganize the Impress tests to be a bit more focused.
Change-Id: I222c824681fc7bcc25c6f591f09c69fae8c812ec
diff --git a/sd/qa/unit/import-tests.cxx b/sd/qa/unit/import-tests.cxx
index 66d4362..73da840 100644
--- a/sd/qa/unit/import-tests.cxx
+++ b/sd/qa/unit/import-tests.cxx
@@ -7,139 +7,48 @@
* file, You can obtain one at http://mozilla.org/MPL/2.0/.
*/
-#include <sal/config.h>
-#include <unotest/filters-test.hxx>
-#include <test/bootstrapfixture.hxx>
-#include <test/xmldiff.hxx>
-#include <rtl/strbuf.hxx>
-#include <osl/file.hxx>
-#include <com/sun/star/lang/XComponent.hpp>
-#include <com/sun/star/document/XFilter.hpp>
-#include <com/sun/star/frame/XStorable.hpp>
+#include "sdmodeltestbase.hxx"
-#include <sfx2/app.hxx>
-#include <sfx2/docfilt.hxx>
-#include <sfx2/docfile.hxx>
-#include <sfx2/sfxmodelfactory.hxx>
#include <svl/stritem.hxx>
-
-#include <svx/svdtext.hxx>
-#include <svx/svdotext.hxx>
-
-#include "drawdoc.hxx"
-#include "../source/ui/inc/DrawDocShell.hxx"
-
-#include <osl/process.h>
-#include <osl/thread.h>
-
-#include <string>
-#include <iostream>
-
-#include <com/sun/star/drawing/XDrawPagesSupplier.hpp>
-#include <drawinglayer/XShapeDumper.hxx>
-
#include <editeng/editobj.hxx>
#include <editeng/outlobj.hxx>
#include <editeng/ulspitem.hxx>
#include <editeng/fhgtitem.hxx>
-/* Implementation of Filters test */
+#include <svx/svdotext.hxx>
using namespace ::com::sun::star;
-class SdFiltersTest
- : public test::FiltersTest
- , public test::BootstrapFixture
+/// Impress import filters tests.
+class SdFiltersTest : public SdModelTestBase
{
public:
- SdFiltersTest();
-
- ::sd::DrawDocShellRef loadURL( const OUString &rURL );
- virtual bool load( const OUString &rFilter,
- const OUString &rURL, const OUString &rUserData,
- unsigned int nFilterFlags, unsigned int nClipboardID,
- unsigned int nFilterVersion);
-
- virtual void setUp();
- virtual void tearDown();
-
- void test();
+ void testDocumentLayout();
void testN759180();
- void testFdo47434();
CPPUNIT_TEST_SUITE(SdFiltersTest);
- CPPUNIT_TEST(test);
+ CPPUNIT_TEST(testDocumentLayout);
CPPUNIT_TEST(testN759180);
- CPPUNIT_TEST(testFdo47434);
CPPUNIT_TEST_SUITE_END();
-
-private:
- uno::Reference<document::XFilter> m_xFilter;
- uno::Reference<uno::XInterface> m_xDrawComponent;
- void testStuff(::sd::DrawDocShellRef xDocShRef, const OString& fileNameBase);
};
-#define PPTX_FORMAT_TYPE 268959811
-#define ODP_FORMAT_TYPE 285212967
-
-struct FileFormat {
- const char* pName; const char* pFilterName; const char* pTypeName; sal_uLong nFormatType;
-};
+/** Test document against a reference XML dump of shapes.
-// cf. sc/qa/unit/filters-test.cxx and filters/...*.xcu to fill out.
-FileFormat aFileFormats[] = {
- { "pptx" , "Impress MS PowerPoint 2007 XML", "MS PowerPoint 2007 XML", PPTX_FORMAT_TYPE },
- { "odp" , "impress8", "impress8", ODP_FORMAT_TYPE },
- { 0, 0, 0, 0 }
-};
-
-::sd::DrawDocShellRef SdFiltersTest::loadURL( const OUString &rURL )
+TODO: add info how to create the reference XML dump.
+*/
+void SdFiltersTest::testDocumentLayout()
{
- FileFormat *pFmt(0);
-
- for (size_t i = 0; i < SAL_N_ELEMENTS (aFileFormats); i++)
+ struct { const char *pInput, *pDump; } aFilesToCompare[] =
{
- pFmt = aFileFormats + i;
- if (pFmt->pName && rURL.endsWithIgnoreAsciiCaseAsciiL (pFmt->pName, strlen (pFmt->pName)))
- break;
- }
- CPPUNIT_ASSERT_MESSAGE( "missing filter info", pFmt->pName != NULL );
+ { "odp/shapes-test.odp", "xml/shapes-test_page" },
+ { "pptx/fdo47434-all.pptx", "pptx/xml/fdo47434_page" }
+ };
- sal_uInt32 nFormat = 0;
- if (pFmt->nFormatType)
- nFormat = SFX_FILTER_IMPORT | SFX_FILTER_USESOPTIONS;
- SfxFilter* aFilter = new SfxFilter(
- OUString::createFromAscii( pFmt->pFilterName ),
- OUString(), pFmt->nFormatType, nFormat,
- OUString::createFromAscii( pFmt->pTypeName ),
- 0, OUString(), OUString(), /* userdata */
- OUString("private:factory/simpress*") );
- aFilter->SetVersion(SOFFICE_FILEFORMAT_CURRENT);
-
- ::sd::DrawDocShellRef xDocShRef = new ::sd::DrawDocShell();
- SfxMedium* pSrcMed = new SfxMedium(rURL, STREAM_STD_READ);
- pSrcMed->SetFilter(aFilter);
- if ( !xDocShRef->DoLoad(pSrcMed) )
+ for ( unsigned int i = 0; i < SAL_N_ELEMENTS( aFilesToCompare ); ++i )
{
- if (xDocShRef.Is())
- xDocShRef->DoClose();
- CPPUNIT_ASSERT_MESSAGE( "failed to load", false );
+ ::sd::DrawDocShellRef xDocShRef = loadURL( getURLFromSrc( "/sd/qa/unit/data/" ) + OUString::createFromAscii( aFilesToCompare[i].pInput ) );
+ compareWithShapesDump( xDocShRef, getPathFromSrc( "/sd/qa/unit/data/" ) + OUString::createFromAscii( aFilesToCompare[i].pDump ) );
}
-
- return xDocShRef;
-}
-
-void SdFiltersTest::test()
-{
- {
- ::sd::DrawDocShellRef xDocShRef = loadURL(getURLFromSrc("/sd/qa/unit/data/odp/shapes-test.odp"));
- testStuff(xDocShRef, OUStringToOString(getPathFromSrc("/sd/qa/unit/data/xml/shapes-test_page"), RTL_TEXTENCODING_UTF8));
- }
- /*
- {
- ::sd::DrawDocShellRef xDocShRef = loadURL(getURLFromSrc("/sd/qa/unit/data/odp/text-test.odp"));
- testStuff(xDocShRef);
- }*/
}
void SdFiltersTest::testN759180()
@@ -180,92 +89,6 @@ void SdFiltersTest::testN759180()
}
}
-void SdFiltersTest::testFdo47434()
-{
- // The problem was the arrow that has cy < 180 and flipH = 0 is rendered incorrectly.
- // Its height should be 1, not negative.
- ::sd::DrawDocShellRef xDocShRef = loadURL(getURLFromSrc("/sd/qa/unit/data/pptx/fdo47434-all.pptx"));
- testStuff(xDocShRef, OUStringToOString(getPathFromSrc("/sd/qa/unit/data/pptx/xml/fdo47434_page"), RTL_TEXTENCODING_UTF8));
-}
-
-void SdFiltersTest::testStuff(::sd::DrawDocShellRef xDocShRef, const OString& fileNameBase)
-{
- CPPUNIT_ASSERT_MESSAGE( "failed to load", xDocShRef.Is() );
- CPPUNIT_ASSERT_MESSAGE( "not in destruction", !xDocShRef->IsInDestruction() );
-
- uno::Reference<frame::XModel> xTempModel(xDocShRef->GetDoc()->getUnoModel(), uno::UNO_QUERY_THROW);
- CPPUNIT_ASSERT(xTempModel.is());
- uno::Reference<drawing::XDrawPagesSupplier> xDrawPagesSupplier (xTempModel, uno::UNO_QUERY_THROW);
- CPPUNIT_ASSERT(xDrawPagesSupplier.is());
- uno::Reference< drawing::XDrawPages > xDrawPages = xDrawPagesSupplier->getDrawPages();
- CPPUNIT_ASSERT(xDrawPages.is());
-
- XShapeDumper xShapeDumper;
- sal_Int32 nLength = xDrawPages->getCount();
- OString aFileNameExt(".xml");
- for (sal_Int32 i = 0; i < nLength; ++i)
- {
- uno::Reference<drawing::XDrawPage> xDrawPage;
- uno::Any aAny = xDrawPages->getByIndex(i);
- aAny >>= xDrawPage;
- uno::Reference< drawing::XShapes > xShapes(xDrawPage, uno::UNO_QUERY_THROW);
- OUString aString = xShapeDumper.dump(xShapes);
- OStringBuffer aFileNameBuf(fileNameBase);
- aFileNameBuf.append(i);
- aFileNameBuf.append(aFileNameExt);
-
- OString aFileName = aFileNameBuf.makeStringAndClear();
-
- std::cout << aString << std::endl;
- doXMLDiff(aFileName.getStr(),
- OUStringToOString(aString, RTL_TEXTENCODING_UTF8).getStr(),
- static_cast<int>(aString.getLength()),
- OUStringToOString(
- getPathFromSrc("/sd/qa/unit/data/tolerance.xml"),
- RTL_TEXTENCODING_UTF8).getStr());
- }
- xDocShRef->DoClose();
-}
-
-bool SdFiltersTest::load(const OUString &rFilter, const OUString &rURL,
- const OUString &rUserData, unsigned int nFilterFlags, unsigned int nClipboardID,
- unsigned int nFilterVersion)
-{
- SfxFilter aFilter(
- rFilter,
- OUString(), nFilterFlags, nClipboardID, OUString(), 0, OUString(),
- rUserData, OUString() );
- aFilter.SetVersion(nFilterVersion);
-
- ::sd::DrawDocShellRef xDocShRef = new ::sd::DrawDocShell();
- SfxMedium* pSrcMed = new SfxMedium(rURL, STREAM_STD_READ);
- pSrcMed->SetFilter(&aFilter);
- bool bLoaded = xDocShRef->DoLoad(pSrcMed);
- xDocShRef->DoClose();
- return bLoaded;
-}
-
-SdFiltersTest::SdFiltersTest()
-{
-}
-
-void SdFiltersTest::setUp()
-{
- test::BootstrapFixture::setUp();
-
- // This is a bit of a fudge, we do this to ensure that ScGlobals::ensure,
- // which is a private symbol to us, gets called
- m_xDrawComponent =
- getMultiServiceFactory()->createInstance(OUString("com.sun.star.comp.Draw.PresentationDocument"));
- CPPUNIT_ASSERT_MESSAGE("no impress component!", m_xDrawComponent.is());
-}
-
-void SdFiltersTest::tearDown()
-{
- uno::Reference< lang::XComponent >( m_xDrawComponent, uno::UNO_QUERY_THROW )->dispose();
- test::BootstrapFixture::tearDown();
-}
-
CPPUNIT_TEST_SUITE_REGISTRATION(SdFiltersTest);
CPPUNIT_PLUGIN_IMPLEMENT();
diff --git a/sd/qa/unit/sdmodeltestbase.hxx b/sd/qa/unit/sdmodeltestbase.hxx
new file mode 100644
index 0000000..9852338
--- /dev/null
+++ b/sd/qa/unit/sdmodeltestbase.hxx
@@ -0,0 +1,162 @@
+/* -*- 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/.
+ */
+
+#ifndef SD_QA_UNIT_SDMODELTESTBASE_HXX
+#define SD_QA_UNIT_SDMODELTESTBASE_HXX
+
+#include <test/bootstrapfixture.hxx>
+#include <test/xmldiff.hxx>
+
+#include <unotest/filters-test.hxx>
+#include <unotest/macros_test.hxx>
+
+#include "drawdoc.hxx"
+#include "../source/ui/inc/DrawDocShell.hxx"
+
+#include <rtl/strbuf.hxx>
+#include <sfx2/docfile.hxx>
+#include <sfx2/docfilt.hxx>
+
+#include <com/sun/star/drawing/XDrawPagesSupplier.hpp>
+#include <drawinglayer/XShapeDumper.hxx>
+
+using namespace ::com::sun::star;
+
+struct FileFormat {
+ const char* pName; const char* pFilterName; const char* pTypeName; sal_uLong nFormatType;
+};
+
+// These values are taken from "Flags" in filter/source/config/fragments/filters/*
+#define ODP_FORMAT_TYPE ( SFX_FILTER_IMPORT | SFX_FILTER_EXPORT | SFX_FILTER_TEMPLATE | SFX_FILTER_OWN | SFX_FILTER_DEFAULT | SFX_FILTER_ENCRYPTION | SFX_FILTER_PREFERED )
+#define PPT_FORMAT_TYPE ( SFX_FILTER_IMPORT | SFX_FILTER_EXPORT | SFX_FILTER_ALIEN )
+#define PPTX_FORMAT_TYPE ( SFX_FILTER_IMPORT | SFX_FILTER_EXPORT | SFX_FILTER_ALIEN | SFX_FILTER_STARONEFILTER | SFX_FILTER_PREFERED )
+
+/** List of file formats we support in Impress unit tests.
+
+Taken from filter/source/config/fragments/filters/ too:
+pName: The file extension.
+pFilterName: <node oor:Name="...">
+pTypeName: <prop oor:Name="UIName">...</prop>
+nFormatType: <prop oor:name="Flags">...</prop>
+*/
+FileFormat aFileFormats[] = {
+ { "odp", "impress8", "impress8", ODP_FORMAT_TYPE },
+ { "ppt", "MS PowerPoint 97", "Microsoft PowerPoint 97/2000/XP/2003", PPT_FORMAT_TYPE },
+ { "pptx", "Impress MS PowerPoint 2007 XML", "MS PowerPoint 2007 XML", PPTX_FORMAT_TYPE },
+ { 0, 0, 0, 0 }
+};
+
+/// Base class for filter tests loading or roundtriping a document, and asserting the document model.
+class SdModelTestBase : public test::BootstrapFixture, public unotest::MacrosTest
+{
+public:
+ SdModelTestBase()
+ {
+ }
+
+ virtual void setUp()
+ {
+ test::BootstrapFixture::setUp();
+
+ // This is a bit of a fudge, we do this to ensure that ScGlobals::ensure,
+ // which is a private symbol to us, gets called
+ m_xDrawComponent = getMultiServiceFactory()->createInstance(OUString("com.sun.star.comp.Draw.PresentationDocument"));
+ CPPUNIT_ASSERT_MESSAGE("no impress component!", m_xDrawComponent.is());
+ }
+
+ virtual void tearDown()
+ {
+ uno::Reference< lang::XComponent >( m_xDrawComponent, uno::UNO_QUERY_THROW )->dispose();
+ test::BootstrapFixture::tearDown();
+ }
+
+protected:
+ /// Load the document.
+ ::sd::DrawDocShellRef loadURL( const OUString &rURL )
+ {
+ FileFormat *pFmt(0);
+
+ for (size_t i = 0; i < SAL_N_ELEMENTS (aFileFormats); i++)
+ {
+ pFmt = aFileFormats + i;
+ if (pFmt->pName && rURL.endsWithIgnoreAsciiCaseAsciiL (pFmt->pName, strlen (pFmt->pName)))
+ break;
+ }
+ CPPUNIT_ASSERT_MESSAGE( "missing filter info", pFmt->pName != NULL );
+
+ sal_uInt32 nFormat = 0;
+ if (pFmt->nFormatType)
+ nFormat = SFX_FILTER_IMPORT | SFX_FILTER_USESOPTIONS;
+ SfxFilter* aFilter = new SfxFilter(
+ OUString::createFromAscii( pFmt->pFilterName ),
+ OUString(), pFmt->nFormatType, nFormat,
+ OUString::createFromAscii( pFmt->pTypeName ),
+ 0, OUString(), OUString(), /* userdata */
+ OUString("private:factory/simpress*") );
+ aFilter->SetVersion(SOFFICE_FILEFORMAT_CURRENT);
+
+ ::sd::DrawDocShellRef xDocShRef = new ::sd::DrawDocShell();
+ SfxMedium* pSrcMed = new SfxMedium(rURL, STREAM_STD_READ);
+ pSrcMed->SetFilter(aFilter);
+ if ( !xDocShRef->DoLoad(pSrcMed) )
+ {
+ if (xDocShRef.Is())
+ xDocShRef->DoClose();
+ CPPUNIT_ASSERT_MESSAGE( "failed to load", false );
+ }
+
+ return xDocShRef;
+ }
+
+ /// Dump shapes in xDocShRef, and compare the dump against content of pShapesDumpFileNameBase<number>.xml.
+ void compareWithShapesDump( ::sd::DrawDocShellRef xDocShRef, const OUString &rShapesDumpFileNameBase )
+ {
+ CPPUNIT_ASSERT_MESSAGE( "failed to load", xDocShRef.Is() );
+ CPPUNIT_ASSERT_MESSAGE( "not in destruction", !xDocShRef->IsInDestruction() );
+
+ uno::Reference<frame::XModel> xTempModel(xDocShRef->GetDoc()->getUnoModel(), uno::UNO_QUERY_THROW);
+ CPPUNIT_ASSERT(xTempModel.is());
+ uno::Reference<drawing::XDrawPagesSupplier> xDrawPagesSupplier (xTempModel, uno::UNO_QUERY_THROW);
+ CPPUNIT_ASSERT(xDrawPagesSupplier.is());
+ uno::Reference< drawing::XDrawPages > xDrawPages = xDrawPagesSupplier->getDrawPages();
+ CPPUNIT_ASSERT(xDrawPages.is());
+
+ XShapeDumper xShapeDumper;
+ sal_Int32 nLength = xDrawPages->getCount();
+ for (sal_Int32 i = 0; i < nLength; ++i)
+ {
+ uno::Reference<drawing::XDrawPage> xDrawPage;
+ uno::Any aAny = xDrawPages->getByIndex(i);
+ aAny >>= xDrawPage;
+ uno::Reference< drawing::XShapes > xShapes(xDrawPage, uno::UNO_QUERY_THROW);
+ OUString aString = xShapeDumper.dump(xShapes);
+
+ OStringBuffer aFileNameBuf( OUStringToOString( rShapesDumpFileNameBase, RTL_TEXTENCODING_UTF8 ) );
+ aFileNameBuf.append(i);
+ aFileNameBuf.append(".xml");
+
+ OString aFileName = aFileNameBuf.makeStringAndClear();
+
+ std::cout << aString << std::endl;
+ doXMLDiff(aFileName.getStr(),
+ OUStringToOString(aString, RTL_TEXTENCODING_UTF8).getStr(),
+ static_cast<int>(aString.getLength()),
+ OUStringToOString(
+ getPathFromSrc("/sd/qa/unit/data/tolerance.xml"),
+ RTL_TEXTENCODING_UTF8).getStr());
+ }
+ xDocShRef->DoClose();
+ }
+
+
+private:
+ uno::Reference<uno::XInterface> m_xDrawComponent;
+};
+
+#endif
commit 77b14c46aae4240226ef16ae3842e3ca35aaee73
Author: Jan Holesovsky <kendy at suse.cz>
Date: Tue May 14 12:00:51 2013 +0200
sd unittests: Better name for the import tests.
Change-Id: I62c47cbfd71e7606770552368e97e1c92fadf211
diff --git a/sd/CppunitTest_sd_regression_test.mk b/sd/CppunitTest_sd_import_tests.mk
similarity index 70%
rename from sd/CppunitTest_sd_regression_test.mk
rename to sd/CppunitTest_sd_import_tests.mk
index 9121af4..419269b 100644
--- a/sd/CppunitTest_sd_regression_test.mk
+++ b/sd/CppunitTest_sd_import_tests.mk
@@ -9,15 +9,15 @@
#
#*************************************************************************
-$(eval $(call gb_CppunitTest_CppunitTest,sd_regression_test))
+$(eval $(call gb_CppunitTest_CppunitTest,sd_import_tests))
-$(eval $(call gb_CppunitTest_use_external,sd_regression_test,boost_headers))
+$(eval $(call gb_CppunitTest_use_external,sd_import_tests,boost_headers))
-$(eval $(call gb_CppunitTest_add_exception_objects,sd_regression_test, \
- sd/qa/unit/regression-test \
+$(eval $(call gb_CppunitTest_add_exception_objects,sd_import_tests, \
+ sd/qa/unit/import-tests \
))
-$(eval $(call gb_CppunitTest_use_libraries,sd_regression_test, \
+$(eval $(call gb_CppunitTest_use_libraries,sd_import_tests, \
avmedia \
basegfx \
comphelper \
@@ -52,20 +52,20 @@ $(eval $(call gb_CppunitTest_use_libraries,sd_regression_test, \
$(gb_UWINAPI) \
))
-$(eval $(call gb_CppunitTest_set_include,sd_regression_test,\
+$(eval $(call gb_CppunitTest_set_include,sd_import_tests,\
-I$(SRCDIR)/sd/source/ui/inc \
-I$(SRCDIR)/sd/inc \
$$(INCLUDE) \
))
-$(eval $(call gb_CppunitTest_use_api,sd_regression_test,\
+$(eval $(call gb_CppunitTest_use_api,sd_import_tests,\
offapi \
udkapi \
))
-$(eval $(call gb_CppunitTest_use_ure,sd_regression_test))
+$(eval $(call gb_CppunitTest_use_ure,sd_import_tests))
-$(eval $(call gb_CppunitTest_use_components,sd_regression_test,\
+$(eval $(call gb_CppunitTest_use_components,sd_import_tests,\
animations/source/animcore/animcore \
basic/util/sb \
comphelper/util/comphelp \
@@ -106,16 +106,16 @@ $(eval $(call gb_CppunitTest_use_components,sd_regression_test,\
xmlsecurity/util/xmlsecurity \
))
-$(eval $(call gb_CppunitTest_use_configuration,sd_regression_test))
+$(eval $(call gb_CppunitTest_use_configuration,sd_import_tests))
-$(eval $(call gb_CppunitTest_use_filter_configuration,sd_regression_test))
+$(eval $(call gb_CppunitTest_use_filter_configuration,sd_import_tests))
-$(eval $(call gb_CppunitTest_use_unittest_configuration,sd_regression_test))
+$(eval $(call gb_CppunitTest_use_unittest_configuration,sd_import_tests))
-$(eval $(call gb_CppunitTest_add_arguments,sd_regression_test,\
+$(eval $(call gb_CppunitTest_add_arguments,sd_import_tests,\
"-env:SVG_DISABLE_FONT_EMBEDDING=YEAH" \
))
-$(call gb_CppunitTest_get_target,sd_regression_test) : $(call gb_AllLangResTarget_get_target,sd)
+$(call gb_CppunitTest_get_target,sd_import_tests) : $(call gb_AllLangResTarget_get_target,sd)
# vim: set noet sw=4 ts=4:
diff --git a/sd/Module_sd.mk b/sd/Module_sd.mk
index 64c6fe9..27cbffa 100644
--- a/sd/Module_sd.mk
+++ b/sd/Module_sd.mk
@@ -25,7 +25,7 @@ $(eval $(call gb_Module_add_targets,sd,\
ifneq ($(OS),DRAGONFLY)
$(eval $(call gb_Module_add_check_targets,sd,\
CppunitTest_sd_uimpress \
- CppunitTest_sd_regression_test \
+ CppunitTest_sd_import_tests \
CppunitTest_sd_filters_test \
))
endif
diff --git a/sd/qa/unit/regression-test.cxx b/sd/qa/unit/import-tests.cxx
similarity index 100%
rename from sd/qa/unit/regression-test.cxx
rename to sd/qa/unit/import-tests.cxx
commit 91ab2b6e9d7ea77778e65831cff0a17f3f48ce67
Author: Jan Holesovsky <kendy at suse.cz>
Date: Tue May 14 10:42:47 2013 +0200
Improve error messages for the xml-diff based unit tests.
Change-Id: Ided6749ebe4899a6d826d069c38d7b21b467d431
diff --git a/test/source/diff/diff.cxx b/test/source/diff/diff.cxx
index 37e711e..567ec80 100644
--- a/test/source/diff/diff.cxx
+++ b/test/source/diff/diff.cxx
@@ -85,15 +85,23 @@ private:
bool compareAttributes(xmlNodePtr node1, xmlNodePtr node2);
bool compareElements(xmlNodePtr node1, xmlNodePtr node2);
+ /// Error message for cppunit that prints out when expected and found are not equal.
+ void cppunitAssertEqual(const xmlChar *expected, const xmlChar *found);
+
+ /// Error message for cppunit that prints out when expected and found are not equal - for doubles.
+ void cppunitAssertEqualDouble(const xmlChar *node, double expected, double found, double delta);
+
ToleranceContainer toleranceContainer;
xmlDocPtr xmlFile1;
xmlDocPtr xmlFile2;
+ std::string fileName;
};
XMLDiff::XMLDiff( const char* pFileName, const char* pContent, int size, const char* pToleranceFile)
+ : fileName(pFileName)
{
xmlFile1 = xmlParseFile(pFileName);
xmlFile2 = xmlParseMemory(pContent, size);
@@ -169,9 +177,7 @@ bool XMLDiff::compare()
#if USE_CPPUNIT
CPPUNIT_ASSERT(root1);
CPPUNIT_ASSERT(root2);
- std::stringstream stringStream("Expected: ");
- stringStream << (char*)root1->name << "\nFound: " << (char*) root2->name;
- CPPUNIT_ASSERT_MESSAGE(stringStream.str(), xmlStrEqual(root1->name, root2->name));
+ cppunitAssertEqual(root1->name, root2->name);
#else
if (!root1 || !root2)
return false;
@@ -201,9 +207,7 @@ bool checkForEmptyChildren(xmlNodePtr node)
bool XMLDiff::compareElements(xmlNode* node1, xmlNode* node2)
{
#if USE_CPPUNIT
- std::stringstream stringStream("Expected: ");
- stringStream << (xmlChar*) node1->name << "\nFound: " << node2->name;
- CPPUNIT_ASSERT_MESSAGE(stringStream.str(), xmlStrEqual( node1->name, node2->name ));
+ cppunitAssertEqual(node1->name, node2->name);
#else
if (!xmlStrEqual( node1->name, node2->name ))
return false;
@@ -244,6 +248,26 @@ bool XMLDiff::compareElements(xmlNode* node1, xmlNode* node2)
return true;
}
+void XMLDiff::cppunitAssertEqual(const xmlChar *expected, const xmlChar *found)
+{
+#if USE_CPPUNIT
+ std::stringstream stringStream;
+ stringStream << "Reference: " << fileName << "\n- Expected: " << (const char*) expected << "\n- Found: " << (const char*) found;
+
+ CPPUNIT_ASSERT_MESSAGE(stringStream.str(), xmlStrEqual(expected, found));
+#endif
+}
+
+void XMLDiff::cppunitAssertEqualDouble(const xmlChar *node, double expected, double found, double delta)
+{
+#if USE_CPPUNIT
+ std::stringstream stringStream;
+ stringStream << "Reference: " << fileName << "\n- Node: " << (const char*) node;
+
+ CPPUNIT_ASSERT_DOUBLES_EQUAL_MESSAGE(stringStream.str(), expected, found, delta);
+#endif
+}
+
namespace {
bool compareValuesWithTolerance(double val1, double val2, double tolerance, bool relative)
@@ -267,7 +291,7 @@ bool XMLDiff::compareAttributes(xmlNodePtr node1, xmlNodePtr node2)
for(attr1 = node1->properties, attr2 = node2->properties; attr1 != NULL && attr2 != NULL; attr1 = attr1->next, attr2 = attr2->next)
{
#if USE_CPPUNIT
- CPPUNIT_ASSERT(xmlStrEqual( attr1->name, attr2->name ));
+ cppunitAssertEqual(attr1->name, attr2->name);
#else
if (!xmlStrEqual( attr1->name, attr2->name ))
return false;
@@ -308,9 +332,7 @@ bool XMLDiff::compareAttributes(xmlNodePtr node1, xmlNodePtr node2)
else
{
#if USE_CPPUNIT
- CPPUNIT_ASSERT_DOUBLES_EQUAL_MESSAGE(
- reinterpret_cast< char const * >(attr1->name), dVal1, dVal2,
- 1e-08);
+ cppunitAssertEqualDouble(attr1->name, dVal1, dVal2, 1e-08);
#else
if (dVal1 != dVal2)
return false;
@@ -321,9 +343,7 @@ bool XMLDiff::compareAttributes(xmlNodePtr node1, xmlNodePtr node2)
{
#if USE_CPPUNIT
- std::stringstream stringStream("Expected: ");
- stringStream << (char*)val1 << "\nFound: " << (char*)val2;
- CPPUNIT_ASSERT_MESSAGE(stringStream.str(), xmlStrEqual(val1, val2));
+ cppunitAssertEqual(val1, val2);
#else
if(!xmlStrEqual( val1, val2 ))
return false;
More information about the Libreoffice-commits
mailing list