LibreOffice Module test (master) 1
scenario.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> xScenario(getScenarioSpreadsheet(), UNO_QUERY_THROW);
26 OUString propName;
27 uno::Any aNewValue;
28
29 propName = "IsActive";
30 bool aIsActive = false;
31 CPPUNIT_ASSERT(xScenario->getPropertyValue(propName) >>= aIsActive);
32 CPPUNIT_ASSERT_MESSAGE("Unable to get property value IsActive", aIsActive);
33
34 aNewValue <<= false;
35 xScenario->setPropertyValue(propName, aNewValue);
36 CPPUNIT_ASSERT(xScenario->getPropertyValue(propName) >>= aIsActive);
37 CPPUNIT_ASSERT_MESSAGE("Unable to set property value IsActive", !aIsActive);
38
39 propName = "BorderColor";
40 sal_Int32 aBorderColor = 0;
41 CPPUNIT_ASSERT(xScenario->getPropertyValue(propName) >>= aBorderColor);
42 CPPUNIT_ASSERT_EQUAL_MESSAGE("Unable to get property value BorderColor", sal_Int32(12632256),
43 aBorderColor);
44
45 aNewValue <<= sal_Int32(42);
46 xScenario->setPropertyValue(propName, aNewValue);
47 CPPUNIT_ASSERT(xScenario->getPropertyValue(propName) >>= aBorderColor);
48 CPPUNIT_ASSERT_EQUAL_MESSAGE("Unable to set property value BorderColor", sal_Int32(42),
49 aBorderColor);
50
51 propName = "Protected";
52 bool aProtected = false;
53 CPPUNIT_ASSERT(xScenario->getPropertyValue(propName) >>= aProtected);
54 CPPUNIT_ASSERT_MESSAGE("Unable to get property value Protected", aProtected);
55
56 aNewValue <<= false;
57 xScenario->setPropertyValue(propName, aNewValue);
58 CPPUNIT_ASSERT(xScenario->getPropertyValue(propName) >>= aProtected);
59 CPPUNIT_ASSERT_MESSAGE("Unable to set property value Protected", !aProtected);
60
61 propName = "ShowBorder";
62 bool aShowBorder = false;
63 CPPUNIT_ASSERT(xScenario->getPropertyValue(propName) >>= aShowBorder);
64 CPPUNIT_ASSERT_MESSAGE("Unable to get property value ShowBorder", aShowBorder);
65
66 aNewValue <<= false;
67 xScenario->setPropertyValue(propName, aNewValue);
68 CPPUNIT_ASSERT(xScenario->getPropertyValue(propName) >>= aShowBorder);
69 CPPUNIT_ASSERT_MESSAGE("Unable to set property value ShowBorder", !aShowBorder);
70
71 propName = "PrintBorder";
72 bool aPrintBorder = false;
73 CPPUNIT_ASSERT(xScenario->getPropertyValue(propName) >>= aPrintBorder);
74 CPPUNIT_ASSERT_MESSAGE("Unable to get property value PrintBorder", aPrintBorder);
75
76 aNewValue <<= false;
77 xScenario->setPropertyValue(propName, aNewValue);
78 CPPUNIT_ASSERT(xScenario->getPropertyValue(propName) >>= aPrintBorder);
79 CPPUNIT_ASSERT_MESSAGE("Unable to set property value PrintBorder", !aPrintBorder);
80
81 propName = "CopyBack";
82 bool aCopyBack = false;
83 CPPUNIT_ASSERT(xScenario->getPropertyValue(propName) >>= aCopyBack);
84 CPPUNIT_ASSERT_MESSAGE("Unable to get property value CopyBack", aCopyBack);
85
86 aNewValue <<= false;
87 xScenario->setPropertyValue(propName, aNewValue);
88 CPPUNIT_ASSERT(xScenario->getPropertyValue(propName) >>= aCopyBack);
89 CPPUNIT_ASSERT_MESSAGE("Unable to set property value CopyBack", !aCopyBack);
90
91 propName = "CopyStyles";
92 bool aCopyStyles = true;
93 CPPUNIT_ASSERT(xScenario->getPropertyValue(propName) >>= aCopyStyles);
94 CPPUNIT_ASSERT_MESSAGE("Unable to get property value CopyStyles", !aCopyStyles);
95
96 aNewValue <<= true;
97 xScenario->setPropertyValue(propName, aNewValue);
98 CPPUNIT_ASSERT(xScenario->getPropertyValue(propName) >>= aCopyStyles);
99 CPPUNIT_ASSERT_MESSAGE("Unable to set property value CopyStyles", aCopyStyles);
100
101 propName = "CopyFormulas";
102 bool aCopyFormulas = false;
103 CPPUNIT_ASSERT(xScenario->getPropertyValue(propName) >>= aCopyFormulas);
104 CPPUNIT_ASSERT_MESSAGE("Unable to get property value CopyFormulas", aCopyFormulas);
105
106 aNewValue <<= false;
107 xScenario->setPropertyValue(propName, aNewValue);
108 CPPUNIT_ASSERT(xScenario->getPropertyValue(propName) >>= aCopyFormulas);
109 CPPUNIT_ASSERT_MESSAGE("Unable to set property value CopyFormulas", !aCopyFormulas);
110}
111}
112
113/* vim:set shiftwidth=4 softtabstop=4 expandtab cinoptions=b1,g0,N-s cinkeys+=0=break: */
void testScenarioProperties()
Definition: scenario.cxx:23
virtual css::uno::Reference< css::uno::XInterface > getScenarioSpreadsheet()=0