summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJens Carl <j.carl43@gmx.de>2018-01-23 18:53:00 +0000
committerJens Carl <j.carl43@gmx.de>2018-01-25 18:18:18 +0100
commit35f6b6f6b9693e098b8407c3c35e74087d59ed8e (patch)
tree8bf4db4c9f0b3a23b3a6362dec3a9228bcbe5962
parent36686e2aae19651e3b2128f255537ed68d92fd06 (diff)
tdf#45904 Move _SheetCell Java tests to C++
Change-Id: I5d698303a901ee103fdd4ffdea34809142afa0e5 Reviewed-on: https://gerrit.libreoffice.org/48463 Tested-by: Jenkins <ci@libreoffice.org> Reviewed-by: Jens Carl <j.carl43@gmx.de>
-rw-r--r--include/test/cppunitasserthelper.hxx36
-rw-r--r--include/test/sheet/sheetcell.hxx34
-rw-r--r--qadevOOo/Jar_OOoRunner.mk1
-rw-r--r--qadevOOo/objdsc/sc/com.sun.star.comp.office.ScCellObj.csv8
-rw-r--r--qadevOOo/tests/java/ifc/sheet/_SheetCell.java29
-rw-r--r--sc/qa/extras/sccellobj.cxx9
-rw-r--r--test/Library_subsequenttest.mk1
-rw-r--r--test/source/sheet/sheetcell.cxx216
8 files changed, 294 insertions, 40 deletions
diff --git a/include/test/cppunitasserthelper.hxx b/include/test/cppunitasserthelper.hxx
index 4f4f920dd9fc..b6703e255ce0 100644
--- a/include/test/cppunitasserthelper.hxx
+++ b/include/test/cppunitasserthelper.hxx
@@ -12,6 +12,8 @@
#include <rtl/ustring.hxx>
+#include <com/sun/star/awt/Point.hpp>
+#include <com/sun/star/awt/Size.hpp>
#include <com/sun/star/table/CellAddress.hpp>
#include <com/sun/star/table/CellRangeAddress.hpp>
@@ -19,6 +21,40 @@
CPPUNIT_NS_BEGIN
+/** @brief Trait used by CPPUNIT_ASSERT* macros to compare com::sun::star:awt::Point.
+ *
+ * This specialization from @c struct @c assertion_traits<> helps to compare
+ * @see com::sun::star::awt::Point.
+ */
+template <> struct assertion_traits<css::awt::Point>
+{
+ static bool equal(const css::awt::Point& x, const css::awt::Point& y) { return x == y; }
+
+ static std::string toString(const css::awt::Point& x)
+ {
+ OStringStream ost;
+ ost << "Point: " << x.X << "." << x.Y << " (coordinate: X.Y)";
+ return ost.str();
+ }
+};
+
+/** @brief Trait used by CPPUNIT_ASSERT* macros to compare com::sun::star:awt::Size.
+ *
+ * This specialization from @c struct @c assertion_traits<> helps to compare
+ * @see com::sun::star::awt::Size.
+ */
+template <> struct assertion_traits<css::awt::Size>
+{
+ static bool equal(const css::awt::Size& x, const css::awt::Size& y) { return x == y; }
+
+ static std::string toString(const css::awt::Size& x)
+ {
+ OStringStream ost;
+ ost << "Size: " << x.Width << " x " << x.Height << " (Width x Height)";
+ return ost.str();
+ }
+};
+
/** @brief Trait used by CPPUNIT_ASSERT* macros to compare com::sun::star::table::CellAddress.
*
* This specialization from @c struct @c assertion_traits<> helps to compare
diff --git a/include/test/sheet/sheetcell.hxx b/include/test/sheet/sheetcell.hxx
new file mode 100644
index 000000000000..a5d35cee1a05
--- /dev/null
+++ b/include/test/sheet/sheetcell.hxx
@@ -0,0 +1,34 @@
+/* -*- 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_SHEETCELL_HXX
+#define INCLUDED_TEST_SHEET_SHEETCELL_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 SheetCell
+{
+public:
+ virtual css::uno::Reference<css::uno::XInterface> init() = 0;
+
+ void testSheetCellProperties();
+
+protected:
+ ~SheetCell() {}
+};
+}
+
+#endif // INCLUDED_TEST_SHEET_SHEETCELL_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 72f64db9f389..ac4ae33a1f08 100644
--- a/qadevOOo/Jar_OOoRunner.mk
+++ b/qadevOOo/Jar_OOoRunner.mk
@@ -565,7 +565,6 @@ $(eval $(call gb_Jar_add_sourcefiles,OOoRunner,\
qadevOOo/tests/java/ifc/sdb/_XSQLErrorBroadcaster \
qadevOOo/tests/java/ifc/sheet/_FunctionDescription \
qadevOOo/tests/java/ifc/sheet/_Shape \
- qadevOOo/tests/java/ifc/sheet/_SheetCell \
qadevOOo/tests/java/ifc/sheet/_SheetCellRange \
qadevOOo/tests/java/ifc/sheet/_SheetCellRanges \
qadevOOo/tests/java/ifc/sheet/_SheetFilterDescriptor \
diff --git a/qadevOOo/objdsc/sc/com.sun.star.comp.office.ScCellObj.csv b/qadevOOo/objdsc/sc/com.sun.star.comp.office.ScCellObj.csv
index a844cd884d23..a217fac5191b 100644
--- a/qadevOOo/objdsc/sc/com.sun.star.comp.office.ScCellObj.csv
+++ b/qadevOOo/objdsc/sc/com.sun.star.comp.office.ScCellObj.csv
@@ -139,14 +139,6 @@
"ScCellObj";"com::sun::star::text::XTextRange";"getEnd()"
"ScCellObj";"com::sun::star::text::XTextRange";"getString()"
"ScCellObj";"com::sun::star::text::XTextRange";"setString()"
-"ScCellObj";"com::sun::star::sheet::SheetCell";"Position"
-"ScCellObj";"com::sun::star::sheet::SheetCell";"Size"
-"ScCellObj";"com::sun::star::sheet::SheetCell";"FormulaLocal#optional"
-"ScCellObj";"com::sun::star::sheet::SheetCell";"FormulaResultType"
-"ScCellObj";"com::sun::star::sheet::SheetCell";"ConditionalFormat"
-"ScCellObj";"com::sun::star::sheet::SheetCell";"ConditionalFormatLocal#optional"
-"ScCellObj";"com::sun::star::sheet::SheetCell";"Validation"
-"ScCellObj";"com::sun::star::sheet::SheetCell";"ValidationLocal#optional"
"ScCellObj";"com::sun::star::beans::XTolerantMultiPropertySet#optional";"setPropertyValuesTolerant()"
"ScCellObj";"com::sun::star::beans::XTolerantMultiPropertySet#optional";"getPropertyValuesTolerant()"
"ScCellObj";"com::sun::star::beans::XTolerantMultiPropertySet#optional";"getDirectPropertyValuesTolerant()"
diff --git a/qadevOOo/tests/java/ifc/sheet/_SheetCell.java b/qadevOOo/tests/java/ifc/sheet/_SheetCell.java
deleted file mode 100644
index c60a44377a32..000000000000
--- a/qadevOOo/tests/java/ifc/sheet/_SheetCell.java
+++ /dev/null
@@ -1,29 +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 lib.MultiPropertyTest;
-
-
-public class _SheetCell extends MultiPropertyTest {
-
-
-}
-
-
diff --git a/sc/qa/extras/sccellobj.cxx b/sc/qa/extras/sccellobj.cxx
index dd9ab6fe633a..bd572af4c4f5 100644
--- a/sc/qa/extras/sccellobj.cxx
+++ b/sc/qa/extras/sccellobj.cxx
@@ -8,6 +8,7 @@
*/
#include <test/calc_unoapi_test.hxx>
+#include <test/sheet/sheetcell.hxx>
#include <test/sheet/xcelladdressable.hxx>
#include <test/sheet/xsheetannotationanchor.hxx>
@@ -26,9 +27,10 @@ using namespace css::uno;
namespace sc_apitest {
-#define NUMBER_OF_TESTS 2
+#define NUMBER_OF_TESTS 3
-class ScCellObj : public CalcUnoApiTest, public apitest::XCellAddressable,
+class ScCellObj : public CalcUnoApiTest, public apitest::SheetCell,
+ public apitest::XCellAddressable,
public apitest::XSheetAnnotationAnchor
{
public:
@@ -40,6 +42,9 @@ public:
CPPUNIT_TEST_SUITE(ScCellObj);
+ // SheetCell
+ CPPUNIT_TEST(testSheetCellProperties);
+
// XCellAddressable
CPPUNIT_TEST(testGetCellAddress);
diff --git a/test/Library_subsequenttest.mk b/test/Library_subsequenttest.mk
index 7b2a550b42bc..df6a7c71d842 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/sheetcell \
test/source/sheet/tableautoformat \
test/source/sheet/tablevalidation \
test/source/sheet/xarealink \
diff --git a/test/source/sheet/sheetcell.cxx b/test/source/sheet/sheetcell.cxx
new file mode 100644
index 000000000000..4d3347d64d72
--- /dev/null
+++ b/test/source/sheet/sheetcell.cxx
@@ -0,0 +1,216 @@
+/* -*- 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/cppunitasserthelper.hxx>
+#include <test/sheet/sheetcell.hxx>
+
+#include <com/sun/star/awt/Point.hpp>
+#include <com/sun/star/awt/Size.hpp>
+#include <com/sun/star/beans/XPropertySet.hpp>
+#include <com/sun/star/beans/XPropertySetInfo.hpp>
+#include <com/sun/star/sheet/ValidationType.hpp>
+#include <com/sun/star/sheet/XSheetConditionalEntry.hpp>
+#include <com/sun/star/sheet/XSheetConditionalEntries.hpp>
+#include <com/sun/star/table/CellContentType.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 SheetCell::testSheetCellProperties()
+{
+ uno::Reference<beans::XPropertySet> xSheetCell(init(), UNO_QUERY_THROW);
+ OUString propName;
+ uno::Any aNewValue;
+
+ propName = "Position";
+ awt::Point aPositionGet;
+ CPPUNIT_ASSERT_MESSAGE("Unable to get PropertyValue Position",
+ xSheetCell->getPropertyValue(propName) >>= aPositionGet);
+
+ awt::Point aPositionSet(42, 42);
+ aNewValue <<= aPositionSet;
+ xSheetCell->setPropertyValue(propName, aNewValue);
+ CPPUNIT_ASSERT(xSheetCell->getPropertyValue(propName) >>= aPositionSet);
+ CPPUNIT_ASSERT_EQUAL_MESSAGE("Able to set PropertyValue Position", aPositionGet, aPositionGet);
+
+ propName = "Size";
+ awt::Size aSizeGet;
+ CPPUNIT_ASSERT_MESSAGE("Unable to get PropertyValue Size",
+ xSheetCell->getPropertyValue(propName) >>= aSizeGet);
+
+ awt::Size aSizeSet(42, 42);
+ aNewValue <<= aSizeGet;
+ xSheetCell->setPropertyValue(propName, aNewValue);
+ CPPUNIT_ASSERT(xSheetCell->getPropertyValue(propName) >>= aSizeSet);
+ CPPUNIT_ASSERT_EQUAL_MESSAGE("Able to set PropertyValue Size", aSizeGet, aSizeSet);
+
+ propName = "FormulaLocal";
+ OUString aFormulaLocal = "";
+ CPPUNIT_ASSERT_MESSAGE("Unable to get PropertyValue FormulaLocal",
+ xSheetCell->getPropertyValue(propName) >>= aFormulaLocal);
+
+ aNewValue <<= OUString("FormulaLocal");
+ xSheetCell->setPropertyValue(propName, aNewValue);
+ CPPUNIT_ASSERT(xSheetCell->getPropertyValue(propName) >>= aFormulaLocal);
+ CPPUNIT_ASSERT_EQUAL_MESSAGE("Unable to set PropertyValue FormulaLocal",
+ OUString("FormulaLocal"), aFormulaLocal);
+
+ propName = "CellContentType";
+ table::CellContentType aCellContentTypeGet;
+ CPPUNIT_ASSERT_MESSAGE("Unable to get PropertyValue CellContentType",
+ xSheetCell->getPropertyValue(propName) >>= aCellContentTypeGet);
+
+ table::CellContentType aCellContentTypeSet = table::CellContentType_TEXT;
+ aNewValue <<= aCellContentTypeSet;
+ xSheetCell->setPropertyValue(propName, aNewValue);
+ CPPUNIT_ASSERT(xSheetCell->getPropertyValue(propName) >>= aCellContentTypeSet);
+ CPPUNIT_ASSERT_EQUAL_MESSAGE("Able to set PropertyValue CellContentType", aCellContentTypeGet,
+ aCellContentTypeSet);
+
+ // Special case, because the API returns the wrong type.
+ propName = "FormulaResultType";
+ table::CellContentType aFormulaResultTypeGet;
+ CPPUNIT_ASSERT_MESSAGE("Unable to get PropertyValue FormulaResultType",
+ xSheetCell->getPropertyValue(propName) >>= aFormulaResultTypeGet);
+
+ table::CellContentType aFormulaResultTypeSet = table::CellContentType_TEXT;
+ aNewValue <<= aFormulaResultTypeSet;
+ xSheetCell->setPropertyValue(propName, aNewValue);
+ CPPUNIT_ASSERT(xSheetCell->getPropertyValue(propName) >>= aFormulaResultTypeSet);
+ CPPUNIT_ASSERT_EQUAL_MESSAGE("Able to set PropertyValue FormulaResultType",
+ aFormulaResultTypeGet, aFormulaResultTypeSet);
+
+ propName = "FormulaResultType2";
+ sal_Int32 aFormulaResultType2Get = 42;
+ CPPUNIT_ASSERT_MESSAGE("Unable to get PropertyValue FormulaResultType2",
+ xSheetCell->getPropertyValue(propName) >>= aFormulaResultType2Get);
+
+ sal_Int32 aFormulaResultType2Set = 42;
+ aNewValue <<= aFormulaResultType2Set;
+ xSheetCell->setPropertyValue(propName, aNewValue);
+ CPPUNIT_ASSERT(xSheetCell->getPropertyValue(propName) >>= aFormulaResultType2Set);
+ CPPUNIT_ASSERT_EQUAL_MESSAGE("Able to set PropertyValue FormulaResultType2",
+ aFormulaResultType2Get, aFormulaResultType2Set);
+
+ uno::Sequence<beans::PropertyValue> aPropValue(1);
+ aPropValue[0].Name = "StyleName";
+ aPropValue[0].Value <<= OUString("Result2");
+
+ propName = "ConditionalFormat";
+ uno::Reference<sheet::XSheetConditionalEntries> aConditionalFormatGet;
+ uno::Reference<sheet::XSheetConditionalEntries> aConditionalFormatSet;
+
+ CPPUNIT_ASSERT_MESSAGE("Unable to get PropertyValue ConditionalFormat",
+ xSheetCell->getPropertyValue(propName) >>= aConditionalFormatGet);
+
+ uno::Reference<sheet::XSheetConditionalEntries> aConditionalFormatNew(aConditionalFormatGet,
+ UNO_QUERY_THROW);
+ aConditionalFormatNew->addNew(aPropValue);
+
+ aNewValue <<= aConditionalFormatNew;
+ xSheetCell->setPropertyValue(propName, aNewValue);
+ CPPUNIT_ASSERT(xSheetCell->getPropertyValue(propName) >>= aConditionalFormatSet);
+ for (auto i = 0; i < aConditionalFormatSet->getCount(); i++)
+ {
+ uno::Reference<sheet::XSheetConditionalEntry> xSCENew(aConditionalFormatNew->getByIndex(i),
+ UNO_QUERY_THROW);
+ uno::Reference<sheet::XSheetConditionalEntry> xSCESet(aConditionalFormatSet->getByIndex(i),
+ UNO_QUERY_THROW);
+
+ CPPUNIT_ASSERT_EQUAL_MESSAGE("Unable to set PropertyValue ConditionalFormat["
+ + std::to_string(i) + "]",
+ xSCENew->getStyleName(), xSCESet->getStyleName());
+ }
+
+ propName = "ConditionalFormatLocal";
+ uno::Reference<sheet::XSheetConditionalEntries> aConditionalFormatLocalGet;
+ uno::Reference<sheet::XSheetConditionalEntries> aConditionalFormatLocalSet;
+
+ CPPUNIT_ASSERT_MESSAGE("Unable to get PropertyValue ConditionalFormatLocal",
+ xSheetCell->getPropertyValue(propName) >>= aConditionalFormatLocalGet);
+
+ uno::Reference<sheet::XSheetConditionalEntries> aConditionalFormatLocalNew(
+ aConditionalFormatLocalGet, UNO_QUERY_THROW);
+ aConditionalFormatLocalNew->addNew(aPropValue);
+
+ aNewValue <<= aConditionalFormatLocalNew;
+ xSheetCell->setPropertyValue(propName, aNewValue);
+ CPPUNIT_ASSERT(xSheetCell->getPropertyValue(propName) >>= aConditionalFormatLocalSet);
+ for (auto i = 0; i < aConditionalFormatLocalSet->getCount(); i++)
+ {
+ uno::Reference<sheet::XSheetConditionalEntry> xSCENew(
+ aConditionalFormatLocalNew->getByIndex(i), UNO_QUERY_THROW);
+ uno::Reference<sheet::XSheetConditionalEntry> xSCESet(
+ aConditionalFormatLocalSet->getByIndex(i), UNO_QUERY_THROW);
+
+ CPPUNIT_ASSERT_EQUAL_MESSAGE("Unable to set PropertyValue ConditionalFormatLocal["
+ + std::to_string(i) + "]",
+ xSCENew->getStyleName(), xSCESet->getStyleName());
+ }
+
+ propName = "Validation";
+ uno::Reference<beans::XPropertySet> aValidationGet;
+ uno::Reference<beans::XPropertySet> aValidationSet;
+
+ CPPUNIT_ASSERT_MESSAGE("Unable to get PropertyValue Validation",
+ xSheetCell->getPropertyValue(propName) >>= aValidationGet);
+
+ uno::Reference<beans::XPropertySet> aValidationNew(aValidationGet, UNO_QUERY_THROW);
+ uno::Any aValidationType;
+ aValidationType <<= sheet::ValidationType_WHOLE;
+ aValidationNew->setPropertyValue("Type", aValidationType);
+
+ aNewValue <<= aValidationNew;
+ xSheetCell->setPropertyValue(propName, aNewValue);
+ CPPUNIT_ASSERT(xSheetCell->getPropertyValue(propName) >>= aValidationSet);
+ sheet::ValidationType aType;
+ aValidationSet->getPropertyValue("Type") >>= aType;
+ CPPUNIT_ASSERT_EQUAL_MESSAGE("Unable to set PropertyValue Validation",
+ sheet::ValidationType_WHOLE, aType);
+
+ propName = "ValidationLocal";
+ uno::Reference<beans::XPropertySet> aValidationLocalGet;
+ uno::Reference<beans::XPropertySet> aValidationLocalSet;
+
+ CPPUNIT_ASSERT_MESSAGE("Unable to get PropertyValue ValidationLocal",
+ xSheetCell->getPropertyValue(propName) >>= aValidationLocalGet);
+
+ uno::Reference<beans::XPropertySet> aValidationLocalNew(aValidationLocalGet, UNO_QUERY_THROW);
+ aValidationType <<= sheet::ValidationType_WHOLE;
+ aValidationLocalNew->setPropertyValue("Type", aValidationType);
+
+ aNewValue <<= aValidationLocalNew;
+ xSheetCell->setPropertyValue(propName, aNewValue);
+ CPPUNIT_ASSERT(xSheetCell->getPropertyValue(propName) >>= aValidationLocalSet);
+ aValidationLocalSet->getPropertyValue("Type") >>= aType;
+ CPPUNIT_ASSERT_EQUAL_MESSAGE("Unable to set PropertyValue ValidationLocal",
+ sheet::ValidationType_WHOLE, aType);
+
+ propName = "AbsoluteName";
+ OUString aAbsoluteNameGet = "";
+ CPPUNIT_ASSERT_MESSAGE("Unable to get PropertyValue AbsoluteName",
+ xSheetCell->getPropertyValue(propName) >>= aAbsoluteNameGet);
+
+ OUString aAbsoluteNameSet = "$Sheet1.$C$3";
+ aNewValue <<= aAbsoluteNameSet;
+ xSheetCell->setPropertyValue(propName, aNewValue);
+ CPPUNIT_ASSERT(xSheetCell->getPropertyValue(propName) >>= aAbsoluteNameSet);
+ CPPUNIT_ASSERT_EQUAL_MESSAGE("Able to set PropertyValue AbsoluteName", aAbsoluteNameGet,
+ aAbsoluteNameSet);
+}
+}
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab cinoptions=b1,g0,N-s cinkeys+=0=break: */