summaryrefslogtreecommitdiffstats
path: root/tests
diff options
context:
space:
mode:
authorDaniel Molkentin <daniel.molkentin@nokia.com>2009-05-05 16:50:31 (GMT)
committerMaurice Kalinowski <maurice.kalinowski@nokia.com>2009-05-05 16:50:31 (GMT)
commit98d485b54d2da97b83b7ff2379b31039923f922e (patch)
tree887938de47713a3c48a0c12f753117d4a0d4b9ba /tests
parent2137f41ca0df3c83abce9dd386074e0fd09a33dc (diff)
downloadQt-98d485b54d2da97b83b7ff2379b31039923f922e.zip
Qt-98d485b54d2da97b83b7ff2379b31039923f922e.tar.gz
Qt-98d485b54d2da97b83b7ff2379b31039923f922e.tar.bz2
Fix behavior of QButtonGroup::addButton(QAbstractButton, int).
The method did not adhere to the documented behavior nor according to its precedessor in Qt 3 times. Now, when being passed -1 as argument, it will automatically assign ids. They will all be negative, starting from -2. Reviewed-by: mae <qt-info@nokia.com>
Diffstat (limited to 'tests')
-rw-r--r--tests/auto/qbuttongroup/tst_qbuttongroup.cpp49
1 files changed, 45 insertions, 4 deletions
diff --git a/tests/auto/qbuttongroup/tst_qbuttongroup.cpp b/tests/auto/qbuttongroup/tst_qbuttongroup.cpp
index 15cca56..4bb414c 100644
--- a/tests/auto/qbuttongroup/tst_qbuttongroup.cpp
+++ b/tests/auto/qbuttongroup/tst_qbuttongroup.cpp
@@ -92,11 +92,15 @@ private slots:
void exclusive();
void exclusiveWithActions();
void testSignals();
-
void checkedButton();
void task106609();
+ // fixed for Qt 4.6.0
+#if QT_VERSION >= 0x040600
+ void autoIncrementId();
+#endif
+
void task209485_removeFromGroupInEventHandler_data();
void task209485_removeFromGroupInEventHandler();
};
@@ -329,13 +333,19 @@ void tst_QButtonGroup::testSignals()
QCOMPARE(clickedSpy.count(), 1);
QCOMPARE(clickedIdSpy.count(), 1);
- QVERIFY(clickedIdSpy.takeFirst().at(0).toInt() == -1);
+
+ int expectedId = -1;
+#if QT_VERSION >= 0x040600
+ expectedId = -2;
+#endif
+
+ QVERIFY(clickedIdSpy.takeFirst().at(0).toInt() == expectedId);
QCOMPARE(pressedSpy.count(), 1);
QCOMPARE(pressedIdSpy.count(), 1);
- QVERIFY(pressedIdSpy.takeFirst().at(0).toInt() == -1);
+ QVERIFY(pressedIdSpy.takeFirst().at(0).toInt() == expectedId);
QCOMPARE(releasedSpy.count(), 1);
QCOMPARE(releasedIdSpy.count(), 1);
- QVERIFY(releasedIdSpy.takeFirst().at(0).toInt() == -1);
+ QVERIFY(releasedIdSpy.takeFirst().at(0).toInt() == expectedId);
clickedSpy.clear();
clickedIdSpy.clear();
@@ -483,5 +493,36 @@ void tst_QButtonGroup::task209485_removeFromGroupInEventHandler()
QCOMPARE(spy1.count() + spy2.count(), signalCount);
}
+#if QT_VERSION >= 0x040600
+void tst_QButtonGroup::autoIncrementId()
+{
+ QDialog dlg(0);
+ QButtonGroup *buttons = new QButtonGroup(&dlg);
+ QVBoxLayout *vbox = new QVBoxLayout(&dlg);
+
+ QRadioButton *radio1 = new QRadioButton(&dlg);
+ radio1->setText("radio1");
+ QRadioButton *radio2 = new QRadioButton(&dlg);
+ radio2->setText("radio2");
+ QRadioButton *radio3 = new QRadioButton(&dlg);
+ radio3->setText("radio3");
+
+ buttons->addButton(radio1);
+ vbox->addWidget(radio1);
+ buttons->addButton(radio2);
+ vbox->addWidget(radio2);
+ buttons->addButton(radio3);
+ vbox->addWidget(radio3);
+
+ radio1->setChecked(true);
+
+ QVERIFY(buttons->id(radio1) == -2);
+ QVERIFY(buttons->id(radio2) == -3);
+ QVERIFY(buttons->id(radio3) == -4);
+
+ dlg.show();
+}
+#endif
+
QTEST_MAIN(tst_QButtonGroup)
#include "tst_qbuttongroup.moc"