summaryrefslogtreecommitdiffstats
path: root/tests/auto/widgets/kernel
diff options
context:
space:
mode:
authorMarc Mutz <marc.mutz@kdab.com>2016-09-30 15:16:55 +0200
committerMarc Mutz <marc.mutz@kdab.com>2016-11-30 07:24:47 +0000
commit2fd3d8ea9e3e1829653942431070a83569bab6eb (patch)
tree7803eed14bf3064b4d2c1420c0f0c94482463b6d /tests/auto/widgets/kernel
parent97b8fdab7d3604294476bf566b024ecbd5b412b0 (diff)
tests/auto/widgets: use QCOMPARE(., nullptr)
.. instead of manually casted 0s. QCOMPARE(., nullptr) was added for Qt 5.8. Make use of the new API. In tst_qwidget.cpp, as a drive-by, change qApp->focusWidget() -> QApplication::focusWidget() Change-Id: I1331b8916b026d48e01534d1ed0b3d72f3f3d50c Reviewed-by: Friedemann Kleint <Friedemann.Kleint@qt.io>
Diffstat (limited to 'tests/auto/widgets/kernel')
-rw-r--r--tests/auto/widgets/kernel/qlayout/tst_qlayout.cpp2
-rw-r--r--tests/auto/widgets/kernel/qstackedlayout/tst_qstackedlayout.cpp6
-rw-r--r--tests/auto/widgets/kernel/qwidget/tst_qwidget.cpp56
-rw-r--r--tests/auto/widgets/kernel/qwindowcontainer/tst_qwindowcontainer.cpp2
4 files changed, 33 insertions, 33 deletions
diff --git a/tests/auto/widgets/kernel/qlayout/tst_qlayout.cpp b/tests/auto/widgets/kernel/qlayout/tst_qlayout.cpp
index 47fc002196..829d0ea098 100644
--- a/tests/auto/widgets/kernel/qlayout/tst_qlayout.cpp
+++ b/tests/auto/widgets/kernel/qlayout/tst_qlayout.cpp
@@ -297,7 +297,7 @@ void tst_QLayout::warnIfWrongParent()
QHBoxLayout lay;
lay.setParent(&root);
QTest::ignoreMessage(QtWarningMsg, "QLayout::parentWidget: A layout can only have another layout as a parent.");
- QCOMPARE(lay.parentWidget(), static_cast<QWidget*>(0));
+ QCOMPARE(lay.parentWidget(), nullptr);
}
void tst_QLayout::controlTypes()
diff --git a/tests/auto/widgets/kernel/qstackedlayout/tst_qstackedlayout.cpp b/tests/auto/widgets/kernel/qstackedlayout/tst_qstackedlayout.cpp
index badeca69bb..835b6ca799 100644
--- a/tests/auto/widgets/kernel/qstackedlayout/tst_qstackedlayout.cpp
+++ b/tests/auto/widgets/kernel/qstackedlayout/tst_qstackedlayout.cpp
@@ -122,7 +122,7 @@ void tst_QStackedLayout::testCase()
// Nothing in layout
QCOMPARE(testLayout->currentIndex(), -1);
- QCOMPARE(testLayout->currentWidget(), static_cast<QWidget*>(0));
+ QCOMPARE(testLayout->currentWidget(), nullptr);
QCOMPARE(testLayout->count(), 0);
// One widget added to layout
@@ -163,7 +163,7 @@ void tst_QStackedLayout::testCase()
QCOMPARE(spy.at(0).at(0).toInt(), -1);
spy.clear();
QCOMPARE(testLayout->currentIndex(), -1);
- QCOMPARE(testLayout->currentWidget(), static_cast<QWidget*>(0));
+ QCOMPARE(testLayout->currentWidget(), nullptr);
QCOMPARE(testLayout->count(), 0);
// Another widget inserted at current index.
@@ -217,7 +217,7 @@ void tst_QStackedLayout::testCase()
QVERIFY(w3->isVisible());
testLayout->removeWidget(w3);
QCOMPARE(testLayout->currentIndex(), -1);
- QCOMPARE(testLayout->currentWidget(), static_cast<QWidget*>(0));
+ QCOMPARE(testLayout->currentWidget(), nullptr);
}
void tst_QStackedLayout::deleteCurrent()
diff --git a/tests/auto/widgets/kernel/qwidget/tst_qwidget.cpp b/tests/auto/widgets/kernel/qwidget/tst_qwidget.cpp
index 0c25a01ba0..731a8c5d91 100644
--- a/tests/auto/widgets/kernel/qwidget/tst_qwidget.cpp
+++ b/tests/auto/widgets/kernel/qwidget/tst_qwidget.cpp
@@ -2188,8 +2188,8 @@ void tst_QWidget::showMinimizedKeepsFocus()
QTRY_COMPARE(qApp->focusWidget(), child);
delete child;
- QCOMPARE(window.focusWidget(), static_cast<QWidget*>(0));
- QCOMPARE(qApp->focusWidget(), static_cast<QWidget*>(0));
+ QCOMPARE(window.focusWidget(), nullptr);
+ QCOMPARE(QApplication::focusWidget(), nullptr);
}
//testing reparenting the focus widget
@@ -2207,8 +2207,8 @@ void tst_QWidget::showMinimizedKeepsFocus()
child->setParent(0);
QScopedPointer<QWidget> childGuard(child);
- QCOMPARE(window.focusWidget(), static_cast<QWidget*>(0));
- QCOMPARE(qApp->focusWidget(), static_cast<QWidget*>(0));
+ QCOMPARE(window.focusWidget(), nullptr);
+ QCOMPARE(QApplication::focusWidget(), nullptr);
}
//testing setEnabled(false)
@@ -2225,8 +2225,8 @@ void tst_QWidget::showMinimizedKeepsFocus()
QTRY_COMPARE(qApp->focusWidget(), child);
child->setEnabled(false);
- QCOMPARE(window.focusWidget(), static_cast<QWidget*>(0));
- QCOMPARE(qApp->focusWidget(), static_cast<QWidget*>(0));
+ QCOMPARE(window.focusWidget(), nullptr);
+ QCOMPARE(QApplication::focusWidget(), nullptr);
}
//testing clearFocus
@@ -2245,14 +2245,14 @@ void tst_QWidget::showMinimizedKeepsFocus()
QTRY_COMPARE(qApp->focusWidget(), child);
child->clearFocus();
- QCOMPARE(window.focusWidget(), static_cast<QWidget*>(0));
- QCOMPARE(qApp->focusWidget(), static_cast<QWidget*>(0));
+ QCOMPARE(window.focusWidget(), nullptr);
+ QCOMPARE(QApplication::focusWidget(), nullptr);
window.showMinimized();
QTest::qWait(30);
QTRY_VERIFY(window.isMinimized());
- QCOMPARE(window.focusWidget(), static_cast<QWidget*>(0));
- QTRY_COMPARE(qApp->focusWidget(), static_cast<QWidget*>(0));
+ QCOMPARE(window.focusWidget(), nullptr);
+ QTRY_COMPARE(QApplication::focusWidget(), nullptr);
window.showNormal();
qApp->setActiveWindow(&window);
@@ -5260,12 +5260,12 @@ void tst_QWidget::setFocus()
child1.setFocus();
QVERIFY(!child1.hasFocus());
QCOMPARE(window.focusWidget(), &child1);
- QCOMPARE(QApplication::focusWidget(), static_cast<QWidget *>(0));
+ QCOMPARE(QApplication::focusWidget(), nullptr);
child2.setFocus();
QVERIFY(!child2.hasFocus());
QCOMPARE(window.focusWidget(), &child2);
- QCOMPARE(QApplication::focusWidget(), static_cast<QWidget *>(0));
+ QCOMPARE(QApplication::focusWidget(), nullptr);
}
{
@@ -5294,12 +5294,12 @@ void tst_QWidget::setFocus()
child1.setFocus();
QVERIFY(!child1.hasFocus());
QCOMPARE(window.focusWidget(), &child1);
- QCOMPARE(QApplication::focusWidget(), static_cast<QWidget *>(0));
+ QCOMPARE(QApplication::focusWidget(), nullptr);
child2.setFocus();
QVERIFY(!child2.hasFocus());
QCOMPARE(window.focusWidget(), &child2);
- QCOMPARE(QApplication::focusWidget(), static_cast<QWidget *>(0));
+ QCOMPARE(QApplication::focusWidget(), nullptr);
}
{
@@ -5355,8 +5355,8 @@ void tst_QWidget::setFocus()
child1.setFocus();
QVERIFY(!child1.hasFocus());
- QCOMPARE(window.focusWidget(), static_cast<QWidget *>(0));
- QCOMPARE(QApplication::focusWidget(), static_cast<QWidget *>(0));
+ QCOMPARE(window.focusWidget(), nullptr);
+ QCOMPARE(QApplication::focusWidget(), nullptr);
child1.show();
QApplication::processEvents();
@@ -5396,33 +5396,33 @@ void tst_QWidget::setFocus()
child1.setFocus();
QVERIFY(!child1.hasFocus());
- QCOMPARE(window.focusWidget(), static_cast<QWidget *>(0));
- QCOMPARE(QApplication::focusWidget(), static_cast<QWidget *>(0));
+ QCOMPARE(window.focusWidget(), nullptr);
+ QCOMPARE(QApplication::focusWidget(), nullptr);
child1.hide();
QVERIFY(!child1.hasFocus());
- QCOMPARE(window.focusWidget(), static_cast<QWidget *>(0));
- QCOMPARE(QApplication::focusWidget(), static_cast<QWidget *>(0));
+ QCOMPARE(window.focusWidget(), nullptr);
+ QCOMPARE(QApplication::focusWidget(), nullptr);
child1.show();
QVERIFY(!child1.hasFocus());
- QCOMPARE(window.focusWidget(), static_cast<QWidget *>(0));
- QCOMPARE(QApplication::focusWidget(), static_cast<QWidget *>(0));
+ QCOMPARE(window.focusWidget(), nullptr);
+ QCOMPARE(QApplication::focusWidget(), nullptr);
child2.setFocus();
QVERIFY(!child2.hasFocus());
- QCOMPARE(window.focusWidget(), static_cast<QWidget *>(0));
- QCOMPARE(QApplication::focusWidget(), static_cast<QWidget *>(0));
+ QCOMPARE(window.focusWidget(), nullptr);
+ QCOMPARE(QApplication::focusWidget(), nullptr);
child2.hide();
QVERIFY(!child2.hasFocus());
- QCOMPARE(window.focusWidget(), static_cast<QWidget *>(0));
- QCOMPARE(QApplication::focusWidget(), static_cast<QWidget *>(0));
+ QCOMPARE(window.focusWidget(), nullptr);
+ QCOMPARE(QApplication::focusWidget(), nullptr);
child2.show();
QVERIFY(!child2.hasFocus());
- QCOMPARE(window.focusWidget(), static_cast<QWidget *>(0));
- QCOMPARE(QApplication::focusWidget(), static_cast<QWidget *>(0));
+ QCOMPARE(window.focusWidget(), nullptr);
+ QCOMPARE(QApplication::focusWidget(), nullptr);
}
}
diff --git a/tests/auto/widgets/kernel/qwindowcontainer/tst_qwindowcontainer.cpp b/tests/auto/widgets/kernel/qwindowcontainer/tst_qwindowcontainer.cpp
index 406b21ccf6..5e3868ea8f 100644
--- a/tests/auto/widgets/kernel/qwindowcontainer/tst_qwindowcontainer.cpp
+++ b/tests/auto/widgets/kernel/qwindowcontainer/tst_qwindowcontainer.cpp
@@ -161,7 +161,7 @@ void tst_QWindowContainer::testOwnership()
delete container;
- QCOMPARE(window.data(), (QWindow *) 0);
+ QCOMPARE(window.data(), nullptr);
}