nss: upgrade to release 3.73
[LibreOffice.git] / test / source / sheet / databaserange.cxx
blob302d88bc6b50555ce3f881931383044ffb075906
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.
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 */
10 #include <test/sheet/databaserange.hxx>
11 #include <test/cppunitasserthelper.hxx>
13 #include <com/sun/star/beans/XPropertySet.hpp>
14 #include <com/sun/star/sheet/XDatabaseRange.hpp>
15 #include <com/sun/star/table/CellRangeAddress.hpp>
16 #include <com/sun/star/uno/Reference.hxx>
18 #include <cppunit/TestAssert.h>
20 using namespace com::sun::star;
21 using namespace com::sun::star::uno;
23 namespace apitest
25 void DatabaseRange::testMoveCells()
27 uno::Reference<beans::XPropertySet> xDatabaseRange(init("DataArea"), UNO_QUERY_THROW);
29 const OUString propName("MoveCells");
31 bool bMoveCells = true;
32 CPPUNIT_ASSERT(xDatabaseRange->getPropertyValue(propName) >>= bMoveCells);
33 CPPUNIT_ASSERT_MESSAGE("Default MoveCells already changed", !bMoveCells);
35 uno::Any aNewMoveCells;
36 aNewMoveCells <<= true;
37 xDatabaseRange->setPropertyValue(propName, aNewMoveCells);
38 CPPUNIT_ASSERT(xDatabaseRange->getPropertyValue(propName) >>= bMoveCells);
39 CPPUNIT_ASSERT_MESSAGE("Value of MoveCells wasn't changed", bMoveCells);
42 void DatabaseRange::testKeepFormats()
44 uno::Reference<beans::XPropertySet> xDatabaseRange(init("DataArea"), UNO_QUERY_THROW);
46 const OUString propName("KeepFormats");
48 bool bKeepFormats = true;
49 CPPUNIT_ASSERT(xDatabaseRange->getPropertyValue(propName) >>= bKeepFormats);
50 CPPUNIT_ASSERT_MESSAGE("Default KeepFormats already changed", !bKeepFormats);
52 uno::Any aNewKeepFormats;
53 aNewKeepFormats <<= true;
54 xDatabaseRange->setPropertyValue(propName, aNewKeepFormats);
55 CPPUNIT_ASSERT(xDatabaseRange->getPropertyValue(propName) >>= bKeepFormats);
56 CPPUNIT_ASSERT_MESSAGE("Value of KeepFormats wasn't changed", bKeepFormats);
59 void DatabaseRange::testStripData()
61 uno::Reference<beans::XPropertySet> xDatabaseRange(init("DataArea"), UNO_QUERY_THROW);
63 const OUString propName("StripData");
65 bool bStripData = true;
66 CPPUNIT_ASSERT(xDatabaseRange->getPropertyValue(propName) >>= bStripData);
67 CPPUNIT_ASSERT_MESSAGE("Default StripData already changed", !bStripData);
69 uno::Any aNewStripData;
70 aNewStripData <<= true;
71 xDatabaseRange->setPropertyValue(propName, aNewStripData);
72 CPPUNIT_ASSERT(xDatabaseRange->getPropertyValue(propName) >>= bStripData);
73 CPPUNIT_ASSERT_MESSAGE("Value of StripData wasn't changed", bStripData);
76 void DatabaseRange::testAutoFilter()
78 uno::Reference<beans::XPropertySet> xDatabaseRange(init("DataArea"), UNO_QUERY_THROW);
80 const OUString propName("AutoFilter");
82 bool bAutoFilter = true;
83 CPPUNIT_ASSERT(xDatabaseRange->getPropertyValue(propName) >>= bAutoFilter);
84 CPPUNIT_ASSERT_MESSAGE("Default AutoFilter already changed", !bAutoFilter);
86 uno::Any aNewAutoFilter;
87 aNewAutoFilter <<= true;
88 xDatabaseRange->setPropertyValue(propName, aNewAutoFilter);
89 CPPUNIT_ASSERT(xDatabaseRange->getPropertyValue(propName) >>= bAutoFilter);
90 CPPUNIT_ASSERT_MESSAGE("Value of AutoFilter wasn't changed", bAutoFilter);
93 void DatabaseRange::testUseFilterCriteriaSource()
95 uno::Reference<beans::XPropertySet> xDatabaseRange(init("DataArea"), UNO_QUERY_THROW);
97 const OUString propName("UseFilterCriteriaSource");
99 bool bUseFilterCriteriaSource = true;
100 CPPUNIT_ASSERT(xDatabaseRange->getPropertyValue(propName) >>= bUseFilterCriteriaSource);
101 CPPUNIT_ASSERT_MESSAGE("Default UseFilterCriteriaSource already changed",
102 !bUseFilterCriteriaSource);
104 uno::Any aNewUseFilterCriteriaSource;
105 aNewUseFilterCriteriaSource <<= true;
106 xDatabaseRange->setPropertyValue(propName, aNewUseFilterCriteriaSource);
107 CPPUNIT_ASSERT(xDatabaseRange->getPropertyValue(propName) >>= bUseFilterCriteriaSource);
108 CPPUNIT_ASSERT_MESSAGE("Value of UseFilterCriteriaSource wasn't changed",
109 bUseFilterCriteriaSource);
112 void DatabaseRange::testFilterCriteriaSource()
114 uno::Reference<beans::XPropertySet> xDatabaseRange(init("DataArea"), UNO_QUERY_THROW);
116 const OUString propName("FilterCriteriaSource");
118 table::CellRangeAddress cellRangeAddress;
119 CPPUNIT_ASSERT(xDatabaseRange->getPropertyValue(propName) >>= cellRangeAddress);
120 CPPUNIT_ASSERT_EQUAL_MESSAGE("Default RefreshPeriod already changed",
121 table::CellRangeAddress(0, 0, 0, 0, 0), cellRangeAddress);
123 uno::Any aFilterCriteriaSource;
124 aFilterCriteriaSource <<= table::CellRangeAddress(1, 1, 1, 1, 1);
125 xDatabaseRange->setPropertyValue(propName, aFilterCriteriaSource);
126 CPPUNIT_ASSERT(xDatabaseRange->getPropertyValue(propName) >>= cellRangeAddress);
127 CPPUNIT_ASSERT_EQUAL_MESSAGE("Value of FilterCriteriaSource wasn't changed",
128 table::CellRangeAddress(1, 1, 1, 1, 1), cellRangeAddress);
131 void DatabaseRange::testRefreshPeriod()
133 uno::Reference<beans::XPropertySet> xDatabaseRange(init("DataArea"), UNO_QUERY_THROW);
135 const OUString propName("RefreshPeriod");
137 sal_Int32 aRefreshPeriod = 1;
138 CPPUNIT_ASSERT(xDatabaseRange->getPropertyValue(propName) >>= aRefreshPeriod);
139 CPPUNIT_ASSERT_EQUAL_MESSAGE("Default RefreshPeriod already changed", sal_Int32(0),
140 aRefreshPeriod);
142 uno::Any aNewRefreshPeriod;
143 aNewRefreshPeriod <<= static_cast<sal_Int32>(42);
144 xDatabaseRange->setPropertyValue(propName, aNewRefreshPeriod);
145 CPPUNIT_ASSERT(xDatabaseRange->getPropertyValue(propName) >>= aRefreshPeriod);
146 CPPUNIT_ASSERT_EQUAL_MESSAGE("Value of RefreshPeriod wasn't changed", sal_Int32(42),
147 aRefreshPeriod);
150 void DatabaseRange::testFromSelection()
152 uno::Reference<beans::XPropertySet> xDatabaseRange(init("DataArea"), UNO_QUERY_THROW);
154 const OUString propName("FromSelection");
156 bool bFromSelection = true;
157 CPPUNIT_ASSERT(xDatabaseRange->getPropertyValue(propName) >>= bFromSelection);
158 CPPUNIT_ASSERT_MESSAGE("Default FromSelection already changed", !bFromSelection);
160 uno::Any aNewFromSelection;
161 aNewFromSelection <<= true;
162 xDatabaseRange->setPropertyValue(propName, aNewFromSelection);
163 CPPUNIT_ASSERT(xDatabaseRange->getPropertyValue(propName) >>= bFromSelection);
164 CPPUNIT_ASSERT_MESSAGE("Value of FromSelection wasn't changed", bFromSelection);
167 void DatabaseRange::testTokenIndex()
169 uno::Reference<beans::XPropertySet> xDatabaseRange(init("DataArea"), UNO_QUERY_THROW);
171 const OUString propName("TokenIndex");
173 sal_Int32 aTokenIndex = 0;
174 CPPUNIT_ASSERT(xDatabaseRange->getPropertyValue(propName) >>= aTokenIndex);
175 CPPUNIT_ASSERT_EQUAL_MESSAGE("Default TotalIndex already changed", sal_Int32(1), aTokenIndex);
177 uno::Any aNewTokenIndex;
178 aNewTokenIndex <<= static_cast<sal_Int32>(42);
179 xDatabaseRange->setPropertyValue(propName, aNewTokenIndex);
180 CPPUNIT_ASSERT(xDatabaseRange->getPropertyValue(propName) >>= aTokenIndex);
181 CPPUNIT_ASSERT_EQUAL_MESSAGE("Value of TotalIndex was changed", sal_Int32(1), aTokenIndex);
184 void DatabaseRange::testTotalsRow()
186 uno::Reference<beans::XPropertySet> xDatabaseRange(init("DataArea"), UNO_QUERY_THROW);
188 const OUString propName("TotalsRow");
190 bool bTotalsRow = true;
191 CPPUNIT_ASSERT(xDatabaseRange->getPropertyValue(propName) >>= bTotalsRow);
192 CPPUNIT_ASSERT_MESSAGE("Default TotalsRow already changed", !bTotalsRow);
194 uno::Any aNewTotalsRow;
195 aNewTotalsRow <<= true;
196 xDatabaseRange->setPropertyValue(propName, aNewTotalsRow);
197 CPPUNIT_ASSERT(xDatabaseRange->getPropertyValue(propName) >>= bTotalsRow);
198 CPPUNIT_ASSERT_MESSAGE("Value of TotalsRow wasn't changed", bTotalsRow);
201 void DatabaseRange::testContainsHeader()
203 uno::Reference<beans::XPropertySet> xDatabaseRange(init("DataArea"), UNO_QUERY_THROW);
205 const OUString propName("ContainsHeader");
207 bool bContainsHeader = false;
208 CPPUNIT_ASSERT(xDatabaseRange->getPropertyValue(propName) >>= bContainsHeader);
209 CPPUNIT_ASSERT_MESSAGE("Default ContainsHeader already changed", bContainsHeader);
211 uno::Any aNewContainsHeader;
212 aNewContainsHeader <<= false;
213 xDatabaseRange->setPropertyValue(propName, aNewContainsHeader);
214 CPPUNIT_ASSERT(xDatabaseRange->getPropertyValue(propName) >>= bContainsHeader);
215 CPPUNIT_ASSERT_MESSAGE("Value of ContainsHeader wasn't changed", !bContainsHeader);
219 /* vim:set shiftwidth=4 softtabstop=4 expandtab cinoptions=b1,g0,N-s cinkeys+=0=break: */