LibreOffice Module test (master)  1
cellarealink.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/Reference.hxx>
14 
15 #include <cppunit/TestAssert.h>
16 
17 using namespace css;
18 
19 namespace apitest
20 {
21 void CellAreaLink::testUrl()
22 {
23  uno::Reference<beans::XPropertySet> xCellAreaLink(init(), uno::UNO_QUERY_THROW);
24 
25  static const OUStringLiteral propName(u"Url");
26 
27  OUString aUrl;
28  CPPUNIT_ASSERT(xCellAreaLink->getPropertyValue(propName) >>= aUrl);
29  CPPUNIT_ASSERT_EQUAL_MESSAGE("Default Url already changed", m_aFileURL, aUrl);
30 
31  uno::Any aNewUrl;
32  aNewUrl <<= OUString("file:///tmp");
33  xCellAreaLink->setPropertyValue(propName, aNewUrl);
34  CPPUNIT_ASSERT(xCellAreaLink->getPropertyValue(propName) >>= aUrl);
35  CPPUNIT_ASSERT_EQUAL_MESSAGE("Value of Url wasn't changed", OUString("file:///tmp"), aUrl);
36 }
37 
38 void CellAreaLink::testFilter()
39 {
40  uno::Reference<beans::XPropertySet> xCellAreaLink(init(), uno::UNO_QUERY_THROW);
41 
42  static const OUStringLiteral propName(u"Filter");
43 
44  OUString aFilter;
45  CPPUNIT_ASSERT(xCellAreaLink->getPropertyValue(propName) >>= aFilter);
46  CPPUNIT_ASSERT_EQUAL_MESSAGE("Default Filter already changed", OUString("calc8"), aFilter);
47 
48  uno::Any aNewFilter;
49  aNewFilter <<= OUString("UnitTest");
50  xCellAreaLink->setPropertyValue(propName, aNewFilter);
51  CPPUNIT_ASSERT(xCellAreaLink->getPropertyValue(propName) >>= aFilter);
52  CPPUNIT_ASSERT_EQUAL_MESSAGE("Value of Filter wasn't changed", OUString("UnitTest"), aFilter);
53 }
54 
55 void CellAreaLink::testFilterOptions()
56 {
57  uno::Reference<beans::XPropertySet> xCellAreaLink(init(), uno::UNO_QUERY_THROW);
58 
59  static const OUStringLiteral propName(u"FilterOptions");
60 
61  OUString aFilterOptions;
62  CPPUNIT_ASSERT(xCellAreaLink->getPropertyValue(propName) >>= aFilterOptions);
63  CPPUNIT_ASSERT_EQUAL_MESSAGE("Default FilterOptions already changed", OUString(""),
64  aFilterOptions);
65 
66  uno::Any aNewFilterOptions;
67  aNewFilterOptions <<= OUString("UnitTest");
68  xCellAreaLink->setPropertyValue(propName, aNewFilterOptions);
69  CPPUNIT_ASSERT(xCellAreaLink->getPropertyValue(propName) >>= aFilterOptions);
70  CPPUNIT_ASSERT_EQUAL_MESSAGE("Value of FilterOptions wasn't changed", OUString("UnitTest"),
71  aFilterOptions);
72 }
73 
74 void CellAreaLink::testRefreshDelay()
75 {
76  uno::Reference<beans::XPropertySet> xCellAreaLink(init(), uno::UNO_QUERY_THROW);
77 
78  static const OUStringLiteral propName(u"RefreshDelay");
79 
80  sal_Int32 aRefreshDelay = 0;
81  CPPUNIT_ASSERT(xCellAreaLink->getPropertyValue(propName) >>= aRefreshDelay);
82  CPPUNIT_ASSERT_EQUAL_MESSAGE("Default RefreshDelay already changed", sal_Int32(0),
83  aRefreshDelay);
84 
85  uno::Any aNewRefreshDelay;
86  aNewRefreshDelay <<= static_cast<sal_Int32>(42);
87  xCellAreaLink->setPropertyValue(propName, aNewRefreshDelay);
88  CPPUNIT_ASSERT(xCellAreaLink->getPropertyValue(propName) >>= aRefreshDelay);
89  CPPUNIT_ASSERT_EQUAL_MESSAGE("Value of RefreshDelay wasn't changed", sal_Int32(42),
90  aRefreshDelay);
91 }
92 
93 void CellAreaLink::testRefreshPeriod()
94 {
95  uno::Reference<beans::XPropertySet> xCellAreaLink(init(), uno::UNO_QUERY_THROW);
96 
97  static const OUStringLiteral propName(u"RefreshPeriod");
98 
99  sal_Int32 aRefreshPeriod = 0;
100  CPPUNIT_ASSERT(xCellAreaLink->getPropertyValue(propName) >>= aRefreshPeriod);
101  CPPUNIT_ASSERT_EQUAL_MESSAGE("Default RefreshPeriod already changed", sal_Int32(0),
102  aRefreshPeriod);
103 
104  uno::Any aNewRefreshPeriod;
105  aNewRefreshPeriod <<= static_cast<sal_Int32>(42);
106  xCellAreaLink->setPropertyValue(propName, aNewRefreshPeriod);
107  CPPUNIT_ASSERT(xCellAreaLink->getPropertyValue(propName) >>= aRefreshPeriod);
108  CPPUNIT_ASSERT_EQUAL_MESSAGE("Value of RefreshPeriod wasn't changed", sal_Int32(42),
109  aRefreshPeriod);
110 }
111 
112 } // namespace apitest
113 
114 /* vim:set shiftwidth=4 softtabstop=4 expandtab cinoptions=b1,g0,N-s cinkeys+=0=break: */
float u
FILE * init(int, char **)