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/.
10 //#include <test/cppunitasserthelper.hxx>
11 #include <test/sheet/sheetsortdescriptor2.hxx>
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>
20 #include <cppunit/TestAssert.h>
24 using namespace com::sun::star
;
25 using namespace com::sun::star::uno
;
29 void SheetSortDescriptor2::testSheetSortDescriptor2Properties()
31 uno::Reference
<util::XSortable
> xSortable(init(), UNO_QUERY_THROW
);
32 const uno::Sequence
<beans::PropertyValue
> values
= xSortable
->createSortDescriptor();
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
)
40 if (value
.Name
== "BindFormatsToContent")
42 names
.push_back(value
.Name
);
44 CPPUNIT_ASSERT(value
.Value
>>= bValue
);
46 else if (value
.Name
== "IsUserListEnabled")
48 names
.push_back(value
.Name
);
50 CPPUNIT_ASSERT(value
.Value
>>= bValue
);
52 else if (value
.Name
== "UserListIndex")
54 names
.push_back(value
.Name
);
56 CPPUNIT_ASSERT(value
.Value
>>= nValue
);
58 else if (value
.Name
== "CopyOutputData")
60 names
.push_back(value
.Name
);
62 CPPUNIT_ASSERT(value
.Value
>>= bValue
);
64 else if (value
.Name
== "OutputPosition")
66 names
.push_back(value
.Name
);
67 table::CellAddress cellAddr
;
68 CPPUNIT_ASSERT(value
.Value
>>= cellAddr
);
70 else if (value
.Name
== "SortFields")
72 names
.push_back(value
.Name
);
73 uno::Sequence
<table::TableSortField
> sSortFields
;
74 CPPUNIT_ASSERT(value
.Value
>>= sSortFields
);
76 else if (value
.Name
== "MaxFieldCount")
78 names
.push_back(value
.Name
);
80 CPPUNIT_ASSERT(value
.Value
>>= nValue
);
82 else if (value
.Name
== "IsSortColumns")
84 names
.push_back(value
.Name
);
86 CPPUNIT_ASSERT(value
.Value
>>= bValue
);
88 else if (value
.Name
== "ContainsHeader")
90 names
.push_back(value
.Name
);
92 CPPUNIT_ASSERT(value
.Value
>>= bValue
);
96 OString sMsg
= "Unsupported PropertyValue: "
97 + OUStringToOString(value
.Name
, RTL_TEXTENCODING_UTF8
);
98 CPPUNIT_FAIL(sMsg
.getStr());
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"));
121 } // namespace apitest
123 /* vim:set shiftwidth=4 softtabstop=4 expandtab cinoptions=b1,g0,N-s cinkeys+=0=break: */