| e5fcad3 by Lars Knoll at 2009-03-23 |
1 |
/**************************************************************************** |
|
2 |
** |
| 89c08c0 by Jason McDonald at 2012-01-11 |
3 |
** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). |
| 04e3b30 by Jason McDonald at 2009-09-09 |
4 |
** All rights reserved. |
| 858c70f by Jason McDonald at 2009-06-16 |
5 |
** Contact: Nokia Corporation (qt-info@nokia.com) |
| e5fcad3 by Lars Knoll at 2009-03-23 |
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 |
| 1eea52e by Jyri Tahtela at 2011-05-13 |
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. |
| e5fcad3 by Lars Knoll at 2009-03-23 |
17 |
** |
| 04e3b30 by Jason McDonald at 2009-09-09 |
18 |
** In addition, as a special exception, Nokia gives you certain additional |
| 1eea52e by Jyri Tahtela at 2011-05-13 |
19 |
** rights. These rights are described in the Nokia Qt LGPL Exception |
| 04e3b30 by Jason McDonald at 2009-09-09 |
20 |
** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. |
| e5fcad3 by Lars Knoll at 2009-03-23 |
21 |
** |
| 1eea52e by Jyri Tahtela at 2011-05-13 |
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. |
| 309db73 by Jason McDonald at 2009-08-31 |
33 |
** |
|
34 |
** |
|
35 |
** |
|
36 |
** |
| e5fcad3 by Lars Knoll at 2009-03-23 |
37 |
** |
|
38 |
** $QT_END_LICENSE$ |
|
39 |
** |
|
40 |
****************************************************************************/ |
|
41 |
|
|
42 |
|
|
43 |
#include <QtTest/QtTest> |
|
44 |
|
|
45 |
#include <qcoreapplication.h> |
|
46 |
#include <qdebug.h> |
|
47 |
#include <qabstractspinbox.h> |
|
48 |
#include <qlineedit.h> |
|
49 |
#include <qspinbox.h> |
|
50 |
|
|
51 |
|
|
52 |
//TESTED_CLASS= |
|
53 |
//TESTED_FILES= |
|
54 |
|
|
55 |
class tst_QAbstractSpinBox : public QObject |
|
56 |
{ |
|
57 |
Q_OBJECT |
|
58 |
|
|
59 |
public: |
|
60 |
tst_QAbstractSpinBox(); |
|
61 |
virtual ~tst_QAbstractSpinBox(); |
|
62 |
|
|
63 |
private slots: |
|
64 |
void getSetCheck(); |
|
65 |
|
|
66 |
// task-specific tests below me: |
|
67 |
void task183108_clear(); |
|
68 |
void task228728_cssselector(); |
|
69 |
}; |
|
70 |
|
|
71 |
tst_QAbstractSpinBox::tst_QAbstractSpinBox() |
|
72 |
{ |
|
73 |
} |
|
74 |
|
|
75 |
tst_QAbstractSpinBox::~tst_QAbstractSpinBox() |
|
76 |
{ |
|
77 |
} |
|
78 |
|
|
79 |
class MyAbstractSpinBox : public QAbstractSpinBox |
|
80 |
{ |
|
81 |
public: |
|
82 |
MyAbstractSpinBox() : QAbstractSpinBox() {} |
|
83 |
QLineEdit *lineEdit() { return QAbstractSpinBox::lineEdit(); } |
|
84 |
void setLineEdit(QLineEdit *le) { QAbstractSpinBox::setLineEdit(le); } |
|
85 |
}; |
|
86 |
|
|
87 |
// Testing get/set functions |
|
88 |
void tst_QAbstractSpinBox::getSetCheck() |
|
89 |
{ |
|
90 |
MyAbstractSpinBox obj1; |
|
91 |
// ButtonSymbols QAbstractSpinBox::buttonSymbols() |
|
92 |
// void QAbstractSpinBox::setButtonSymbols(ButtonSymbols) |
|
93 |
obj1.setButtonSymbols(QAbstractSpinBox::ButtonSymbols(QAbstractSpinBox::UpDownArrows)); |
|
94 |
QCOMPARE(QAbstractSpinBox::ButtonSymbols(QAbstractSpinBox::UpDownArrows), obj1.buttonSymbols()); |
|
95 |
obj1.setButtonSymbols(QAbstractSpinBox::ButtonSymbols(QAbstractSpinBox::PlusMinus)); |
|
96 |
QCOMPARE(QAbstractSpinBox::ButtonSymbols(QAbstractSpinBox::PlusMinus), obj1.buttonSymbols()); |
|
97 |
|
|
98 |
// bool QAbstractSpinBox::wrapping() |
|
99 |
// void QAbstractSpinBox::setWrapping(bool) |
|
100 |
obj1.setWrapping(false); |
|
101 |
QCOMPARE(false, obj1.wrapping()); |
|
102 |
obj1.setWrapping(true); |
|
103 |
QCOMPARE(true, obj1.wrapping()); |
|
104 |
|
|
105 |
// QLineEdit * QAbstractSpinBox::lineEdit() |
|
106 |
// void QAbstractSpinBox::setLineEdit(QLineEdit *) |
|
107 |
QLineEdit *var3 = new QLineEdit(0); |
|
108 |
obj1.setLineEdit(var3); |
|
109 |
QCOMPARE(var3, obj1.lineEdit()); |
|
110 |
#ifndef QT_DEBUG |
|
111 |
obj1.setLineEdit((QLineEdit *)0); // Will assert in debug, so only test in release |
|
112 |
QCOMPARE(var3, obj1.lineEdit()); // Setting 0 should keep the current editor |
|
113 |
#endif |
|
114 |
// delete var3; // No delete, since QAbstractSpinBox takes ownership |
|
115 |
} |
|
116 |
|
|
117 |
void tst_QAbstractSpinBox::task183108_clear() |
|
118 |
{ |
|
119 |
QAbstractSpinBox *sbox; |
|
120 |
|
|
121 |
sbox = new QSpinBox; |
|
122 |
sbox->clear(); |
|
123 |
sbox->show(); |
|
124 |
qApp->processEvents(); |
|
125 |
QVERIFY(sbox->text().isEmpty()); |
|
126 |
|
|
127 |
delete sbox; |
|
128 |
sbox = new QSpinBox; |
|
129 |
sbox->clear(); |
|
130 |
sbox->show(); |
|
131 |
sbox->hide(); |
|
132 |
qApp->processEvents(); |
|
133 |
QCOMPARE(sbox->text(), QString()); |
|
134 |
|
|
135 |
delete sbox; |
|
136 |
sbox = new QSpinBox; |
|
137 |
sbox->show(); |
|
138 |
sbox->clear(); |
|
139 |
qApp->processEvents(); |
|
140 |
QCOMPARE(sbox->text(), QString()); |
|
141 |
|
|
142 |
delete sbox; |
|
143 |
sbox = new QSpinBox; |
|
144 |
sbox->show(); |
|
145 |
sbox->clear(); |
|
146 |
sbox->hide(); |
|
147 |
qApp->processEvents(); |
|
148 |
QCOMPARE(sbox->text(), QString()); |
|
149 |
|
|
150 |
delete sbox; |
|
151 |
} |
|
152 |
|
|
153 |
void tst_QAbstractSpinBox::task228728_cssselector() |
|
154 |
{ |
|
155 |
//QAbstractSpinBox does some call to stylehint into his constructor. |
|
156 |
//so while the stylesheet want to access property, it should not crash |
| 130e906 by aavit at 2011-08-23 |
157 |
qApp->setStyleSheet("[alignment=\"1\"], [text=\"foo\"] { color:black; }" ); |
| e5fcad3 by Lars Knoll at 2009-03-23 |
158 |
QSpinBox box; |
|
159 |
} |
|
160 |
|
|
161 |
|
|
162 |
QTEST_MAIN(tst_QAbstractSpinBox) |
|
163 |
#include "tst_qabstractspinbox.moc" |