LibreOffice Module test (master) 1
subtotaldescriptor.cxx
Go to the documentation of this file.
1/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4; fill-column: 100 -*- */
2/*
3 * This file is part of the LibreOffice project.
4 *
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/.
8 */
9
11
12#include <com/sun/star/beans/XPropertySet.hpp>
13#include <com/sun/star/uno/Any.hxx>
14#include <com/sun/star/uno/Reference.hxx>
15
16#include <cppunit/TestAssert.h>
17
18using namespace com::sun::star;
19using namespace com::sun::star::uno;
20
21namespace apitest
22{
24{
25 uno::Reference<beans::XPropertySet> xSubTotalDescriptor(init(), UNO_QUERY_THROW);
26 OUString propName;
27 uno::Any aNewValue;
28
29 propName = "InsertPageBreaks";
30 bool aInsertPageBreaks = true;
31 CPPUNIT_ASSERT(xSubTotalDescriptor->getPropertyValue(propName) >>= aInsertPageBreaks);
32 CPPUNIT_ASSERT_MESSAGE("Unable to get PropertyValue InsertPageBreaks", !aInsertPageBreaks);
33
34 aNewValue <<= true;
35 xSubTotalDescriptor->setPropertyValue(propName, aNewValue);
36 CPPUNIT_ASSERT(xSubTotalDescriptor->getPropertyValue(propName) >>= aInsertPageBreaks);
37 CPPUNIT_ASSERT_MESSAGE("Unable to set PropertyValue InsertPageBreaks", aInsertPageBreaks);
38
39 propName = "IsCaseSensitive";
40 bool aIsCaseSensitive = true;
41 CPPUNIT_ASSERT(xSubTotalDescriptor->getPropertyValue(propName) >>= aIsCaseSensitive);
42 CPPUNIT_ASSERT_MESSAGE("Unable to get PropertyValue IsCaseSensitive", !aIsCaseSensitive);
43
44 aNewValue <<= true;
45 xSubTotalDescriptor->setPropertyValue(propName, aNewValue);
46 CPPUNIT_ASSERT(xSubTotalDescriptor->getPropertyValue(propName) >>= aIsCaseSensitive);
47 CPPUNIT_ASSERT_MESSAGE("Unable to set PropertyValue IsCaseSensitive", aIsCaseSensitive);
48
49 propName = "EnableUserSortList";
50 bool aEnableUserSortList = true;
51 CPPUNIT_ASSERT(xSubTotalDescriptor->getPropertyValue(propName) >>= aEnableUserSortList);
52 CPPUNIT_ASSERT_MESSAGE("Unable to get PropertyValue EnableUserSortList", !aEnableUserSortList);
53
54 aNewValue <<= true;
55 xSubTotalDescriptor->setPropertyValue(propName, aNewValue);
56 CPPUNIT_ASSERT(xSubTotalDescriptor->getPropertyValue(propName) >>= aEnableUserSortList);
57 CPPUNIT_ASSERT_MESSAGE("Unable to set PropertyValue EnableUserSortList", aEnableUserSortList);
58
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),
63 aUserSortListIndex);
64
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),
69 aUserSortListIndex);
70
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);
76
77 aNewValue <<= true;
78 xSubTotalDescriptor->setPropertyValue(propName, aNewValue);
79 CPPUNIT_ASSERT(xSubTotalDescriptor->getPropertyValue(propName) >>= aBindFormatsToContent);
80 CPPUNIT_ASSERT_MESSAGE("Unable to set PropertyValue BindFormatsToContent",
81 aBindFormatsToContent);
82
83 propName = "EnableSort";
84 bool aEnableSort = false;
85 CPPUNIT_ASSERT(xSubTotalDescriptor->getPropertyValue(propName) >>= aEnableSort);
86 CPPUNIT_ASSERT_MESSAGE("Unable to get PropertyValue EnableSort", aEnableSort);
87
88 aNewValue <<= false;
89 xSubTotalDescriptor->setPropertyValue(propName, aNewValue);
90 CPPUNIT_ASSERT(xSubTotalDescriptor->getPropertyValue(propName) >>= aEnableSort);
91 CPPUNIT_ASSERT_MESSAGE("Unable to set PropertyValue EnableSort", !aEnableSort);
92
93 propName = "SortAscending";
94 bool aSortAscending = false;
95 CPPUNIT_ASSERT(xSubTotalDescriptor->getPropertyValue(propName) >>= aSortAscending);
96 CPPUNIT_ASSERT_MESSAGE("Unable to get PropertyValue SortAscending", aSortAscending);
97
98 aNewValue <<= false;
99 xSubTotalDescriptor->setPropertyValue(propName, aNewValue);
100 CPPUNIT_ASSERT(xSubTotalDescriptor->getPropertyValue(propName) >>= aSortAscending);
101 CPPUNIT_ASSERT_MESSAGE("Unable to set PropertyValue SortAscending", !aSortAscending);
102
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),
107 aMaxFieldCount);
108
109 aNewValue <<= sal_Int32(42);
110 CPPUNIT_ASSERT_THROW_MESSAGE("Able to change PropertyValue MaxFieldCount",
111 xSubTotalDescriptor->setPropertyValue(propName, aNewValue),
112 lang::IllegalArgumentException);
113}
114}
115
116/* vim:set shiftwidth=4 softtabstop=4 expandtab cinoptions=b1,g0,N-s cinkeys+=0=break: */
virtual css::uno::Reference< css::uno::XInterface > init()=0