LibreOffice Module test (master) 1
functiondescription.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
10#include <vector>
11
13
14#include <com/sun/star/beans/PropertyValue.hpp>
15#include <com/sun/star/sheet/FunctionArgument.hpp>
16
17#include <cppunit/TestAssert.h>
18
19using namespace com::sun::star;
20using namespace com::sun::star::uno;
21
22namespace apitest
23{
25{
26 const uno::Sequence<beans::PropertyValue> aFunctionDescription(init());
27
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)
33 {
34 if (value.Name == "Id")
35 {
36 names.push_back(value.Name);
37 sal_Int32 nValue = 0;
38 CPPUNIT_ASSERT(value.Value >>= nValue);
39 }
40 else if (value.Name == "Category")
41 {
42 names.push_back(value.Name);
43 sal_Int32 nValue = 0;
44 CPPUNIT_ASSERT(value.Value >>= nValue);
45 }
46 else if (value.Name == "Name")
47 {
48 names.push_back(value.Name);
49 OUString sValue;
50 CPPUNIT_ASSERT(value.Value >>= sValue);
51 }
52 else if (value.Name == "Description")
53 {
54 names.push_back(value.Name);
55 OUString sValue;
56 CPPUNIT_ASSERT(value.Value >>= sValue);
57 }
58 else if (value.Name == "Arguments")
59 {
60 names.push_back(value.Name);
61 uno::Sequence<sheet::FunctionArgument> sArguments;
62 CPPUNIT_ASSERT(value.Value >>= sArguments);
63 }
64 else
65 {
66 OString aMsg = "Unsupported PropertyValue: "
67 + OUStringToOString(value.Name, RTL_TEXTENCODING_UTF8);
68 CPPUNIT_FAIL(aMsg.getStr());
69 }
70 }
71
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"));
82}
83} // namespace apitest
84
85/* vim:set shiftwidth=4 softtabstop=4 expandtab cinoptions=b1,g0,N-s cinkeys+=0=break: */
virtual css::uno::Sequence< css::beans::PropertyValue > init()=0
Any value
sal_Int16 nValue
OString OUStringToOString(std::u16string_view str, ConnectionSettings const *settings)