1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4; fill-column: 100 -*- */
3 * This file is part of the LibreOffice project.
5 * This Source Code Form is subject to the terms of the Mozilla Public
6 * License, v. 2.0. If a copy of the MPL was not distributed with this
7 * file, You can obtain one at http://mozilla.org/MPL/2.0/.
10 #include <test/sheet/subtotaldescriptor.hxx>
12 #include <com/sun/star/beans/XPropertySet.hpp>
13 #include <com/sun/star/uno/Any.hxx>
14 #include <com/sun/star/uno/Reference.hxx>
16 #include <cppunit/TestAssert.h>
18 using namespace com::sun::star
;
19 using namespace com::sun::star::uno
;
23 void SubTotalDescriptor::testSubTotalDescriptorProperties()
25 uno::Reference
<beans::XPropertySet
> xSubTotalDescriptor(init(), UNO_QUERY_THROW
);
29 propName
= "InsertPageBreaks";
30 bool aInsertPageBreaks
= true;
31 CPPUNIT_ASSERT(xSubTotalDescriptor
->getPropertyValue(propName
) >>= aInsertPageBreaks
);
32 CPPUNIT_ASSERT_MESSAGE("Unable to get PropertyValue InsertPageBreaks", !aInsertPageBreaks
);
35 xSubTotalDescriptor
->setPropertyValue(propName
, aNewValue
);
36 CPPUNIT_ASSERT(xSubTotalDescriptor
->getPropertyValue(propName
) >>= aInsertPageBreaks
);
37 CPPUNIT_ASSERT_MESSAGE("Unable to set PropertyValue InsertPageBreaks", aInsertPageBreaks
);
39 propName
= "IsCaseSensitive";
40 bool aIsCaseSensitive
= true;
41 CPPUNIT_ASSERT(xSubTotalDescriptor
->getPropertyValue(propName
) >>= aIsCaseSensitive
);
42 CPPUNIT_ASSERT_MESSAGE("Unable to get PropertyValue IsCaseSensitive", !aIsCaseSensitive
);
45 xSubTotalDescriptor
->setPropertyValue(propName
, aNewValue
);
46 CPPUNIT_ASSERT(xSubTotalDescriptor
->getPropertyValue(propName
) >>= aIsCaseSensitive
);
47 CPPUNIT_ASSERT_MESSAGE("Unable to set PropertyValue IsCaseSensitive", aIsCaseSensitive
);
49 propName
= "EnableUserSortList";
50 bool aEnableUserSortList
= true;
51 CPPUNIT_ASSERT(xSubTotalDescriptor
->getPropertyValue(propName
) >>= aEnableUserSortList
);
52 CPPUNIT_ASSERT_MESSAGE("Unable to get PropertyValue EnableUserSortList", !aEnableUserSortList
);
55 xSubTotalDescriptor
->setPropertyValue(propName
, aNewValue
);
56 CPPUNIT_ASSERT(xSubTotalDescriptor
->getPropertyValue(propName
) >>= aEnableUserSortList
);
57 CPPUNIT_ASSERT_MESSAGE("Unable to set PropertyValue EnableUserSortList", aEnableUserSortList
);
59 propName
= "UserSortListIndex";
60 sal_Int32 aUserSortListIndex
= 42;
61 CPPUNIT_ASSERT(xSubTotalDescriptor
->getPropertyValue(propName
) >>= aUserSortListIndex
);
62 CPPUNIT_ASSERT_EQUAL_MESSAGE("Unable to get PropertyValue UserSortListIndex", sal_Int32(0),
65 aNewValue
<<= sal_Int32(42);
66 xSubTotalDescriptor
->setPropertyValue(propName
, aNewValue
);
67 CPPUNIT_ASSERT(xSubTotalDescriptor
->getPropertyValue(propName
) >>= aUserSortListIndex
);
68 CPPUNIT_ASSERT_EQUAL_MESSAGE("Unable to set PropertyValue UserSortListIndex", sal_Int32(42),
71 propName
= "BindFormatsToContent";
72 bool aBindFormatsToContent
= true;
73 CPPUNIT_ASSERT(xSubTotalDescriptor
->getPropertyValue(propName
) >>= aBindFormatsToContent
);
74 CPPUNIT_ASSERT_MESSAGE("Unable to get PropertyValue BindFormatsToContent",
75 !aBindFormatsToContent
);
78 xSubTotalDescriptor
->setPropertyValue(propName
, aNewValue
);
79 CPPUNIT_ASSERT(xSubTotalDescriptor
->getPropertyValue(propName
) >>= aBindFormatsToContent
);
80 CPPUNIT_ASSERT_MESSAGE("Unable to set PropertyValue BindFormatsToContent",
81 aBindFormatsToContent
);
83 propName
= "EnableSort";
84 bool aEnableSort
= false;
85 CPPUNIT_ASSERT(xSubTotalDescriptor
->getPropertyValue(propName
) >>= aEnableSort
);
86 CPPUNIT_ASSERT_MESSAGE("Unable to get PropertyValue EnableSort", aEnableSort
);
89 xSubTotalDescriptor
->setPropertyValue(propName
, aNewValue
);
90 CPPUNIT_ASSERT(xSubTotalDescriptor
->getPropertyValue(propName
) >>= aEnableSort
);
91 CPPUNIT_ASSERT_MESSAGE("Unable to set PropertyValue EnableSort", !aEnableSort
);
93 propName
= "SortAscending";
94 bool aSortAscending
= false;
95 CPPUNIT_ASSERT(xSubTotalDescriptor
->getPropertyValue(propName
) >>= aSortAscending
);
96 CPPUNIT_ASSERT_MESSAGE("Unable to get PropertyValue SortAscending", aSortAscending
);
99 xSubTotalDescriptor
->setPropertyValue(propName
, aNewValue
);
100 CPPUNIT_ASSERT(xSubTotalDescriptor
->getPropertyValue(propName
) >>= aSortAscending
);
101 CPPUNIT_ASSERT_MESSAGE("Unable to set PropertyValue SortAscending", !aSortAscending
);
103 propName
= "MaxFieldCount";
104 sal_Int32 aMaxFieldCount
= 42;
105 CPPUNIT_ASSERT(xSubTotalDescriptor
->getPropertyValue(propName
) >>= aMaxFieldCount
);
106 CPPUNIT_ASSERT_EQUAL_MESSAGE("Unable to get PropertyValue MaxFieldCount", sal_Int32(3),
109 aNewValue
<<= sal_Int32(42);
110 CPPUNIT_ASSERT_THROW_MESSAGE("Able to change PropertyValue MaxFieldCount",
111 xSubTotalDescriptor
->setPropertyValue(propName
, aNewValue
),
112 lang::IllegalArgumentException
);
116 /* vim:set shiftwidth=4 softtabstop=4 expandtab cinoptions=b1,g0,N-s cinkeys+=0=break: */