CppunitTest_embeddedobj_msole: inherit from UnoApiXmlTest

Change-Id: I26e0a4db8484c8e91f3ebff9828d76270ddc5f6e
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/142256
Tested-by: Jenkins
Reviewed-by: Xisco Fauli <xiscofauli@libreoffice.org>
This commit is contained in:
Xisco Fauli 2022-11-03 23:08:22 +01:00
parent 1e007e8f17
commit f62e649652
2 changed files with 11 additions and 38 deletions

View file

@ -25,6 +25,7 @@ $(eval $(call gb_CppunitTest_use_libraries,embeddedobj_msole, \
cppu \
embobj \
sal \
subsequenttest \
test \
unotest \
utl \

View file

@ -7,14 +7,11 @@
* file, You can obtain one at http://mozilla.org/MPL/2.0/.
*/
#include <test/bootstrapfixture.hxx>
#include <unotest/macros_test.hxx>
#include <test/xmltesttools.hxx>
#include <test/unoapixml_test.hxx>
#include <com/sun/star/frame/Desktop.hpp>
#include <com/sun/star/embed/XStorage.hpp>
#include <com/sun/star/frame/XStorable.hpp>
#include <com/sun/star/packages/zip/ZipFileAccess.hpp>
#include <com/sun/star/util/XCloseable.hpp>
#include <comphelper/embeddedobjectcontainer.hxx>
@ -34,36 +31,16 @@ using namespace ::com::sun::star;
namespace
{
/// Covers embeddedobj/source/msole/ fixes.
class Test : public test::BootstrapFixture, public unotest::MacrosTest, public XmlTestTools
class Test : public UnoApiXmlTest
{
private:
uno::Reference<lang::XComponent> mxComponent;
public:
void setUp() override;
void tearDown() override;
uno::Reference<lang::XComponent>& getComponent() { return mxComponent; }
void registerNamespaces(xmlXPathContextPtr& pXmlXpathCtx) override;
};
}
void Test::setUp()
{
test::BootstrapFixture::setUp();
mxDesktop.set(frame::Desktop::create(mxComponentContext));
}
void Test::tearDown()
{
if (mxComponent)
Test()
: UnoApiXmlTest("/embeddedobj/qa/cppunit/data/")
{
uno::Reference<util::XCloseable> xCloseable(mxComponent, css::uno::UNO_QUERY_THROW);
xCloseable->close(false);
mxComponent.clear();
}
test::BootstrapFixture::tearDown();
void registerNamespaces(xmlXPathContextPtr& pXmlXpathCtx) override;
};
}
void Test::registerNamespaces(xmlXPathContextPtr& pXmlXpathCtx)
@ -109,17 +86,17 @@ CPPUNIT_TEST_FIXTURE(Test, testSaveOnThread)
}
DBG_TESTSOLARMUTEX();
OUString aURL = m_directories.getURLFromSrc(u"embeddedobj/qa/cppunit/data/reqif-ole2.xhtml");
OUString aURL = createFileURL(u"reqif-ole2.xhtml");
uno::Sequence<beans::PropertyValue> aLoadProperties = {
comphelper::makePropertyValue("FilterName", OUString("HTML (StarWriter)")),
comphelper::makePropertyValue("FilterOptions", OUString("xhtmlns=reqif-xhtml")),
};
getComponent().set(loadFromDesktop(aURL, "com.sun.star.text.TextDocument", aLoadProperties));
mxComponent = loadFromDesktop(aURL, "com.sun.star.text.TextDocument", aLoadProperties);
// When saving that document on a thread:
utl::TempFileNamed aTempFile;
aTempFile.EnableKillingFile();
OdtExportThread aThread(getComponent(), aTempFile.GetURL());
OdtExportThread aThread(mxComponent, aTempFile.GetURL());
aThread.create();
{
SolarMutexReleaser r;
@ -131,12 +108,7 @@ CPPUNIT_TEST_FIXTURE(Test, testSaveOnThread)
}
// Then make sure its visible area's width is correct.
uno::Reference<packages::zip::XZipFileAccess2> xNameAccess
= packages::zip::ZipFileAccess::createWithURL(mxComponentContext, aTempFile.GetURL());
uno::Reference<io::XInputStream> xInputStream(xNameAccess->getByName("content.xml"),
uno::UNO_QUERY);
std::unique_ptr<SvStream> pStream(utl::UcbStreamHelper::CreateStream(xInputStream, true));
xmlDocUniquePtr pXmlDoc = parseXmlStream(pStream.get());
xmlDocUniquePtr pXmlDoc = parseExport(aTempFile.GetURL(), "content.xml");
// 16 pixels, assuming 96 DPI.
// Without the accompanying fix in place, this test would have failed with:
// - Expected: 0.1665in