LibreOffice Module test (master) 1
datapilotitem.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
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> xItem(init(), UNO_QUERY_THROW);
26
27 static constexpr OUStringLiteral propNameIS(u"IsHidden");
28
29 bool bIsHidden = true;
30 CPPUNIT_ASSERT(xItem->getPropertyValue(propNameIS) >>= bIsHidden);
31 CPPUNIT_ASSERT_MESSAGE("Default IsHidden already changed", !bIsHidden);
32
33 uno::Any aNewIsHidden;
34 aNewIsHidden <<= false;
35 xItem->setPropertyValue(propNameIS, aNewIsHidden);
36 CPPUNIT_ASSERT(xItem->getPropertyValue(propNameIS) >>= bIsHidden);
37 CPPUNIT_ASSERT_MESSAGE("Value of IsHidden wasn't changed", !bIsHidden);
38
39 static constexpr OUStringLiteral propNameSD(u"ShowDetail");
40
41 bool bShowDetail = false;
42 CPPUNIT_ASSERT(xItem->getPropertyValue(propNameSD) >>= bShowDetail);
43 CPPUNIT_ASSERT_MESSAGE("Default ShowDetail already changed", bShowDetail);
44
45 uno::Any aNewShowDetail;
46 aNewShowDetail <<= true;
47 xItem->setPropertyValue(propNameSD, aNewShowDetail);
48 CPPUNIT_ASSERT(xItem->getPropertyValue(propNameSD) >>= bShowDetail);
49 CPPUNIT_ASSERT_MESSAGE("Value of ShowDetail wasn't changed", bShowDetail);
50
51 sal_Int32 nPosition = 42;
52 CPPUNIT_ASSERT(xItem->getPropertyValue("Position") >>= nPosition);
53 CPPUNIT_ASSERT_EQUAL_MESSAGE("Default Position already changed", sal_Int32(0), nPosition);
54
55 // FIXME: This throws somehow a com.sun.star.lang.IllegalArgumentException
56 //uno::Any aNewPosition;
57 //aNewPosition <<= static_cast<sal_Int32>(42);
58 //xItem->setPropertyValue(propNameP, aNewPosition);
59 //CPPUNIT_ASSERT(xItem->getPropertyValue(propNameP) >>= nPosition);
60 //CPPUNIT_ASSERT_EQUAL_MESSAGE("Value of Position wasn't changed", sal_Int32(42), nPosition);
61}
62}
63
64/* vim:set shiftwidth=4 softtabstop=4 expandtab cinoptions=b1,g0,N-s cinkeys+=0=break: */
virtual css::uno::Reference< css::uno::XInterface > init()=0
float u