LibreOffice Module test (master) 1
sheetsortdescriptor2.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 <test/cppunitasserthelper.hxx>
12
13#include <com/sun/star/beans/PropertyValue.hpp>
14#include <com/sun/star/util/XSortable.hpp>
15#include <com/sun/star/table/CellAddress.hpp>
16#include <com/sun/star/table/TableSortField.hpp>
17#include <com/sun/star/uno/Reference.hxx>
18#include <com/sun/star/uno/Sequence.hxx>
19
20#include <cppunit/TestAssert.h>
21
22#include <vector>
23
24using namespace com::sun::star;
25using namespace com::sun::star::uno;
26
27namespace apitest
28{
30{
31 uno::Reference<util::XSortable> xSortable(init(), UNO_QUERY_THROW);
32 const uno::Sequence<beans::PropertyValue> values = xSortable->createSortDescriptor();
33
34 std::vector<OUString> names;
35 // Only test the get/read operation of the values, because set/write operation doesn't
36 // make any sense. It doesn't trigger any changes.
37 // See discussion: nabble.documentfoundation.org/Testing-UNO-API-service-properties-td4236286.html.
38 for (const auto& value : values)
39 {
40 if (value.Name == "BindFormatsToContent")
41 {
42 names.push_back(value.Name);
43 bool bValue = false;
44 CPPUNIT_ASSERT(value.Value >>= bValue);
45 }
46 else if (value.Name == "IsUserListEnabled")
47 {
48 names.push_back(value.Name);
49 bool bValue = false;
50 CPPUNIT_ASSERT(value.Value >>= bValue);
51 }
52 else if (value.Name == "UserListIndex")
53 {
54 names.push_back(value.Name);
55 sal_Int32 nValue = 0;
56 CPPUNIT_ASSERT(value.Value >>= nValue);
57 }
58 else if (value.Name == "CopyOutputData")
59 {
60 names.push_back(value.Name);
61 bool bValue = false;
62 CPPUNIT_ASSERT(value.Value >>= bValue);
63 }
64 else if (value.Name == "OutputPosition")
65 {
66 names.push_back(value.Name);
67 table::CellAddress cellAddr;
68 CPPUNIT_ASSERT(value.Value >>= cellAddr);
69 }
70 else if (value.Name == "SortFields")
71 {
72 names.push_back(value.Name);
73 uno::Sequence<table::TableSortField> sSortFields;
74 CPPUNIT_ASSERT(value.Value >>= sSortFields);
75 }
76 else if (value.Name == "MaxFieldCount")
77 {
78 names.push_back(value.Name);
79 sal_Int32 nValue = 0;
80 CPPUNIT_ASSERT(value.Value >>= nValue);
81 }
82 else if (value.Name == "IsSortColumns")
83 {
84 names.push_back(value.Name);
85 bool bValue = false;
86 CPPUNIT_ASSERT(value.Value >>= bValue);
87 }
88 else if (value.Name == "ContainsHeader")
89 {
90 names.push_back(value.Name);
91 bool bValue = false;
92 CPPUNIT_ASSERT(value.Value >>= bValue);
93 }
94 else
95 {
96 OString sMsg = "Unsupported PropertyValue: "
97 + OUStringToOString(value.Name, RTL_TEXTENCODING_UTF8);
98 CPPUNIT_FAIL(sMsg.getStr());
99 }
100 }
101
102 CPPUNIT_ASSERT_MESSAGE("Property BindFormatsToContent not found",
103 std::count(std::begin(names), std::end(names), "BindFormatsToContent"));
104 CPPUNIT_ASSERT_MESSAGE("Property IsUserListEnabled not found",
105 std::count(std::begin(names), std::end(names), "IsUserListEnabled"));
106 CPPUNIT_ASSERT_MESSAGE("Property UserListIndex not found",
107 std::count(std::begin(names), std::end(names), "UserListIndex"));
108 CPPUNIT_ASSERT_MESSAGE("Property CopyOutputData not found",
109 std::count(std::begin(names), std::end(names), "CopyOutputData"));
110 CPPUNIT_ASSERT_MESSAGE("Property OutputPosition not found",
111 std::count(std::begin(names), std::end(names), "OutputPosition"));
112 CPPUNIT_ASSERT_MESSAGE("Property SortFields not found",
113 std::count(std::begin(names), std::end(names), "SortFields"));
114 CPPUNIT_ASSERT_MESSAGE("Property MaxFieldCount not found",
115 std::count(std::begin(names), std::end(names), "MaxFieldCount"));
116 CPPUNIT_ASSERT_MESSAGE("Property IsSortColumns not found",
117 std::count(std::begin(names), std::end(names), "IsSortColumns"));
118 CPPUNIT_ASSERT_MESSAGE("Property ContainsHeader not found",
119 std::count(std::begin(names), std::end(names), "ContainsHeader"));
120}
121} // namespace apitest
122
123/* vim:set shiftwidth=4 softtabstop=4 expandtab cinoptions=b1,g0,N-s cinkeys+=0=break: */
virtual css::uno::Reference< css::uno::XInterface > init()=0
Any value
sal_Int16 nValue
OString OUStringToOString(std::u16string_view str, ConnectionSettings const *settings)
std::vector< char * > values