From 43f52f93b558cb1c095d445c41c8be3e84ca81c3 Mon Sep 17 00:00:00 2001 From: Keith Gardner Date: Tue, 22 Apr 2014 21:31:47 -0700 Subject: Updated corelib's unit tests to use QSignalSpy's functor constructor The intent is to provide compile time validation of signals and to help detect signal overloading in the future. Change-Id: I9d5d46ed4b70c5d0cd407deb5928b1e76d37e007 Reviewed-by: Olivier Goffart Reviewed-by: Frederik Gladhorn --- .../thread/qfuturewatcher/tst_qfuturewatcher.cpp | 38 +++++++++++----------- 1 file changed, 19 insertions(+), 19 deletions(-) (limited to 'tests/auto/corelib/thread') diff --git a/tests/auto/corelib/thread/qfuturewatcher/tst_qfuturewatcher.cpp b/tests/auto/corelib/thread/qfuturewatcher/tst_qfuturewatcher.cpp index b2b0eace34..5c9f26b70e 100644 --- a/tests/auto/corelib/thread/qfuturewatcher/tst_qfuturewatcher.cpp +++ b/tests/auto/corelib/thread/qfuturewatcher/tst_qfuturewatcher.cpp @@ -87,8 +87,8 @@ void tst_QFutureWatcher::startFinish() { QFutureWatcher futureWatcher; - QSignalSpy startedSpy(&futureWatcher, SIGNAL(started())); - QSignalSpy finishedSpy(&futureWatcher, SIGNAL(finished())); + QSignalSpy startedSpy(&futureWatcher, &QFutureWatcher::started); + QSignalSpy finishedSpy(&futureWatcher, &QFutureWatcher::finished); QVERIFY(startedSpy.isValid()); QVERIFY(finishedSpy.isValid()); @@ -322,7 +322,7 @@ void tst_QFutureWatcher::futureSignals() a.reportStarted(); f.setFuture(a.future()); - QSignalSpy progressSpy(&f, SIGNAL(progressValueChanged(int))); + QSignalSpy progressSpy(&f, &QFutureWatcher::progressValueChanged); QVERIFY(progressSpy.isValid()); const int progress = 1; a.setProgressValue(progress); @@ -331,8 +331,8 @@ void tst_QFutureWatcher::futureSignals() QCOMPARE(progressSpy.takeFirst().at(0).toInt(), 0); QCOMPARE(progressSpy.takeFirst().at(0).toInt(), 1); - QSignalSpy finishedSpy(&f, SIGNAL(finished())); - QSignalSpy resultReadySpy(&f, SIGNAL(resultReadyAt(int))); + QSignalSpy finishedSpy(&f, &QFutureWatcher::finished); + QSignalSpy resultReadySpy(&f, &QFutureWatcher::resultReadyAt); QVERIFY(finishedSpy.isValid()); QVERIFY(resultReadySpy.isValid()); @@ -374,10 +374,10 @@ void tst_QFutureWatcher::watchFinishedFuture() #endif connect(&watcher, SIGNAL(resultReadyAt(int)), &object, SLOT(resultReadyAt(int))); - QSignalSpy startedSpy(&watcher, SIGNAL(started())); - QSignalSpy finishedSpy(&watcher, SIGNAL(finished())); - QSignalSpy resultReadySpy(&watcher, SIGNAL(resultReadyAt(int))); - QSignalSpy canceledSpy(&watcher, SIGNAL(canceled())); + QSignalSpy startedSpy(&watcher, &QFutureWatcher::started); + QSignalSpy finishedSpy(&watcher, &QFutureWatcher::finished); + QSignalSpy resultReadySpy(&watcher, &QFutureWatcher::resultReadyAt); + QSignalSpy canceledSpy(&watcher, &QFutureWatcher::canceled); QVERIFY(startedSpy.isValid()); QVERIFY(finishedSpy.isValid()); @@ -408,10 +408,10 @@ void tst_QFutureWatcher::watchCanceledFuture() #endif connect(&watcher, SIGNAL(resultReadyAt(int)), &object, SLOT(resultReadyAt(int))); - QSignalSpy startedSpy(&watcher, SIGNAL(started())); - QSignalSpy finishedSpy(&watcher, SIGNAL(finished())); - QSignalSpy resultReadySpy(&watcher, SIGNAL(resultReadyAt(int))); - QSignalSpy canceledSpy(&watcher, SIGNAL(canceled())); + QSignalSpy startedSpy(&watcher, &QFutureWatcher::started); + QSignalSpy finishedSpy(&watcher, &QFutureWatcher::finished); + QSignalSpy resultReadySpy(&watcher, &QFutureWatcher::resultReadyAt); + QSignalSpy canceledSpy(&watcher, &QFutureWatcher::canceled); QVERIFY(startedSpy.isValid()); QVERIFY(finishedSpy.isValid()); @@ -439,8 +439,8 @@ void tst_QFutureWatcher::disconnectRunningFuture() SignalSlotObject object; connect(watcher, SIGNAL(resultReadyAt(int)), &object, SLOT(resultReadyAt(int))); - QSignalSpy finishedSpy(watcher, SIGNAL(finished())); - QSignalSpy resultReadySpy(watcher, SIGNAL(resultReadyAt(int))); + QSignalSpy finishedSpy(watcher, &QFutureWatcher::finished); + QSignalSpy resultReadySpy(watcher, &QFutureWatcher::resultReadyAt); QVERIFY(finishedSpy.isValid()); QVERIFY(resultReadySpy.isValid()); @@ -634,7 +634,7 @@ void tst_QFutureWatcher::changeFuture() SignalSlotObject object; connect(&watcher, SIGNAL(resultReadyAt(int)), &object, SLOT(resultReadyAt(int))); - QSignalSpy resultReadySpy(&watcher, SIGNAL(resultReadyAt(int))); + QSignalSpy resultReadySpy(&watcher, &QFutureWatcher::resultReadyAt); QVERIFY(resultReadySpy.isValid()); watcher.setFuture(a); // Watch 'a' which will genere a resultReady event. @@ -666,7 +666,7 @@ void tst_QFutureWatcher::cancelEvents() SignalSlotObject object; connect(&watcher, SIGNAL(resultReadyAt(int)), &object, SLOT(resultReadyAt(int))); - QSignalSpy resultReadySpy(&watcher, SIGNAL(resultReadyAt(int))); + QSignalSpy resultReadySpy(&watcher, &QFutureWatcher::resultReadyAt); QVERIFY(resultReadySpy.isValid()); watcher.setFuture(a); @@ -694,7 +694,7 @@ void tst_QFutureWatcher::pauseEvents() SignalSlotObject object; connect(&watcher, SIGNAL(resultReadyAt(int)), &object, SLOT(resultReadyAt(int))); - QSignalSpy resultReadySpy(&watcher, SIGNAL(resultReadyAt(int))); + QSignalSpy resultReadySpy(&watcher, &QFutureWatcher::resultReadyAt); QVERIFY(resultReadySpy.isValid()); watcher.setFuture(a); @@ -720,7 +720,7 @@ void tst_QFutureWatcher::pauseEvents() SignalSlotObject object; connect(&watcher, SIGNAL(resultReadyAt(int)), &object, SLOT(resultReadyAt(int))); - QSignalSpy resultReadySpy(&watcher, SIGNAL(resultReadyAt(int))); + QSignalSpy resultReadySpy(&watcher, &QFutureWatcher::resultReadyAt); QVERIFY(resultReadySpy.isValid()); watcher.setFuture(a); -- cgit v1.2.3