1
/****************************************************************************
2
**
3
** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
4
** All rights reserved.
5
** Contact: Nokia Corporation (qt-info@nokia.com)
6
**
7
** This file is part of the test suite of the Qt Toolkit.
8
**
9
** $QT_BEGIN_LICENSE:LGPL$
10
** GNU Lesser General Public License Usage
11
** This file may be used under the terms of the GNU Lesser General Public
12
** License version 2.1 as published by the Free Software Foundation and
13
** appearing in the file LICENSE.LGPL included in the packaging of this
14
** file. Please review the following information to ensure the GNU Lesser
15
** General Public License version 2.1 requirements will be met:
16
** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
17
**
18
** In addition, as a special exception, Nokia gives you certain additional
19
** rights. These rights are described in the Nokia Qt LGPL Exception
20
** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
21
**
22
** GNU General Public License Usage
23
** Alternatively, this file may be used under the terms of the GNU General
24
** Public License version 3.0 as published by the Free Software Foundation
25
** and appearing in the file LICENSE.GPL included in the packaging of this
26
** file. Please review the following information to ensure the GNU General
27
** Public License version 3.0 requirements will be met:
28
** http://www.gnu.org/copyleft/gpl.html.
29
**
30
** Other Usage
31
** Alternatively, this file may be used in accordance with the terms and
32
** conditions contained in a signed written agreement between you and Nokia.
33
**
34
**
35
**
36
**
37
**
38
** $QT_END_LICENSE$
39
**
40
****************************************************************************/
41
42
43
#include <QtTest/QtTest>
44
#include <qapplication.h>
45
#include <qdebug.h>
46
#include <q3stylesheet.h>
47
48
//TESTED_CLASS=
49
//TESTED_FILES=
50
51
class tst_Q3StyleSheet : public QObject
52
{
53
Q_OBJECT
54
55
public:
56
    tst_Q3StyleSheet();
57
    virtual ~tst_Q3StyleSheet();
58
59
private slots:
60
    void getSetCheck();
61
};
62
63
tst_Q3StyleSheet::tst_Q3StyleSheet()
64
{
65
}
66
67
tst_Q3StyleSheet::~tst_Q3StyleSheet()
68
{
69
}
70
71
// Testing get/set functions
72
void tst_Q3StyleSheet::getSetCheck()
73
{
74
    Q3StyleSheet ss;
75
    Q3StyleSheetItem *obj1 = new Q3StyleSheetItem(&ss, "Stylesheet Item");
76
    // DisplayMode Q3StyleSheetItem::displayMode()
77
    // void Q3StyleSheetItem::setDisplayMode(DisplayMode)
78
    obj1->setDisplayMode(Q3StyleSheetItem::DisplayMode(Q3StyleSheetItem::DisplayInline));
79
    QCOMPARE(obj1->displayMode(), Q3StyleSheetItem::DisplayMode(Q3StyleSheetItem::DisplayInline));
80
    obj1->setDisplayMode(Q3StyleSheetItem::DisplayMode(Q3StyleSheetItem::DisplayListItem));
81
    QCOMPARE(obj1->displayMode(), Q3StyleSheetItem::DisplayMode(Q3StyleSheetItem::DisplayListItem));
82
    obj1->setDisplayMode(Q3StyleSheetItem::DisplayMode(Q3StyleSheetItem::DisplayNone));
83
    QCOMPARE(obj1->displayMode(), Q3StyleSheetItem::DisplayMode(Q3StyleSheetItem::DisplayNone));
84
    obj1->setDisplayMode(Q3StyleSheetItem::DisplayMode(Q3StyleSheetItem::DisplayBlock));
85
    QCOMPARE(obj1->displayMode(), Q3StyleSheetItem::DisplayMode(Q3StyleSheetItem::DisplayBlock));
86
87
    // int Q3StyleSheetItem::alignment()
88
    // void Q3StyleSheetItem::setAlignment(int)
89
    obj1->setAlignment(0);
90
    QCOMPARE(obj1->alignment(), 0);
91
    obj1->setAlignment(INT_MIN);
92
    QCOMPARE(obj1->alignment(), INT_MIN);
93
    obj1->setAlignment(INT_MAX);
94
    QCOMPARE(obj1->alignment(), INT_MAX);
95
96
    // VerticalAlignment Q3StyleSheetItem::verticalAlignment()
97
    // void Q3StyleSheetItem::setVerticalAlignment(VerticalAlignment)
98
    obj1->setVerticalAlignment(Q3StyleSheetItem::VerticalAlignment(Q3StyleSheetItem::VAlignBaseline));
99
    QCOMPARE(obj1->verticalAlignment(), Q3StyleSheetItem::VerticalAlignment(Q3StyleSheetItem::VAlignBaseline));
100
    obj1->setVerticalAlignment(Q3StyleSheetItem::VerticalAlignment(Q3StyleSheetItem::VAlignSub));
101
    QCOMPARE(obj1->verticalAlignment(), Q3StyleSheetItem::VerticalAlignment(Q3StyleSheetItem::VAlignSub));
102
    obj1->setVerticalAlignment(Q3StyleSheetItem::VerticalAlignment(Q3StyleSheetItem::VAlignSuper));
103
    QCOMPARE(obj1->verticalAlignment(), Q3StyleSheetItem::VerticalAlignment(Q3StyleSheetItem::VAlignSuper));
104
105
    // int Q3StyleSheetItem::fontWeight()
106
    // void Q3StyleSheetItem::setFontWeight(int)
107
    obj1->setFontWeight(0);
108
    QCOMPARE(obj1->fontWeight(), 0);
109
    obj1->setFontWeight(INT_MIN);
110
    // Should return 0, but we cannot change this behavior in a Qt3Support class.
111
    QCOMPARE(obj1->fontWeight(), INT_MIN); // Range<0, 99>
112
    obj1->setFontWeight(INT_MAX);
113
    // Should return 99, but we cannot change this behavior in a Qt3Support class.
114
    QCOMPARE(obj1->fontWeight(), INT_MAX); // Range<0, 99>
115
116
    // int Q3StyleSheetItem::logicalFontSize()
117
    // void Q3StyleSheetItem::setLogicalFontSize(int)
118
    obj1->setLogicalFontSize(0);
119
    // Should return 1, but we cannot change this behavior in a Qt3Support class.
120
    QCOMPARE(obj1->logicalFontSize(), 0); // Range<1, 7>
121
    obj1->setLogicalFontSize(INT_MIN);
122
    // Should return 1, but we cannot change this behavior in a Qt3Support class.
123
    QCOMPARE(obj1->logicalFontSize(), INT_MIN); // Range<1, 7>
124
    obj1->setLogicalFontSize(INT_MAX);
125
    // Should return 7, but we cannot change this behavior in a Qt3Support class.
126
    QCOMPARE(obj1->logicalFontSize(), INT_MAX);  // Range<1, 7>
127
128
    // int Q3StyleSheetItem::logicalFontSizeStep()
129
    // void Q3StyleSheetItem::setLogicalFontSizeStep(int)
130
    obj1->setLogicalFontSizeStep(0);
131
    QCOMPARE(obj1->logicalFontSizeStep(), 0);
132
    obj1->setLogicalFontSizeStep(INT_MIN);
133
    QCOMPARE(obj1->logicalFontSizeStep(), INT_MIN);
134
    obj1->setLogicalFontSizeStep(INT_MAX);
135
    QCOMPARE(obj1->logicalFontSizeStep(), INT_MAX);
136
137
    // int Q3StyleSheetItem::fontSize()
138
    // void Q3StyleSheetItem::setFontSize(int)
139
    obj1->setFontSize(0);
140
    QCOMPARE(obj1->fontSize(), 0);
141
    obj1->setFontSize(INT_MIN);
142
    // Should return -1, but we cannot change this behavior in a Qt3Support class.
143
    QCOMPARE(obj1->fontSize(), INT_MIN); // Expect an undefined return value for non-valid point size, as per docs
144
    obj1->setFontSize(INT_MAX);
145
    QCOMPARE(obj1->fontSize(), INT_MAX);
146
147
    // int Q3StyleSheetItem::numberOfColumns()
148
    // void Q3StyleSheetItem::setNumberOfColumns(int)
149
    int currentNumCols = obj1->numberOfColumns();
150
    obj1->setNumberOfColumns(0);
151
    QCOMPARE(obj1->numberOfColumns(), currentNumCols); // Can't set 0 column count
152
    obj1->setNumberOfColumns(INT_MIN);
153
    QCOMPARE(obj1->numberOfColumns(), currentNumCols); // Can't set negative column count
154
    obj1->setNumberOfColumns(INT_MAX);
155
    QCOMPARE(obj1->numberOfColumns(), INT_MAX);
156
157
    // WhiteSpaceMode Q3StyleSheetItem::whiteSpaceMode()
158
    // void Q3StyleSheetItem::setWhiteSpaceMode(WhiteSpaceMode)
159
    obj1->setWhiteSpaceMode(Q3StyleSheetItem::WhiteSpaceMode(Q3StyleSheetItem::WhiteSpaceNormal));
160
    QCOMPARE(obj1->whiteSpaceMode(), Q3StyleSheetItem::WhiteSpaceMode(Q3StyleSheetItem::WhiteSpaceNormal));
161
    obj1->setWhiteSpaceMode(Q3StyleSheetItem::WhiteSpaceMode(Q3StyleSheetItem::WhiteSpacePre));
162
    QCOMPARE(obj1->whiteSpaceMode(), Q3StyleSheetItem::WhiteSpaceMode(Q3StyleSheetItem::WhiteSpacePre));
163
    obj1->setWhiteSpaceMode(Q3StyleSheetItem::WhiteSpaceMode(Q3StyleSheetItem::WhiteSpaceNoWrap));
164
    QCOMPARE(obj1->whiteSpaceMode(), Q3StyleSheetItem::WhiteSpaceMode(Q3StyleSheetItem::WhiteSpaceNoWrap));
165
166
    // int Q3StyleSheetItem::lineSpacing()
167
    // void Q3StyleSheetItem::setLineSpacing(int)
168
    obj1->setLineSpacing(0);
169
    QCOMPARE(obj1->lineSpacing(), 0);
170
    obj1->setLineSpacing(INT_MIN);
171
    // Should return -1, but we cannot change this behavior in a Qt3Support class.
172
    QCOMPARE(obj1->lineSpacing(), INT_MIN); // Should not be able to set negative line spacing(?)
173
    obj1->setLineSpacing(INT_MAX);
174
    QCOMPARE(obj1->lineSpacing(), INT_MAX);
175
}
176
177
QTEST_MAIN(tst_Q3StyleSheet)
178
#include "tst_q3stylesheet.moc"