diff options
author | Tomaž Vajngerl <tomaz.vajngerl@collabora.co.uk> | 2022-03-10 14:08:35 +0900 |
---|---|---|
committer | Tomaž Vajngerl <quikee@gmail.com> | 2022-04-03 04:52:22 +0200 |
commit | b1349537f936dc1053e623b333c9c8f57345b8ff (patch) | |
tree | e22886330b44972e98b90b3480b14a4588ebe851 | |
parent | 52ef78f4923283e6e52d575bec81985b031cb30b (diff) |
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 <quikee@gmail.com>
-rw-r--r-- | sc/CppunitTest_sc_sparkline_test.mk | 1 | ||||
-rw-r--r-- | sc/qa/unit/SparklineTest.cxx | 66 |
2 files changed, 67 insertions, 0 deletions
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: */ |