1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
|
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4; fill-column: 100 -*- */
/*
* This file is part of the LibreOffice project.
*
* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/.
*/
//#include <test/cppunitasserthelper.hxx>
#include <test/sheet/sheetsortdescriptor2.hxx>
#include <com/sun/star/beans/PropertyValue.hpp>
#include <com/sun/star/util/XSortable.hpp>
#include <com/sun/star/table/CellAddress.hpp>
#include <com/sun/star/table/TableSortField.hpp>
#include <com/sun/star/uno/Reference.hxx>
#include <com/sun/star/uno/Sequence.hxx>
#include <cppunit/TestAssert.h>
#include <vector>
using namespace com::sun::star;
using namespace com::sun::star::uno;
namespace apitest
{
void SheetSortDescriptor2::testSheetSortDescriptor2Properties()
{
uno::Reference<util::XSortable> xSortable(init(), UNO_QUERY_THROW);
const uno::Sequence<beans::PropertyValue> values = xSortable->createSortDescriptor();
std::vector<OUString> names;
// Only test the get/read operation of the values, because set/write operation doesn't
// make any sense. It doesn't trigger any changes.
// See discussion: nabble.documentfoundation.org/Testing-UNO-API-service-properties-td4236286.html.
for (const auto& value : values)
{
if (value.Name == "BindFormatsToContent")
{
names.push_back(value.Name);
bool bValue = false;
CPPUNIT_ASSERT(value.Value >>= bValue);
}
else if (value.Name == "IsUserListEnabled")
{
names.push_back(value.Name);
bool bValue = false;
CPPUNIT_ASSERT(value.Value >>= bValue);
}
else if (value.Name == "UserListIndex")
{
names.push_back(value.Name);
sal_Int32 nValue = 0;
CPPUNIT_ASSERT(value.Value >>= nValue);
}
else if (value.Name == "CopyOutputData")
{
names.push_back(value.Name);
bool bValue = false;
CPPUNIT_ASSERT(value.Value >>= bValue);
}
else if (value.Name == "OutputPosition")
{
names.push_back(value.Name);
table::CellAddress cellAddr;
CPPUNIT_ASSERT(value.Value >>= cellAddr);
}
else if (value.Name == "SortFields")
{
names.push_back(value.Name);
uno::Sequence<table::TableSortField> sSortFields;
CPPUNIT_ASSERT(value.Value >>= sSortFields);
}
else if (value.Name == "MaxFieldCount")
{
names.push_back(value.Name);
sal_Int32 nValue = 0;
CPPUNIT_ASSERT(value.Value >>= nValue);
}
else if (value.Name == "IsSortColumns")
{
names.push_back(value.Name);
bool bValue = false;
CPPUNIT_ASSERT(value.Value >>= bValue);
}
else if (value.Name == "ContainsHeader")
{
names.push_back(value.Name);
bool bValue = false;
CPPUNIT_ASSERT(value.Value >>= bValue);
}
else
{
OString sMsg = "Unsupported PropertyValue: "
+ OUStringToOString(value.Name, RTL_TEXTENCODING_UTF8);
CPPUNIT_FAIL(sMsg.getStr());
}
}
CPPUNIT_ASSERT_MESSAGE("Property BindFormatsToContent not found",
std::count(std::begin(names), std::end(names), "BindFormatsToContent"));
CPPUNIT_ASSERT_MESSAGE("Property IsUserListEnabled not found",
std::count(std::begin(names), std::end(names), "IsUserListEnabled"));
CPPUNIT_ASSERT_MESSAGE("Property UserListIndex not found",
std::count(std::begin(names), std::end(names), "UserListIndex"));
CPPUNIT_ASSERT_MESSAGE("Property CopyOutputData not found",
std::count(std::begin(names), std::end(names), "CopyOutputData"));
CPPUNIT_ASSERT_MESSAGE("Property OutputPosition not found",
std::count(std::begin(names), std::end(names), "OutputPosition"));
CPPUNIT_ASSERT_MESSAGE("Property SortFields not found",
std::count(std::begin(names), std::end(names), "SortFields"));
CPPUNIT_ASSERT_MESSAGE("Property MaxFieldCount not found",
std::count(std::begin(names), std::end(names), "MaxFieldCount"));
CPPUNIT_ASSERT_MESSAGE("Property IsSortColumns not found",
std::count(std::begin(names), std::end(names), "IsSortColumns"));
CPPUNIT_ASSERT_MESSAGE("Property ContainsHeader not found",
std::count(std::begin(names), std::end(names), "ContainsHeader"));
}
} // namespace apitest
/* vim:set shiftwidth=4 softtabstop=4 expandtab cinoptions=b1,g0,N-s cinkeys+=0=break: */
|