summaryrefslogtreecommitdiff
path: root/test/source/sheet/xconsolidationdescriptor.cxx
blob: 45ba69877eb46aa3cc1450783eb0c4e5aa30163f (plain)
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
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
/* -*- 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/sheet/xconsolidationdescriptor.hxx>
#include <test/cppunitasserthelper.hxx>

#include <com/sun/star/sheet/GeneralFunction.hpp>
#include <com/sun/star/sheet/XConsolidationDescriptor.hpp>
#include <com/sun/star/table/CellAddress.hpp>
#include <com/sun/star/table/CellRangeAddress.hpp>
#include <com/sun/star/uno/Reference.hxx>
#include <com/sun/star/uno/Sequence.hxx>

#include <cppunit/TestAssert.h>

using namespace css;
using namespace css::uno;

namespace apitest
{
void XConsolidationDescriptor::testGetFunction()
{
    uno::Reference<sheet::XConsolidationDescriptor> xConsolidationDescriptor(init(),
                                                                             UNO_QUERY_THROW);

    CPPUNIT_ASSERT_EQUAL_MESSAGE("Unable to get function", sheet::GeneralFunction_SUM,
                                 xConsolidationDescriptor->getFunction());
}

void XConsolidationDescriptor::testSetFunction()
{
    uno::Reference<sheet::XConsolidationDescriptor> xConsolidationDescriptor(init(),
                                                                             UNO_QUERY_THROW);

    xConsolidationDescriptor->setFunction(sheet::GeneralFunction_COUNT);
    CPPUNIT_ASSERT_EQUAL_MESSAGE("Unable to set function", sheet::GeneralFunction_COUNT,
                                 xConsolidationDescriptor->getFunction());
}

void XConsolidationDescriptor::testGetSources()
{
    uno::Reference<sheet::XConsolidationDescriptor> xConsolidationDescriptor(init(),
                                                                             UNO_QUERY_THROW);

    uno::Sequence<table::CellRangeAddress> aSources = xConsolidationDescriptor->getSources();
    CPPUNIT_ASSERT_MESSAGE("Unable to get sources", !aSources.hasElements());
}

void XConsolidationDescriptor::testSetSources()
{
    uno::Reference<sheet::XConsolidationDescriptor> xConsolidationDescriptor(init(),
                                                                             UNO_QUERY_THROW);

    uno::Sequence<table::CellRangeAddress> aSources{ table::CellRangeAddress(0, 1, 1, 5, 5) };
    xConsolidationDescriptor->setSources(aSources);
    CPPUNIT_ASSERT_EQUAL_MESSAGE("Unable to set sources", table::CellRangeAddress(0, 1, 1, 5, 5),
                                 xConsolidationDescriptor->getSources()[0]);
}

void XConsolidationDescriptor::testGetStartOutputPosition()
{
    uno::Reference<sheet::XConsolidationDescriptor> xConsolidationDescriptor(init(),
                                                                             UNO_QUERY_THROW);

    CPPUNIT_ASSERT_EQUAL_MESSAGE("Unable to get start output position", table::CellAddress(0, 0, 0),
                                 xConsolidationDescriptor->getStartOutputPosition());
}

void XConsolidationDescriptor::testSetStartOutputPosition()
{
    uno::Reference<sheet::XConsolidationDescriptor> xConsolidationDescriptor(init(),
                                                                             UNO_QUERY_THROW);

    xConsolidationDescriptor->setStartOutputPosition(table::CellAddress(0, 1, 2));
    CPPUNIT_ASSERT_EQUAL_MESSAGE("Unable to set start output position", table::CellAddress(0, 1, 2),
                                 xConsolidationDescriptor->getStartOutputPosition());
}

void XConsolidationDescriptor::testGetUseColumnHeaders()
{
    uno::Reference<sheet::XConsolidationDescriptor> xConsolidationDescriptor(init(),
                                                                             UNO_QUERY_THROW);

    CPPUNIT_ASSERT_MESSAGE("Unable to get use column headers",
                           !xConsolidationDescriptor->getUseColumnHeaders());
}

void XConsolidationDescriptor::testSetUseColumnHeaders()
{
    uno::Reference<sheet::XConsolidationDescriptor> xConsolidationDescriptor(init(),
                                                                             UNO_QUERY_THROW);

    xConsolidationDescriptor->setUseColumnHeaders(true);
    CPPUNIT_ASSERT_MESSAGE("Unable to set use column headers",
                           xConsolidationDescriptor->getUseColumnHeaders());
}

void XConsolidationDescriptor::testGetUseRowHeaders()
{
    uno::Reference<sheet::XConsolidationDescriptor> xConsolidationDescriptor(init(),
                                                                             UNO_QUERY_THROW);

    CPPUNIT_ASSERT_MESSAGE("Unable to get use row headers",
                           !xConsolidationDescriptor->getUseRowHeaders());
}

void XConsolidationDescriptor::testSetUseRowHeaders()
{
    uno::Reference<sheet::XConsolidationDescriptor> xConsolidationDescriptor(init(),
                                                                             UNO_QUERY_THROW);

    xConsolidationDescriptor->setUseRowHeaders(true);
    CPPUNIT_ASSERT_MESSAGE("Unable to set use row headers",
                           xConsolidationDescriptor->getUseRowHeaders());
}

void XConsolidationDescriptor::testGetInsertLinks()
{
    uno::Reference<sheet::XConsolidationDescriptor> xConsolidationDescriptor(init(),
                                                                             UNO_QUERY_THROW);

    CPPUNIT_ASSERT_MESSAGE("Unable to get use insert links",
                           !xConsolidationDescriptor->getInsertLinks());
}

void XConsolidationDescriptor::testSetInsertLinks()
{
    uno::Reference<sheet::XConsolidationDescriptor> xConsolidationDescriptor(init(),
                                                                             UNO_QUERY_THROW);

    xConsolidationDescriptor->setInsertLinks(true);
    CPPUNIT_ASSERT_MESSAGE("Unable to set use insert links",
                           xConsolidationDescriptor->getInsertLinks());
}
}

/* vim:set shiftwidth=4 softtabstop=4 expandtab cinoptions=b1,g0,N-s cinkeys+=0=break: */