summaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
authorJens Carl <j.carl43@gmx.de>2018-01-09 01:00:49 +0000
committerJens Carl <j.carl43@gmx.de>2018-01-09 03:56:31 +0100
commitc29828daa32f3dee503e4db2b5b55d3d12f1fd39 (patch)
treea954195ed4d433f6ace8cebec61aee0e8b266bbd /test
parentacb43c0b8efbfb841e7b40603d75a8432eb21f21 (diff)
tdf#45904 Move _SubTotalDescriptor Java tests to C++
Change-Id: Id4265dd6a8123624bccdfe343655525948cadee7 Reviewed-on: https://gerrit.libreoffice.org/47623 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/subtotaldescriptor.cxx116
2 files changed, 117 insertions, 0 deletions
diff --git a/test/Library_subsequenttest.mk b/test/Library_subsequenttest.mk
index 7baa283a5908..9ad263fa411c 100644
--- a/test/Library_subsequenttest.mk
+++ b/test/Library_subsequenttest.mk
@@ -50,6 +50,7 @@ $(eval $(call gb_Library_add_exception_objects,subsequenttest,\
test/source/sheet/datapilotitem \
test/source/sheet/documentsettings \
test/source/sheet/scenario \
+ test/source/sheet/subtotaldescriptor \
test/source/sheet/tableautoformat \
test/source/sheet/tablevalidation \
test/source/sheet/xarealink \
diff --git a/test/source/sheet/subtotaldescriptor.cxx b/test/source/sheet/subtotaldescriptor.cxx
new file mode 100644
index 000000000000..2442648aa39c
--- /dev/null
+++ b/test/source/sheet/subtotaldescriptor.cxx
@@ -0,0 +1,116 @@
+/* -*- 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/subtotaldescriptor.hxx>
+
+#include <com/sun/star/beans/XPropertySet.hpp>
+#include <com/sun/star/uno/Any.hxx>
+#include <com/sun/star/uno/Reference.hxx>
+
+#include <cppunit/extensions/HelperMacros.h>
+
+using namespace com::sun::star;
+using namespace com::sun::star::uno;
+
+namespace apitest
+{
+void SubTotalDescriptor::testSubTotalDescriptorProperties()
+{
+ uno::Reference<beans::XPropertySet> xSubTotalDescriptor(init(), UNO_QUERY_THROW);
+ OUString propName;
+ uno::Any aNewValue;
+
+ propName = "InsertPageBreaks";
+ bool aInsertPageBreaks = true;
+ CPPUNIT_ASSERT(xSubTotalDescriptor->getPropertyValue(propName) >>= aInsertPageBreaks);
+ CPPUNIT_ASSERT_MESSAGE("Unable to get PropertyValue InsertPageBreaks", !aInsertPageBreaks);
+
+ aNewValue <<= true;
+ xSubTotalDescriptor->setPropertyValue(propName, aNewValue);
+ CPPUNIT_ASSERT(xSubTotalDescriptor->getPropertyValue(propName) >>= aInsertPageBreaks);
+ CPPUNIT_ASSERT_MESSAGE("Unable to set PropertyValue InsertPageBreaks", aInsertPageBreaks);
+
+ propName = "IsCaseSensitive";
+ bool aIsCaseSensitive = true;
+ CPPUNIT_ASSERT(xSubTotalDescriptor->getPropertyValue(propName) >>= aIsCaseSensitive);
+ CPPUNIT_ASSERT_MESSAGE("Unable to get PropertyValue IsCaseSensitive", !aIsCaseSensitive);
+
+ aNewValue <<= true;
+ xSubTotalDescriptor->setPropertyValue(propName, aNewValue);
+ CPPUNIT_ASSERT(xSubTotalDescriptor->getPropertyValue(propName) >>= aIsCaseSensitive);
+ CPPUNIT_ASSERT_MESSAGE("Unable to set PropertyValue IsCaseSensitive", aIsCaseSensitive);
+
+ propName = "EnableUserSortList";
+ bool aEnableUserSortList = true;
+ CPPUNIT_ASSERT(xSubTotalDescriptor->getPropertyValue(propName) >>= aEnableUserSortList);
+ CPPUNIT_ASSERT_MESSAGE("Unable to get PropertyValue EnableUserSortList", !aEnableUserSortList);
+
+ aNewValue <<= true;
+ xSubTotalDescriptor->setPropertyValue(propName, aNewValue);
+ CPPUNIT_ASSERT(xSubTotalDescriptor->getPropertyValue(propName) >>= aEnableUserSortList);
+ CPPUNIT_ASSERT_MESSAGE("Unable to set PropertyValue EnableUserSortList", aEnableUserSortList);
+
+ propName = "UserSortListIndex";
+ sal_Int32 aUserSortListIndex = 42;
+ CPPUNIT_ASSERT(xSubTotalDescriptor->getPropertyValue(propName) >>= aUserSortListIndex);
+ CPPUNIT_ASSERT_EQUAL_MESSAGE("Unable to get PropertyValue UserSortListIndex", sal_Int32(0),
+ aUserSortListIndex);
+
+ aNewValue <<= sal_Int32(42);
+ xSubTotalDescriptor->setPropertyValue(propName, aNewValue);
+ CPPUNIT_ASSERT(xSubTotalDescriptor->getPropertyValue(propName) >>= aUserSortListIndex);
+ CPPUNIT_ASSERT_EQUAL_MESSAGE("Unable to set PropertyValue UserSortListIndex", sal_Int32(42),
+ aUserSortListIndex);
+
+ propName = "BindFormatsToContent";
+ bool aBindFormatsToContent = true;
+ CPPUNIT_ASSERT(xSubTotalDescriptor->getPropertyValue(propName) >>= aBindFormatsToContent);
+ CPPUNIT_ASSERT_MESSAGE("Unable to get PropertyValue BindFormatsToContent",
+ !aBindFormatsToContent);
+
+ aNewValue <<= true;
+ xSubTotalDescriptor->setPropertyValue(propName, aNewValue);
+ CPPUNIT_ASSERT(xSubTotalDescriptor->getPropertyValue(propName) >>= aBindFormatsToContent);
+ CPPUNIT_ASSERT_MESSAGE("Unable to set PropertyValue BindFormatsToContent",
+ aBindFormatsToContent);
+
+ propName = "EnableSort";
+ bool aEnableSort = false;
+ CPPUNIT_ASSERT(xSubTotalDescriptor->getPropertyValue(propName) >>= aEnableSort);
+ CPPUNIT_ASSERT_MESSAGE("Unable to get PropertyValue EnableSort", aEnableSort);
+
+ aNewValue <<= false;
+ xSubTotalDescriptor->setPropertyValue(propName, aNewValue);
+ CPPUNIT_ASSERT(xSubTotalDescriptor->getPropertyValue(propName) >>= aEnableSort);
+ CPPUNIT_ASSERT_MESSAGE("Unable to set PropertyValue EnableSort", !aEnableSort);
+
+ propName = "SortAscending";
+ bool aSortAscending = false;
+ CPPUNIT_ASSERT(xSubTotalDescriptor->getPropertyValue(propName) >>= aSortAscending);
+ CPPUNIT_ASSERT_MESSAGE("Unable to get PropertyValue SortAscending", aSortAscending);
+
+ aNewValue <<= false;
+ xSubTotalDescriptor->setPropertyValue(propName, aNewValue);
+ CPPUNIT_ASSERT(xSubTotalDescriptor->getPropertyValue(propName) >>= aSortAscending);
+ CPPUNIT_ASSERT_MESSAGE("Unable to set PropertyValue SortAscending", !aSortAscending);
+
+ propName = "MaxFieldCount";
+ sal_Int32 aMaxFieldCount = 42;
+ CPPUNIT_ASSERT(xSubTotalDescriptor->getPropertyValue(propName) >>= aMaxFieldCount);
+ CPPUNIT_ASSERT_EQUAL_MESSAGE("Unable to get PropertyValue MaxFieldCount", sal_Int32(3),
+ aMaxFieldCount);
+
+ aNewValue <<= sal_Int32(42);
+ CPPUNIT_ASSERT_THROW_MESSAGE("Able to change PropertyValue MaxFieldCount",
+ xSubTotalDescriptor->setPropertyValue(propName, aNewValue),
+ lang::IllegalArgumentException);
+}
+}
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab cinoptions=b1,g0,N-s cinkeys+=0=break: */