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 \
cppuhelper \
sal \
subsequenttest \
svx \
svxcore \
test \

View file

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