author | Eckhart Koeppen <eckhart.koppen@nokia.com> |
Wed, 21 Apr 2010 09:15:16 +0300 | |
branch | RCL_3 |
changeset 10 | 68d3b337861b |
parent 4 | 3b1da2848fc7 |
permissions | -rw-r--r-- |
0 | 1 |
/**************************************************************************** |
2 |
** |
|
4
3b1da2848fc7
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
3
diff
changeset
|
3 |
** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies). |
0 | 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 <QtTest/QtTest> |
|
44 |
#include <qapplication.h> |
|
45 |
#include <limits.h> |
|
46 |
||
47 |
#include <float.h> |
|
48 |
||
49 |
#include <qspinbox.h> |
|
50 |
#include <qlocale.h> |
|
51 |
#include <qlayout.h> |
|
52 |
||
53 |
#include <qlineedit.h> |
|
54 |
#include <qdebug.h> |
|
55 |
||
56 |
#include "../../shared/util.h" |
|
57 |
||
58 |
//TESTED_CLASS= |
|
59 |
//TESTED_FILES=gui/widgets/qspinbox.h gui/widgets/qspinbox.cpp gui/widgets/qabstractspinbox.cpp gui/widgets/qabstractspinbox_p.h gui/widgets/qabstractspinbox.h |
|
60 |
||
61 |
||
62 |
class DoubleSpinBox : public QDoubleSpinBox |
|
63 |
{ |
|
64 |
Q_OBJECT |
|
65 |
public: |
|
66 |
DoubleSpinBox(QWidget *parent = 0) |
|
67 |
: QDoubleSpinBox(parent) |
|
68 |
{ /*connect(this, SIGNAL(valueChanged(double)), this, SLOT(foo(double)));*/ } |
|
69 |
QString textFromValue(double v) const |
|
70 |
{ |
|
71 |
return QDoubleSpinBox::textFromValue(v); |
|
72 |
} |
|
73 |
QValidator::State validate(QString &text, int &pos) const |
|
74 |
{ |
|
75 |
return QDoubleSpinBox::validate(text, pos); |
|
76 |
} |
|
77 |
double valueFromText(const QString &text) const |
|
78 |
{ |
|
79 |
return QDoubleSpinBox::valueFromText(text); |
|
80 |
} |
|
81 |
||
82 |
QLineEdit* lineEdit() const { return QDoubleSpinBox::lineEdit(); } |
|
83 |
public slots: |
|
84 |
void foo(double vla) |
|
85 |
{ |
|
86 |
qDebug() << vla; |
|
87 |
} |
|
88 |
}; |
|
89 |
||
90 |
||
91 |
class tst_QDoubleSpinBox : public QObject |
|
92 |
{ |
|
93 |
Q_OBJECT |
|
94 |
public: |
|
95 |
tst_QDoubleSpinBox(); |
|
96 |
virtual ~tst_QDoubleSpinBox(); |
|
97 |
public slots: |
|
98 |
void initTestCase(); |
|
99 |
void cleanupTestCase(); |
|
100 |
void init(); |
|
101 |
||
102 |
private slots: |
|
103 |
void germanTest(); |
|
104 |
||
105 |
void task54433(); |
|
106 |
||
107 |
void setValue_data(); |
|
108 |
void setValue(); |
|
109 |
||
110 |
void setPrefixSuffix_data(); |
|
111 |
void setPrefixSuffix(); |
|
112 |
||
113 |
void setTracking_data(); |
|
114 |
void setTracking(); |
|
115 |
||
116 |
void setWrapping_data(); |
|
117 |
void setWrapping(); |
|
118 |
||
119 |
void setSpecialValueText_data(); |
|
120 |
void setSpecialValueText(); |
|
121 |
||
122 |
void setSingleStep_data(); |
|
123 |
void setSingleStep(); |
|
124 |
||
125 |
void setMinMax_data(); |
|
126 |
void setMinMax(); |
|
127 |
||
128 |
void setDecimals_data(); |
|
129 |
void setDecimals(); |
|
130 |
||
131 |
void doubleDot(); |
|
132 |
||
133 |
void undoRedo(); |
|
134 |
||
135 |
void valueFromTextAndValidate_data(); |
|
136 |
void valueFromTextAndValidate(); |
|
137 |
||
138 |
void setReadOnly(); |
|
139 |
||
140 |
void editingFinished(); |
|
141 |
||
142 |
void removeAll(); |
|
143 |
||
144 |
void task199226_stateAfterEnter(); |
|
145 |
void task224497_fltMax(); |
|
146 |
||
147 |
void task221221(); |
|
148 |
void task255471_decimalsValidation(); |
|
149 |
||
3
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
150 |
void taskQTBUG_5008_textFromValueAndValidate(); |
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
151 |
void taskQTBUG_6670_selectAllWithPrefix(); |
4
3b1da2848fc7
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
3
diff
changeset
|
152 |
void taskQTBUG_6496_fiddlingWithPrecision(); |
3
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
153 |
|
0 | 154 |
public slots: |
155 |
void valueChangedHelper(const QString &); |
|
156 |
void valueChangedHelper(double); |
|
157 |
private: |
|
158 |
QStringList actualTexts; |
|
159 |
QList<double> actualValues; |
|
160 |
QWidget *testFocusWidget; |
|
161 |
}; |
|
162 |
||
163 |
typedef QList<double> DoubleList; |
|
164 |
Q_DECLARE_METATYPE(DoubleList) |
|
165 |
||
166 |
tst_QDoubleSpinBox::tst_QDoubleSpinBox() |
|
167 |
||
168 |
{ |
|
169 |
} |
|
170 |
||
171 |
tst_QDoubleSpinBox::~tst_QDoubleSpinBox() |
|
172 |
{ |
|
173 |
||
174 |
} |
|
175 |
||
176 |
void tst_QDoubleSpinBox::initTestCase() |
|
177 |
{ |
|
178 |
testFocusWidget = new QWidget(0); |
|
179 |
testFocusWidget->resize(200, 100); |
|
180 |
testFocusWidget->show(); |
|
181 |
} |
|
182 |
||
183 |
void tst_QDoubleSpinBox::cleanupTestCase() |
|
184 |
{ |
|
185 |
delete testFocusWidget; |
|
186 |
testFocusWidget = 0; |
|
187 |
} |
|
188 |
||
189 |
void tst_QDoubleSpinBox::init() |
|
190 |
{ |
|
191 |
QLocale::setDefault(QLocale(QLocale::C)); |
|
192 |
} |
|
193 |
||
194 |
void tst_QDoubleSpinBox::setValue_data() |
|
195 |
{ |
|
196 |
QTest::addColumn<double>("val"); |
|
197 |
||
198 |
QTest::newRow("data0") << 0.0; |
|
199 |
QTest::newRow("data1") << 100.5; |
|
200 |
QTest::newRow("data2") << -100.5; |
|
201 |
QTest::newRow("data3") << -DBL_MAX; |
|
202 |
QTest::newRow("data4") << DBL_MAX; |
|
203 |
} |
|
204 |
||
205 |
void tst_QDoubleSpinBox::setValue() |
|
206 |
{ |
|
207 |
QFETCH(double, val); |
|
208 |
QDoubleSpinBox spin(0); |
|
209 |
spin.setRange(-DBL_MAX, DBL_MAX); |
|
210 |
spin.setValue(val); |
|
211 |
QCOMPARE(spin.value(), val); |
|
212 |
} |
|
213 |
||
214 |
void tst_QDoubleSpinBox::setPrefixSuffix_data() |
|
215 |
{ |
|
216 |
QTest::addColumn<QString>("prefix"); |
|
217 |
QTest::addColumn<QString>("suffix"); |
|
218 |
QTest::addColumn<double>("value"); |
|
219 |
QTest::addColumn<int>("decimals"); |
|
220 |
QTest::addColumn<QString>("expectedText"); |
|
221 |
QTest::addColumn<QString>("expectedCleanText"); |
|
222 |
QTest::addColumn<bool>("show"); |
|
223 |
||
224 |
QTest::newRow("data0") << QString() << QString() << 10.5 << 1 << "10.5" << "10.5" << false; |
|
225 |
QTest::newRow("data1") << QString() << "cm" << 10.5 << 2 << "10.50cm" << "10.50" << false; |
|
226 |
QTest::newRow("data2") << "cm: " << QString() << 10.5 << 0 << "cm: 10" << "10" << false; |
|
227 |
QTest::newRow("data3") << "length: " << "cm" << 10.5 << 3 << "length: 10.500cm" << "10.500" << false; |
|
228 |
||
229 |
QTest::newRow("data4") << QString() << QString() << 10.5 << 1 << "10.5" << "10.5" << true; |
|
230 |
QTest::newRow("data5") << QString() << "cm" << 10.5 << 2 << "10.50cm" << "10.50" << true; |
|
231 |
QTest::newRow("data6") << "cm: " << QString() << 10.5 << 0 << "cm: 10" << "10" << true; |
|
232 |
QTest::newRow("data7") << "length: " << "cm" << 10.5 << 3 << "length: 10.500cm" << "10.500" << true; |
|
233 |
} |
|
234 |
||
235 |
void tst_QDoubleSpinBox::setPrefixSuffix() |
|
236 |
{ |
|
237 |
QFETCH(QString, prefix); |
|
238 |
QFETCH(QString, suffix); |
|
239 |
QFETCH(double, value); |
|
240 |
QFETCH(int, decimals); |
|
241 |
QFETCH(QString, expectedText); |
|
242 |
QFETCH(QString, expectedCleanText); |
|
243 |
QFETCH(bool, show); |
|
244 |
||
245 |
QDoubleSpinBox spin(0); |
|
246 |
spin.setDecimals(decimals); |
|
247 |
spin.setPrefix(prefix); |
|
248 |
spin.setSuffix(suffix); |
|
249 |
spin.setValue(value); |
|
250 |
if (show) |
|
251 |
spin.show(); |
|
252 |
||
253 |
QCOMPARE(spin.text(), expectedText); |
|
254 |
QCOMPARE(spin.cleanText(), expectedCleanText); |
|
255 |
} |
|
256 |
||
257 |
void tst_QDoubleSpinBox::valueChangedHelper(const QString &text) |
|
258 |
{ |
|
259 |
actualTexts << text; |
|
260 |
} |
|
261 |
||
262 |
void tst_QDoubleSpinBox::valueChangedHelper(double value) |
|
263 |
{ |
|
264 |
actualValues << value; |
|
265 |
} |
|
266 |
||
267 |
void tst_QDoubleSpinBox::setTracking_data() |
|
268 |
{ |
|
269 |
QTest::addColumn<int>("decimals"); |
|
270 |
QTest::addColumn<QTestEventList>("keys"); |
|
271 |
QTest::addColumn<QStringList>("texts"); |
|
272 |
QTest::addColumn<bool>("tracking"); |
|
273 |
||
274 |
QTestEventList keys; |
|
275 |
QStringList texts1; |
|
276 |
QStringList texts2; |
|
277 |
#ifdef Q_WS_MAC |
|
278 |
keys.addKeyClick(Qt::Key_Right, Qt::ControlModifier); |
|
279 |
#else |
|
280 |
keys.addKeyClick(Qt::Key_End); |
|
281 |
#endif |
|
282 |
keys.addKeyClick(Qt::Key_Backspace); |
|
283 |
keys.addKeyClick(Qt::Key_Backspace); |
|
284 |
keys.addKeyClick(Qt::Key_Backspace); |
|
285 |
keys.addKeyClick(Qt::Key_Backspace); |
|
286 |
keys.addKeyClick(Qt::Key_Backspace); |
|
287 |
keys.addKeyClick(Qt::Key_Backspace); |
|
288 |
keys.addKeyClick(Qt::Key_Backspace); |
|
289 |
keys.addKeyClick(Qt::Key_Backspace); |
|
290 |
keys.addKeyClick('7'); |
|
291 |
keys.addKeyClick('.'); |
|
292 |
keys.addKeyClick('9'); |
|
293 |
keys.addKeyClick(Qt::Key_Backspace); |
|
294 |
keys.addKeyClick('2'); |
|
295 |
keys.addKeyClick(Qt::Key_Enter); |
|
296 |
keys.addKeyClick(Qt::Key_Enter); |
|
297 |
keys.addKeyClick(Qt::Key_Enter); |
|
298 |
texts1 << "7" << "7.9" << "7." << "7.2" << "7.200" << "7.200" << "7.200"; |
|
299 |
texts2 << "7.200"; |
|
300 |
QTest::newRow("data1") << 3 << keys << texts1 << true; |
|
301 |
QTest::newRow("data2") << 3 << keys << texts2 << false; |
|
302 |
||
303 |
} |
|
304 |
||
305 |
void tst_QDoubleSpinBox::setTracking() |
|
306 |
{ |
|
307 |
QLocale::setDefault(QLocale(QLocale::C)); |
|
308 |
||
309 |
actualTexts.clear(); |
|
310 |
QFETCH(int, decimals); |
|
311 |
QFETCH(QTestEventList, keys); |
|
312 |
QFETCH(QStringList, texts); |
|
313 |
QFETCH(bool, tracking); |
|
314 |
||
315 |
QDoubleSpinBox spin(0); |
|
316 |
spin.setKeyboardTracking(tracking); |
|
317 |
spin.setDecimals(decimals); |
|
318 |
spin.show(); |
|
319 |
||
320 |
connect(&spin, SIGNAL(valueChanged(QString)), this, SLOT(valueChangedHelper(const QString &))); |
|
321 |
||
322 |
keys.simulate(&spin); |
|
323 |
QCOMPARE(actualTexts, texts); |
|
324 |
} |
|
325 |
||
326 |
void tst_QDoubleSpinBox::setWrapping_data() |
|
327 |
{ |
|
328 |
QTest::addColumn<bool>("wrapping"); |
|
329 |
QTest::addColumn<double>("minimum"); |
|
330 |
QTest::addColumn<double>("maximum"); |
|
331 |
QTest::addColumn<double>("startValue"); |
|
332 |
QTest::addColumn<QTestEventList>("keys"); |
|
333 |
QTest::addColumn<DoubleList>("expected"); |
|
334 |
||
335 |
QTestEventList keys; |
|
336 |
DoubleList values; |
|
337 |
keys.addKeyClick(Qt::Key_Up); |
|
338 |
values << 10; |
|
339 |
keys.addKeyClick(Qt::Key_Up); |
|
340 |
QTest::newRow("data0") << false << 0.0 << 10.0 << 9.0 << keys << values; |
|
341 |
||
342 |
keys.clear(); |
|
343 |
values.clear(); |
|
344 |
keys.addKeyClick(Qt::Key_Up); |
|
345 |
values << 10; |
|
346 |
keys.addKeyClick(Qt::Key_Up); |
|
347 |
values << 0; |
|
348 |
QTest::newRow("data1") << true << 0.0 << 10.0 << 9.0 << keys << values; |
|
349 |
||
350 |
keys.clear(); |
|
351 |
values.clear(); |
|
352 |
#ifdef Q_WS_MAC |
|
353 |
keys.addKeyClick(Qt::Key_Right, Qt::ControlModifier); |
|
354 |
#else |
|
355 |
keys.addKeyClick(Qt::Key_End); |
|
356 |
#endif |
|
357 |
keys.addKeyClick(Qt::Key_Backspace); |
|
358 |
keys.addKeyClick('1'); |
|
359 |
keys.addKeyClick(Qt::Key_Down); |
|
360 |
keys.addKeyClick(Qt::Key_Down); |
|
361 |
keys.addKeyClick(Qt::Key_PageDown); |
|
362 |
values << 9.01 << 8.01 << 7.01 << 0.0; |
|
363 |
QTest::newRow("data2") << false << 0.0 << 10.0 << 9.0 << keys << values; |
|
364 |
||
365 |
keys.clear(); |
|
366 |
values.clear(); |
|
367 |
#ifdef Q_WS_MAC |
|
368 |
keys.addKeyClick(Qt::Key_Left, Qt::ControlModifier); |
|
369 |
#else |
|
370 |
keys.addKeyClick(Qt::Key_Home); |
|
371 |
#endif |
|
372 |
keys.addKeyClick(Qt::Key_Delete); |
|
373 |
keys.addKeyClick(Qt::Key_Delete); |
|
374 |
keys.addKeyClick(Qt::Key_Delete); |
|
375 |
keys.addKeyClick(Qt::Key_Delete); |
|
376 |
keys.addKeyClick(Qt::Key_Delete); |
|
377 |
keys.addKeyClick(Qt::Key_Delete); |
|
378 |
keys.addKeyClick(Qt::Key_Delete); |
|
379 |
keys.addKeyClick('1'); |
|
380 |
keys.addKeyClick(Qt::Key_Down); |
|
381 |
keys.addKeyClick(Qt::Key_Down); |
|
382 |
values << 0 << 1 << 0 << 10; |
|
383 |
QTest::newRow("data3") << true << 0.0 << 10.0 << 9.0 << keys << values; |
|
384 |
||
385 |
keys.clear(); |
|
386 |
values.clear(); |
|
387 |
keys.addKeyClick(Qt::Key_PageDown); |
|
388 |
keys.addKeyClick(Qt::Key_Down); |
|
389 |
values << 0; |
|
390 |
QTest::newRow("data4") << false << 0.0 << 10.0 << 6.0 << keys << values; |
|
391 |
||
392 |
keys.clear(); |
|
393 |
values.clear(); |
|
394 |
keys.addKeyClick(Qt::Key_PageDown); |
|
395 |
keys.addKeyClick(Qt::Key_Down); |
|
396 |
values << 0 << 10; |
|
397 |
QTest::newRow("data5") << true << 0.0 << 10.0 << 6.0 << keys << values; |
|
398 |
||
399 |
keys.clear(); |
|
400 |
values.clear(); |
|
401 |
keys.addKeyClick(Qt::Key_PageUp); |
|
402 |
keys.addKeyClick(Qt::Key_PageDown); |
|
403 |
keys.addKeyClick(Qt::Key_Down); |
|
404 |
keys.addKeyClick(Qt::Key_Up); |
|
405 |
keys.addKeyClick(Qt::Key_PageDown); |
|
406 |
keys.addKeyClick(Qt::Key_PageDown); |
|
407 |
values << 10 << 0 << 10 << 0 << 10 << 0; |
|
408 |
QTest::newRow("data6") << true << 0.0 << 10.0 << 6.0 << keys << values; |
|
409 |
||
410 |
} |
|
411 |
||
412 |
||
413 |
void tst_QDoubleSpinBox::setWrapping() |
|
414 |
{ |
|
415 |
QLocale::setDefault(QLocale(QLocale::C)); |
|
416 |
QFETCH(bool, wrapping); |
|
417 |
QFETCH(double, minimum); |
|
418 |
QFETCH(double, maximum); |
|
419 |
QFETCH(double, startValue); |
|
420 |
QFETCH(QTestEventList, keys); |
|
421 |
QFETCH(DoubleList, expected); |
|
422 |
||
423 |
QDoubleSpinBox spin(0); |
|
424 |
spin.setMinimum(minimum); |
|
425 |
spin.setMaximum(maximum); |
|
426 |
spin.setValue(startValue); |
|
427 |
spin.setWrapping(wrapping); |
|
428 |
spin.show(); |
|
429 |
actualValues.clear(); |
|
430 |
connect(&spin, SIGNAL(valueChanged(double)), this, SLOT(valueChangedHelper(double))); |
|
431 |
||
432 |
keys.simulate(&spin); |
|
433 |
||
434 |
QCOMPARE(actualValues.size(), expected.size()); |
|
435 |
for (int i=0; i<qMin(actualValues.size(), expected.size()); ++i) { |
|
436 |
QCOMPARE(actualValues.at(i), expected.at(i)); |
|
437 |
} |
|
438 |
} |
|
439 |
||
440 |
void tst_QDoubleSpinBox::setSpecialValueText_data() |
|
441 |
{ |
|
442 |
QTest::addColumn<QString>("specialValueText"); |
|
443 |
QTest::addColumn<double>("minimum"); |
|
444 |
QTest::addColumn<double>("maximum"); |
|
445 |
QTest::addColumn<double>("value"); |
|
446 |
QTest::addColumn<int>("decimals"); |
|
447 |
QTest::addColumn<QString>("expected"); |
|
448 |
QTest::addColumn<bool>("show"); |
|
449 |
||
450 |
QTest::newRow("data0") << QString() << 0.0 << 10.0 << 1.0 << 4 << "1.0000" << false; |
|
451 |
QTest::newRow("data1") << QString() << 0.0 << 10.0 << 1.0 << 4 << "1.0000" << true; |
|
452 |
QTest::newRow("data2") << "foo" << 0.0 << 10.0 << 0.0 << 2 << "foo" << false; |
|
453 |
QTest::newRow("data3") << "foo" << 0.0 << 10.0 << 0.0 << 2 << "foo" << true; |
|
454 |
} |
|
455 |
||
456 |
void tst_QDoubleSpinBox::setSpecialValueText() |
|
457 |
{ |
|
458 |
QFETCH(QString, specialValueText); |
|
459 |
QFETCH(double, minimum); |
|
460 |
QFETCH(double, maximum); |
|
461 |
QFETCH(double, value); |
|
462 |
QFETCH(int, decimals); |
|
463 |
QFETCH(QString, expected); |
|
464 |
QFETCH(bool, show); |
|
465 |
||
466 |
QDoubleSpinBox spin(0); |
|
467 |
spin.setSpecialValueText(specialValueText); |
|
468 |
spin.setMinimum(minimum); |
|
469 |
spin.setMaximum(maximum); |
|
470 |
spin.setValue(value); |
|
471 |
spin.setDecimals(decimals); |
|
472 |
if (show) |
|
473 |
spin.show(); |
|
474 |
||
475 |
QCOMPARE(spin.text(), expected); |
|
476 |
} |
|
477 |
||
478 |
void tst_QDoubleSpinBox::setSingleStep_data() |
|
479 |
{ |
|
480 |
QTest::addColumn<double>("singleStep"); |
|
481 |
QTest::addColumn<double>("startValue"); |
|
482 |
QTest::addColumn<QTestEventList>("keys"); |
|
483 |
QTest::addColumn<DoubleList>("expected"); |
|
484 |
QTest::addColumn<bool>("show"); |
|
485 |
||
486 |
QTestEventList keys; |
|
487 |
DoubleList values; |
|
488 |
keys.addKeyClick(Qt::Key_Up); |
|
489 |
keys.addKeyClick(Qt::Key_Down); |
|
490 |
keys.addKeyClick(Qt::Key_Up); |
|
491 |
values << 11 << 10 << 11; |
|
492 |
QTest::newRow("data0") << 1.0 << 10.0 << keys << values << false; |
|
493 |
QTest::newRow("data1") << 1.0 << 10.0 << keys << values << true; |
|
494 |
||
495 |
keys.clear(); |
|
496 |
values.clear(); |
|
497 |
keys.addKeyClick(Qt::Key_Up); |
|
498 |
keys.addKeyClick(Qt::Key_Down); |
|
499 |
keys.addKeyClick(Qt::Key_Up); |
|
500 |
values << 12.5 << 10.0 << 12.5; |
|
501 |
QTest::newRow("data2") << 2.5 << 10.0 << keys << values << false; |
|
502 |
QTest::newRow("data3") << 2.5 << 10.0 << keys << values << true; |
|
503 |
} |
|
504 |
||
505 |
void tst_QDoubleSpinBox::setSingleStep() |
|
506 |
{ |
|
507 |
QFETCH(double, singleStep); |
|
508 |
QFETCH(double, startValue); |
|
509 |
QFETCH(QTestEventList, keys); |
|
510 |
QFETCH(DoubleList, expected); |
|
511 |
QFETCH(bool, show); |
|
512 |
||
513 |
QDoubleSpinBox spin(0); |
|
514 |
actualValues.clear(); |
|
515 |
spin.setSingleStep(singleStep); |
|
516 |
spin.setValue(startValue); |
|
517 |
if (show) |
|
518 |
spin.show(); |
|
519 |
connect(&spin, SIGNAL(valueChanged(double)), this, SLOT(valueChangedHelper(double))); |
|
520 |
||
521 |
QCOMPARE(actualValues.size(), 0); |
|
522 |
keys.simulate(&spin); |
|
523 |
QCOMPARE(actualValues.size(), expected.size()); |
|
524 |
for (int i=0; i<qMin(actualValues.size(), expected.size()); ++i) { |
|
525 |
QCOMPARE(actualValues.at(i), expected.at(i)); |
|
526 |
} |
|
527 |
} |
|
528 |
||
529 |
void tst_QDoubleSpinBox::setMinMax_data() |
|
530 |
{ |
|
531 |
QTest::addColumn<double>("startValue"); |
|
532 |
QTest::addColumn<double>("minimum"); |
|
533 |
QTest::addColumn<double>("maximum"); |
|
534 |
QTest::addColumn<QTestEventList>("keys"); |
|
535 |
QTest::addColumn<double>("expected"); |
|
536 |
QTest::addColumn<bool>("show"); |
|
537 |
||
538 |
QTestEventList keys; |
|
539 |
keys.addKeyClick(Qt::Key_Up); |
|
540 |
keys.addKeyClick(Qt::Key_Up); |
|
541 |
keys.addKeyClick(Qt::Key_Up); |
|
542 |
keys.addKeyClick(Qt::Key_Up); |
|
543 |
keys.addKeyClick(Qt::Key_Up); |
|
544 |
QTest::newRow("data0") << 1.0 << -DBL_MAX << 2.0 << keys << 2.0 << false; |
|
545 |
QTest::newRow("data1") << 1.0 << -DBL_MAX << 2.0 << keys << 2.0 << true; |
|
546 |
QTest::newRow("data2") << -20000.0 << -15000.0 << -13000.0 << keys << -14995.0 << false; |
|
547 |
QTest::newRow("data3") << -20000.0 << -15000.0 << -13000.0 << keys << -14995.0 << true; |
|
548 |
QTest::newRow("data4") << 20.0 << -101.2 << -102.0 << QTestEventList() << -102.0 << false; |
|
549 |
QTest::newRow("data5") << 20.0 << -101.2 << -102.0 << QTestEventList() << -102.0 << true; |
|
550 |
} |
|
551 |
||
552 |
void tst_QDoubleSpinBox::setMinMax() |
|
553 |
{ |
|
554 |
QFETCH(double, startValue); |
|
555 |
QFETCH(double, minimum); |
|
556 |
QFETCH(double, maximum); |
|
557 |
QFETCH(QTestEventList, keys); |
|
558 |
QFETCH(double, expected); |
|
559 |
QFETCH(bool, show); |
|
560 |
||
561 |
{ |
|
562 |
QDoubleSpinBox spin(0); |
|
563 |
spin.setMinimum(minimum); |
|
564 |
spin.setMaximum(maximum); |
|
565 |
spin.setValue(startValue); |
|
566 |
||
567 |
if (show) |
|
568 |
spin.show(); |
|
569 |
keys.simulate(&spin); |
|
570 |
QCOMPARE(spin.value(), expected); |
|
571 |
} |
|
572 |
||
573 |
{ |
|
574 |
QDoubleSpinBox spin(0); |
|
575 |
spin.setMaximum(maximum); |
|
576 |
spin.setMinimum(minimum); |
|
577 |
spin.setValue(startValue); |
|
578 |
||
579 |
if (show) |
|
580 |
spin.show(); |
|
581 |
keys.simulate(&spin); |
|
582 |
} |
|
583 |
||
584 |
{ |
|
585 |
QDoubleSpinBox spin(0); |
|
586 |
spin.setRange(minimum, maximum); |
|
587 |
spin.setValue(startValue); |
|
588 |
||
589 |
if (show) |
|
590 |
spin.show(); |
|
591 |
keys.simulate(&spin); |
|
592 |
} |
|
593 |
||
594 |
||
595 |
} |
|
596 |
||
597 |
void tst_QDoubleSpinBox::setDecimals_data() |
|
598 |
{ |
|
599 |
QTest::addColumn<int>("decimals"); |
|
600 |
QTest::addColumn<int>("expectedDecimals"); |
|
601 |
QTest::addColumn<double>("startValue"); |
|
602 |
QTest::addColumn<QString>("expected"); |
|
603 |
||
604 |
QTest::newRow("data0") << 4 << 4 << 1.0 << "1.0000"; |
|
605 |
QTest::newRow("data1") << 1 << 1 << 1.243443 << "1.2"; |
|
606 |
QTest::newRow("data2") << 6 << 6 << 1.29 << "1.290000"; |
|
607 |
QTest::newRow("data3") << 8 << 8 << 9.1234567809 << "9.12345678"; |
|
608 |
QTest::newRow("data4") << 13 << 13 << 0.12345678901237 << "0.1234567890124"; |
|
609 |
QTest::newRow("data5") << 13 << 13 << -0.12345678901237 << "-0.1234567890124"; |
|
610 |
QTest::newRow("data6") << 13 << 13 << -0.12345678901237 << "-0.1234567890124"; |
|
611 |
QTest::newRow("data7") << -1 << 0 << 0.1 << "0"; |
|
612 |
QTest::newRow("data8") << 120 << 120 << -0.12345678901237 << "-0.123456789012370005131913330842508003115653991699218750000000000000000000000000000000000000000000000000000000000000000000"; |
|
613 |
||
614 |
} |
|
615 |
||
616 |
void tst_QDoubleSpinBox::setDecimals() |
|
617 |
{ |
|
618 |
QFETCH(int, decimals); |
|
619 |
QFETCH(int, expectedDecimals); |
|
620 |
QFETCH(double, startValue); |
|
621 |
QFETCH(QString, expected); |
|
622 |
||
623 |
QDoubleSpinBox spin(0); |
|
624 |
spin.setRange(-DBL_MAX, DBL_MAX); |
|
625 |
spin.setDecimals(decimals); |
|
626 |
spin.setValue(startValue); |
|
627 |
QCOMPARE(spin.decimals(), expectedDecimals); |
|
628 |
if (sizeof(qreal) == sizeof(float)) |
|
629 |
QCOMPARE(spin.text().left(17), expected.left(17)); |
|
630 |
else |
|
631 |
QCOMPARE(spin.text(), expected); |
|
632 |
||
633 |
if (spin.decimals() > 0) { |
|
634 |
#ifdef Q_WS_MAC |
|
635 |
QTest::keyClick(&spin, Qt::Key_Right, Qt::ControlModifier); |
|
636 |
#else |
|
637 |
QTest::keyClick(&spin, Qt::Key_End); |
|
638 |
#endif |
|
639 |
QTest::keyClick(&spin, Qt::Key_1); // just make sure we can't input more decimals than what is specified |
|
640 |
QTest::keyClick(&spin, Qt::Key_1); |
|
641 |
QTest::keyClick(&spin, Qt::Key_1); |
|
642 |
QTest::keyClick(&spin, Qt::Key_1); |
|
643 |
QTest::keyClick(&spin, Qt::Key_1); |
|
644 |
if (sizeof(qreal) == sizeof(float)) |
|
645 |
QCOMPARE(spin.text().left(17), expected.left(17)); |
|
646 |
else |
|
647 |
QCOMPARE(spin.text(), expected); |
|
648 |
} |
|
649 |
} |
|
650 |
||
651 |
static QString stateName(int state) |
|
652 |
{ |
|
653 |
switch (state) { |
|
654 |
case QValidator::Acceptable: return QString("Acceptable"); |
|
655 |
case QValidator::Intermediate: return QString("Intermediate"); |
|
656 |
case QValidator::Invalid: return QString("Invalid"); |
|
657 |
default: break; |
|
658 |
} |
|
659 |
qWarning("%s %d: this should never happen", __FILE__, __LINE__); |
|
660 |
return QString(); |
|
661 |
} |
|
662 |
||
663 |
void tst_QDoubleSpinBox::valueFromTextAndValidate_data() |
|
664 |
{ |
|
665 |
const int Intermediate = QValidator::Intermediate; |
|
666 |
const int Invalid = QValidator::Invalid; |
|
667 |
const int Acceptable = QValidator::Acceptable; |
|
668 |
||
669 |
QTest::addColumn<QString>("txt"); |
|
670 |
QTest::addColumn<int>("state"); |
|
671 |
QTest::addColumn<double>("mini"); |
|
672 |
QTest::addColumn<double>("maxi"); |
|
673 |
QTest::addColumn<int>("language"); |
|
674 |
QTest::addColumn<QString>("expectedText"); // if empty we don't check |
|
675 |
||
676 |
QTest::newRow("data0") << QString("2.2") << Intermediate << 3.0 << 5.0 << (int)QLocale::C << QString(); |
|
677 |
QTest::newRow("data1") << QString() << Intermediate << 0.0 << 100.0 << (int)QLocale::C << QString(); |
|
678 |
QTest::newRow("data2") << QString("asd") << Invalid << 0.0 << 100.0 << (int)QLocale::C << QString(); |
|
679 |
QTest::newRow("data3") << QString("2.2") << Acceptable << 0.0 << 100.0 << (int)QLocale::C << QString(); |
|
680 |
QTest::newRow("data4") << QString(" ") << Intermediate << 0.0 << 100.0 << (int)QLocale::Norwegian << QString(); |
|
681 |
QTest::newRow("data5") << QString(" ") << Intermediate << 0.0 << 100.0 << (int)QLocale::C << QString(); |
|
682 |
QTest::newRow("data6") << QString(",") << Intermediate << 0.0 << 100.0 << (int)QLocale::Norwegian << QString(); |
|
683 |
QTest::newRow("data7") << QString(",") << Invalid << 0.0 << 100.0 << (int)QLocale::C << QString(); |
|
684 |
QTest::newRow("data8") << QString("1 ") << Acceptable << 0.0 << 1000.0 << (int)QLocale::Norwegian << QString("1"); |
|
685 |
QTest::newRow("data9") << QString("1 ") << Acceptable << 0.0 << 100.0 << (int)QLocale::C << QString("1"); |
|
686 |
QTest::newRow("data10") << QString(" 1") << Acceptable << 0.0 << 100.0 << (int)QLocale::Norwegian << QString("1"); |
|
687 |
QTest::newRow("data11") << QString(" 1") << Acceptable << 0.0 << 100.0 << (int)QLocale::C << QString("1"); |
|
688 |
QTest::newRow("data12") << QString("1,") << Acceptable << 0.0 << 100.0 << (int)QLocale::Norwegian << QString(); |
|
3
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
689 |
QTest::newRow("data13") << QString("1,") << Acceptable << 0.0 << 1000.0 << (int)QLocale::C << QString(); |
0 | 690 |
QTest::newRow("data14") << QString("1, ") << Acceptable << 0.0 << 100.0 << (int)QLocale::Norwegian << QString("1,"); |
691 |
QTest::newRow("data15") << QString("1, ") << Invalid << 0.0 << 100.0 << (int)QLocale::C << QString(); |
|
692 |
QTest::newRow("data16") << QString("2") << Intermediate << 100.0 << 102.0 << (int)QLocale::C << QString(); |
|
693 |
QTest::newRow("data17") << QString("22.0") << Intermediate << 100.0 << 102.0 << (int)QLocale::C << QString(); |
|
694 |
QTest::newRow("data18") << QString("12.0") << Intermediate << 100.0 << 102.0 << (int)QLocale::C << QString(); |
|
695 |
QTest::newRow("data19") << QString("12.2") << Intermediate << 100. << 102.0 << (int)QLocale::C << QString(); |
|
696 |
QTest::newRow("data20") << QString("21.") << Intermediate << 100.0 << 102.0 << (int)QLocale::C << QString(); |
|
697 |
QTest::newRow("data21") << QString("-21.") << Intermediate << -102.0 << -100.0 << (int)QLocale::C << QString(); |
|
698 |
QTest::newRow("data22") << QString("-12.") << Intermediate << -102.0 << -100.0 << (int)QLocale::C << QString(); |
|
699 |
QTest::newRow("data23") << QString("-11.11") << Intermediate << -102.0 << -101.2 << (int)QLocale::C << QString(); |
|
700 |
QTest::newRow("data24") << QString("-11.4") << Intermediate << -102.0 << -101.3 << (int)QLocale::C << QString(); |
|
701 |
QTest::newRow("data25") << QString("11.400") << Invalid << 0.0 << 100.0 << (int)QLocale::C << QString(); |
|
702 |
QTest::newRow("data26") << QString(".4") << Intermediate << 0.45 << 0.5 << (int)QLocale::C << QString(); |
|
703 |
QTest::newRow("data27") << QString("+.4") << Intermediate << 0.45 << 0.5 << (int)QLocale::C << QString(); |
|
704 |
QTest::newRow("data28") << QString("-.4") << Intermediate << -0.5 << -0.45 << (int)QLocale::C << QString(); |
|
705 |
QTest::newRow("data29") << QString(".4") << Intermediate << 1.0 << 2.4 << (int)QLocale::C << QString(); |
|
706 |
QTest::newRow("data30") << QString("-.4") << Intermediate << -2.3 << -1.9 << (int)QLocale::C << QString(); |
|
707 |
QTest::newRow("data31") << QString("-42") << Invalid << -2.43 << -1.0 << (int)QLocale::C << QString(); |
|
708 |
QTest::newRow("data32") << QString("-4") << Invalid << -1.4 << -1.0 << (int)QLocale::C << QString(); |
|
709 |
QTest::newRow("data33") << QString("-42") << Invalid << -1.4 << -1.0 << (int)QLocale::C << QString(); |
|
710 |
QTest::newRow("data34") << QString("1000000000000") << Invalid << -140.0 << -120.2 << (int)QLocale::C << QString(); |
|
711 |
QTest::newRow("data35") << QString("+.12") << Invalid << -5.0 << -3.2 << (int)QLocale::C << QString(); |
|
712 |
QTest::newRow("data36") << QString("-.12") << Invalid << 5.0 << 33.2 << (int)QLocale::C << QString(); |
|
713 |
QTest::newRow("data37") << QString("12.2") << Intermediate << 100. << 103.0 << (int)QLocale::C << QString(); |
|
714 |
QTest::newRow("data38") << QString("12.2") << Intermediate << 100. << 102.3 << (int)QLocale::C << QString(); |
|
715 |
QTest::newRow("data39") << QString("-12.") << Acceptable << -102.0 << 102.0 << (int)QLocale::C << QString(); |
|
716 |
QTest::newRow("data40") << QString("12.") << Invalid << -102.0 << 11.0 << (int)QLocale::C << QString(); |
|
717 |
QTest::newRow("data41") << QString("103.") << Invalid << -102.0 << 11.0 << (int)QLocale::C << QString(); |
|
718 |
QTest::newRow("data42") << QString("122") << Invalid << 10.0 << 12.2 << (int)QLocale::C << QString(); |
|
719 |
QTest::newRow("data43") << QString("-2.2") << Intermediate << -12.2 << -3.2 << (int)QLocale::C << QString(); |
|
720 |
QTest::newRow("data44") << QString("-2.20") << Intermediate << -12.1 << -3.2 << (int)QLocale::C << QString(); |
|
721 |
QTest::newRow("data45") << QString("200,2") << Invalid << 0.0 << 1000.0 << (int)QLocale::C << QString(); |
|
722 |
QTest::newRow("data46") << QString("200,2") << Acceptable << 0.0 << 1000.0 << (int)QLocale::German << QString(); |
|
723 |
QTest::newRow("data47") << QString("2.2") << Acceptable << 0.0 << 1000.0 << (int)QLocale::C << QString(); |
|
3
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
724 |
QTest::newRow("data48") << QString("2.2") << Acceptable << 0.0 << 1000.0 << (int)QLocale::German << QString(); |
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
725 |
QTest::newRow("data49") << QString("2.2,00") << Acceptable << 0.0 << 1000.0 << (int)QLocale::German << QString(); |
0 | 726 |
QTest::newRow("data50") << QString("2.2") << Acceptable << 0.0 << 1000.0 << (int)QLocale::C << QString(); |
727 |
QTest::newRow("data51") << QString("2.2,00") << Invalid << 0.0 << 1000.0 << (int)QLocale::C << QString(); |
|
728 |
QTest::newRow("data52") << QString("2..2,00") << Invalid << 0.0 << 1000.0 << (int)QLocale::German << QString(); |
|
729 |
QTest::newRow("data53") << QString("2.2") << Invalid << 0.0 << 1000.0 << (int)QLocale::Norwegian << QString(); |
|
730 |
QTest::newRow("data54") << QString(" 2.2") << Acceptable << 0.0 << 1000.0 << (int)QLocale::C << QString(); |
|
731 |
QTest::newRow("data55") << QString("2.2 ") << Acceptable << 0.0 << 1000.0 << (int)QLocale::C << QString("2.2"); |
|
732 |
QTest::newRow("data56") << QString(" 2.2 ") << Acceptable << 0.0 << 1000.0 << (int)QLocale::C << QString("2.2"); |
|
733 |
QTest::newRow("data57") << QString("2 2") << Invalid << 0.0 << 1000.0 << (int)QLocale::C << QString(); |
|
734 |
} |
|
735 |
||
736 |
void tst_QDoubleSpinBox::valueFromTextAndValidate() |
|
737 |
{ |
|
738 |
QFETCH(QString, txt); |
|
739 |
QFETCH(int, state); |
|
740 |
QFETCH(double, mini); |
|
741 |
QFETCH(double, maxi); |
|
742 |
QFETCH(int, language); |
|
743 |
QFETCH(QString, expectedText); |
|
744 |
QLocale::setDefault(QLocale((QLocale::Language)language)); |
|
745 |
||
746 |
DoubleSpinBox sb(0); |
|
747 |
sb.show(); |
|
748 |
sb.setRange(mini, maxi); |
|
749 |
||
750 |
int unused = 0; |
|
751 |
QCOMPARE(stateName(sb.validate(txt, unused)), stateName(state)); |
|
752 |
if (!expectedText.isEmpty()) |
|
753 |
QCOMPARE(txt, expectedText); |
|
754 |
} |
|
755 |
||
756 |
void tst_QDoubleSpinBox::setReadOnly() |
|
757 |
{ |
|
758 |
QDoubleSpinBox spin(0); |
|
759 |
spin.setValue(0.2); |
|
760 |
spin.show(); |
|
761 |
QCOMPARE(spin.value(), 0.2); |
|
762 |
QTest::keyClick(&spin, Qt::Key_Up); |
|
763 |
QCOMPARE(spin.value(), 1.2); |
|
764 |
spin.setReadOnly(true); |
|
765 |
QTest::keyClick(&spin, Qt::Key_Up); |
|
766 |
QCOMPARE(spin.value(), 1.2); |
|
767 |
spin.stepBy(1); |
|
768 |
QCOMPARE(spin.value(), 2.2); |
|
769 |
spin.setReadOnly(false); |
|
770 |
QTest::keyClick(&spin, Qt::Key_Up); |
|
771 |
QCOMPARE(spin.value(), 3.2); |
|
772 |
} |
|
773 |
||
774 |
void tst_QDoubleSpinBox::editingFinished() |
|
775 |
{ |
|
776 |
QVBoxLayout *layout = new QVBoxLayout(testFocusWidget); |
|
777 |
QDoubleSpinBox *box = new QDoubleSpinBox(testFocusWidget); |
|
778 |
layout->addWidget(box); |
|
779 |
QDoubleSpinBox *box2 = new QDoubleSpinBox(testFocusWidget); |
|
780 |
layout->addWidget(box2); |
|
781 |
||
782 |
testFocusWidget->show(); |
|
783 |
QApplication::setActiveWindow(testFocusWidget); |
|
784 |
QTest::qWait(10); |
|
785 |
QTRY_VERIFY(testFocusWidget->isActiveWindow()); |
|
786 |
box->setFocus(); |
|
787 |
QTRY_VERIFY(box->hasFocus()); |
|
788 |
||
789 |
QSignalSpy editingFinishedSpy1(box, SIGNAL(editingFinished())); |
|
790 |
QSignalSpy editingFinishedSpy2(box2, SIGNAL(editingFinished())); |
|
791 |
||
792 |
box->setFocus(); |
|
793 |
QTest::keyClick(box, Qt::Key_Up); |
|
794 |
QTest::keyClick(box, Qt::Key_Up); |
|
795 |
||
796 |
||
797 |
QCOMPARE(editingFinishedSpy1.count(), 0); |
|
798 |
QCOMPARE(editingFinishedSpy2.count(), 0); |
|
799 |
||
800 |
QTest::keyClick(box2, Qt::Key_Up); |
|
801 |
QTest::keyClick(box2, Qt::Key_Up); |
|
802 |
box2->setFocus(); |
|
803 |
QCOMPARE(editingFinishedSpy1.count(), 1); |
|
804 |
box->setFocus(); |
|
805 |
QCOMPARE(editingFinishedSpy1.count(), 1); |
|
806 |
QCOMPARE(editingFinishedSpy2.count(), 1); |
|
807 |
QTest::keyClick(box, Qt::Key_Up); |
|
808 |
QCOMPARE(editingFinishedSpy1.count(), 1); |
|
809 |
QCOMPARE(editingFinishedSpy2.count(), 1); |
|
810 |
QTest::keyClick(box, Qt::Key_Enter); |
|
811 |
QCOMPARE(editingFinishedSpy1.count(), 2); |
|
812 |
QCOMPARE(editingFinishedSpy2.count(), 1); |
|
813 |
QTest::keyClick(box, Qt::Key_Return); |
|
814 |
QCOMPARE(editingFinishedSpy1.count(), 3); |
|
815 |
QCOMPARE(editingFinishedSpy2.count(), 1); |
|
816 |
box2->setFocus(); |
|
817 |
QCOMPARE(editingFinishedSpy1.count(), 4); |
|
818 |
QCOMPARE(editingFinishedSpy2.count(), 1); |
|
819 |
QTest::keyClick(box2, Qt::Key_Enter); |
|
820 |
QCOMPARE(editingFinishedSpy1.count(), 4); |
|
821 |
QCOMPARE(editingFinishedSpy2.count(), 2); |
|
822 |
QTest::keyClick(box2, Qt::Key_Return); |
|
823 |
QCOMPARE(editingFinishedSpy1.count(), 4); |
|
824 |
QCOMPARE(editingFinishedSpy2.count(), 3); |
|
825 |
testFocusWidget->hide(); |
|
826 |
QCOMPARE(editingFinishedSpy1.count(), 4); |
|
827 |
QCOMPARE(editingFinishedSpy2.count(), 4); |
|
828 |
||
829 |
} |
|
830 |
||
831 |
void tst_QDoubleSpinBox::removeAll() |
|
832 |
{ |
|
833 |
DoubleSpinBox spin(0); |
|
834 |
spin.setPrefix("foo"); |
|
835 |
spin.setSuffix("bar"); |
|
836 |
spin.setValue(0.2); |
|
837 |
spin.setDecimals(1); |
|
838 |
spin.show(); |
|
839 |
#ifdef Q_WS_MAC |
|
840 |
QTest::keyClick(&spin, Qt::Key_Left, Qt::ControlModifier); |
|
841 |
#else |
|
842 |
QTest::keyClick(&spin, Qt::Key_Home); |
|
843 |
#endif |
|
844 |
||
845 |
#ifdef Q_WS_MAC |
|
846 |
QTest::keyClick(&spin, Qt::Key_Right, Qt::ControlModifier|Qt::ShiftModifier); |
|
847 |
#else |
|
848 |
QTest::keyClick(&spin, Qt::Key_End, Qt::ShiftModifier); |
|
849 |
#endif |
|
850 |
||
851 |
QCOMPARE(spin.lineEdit()->selectedText(), QString("foo0.2bar")); |
|
852 |
QTest::keyClick(&spin, Qt::Key_1); |
|
853 |
QCOMPARE(spin.text(), QString("foo1bar")); |
|
854 |
} |
|
855 |
||
856 |
void tst_QDoubleSpinBox::task54433() |
|
857 |
{ |
|
858 |
DoubleSpinBox priceSpinBox; |
|
859 |
priceSpinBox.show(); |
|
860 |
priceSpinBox.setRange(0.0, 999.99); |
|
861 |
priceSpinBox.setDecimals(2); |
|
862 |
priceSpinBox.setValue(999.99); |
|
863 |
QCOMPARE(priceSpinBox.text(), QString("999.99")); |
|
864 |
QCOMPARE(priceSpinBox.value(), 999.99); |
|
865 |
QCOMPARE(priceSpinBox.maximum(), 999.99); |
|
866 |
priceSpinBox.setDecimals(1); |
|
867 |
QCOMPARE(priceSpinBox.value(), 1000.0); |
|
868 |
QCOMPARE(priceSpinBox.maximum(), 1000.0); |
|
869 |
QCOMPARE(priceSpinBox.text(), QString("1000.0")); |
|
870 |
||
871 |
priceSpinBox.setDecimals(2); |
|
872 |
priceSpinBox.setRange(-999.99, 0.0); |
|
873 |
priceSpinBox.setValue(-999.99); |
|
874 |
QCOMPARE(priceSpinBox.text(), QString("-999.99")); |
|
875 |
QCOMPARE(priceSpinBox.value(), -999.99); |
|
876 |
QCOMPARE(priceSpinBox.minimum(), -999.99); |
|
877 |
priceSpinBox.setDecimals(1); |
|
878 |
QCOMPARE(priceSpinBox.value(), -1000.0); |
|
879 |
QCOMPARE(priceSpinBox.minimum(), -1000.0); |
|
880 |
QCOMPARE(priceSpinBox.text(), QString("-1000.0")); |
|
881 |
} |
|
882 |
||
883 |
||
884 |
||
885 |
void tst_QDoubleSpinBox::germanTest() |
|
886 |
{ |
|
887 |
QLocale::setDefault(QLocale(QLocale::German)); |
|
888 |
DoubleSpinBox spin; |
|
889 |
spin.show(); |
|
890 |
spin.setValue(2.12); |
|
891 |
#ifdef Q_WS_MAC |
|
892 |
QTest::keyClick(&spin, Qt::Key_Right, Qt::ControlModifier); |
|
893 |
#else |
|
894 |
QTest::keyClick(&spin, Qt::Key_End); |
|
895 |
#endif |
|
896 |
QTest::keyClick(&spin, Qt::Key_Backspace); |
|
897 |
QCOMPARE(spin.text(), QString("2,1")); |
|
898 |
QTest::keyClick(&spin, Qt::Key_Enter); |
|
899 |
QCOMPARE(spin.text(), QString("2,10")); |
|
900 |
} |
|
901 |
||
902 |
void tst_QDoubleSpinBox::doubleDot() |
|
903 |
{ |
|
904 |
DoubleSpinBox spin; |
|
905 |
spin.show(); |
|
906 |
spin.setValue(2.12); |
|
907 |
QTest::keyClick(&spin, Qt::Key_Backspace); |
|
908 |
QCOMPARE(spin.text(), QString("2.12")); |
|
909 |
#ifdef Q_WS_MAC |
|
910 |
QTest::keyClick(&spin, Qt::Key_Left, Qt::ControlModifier); |
|
911 |
#else |
|
912 |
QTest::keyClick(&spin, Qt::Key_Home); |
|
913 |
#endif |
|
914 |
QTest::keyClick(&spin, Qt::Key_Right, Qt::ShiftModifier); |
|
915 |
QCOMPARE(spin.lineEdit()->selectedText(), QString("2")); |
|
916 |
QTest::keyClick(&spin, Qt::Key_1); |
|
917 |
QCOMPARE(spin.text(), QString("1.12")); |
|
918 |
QCOMPARE(spin.lineEdit()->cursorPosition(), 1); |
|
919 |
QTest::keyClick(&spin, Qt::Key_Period); |
|
920 |
QCOMPARE(spin.text(), QString("1.12")); |
|
921 |
QCOMPARE(spin.lineEdit()->cursorPosition(), 2); |
|
922 |
} |
|
923 |
||
924 |
void tst_QDoubleSpinBox::undoRedo() |
|
925 |
{ |
|
926 |
//test undo/redo feature (in conjunction with the "undoRedoEnabled" property) |
|
927 |
DoubleSpinBox spin(0); |
|
928 |
spin.show(); |
|
929 |
||
930 |
//the undo/redo is disabled by default |
|
931 |
||
932 |
QCOMPARE(spin.value(), 0.0); //this is the default value |
|
933 |
QVERIFY(!spin.lineEdit()->isUndoAvailable()); |
|
934 |
QVERIFY(!spin.lineEdit()->isRedoAvailable()); |
|
935 |
||
936 |
spin.lineEdit()->selectAll(); //ensures everything is selected and will be cleared by typing a key |
|
937 |
QTest::keyClick(&spin, Qt::Key_1); //we put 1 into the spinbox |
|
938 |
QCOMPARE(spin.value(), 1.0); |
|
939 |
QVERIFY(spin.lineEdit()->isUndoAvailable()); |
|
940 |
||
941 |
//testing CTRL+Z (undo) |
|
942 |
int val = QKeySequence(QKeySequence::Undo)[0]; |
|
943 |
if (val != 0) { |
|
944 |
Qt::KeyboardModifiers mods = (Qt::KeyboardModifiers)(val & Qt::KeyboardModifierMask); |
|
945 |
QTest::keyClick(&spin, val & ~mods, mods); |
|
946 |
QCOMPARE(spin.value(), 0.0); |
|
947 |
QVERIFY(!spin.lineEdit()->isUndoAvailable()); |
|
948 |
QVERIFY(spin.lineEdit()->isRedoAvailable()); |
|
949 |
} else { |
|
950 |
QWARN("Undo not tested because no key sequence associated to QKeySequence::Redo"); |
|
951 |
} |
|
952 |
||
953 |
||
954 |
//testing CTRL+Y (redo) |
|
955 |
val = QKeySequence(QKeySequence::Redo)[0]; |
|
956 |
if (val != 0) { |
|
957 |
Qt::KeyboardModifiers mods = (Qt::KeyboardModifiers)(val & Qt::KeyboardModifierMask); |
|
958 |
QTest::keyClick(&spin, val & ~mods, mods); |
|
959 |
QCOMPARE(spin.value(), 1.0); |
|
960 |
QVERIFY(!spin.lineEdit()->isRedoAvailable()); |
|
961 |
QVERIFY(spin.lineEdit()->isUndoAvailable()); |
|
962 |
} else { |
|
963 |
QWARN("Redo not tested because no key sequence associated to QKeySequence::Redo"); |
|
964 |
} |
|
965 |
||
966 |
||
967 |
spin.setValue(55.0); |
|
968 |
QVERIFY(!spin.lineEdit()->isUndoAvailable()); |
|
969 |
QVERIFY(!spin.lineEdit()->isRedoAvailable()); |
|
970 |
} |
|
971 |
||
972 |
struct task199226_DoubleSpinBox : public QDoubleSpinBox |
|
973 |
{ |
|
974 |
task199226_DoubleSpinBox(QWidget *parent = 0) : QDoubleSpinBox(parent) {} |
|
975 |
QLineEdit *lineEdit() { return QAbstractSpinBox::lineEdit(); } |
|
976 |
}; |
|
977 |
||
978 |
void tst_QDoubleSpinBox::task199226_stateAfterEnter() |
|
979 |
{ |
|
980 |
task199226_DoubleSpinBox spin; |
|
981 |
spin.setMinimum(0); |
|
982 |
spin.setMaximum(10); |
|
983 |
spin.setDecimals(0); |
|
984 |
spin.show(); |
|
985 |
QTest::mouseDClick(spin.lineEdit(), Qt::LeftButton); |
|
986 |
QTest::keyClick(spin.lineEdit(), Qt::Key_3); |
|
987 |
QVERIFY(spin.lineEdit()->isModified()); |
|
988 |
QVERIFY(spin.lineEdit()->isUndoAvailable()); |
|
989 |
QTest::keyClick(spin.lineEdit(), Qt::Key_Enter); |
|
990 |
QVERIFY(!spin.lineEdit()->isModified()); |
|
991 |
QVERIFY(!spin.lineEdit()->isUndoAvailable()); |
|
992 |
} |
|
993 |
||
994 |
class task224497_fltMax_DoubleSpinBox : public QDoubleSpinBox |
|
995 |
{ |
|
996 |
public: |
|
997 |
QLineEdit * lineEdit () const { return QDoubleSpinBox::lineEdit(); } |
|
998 |
}; |
|
999 |
||
1000 |
void tst_QDoubleSpinBox::task224497_fltMax() |
|
1001 |
{ |
|
1002 |
task224497_fltMax_DoubleSpinBox *dspin = new task224497_fltMax_DoubleSpinBox; |
|
1003 |
dspin->setMinimum(3); |
|
1004 |
dspin->setMaximum(FLT_MAX); |
|
1005 |
dspin->show(); |
|
1006 |
QTest::qWait(1000); |
|
1007 |
dspin->lineEdit()->selectAll(); |
|
1008 |
QTest::keyClick(dspin->lineEdit(), Qt::Key_Delete); |
|
1009 |
QTest::keyClick(dspin->lineEdit(), Qt::Key_1); |
|
1010 |
QCOMPARE(dspin->cleanText(), QLatin1String("1")); |
|
1011 |
} |
|
1012 |
||
1013 |
void tst_QDoubleSpinBox::task221221() |
|
1014 |
{ |
|
1015 |
QDoubleSpinBox spin; |
|
1016 |
QTest::keyClick(&spin, Qt::Key_1); |
|
1017 |
QCOMPARE(spin.text(), QLatin1String("1")); |
|
1018 |
spin.show(); |
|
1019 |
#ifdef Q_WS_X11 |
|
1020 |
qt_x11_wait_for_window_manager(&spin); |
|
1021 |
#endif |
|
1022 |
QVERIFY(spin.isVisible()); |
|
1023 |
QCOMPARE(spin.text(), QLatin1String("1")); |
|
1024 |
} |
|
1025 |
||
1026 |
void tst_QDoubleSpinBox::task255471_decimalsValidation() |
|
1027 |
{ |
|
1028 |
// QDoubleSpinBox shouldn't crash with large numbers of decimals. Even if |
|
1029 |
// the results are useless ;-) |
|
1030 |
for (int i = 0; i < 32; ++i) |
|
1031 |
{ |
|
1032 |
QDoubleSpinBox spinBox; |
|
1033 |
spinBox.setDecimals(i); |
|
1034 |
spinBox.setMinimum(0.3); |
|
1035 |
spinBox.setMaximum(12); |
|
1036 |
||
1037 |
spinBox.show(); |
|
1038 |
QTRY_VERIFY(spinBox.isVisible()); |
|
1039 |
spinBox.setFocus(); |
|
1040 |
QTRY_VERIFY(spinBox.hasFocus()); |
|
1041 |
||
1042 |
QTest::keyPress(&spinBox, Qt::Key_Right); |
|
1043 |
QTest::keyPress(&spinBox, Qt::Key_Right); |
|
1044 |
QTest::keyPress(&spinBox, Qt::Key_Delete); |
|
1045 |
||
1046 |
// Don't crash! |
|
1047 |
QTest::keyPress(&spinBox, Qt::Key_2); |
|
1048 |
} |
|
1049 |
} |
|
1050 |
||
3
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1051 |
void tst_QDoubleSpinBox::taskQTBUG_5008_textFromValueAndValidate() |
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1052 |
{ |
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1053 |
class DecoratedSpinBox : public QDoubleSpinBox |
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1054 |
{ |
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1055 |
public: |
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1056 |
DecoratedSpinBox() |
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1057 |
{ |
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1058 |
setLocale(QLocale::French); |
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1059 |
setMaximum(100000000); |
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1060 |
setValue(1000); |
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1061 |
} |
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1062 |
|
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1063 |
QLineEdit *lineEdit() const |
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1064 |
{ |
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1065 |
return QDoubleSpinBox::lineEdit(); |
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1066 |
} |
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1067 |
|
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1068 |
//we use the French delimiters here |
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1069 |
QString textFromValue (double value) const |
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1070 |
{ |
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1071 |
return locale().toString(value); |
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1072 |
} |
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1073 |
} spinbox; |
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1074 |
spinbox.show(); |
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1075 |
spinbox.activateWindow(); |
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1076 |
spinbox.setFocus(); |
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1077 |
QApplication::setActiveWindow(&spinbox); |
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1078 |
QTest::qWaitForWindowShown(&spinbox); |
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1079 |
QTRY_VERIFY(spinbox.hasFocus()); |
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1080 |
QTRY_COMPARE(static_cast<QWidget *>(&spinbox), QApplication::activeWindow()); |
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1081 |
QCOMPARE(spinbox.text(), spinbox.locale().toString(spinbox.value())); |
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1082 |
spinbox.lineEdit()->setCursorPosition(2); //just after the first thousand separator |
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1083 |
QTest::keyClick(0, Qt::Key_0); // let's insert a 0 |
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1084 |
QCOMPARE(spinbox.value(), 10000.); |
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1085 |
spinbox.clearFocus(); //make sure the value is correctly formatted |
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1086 |
QCOMPARE(spinbox.text(), spinbox.locale().toString(spinbox.value())); |
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1087 |
} |
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1088 |
|
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1089 |
void tst_QDoubleSpinBox::taskQTBUG_6670_selectAllWithPrefix() |
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1090 |
{ |
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1091 |
DoubleSpinBox spin; |
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1092 |
spin.setPrefix("$ "); |
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1093 |
spin.lineEdit()->selectAll(); |
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1094 |
QTest::keyClick(spin.lineEdit(), Qt::Key_1); |
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1095 |
QCOMPARE(spin.value(), 1.); |
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1096 |
QTest::keyClick(spin.lineEdit(), Qt::Key_2); |
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1097 |
QCOMPARE(spin.value(), 12.); |
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1098 |
} |
0 | 1099 |
|
4
3b1da2848fc7
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
3
diff
changeset
|
1100 |
void tst_QDoubleSpinBox::taskQTBUG_6496_fiddlingWithPrecision() |
3b1da2848fc7
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
3
diff
changeset
|
1101 |
{ |
3b1da2848fc7
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
3
diff
changeset
|
1102 |
QDoubleSpinBox dsb; |
3b1da2848fc7
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
3
diff
changeset
|
1103 |
dsb.setRange(0, 0.991); |
3b1da2848fc7
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
3
diff
changeset
|
1104 |
dsb.setDecimals(1); |
3b1da2848fc7
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
3
diff
changeset
|
1105 |
QCOMPARE(dsb.maximum(), 1.0); |
3b1da2848fc7
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
3
diff
changeset
|
1106 |
dsb.setDecimals(2); |
3b1da2848fc7
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
3
diff
changeset
|
1107 |
QCOMPARE(dsb.maximum(), 0.99); |
3b1da2848fc7
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
3
diff
changeset
|
1108 |
dsb.setDecimals(3); |
3b1da2848fc7
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
3
diff
changeset
|
1109 |
QCOMPARE(dsb.maximum(), 0.991); |
3b1da2848fc7
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
3
diff
changeset
|
1110 |
} |
3b1da2848fc7
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
3
diff
changeset
|
1111 |
|
0 | 1112 |
QTEST_MAIN(tst_QDoubleSpinBox) |
1113 |
#include "tst_qdoublespinbox.moc" |