summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJan Holesovsky <kendy@suse.cz>2013-05-14 16:39:14 +0200
committerJan Holesovsky <kendy@suse.cz>2013-05-14 16:50:48 +0200
commitd97732f635c0583fbeea5706399ba9197903dc83 (patch)
treebca670915682a034de36535cae46db9b6af675f0
parentafdbd5099237c5f9ab4f7b2a6599fe05ce703330 (diff)
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
-rwxr-xr-xsd/qa/unit/data/n758621.pptbin0 -> 115712 bytes
-rw-r--r--sd/qa/unit/data/xml/n758621_0.xml31
-rw-r--r--sd/qa/unit/data/xml/n758621_1.xml31
-rw-r--r--sd/qa/unit/import-tests.cxx20
-rw-r--r--sd/qa/unit/sdmodeltestbase.hxx46
5 files changed, 108 insertions, 20 deletions
diff --git a/sd/qa/unit/data/n758621.ppt b/sd/qa/unit/data/n758621.ppt
new file mode 100755
index 000000000000..1470efa2b334
--- /dev/null
+++ b/sd/qa/unit/data/n758621.ppt
Binary files 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 000000000000..fe2e15652e08
--- /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 000000000000..a76af22f6c82
--- /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 df3b1de7e9ac..0c6d8a72a89d 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 9852338a4c21..853f089d0c26 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: */