CppunitTest_svx_core: inherit from UnoApiTest

Change-Id: I4e7cdd1507232d48eba7c4afc599adf8da7a3df7
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/142094
Tested-by: Jenkins
Reviewed-by: Xisco Fauli <xiscofauli@libreoffice.org>
This commit is contained in:
Xisco Fauli 2022-11-01 10:09:23 +01:00
parent bc770e44c1
commit cfc8a8f5d8
2 changed files with 11 additions and 31 deletions

View file

@ -24,6 +24,7 @@ $(eval $(call gb_CppunitTest_use_libraries,svx_core, \
cppu \ cppu \
cppuhelper \ cppuhelper \
sal \ sal \
subsequenttest \
svx \ svx \
svxcore \ svxcore \
test \ test \

View file

@ -7,8 +7,7 @@
* file, You can obtain one at http://mozilla.org/MPL/2.0/. * file, You can obtain one at http://mozilla.org/MPL/2.0/.
*/ */
#include <test/bootstrapfixture.hxx> #include <test/unoapi_test.hxx>
#include <unotest/macros_test.hxx>
#include <com/sun/star/embed/XStorage.hpp> #include <com/sun/star/embed/XStorage.hpp>
#include <com/sun/star/frame/Desktop.hpp> #include <com/sun/star/frame/Desktop.hpp>
#include <com/sun/star/drawing/XDrawPagesSupplier.hpp> #include <com/sun/star/drawing/XDrawPagesSupplier.hpp>
@ -25,47 +24,27 @@ using namespace ::com::sun::star;
namespace namespace
{ {
/// Tests for svx/source/core/ code. /// Tests for svx/source/core/ code.
class Test : public test::BootstrapFixture, public unotest::MacrosTest class Test : public UnoApiTest
{ {
private:
uno::Reference<lang::XComponent> mxComponent;
public: public:
void setUp() override; Test()
void tearDown() override; : UnoApiTest("svx/qa/unit/data/")
uno::Reference<lang::XComponent>& getComponent() { return mxComponent; } {
}
}; };
void Test::setUp()
{
test::BootstrapFixture::setUp();
mxDesktop.set(frame::Desktop::create(mxComponentContext));
}
void Test::tearDown()
{
if (mxComponent.is())
mxComponent->dispose();
test::BootstrapFixture::tearDown();
}
constexpr OUStringLiteral DATA_DIRECTORY = u"/svx/qa/unit/data/";
CPPUNIT_TEST_FIXTURE(Test, testChartExportToPdf) CPPUNIT_TEST_FIXTURE(Test, testChartExportToPdf)
{ {
// Given a Calc document with a chart in it: // Given a Calc document with a chart in it:
OUString aURL = m_directories.getURLFromSrc(DATA_DIRECTORY) + "chart.ods"; loadFromURL(u"chart.ods");
getComponent() = loadFromDesktop(aURL); uno::Reference<drawing::XDrawPagesSupplier> xDrawPagesSupplier(mxComponent, uno::UNO_QUERY);
uno::Reference<drawing::XDrawPagesSupplier> xDrawPagesSupplier(getComponent(), uno::UNO_QUERY);
uno::Reference<drawing::XDrawPage> xDrawPage(xDrawPagesSupplier->getDrawPages()->getByIndex(0), uno::Reference<drawing::XDrawPage> xDrawPage(xDrawPagesSupplier->getDrawPages()->getByIndex(0),
uno::UNO_QUERY); uno::UNO_QUERY);
uno::Reference<drawing::XShape> xShape(xDrawPage->getByIndex(0), uno::UNO_QUERY); uno::Reference<drawing::XShape> xShape(xDrawPage->getByIndex(0), uno::UNO_QUERY);
// When exporting that chart to PDF: // When exporting that chart to PDF:
utl::TempFileNamed aTempFile; utl::TempFileNamed aTempFile;
GraphicHelper::SaveShapeAsGraphicToPath(getComponent(), xShape, "application/pdf", GraphicHelper::SaveShapeAsGraphicToPath(mxComponent, xShape, "application/pdf",
aTempFile.GetURL()); aTempFile.GetURL());
// Then make sure we get a valid, non-empty PDF: // Then make sure we get a valid, non-empty PDF:
@ -85,7 +64,7 @@ CPPUNIT_TEST_FIXTURE(Test, testChartExportToPdf)
CPPUNIT_TEST_FIXTURE(Test, testGraphicObjectResolver) CPPUNIT_TEST_FIXTURE(Test, testGraphicObjectResolver)
{ {
OUString aURL = m_directories.getURLFromSrc(DATA_DIRECTORY) + "GraphicObjectResolverTest.zip"; OUString aURL = createFileURL(u"GraphicObjectResolverTest.zip");
uno::Reference<embed::XStorage> xStorage uno::Reference<embed::XStorage> xStorage
= comphelper::OStorageHelper::GetStorageOfFormatFromURL(ZIP_STORAGE_FORMAT_STRING, aURL, = comphelper::OStorageHelper::GetStorageOfFormatFromURL(ZIP_STORAGE_FORMAT_STRING, aURL,
embed::ElementModes::READWRITE); embed::ElementModes::READWRITE);