1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4; fill-column: 100 -*- */
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/.
12 #include <test/sheet/functiondescription.hxx>
14 #include <com/sun/star/beans/PropertyValue.hpp>
15 #include <com/sun/star/sheet/FunctionArgument.hpp>
17 #include <cppunit/TestAssert.h>
19 using namespace com::sun::star
;
20 using namespace com::sun::star::uno
;
24 void FunctionDescription::testFunctionDescriptionProperties()
26 const uno::Sequence
<beans::PropertyValue
> aFunctionDescription(init());
28 std::vector
<OUString
> names
;
29 // Only test the get/read operation of the values, because set/write operation doesn't
30 // make any sense. It doesn't trigger any changes.
31 // See discussion: nabble.documentfoundation.org/Testing-UNO-API-service-properties-td4236286.html.
32 for (const auto& value
: aFunctionDescription
)
34 if (value
.Name
== "Id")
36 names
.push_back(value
.Name
);
38 CPPUNIT_ASSERT(value
.Value
>>= nValue
);
40 else if (value
.Name
== "Category")
42 names
.push_back(value
.Name
);
44 CPPUNIT_ASSERT(value
.Value
>>= nValue
);
46 else if (value
.Name
== "Name")
48 names
.push_back(value
.Name
);
50 CPPUNIT_ASSERT(value
.Value
>>= sValue
);
52 else if (value
.Name
== "Description")
54 names
.push_back(value
.Name
);
56 CPPUNIT_ASSERT(value
.Value
>>= sValue
);
58 else if (value
.Name
== "Arguments")
60 names
.push_back(value
.Name
);
61 uno::Sequence
<sheet::FunctionArgument
> sArguments
;
62 CPPUNIT_ASSERT(value
.Value
>>= sArguments
);
66 OString aMsg
= "Unsupported PropertyValue: "
67 + OUStringToOString(value
.Name
, RTL_TEXTENCODING_UTF8
);
68 CPPUNIT_FAIL(aMsg
.getStr());
72 CPPUNIT_ASSERT_MESSAGE("Property Id not found",
73 std::count(std::begin(names
), std::end(names
), "Id"));
74 CPPUNIT_ASSERT_MESSAGE("Property Category not found",
75 std::count(std::begin(names
), std::end(names
), "Category"));
76 CPPUNIT_ASSERT_MESSAGE("Property Name not found",
77 std::count(std::begin(names
), std::end(names
), "Name"));
78 CPPUNIT_ASSERT_MESSAGE("Property Description not found",
79 std::count(std::begin(names
), std::end(names
), "Description"));
80 CPPUNIT_ASSERT_MESSAGE("Property Arguments not found",
81 std::count(std::begin(names
), std::end(names
), "Arguments"));
83 } // namespace apitest
85 /* vim:set shiftwidth=4 softtabstop=4 expandtab cinoptions=b1,g0,N-s cinkeys+=0=break: */