sc/qa/extras/htmlexporttest.cxx | 8 ++ sd/qa/unit/HtmlExportTest.cxx | 4 - sd/qa/unit/sdmodeltestbase.hxx | 16 ++--- sw/qa/extras/htmlexport/htmlexport.cxx | 28 ++++------ sw/qa/extras/inc/swmodeltestbase.hxx | 78 ++++++++++++++-------------- sw/qa/extras/ooxmlexport/ooxmlexport.cxx | 10 +-- sw/qa/extras/ooxmlexport/ooxmlsdrexport.cxx | 24 ++++---- 7 files changed, 86 insertions(+), 82 deletions(-)
New commits: commit a95c7069c391563cc49eec6373216c589ba98348 Author: Tomaž Vajngerl <[email protected]> Date: Thu May 15 22:11:00 2014 +0200 sd html test: move local vars on top, clean-up Change-Id: Iac393561337825e316a974801a6061944b8fd72a diff --git a/sd/qa/unit/HtmlExportTest.cxx b/sd/qa/unit/HtmlExportTest.cxx index a85f4a5..388417f 100644 --- a/sd/qa/unit/HtmlExportTest.cxx +++ b/sd/qa/unit/HtmlExportTest.cxx @@ -18,7 +18,7 @@ using namespace rtl; class SdHTMLFilterTest : public SdModelTestBase, public XmlTestTools, public HtmlTestTools { private: - htmlDocPtr exportAndparseHtml(sd::DrawDocShellRef& xDocShRef) + htmlDocPtr exportAndParseHtml(sd::DrawDocShellRef& xDocShRef) { FileFormat* pFormat = getFormat(HTML); OUString aExt = OUString( "." ) + OUString::createFromAscii(pFormat->pName); @@ -33,7 +33,7 @@ public: void testHTMLExport() { sd::DrawDocShellRef xDocShRef = loadURL(getURLFromSrc("/sd/qa/unit/data/HtmlExportTestDocument.odp")); - htmlDocPtr htmlDoc = exportAndparseHtml(xDocShRef); + htmlDocPtr htmlDoc = exportAndParseHtml(xDocShRef); assertXPath(htmlDoc, "/html", 1); assertXPath(htmlDoc, "/html/body", 1); diff --git a/sd/qa/unit/sdmodeltestbase.hxx b/sd/qa/unit/sdmodeltestbase.hxx index bb82929..636bd0d 100644 --- a/sd/qa/unit/sdmodeltestbase.hxx +++ b/sd/qa/unit/sdmodeltestbase.hxx @@ -63,10 +63,12 @@ FileFormat aFileFormats[] = { /// Base class for filter tests loading or roundtriping a document, and asserting the document model. class SdModelTestBase : public test::BootstrapFixture, public unotest::MacrosTest { +private: + uno::Reference<uno::XInterface> mxDrawComponent; + public: SdModelTestBase() - { - } + {} virtual void setUp() SAL_OVERRIDE { @@ -74,13 +76,13 @@ public: // 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("com.sun.star.comp.Draw.PresentationDocument"); - CPPUNIT_ASSERT_MESSAGE("no impress component!", m_xDrawComponent.is()); + mxDrawComponent = getMultiServiceFactory()->createInstance("com.sun.star.comp.Draw.PresentationDocument"); + CPPUNIT_ASSERT_MESSAGE("no impress component!", mxDrawComponent.is()); } virtual void tearDown() SAL_OVERRIDE { - uno::Reference< lang::XComponent >( m_xDrawComponent, uno::UNO_QUERY_THROW )->dispose(); + uno::Reference<lang::XComponent>(mxDrawComponent, uno::UNO_QUERY_THROW)->dispose(); test::BootstrapFixture::tearDown(); } @@ -230,10 +232,6 @@ protected: } xDocShRef->DoClose(); } - - -private: - uno::Reference<uno::XInterface> m_xDrawComponent; }; #endif commit 2dd1f71b24da9a10f5cdbfd4a920d5f49963c861 Author: Tomaž Vajngerl <[email protected]> Date: Thu May 15 22:05:15 2014 +0200 sc html test: dispose xComponent in teardown Change-Id: If33ad8bcca2c224b6bf68a1bdaa015326c17aef8 diff --git a/sc/qa/extras/htmlexporttest.cxx b/sc/qa/extras/htmlexporttest.cxx index e065251..a9c0000 100644 --- a/sc/qa/extras/htmlexporttest.cxx +++ b/sc/qa/extras/htmlexporttest.cxx @@ -65,6 +65,14 @@ public: mxDesktop.set(css::frame::Desktop::create(comphelper::getComponentContext(getMultiServiceFactory()))); } + virtual void tearDown() SAL_OVERRIDE + { + if (mxComponent.is()) + mxComponent->dispose(); + + test::BootstrapFixture::tearDown(); + } + void testHtmlSkipImage() { htmlDocPtr pDoc; commit 0261d4999ad930bffa26eab089af70b805f24857 Author: Tomaž Vajngerl <[email protected]> Date: Thu May 15 22:03:54 2014 +0200 sw test: HtmlExportTest - assert pDoc exists, rename class Change-Id: I5e17b8636236c2a0f78df80c36d82a3ba16a1c5f diff --git a/sw/qa/extras/htmlexport/htmlexport.cxx b/sw/qa/extras/htmlexport/htmlexport.cxx index 8d73286..961b050 100644 --- a/sw/qa/extras/htmlexport/htmlexport.cxx +++ b/sw/qa/extras/htmlexport/htmlexport.cxx @@ -22,13 +22,13 @@ using namespace rtl; -class Test : public SwModelTestBase, public HtmlTestTools +class HtmlExportTest : public SwModelTestBase, public HtmlTestTools { private: FieldUnit m_eUnit; public: - Test() : + HtmlExportTest() : SwModelTestBase("/sw/qa/extras/htmlexport/data/", "HTML (StarWriter)"), m_eUnit(FUNIT_NONE) {} @@ -70,7 +70,7 @@ private: } }; -#define DECLARE_HTMLEXPORT_ROUNDTRIP_TEST(TestName, filename) DECLARE_SW_ROUNDTRIP_TEST(TestName, filename, Test) +#define DECLARE_HTMLEXPORT_ROUNDTRIP_TEST(TestName, filename) DECLARE_SW_ROUNDTRIP_TEST(TestName, filename, HtmlExportTest) DECLARE_HTMLEXPORT_ROUNDTRIP_TEST(testFdo62336, "fdo62336.docx") { @@ -105,22 +105,20 @@ DECLARE_HTMLEXPORT_ROUNDTRIP_TEST(testCharacterBorder, "charborder.odt") DECLARE_HTMLEXPORT_TEST(testExportOfImages, "textAndImage.docx") { - htmlDocPtr pDoc = parseHtml(m_aTempFile); - if (pDoc) - { - assertXPath(pDoc, "/html/body", 1); - assertXPath(pDoc, "/html/body/p/img", 1); - } + htmlDocPtr pDoc = parseHtml(maTempFile); + CPPUNIT_ASSERT(pDoc); + + assertXPath(pDoc, "/html/body", 1); + assertXPath(pDoc, "/html/body/p/img", 1); } DECLARE_HTMLEXPORT_TEST(testExportOfImagesWithSkipImageEnabled, "textAndImage.docx") { - htmlDocPtr pDoc = parseHtml(m_aTempFile); - if (pDoc) - { - assertXPath(pDoc, "/html/body", 1); - assertXPath(pDoc, "/html/body/p/img", 0); - } + htmlDocPtr pDoc = parseHtml(maTempFile); + CPPUNIT_ASSERT(pDoc); + + assertXPath(pDoc, "/html/body", 1); + assertXPath(pDoc, "/html/body/p/img", 0); } #endif commit 543a88d7c291d53884aab74f5f379e8bfc4b73c4 Author: Tomaž Vajngerl <[email protected]> Date: Thu May 15 22:02:56 2014 +0200 sw test: unify names of local variables and move to them to top Change-Id: Iaba274f73edf4ff49d06f5dd15ab8ab2ddd043f7 diff --git a/sw/qa/extras/inc/swmodeltestbase.hxx b/sw/qa/extras/inc/swmodeltestbase.hxx index a5134db..2c688fd 100644 --- a/sw/qa/extras/inc/swmodeltestbase.hxx +++ b/sw/qa/extras/inc/swmodeltestbase.hxx @@ -112,7 +112,26 @@ using namespace css; /// Base class for filter tests loading or roundtriping a document, then asserting the document model. class SwModelTestBase : public test::BootstrapFixture, public unotest::MacrosTest, public XmlTestTools { +private: OUString maFilterOptions; + +protected: + uno::Reference<lang::XComponent> mxComponent; + xmlBufferPtr mpXmlBuffer; + const char* mpTestDocumentPath; + const char* mpFilter; + + template<typename T> + struct MethodEntry + { + const char* pName; + void (T::*pMethod)(); + }; + + sal_uInt32 mnStartTime; + utl::TempFile maTempFile; + bool mbExported; ///< Does maTempFile already contain something useful? + protected: virtual OUString getTestName() { return OUString(); } @@ -127,12 +146,14 @@ public: } SwModelTestBase(const char* pTestDocumentPath = "", const char* pFilter = "") - : mpXmlBuffer(0), - mpTestDocumentPath(pTestDocumentPath), - mpFilter(pFilter), - m_nStartTime(0), - m_bExported(false) - { m_aTempFile.EnableKillingFile(); } + : mpXmlBuffer(0) + , mpTestDocumentPath(pTestDocumentPath) + , mpFilter(pFilter) + , mnStartTime(0) + , mbExported(false) + { + maTempFile.EnableKillingFile(); + } virtual ~SwModelTestBase() {} @@ -141,7 +162,7 @@ public: { test::BootstrapFixture::setUp(); - mxDesktop.set( com::sun::star::frame::Desktop::create(comphelper::getComponentContext(getMultiServiceFactory())) ); + mxDesktop.set(css::frame::Desktop::create(comphelper::getComponentContext(getMultiServiceFactory()))); } virtual void tearDown() SAL_OVERRIDE @@ -198,7 +219,7 @@ protected: header(); preTest(filename); load(mpTestDocumentPath, filename); - save(OUString::createFromAscii(mpFilter), m_aTempFile); + save(OUString::createFromAscii(mpFilter), maTempFile); postTest(filename); verify(); finish(); @@ -481,7 +502,7 @@ protected: mxComponent->dispose(); // Output name early, so in the case of a hang, the name of the hanging input file is visible. std::cout << pName << ","; - m_nStartTime = osl_getGlobalTimer(); + mnStartTime = osl_getGlobalTimer(); mxComponent = loadFromDesktop(getURLFromSrc(pDir) + OUString::createFromAscii(pName), "com.sun.star.text.TextDocument"); if (mustCalcLayoutOf(pName)) calcLayout(); @@ -495,20 +516,20 @@ protected: aMediaDescriptor["FilterName"] <<= aFilterName; if (!maFilterOptions.isEmpty()) aMediaDescriptor["FilterOptions"] <<= maFilterOptions; - xStorable->storeToURL(m_aTempFile.GetURL(), aMediaDescriptor.getAsConstPropertyValueList()); + xStorable->storeToURL(maTempFile.GetURL(), aMediaDescriptor.getAsConstPropertyValueList()); uno::Reference<lang::XComponent> xComponent(xStorable, uno::UNO_QUERY); xComponent->dispose(); - m_bExported = true; - mxComponent = loadFromDesktop(m_aTempFile.GetURL(), "com.sun.star.text.TextDocument"); + mbExported = true; + mxComponent = loadFromDesktop(maTempFile.GetURL(), "com.sun.star.text.TextDocument"); if(aFilterName == "Office Open XML Text") { // too many validation errors right now - // validate(m_aTempFile.GetFileName(), test::OOXML); + // validate(maTempFile.GetFileName(), test::OOXML); } else if(aFilterName == "writer8") { // still a few validation errors - // validate(m_aTempFile.GetFileName(), test::ODF); + // validate(maTempFile.GetFileName(), test::ODF); } if (mpXmlBuffer) @@ -535,7 +556,7 @@ protected: void finish() { sal_uInt32 nEndTime = osl_getGlobalTimer(); - std::cout << (nEndTime - m_nStartTime) << std::endl; + std::cout << (nEndTime - mnStartTime) << std::endl; if (mpXmlBuffer) { xmlBufferFree(mpXmlBuffer); @@ -561,13 +582,12 @@ protected: */ xmlDocPtr parseExport(const OUString& rStreamName = OUString("word/document.xml")) { - if (!m_bExported) + if (!mbExported) return 0; // Read the XML stream we're interested in. - uno::Reference<packages::zip::XZipFileAccess2> xNameAccess = packages::zip::ZipFileAccess::createWithURL(comphelper::getComponentContext(m_xSFactory), m_aTempFile.GetURL()); + uno::Reference<packages::zip::XZipFileAccess2> xNameAccess = packages::zip::ZipFileAccess::createWithURL(comphelper::getComponentContext(m_xSFactory), maTempFile.GetURL()); uno::Reference<io::XInputStream> xInputStream(xNameAccess->getByName(rStreamName), uno::UNO_QUERY); - boost::shared_ptr<SvStream> pStream(utl::UcbStreamHelper::CreateStream(xInputStream, true)); return parseXmlStream(pStream.get()); @@ -594,21 +614,6 @@ protected: xmlXPathRegisterNs(pXmlXpathCtx, BAD_CAST("lc"), BAD_CAST("http://schemas.openxmlformats.org/drawingml/2006/lockedCanvas")); xmlXPathRegisterNs(pXmlXpathCtx, BAD_CAST("extended-properties"), BAD_CAST("http://schemas.openxmlformats.org/officeDocument/2006/extended-properties")); } - - uno::Reference<lang::XComponent> mxComponent; - xmlBufferPtr mpXmlBuffer; - const char* mpTestDocumentPath; - const char* mpFilter; - - template< typename T > - struct MethodEntry - { - const char* pName; - void (T::*pMethod)(); - }; - sal_uInt32 m_nStartTime; - utl::TempFile m_aTempFile; - bool m_bExported; ///< Does m_aTempFile already contain something useful? }; /** diff --git a/sw/qa/extras/ooxmlexport/ooxmlexport.cxx b/sw/qa/extras/ooxmlexport/ooxmlexport.cxx index 67bd0ca..cb89ac3 100644 --- a/sw/qa/extras/ooxmlexport/ooxmlexport.cxx +++ b/sw/qa/extras/ooxmlexport/ooxmlexport.cxx @@ -2062,7 +2062,7 @@ DECLARE_OOXMLEXPORT_TEST(testRelorientation, "relorientation.docx") CPPUNIT_ASSERT_EQUAL(OUString("com.sun.star.drawing.GroupShape"), xShapeDescriptor->getShapeType()); // Right after import we get a rounding error: 8662 vs 8664. - if (m_bExported) + if (mbExported) { uno::Reference<drawing::XShape> xYear(xGroup->getByIndex(1), uno::UNO_QUERY); // This was 2, due to incorrect handling of parent transformations inside DML groupshapes. @@ -2271,7 +2271,7 @@ DECLARE_OOXMLEXPORT_TEST(testTrackChangesParagraphProperties, "testTrackChangesP DECLARE_OOXMLEXPORT_TEST(testMsoSpt180, "mso-spt180.docx") { - if (!m_bExported) + if (!mbExported) return; uno::Reference<container::XIndexAccess> xGroup(getShape(1), uno::UNO_QUERY); @@ -2601,7 +2601,7 @@ DECLARE_OOXMLEXPORT_TEST(testEmbeddedXlsx, "embedded-xlsx.docx") assertXPath(pXmlDocument, "/w:document/w:body/w:p/w:r/w:object", 2); // finally check the embedded files are present in the zipped document - uno::Reference<packages::zip::XZipFileAccess2> xNameAccess = packages::zip::ZipFileAccess::createWithURL(comphelper::getComponentContext(m_xSFactory), m_aTempFile.GetURL()); + uno::Reference<packages::zip::XZipFileAccess2> xNameAccess = packages::zip::ZipFileAccess::createWithURL(comphelper::getComponentContext(m_xSFactory), maTempFile.GetURL()); uno::Sequence<OUString> names = xNameAccess->getElementNames(); int nSheetFiles = 0; int nImageFiles = 0; @@ -2758,7 +2758,7 @@ DECLARE_OOXMLEXPORT_TEST(testFdo74792, "fdo74792.docx") return; assertXPath(pXmlDoc,"/rels:Relationships/rels:Relationship", 4); uno::Reference<packages::zip::XZipFileAccess2> xNameAccess = packages::zip::ZipFileAccess::createWithURL( - comphelper::getComponentContext(m_xSFactory), m_aTempFile.GetURL()); + comphelper::getComponentContext(m_xSFactory), maTempFile.GetURL()); //check that images are also saved OUString sImageFile( "word/media/OOXDiagramDataRels1_0.jpeg" ); //added anchor id to form a uniqe name @@ -2785,7 +2785,7 @@ DECLARE_OOXMLEXPORT_TEST(testFdo77718, "fdo77718.docx") assertXPath(pXmlDataRels2,"/rels:Relationships/rels:Relationship", 4); uno::Reference<packages::zip::XZipFileAccess2> xNameAccess = packages::zip::ZipFileAccess::createWithURL( - comphelper::getComponentContext(m_xSFactory), m_aTempFile.GetURL()); + comphelper::getComponentContext(m_xSFactory), maTempFile.GetURL()); //check that images are also saved OUString sImageFile1( "word/media/OOXDiagramDataRels1_0.jpeg" ); //added anchor id to form a uniqe name diff --git a/sw/qa/extras/ooxmlexport/ooxmlsdrexport.cxx b/sw/qa/extras/ooxmlexport/ooxmlsdrexport.cxx index 98b44a5..2ea3562 100644 --- a/sw/qa/extras/ooxmlexport/ooxmlsdrexport.cxx +++ b/sw/qa/extras/ooxmlexport/ooxmlsdrexport.cxx @@ -80,10 +80,10 @@ DECLARE_OOXMLEXPORT_TEST(testDmlShapeRelsize, "dml-shape-relsize.docx") DECLARE_OOXMLEXPORT_TEST(testDmlPictureInTextframe, "dml-picture-in-textframe.docx") { - if (!m_bExported) + if (!mbExported) return; - uno::Reference<packages::zip::XZipFileAccess2> xNameAccess = packages::zip::ZipFileAccess::createWithURL(comphelper::getComponentContext(m_xSFactory), m_aTempFile.GetURL()); + uno::Reference<packages::zip::XZipFileAccess2> xNameAccess = packages::zip::ZipFileAccess::createWithURL(comphelper::getComponentContext(m_xSFactory), maTempFile.GetURL()); CPPUNIT_ASSERT_EQUAL(true, bool(xNameAccess->hasByName("word/media/image1.gif"))); // This was also true, image was written twice. CPPUNIT_ASSERT_EQUAL(false, bool(xNameAccess->hasByName("word/media/image2.gif"))); @@ -232,10 +232,10 @@ DECLARE_OOXMLEXPORT_TEST(testDMLShapeFillBitmapCrop, "dml-shape-fillbitmapcrop.d // 1st shape has some cropping text::GraphicCrop aGraphicCropStruct = getProperty<text::GraphicCrop>(getShape(1), "GraphicCrop"); - CPPUNIT_ASSERT_EQUAL( sal_Int32(m_bExported ? 454 : 455 ), aGraphicCropStruct.Left ); - CPPUNIT_ASSERT_EQUAL( sal_Int32(m_bExported ? 367 : 368 ), aGraphicCropStruct.Right ); - CPPUNIT_ASSERT_EQUAL( sal_Int32(m_bExported ? -454 : -455 ), aGraphicCropStruct.Top ); - CPPUNIT_ASSERT_EQUAL( sal_Int32(m_bExported ? -367 : -368 ), aGraphicCropStruct.Bottom ); + CPPUNIT_ASSERT_EQUAL( sal_Int32(mbExported ? 454 : 455 ), aGraphicCropStruct.Left ); + CPPUNIT_ASSERT_EQUAL( sal_Int32(mbExported ? 367 : 368 ), aGraphicCropStruct.Right ); + CPPUNIT_ASSERT_EQUAL( sal_Int32(mbExported ? -454 : -455 ), aGraphicCropStruct.Top ); + CPPUNIT_ASSERT_EQUAL( sal_Int32(mbExported ? -367 : -368 ), aGraphicCropStruct.Bottom ); // 2nd shape has no cropping aGraphicCropStruct = getProperty<text::GraphicCrop>(getShape(2), "GraphicCrop"); @@ -331,17 +331,17 @@ DECLARE_OOXMLEXPORT_TEST(testDMLGroupShapeChildPosition, "dml-groupshape-childpo uno::Reference<drawing::XShapes> xGroup(getShape(1), uno::UNO_QUERY); uno::Reference<drawing::XShape> xChildGroup(xGroup->getByIndex(1), uno::UNO_QUERY); - CPPUNIT_ASSERT_EQUAL(sal_Int32(m_bExported ? -2119 : -2121), xChildGroup->getPosition().X); - CPPUNIT_ASSERT_EQUAL(sal_Int32(m_bExported ? 11338 : 11335), xChildGroup->getPosition().Y); + CPPUNIT_ASSERT_EQUAL(sal_Int32(mbExported ? -2119 : -2121), xChildGroup->getPosition().X); + CPPUNIT_ASSERT_EQUAL(sal_Int32(mbExported ? 11338 : 11335), xChildGroup->getPosition().Y); xGroup.set(xChildGroup, uno::UNO_QUERY); xChildGroup.set(xGroup->getByIndex(0), uno::UNO_QUERY); - CPPUNIT_ASSERT_EQUAL(sal_Int32(m_bExported ? -1856 : -1858), xChildGroup->getPosition().X); - CPPUNIT_ASSERT_EQUAL(sal_Int32(m_bExported ? 11338 : 11335), xChildGroup->getPosition().Y); + CPPUNIT_ASSERT_EQUAL(sal_Int32(mbExported ? -1856 : -1858), xChildGroup->getPosition().X); + CPPUNIT_ASSERT_EQUAL(sal_Int32(mbExported ? 11338 : 11335), xChildGroup->getPosition().Y); xChildGroup.set(xGroup->getByIndex(1), uno::UNO_QUERY); - CPPUNIT_ASSERT_EQUAL(sal_Int32(m_bExported ? -2119 : -2121), xChildGroup->getPosition().X); - CPPUNIT_ASSERT_EQUAL(sal_Int32(m_bExported ? 14028 : 14025), xChildGroup->getPosition().Y); + CPPUNIT_ASSERT_EQUAL(sal_Int32(mbExported ? -2119 : -2121), xChildGroup->getPosition().X); + CPPUNIT_ASSERT_EQUAL(sal_Int32(mbExported ? 14028 : 14025), xChildGroup->getPosition().Y); } DECLARE_OOXMLEXPORT_TEST(testDMLGradientFillTheme, "dml-gradientfill-theme.docx") commit 0e5898f6a972e4bbe068c5565eb446db41170ba0 Author: Tomaž Vajngerl <[email protected]> Date: Thu May 15 21:44:17 2014 +0200 sw test: user parent's parseXmlStream method Change-Id: I6b50172b636cd8334b5cbfd3986631c1f17dd366 diff --git a/sw/qa/extras/inc/swmodeltestbase.hxx b/sw/qa/extras/inc/swmodeltestbase.hxx index 84f445d..a5134db 100644 --- a/sw/qa/extras/inc/swmodeltestbase.hxx +++ b/sw/qa/extras/inc/swmodeltestbase.hxx @@ -569,13 +569,8 @@ protected: uno::Reference<io::XInputStream> xInputStream(xNameAccess->getByName(rStreamName), uno::UNO_QUERY); boost::shared_ptr<SvStream> pStream(utl::UcbStreamHelper::CreateStream(xInputStream, true)); - sal_Size nSize = pStream->remainingSize(); - rtl::ByteSequence aBuffer(nSize); - pStream->Read(aBuffer.getArray(), nSize); - - // Parse the XML. - return xmlParseMemory(reinterpret_cast<const char*>(aBuffer.getArray()), aBuffer.getLength()); + return parseXmlStream(pStream.get()); } /**
_______________________________________________ Libreoffice-commits mailing list [email protected] http://lists.freedesktop.org/mailman/listinfo/libreoffice-commits
