diff options
author | Markus Mohrhard <markus.mohrhard@googlemail.com> | 2013-12-13 17:38:43 +0100 |
---|---|---|
committer | Markus Mohrhard <markus.mohrhard@googlemail.com> | 2013-12-13 20:05:14 +0100 |
commit | 31cba7d34694f50ddf015b405688635b591ce2c0 (patch) | |
tree | 8ad14a5279a4c878834fe1640242028429b7b708 /chart2 | |
parent | d843d64283c311f02ff663cb02d7ac5a4e744bfc (diff) |
fixes for previous commit
Change-Id: Ic4f2d36ce901b88b47b43fdebba197daf8bd0373
Diffstat (limited to 'chart2')
-rw-r--r-- | chart2/qa/extras/chart2export.cxx | 14 | ||||
-rw-r--r-- | chart2/qa/extras/charttest.hxx | 43 |
2 files changed, 25 insertions, 32 deletions
diff --git a/chart2/qa/extras/chart2export.cxx b/chart2/qa/extras/chart2export.cxx index d122d8c0f147..276715874979 100644 --- a/chart2/qa/extras/chart2export.cxx +++ b/chart2/qa/extras/chart2export.cxx @@ -49,7 +49,7 @@ protected: * xml stream, and asserting an XPath expression. This method returns the * xml stream, so that you can do the asserting. */ - xmlDocPtr parseExport(const OUString& rStreamName); + xmlDocPtr parseExport(const OUString& rStreamName, const OUString& rFilterFormat); /** * Helper method to return nodes represented by rXPath. @@ -83,11 +83,9 @@ void Chart2ExportTest::test() reload("Calc Office Open XML"); } -xmlDocPtr Chart2ExportTest::parseExport(const OUString& rStreamName) +xmlDocPtr Chart2ExportTest::parseExport(const OUString& rStreamName, const OUString& rFilterFormat) { - if (!m_bExported) - return 0; - utl::TempFile aTempFile = reload("Office Open XML Text"); + utl::TempFile aTempFile = reload(rFilterFormat); // Read the XML stream we're interested in. uno::Reference<packages::zip::XZipFileAccess2> xNameAccess = packages::zip::ZipFileAccess::createWithURL(comphelper::getComponentContext(m_xSFactory), aTempFile.GetURL()); @@ -374,7 +372,7 @@ void Chart2ExportTest::testStockChart() */ load("/chart2/qa/extras/data/docx/", "testStockChart.docx"); - xmlDocPtr pXmlDoc = parseExport("word/charts/chart1.xml"); + xmlDocPtr pXmlDoc = parseExport("word/charts/chart1.xml", "Office Open XML Text"); if (!pXmlDoc) return; @@ -386,9 +384,9 @@ void Chart2ExportTest::testStockChart() void Chart2ExportTest::testBarChart() { load("/chart2/qa/extras/data/docx/", "testBarChart.docx"); - xmlDocPtr pXmlDoc = parseExport("word/charts/chart1.xml"); + xmlDocPtr pXmlDoc = parseExport("word/charts/chart1.xml", "Office Open XML Text"); if (!pXmlDoc) - return; + return; assertXPath(pXmlDoc, "/c:chartSpace/c:chart/c:plotArea/c:barChart/c:barDir", "val", "col"); } diff --git a/chart2/qa/extras/charttest.hxx b/chart2/qa/extras/charttest.hxx index fdabb9c0b654..b50f4fd6cd0f 100644 --- a/chart2/qa/extras/charttest.hxx +++ b/chart2/qa/extras/charttest.hxx @@ -50,15 +50,10 @@ using namespace com::sun::star::uno; class ChartTest : public test::BootstrapFixture, public unotest::MacrosTest { public: - ChartTest() - : mServiceName(), - m_bExported(false) - { - } - void load( const char* pDir, const char* pName ); - utl::TempFile reload( const OUString& rFilterName ); + void load( const OUString& rDir, const OUString& rFileName ); + utl::TempFile reload( const OUString& rFileName ); uno::Sequence < OUString > getImpressChartColumnDescriptions( const char* pDir, const char* pName ); - OUString getFileExtension( const char* pName ); + OUString getFileExtension( const OUString& rFileName ); void loadDocx(const char* pDir, const char* pName); utl::TempFile reloadDocx(); @@ -67,29 +62,29 @@ public: protected: Reference< lang::XComponent > mxComponent; - const char* mServiceName; - bool m_bExported; ///< Does m_aTempFile already contain something useful? - + OUString maServiceName; }; -OUString ChartTest::getFileExtension( const char* pName ) + +OUString ChartTest::getFileExtension( const OUString& aFileName ) { - OUString fileName = OUString::createFromAscii(pName); - sal_Int32 dotLocation = fileName.lastIndexOf(L'.'); - return fileName.copy(dotLocation); + sal_Int32 nDotLocation = aFileName.lastIndexOf('.'); + CPPUNIT_ASSERT(nDotLocation != -1); + return aFileName.copy(nDotLocation); } -void ChartTest::load( const char* pDir, const char* pName ) + +void ChartTest::load( const OUString& aDir, const OUString& aName ) { - OUString extension = getFileExtension(pName); - if(extension.equals("ods")) + OUString extension = getFileExtension(aName); + if(extension == "ods") { - mServiceName = "com.sun.star.sheet.SpreadsheetDocument"; + maServiceName = "com.sun.star.sheet.SpreadsheetDocument"; } - else if(extension.equals("docx")) + else if(extension == "docx") { - mServiceName = "com.sun.star.text.TextDocument"; - + maServiceName = "com.sun.star.text.TextDocument"; } - mxComponent = loadFromDesktop(getURLFromSrc(pDir) + OUString::createFromAscii(pName), mServiceName); + + mxComponent = loadFromDesktop(getURLFromSrc(aDir) + aName, maServiceName); CPPUNIT_ASSERT(mxComponent.is()); } @@ -103,7 +98,7 @@ utl::TempFile ChartTest::reload(const OUString& rFilterName) aTempFile.EnableKillingFile(); xStorable->storeToURL(aTempFile.GetURL(), aArgs); mxComponent->dispose(); - mxComponent = loadFromDesktop(aTempFile.GetURL(), mServiceName); + mxComponent = loadFromDesktop(aTempFile.GetURL(), maServiceName); std::cout << aTempFile.GetURL(); CPPUNIT_ASSERT(mxComponent.is()); return aTempFile; |