0
|
1 |
/****************************************************************************
|
|
2 |
**
|
|
3 |
** Copyright (C) 2009 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 |
** No Commercial Usage
|
|
11 |
** This file contains pre-release code and may not be distributed.
|
|
12 |
** You may use this file in accordance with the terms and conditions
|
|
13 |
** contained in the Technology Preview License Agreement accompanying
|
|
14 |
** this package.
|
|
15 |
**
|
|
16 |
** GNU Lesser General Public License Usage
|
|
17 |
** Alternatively, this file may be used under the terms of the GNU Lesser
|
|
18 |
** General Public License version 2.1 as published by the Free Software
|
|
19 |
** Foundation and appearing in the file LICENSE.LGPL included in the
|
|
20 |
** packaging of this file. Please review the following information to
|
|
21 |
** ensure the GNU Lesser General Public License version 2.1 requirements
|
|
22 |
** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
|
|
23 |
**
|
|
24 |
** In addition, as a special exception, Nokia gives you certain additional
|
|
25 |
** rights. These rights are described in the Nokia Qt LGPL Exception
|
|
26 |
** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
|
|
27 |
**
|
|
28 |
** If you have questions regarding the use of this file, please contact
|
|
29 |
** Nokia at qt-info@nokia.com.
|
|
30 |
**
|
|
31 |
**
|
|
32 |
**
|
|
33 |
**
|
|
34 |
**
|
|
35 |
**
|
|
36 |
**
|
|
37 |
**
|
|
38 |
** $QT_END_LICENSE$
|
|
39 |
**
|
|
40 |
****************************************************************************/
|
|
41 |
|
|
42 |
|
|
43 |
#include <QApplication>
|
|
44 |
#include <QGroupBox>
|
|
45 |
#include <Q3GroupBox>
|
|
46 |
#include <QLabel>
|
|
47 |
#include <QVBoxLayout>
|
|
48 |
#include <QDebug>
|
|
49 |
#include <QtTest/QtTest>
|
|
50 |
|
|
51 |
class tst_q3groupbox : public QObject
|
|
52 |
{
|
|
53 |
Q_OBJECT
|
|
54 |
private slots:
|
|
55 |
void getSetCheck();
|
|
56 |
void groupBoxHeight();
|
|
57 |
};
|
|
58 |
|
|
59 |
// Testing get/set functions
|
|
60 |
void tst_q3groupbox::getSetCheck()
|
|
61 |
{
|
|
62 |
Q3GroupBox obj1;
|
|
63 |
// int Q3GroupBox::insideMargin()
|
|
64 |
// void Q3GroupBox::setInsideMargin(int)
|
|
65 |
obj1.setInsideMargin(0);
|
|
66 |
QCOMPARE(0, obj1.insideMargin());
|
|
67 |
obj1.setInsideMargin(INT_MIN);
|
|
68 |
QCOMPARE(INT_MIN, obj1.insideMargin());
|
|
69 |
obj1.setInsideMargin(INT_MAX);
|
|
70 |
QCOMPARE(INT_MAX, obj1.insideMargin());
|
|
71 |
|
|
72 |
// int Q3GroupBox::insideSpacing()
|
|
73 |
// void Q3GroupBox::setInsideSpacing(int)
|
|
74 |
obj1.setInsideSpacing(0);
|
|
75 |
QCOMPARE(0, obj1.insideSpacing());
|
|
76 |
obj1.setInsideSpacing(INT_MIN);
|
|
77 |
QCOMPARE(INT_MIN, obj1.insideSpacing());
|
|
78 |
obj1.setInsideSpacing(INT_MAX);
|
|
79 |
QCOMPARE(INT_MAX, obj1.insideSpacing());
|
|
80 |
}
|
|
81 |
|
|
82 |
/*
|
|
83 |
Test that a Q3GroupBox has a reasonable height compared to a QGroupBox.
|
|
84 |
*/
|
|
85 |
void tst_q3groupbox::groupBoxHeight()
|
|
86 |
{
|
|
87 |
QWidget w;
|
|
88 |
|
|
89 |
// Create group boxes.
|
|
90 |
Q3GroupBox * const g3 = new Q3GroupBox(1000, Qt::Vertical, "Q3 Group Box", &w);
|
|
91 |
new QLabel("Row 1", g3);
|
|
92 |
|
|
93 |
QGroupBox * const g4 = new QGroupBox(&w, "QGroupBox");
|
|
94 |
g4->setTitle("QGroupBox");
|
|
95 |
QVBoxLayout * const g4Layout = new QVBoxLayout(g4);
|
|
96 |
g4Layout->addWidget(new QLabel("QT4 Row 1"));
|
|
97 |
|
|
98 |
// Add them to a layout.
|
|
99 |
QVBoxLayout * const layout = new QVBoxLayout(&w, 5, 5);
|
|
100 |
layout->addWidget(g3);
|
|
101 |
layout->addWidget(g4);
|
|
102 |
layout->addWidget(new QLabel("Label at Bottom"));
|
|
103 |
w.show();
|
|
104 |
|
|
105 |
// Measure height and test.
|
|
106 |
const int q3height = g3->height();
|
|
107 |
const int q4height = g4->height();
|
|
108 |
|
|
109 |
const double withinReason = 0.5; // Up to 50% off is OK.
|
|
110 |
const int minimum = int(q4height * (1.0 - withinReason));
|
|
111 |
const int maximum = int(q4height * (1.0 + withinReason));
|
|
112 |
|
|
113 |
QVERIFY(q3height > minimum);
|
|
114 |
QVERIFY(q3height < maximum);
|
|
115 |
}
|
|
116 |
|
|
117 |
QTEST_MAIN(tst_q3groupbox)
|
|
118 |
#include "tst_q3groupbox.moc"
|