bump product version to 6.4.0.3
[LibreOffice.git] / test / source / sheet / sheetsortdescriptor2.cxx
blob85ca8706cd4c90b2963a9541dd01f66357f1046b
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.
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 */
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/extensions/HelperMacros.h>
22 using namespace com::sun::star;
23 using namespace com::sun::star::uno;
25 namespace apitest
27 void SheetSortDescriptor2::testSheetSortDescriptor2Properties()
29 uno::Reference<util::XSortable> xSortable(init(), UNO_QUERY_THROW);
30 const uno::Sequence<beans::PropertyValue> values = xSortable->createSortDescriptor();
32 std::vector<OUString> names;
33 // Only test the get/read operation of the values, because set/write operation doesn't
34 // make any sense. It doesn't trigger any changes.
35 // See discussion: nabble.documentfoundation.org/Testing-UNO-API-service-properties-td4236286.html.
36 for (const auto& value : values)
38 if (value.Name == "BindFormatsToContent")
40 names.push_back(value.Name);
41 bool bValue = false;
42 CPPUNIT_ASSERT(value.Value >>= bValue);
44 else if (value.Name == "IsUserListEnabled")
46 names.push_back(value.Name);
47 bool bValue = false;
48 CPPUNIT_ASSERT(value.Value >>= bValue);
50 else if (value.Name == "UserListIndex")
52 names.push_back(value.Name);
53 sal_Int32 nValue = 0;
54 CPPUNIT_ASSERT(value.Value >>= nValue);
56 else if (value.Name == "CopyOutputData")
58 names.push_back(value.Name);
59 bool bValue = false;
60 CPPUNIT_ASSERT(value.Value >>= bValue);
62 else if (value.Name == "OutputPosition")
64 names.push_back(value.Name);
65 table::CellAddress cellAddr;
66 CPPUNIT_ASSERT(value.Value >>= cellAddr);
68 else if (value.Name == "SortFields")
70 names.push_back(value.Name);
71 uno::Sequence<table::TableSortField> sSortFields;
72 CPPUNIT_ASSERT(value.Value >>= sSortFields);
74 else if (value.Name == "MaxFieldCount")
76 names.push_back(value.Name);
77 sal_Int32 nValue = 0;
78 CPPUNIT_ASSERT(value.Value >>= nValue);
80 else if (value.Name == "IsSortColumns")
82 names.push_back(value.Name);
83 bool bValue = false;
84 CPPUNIT_ASSERT(value.Value >>= bValue);
86 else if (value.Name == "ContainsHeader")
88 names.push_back(value.Name);
89 bool bValue = false;
90 CPPUNIT_ASSERT(value.Value >>= bValue);
92 else
94 OString sMsg = "Unsupported PropertyValue: "
95 + OUStringToOString(value.Name, RTL_TEXTENCODING_UTF8);
96 CPPUNIT_FAIL(sMsg.getStr());
100 CPPUNIT_ASSERT_MESSAGE("Property BindFormatsToContent not found",
101 std::count(std::begin(names), std::end(names), "BindFormatsToContent"));
102 CPPUNIT_ASSERT_MESSAGE("Property IsUserListEnabled not found",
103 std::count(std::begin(names), std::end(names), "IsUserListEnabled"));
104 CPPUNIT_ASSERT_MESSAGE("Property UserListIndex not found",
105 std::count(std::begin(names), std::end(names), "UserListIndex"));
106 CPPUNIT_ASSERT_MESSAGE("Property CopyOutputData not found",
107 std::count(std::begin(names), std::end(names), "CopyOutputData"));
108 CPPUNIT_ASSERT_MESSAGE("Property OutputPosition not found",
109 std::count(std::begin(names), std::end(names), "OutputPosition"));
110 CPPUNIT_ASSERT_MESSAGE("Property SortFields not found",
111 std::count(std::begin(names), std::end(names), "SortFields"));
112 CPPUNIT_ASSERT_MESSAGE("Property MaxFieldCount not found",
113 std::count(std::begin(names), std::end(names), "MaxFieldCount"));
114 CPPUNIT_ASSERT_MESSAGE("Property IsSortColumns not found",
115 std::count(std::begin(names), std::end(names), "IsSortColumns"));
116 CPPUNIT_ASSERT_MESSAGE("Property ContainsHeader not found",
117 std::count(std::begin(names), std::end(names), "ContainsHeader"));
119 } // namespace apitest
121 /* vim:set shiftwidth=4 softtabstop=4 expandtab cinoptions=b1,g0,N-s cinkeys+=0=break: */