diff options
author | Jens Carl <j.carl43@gmx.de> | 2019-03-27 18:43:29 +0000 |
---|---|---|
committer | Jens Carl <j.carl43@gmx.de> | 2019-03-27 23:53:32 +0100 |
commit | ed6a71eafa61bade50219d2ff6233a42ab6d1c17 (patch) | |
tree | f148500352fd8fc1831b247fd6be4843d4d8481d /sc | |
parent | 0c44946a43d1a16f94327c996369e68f9f01f5d3 (diff) |
tdf#45904 Move XIndexAccess Java tests to C++
Move XIndexAccess Java tests to C++ for ScDrawPageObj.
Change-Id: I8b0c80b9213130870ce5445bcf52705df367cb0e
Reviewed-on: https://gerrit.libreoffice.org/69864
Tested-by: Jenkins
Reviewed-by: Jens Carl <j.carl43@gmx.de>
Diffstat (limited to 'sc')
-rw-r--r-- | sc/CppunitTest_sc_drawpageobj.mk | 43 | ||||
-rw-r--r-- | sc/Module_sc.mk | 1 | ||||
-rw-r--r-- | sc/qa/extras/scdrawpageobj.cxx | 98 |
3 files changed, 142 insertions, 0 deletions
diff --git a/sc/CppunitTest_sc_drawpageobj.mk b/sc/CppunitTest_sc_drawpageobj.mk new file mode 100644 index 000000000000..05bbaef9eb37 --- /dev/null +++ b/sc/CppunitTest_sc_drawpageobj.mk @@ -0,0 +1,43 @@ +# -*- Mode: makefile-gmake; tab-width: 4; indent-tabs-mode: t -*- +#************************************************************************* +# +# 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/. +# +#************************************************************************* + +$(eval $(call gb_CppunitTest_CppunitTest,sc_drawpageobj)) + +$(eval $(call gb_CppunitTest_use_external,sc_drawpageobj,boost_headers)) + +$(eval $(call gb_CppunitTest_add_exception_objects,sc_drawpageobj, \ + sc/qa/extras/scdrawpageobj \ +)) + +$(eval $(call gb_CppunitTest_use_libraries,sc_drawpageobj, \ + cppu \ + sal \ + subsequenttest \ + test \ + unotest \ +)) + +$(eval $(call gb_CppunitTest_set_include,sc_drawpageobj,\ + $$(INCLUDE) \ +)) + +$(eval $(call gb_CppunitTest_use_sdk_api,sc_drawpageobj)) + +$(eval $(call gb_CppunitTest_use_ure,sc_drawpageobj)) +$(eval $(call gb_CppunitTest_use_vcl,sc_drawpageobj)) + +$(eval $(call gb_CppunitTest_use_components,sc_drawpageobj,\ + $(sc_unoapi_common_components) \ +)) + +$(eval $(call gb_CppunitTest_use_configuration,sc_drawpageobj)) + +# vim: set noet sw=4 ts=4: diff --git a/sc/Module_sc.mk b/sc/Module_sc.mk index e5975b78352e..7e014431f6a5 100644 --- a/sc/Module_sc.mk +++ b/sc/Module_sc.mk @@ -140,6 +140,7 @@ $(eval $(call gb_Module_add_subsequentcheck_targets,sc,\ CppunitTest_sc_ddelinkobj \ CppunitTest_sc_ddelinksobj \ CppunitTest_sc_documentconfigurationobj \ + CppunitTest_sc_drawpageobj \ CppunitTest_sc_drawpagesobj \ CppunitTest_sc_editfieldobj_cell \ CppunitTest_sc_editfieldobj_header \ diff --git a/sc/qa/extras/scdrawpageobj.cxx b/sc/qa/extras/scdrawpageobj.cxx new file mode 100644 index 000000000000..77beb3629528 --- /dev/null +++ b/sc/qa/extras/scdrawpageobj.cxx @@ -0,0 +1,98 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4; fill-column: 100 -*- */ +/* + * 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 <test/calc_unoapi_test.hxx> +#include <test/helper/shape.hxx> +#include <test/container/xindexaccess.hxx> + +#include <com/sun/star/drawing/XDrawPage.hpp> +#include <com/sun/star/drawing/XDrawPages.hpp> +#include <com/sun/star/drawing/XDrawPagesSupplier.hpp> +#include <com/sun/star/drawing/XShape.hpp> +#include <com/sun/star/drawing/XShapes.hpp> +#include <com/sun/star/lang/XComponent.hpp> +#include <com/sun/star/sheet/XSpreadsheetDocument.hpp> +#include <com/sun/star/uno/XInterface.hpp> + +#include <com/sun/star/uno/Reference.hxx> + +using namespace css; + +namespace sc_apitest +{ +class ScDrawPageObj : public CalcUnoApiTest, public apitest::XIndexAccess +{ +public: + ScDrawPageObj(); + + virtual uno::Reference<uno::XInterface> init() override; + virtual void setUp() override; + virtual void tearDown() override; + + CPPUNIT_TEST_SUITE(ScDrawPageObj); + + // XIndexAccess + CPPUNIT_TEST(testGetByIndex); + CPPUNIT_TEST(testGetCount); + + CPPUNIT_TEST_SUITE_END(); + +private: + uno::Reference<lang::XComponent> m_xComponent; +}; + +ScDrawPageObj::ScDrawPageObj() + : CalcUnoApiTest("/sc/qa/extras/testdocuments") + , XIndexAccess(2) +{ +} + +uno::Reference<uno::XInterface> ScDrawPageObj::init() +{ + uno::Reference<sheet::XSpreadsheetDocument> xDoc(m_xComponent, uno::UNO_QUERY_THROW); + uno::Reference<drawing::XDrawPagesSupplier> xDPS(xDoc, uno::UNO_QUERY_THROW); + uno::Reference<drawing::XDrawPages> xDP(xDPS->getDrawPages(), uno::UNO_QUERY_THROW); + xDP->insertNewByIndex(0); + xDP->insertNewByIndex(1); + + uno::Reference<drawing::XDrawPage> xDrawPage(xDP->getByIndex(0), uno::UNO_QUERY_THROW); + uno::Reference<drawing::XShapes> xShapes(xDrawPage, uno::UNO_QUERY_THROW); + + uno::Reference<drawing::XShape> xRectangle0( + apitest::helper::shape::createRectangle(m_xComponent, 7500, 5000, 5000, 3500), + uno::UNO_QUERY_THROW); + xShapes->add(xRectangle0); + uno::Reference<drawing::XShape> xRectangle1( + apitest::helper::shape::createRectangle(m_xComponent, 5000, 5000, 5000, 5500), + uno::UNO_QUERY_THROW); + xShapes->add(xRectangle1); + + return xDrawPage; +} + +void ScDrawPageObj::setUp() +{ + CalcUnoApiTest::setUp(); + // create calc document + m_xComponent = loadFromDesktop("private:factory/scalc"); +} + +void ScDrawPageObj::tearDown() +{ + closeDocument(m_xComponent); + CalcUnoApiTest::tearDown(); +} + +CPPUNIT_TEST_SUITE_REGISTRATION(ScDrawPageObj); + +} // namespace sc_apitest + +CPPUNIT_PLUGIN_IMPLEMENT(); + +/* vim:set shiftwidth=4 softtabstop=4 expandtab cinoptions=b1,g0,N-s cinkeys+=0=break: */ |