summaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
authorJens Carl <j.carl43@gmx.de>2017-11-23 01:50:39 +0000
committerJens Carl <j.carl43@gmx.de>2017-11-23 08:41:48 +0100
commit39c5ade7bbb444eb204015955276748a5b381ad9 (patch)
treeda623126068a4db9e2309685cf4f7ca68ee95c13 /test
parent0e2f224d07a0e7f542984d9e9f48c9cda86a80f6 (diff)
tdf#45904 Move _XSheetAuditing Java tests to C++
Change-Id: I057447494ff488546d43d2d3068a65d5c0d402e0 Reviewed-on: https://gerrit.libreoffice.org/45120 Tested-by: Jenkins <ci@libreoffice.org> Reviewed-by: Jens Carl <j.carl43@gmx.de>
Diffstat (limited to 'test')
-rw-r--r--test/Library_subsequenttest.mk1
-rw-r--r--test/source/sheet/xsheetauditing.cxx136
2 files changed, 137 insertions, 0 deletions
diff --git a/test/Library_subsequenttest.mk b/test/Library_subsequenttest.mk
index 2b60f192df78..b9a033d73326 100644
--- a/test/Library_subsequenttest.mk
+++ b/test/Library_subsequenttest.mk
@@ -76,6 +76,7 @@ $(eval $(call gb_Library_add_exception_objects,subsequenttest,\
test/source/sheet/xsheetannotations \
test/source/sheet/xsheetannotationssupplier \
test/source/sheet/xsheetannotationshapesupplier \
+ test/source/sheet/xsheetauditing \
test/source/sheet/xsheetcellrangecontainer \
test/source/sheet/xsheetcellrange \
test/source/sheet/xsheetcellranges \
diff --git a/test/source/sheet/xsheetauditing.cxx b/test/source/sheet/xsheetauditing.cxx
new file mode 100644
index 000000000000..3e832413ffe4
--- /dev/null
+++ b/test/source/sheet/xsheetauditing.cxx
@@ -0,0 +1,136 @@
+/* -*- 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/xsheetauditing.hxx>
+
+#include <com/sun/star/beans/XPropertySet.hpp>
+#include <com/sun/star/drawing/XDrawPage.hpp>
+#include <com/sun/star/drawing/XDrawPageSupplier.hpp>
+#include <com/sun/star/sheet/XSheetAuditing.hpp>
+#include <com/sun/star/sheet/XSpreadsheet.hpp>
+#include <com/sun/star/sheet/ValidationType.hpp>
+#include <com/sun/star/table/CellAddress.hpp>
+#include <com/sun/star/table/XCell.hpp>
+#include <com/sun/star/text/XText.hpp>
+#include <com/sun/star/uno/Any.hxx>
+#include <com/sun/star/uno/Reference.hxx>
+
+#include <cppunit/extensions/HelperMacros.h>
+
+using namespace css;
+using namespace css::uno;
+
+namespace apitest
+{
+void XSheetAuditing::testShowHideDependents()
+{
+ uno::Reference<sheet::XSheetAuditing> xAuditing(init(), UNO_QUERY_THROW);
+
+ uno::Reference<drawing::XDrawPageSupplier> xDPS(xAuditing, UNO_QUERY_THROW);
+ uno::Reference<drawing::XDrawPage> xDrawPage = xDPS->getDrawPage();
+ const sal_Int32 nElements = xDrawPage->getCount();
+
+ xAuditing->showDependents(table::CellAddress(0, 8, 6));
+ CPPUNIT_ASSERT_EQUAL_MESSAGE("Unable to showDependents()", nElements + 1,
+ xDrawPage->getCount());
+
+ xAuditing->hideDependents(table::CellAddress(0, 8, 6));
+ CPPUNIT_ASSERT_EQUAL_MESSAGE("Unable to hideDependents()", nElements, xDrawPage->getCount());
+}
+
+void XSheetAuditing::testShowHidePrecedents()
+{
+ uno::Reference<sheet::XSheetAuditing> xAuditing(init(), UNO_QUERY_THROW);
+
+ uno::Reference<drawing::XDrawPageSupplier> xDPS(xAuditing, UNO_QUERY_THROW);
+ uno::Reference<drawing::XDrawPage> xDrawPage = xDPS->getDrawPage();
+ const sal_Int32 nElements = xDrawPage->getCount();
+
+ xAuditing->showPrecedents(table::CellAddress(0, 8, 6));
+ CPPUNIT_ASSERT_EQUAL_MESSAGE("Unable to showPrecedents()", nElements + 2,
+ xDrawPage->getCount());
+
+ xAuditing->hidePrecedents(table::CellAddress(0, 8, 6));
+ CPPUNIT_ASSERT_EQUAL_MESSAGE("Unable to showPrecedents()", nElements, xDrawPage->getCount());
+}
+
+void XSheetAuditing::testClearArrows()
+{
+ uno::Reference<sheet::XSheetAuditing> xAuditing(init(), UNO_QUERY_THROW);
+
+ uno::Reference<drawing::XDrawPageSupplier> xDPS(xAuditing, UNO_QUERY_THROW);
+ uno::Reference<drawing::XDrawPage> xDrawPage = xDPS->getDrawPage();
+ const sal_Int32 nElements = xDrawPage->getCount();
+
+ xAuditing->showPrecedents(table::CellAddress(0, 8, 6));
+ xAuditing->showDependents(table::CellAddress(0, 8, 6));
+ CPPUNIT_ASSERT_EQUAL_MESSAGE("Unable to set arrows", nElements + 3, xDrawPage->getCount());
+
+ xAuditing->clearArrows();
+ CPPUNIT_ASSERT_EQUAL_MESSAGE("Unable to clear arrows", nElements, xDrawPage->getCount());
+}
+
+void XSheetAuditing::testShowErrors()
+{
+ uno::Reference<sheet::XSheetAuditing> xAuditing(init(), UNO_QUERY_THROW);
+
+ uno::Reference<drawing::XDrawPageSupplier> xDPS(xAuditing, UNO_QUERY_THROW);
+ uno::Reference<drawing::XDrawPage> xDrawPage = xDPS->getDrawPage();
+ const sal_Int32 nElements = xDrawPage->getCount();
+
+ uno::Reference<sheet::XSpreadsheet> xSheet(xAuditing, UNO_QUERY_THROW);
+ uno::Reference<table::XCell> xCell = xSheet->getCellByPosition(7, 6);
+ xCell->setValue(-9);
+ xCell->setFormula("=SQRT(" + OUString(static_cast<char>('A' + 7)) + OUString::number(7) + ")");
+
+ uno::Reference<text::XText> xText(xCell, UNO_QUERY_THROW);
+ CPPUNIT_ASSERT_EQUAL_MESSAGE("No error code", OUString("Err:522"), xText->getString());
+
+ xAuditing->showErrors(table::CellAddress(0, 7, 6));
+ CPPUNIT_ASSERT_EQUAL_MESSAGE("Unable to show errors", nElements + 1, xDrawPage->getCount());
+}
+
+void XSheetAuditing::testShowInvalid()
+{
+ uno::Reference<sheet::XSheetAuditing> xAuditing(init(), UNO_QUERY_THROW);
+
+ uno::Reference<drawing::XDrawPageSupplier> xDPS(xAuditing, UNO_QUERY_THROW);
+ uno::Reference<drawing::XDrawPage> xDrawPage = xDPS->getDrawPage();
+ const sal_Int32 nElements = xDrawPage->getCount();
+
+ uno::Reference<sheet::XSpreadsheet> xSheet(xAuditing, UNO_QUERY_THROW);
+ uno::Reference<table::XCell> xCell = xSheet->getCellByPosition(7, 6);
+ xCell->setValue(2.5);
+
+ uno::Reference<beans::XPropertySet> xPropSet(xCell, UNO_QUERY_THROW);
+ uno::Any aValidation = xPropSet->getPropertyValue("Validation");
+ uno::Reference<beans::XPropertySet> xValidation(aValidation, UNO_QUERY_THROW);
+ uno::Any aAny;
+
+ aAny <<= sheet::ValidationType_WHOLE;
+ xValidation->setPropertyValue("Type", aAny);
+ aAny <<= xValidation;
+ xPropSet->setPropertyValue("Validation", aAny);
+ xAuditing->showInvalid();
+ CPPUNIT_ASSERT_EQUAL_MESSAGE("Unable to show invalid (WHOLE)", nElements + 1,
+ xDrawPage->getCount());
+
+ xAuditing->clearArrows();
+
+ aAny <<= sheet::ValidationType_ANY;
+ xValidation->setPropertyValue("Type", aAny);
+ aAny <<= xValidation;
+ xPropSet->setPropertyValue("Validation", aAny);
+
+ xAuditing->showInvalid();
+ CPPUNIT_ASSERT_EQUAL_MESSAGE("Unable to show invalid (ANY)", nElements, xDrawPage->getCount());
+}
+}
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab cinoptions=b1,g0,N-s cinkeys+=0=break: */