sc/CppunitTest_sc_sparkline_test.mk | 1 sc/qa/unit/SparklineTest.cxx | 66 ++++++++++++++++++++++++++++++++++++ 2 files changed, 67 insertions(+)
New commits: commit b1349537f936dc1053e623b333c9c8f57345b8ff Author: Tomaž Vajngerl <[email protected]> AuthorDate: Thu Mar 10 14:08:35 2022 +0900 Commit: Tomaž Vajngerl <[email protected]> CommitDate: Sun Apr 3 04:52:22 2022 +0200 sc: simple unit test for adding a new Sparkline to a new document Change-Id: Ifb42167300dadd0e6c48bf178b7e8902985db3d1 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/132464 Tested-by: Jenkins Reviewed-by: Tomaž Vajngerl <[email protected]> diff --git a/sc/CppunitTest_sc_sparkline_test.mk b/sc/CppunitTest_sc_sparkline_test.mk index c961d466f857..7a46d5d21727 100644 --- a/sc/CppunitTest_sc_sparkline_test.mk +++ b/sc/CppunitTest_sc_sparkline_test.mk @@ -15,6 +15,7 @@ $(eval $(call gb_CppunitTest_use_common_precompiled_header,sc_sparkline_test)) $(eval $(call gb_CppunitTest_add_exception_objects,sc_sparkline_test, \ sc/qa/unit/SparklineImportExportTest \ + sc/qa/unit/SparklineTest \ )) $(eval $(call gb_CppunitTest_use_libraries,sc_sparkline_test, \ diff --git a/sc/qa/unit/SparklineTest.cxx b/sc/qa/unit/SparklineTest.cxx new file mode 100644 index 000000000000..d4a8d2d119a8 --- /dev/null +++ b/sc/qa/unit/SparklineTest.cxx @@ -0,0 +1,66 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/* + * This file is part of the LibreOffice project. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + */ + +#include "helper/qahelper.hxx" +#include <docsh.hxx> +#include <Sparkline.hxx> +#include <SparklineGroup.hxx> + +using namespace css; + +class SparklineTest : public ScBootstrapFixture +{ +private: + uno::Reference<uno::XInterface> m_xCalcComponent; + +public: + SparklineTest() + : ScBootstrapFixture("sc/qa/unit/data") + { + } + + virtual void setUp() override + { + test::BootstrapFixture::setUp(); + + // 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_xCalcComponent = getMultiServiceFactory()->createInstance( + "com.sun.star.comp.Calc.SpreadsheetDocument"); + CPPUNIT_ASSERT_MESSAGE("no calc component!", m_xCalcComponent.is()); + } + + virtual void tearDown() override + { + uno::Reference<lang::XComponent>(m_xCalcComponent, uno::UNO_QUERY_THROW)->dispose(); + test::BootstrapFixture::tearDown(); + } + + void testAddSparkline(); + + CPPUNIT_TEST_SUITE(SparklineTest); + CPPUNIT_TEST(testAddSparkline); + CPPUNIT_TEST_SUITE_END(); +}; + +void SparklineTest::testAddSparkline() +{ + ScDocShellRef xDocSh = loadEmptyDocument(); + CPPUNIT_ASSERT(xDocSh); + + ScDocument& rDocument = xDocSh->GetDocument(); + auto pSparklineGroup = std::make_shared<sc::SparklineGroup>(); + + sc::Sparkline* pSparkline = rDocument.CreateSparkline(ScAddress(0, 0, 0), pSparklineGroup); + CPPUNIT_ASSERT(pSparkline); +} + +CPPUNIT_TEST_SUITE_REGISTRATION(SparklineTest); + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
