[Libreoffice-commits] core.git: include/test qadevOOo/Jar_OOoRunner.mk qadevOOo/objdsc qadevOOo/tests sc/CppunitTest_sc_shapeobj.mk sc/Module_sc.mk sc/qa test/Library_subsequenttest.mk test/source
Jens Carl
j.carl43 at gmx.de
Sun Mar 4 17:59:44 UTC 2018
include/test/sheet/shape.hxx | 35 +++
qadevOOo/Jar_OOoRunner.mk | 1
qadevOOo/objdsc/sc/com.sun.star.comp.office.ScShapeObj.csv | 3
qadevOOo/tests/java/ifc/sheet/_Shape.java | 53 ------
sc/CppunitTest_sc_shapeobj.mk | 105 +++++++++++
sc/Module_sc.mk | 1
sc/qa/extras/scshapeobj.cxx | 114 +++++++++++++
test/Library_subsequenttest.mk | 1
test/source/sheet/shape.cxx | 95 ++++++++++
9 files changed, 351 insertions(+), 57 deletions(-)
New commits:
commit 7b7e0ff7b78f2e745712c551e5efe7457987f136
Author: Jens Carl <j.carl43 at gmx.de>
Date: Sun Mar 4 08:13:28 2018 +0000
tdf#45904: Move _Shape Java tests to C++
Change-Id: If0bfa9fb465f37e0ccce5b2fa4e909baaac1df50
Reviewed-on: https://gerrit.libreoffice.org/50722
Tested-by: Jenkins <ci at libreoffice.org>
Reviewed-by: Jens Carl <j.carl43 at gmx.de>
diff --git a/include/test/sheet/shape.hxx b/include/test/sheet/shape.hxx
new file mode 100644
index 000000000000..3d10fc31eb4f
--- /dev/null
+++ b/include/test/sheet/shape.hxx
@@ -0,0 +1,35 @@
+/* -*- 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/.
+ */
+
+#ifndef INCLUDED_TEST_SHEET_SHAPE_HXX
+#define INCLUDED_TEST_SHEET_SHAPE_HXX
+
+#include <com/sun/star/uno/XInterface.hpp>
+#include <com/sun/star/uno/Reference.hxx>
+
+#include <test/testdllapi.hxx>
+
+namespace apitest
+{
+class OOO_DLLPUBLIC_TEST Shape
+{
+public:
+ virtual css::uno::Reference<css::uno::XInterface> init() = 0;
+ virtual css::uno::Reference<css::uno::XInterface> getXSheetDocument() = 0;
+
+ void testShapeProperties();
+
+protected:
+ ~Shape() {}
+};
+}
+
+#endif // INCLUDED_TEST_SHEET_SHAPE_HXX
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab cinoptions=b1,g0,N-s cinkeys+=0=break: */
diff --git a/qadevOOo/Jar_OOoRunner.mk b/qadevOOo/Jar_OOoRunner.mk
index fa6d33e0fade..d57a9e7543fb 100644
--- a/qadevOOo/Jar_OOoRunner.mk
+++ b/qadevOOo/Jar_OOoRunner.mk
@@ -564,7 +564,6 @@ $(eval $(call gb_Jar_add_sourcefiles,OOoRunner,\
qadevOOo/tests/java/ifc/sdb/_XSingleSelectQueryComposer \
qadevOOo/tests/java/ifc/sdb/_XSQLErrorBroadcaster \
qadevOOo/tests/java/ifc/sheet/_FunctionDescription \
- qadevOOo/tests/java/ifc/sheet/_Shape \
qadevOOo/tests/java/ifc/sheet/_SheetLink \
qadevOOo/tests/java/ifc/sheet/_SheetSortDescriptor \
qadevOOo/tests/java/ifc/sheet/_Spreadsheet \
diff --git a/qadevOOo/objdsc/sc/com.sun.star.comp.office.ScShapeObj.csv b/qadevOOo/objdsc/sc/com.sun.star.comp.office.ScShapeObj.csv
index 607ebb7eaa8c..e7385e4ec6f7 100644
--- a/qadevOOo/objdsc/sc/com.sun.star.comp.office.ScShapeObj.csv
+++ b/qadevOOo/objdsc/sc/com.sun.star.comp.office.ScShapeObj.csv
@@ -14,9 +14,6 @@
"ScShapeObj";"com::sun::star::drawing::Shape";"InteropGrabBag#optional"
"ScShapeObj";"com::sun::star::drawing::XShapeDescriptor";"getShapeType()"
"ScShapeObj";"com::sun::star::drawing::XGluePointsSupplier#optional";"getGluePoints()"
-"ScShapeObj";"com::sun::star::sheet::Shape";"Anchor"
-"ScShapeObj";"com::sun::star::sheet::Shape";"HoriOrientPosition"
-"ScShapeObj";"com::sun::star::sheet::Shape";"VertOrientPosition"
"ScShapeObj";"com::sun::star::beans::XPropertySet";"getPropertySetInfo()"
"ScShapeObj";"com::sun::star::beans::XPropertySet";"setPropertyValue()"
"ScShapeObj";"com::sun::star::beans::XPropertySet";"getPropertyValue()"
diff --git a/qadevOOo/tests/java/ifc/sheet/_Shape.java b/qadevOOo/tests/java/ifc/sheet/_Shape.java
deleted file mode 100644
index c5def63c4379..000000000000
--- a/qadevOOo/tests/java/ifc/sheet/_Shape.java
+++ /dev/null
@@ -1,53 +0,0 @@
-/*
- * 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/.
- *
- * This file incorporates work covered by the following license notice:
- *
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed
- * with this work for additional information regarding copyright
- * ownership. The ASF licenses this file to you under the Apache
- * License, Version 2.0 (the "License"); you may not use this file
- * except in compliance with the License. You may obtain a copy of
- * the License at http://www.apache.org/licenses/LICENSE-2.0 .
- */
-package ifc.sheet;
-
-import com.sun.star.sheet.XSpreadsheet;
-import com.sun.star.sheet.XSpreadsheetDocument;
-import com.sun.star.table.XCell;
-import com.sun.star.uno.UnoRuntime;
-
-import lib.MultiPropertyTest;
-
-
-public class _Shape extends MultiPropertyTest {
- public void _Anchor() {
- XSpreadsheetDocument xSheetDoc = UnoRuntime.queryInterface(
- XSpreadsheetDocument.class,
- tEnv.getObjRelation(
- "DOCUMENT"));
- String[] sheetNames = xSheetDoc.getSheets().getElementNames();
- XSpreadsheet xSheet = null;
- XCell xCell = null;
-
- try {
- xSheet = UnoRuntime.queryInterface(
- XSpreadsheet.class,
- xSheetDoc.getSheets().getByName(sheetNames[0]));
- xCell = xSheet.getCellByPosition(0, 0);
- } catch (com.sun.star.container.NoSuchElementException e) {
- e.printStackTrace();
- } catch (com.sun.star.lang.IndexOutOfBoundsException e) {
- e.printStackTrace();
- } catch (com.sun.star.lang.WrappedTargetException e) {
- e.printStackTrace();
- }
-
- testProperty("Anchor", xSheet, xCell);
- }
-}
\ No newline at end of file
diff --git a/sc/CppunitTest_sc_shapeobj.mk b/sc/CppunitTest_sc_shapeobj.mk
new file mode 100644
index 000000000000..a5939ac3814b
--- /dev/null
+++ b/sc/CppunitTest_sc_shapeobj.mk
@@ -0,0 +1,105 @@
+# -*- 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_shapeobj))
+
+$(eval $(call gb_CppunitTest_use_external,sc_shapeobj,boost_headers))
+
+$(eval $(call gb_CppunitTest_add_exception_objects,sc_shapeobj, \
+ sc/qa/extras/scshapeobj \
+))
+
+$(eval $(call gb_CppunitTest_use_libraries,sc_shapeobj, \
+ basegfx \
+ comphelper \
+ cppu \
+ cppuhelper \
+ drawinglayer \
+ editeng \
+ for \
+ forui \
+ i18nlangtag \
+ msfilter \
+ oox \
+ sal \
+ salhelper \
+ sax \
+ sb \
+ sc \
+ sfx \
+ sot \
+ subsequenttest \
+ svl \
+ svt \
+ svx \
+ svxcore \
+ test \
+ tk \
+ tl \
+ ucbhelper \
+ unotest \
+ utl \
+ vbahelper \
+ vcl \
+ xo \
+))
+
+$(eval $(call gb_CppunitTest_set_include,sc_shapeobj,\
+ -I$(SRCDIR)/sc/source/ui/inc \
+ -I$(SRCDIR)/sc/inc \
+ $$(INCLUDE) \
+))
+
+$(eval $(call gb_CppunitTest_use_sdk_api,sc_shapeobj))
+
+$(eval $(call gb_CppunitTest_use_ure,sc_shapeobj))
+$(eval $(call gb_CppunitTest_use_vcl,sc_shapeobj))
+
+$(eval $(call gb_CppunitTest_use_components,sc_shapeobj,\
+ basic/util/sb \
+ comphelper/util/comphelp \
+ configmgr/source/configmgr \
+ dbaccess/util/dba \
+ filter/source/config/cache/filterconfig1 \
+ filter/source/storagefilterdetect/storagefd \
+ forms/util/frm \
+ framework/util/fwk \
+ i18npool/util/i18npool \
+ linguistic/source/lng \
+ oox/util/oox \
+ package/source/xstor/xstor \
+ package/util/package2 \
+ sax/source/expatwrap/expwrap \
+ scripting/source/basprov/basprov \
+ scripting/util/scriptframe \
+ sc/util/sc \
+ sc/util/scd \
+ sc/util/scfilt \
+ $(call gb_Helper_optional,SCRIPTING, \
+ sc/util/vbaobj) \
+ sfx2/util/sfx \
+ sot/util/sot \
+ svl/source/fsstor/fsstorage \
+ toolkit/util/tk \
+ ucb/source/core/ucb1 \
+ ucb/source/ucp/file/ucpfile1 \
+ ucb/source/ucp/tdoc/ucptdoc1 \
+ unotools/util/utl \
+ unoxml/source/rdf/unordf \
+ unoxml/source/service/unoxml \
+ uui/util/uui \
+ xmloff/util/xo \
+ svtools/util/svt \
+))
+
+$(eval $(call gb_CppunitTest_use_configuration,sc_shapeobj))
+
+# vim: set noet sw=4 ts=4:
diff --git a/sc/Module_sc.mk b/sc/Module_sc.mk
index ca37c6413780..482b77e4e93e 100644
--- a/sc/Module_sc.mk
+++ b/sc/Module_sc.mk
@@ -152,6 +152,7 @@ $(eval $(call gb_Module_add_subsequentcheck_targets,sc,\
CppunitTest_sc_importdescriptorbaseobj \
CppunitTest_sc_documentconfigurationobj \
CppunitTest_sc_spreadsheetsettingsobj \
+ CppunitTest_sc_shapeobj \
))
$(eval $(call gb_Module_add_perfcheck_targets,sc,\
diff --git a/sc/qa/extras/scshapeobj.cxx b/sc/qa/extras/scshapeobj.cxx
new file mode 100644
index 000000000000..1e2fab13ac86
--- /dev/null
+++ b/sc/qa/extras/scshapeobj.cxx
@@ -0,0 +1,114 @@
+/* -*- 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/sheet/shape.hxx>
+
+#include <com/sun/star/awt/Point.hpp>
+#include <com/sun/star/awt/Size.hpp>
+#include <com/sun/star/drawing/XDrawPagesSupplier.hpp>
+#include <com/sun/star/drawing/XDrawPage.hpp>
+#include <com/sun/star/drawing/XDrawPages.hpp>
+#include <com/sun/star/drawing/XShape.hpp>
+#include <com/sun/star/drawing/XShapes.hpp>
+#include <com/sun/star/drawing/XShape.hpp>
+#include <com/sun/star/lang/XComponent.hpp>
+#include <com/sun/star/lang/XMultiServiceFactory.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;
+using namespace css::uno;
+using namespace com::sun::star;
+
+namespace sc_apitest
+{
+class ScShapeObj : public CalcUnoApiTest, public apitest::Shape
+{
+public:
+ ScShapeObj();
+
+ virtual uno::Reference<uno::XInterface> init() override;
+ virtual uno::Reference<uno::XInterface> getXSheetDocument() override;
+ virtual void setUp() override;
+ virtual void tearDown() override;
+
+ CPPUNIT_TEST_SUITE(ScShapeObj);
+
+ // Shape
+ CPPUNIT_TEST(testShapeProperties);
+
+ CPPUNIT_TEST_SUITE_END();
+
+private:
+ uno::Reference<lang::XComponent> mxComponent;
+};
+
+ScShapeObj::ScShapeObj()
+ : CalcUnoApiTest("/sc/qa/extras/testdocuments")
+{
+}
+
+uno::Reference<uno::XInterface> ScShapeObj::init()
+{
+ uno::Reference<sheet::XSpreadsheetDocument> xDoc(mxComponent, UNO_QUERY_THROW);
+ CPPUNIT_ASSERT_MESSAGE("no calc document", xDoc.is());
+
+ uno::Reference<lang::XMultiServiceFactory> xMSF(xDoc, UNO_QUERY_THROW);
+ uno::Reference<drawing::XShape> xShape(
+ xMSF->createInstance("com.sun.star.drawing.RectangleShape"), UNO_QUERY_THROW);
+ xShape->setPosition(awt::Point(5000, 3500));
+ xShape->setSize(awt::Size(7500, 5000));
+
+ uno::Reference<drawing::XDrawPagesSupplier> xDPS(xDoc, UNO_QUERY_THROW);
+ uno::Reference<drawing::XDrawPages> xDrawPages = xDPS->getDrawPages();
+ uno::Reference<drawing::XDrawPage> xDrawPage(xDrawPages->getByIndex(0), UNO_QUERY_THROW);
+ uno::Reference<drawing::XShapes> xShapes(xDrawPage, UNO_QUERY_THROW);
+ xShapes->add(xShape);
+
+ for (auto i = 0; i < 10; i++)
+ {
+ xShape->setPosition(awt::Point(5000, 3500));
+ xShape->setSize(awt::Size(7510 + 10 * i, 5010 + 10 * i));
+ xShapes->add(xShape);
+ }
+
+ return xShape;
+}
+
+uno::Reference<uno::XInterface> ScShapeObj::getXSheetDocument()
+{
+ uno::Reference<sheet::XSpreadsheetDocument> xDoc(mxComponent, UNO_QUERY_THROW);
+ CPPUNIT_ASSERT_MESSAGE("no calc document", xDoc.is());
+
+ return xDoc;
+}
+
+void ScShapeObj::setUp()
+{
+ CalcUnoApiTest::setUp();
+ // create a calc document
+ mxComponent = loadFromDesktop("private:factory/scalc");
+}
+
+void ScShapeObj::tearDown()
+{
+ closeDocument(mxComponent);
+ CalcUnoApiTest::tearDown();
+}
+
+CPPUNIT_TEST_SUITE_REGISTRATION(ScShapeObj);
+
+} // end namespace
+
+CPPUNIT_PLUGIN_IMPLEMENT();
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab cinoptions=b1,g0,N-s cinkeys+=0=break: */
diff --git a/test/Library_subsequenttest.mk b/test/Library_subsequenttest.mk
index 9bf962c1731c..65c638525a07 100644
--- a/test/Library_subsequenttest.mk
+++ b/test/Library_subsequenttest.mk
@@ -53,6 +53,7 @@ $(eval $(call gb_Library_add_exception_objects,subsequenttest,\
test/source/sheet/scenario \
test/source/sheet/spreadsheetviewsettings \
test/source/sheet/subtotaldescriptor \
+ test/source/sheet/shape \
test/source/sheet/sheetcell \
test/source/sheet/sheetcellrange \
test/source/sheet/sheetcellranges \
diff --git a/test/source/sheet/shape.cxx b/test/source/sheet/shape.cxx
new file mode 100644
index 000000000000..ffa7d8ab112b
--- /dev/null
+++ b/test/source/sheet/shape.cxx
@@ -0,0 +1,95 @@
+/* -*- 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/sheet/shape.hxx>
+
+#include <com/sun/star/beans/XPropertySet.hpp>
+#include <com/sun/star/sheet/XSpreadsheetDocument.hpp>
+#include <com/sun/star/sheet/XSpreadsheet.hpp>
+#include <com/sun/star/sheet/XSpreadsheets.hpp>
+#include <com/sun/star/table/XCell.hpp>
+#include <com/sun/star/uno/Any.hxx>
+#include <com/sun/star/uno/Reference.hxx>
+#include <com/sun/star/uno/Sequence.hxx>
+
+#include <cppunit/extensions/HelperMacros.h>
+
+using namespace com::sun::star;
+using namespace com::sun::star::uno;
+
+namespace apitest
+{
+void Shape::testShapeProperties()
+{
+ uno::Reference<beans::XPropertySet> xShape(init(), UNO_QUERY_THROW);
+ OUString propName;
+ uno::Any aNewValue;
+
+ propName = "Anchor";
+ uno::Reference<sheet::XSpreadsheetDocument> xDoc(getXSheetDocument(), UNO_QUERY_THROW);
+ uno::Reference<sheet::XSpreadsheets> xSheets(xDoc->getSheets(), UNO_QUERY_THROW);
+ uno::Sequence<OUString> sheetNames = xSheets->getElementNames();
+ uno::Reference<sheet::XSpreadsheet> xSheet(xSheets->getByName(sheetNames[0]), UNO_QUERY_THROW);
+ uno::Reference<table::XCell> xCell(xSheet->getCellByPosition(0, 0), UNO_QUERY_THROW);
+
+ uno::Reference<sheet::XSpreadsheet> xSheetGet;
+ uno::Reference<table::XCell> xCellGet;
+
+ if (xShape->getPropertyValue(propName) >>= xSheetGet)
+ {
+ uno::Reference<sheet::XSpreadsheet> xSheetSet;
+ CPPUNIT_ASSERT_MESSAGE("Unable to get PropertyValue Anchor (XSpreadsheet)",
+ xShape->getPropertyValue(propName) >>= xSheetGet);
+
+ aNewValue <<= xSheet;
+ xShape->setPropertyValue(propName, aNewValue);
+ CPPUNIT_ASSERT(xShape->getPropertyValue(propName) >>= xSheetSet);
+ // TODO: Find a way to compare sheet::XSpreadsheet objects
+ //CPPUNIT_ASSERT_EQUAL_MESSAGE("Unable to set PropertyValue Anchor (XSpreadsheet)",
+ //xSheet.get(), xSheetSet.get());
+ }
+ else if (xShape->getPropertyValue(propName) >>= xCellGet)
+ {
+ uno::Reference<table::XCell> xCellSet;
+ CPPUNIT_ASSERT_MESSAGE("Unable to get PropertyValue Anchor (XCell)",
+ xShape->getPropertyValue(propName) >>= xCellGet);
+
+ aNewValue <<= xCell;
+ xShape->setPropertyValue(propName, aNewValue);
+ CPPUNIT_ASSERT(xShape->getPropertyValue(propName) >>= xCellSet);
+ CPPUNIT_ASSERT_EQUAL_MESSAGE("Unable to set PropertyValue Anchor (XCell)", xCell, xCellSet);
+ }
+
+ propName = "HoriOrientPosition";
+ sal_Int32 nHoriOrientPositionGet = 0;
+ sal_Int32 nHoriOrientPositionSet = 0;
+ CPPUNIT_ASSERT_MESSAGE("Unable to get PropertyValue HoriOrientPosition",
+ xShape->getPropertyValue(propName) >>= nHoriOrientPositionGet);
+
+ aNewValue <<= nHoriOrientPositionGet + 42;
+ xShape->setPropertyValue(propName, aNewValue);
+ CPPUNIT_ASSERT(xShape->getPropertyValue(propName) >>= nHoriOrientPositionSet);
+ CPPUNIT_ASSERT_EQUAL_MESSAGE("Unable to set PropertyValue HoriOrientPosition",
+ nHoriOrientPositionGet + 42, nHoriOrientPositionSet);
+
+ propName = "VertOrientPosition";
+ sal_Int32 nVertOrientPositionGet = 0;
+ sal_Int32 nVertOrientPositionSet = 0;
+ CPPUNIT_ASSERT_MESSAGE("Unable to get PropertyValue VertOrientPosition",
+ xShape->getPropertyValue(propName) >>= nVertOrientPositionGet);
+
+ aNewValue <<= nVertOrientPositionGet + 42;
+ xShape->setPropertyValue(propName, aNewValue);
+ CPPUNIT_ASSERT(xShape->getPropertyValue(propName) >>= nVertOrientPositionSet);
+ CPPUNIT_ASSERT_EQUAL_MESSAGE("Unable to set PropertyValue VertOrientPosition",
+ nVertOrientPositionGet + 42, nVertOrientPositionSet);
+}
+}
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab cinoptions=b1,g0,N-s cinkeys+=0=break: */
More information about the Libreoffice-commits
mailing list