diff options
author | Friedemann Kleint <Friedemann.Kleint@theqtcompany.com> | 2015-07-24 15:27:58 +0200 |
---|---|---|
committer | Friedemann Kleint <Friedemann.Kleint@theqtcompany.com> | 2015-07-29 09:44:39 +0000 |
commit | 0ea3c24cfe7d1057964fe864924a7ee083764084 (patch) | |
tree | 681b7df0a201641203c936e748afd7d6a7ec39b5 | |
parent | bb87365ffabcba3a70dd49a4c3232a12b5b224a3 (diff) |
tests/qml: Replace Q[TRY]_VERIFY(a == b) by Q[TRY]_COMPARE(a, b).
- Replace Q[TRY]_VERIFY(pointer == 0) by Q[TRY]_VERIFY(!pointer).
- Replace Q[TRY]_VERIFY(smartPointer == 0) by
Q[TRY]_VERIFY(smartPointer.isNull()).
- Replace Q[TRY]_VERIFY(a == b) by Q[TRY]_COMPARE(a, b) and
add casts where necessary. The values will then be logged
should a test fail.
Change-Id: I8cc97fd9b48fc789a849e9527c292c4e05accd97
Reviewed-by: Mitch Curtis <mitch.curtis@theqtcompany.com>
29 files changed, 368 insertions, 367 deletions
diff --git a/tests/auto/qml/animation/qpauseanimationjob/tst_qpauseanimationjob.cpp b/tests/auto/qml/animation/qpauseanimationjob/tst_qpauseanimationjob.cpp index 21384ef3d8..92065d35e3 100644 --- a/tests/auto/qml/animation/qpauseanimationjob/tst_qpauseanimationjob.cpp +++ b/tests/auto/qml/animation/qpauseanimationjob/tst_qpauseanimationjob.cpp @@ -120,10 +120,10 @@ void tst_QPauseAnimationJob::changeDirectionWhileRunning() animation.setDuration(400); animation.start(); QTest::qWait(100); - QVERIFY(animation.state() == QAbstractAnimationJob::Running); + QCOMPARE(animation.state(), QAbstractAnimationJob::Running); animation.setDirection(QAbstractAnimationJob::Backward); QTest::qWait(animation.totalDuration() + 50); - QVERIFY(animation.state() == QAbstractAnimationJob::Stopped); + QCOMPARE(animation.state(), QAbstractAnimationJob::Stopped); } void tst_QPauseAnimationJob::noTimerUpdates_data() @@ -155,7 +155,7 @@ void tst_QPauseAnimationJob::noTimerUpdates() QEXPECT_FAIL("", winTimerError, Abort); #endif - QVERIFY(animation.state() == QAbstractAnimationJob::Stopped); + QCOMPARE(animation.state(), QAbstractAnimationJob::Stopped); const int expectedLoopCount = 1 + loopCount; #ifdef Q_OS_WIN @@ -183,13 +183,13 @@ void tst_QPauseAnimationJob::multiplePauseAnimations() if (animation.state() != QAbstractAnimationJob::Stopped) QEXPECT_FAIL("", winTimerError, Abort); #endif - QVERIFY(animation.state() == QAbstractAnimationJob::Stopped); + QCOMPARE(animation.state(), QAbstractAnimationJob::Stopped); #ifdef Q_OS_WIN if (animation2.state() != QAbstractAnimationJob::Running) QEXPECT_FAIL("", winTimerError, Abort); #endif - QVERIFY(animation2.state() == QAbstractAnimationJob::Running); + QCOMPARE(animation2.state(), QAbstractAnimationJob::Running); #ifdef Q_OS_WIN if (animation.m_updateCurrentTimeCount != 2) @@ -224,7 +224,7 @@ void tst_QPauseAnimationJob::pauseAndPropertyAnimations() QCOMPARE(animation.state(), QAbstractAnimationJob::Running); QTRY_COMPARE(animation.state(), QAbstractAnimationJob::Running); - QVERIFY(pause.state() == QAbstractAnimationJob::Running); + QCOMPARE(pause.state(), QAbstractAnimationJob::Running); QVERIFY2(pause.m_updateCurrentTimeCount >= 2, QByteArrayLiteral("pause.m_updateCurrentTimeCount=") + QByteArray::number(pause.m_updateCurrentTimeCount)); @@ -245,7 +245,7 @@ void tst_QPauseAnimationJob::pauseResume() QCOMPARE(animation.state(), QAbstractAnimationJob::Paused); animation.start(); QTest::qWait(300); - QTRY_VERIFY(animation.state() == QAbstractAnimationJob::Stopped); + QTRY_COMPARE(animation.state(), QAbstractAnimationJob::Stopped); QVERIFY2(animation.m_updateCurrentTimeCount >= 3, QByteArrayLiteral("animation.m_updateCurrentTimeCount=") + QByteArray::number(animation.m_updateCurrentTimeCount)); } @@ -266,39 +266,39 @@ void tst_QPauseAnimationJob::sequentialPauseGroup() QCOMPARE(animation2.m_updateCurrentTimeCount, 0); QCOMPARE(animation3.m_updateCurrentTimeCount, 0); - QVERIFY(group.state() == QAbstractAnimationJob::Running); - QVERIFY(animation1.state() == QAbstractAnimationJob::Running); - QVERIFY(animation2.state() == QAbstractAnimationJob::Stopped); - QVERIFY(animation3.state() == QAbstractAnimationJob::Stopped); + QCOMPARE(group.state(), QAbstractAnimationJob::Running); + QCOMPARE(animation1.state(), QAbstractAnimationJob::Running); + QCOMPARE(animation2.state(), QAbstractAnimationJob::Stopped); + QCOMPARE(animation3.state(), QAbstractAnimationJob::Stopped); group.setCurrentTime(250); QCOMPARE(animation1.m_updateCurrentTimeCount, 2); QCOMPARE(animation2.m_updateCurrentTimeCount, 1); QCOMPARE(animation3.m_updateCurrentTimeCount, 0); - QVERIFY(group.state() == QAbstractAnimationJob::Running); - QVERIFY(animation1.state() == QAbstractAnimationJob::Stopped); + QCOMPARE(group.state(), QAbstractAnimationJob::Running); + QCOMPARE(animation1.state(), QAbstractAnimationJob::Stopped); QCOMPARE((QAbstractAnimationJob*)&animation2, group.currentAnimation()); - QVERIFY(animation2.state() == QAbstractAnimationJob::Running); - QVERIFY(animation3.state() == QAbstractAnimationJob::Stopped); + QCOMPARE(animation2.state(), QAbstractAnimationJob::Running); + QCOMPARE(animation3.state(), QAbstractAnimationJob::Stopped); group.setCurrentTime(500); QCOMPARE(animation1.m_updateCurrentTimeCount, 2); QCOMPARE(animation2.m_updateCurrentTimeCount, 2); QCOMPARE(animation3.m_updateCurrentTimeCount, 1); - QVERIFY(group.state() == QAbstractAnimationJob::Running); - QVERIFY(animation1.state() == QAbstractAnimationJob::Stopped); - QVERIFY(animation2.state() == QAbstractAnimationJob::Stopped); + QCOMPARE(group.state(), QAbstractAnimationJob::Running); + QCOMPARE(animation1.state(), QAbstractAnimationJob::Stopped); + QCOMPARE(animation2.state(), QAbstractAnimationJob::Stopped); QCOMPARE((QAbstractAnimationJob*)&animation3, group.currentAnimation()); - QVERIFY(animation3.state() == QAbstractAnimationJob::Running); + QCOMPARE(animation3.state(), QAbstractAnimationJob::Running); group.setCurrentTime(750); - QVERIFY(group.state() == QAbstractAnimationJob::Stopped); - QVERIFY(animation1.state() == QAbstractAnimationJob::Stopped); - QVERIFY(animation2.state() == QAbstractAnimationJob::Stopped); - QVERIFY(animation3.state() == QAbstractAnimationJob::Stopped); + QCOMPARE(group.state(), QAbstractAnimationJob::Stopped); + QCOMPARE(animation1.state(), QAbstractAnimationJob::Stopped); + QCOMPARE(animation2.state(), QAbstractAnimationJob::Stopped); + QCOMPARE(animation3.state(), QAbstractAnimationJob::Stopped); QCOMPARE(animation1.m_updateCurrentTimeCount, 2); QCOMPARE(animation2.m_updateCurrentTimeCount, 2); @@ -318,22 +318,22 @@ void tst_QPauseAnimationJob::sequentialGroupWithPause() group.start(); - QVERIFY(group.state() == QAbstractAnimationJob::Running); - QVERIFY(animation.state() == QAbstractAnimationJob::Running); - QVERIFY(pause.state() == QAbstractAnimationJob::Stopped); + QCOMPARE(group.state(), QAbstractAnimationJob::Running); + QCOMPARE(animation.state(), QAbstractAnimationJob::Running); + QCOMPARE(pause.state(), QAbstractAnimationJob::Stopped); group.setCurrentTime(300); - QVERIFY(group.state() == QAbstractAnimationJob::Running); - QVERIFY(animation.state() == QAbstractAnimationJob::Stopped); + QCOMPARE(group.state(), QAbstractAnimationJob::Running); + QCOMPARE(animation.state(), QAbstractAnimationJob::Stopped); QCOMPARE((QAbstractAnimationJob*)&pause, group.currentAnimation()); - QVERIFY(pause.state() == QAbstractAnimationJob::Running); + QCOMPARE(pause.state(), QAbstractAnimationJob::Running); group.setCurrentTime(600); - QVERIFY(group.state() == QAbstractAnimationJob::Stopped); - QVERIFY(animation.state() == QAbstractAnimationJob::Stopped); - QVERIFY(pause.state() == QAbstractAnimationJob::Stopped); + QCOMPARE(group.state(), QAbstractAnimationJob::Stopped); + QCOMPARE(animation.state(), QAbstractAnimationJob::Stopped); + QCOMPARE(pause.state(), QAbstractAnimationJob::Stopped); QCOMPARE(pause.m_updateCurrentTimeCount, 2); } @@ -383,11 +383,11 @@ void tst_QPauseAnimationJob::multipleSequentialGroups() group.start(); - QVERIFY(group.state() == QAbstractAnimationJob::Running); - QVERIFY(subgroup1.state() == QAbstractAnimationJob::Running); - QVERIFY(subgroup2.state() == QAbstractAnimationJob::Running); - QVERIFY(subgroup3.state() == QAbstractAnimationJob::Running); - QVERIFY(subgroup4.state() == QAbstractAnimationJob::Running); + QCOMPARE(group.state(), QAbstractAnimationJob::Running); + QCOMPARE(subgroup1.state(), QAbstractAnimationJob::Running); + QCOMPARE(subgroup2.state(), QAbstractAnimationJob::Running); + QCOMPARE(subgroup3.state(), QAbstractAnimationJob::Running); + QCOMPARE(subgroup4.state(), QAbstractAnimationJob::Running); // This is a pretty long animation so it tends to get rather out of sync // when using the consistent timer, so run for an extra half second for good @@ -398,31 +398,31 @@ void tst_QPauseAnimationJob::multipleSequentialGroups() if (group.state() != QAbstractAnimationJob::Stopped) QEXPECT_FAIL("", winTimerError, Abort); #endif - QTRY_VERIFY(group.state() == QAbstractAnimationJob::Stopped); + QTRY_COMPARE(group.state(), QAbstractAnimationJob::Stopped); #ifdef Q_OS_WIN if (subgroup1.state() != QAbstractAnimationJob::Stopped) QEXPECT_FAIL("", winTimerError, Abort); #endif - QVERIFY(subgroup1.state() == QAbstractAnimationJob::Stopped); + QCOMPARE(subgroup1.state(), QAbstractAnimationJob::Stopped); #ifdef Q_OS_WIN if (subgroup2.state() != QAbstractAnimationJob::Stopped) QEXPECT_FAIL("", winTimerError, Abort); #endif - QVERIFY(subgroup2.state() == QAbstractAnimationJob::Stopped); + QCOMPARE(subgroup2.state(), QAbstractAnimationJob::Stopped); #ifdef Q_OS_WIN if (subgroup3.state() != QAbstractAnimationJob::Stopped) QEXPECT_FAIL("", winTimerError, Abort); #endif - QVERIFY(subgroup3.state() == QAbstractAnimationJob::Stopped); + QCOMPARE(subgroup3.state(), QAbstractAnimationJob::Stopped); #ifdef Q_OS_WIN if (subgroup4.state() != QAbstractAnimationJob::Stopped) QEXPECT_FAIL("", winTimerError, Abort); #endif - QVERIFY(subgroup4.state() == QAbstractAnimationJob::Stopped); + QCOMPARE(subgroup4.state(), QAbstractAnimationJob::Stopped); #ifdef Q_OS_WIN if (pause5.m_updateCurrentTimeCount != 4) @@ -437,7 +437,7 @@ void tst_QPauseAnimationJob::zeroDuration() animation.setDuration(0); animation.start(); QTest::qWait(animation.totalDuration() + 100); - QVERIFY(animation.state() == QAbstractAnimationJob::Stopped); + QCOMPARE(animation.state(), QAbstractAnimationJob::Stopped); QCOMPARE(animation.m_updateCurrentTimeCount, 1); } diff --git a/tests/auto/qml/animation/qsequentialanimationgroupjob/tst_qsequentialanimationgroupjob.cpp b/tests/auto/qml/animation/qsequentialanimationgroupjob/tst_qsequentialanimationgroupjob.cpp index 848bec0b0b..f004593d94 100644 --- a/tests/auto/qml/animation/qsequentialanimationgroupjob/tst_qsequentialanimationgroupjob.cpp +++ b/tests/auto/qml/animation/qsequentialanimationgroupjob/tst_qsequentialanimationgroupjob.cpp @@ -911,7 +911,7 @@ void tst_QSequentialAnimationGroupJob::startDelay() QTest::qWait(500); QTRY_COMPARE(group.state(), QAnimationGroupJob::Stopped); - QVERIFY(group.currentLoopTime() == 375); + QCOMPARE(group.currentLoopTime(), 375); } void tst_QSequentialAnimationGroupJob::clearGroup() @@ -1456,7 +1456,7 @@ void tst_QSequentialAnimationGroupJob::addRemoveAnimation() void tst_QSequentialAnimationGroupJob::currentAnimation() { QSequentialAnimationGroupJob group; - QVERIFY(group.currentAnimation() == 0); + QVERIFY(!group.currentAnimation()); TestAnimation anim(0); group.appendAnimation(&anim); @@ -1466,7 +1466,7 @@ void tst_QSequentialAnimationGroupJob::currentAnimation() void tst_QSequentialAnimationGroupJob::currentAnimationWithZeroDuration() { QSequentialAnimationGroupJob group; - QVERIFY(group.currentAnimation() == 0); + QVERIFY(!group.currentAnimation()); TestAnimation zero1(0); TestAnimation zero2(0); diff --git a/tests/auto/qml/debugger/qdebugmessageservice/tst_qdebugmessageservice.cpp b/tests/auto/qml/debugger/qdebugmessageservice/tst_qdebugmessageservice.cpp index 6f559d7833..d0801dd4ee 100644 --- a/tests/auto/qml/debugger/qdebugmessageservice/tst_qdebugmessageservice.cpp +++ b/tests/auto/qml/debugger/qdebugmessageservice/tst_qdebugmessageservice.cpp @@ -185,7 +185,7 @@ void tst_QDebugMessageService::init() if (m_client->state() != QQmlDebugClient::Enabled) QQmlDebugTest::waitForSignal(m_client, SIGNAL(enabled())); - QVERIFY(m_client->state() == QQmlDebugClient::Enabled); + QCOMPARE(m_client->state(), QQmlDebugClient::Enabled); } void tst_QDebugMessageService::cleanup() diff --git a/tests/auto/qml/debugger/qpacketprotocol/tst_qpacketprotocol.cpp b/tests/auto/qml/debugger/qpacketprotocol/tst_qpacketprotocol.cpp index 155f11bdaf..db9e621d54 100644 --- a/tests/auto/qml/debugger/qpacketprotocol/tst_qpacketprotocol.cpp +++ b/tests/auto/qml/debugger/qpacketprotocol/tst_qpacketprotocol.cpp @@ -222,7 +222,7 @@ void tst_QPacketProtocol::read() void tst_QPacketProtocol::device() { QPacketProtocol p(m_client); - QVERIFY(p.device() == m_client); + QCOMPARE(p.device(), m_client); } void tst_QPacketProtocol::tst_QPacket_clear() diff --git a/tests/auto/qml/debugger/qqmldebugclient/tst_qqmldebugclient.cpp b/tests/auto/qml/debugger/qqmldebugclient/tst_qqmldebugclient.cpp index 99ba06ae31..d2ae863433 100644 --- a/tests/auto/qml/debugger/qqmldebugclient/tst_qqmldebugclient.cpp +++ b/tests/auto/qml/debugger/qqmldebugclient/tst_qqmldebugclient.cpp @@ -164,7 +164,7 @@ void tst_QQmlDebugClient::sequentialConnect() connection2.connectToHost("127.0.0.1", PORT); QVERIFY(connection2.waitForConnected()); QVERIFY(connection2.isConnected()); - QTRY_VERIFY(client2.state() == QQmlDebugClient::Enabled); + QTRY_COMPARE(client2.state(), QQmlDebugClient::Enabled); } int main(int argc, char *argv[]) diff --git a/tests/auto/qml/debugger/qqmlenginedebugservice/tst_qqmlenginedebugservice.cpp b/tests/auto/qml/debugger/qqmlenginedebugservice/tst_qqmlenginedebugservice.cpp index 5090580cc5..0b766bc500 100644 --- a/tests/auto/qml/debugger/qqmlenginedebugservice/tst_qqmlenginedebugservice.cpp +++ b/tests/auto/qml/debugger/qqmlenginedebugservice/tst_qqmlenginedebugservice.cpp @@ -353,7 +353,7 @@ void tst_QQmlEngineDebugService::initTestCase() QVERIFY(ok); QTRY_VERIFY(QQmlDebugService::hasDebuggingClient()); m_dbg = new QQmlEngineDebugClient(m_conn); - QTRY_VERIFY(m_dbg->state() == QQmlEngineDebugClient::Enabled); + QTRY_COMPARE(m_dbg->state(), QQmlEngineDebugClient::Enabled); } void tst_QQmlEngineDebugService::cleanupTestCase() @@ -374,7 +374,7 @@ void tst_QQmlEngineDebugService::setMethodBody() QVariant rv; QVERIFY(QMetaObject::invokeMethod(root, "myMethodNoArgs", Qt::DirectConnection, Q_RETURN_ARG(QVariant, rv))); - QVERIFY(rv == QVariant(qreal(3))); + QCOMPARE(rv, QVariant(qreal(3))); QVERIFY(m_dbg->setMethodBody(obj.debugId, "myMethodNoArgs", "return 7", @@ -384,7 +384,7 @@ void tst_QQmlEngineDebugService::setMethodBody() QVERIFY(QMetaObject::invokeMethod(root, "myMethodNoArgs", Qt::DirectConnection, Q_RETURN_ARG(QVariant, rv))); - QVERIFY(rv == QVariant(qreal(7))); + QCOMPARE(rv, QVariant(qreal(7))); } // With args @@ -392,7 +392,7 @@ void tst_QQmlEngineDebugService::setMethodBody() QVariant rv; QVERIFY(QMetaObject::invokeMethod(root, "myMethod", Qt::DirectConnection, Q_RETURN_ARG(QVariant, rv), Q_ARG(QVariant, QVariant(19)))); - QVERIFY(rv == QVariant(qreal(28))); + QCOMPARE(rv, QVariant(qreal(28))); QVERIFY(m_dbg->setMethodBody(obj.debugId, "myMethod", "return a + 7", &success)); @@ -401,7 +401,7 @@ void tst_QQmlEngineDebugService::setMethodBody() QVERIFY(QMetaObject::invokeMethod(root, "myMethod", Qt::DirectConnection, Q_RETURN_ARG(QVariant, rv), Q_ARG(QVariant, QVariant(19)))); - QVERIFY(rv == QVariant(qreal(26))); + QCOMPARE(rv, QVariant(qreal(26))); } } @@ -733,7 +733,7 @@ void tst_QQmlEngineDebugService::queryObjectsForLocation() QVERIFY(success); QVERIFY(QQmlDebugTest::waitForSignal(m_dbg, SIGNAL(result()))); - QVERIFY(m_dbg->objects().count() == 1); + QCOMPARE(m_dbg->objects().count(), 1); QmlDebugObjectReference obj = m_dbg->objects().first(); // check source as defined in main() diff --git a/tests/auto/qml/qjsengine/tst_qjsengine.cpp b/tests/auto/qml/qjsengine/tst_qjsengine.cpp index 5a9d6d20eb..4c7dba9f90 100644 --- a/tests/auto/qml/qjsengine/tst_qjsengine.cpp +++ b/tests/auto/qml/qjsengine/tst_qjsengine.cpp @@ -336,7 +336,7 @@ void tst_QJSEngine::constructWithParent() QJSEngine *engine = new QJSEngine(&obj); ptr = engine; } - QVERIFY(ptr == 0); + QVERIFY(ptr.isNull()); } void tst_QJSEngine::newObject() @@ -631,7 +631,7 @@ void tst_QJSEngine::newQObject_ownership() eng.collectGarbage(); if (ptr) QGuiApplication::sendPostedEvents(ptr, QEvent::DeferredDelete); - QVERIFY(ptr == 0); + QVERIFY(ptr.isNull()); } { QPointer<QObject> ptr = new QObject(this); @@ -641,7 +641,7 @@ void tst_QJSEngine::newQObject_ownership() } QObject *before = ptr; eng.collectGarbage(); - QVERIFY(ptr == before); + QCOMPARE(ptr.data(), before); delete ptr; } { @@ -662,7 +662,7 @@ void tst_QJSEngine::newQObject_ownership() // no parent, so it should be like ScriptOwnership if (ptr) QGuiApplication::sendPostedEvents(ptr, QEvent::DeferredDelete); - QVERIFY(ptr == 0); + QVERIFY(ptr.isNull()); } { QObject *parent = new QObject(); @@ -1258,7 +1258,7 @@ void tst_QJSEngine::valueConversion_QVariant() { QVariant tmp1; QVariant tmp2(QMetaType::QVariant, &tmp1); - QVERIFY(QMetaType::Type(tmp2.type()) == QMetaType::QVariant); + QCOMPARE(QMetaType::Type(tmp2.type()), QMetaType::QVariant); QJSValue val1 = eng.toScriptValue(tmp1); QJSValue val2 = eng.toScriptValue(tmp2); @@ -1273,9 +1273,9 @@ void tst_QJSEngine::valueConversion_QVariant() QVariant tmp1(123); QVariant tmp2(QMetaType::QVariant, &tmp1); QVariant tmp3(QMetaType::QVariant, &tmp2); - QVERIFY(QMetaType::Type(tmp1.type()) == QMetaType::Int); - QVERIFY(QMetaType::Type(tmp2.type()) == QMetaType::QVariant); - QVERIFY(QMetaType::Type(tmp3.type()) == QMetaType::QVariant); + QCOMPARE(QMetaType::Type(tmp1.type()), QMetaType::Int); + QCOMPARE(QMetaType::Type(tmp2.type()), QMetaType::QVariant); + QCOMPARE(QMetaType::Type(tmp3.type()), QMetaType::QVariant); QJSValue val1 = eng.toScriptValue(tmp2); QJSValue val2 = eng.toScriptValue(tmp3); @@ -1285,8 +1285,8 @@ void tst_QJSEngine::valueConversion_QVariant() QVERIFY(val1.isVariant()); QEXPECT_FAIL("", "Variant are unrwapped, maybe we should not...", Continue); QVERIFY(val2.isVariant()); - QVERIFY(val1.toVariant().toInt() == 123); - QVERIFY(eng.toScriptValue(val2.toVariant()).toVariant().toInt() == 123); + QCOMPARE(val1.toVariant().toInt(), 123); + QCOMPARE(eng.toScriptValue(val2.toVariant()).toVariant().toInt(), 123); } { QJSValue val = eng.toScriptValue(QVariant(true)); @@ -1472,7 +1472,7 @@ void tst_QJSEngine::collectGarbage() eng.collectGarbage(); if (ptr) QGuiApplication::sendPostedEvents(ptr, QEvent::DeferredDelete); - QVERIFY(ptr == 0); + QVERIFY(ptr.isNull()); } void tst_QJSEngine::gcWithNestedDataStructure() diff --git a/tests/auto/qml/qjsvalue/tst_qjsvalue.cpp b/tests/auto/qml/qjsvalue/tst_qjsvalue.cpp index d608379d52..bea44cb6e3 100644 --- a/tests/auto/qml/qjsvalue/tst_qjsvalue.cpp +++ b/tests/auto/qml/qjsvalue/tst_qjsvalue.cpp @@ -1076,7 +1076,7 @@ void tst_QJSValue::toVariant() QVariantList listOut = ret.toList(); QCOMPARE(listOut.size(), listIn.size()); for (int i = 0; i < listIn.size(); ++i) - QVERIFY(listOut.at(i) == listIn.at(i)); + QCOMPARE(listOut.at(i), listIn.at(i)); // round-trip conversion QJSValue array2 = eng.toScriptValue(ret); QVERIFY(array2.isArray()); @@ -2261,7 +2261,7 @@ void tst_QJSValue::castToPointer() QCOMPARE(*cp, c); QBrush *bp = qjsvalue_cast<QBrush*>(v); - QVERIFY(bp == 0); + QVERIFY(!bp); QJSValue v2 = eng.toScriptValue(qVariantFromValue(cp)); QCOMPARE(qjsvalue_cast<QColor*>(v2), cp); @@ -2465,15 +2465,15 @@ void tst_QJSValue::engineDeleted() delete eng; QVERIFY(v1.isUndefined()); - QVERIFY(v1.engine() == 0); + QVERIFY(!v1.engine()); QVERIFY(v2.isUndefined()); - QVERIFY(v2.engine() == 0); + QVERIFY(!v2.engine()); QVERIFY(v3.isUndefined()); - QVERIFY(v3.engine() == 0); + QVERIFY(!v3.engine()); QVERIFY(v4.isUndefined()); - QVERIFY(v4.engine() == 0); + QVERIFY(!v4.engine()); QVERIFY(v5.isString()); // was not bound to engine - QVERIFY(v5.engine() == 0); + QVERIFY(!v5.engine()); QVERIFY(v3.property("foo").isUndefined()); } diff --git a/tests/auto/qml/qjsvalueiterator/tst_qjsvalueiterator.cpp b/tests/auto/qml/qjsvalueiterator/tst_qjsvalueiterator.cpp index 6049e423e8..81a79331c3 100644 --- a/tests/auto/qml/qjsvalueiterator/tst_qjsvalueiterator.cpp +++ b/tests/auto/qml/qjsvalueiterator/tst_qjsvalueiterator.cpp @@ -92,7 +92,7 @@ void tst_QJSValueIterator::iterateForward() QFETCH(QStringList, propertyNames); QFETCH(QStringList, propertyValues); QMap<QString, QString> pmap; - QVERIFY(propertyNames.size() == propertyValues.size()); + QCOMPARE(propertyNames.size(), propertyValues.size()); QJSEngine engine; QJSValue object = engine.newObject(); diff --git a/tests/auto/qml/qqmlcomponent/tst_qqmlcomponent.cpp b/tests/auto/qml/qqmlcomponent/tst_qqmlcomponent.cpp index dddd9a7dc8..85579a6019 100644 --- a/tests/auto/qml/qqmlcomponent/tst_qqmlcomponent.cpp +++ b/tests/auto/qml/qqmlcomponent/tst_qqmlcomponent.cpp @@ -251,7 +251,7 @@ void tst_qqmlcomponent::qmlCreateObjectWithProperties() QObject *testObject1 = object->property("declarativerectangle").value<QObject*>(); QVERIFY(testObject1); - QVERIFY(testObject1->parent() == object); + QCOMPARE(testObject1->parent(), object); QCOMPARE(testObject1->property("x").value<int>(), 17); QCOMPARE(testObject1->property("y").value<int>(), 17); QCOMPARE(testObject1->property("color").value<QColor>(), QColor(255,255,255)); @@ -261,7 +261,7 @@ void tst_qqmlcomponent::qmlCreateObjectWithProperties() QObject *testObject2 = object->property("declarativeitem").value<QObject*>(); QVERIFY(testObject2); - QVERIFY(testObject2->parent() == object); + QCOMPARE(testObject2->parent(), object); //QCOMPARE(testObject2->metaObject()->className(), "QDeclarativeItem_QML_2"); QCOMPARE(testObject2->property("x").value<int>(), 17); QCOMPARE(testObject2->property("y").value<int>(), 17); @@ -448,7 +448,7 @@ void tst_qqmlcomponent::componentUrlCanonicalization() QQmlComponent component(&engine, testFileUrl("componentUrlCanonicalization.5.qml")); QTest::ignoreMessage(QtWarningMsg, QLatin1String("QQmlComponent: Component is not ready").data()); QScopedPointer<QObject> object(component.create()); - QVERIFY(object == 0); + QVERIFY(object.isNull()); } } diff --git a/tests/auto/qml/qqmlconnections/tst_qqmlconnections.cpp b/tests/auto/qml/qqmlconnections/tst_qqmlconnections.cpp index c7781c2e9d..e529c74acc 100644 --- a/tests/auto/qml/qqmlconnections/tst_qqmlconnections.cpp +++ b/tests/auto/qml/qqmlconnections/tst_qqmlconnections.cpp @@ -72,7 +72,7 @@ void tst_qqmlconnections::defaultValues() QQmlConnections *item = qobject_cast<QQmlConnections*>(c.create()); QVERIFY(item != 0); - QVERIFY(item->target() == 0); + QVERIFY(!item->target()); delete item; } @@ -86,7 +86,7 @@ void tst_qqmlconnections::properties() QVERIFY(item != 0); QVERIFY(item != 0); - QVERIFY(item->target() == item); + QCOMPARE(item->target(), item); delete item; } @@ -146,7 +146,7 @@ void tst_qqmlconnections::targetChanged() QQuickItem *item2 = item->findChild<QQuickItem*>("item2"); QVERIFY(item2); - QVERIFY(connections->target() == item2); + QCOMPARE(connections->target(), item2); // If we don't crash then we're OK @@ -213,7 +213,7 @@ void tst_qqmlconnections::errors() QQmlComponent c(&engine, url); QVERIFY(c.isError()); QList<QQmlError> errors = c.errors(); - QVERIFY(errors.count() == 1); + QCOMPARE(errors.count(), 1); QCOMPARE(errors.at(0).description(), error); } diff --git a/tests/auto/qml/qqmlcontext/tst_qqmlcontext.cpp b/tests/auto/qml/qqmlcontext/tst_qqmlcontext.cpp index 1bd070c2d0..18ef7ac31d 100644 --- a/tests/auto/qml/qqmlcontext/tst_qqmlcontext.cpp +++ b/tests/auto/qml/qqmlcontext/tst_qqmlcontext.cpp @@ -433,12 +433,12 @@ void tst_qqmlcontext::idAsContextProperty() QVERIFY(obj); QVariant a = obj->property("a"); - QVERIFY(a.userType() == QMetaType::QObjectStar); + QCOMPARE(a.userType(), int(QMetaType::QObjectStar)); QVariant ctxt = qmlContext(obj)->contextProperty("myObject"); - QVERIFY(ctxt.userType() == QMetaType::QObjectStar); + QCOMPARE(ctxt.userType(), int(QMetaType::QObjectStar)); - QVERIFY(a == ctxt); + QCOMPARE(a, ctxt); delete obj; } @@ -455,20 +455,20 @@ void tst_qqmlcontext::readOnlyContexts() QQmlContext *context = qmlContext(obj); QVERIFY(context); - QVERIFY(qvariant_cast<QObject*>(context->contextProperty("me")) == obj); - QVERIFY(context->contextObject() == obj); + QCOMPARE(qvariant_cast<QObject*>(context->contextProperty("me")), obj); + QCOMPARE(context->contextObject(), obj); QTest::ignoreMessage(QtWarningMsg, "QQmlContext: Cannot set property on internal context."); context->setContextProperty("hello", 12); - QVERIFY(context->contextProperty("hello") == QVariant()); + QCOMPARE(context->contextProperty("hello"), QVariant()); QTest::ignoreMessage(QtWarningMsg, "QQmlContext: Cannot set property on internal context."); context->setContextProperty("hello", obj); - QVERIFY(context->contextProperty("hello") == QVariant()); + QCOMPARE(context->contextProperty("hello"), QVariant()); QTest::ignoreMessage(QtWarningMsg, "QQmlContext: Cannot set context object for internal context."); context->setContextObject(0); - QVERIFY(context->contextObject() == obj); + QCOMPARE(context->contextObject(), obj); delete obj; } diff --git a/tests/auto/qml/qqmlecmascript/tst_qqmlecmascript.cpp b/tests/auto/qml/qqmlecmascript/tst_qqmlecmascript.cpp index 78c4022322..8bb9ddc07e 100644 --- a/tests/auto/qml/qqmlecmascript/tst_qqmlecmascript.cpp +++ b/tests/auto/qml/qqmlecmascript/tst_qqmlecmascript.cpp @@ -521,7 +521,7 @@ void tst_qqmlecmascript::idShortcutInvalidates() QVERIFY(object != 0); QVERIFY(object->objectProperty() != 0); delete object->objectProperty(); - QVERIFY(object->objectProperty() == 0); + QVERIFY(!object->objectProperty()); delete object; } @@ -531,7 +531,7 @@ void tst_qqmlecmascript::idShortcutInvalidates() QVERIFY(object != 0); QVERIFY(object->objectProperty() != 0); delete object->objectProperty(); - QVERIFY(object->objectProperty() == 0); + QVERIFY(!object->objectProperty()); delete object; } } @@ -885,7 +885,7 @@ void tst_qqmlecmascript::deferredProperties() qobject_cast<MyDeferredObject *>(component.create()); QVERIFY(object != 0); QCOMPARE(object->value(), 0); - QVERIFY(object->objectProperty() == 0); + QVERIFY(!object->objectProperty()); QVERIFY(object->objectProperty2() != 0); qmlExecuteDeferred(object); QCOMPARE(object->value(), 10); @@ -908,8 +908,8 @@ void tst_qqmlecmascript::deferredPropertiesErrors() qobject_cast<MyDeferredObject *>(component.create()); QVERIFY(object != 0); QCOMPARE(object->value(), 0); - QVERIFY(object->objectProperty() == 0); - QVERIFY(object->objectProperty2() == 0); + QVERIFY(!object->objectProperty()); + QVERIFY(!object->objectProperty2()); QString warning = component.url().toString() + ":6:21: Unable to assign [undefined] to QObject*"; QTest::ignoreMessage(QtWarningMsg, qPrintable(warning)); @@ -932,7 +932,7 @@ void tst_qqmlecmascript::deferredPropertiesInComponents() MyDeferredObject *defObjectA = qobject_cast<MyDeferredObject *>(object->property("deferredInside").value<QObject*>()); QVERIFY(defObjectA != 0); - QVERIFY(defObjectA->objectProperty() == 0); + QVERIFY(!defObjectA->objectProperty()); qmlExecuteDeferred(defObjectA); QVERIFY(defObjectA->objectProperty() != 0); @@ -941,7 +941,7 @@ void tst_qqmlecmascript::deferredPropertiesInComponents() MyDeferredObject *defObjectB = qobject_cast<MyDeferredObject *>(object->property("deferredOutside").value<QObject*>()); QVERIFY(defObjectB != 0); - QVERIFY(defObjectB->objectProperty() == 0); + QVERIFY(!defObjectB->objectProperty()); qmlExecuteDeferred(defObjectB); QVERIFY(defObjectB->objectProperty() != 0); @@ -995,7 +995,7 @@ void tst_qqmlecmascript::overrideExtensionProperties() qobject_cast<OverrideDefaultPropertyObject *>(component.create()); QVERIFY(object != 0); QVERIFY(object->secondProperty() != 0); - QVERIFY(object->firstProperty() == 0); + QVERIFY(!object->firstProperty()); delete object; } @@ -1459,7 +1459,7 @@ void tst_qqmlecmascript::aliasPropertyReset() QVERIFY(object->property("sourceComponentAlias").value<QQmlComponent*>() != 0); QCOMPARE(object->property("aliasIsUndefined"), QVariant(false)); QMetaObject::invokeMethod(object, "resetAliased"); - QVERIFY(object->property("sourceComponentAlias").value<QQmlComponent*>() == 0); + QVERIFY(!object->property("sourceComponentAlias").value<QQmlComponent*>()); QCOMPARE(object->property("aliasIsUndefined"), QVariant(true)); delete object; @@ -1470,7 +1470,7 @@ void tst_qqmlecmascript::aliasPropertyReset() QVERIFY(object->property("sourceComponentAlias").value<QQmlComponent*>() != 0); QCOMPARE(object->property("loaderSourceComponentIsUndefined"), QVariant(false)); QMetaObject::invokeMethod(object, "resetAlias"); - QVERIFY(object->property("sourceComponentAlias").value<QQmlComponent*>() == 0); + QVERIFY(!object->property("sourceComponentAlias").value<QQmlComponent*>()); QCOMPARE(object->property("loaderSourceComponentIsUndefined"), QVariant(true)); delete object; @@ -1482,7 +1482,7 @@ void tst_qqmlecmascript::aliasPropertyReset() QCOMPARE(object->property("loaderOneSourceComponentIsUndefined"), QVariant(false)); QCOMPARE(object->property("loaderTwoSourceComponentIsUndefined"), QVariant(false)); QMetaObject::invokeMethod(object, "resetAlias"); - QVERIFY(object->property("sourceComponentAlias").value<QQmlComponent*>() == 0); + QVERIFY(!object->property("sourceComponentAlias").value<QQmlComponent*>()); QCOMPARE(object->property("loaderOneSourceComponentIsUndefined"), QVariant(true)); QCOMPARE(object->property("loaderTwoSourceComponentIsUndefined"), QVariant(false)); delete object; @@ -1498,9 +1498,9 @@ void tst_qqmlecmascript::aliasPropertyReset() delete loader; QVERIFY(object->property("sourceComponentAlias").value<QQmlComponent*>() == 0); // deletion should have caused value unset. QMetaObject::invokeMethod(object, "resetAlias"); // shouldn't crash. - QVERIFY(object->property("sourceComponentAlias").value<QQmlComponent*>() == 0); + QVERIFY(!object->property("sourceComponentAlias").value<QQmlComponent*>()); QMetaObject::invokeMethod(object, "setAlias"); // shouldn't crash, and shouldn't change value (since it's no longer referencing anything). - QVERIFY(object->property("sourceComponentAlias").value<QQmlComponent*>() == 0); + QVERIFY(!object->property("sourceComponentAlias").value<QQmlComponent*>()); delete object; // test that binding an alias property to an undefined value works correctly @@ -1680,7 +1680,7 @@ void tst_qqmlecmascript::dynamicDestruction() QObject *o = component.create(); QVERIFY(o != 0); - QVERIFY(qvariant_cast<QObject*>(o->property("objectProperty")) == 0); + QVERIFY(!qvariant_cast<QObject*>(o->property("objectProperty"))); QMetaObject::invokeMethod(o, "create"); @@ -1691,7 +1691,7 @@ void tst_qqmlecmascript::dynamicDestruction() QCoreApplication::sendPostedEvents(0, QEvent::DeferredDelete); QCoreApplication::processEvents(); - QVERIFY(qvariant_cast<QObject*>(o->property("objectProperty")) == 0); + QVERIFY(!qvariant_cast<QObject*>(o->property("objectProperty"))); delete o; } @@ -1702,19 +1702,19 @@ void tst_qqmlecmascript::dynamicDestruction() QQmlComponent component(&engine, testFileUrl("dynamicDeletion.3.qml")); QObject *o = component.create(); QVERIFY(o != 0); - QVERIFY(qvariant_cast<QObject*>(o->property("objectProperty")) == 0); + QVERIFY(!qvariant_cast<QObject*>(o->property("objectProperty"))); QMetaObject::invokeMethod(o, "create"); createdQmlObject = qvariant_cast<QObject*>(o->property("objectProperty")); QVERIFY(createdQmlObject); QMetaObject::invokeMethod(o, "destroy"); - QVERIFY(qvariant_cast<bool>(o->property("test")) == false); + QCOMPARE(qvariant_cast<bool>(o->property("test")), false); for (int ii = 0; createdQmlObject && ii < 50; ++ii) { // After 5 seconds we should give up QTest::qWait(100); QCoreApplication::sendPostedEvents(0, QEvent::DeferredDelete); QCoreApplication::processEvents(); } - QVERIFY(qvariant_cast<QObject*>(o->property("objectProperty")) == 0); - QVERIFY(qvariant_cast<bool>(o->property("test")) == true); + QVERIFY(!qvariant_cast<QObject*>(o->property("objectProperty"))); + QCOMPARE(qvariant_cast<bool>(o->property("test")), true); delete o; } } @@ -1846,7 +1846,7 @@ void tst_qqmlecmascript::uncreatableExtendedObjectFailureCheck() QQmlComponent component(&engine, testFileUrl("uncreatableExtendedObjectFailureCheck.qml")); QObject *object = component.create(); - QVERIFY(object == 0); + QVERIFY(!object); } /* @@ -2235,7 +2235,7 @@ void tst_qqmlecmascript::dynamicCreationCrash() QTest::ignoreMessage(QtWarningMsg, "QQmlComponent: Component is not ready"); QMetaObject::invokeMethod(object, "dontCrash"); QObject *created = object->objectProperty(); - QVERIFY(created == 0); + QVERIFY(!created); delete object; } @@ -2993,7 +2993,7 @@ void tst_qqmlecmascript::listToVariant() QVariant v = object->property("test"); QCOMPARE(v.userType(), qMetaTypeId<QQmlListReference>()); - QVERIFY(qvariant_cast<QQmlListReference>(v).object() == &container); + QCOMPARE(qvariant_cast<QQmlListReference>(v).object(), &container); delete object; } @@ -3260,7 +3260,7 @@ void tst_qqmlecmascript::ownership() QCoreApplication::sendPostedEvents(0, QEvent::DeferredDelete); QCoreApplication::processEvents(); - QVERIFY(own.object == 0); + QVERIFY(own.object.isNull()); delete object; } @@ -3319,7 +3319,7 @@ void tst_qqmlecmascript::cppOwnershipReturnValue() QQmlEngine engine; engine.rootContext()->setContextProperty("source", &source); - QVERIFY(source.value == 0); + QVERIFY(source.value.isNull()); QQmlComponent component(&engine); component.setData("import QtQuick 2.0\nQtObject {\nComponent.onCompleted: { var a = source.create(); }\n}\n", QUrl()); @@ -3347,7 +3347,7 @@ void tst_qqmlecmascript::ownershipCustomReturnValue() QQmlEngine engine; engine.rootContext()->setContextProperty("source", &source); - QVERIFY(source.value == 0); + QVERIFY(source.value.isNull()); QQmlComponent component(&engine); component.setData("import QtQuick 2.0\nQtObject {\nComponent.onCompleted: { var a = source.createQmlObject(); }\n}\n", QUrl()); @@ -3364,7 +3364,7 @@ void tst_qqmlecmascript::ownershipCustomReturnValue() QCoreApplication::sendPostedEvents(0, QEvent::DeferredDelete); QCoreApplication::processEvents(); - QVERIFY(source.value == 0); + QVERIFY(source.value.isNull()); } //the return value from getObject will be JS ownership, @@ -3446,7 +3446,7 @@ void tst_qqmlecmascript::ownershipQmlIncubated() QCoreApplication::sendPostedEvents(0, QEvent::DeferredDelete); QCoreApplication::processEvents(); - QVERIFY(object->property("incubatedItem").value<QObject*>() == 0); + QVERIFY(!object->property("incubatedItem").value<QObject*>()); delete object; } @@ -3863,7 +3863,7 @@ void tst_qqmlecmascript::singletonType() QObject *object = component.create(); if (!errorMessage.isEmpty()) { - QVERIFY(object == 0); + QVERIFY(!object); } else { QVERIFY(object != 0); for (int i = 0; i < readProperties.size(); ++i) @@ -3920,7 +3920,7 @@ void tst_qqmlecmascript::singletonTypeImportOrder() QQmlComponent component(&engine, testFileUrl("singletontype/singletonTypeImportOrder.qml")); QObject *object = component.create(); QVERIFY(object); - QVERIFY(object->property("v") == 1); + QCOMPARE(object->property("v").toInt(), 1); delete object; } @@ -3958,7 +3958,7 @@ void tst_qqmlecmascript::verifyContextLifetime(QQmlContextData *ctxt) { ctxt->engine->collectGarbage(); qml = scripts->getIndexed(i); newContext = QV4::QmlContextWrapper::getContext(qml); - QVERIFY(scriptContext == newContext); + QCOMPARE(scriptContext, newContext); } } @@ -4232,7 +4232,7 @@ void tst_qqmlecmascript::importScripts() QObject *object = component.create(); if (!errorMessage.isEmpty()) { - QVERIFY(object == 0); + QVERIFY(!object); } else { QVERIFY(object != 0); @@ -4685,7 +4685,7 @@ void tst_qqmlecmascript::propertyChangeSlots() QString expectedErrorString = e1.url().toString() + QLatin1String(":9:5: Cannot assign to non-existent property \"on_nameWithUnderscoreChanged\""); QCOMPARE(e1.errors().at(0).toString(), expectedErrorString); object = e1.create(); - QVERIFY(object == 0); + QVERIFY(!object); delete object; QTest::ignoreMessage(QtWarningMsg, "QQmlComponent: Component is not ready"); @@ -4693,7 +4693,7 @@ void tst_qqmlecmascript::propertyChangeSlots() expectedErrorString = e2.url().toString() + QLatin1String(":9:5: Cannot assign to non-existent property \"on____nameWithUnderscoresChanged\""); QCOMPARE(e2.errors().at(0).toString(), expectedErrorString); object = e2.create(); - QVERIFY(object == 0); + QVERIFY(!object); delete object; QTest::ignoreMessage(QtWarningMsg, "QQmlComponent: Component is not ready"); @@ -4701,7 +4701,7 @@ void tst_qqmlecmascript::propertyChangeSlots() expectedErrorString = e3.url().toString() + QLatin1String(":9:5: Cannot assign to non-existent property \"on$NameWithDollarsignChanged\""); QCOMPARE(e3.errors().at(0).toString(), expectedErrorString); object = e3.create(); - QVERIFY(object == 0); + QVERIFY(!object); delete object; QTest::ignoreMessage(QtWarningMsg, "QQmlComponent: Component is not ready"); @@ -4709,7 +4709,7 @@ void tst_qqmlecmascript::propertyChangeSlots() expectedErrorString = e4.url().toString() + QLatin1String(":9:5: Cannot assign to non-existent property \"on_6NameWithUnderscoreNumberChanged\""); QCOMPARE(e4.errors().at(0).toString(), expectedErrorString); object = e4.create(); - QVERIFY(object == 0); + QVERIFY(!object); delete object; } @@ -5747,10 +5747,10 @@ void tst_qqmlecmascript::variants() QObject *object = component.create(); QVERIFY(object != 0); - QVERIFY(object->property("undefinedVariant").type() == QVariant::Invalid); - QVERIFY(object->property("nullVariant").type() == (int)QMetaType::VoidStar); - QVERIFY(object->property("intVariant").type() == QVariant::Int); - QVERIFY(object->property("doubleVariant").type() == QVariant::Double); + QCOMPARE(object->property("undefinedVariant").type(), QVariant::Invalid); + QCOMPARE(int(object->property("nullVariant").type()), int(QMetaType::VoidStar)); + QCOMPARE(object->property("intVariant").type(), QVariant::Int); + QCOMPARE(object->property("doubleVariant").type(), QVariant::Double); QVariant result; QMetaObject::invokeMethod(object, "checkNull", Q_RETURN_ARG(QVariant, result)); @@ -5801,7 +5801,7 @@ void tst_qqmlecmascript::qtcreatorbug_1289() delete nested; nested = qvariant_cast<QObject *>(o->property("object")); - QVERIFY(nested == 0); + QVERIFY(!nested); // If the bug is present, the next line will crash delete o; @@ -5848,7 +5848,7 @@ void tst_qqmlecmascript::canAssignNullToQObject() o->setProperty("runTest", true); - QVERIFY(o->objectProperty() == 0); + QVERIFY(!o->objectProperty()); delete o; } @@ -5859,7 +5859,7 @@ void tst_qqmlecmascript::canAssignNullToQObject() MyQmlObject *o = qobject_cast<MyQmlObject *>(component.create()); QVERIFY(o != 0); - QVERIFY(o->objectProperty() == 0); + QVERIFY(!o->objectProperty()); delete o; } @@ -6132,7 +6132,7 @@ void tst_qqmlecmascript::signalHandlers() QObject *o = component.create(); QVERIFY(o != 0); - QVERIFY(o->property("count").toInt() == 0); + QCOMPARE(o->property("count").toInt(), 0); QMetaObject::invokeMethod(o, "testSignalCall"); QCOMPARE(o->property("count").toInt(), 1); @@ -6140,7 +6140,7 @@ void tst_qqmlecmascript::signalHandlers() QCOMPARE(o->property("count").toInt(), 1); QCOMPARE(o->property("errorString").toString(), QLatin1String("TypeError: Property 'onTestSignal' of object [object Object] is not a function")); - QVERIFY(o->property("funcCount").toInt() == 0); + QCOMPARE(o->property("funcCount").toInt(), 0); QMetaObject::invokeMethod(o, "testSignalConnection"); QCOMPARE(o->property("funcCount").toInt(), 1); @@ -6684,7 +6684,7 @@ void tst_qqmlecmascript::incrDecrSemicolon_error1() { QQmlComponent component(&engine, testFileUrl("incrDecrSemicolon_error1.qml")); QObject *object = component.create(); - QVERIFY(object == 0); + QVERIFY(!object); } void tst_qqmlecmascript::unaryExpression() @@ -7478,7 +7478,7 @@ void tst_qqmlecmascript::stringParsing() file = file.arg(i); QQmlComponent component(&engine, testFileUrl(file)); QObject *object = component.create(); - QVERIFY(object == 0); + QVERIFY(!object); } } @@ -7491,7 +7491,7 @@ void tst_qqmlecmascript::push_and_shift() " array.push(5); array.unshift(5); array.push(5);" "}" "array.length;"; - QVERIFY(e.evaluate(program).toNumber() == 30000); + QCOMPARE(e.evaluate(program).toNumber(), double(30000)); } void tst_qqmlecmascript::qtbug_32801() @@ -7665,7 +7665,7 @@ void tst_qqmlecmascript::singletonWithEnum() qDebug() << component.errors().first().toString(); QVERIFY(!obj.isNull()); QVariant prop = obj->property("testValue"); - QVERIFY(prop.type() == QVariant::Int); + QCOMPARE(prop.type(), QVariant::Int); QCOMPARE(prop.toInt(), int(SingletonWithEnum::TestValue)); } @@ -7677,7 +7677,7 @@ void tst_qqmlecmascript::lazyBindingEvaluation() qDebug() << component.errors().first().toString(); QVERIFY(!obj.isNull()); QVariant prop = obj->property("arrayLength"); - QVERIFY(prop.type() == QVariant::Int); + QCOMPARE(prop.type(), QVariant::Int); QCOMPARE(prop.toInt(), 2); } diff --git a/tests/auto/qml/qqmlengine/tst_qqmlengine.cpp b/tests/auto/qml/qqmlengine/tst_qqmlengine.cpp index 2cefb6bf3f..cb911d0115 100644 --- a/tests/auto/qml/qqmlengine/tst_qqmlengine.cpp +++ b/tests/auto/qml/qqmlengine/tst_qqmlengine.cpp @@ -90,7 +90,7 @@ void tst_qqmlengine::rootContext() QVERIFY(engine.rootContext()); QCOMPARE(engine.rootContext()->engine(), &engine); - QVERIFY(engine.rootContext()->parentContext() == 0); + QVERIFY(!engine.rootContext()->parentContext()); } class NetworkAccessManagerFactory : public QQmlNetworkAccessManagerFactory @@ -119,8 +119,9 @@ void tst_qqmlengine::networkAccessManager() engine = new QQmlEngine; NetworkAccessManagerFactory factory; engine->setNetworkAccessManagerFactory(&factory); - QVERIFY(engine->networkAccessManagerFactory() == &factory); - QVERIFY(engine->networkAccessManager() == factory.manager); + QCOMPARE(engine->networkAccessManagerFactory(), &factory); + QNetworkAccessManager *engineNam = engine->networkAccessManager(); // calls NetworkAccessManagerFactory::create() + QCOMPARE(engineNam, factory.manager); delete engine; } @@ -184,7 +185,7 @@ void tst_qqmlengine::baseUrl() dir.cdUp(); QVERIFY(dir != QDir::current()); QDir::setCurrent(dir.path()); - QVERIFY(QDir::current() == dir); + QCOMPARE(QDir::current(), dir); QUrl cwd2 = QUrl::fromLocalFile(QDir::currentPath() + QDir::separator()); QCOMPARE(engine.baseUrl(), cwd2); @@ -200,11 +201,11 @@ void tst_qqmlengine::contextForObject() QQmlEngine *engine = new QQmlEngine; // Test null-object - QVERIFY(QQmlEngine::contextForObject(0) == 0); + QVERIFY(!QQmlEngine::contextForObject(0)); // Test an object with no context QObject object; - QVERIFY(QQmlEngine::contextForObject(&object) == 0); + QVERIFY(!QQmlEngine::contextForObject(&object)); // Test setting null-object QQmlEngine::setContextForObject(0, engine->rootContext()); @@ -214,18 +215,18 @@ void tst_qqmlengine::contextForObject() // Test setting context QQmlEngine::setContextForObject(&object, engine->rootContext()); - QVERIFY(QQmlEngine::contextForObject(&object) == engine->rootContext()); + QCOMPARE(QQmlEngine::contextForObject(&object), engine->rootContext()); QQmlContext context(engine->rootContext()); // Try changing context QTest::ignoreMessage(QtWarningMsg, "QQmlEngine::setContextForObject(): Object already has a QQmlContext"); QQmlEngine::setContextForObject(&object, &context); - QVERIFY(QQmlEngine::contextForObject(&object) == engine->rootContext()); + QCOMPARE(QQmlEngine::contextForObject(&object), engine->rootContext()); // Delete context delete engine; engine = 0; - QVERIFY(QQmlEngine::contextForObject(&object) == 0); + QVERIFY(!QQmlEngine::contextForObject(&object)); } void tst_qqmlengine::offlineStoragePath() @@ -446,7 +447,7 @@ void tst_qqmlengine::failedCompilation() QQmlComponent component(&engine, testFileUrl(file)); QVERIFY(!component.isReady()); QScopedPointer<QObject> object(component.create()); - QVERIFY(object == 0); + QVERIFY(object.isNull()); engine.collectGarbage(); engine.trimComponentCache(); diff --git a/tests/auto/qml/qqmlexpression/tst_qqmlexpression.cpp b/tests/auto/qml/qqmlexpression/tst_qqmlexpression.cpp index e381976448..d9838a4941 100644 --- a/tests/auto/qml/qqmlexpression/tst_qqmlexpression.cpp +++ b/tests/auto/qml/qqmlexpression/tst_qqmlexpression.cpp @@ -140,7 +140,7 @@ void tst_qqmlexpression::expressionFromDataComponent() QQmlExpression expression(object->scriptString()); QVariant result = expression.evaluate(); - QVERIFY(result.type() == QVariant::String); + QCOMPARE(result.type(), QVariant::String); QCOMPARE(result.toString(), QStringLiteral("success")); } diff --git a/tests/auto/qml/qqmlincubator/tst_qqmlincubator.cpp b/tests/auto/qml/qqmlincubator/tst_qqmlincubator.cpp index 26092595d9..4f559b0d33 100644 --- a/tests/auto/qml/qqmlincubator/tst_qqmlincubator.cpp +++ b/tests/auto/qml/qqmlincubator/tst_qqmlincubator.cpp @@ -148,7 +148,7 @@ void tst_qqmlincubator::objectDeleted() component.create(incubator); QCOMPARE(incubator.status(), QQmlIncubator::Loading); - QVERIFY(SelfRegisteringType::me() == 0); + QVERIFY(!SelfRegisteringType::me()); while (SelfRegisteringOuterType::me() == 0 && incubator.isLoading()) { bool b = false; @@ -172,7 +172,7 @@ void tst_qqmlincubator::objectDeleted() QVERIFY(incubator.isError()); VERIFY_ERRORS(incubator, "objectDeleted.errors.txt"); - QVERIFY(incubator.object() == 0); + QVERIFY(!incubator.object()); } QVERIFY(SelfRegisteringOuterType::beenDeleted); } @@ -236,7 +236,7 @@ void tst_qqmlincubator::clear() incubator.clear(); QVERIFY(incubator.isNull()); - QVERIFY(incubator.object() == 0); + QVERIFY(!incubator.object()); QVERIFY(!obj.isNull()); delete obj; @@ -413,7 +413,7 @@ void tst_qqmlincubator::clearDuringCompletion() component.create(incubator); QCOMPARE(incubator.status(), QQmlIncubator::Loading); - QVERIFY(CompletionRegisteringType::me() == 0); + QVERIFY(!CompletionRegisteringType::me()); while (CompletionRegisteringType::me() == 0 && incubator.isLoading()) { bool b = false; @@ -622,7 +622,7 @@ void tst_qqmlincubator::asynchronousIfNested() component.create(incubator); QVERIFY(incubator.isLoading()); - QVERIFY(SelfRegisteringType::me() == 0); + QVERIFY(!SelfRegisteringType::me()); while (SelfRegisteringType::me() == 0 && incubator.isLoading()) { bool b = false; controller.incubateWhile(&b); @@ -741,7 +741,7 @@ void tst_qqmlincubator::chainedAsynchronousIfNested() component.create(incubator); QVERIFY(incubator.isLoading()); - QVERIFY(SelfRegisteringType::me() == 0); + QVERIFY(!SelfRegisteringType::me()); while (SelfRegisteringType::me() == 0 && incubator.isLoading()) { bool b = false; @@ -855,7 +855,7 @@ void tst_qqmlincubator::chainedAsynchronousIfNestedOnCompleted() component.create(incubator); QVERIFY(incubator.isLoading()); - QVERIFY(SelfRegisteringType::me() == 0); + QVERIFY(!SelfRegisteringType::me()); while (SelfRegisteringType::me() == 0 && incubator.isLoading()) { bool b = false; @@ -983,7 +983,7 @@ void tst_qqmlincubator::chainedAsynchronousClear() component.create(incubator); QVERIFY(incubator.isLoading()); - QVERIFY(SelfRegisteringType::me() == 0); + QVERIFY(!SelfRegisteringType::me()); while (SelfRegisteringType::me() == 0 && incubator.isLoading()) { bool b = false; @@ -1106,7 +1106,7 @@ void tst_qqmlincubator::selfDelete() component.create(*incubator); QCOMPARE(incubator->QQmlIncubator::status(), QQmlIncubator::Loading); - QVERIFY(SelfRegisteringType::me() == 0); + QVERIFY(!SelfRegisteringType::me()); while (SelfRegisteringType::me() == 0 && incubator->isLoading()) { bool b = false; diff --git a/tests/auto/qml/qqmllanguage/tst_qqmllanguage.cpp b/tests/auto/qml/qqmllanguage/tst_qqmllanguage.cpp index 08da779d90..f8cb053e6c 100644 --- a/tests/auto/qml/qqmllanguage/tst_qqmllanguage.cpp +++ b/tests/auto/qml/qqmllanguage/tst_qqmllanguage.cpp @@ -328,7 +328,7 @@ void tst_qqmllanguage::insertedSemicolon() if(create) { QObject *object = component.create(); - QVERIFY(object == 0); + QVERIFY(!object); } VERIFY_ERRORS(errorFile.toLatin1().constData()); @@ -550,7 +550,7 @@ void tst_qqmllanguage::errors() if (create) { QObject *object = component.create(); - QVERIFY(object == 0); + QVERIFY(!object); } VERIFY_ERRORS(errorFile.toLatin1().constData()); @@ -580,7 +580,7 @@ void tst_qqmllanguage::interfaceProperty() MyQmlObject *object = qobject_cast<MyQmlObject*>(component.create()); QVERIFY(object != 0); QVERIFY(object->interface()); - QVERIFY(object->interface()->id == 913); + QCOMPARE(object->interface()->id, 913); } void tst_qqmllanguage::interfaceQList() @@ -589,9 +589,9 @@ void tst_qqmllanguage::interfaceQList() VERIFY_ERRORS(0); MyContainer *container= qobject_cast<MyContainer*>(component.create()); QVERIFY(container != 0); - QVERIFY(container->getQListInterfaces()->count() == 2); + QCOMPARE(container->getQListInterfaces()->count(), 2); for(int ii = 0; ii < 2; ++ii) - QVERIFY(container->getQListInterfaces()->at(ii)->id == 913); + QCOMPARE(container->getQListInterfaces()->at(ii)->id, 913); } void tst_qqmllanguage::assignObjectToSignal() @@ -630,7 +630,7 @@ void tst_qqmllanguage::assignQmlComponent() VERIFY_ERRORS(0); MyContainer *object = qobject_cast<MyContainer *>(component.create()); QVERIFY(object != 0); - QVERIFY(object->getChildren()->count() == 1); + QCOMPARE(object->getChildren()->count(), 1); QObject *child = object->getChildren()->at(0); QCOMPARE(child->property("x"), QVariant(10)); QCOMPARE(child->property("y"), QVariant(11)); @@ -722,17 +722,17 @@ void tst_qqmllanguage::assignLiteralToVariant() QCOMPARE(object->property("test11").userType(), (int)QVariant::Bool); QCOMPARE(object->property("test12").userType(), (int)QVariant::Vector4D); - QVERIFY(object->property("test1") == QVariant(1)); - QVERIFY(object->property("test2") == QVariant((double)1.7)); + QCOMPARE(object->property("test1"), QVariant(1)); + QCOMPARE(object->property("test2"), QVariant((double)1.7)); QVERIFY(object->property("test3") == QVariant(QString(QLatin1String("Hello world!")))); - QVERIFY(object->property("test4") == QVariant(QColor::fromRgb(0xFF008800))); + QCOMPARE(object->property("test4"), QVariant(QColor::fromRgb(0xFF008800))); QVERIFY(object->property("test5") == QVariant(QRectF(10, 10, 10, 10))); QVERIFY(object->property("test6") == QVariant(QPointF(10, 10))); QVERIFY(object->property("test7") == QVariant(QSizeF(10, 10))); QVERIFY(object->property("test8") == QVariant(QVector3D(100, 100, 100))); - QVERIFY(object->property("test9") == QVariant(QString(QLatin1String("#FF008800")))); - QVERIFY(object->property("test10") == QVariant(bool(true))); - QVERIFY(object->property("test11") == QVariant(bool(false))); + QCOMPARE(object->property("test9"), QVariant(QString(QLatin1String("#FF008800")))); + QCOMPARE(object->property("test10"), QVariant(bool(true))); + QCOMPARE(object->property("test11"), QVariant(bool(false))); QVERIFY(object->property("test12") == QVariant(QVector4D(100, 100, 100, 100))); delete object; @@ -1170,7 +1170,7 @@ void tst_qqmllanguage::customParserTypes() VERIFY_ERRORS(0); QObject *object = component.create(); QVERIFY(object != 0); - QVERIFY(object->property("count") == QVariant(2)); + QCOMPARE(object->property("count"), QVariant(2)); } // Tests that the root item can be a custom component @@ -1352,7 +1352,7 @@ void tst_qqmllanguage::dynamicObjectProperties() QObject *object = component.create(); QVERIFY(object != 0); - QVERIFY(object->property("objectProperty") == qVariantFromValue((QObject*)0)); + QCOMPARE(object->property("objectProperty"), qVariantFromValue((QObject*)0)); QVERIFY(object->property("objectProperty2") != qVariantFromValue((QObject*)0)); } { @@ -1661,7 +1661,7 @@ void tst_qqmllanguage::aliasProperties() v = object->property("otherAlias"); QCOMPARE(v.userType(), qMetaTypeId<MyQmlObject*>()); o = qvariant_cast<MyQmlObject*>(v); - QVERIFY(o == 0); + QVERIFY(!o); delete object; } @@ -1691,7 +1691,7 @@ void tst_qqmllanguage::aliasProperties() QVERIFY(object2 != 0); QObject *alias = qvariant_cast<QObject *>(object->property("aliasedObject")); - QVERIFY(alias == object2); + QCOMPARE(alias, object2); delete object1; @@ -1700,7 +1700,7 @@ void tst_qqmllanguage::aliasProperties() void *a[] = { &alias2, 0, &status }; QMetaObject::metacall(object, QMetaObject::ReadProperty, object->metaObject()->indexOfProperty("aliasedObject"), a); - QVERIFY(alias2 == 0); + QVERIFY(!alias2); } // Simple composite type @@ -2106,50 +2106,50 @@ void tst_qqmllanguage::scriptStringComparison() const qreal n = 12.345; bool ok; - QVERIFY(object2->scriptProperty().stringLiteral() == s); + QCOMPARE(object2->scriptProperty().stringLiteral(), s); QVERIFY(object3->scriptProperty().numberLiteral(&ok) == n && ok); - QVERIFY(object1->scriptProperty() == object1->scriptProperty()); - QVERIFY(object2->scriptProperty() == object2->scriptProperty()); - QVERIFY(object3->scriptProperty() == object3->scriptProperty()); + QCOMPARE(object1->scriptProperty(), object1->scriptProperty()); + QCOMPARE(object2->scriptProperty(), object2->scriptProperty()); + QCOMPARE(object3->scriptProperty(), object3->scriptProperty()); QVERIFY(object2->scriptProperty() != object3->scriptProperty()); QVERIFY(object1->scriptProperty() != object2->scriptProperty()); QVERIFY(object1->scriptProperty() != object3->scriptProperty()); func.callWithInstance(inst2, QJSValueList() << n); - QVERIFY(object2->scriptProperty() == object3->scriptProperty()); + QCOMPARE(object2->scriptProperty(), object3->scriptProperty()); func.callWithInstance(inst2, QJSValueList() << s); QVERIFY(object2->scriptProperty() != object3->scriptProperty()); func.callWithInstance(inst3, QJSValueList() << s); - QVERIFY(object2->scriptProperty() == object3->scriptProperty()); + QCOMPARE(object2->scriptProperty(), object3->scriptProperty()); func.callWithInstance(inst2, QJSValueList() << QJSValue::UndefinedValue); QVERIFY(object2->scriptProperty() != object3->scriptProperty()); func.callWithInstance(inst3, QJSValueList() << QJSValue::UndefinedValue); - QVERIFY(object2->scriptProperty() == object3->scriptProperty()); + QCOMPARE(object2->scriptProperty(), object3->scriptProperty()); func.callWithInstance(inst2, QJSValueList() << QJSValue::NullValue); QVERIFY(object2->scriptProperty() != object3->scriptProperty()); func.callWithInstance(inst3, QJSValueList() << QJSValue::NullValue); - QVERIFY(object2->scriptProperty() == object3->scriptProperty()); + QCOMPARE(object2->scriptProperty(), object3->scriptProperty()); func.callWithInstance(inst2, QJSValueList() << false); QVERIFY(object2->scriptProperty() != object3->scriptProperty()); func.callWithInstance(inst3, QJSValueList() << false); - QVERIFY(object2->scriptProperty() == object3->scriptProperty()); + QCOMPARE(object2->scriptProperty(), object3->scriptProperty()); func.callWithInstance(inst2, QJSValueList() << true); QVERIFY(object2->scriptProperty() != object3->scriptProperty()); func.callWithInstance(inst3, QJSValueList() << true); - QVERIFY(object2->scriptProperty() == object3->scriptProperty()); + QCOMPARE(object2->scriptProperty(), object3->scriptProperty()); QVERIFY(object1->scriptProperty() != object2->scriptProperty()); object2->setScriptProperty(object1->scriptProperty()); - QVERIFY(object1->scriptProperty() == object2->scriptProperty()); + QCOMPARE(object1->scriptProperty(), object2->scriptProperty()); QVERIFY(object1->scriptProperty() != object3->scriptProperty()); func.callWithInstance(inst3, QJSValueList() << engine.toScriptValue(object1->scriptProperty())); - QVERIFY(object1->scriptProperty() == object3->scriptProperty()); + QCOMPARE(object1->scriptProperty(), object3->scriptProperty()); // While this are two instances of the same object they are still considered different // because the (none literal) script string may access variables which have different @@ -3250,7 +3250,7 @@ void tst_qqmllanguage::registrationOrder() QObject *o = component.create(); QVERIFY(o != 0); - QVERIFY(o->metaObject() == &MyVersion2Class::staticMetaObject); + QCOMPARE(o->metaObject(), &MyVersion2Class::staticMetaObject); delete o; } @@ -3644,7 +3644,7 @@ void tst_qqmllanguage::compositeSingletonSameEngine() QVERIFY(s2 != 0); QCOMPARE(s2->property("testProp2"), QVariant(13)); - QVERIFY(s1 == s2); + QCOMPARE(s1, s2); } // Checks that the addresses of the composite singletons used in different @@ -3693,7 +3693,7 @@ void tst_qqmllanguage::compositeSingletonQualifiedNamespace() getSingletonInstance(engine, "singletonTest5a.qml", "singletonInstance", &s2); QVERIFY(s2 != 0); - QVERIFY(s1 == s2); + QCOMPARE(s1, s2); } // Loads a singleton from a module @@ -3719,7 +3719,7 @@ void tst_qqmllanguage::compositeSingletonModule() getSingletonInstance(engine, "singletonTest6a.qml", "singletonInstance", &s2); QVERIFY(s2 != 0); - QVERIFY(s1 == s2); + QCOMPARE(s1, s2); } // Loads a singleton from a module with a higher version @@ -3745,7 +3745,7 @@ void tst_qqmllanguage::compositeSingletonModuleVersioned() getSingletonInstance(engine, "singletonTest7a.qml", "singletonInstance", &s2); QVERIFY(s2 != 0); - QVERIFY(s1 == s2); + QCOMPARE(s1, s2); } // Loads a singleton from a module with a qualified namespace @@ -3771,7 +3771,7 @@ void tst_qqmllanguage::compositeSingletonModuleQualified() getSingletonInstance(engine, "singletonTest8a.qml", "singletonInstance", &s2); QVERIFY(s2 != 0); - QVERIFY(s1 == s2); + QCOMPARE(s1, s2); } // Tries to instantiate a type with a pragma Singleton and fails @@ -3995,7 +3995,7 @@ void tst_qqmllanguage::propertyCacheInSync() QVERIFY(ddata); QVERIFY(ddata->propertyCache); // Those always have to be in sync and correct. - QVERIFY(ddata->propertyCache == vmemoCache); + QCOMPARE(ddata->propertyCache, vmemoCache); QCOMPARE(anchors->property("margins").toInt(), 50); } diff --git a/tests/auto/qml/qqmllistmodel/tst_qqmllistmodel.cpp b/tests/auto/qml/qqmllistmodel/tst_qqmllistmodel.cpp index 4d76fc4fba..5c252013ea 100644 --- a/tests/auto/qml/qqmllistmodel/tst_qqmllistmodel.cpp +++ b/tests/auto/qml/qqmllistmodel/tst_qqmllistmodel.cpp @@ -642,7 +642,7 @@ void tst_qqmllistmodel::enumerate() } } - QVERIFY(matchCount == expectedStringCount); + QCOMPARE(matchCount, expectedStringCount); delete item; } @@ -1296,7 +1296,7 @@ void tst_qqmllistmodel::datetime() QQmlExpression e(engine.rootContext(), &model, qml); QVariant result = e.evaluate(); QDateTime dtResult = result.toDateTime(); - QVERIFY(expected == dtResult); + QCOMPARE(expected, dtResult); } class RowTester : public QObject diff --git a/tests/auto/qml/qqmllistmodelworkerscript/tst_qqmllistmodelworkerscript.cpp b/tests/auto/qml/qqmllistmodelworkerscript/tst_qqmllistmodelworkerscript.cpp index 5bf75d41d4..0ad2963265 100644 --- a/tests/auto/qml/qqmllistmodelworkerscript/tst_qqmllistmodelworkerscript.cpp +++ b/tests/auto/qml/qqmllistmodelworkerscript/tst_qqmllistmodelworkerscript.cpp @@ -647,15 +647,15 @@ void tst_qqmllistmodelworkerscript::worker_sync() QQuickItem *item = createWorkerTest(&eng, &component, &model); QVERIFY(item != 0); - QVERIFY(model.count() == 0); + QCOMPARE(model.count(), 0); QVERIFY(QMetaObject::invokeMethod(item, "addItem0")); - QVERIFY(model.count() == 2); + QCOMPARE(model.count(), 2); QVariant childData = model.data(0, 0); QQmlListModel *childModel = qobject_cast<QQmlListModel *>(childData.value<QObject *>()); QVERIFY(childModel); - QVERIFY(childModel->count() == 1); + QCOMPARE(childModel->count(), 1); QSignalSpy spyModelInserted(&model, SIGNAL(rowsInserted(QModelIndex,int,int))); QSignalSpy spyChildInserted(childModel, SIGNAL(rowsInserted(QModelIndex,int,int))); @@ -663,34 +663,34 @@ void tst_qqmllistmodelworkerscript::worker_sync() QVERIFY(QMetaObject::invokeMethod(item, "addItemViaWorker")); waitForWorker(item); - QVERIFY(model.count() == 2); - QVERIFY(childModel->count() == 1); - QVERIFY(spyModelInserted.count() == 0); - QVERIFY(spyChildInserted.count() == 0); + QCOMPARE(model.count(), 2); + QCOMPARE(childModel->count(), 1); + QCOMPARE(spyModelInserted.count(), 0); + QCOMPARE(spyChildInserted.count(), 0); QVERIFY(QMetaObject::invokeMethod(item, "doSync")); waitForWorker(item); - QVERIFY(model.count() == 2); - QVERIFY(childModel->count() == 2); - QVERIFY(spyModelInserted.count() == 0); - QVERIFY(spyChildInserted.count() == 1); + QCOMPARE(model.count(), 2); + QCOMPARE(childModel->count(), 2); + QCOMPARE(spyModelInserted.count(), 0); + QCOMPARE(spyChildInserted.count(), 1); QVERIFY(QMetaObject::invokeMethod(item, "addItemViaWorker")); waitForWorker(item); - QVERIFY(model.count() == 2); - QVERIFY(childModel->count() == 2); - QVERIFY(spyModelInserted.count() == 0); - QVERIFY(spyChildInserted.count() == 1); + QCOMPARE(model.count(), 2); + QCOMPARE(childModel->count(), 2); + QCOMPARE(spyModelInserted.count(), 0); + QCOMPARE(spyChildInserted.count(), 1); QVERIFY(QMetaObject::invokeMethod(item, "doSync")); waitForWorker(item); - QVERIFY(model.count() == 2); - QVERIFY(childModel->count() == 3); - QVERIFY(spyModelInserted.count() == 0); - QVERIFY(spyChildInserted.count() == 2); + QCOMPARE(model.count(), 2); + QCOMPARE(childModel->count(), 3); + QCOMPARE(spyModelInserted.count(), 0); + QCOMPARE(spyChildInserted.count(), 2); delete item; qApp->processEvents(); @@ -714,24 +714,24 @@ void tst_qqmllistmodelworkerscript::worker_remove_element() QSignalSpy spyModelRemoved(&model, SIGNAL(rowsRemoved(QModelIndex,int,int))); - QVERIFY(model.count() == 0); - QVERIFY(spyModelRemoved.count() == 0); + QCOMPARE(model.count(), 0); + QCOMPARE(spyModelRemoved.count(), 0); QVERIFY(QMetaObject::invokeMethod(item, "addItem")); - QVERIFY(model.count() == 1); + QCOMPARE(model.count(), 1); QVERIFY(QMetaObject::invokeMethod(item, "removeItemViaWorker")); waitForWorker(item); - QVERIFY(model.count() == 1); - QVERIFY(spyModelRemoved.count() == 0); + QCOMPARE(model.count(), 1); + QCOMPARE(spyModelRemoved.count(), 0); QVERIFY(QMetaObject::invokeMethod(item, "doSync")); waitForWorker(item); - QVERIFY(model.count() == 0); - QVERIFY(spyModelRemoved.count() == 1); + QCOMPARE(model.count(), 0); + QCOMPARE(spyModelRemoved.count(), 1); delete item; qApp->processEvents(); @@ -747,7 +747,7 @@ void tst_qqmllistmodelworkerscript::worker_remove_element() QVERIFY(QMetaObject::invokeMethod(item, "addItem")); - QVERIFY(model->count() == 1); + QCOMPARE(model->count(), 1); QVERIFY(QMetaObject::invokeMethod(item, "removeItemViaWorker")); QVERIFY(QMetaObject::invokeMethod(item, "doSync")); @@ -777,24 +777,24 @@ void tst_qqmllistmodelworkerscript::worker_remove_list() QSignalSpy spyModelRemoved(&model, SIGNAL(rowsRemoved(QModelIndex,int,int))); - QVERIFY(model.count() == 0); - QVERIFY(spyModelRemoved.count() == 0); + QCOMPARE(model.count(), 0); + QCOMPARE(spyModelRemoved.count(), 0); QVERIFY(QMetaObject::invokeMethod(item, "addList")); - QVERIFY(model.count() == 1); + QCOMPARE(model.count(), 1); QVERIFY(QMetaObject::invokeMethod(item, "removeListViaWorker")); waitForWorker(item); - QVERIFY(model.count() == 1); - QVERIFY(spyModelRemoved.count() == 0); + QCOMPARE(model.count(), 1); + QCOMPARE(spyModelRemoved.count(), 0); QVERIFY(QMetaObject::invokeMethod(item, "doSync")); waitForWorker(item); - QVERIFY(model.count() == 0); - QVERIFY(spyModelRemoved.count() == 1); + QCOMPARE(model.count(), 0); + QCOMPARE(spyModelRemoved.count(), 1); delete item; qApp->processEvents(); diff --git a/tests/auto/qml/qqmllistreference/tst_qqmllistreference.cpp b/tests/auto/qml/qqmllistreference/tst_qqmllistreference.cpp index 012080a5d9..274f292c38 100644 --- a/tests/auto/qml/qqmllistreference/tst_qqmllistreference.cpp +++ b/tests/auto/qml/qqmllistreference/tst_qqmllistreference.cpp @@ -113,15 +113,15 @@ void tst_qqmllistreference::qmllistreference_invalid() { QQmlListReference r; QVERIFY(!r.isValid()); - QVERIFY(r.object() == 0); - QVERIFY(r.listElementType() == 0); + QVERIFY(!r.object()); + QVERIFY(!r.listElementType()); QVERIFY(!r.canAt()); QVERIFY(!r.canClear()); QVERIFY(!r.canCount()); QVERIFY(!r.append(0)); - QVERIFY(r.at(10) == 0); + QVERIFY(!r.at(10)); QVERIFY(!r.clear()); - QVERIFY(r.count() == 0); + QCOMPARE(r.count(), 0); QVERIFY(!r.isReadable()); QVERIFY(!r.isManipulable()); } @@ -130,15 +130,15 @@ void tst_qqmllistreference::qmllistreference_invalid() { QQmlListReference r(&tt, "blah"); QVERIFY(!r.isValid()); - QVERIFY(r.object() == 0); - QVERIFY(r.listElementType() == 0); + QVERIFY(!r.object()); + QVERIFY(!r.listElementType()); QVERIFY(!r.canAt()); QVERIFY(!r.canClear()); QVERIFY(!r.canCount()); QVERIFY(!r.append(0)); - QVERIFY(r.at(10) == 0); + QVERIFY(!r.at(10)); QVERIFY(!r.clear()); - QVERIFY(r.count() == 0); + QCOMPARE(r.count(), 0); QVERIFY(!r.isReadable()); QVERIFY(!r.isManipulable()); } @@ -147,15 +147,15 @@ void tst_qqmllistreference::qmllistreference_invalid() { QQmlListReference r(&tt, "intProperty"); QVERIFY(!r.isValid()); - QVERIFY(r.object() == 0); - QVERIFY(r.listElementType() == 0); + QVERIFY(!r.object()); + QVERIFY(!r.listElementType()); QVERIFY(!r.canAt()); QVERIFY(!r.canClear()); QVERIFY(!r.canCount()); QVERIFY(!r.append(0)); - QVERIFY(r.at(10) == 0); + QVERIFY(!r.at(10)); QVERIFY(!r.clear()); - QVERIFY(r.count() == 0); + QCOMPARE(r.count(), 0); QVERIFY(!r.isReadable()); QVERIFY(!r.isManipulable()); } @@ -189,19 +189,19 @@ void tst_qqmllistreference::object() { QQmlListReference ref; - QVERIFY(ref.object() == 0); + QVERIFY(!ref.object()); } { QQmlListReference ref(tt, "blah"); - QVERIFY(ref.object() == 0); + QVERIFY(!ref.object()); } { QQmlListReference ref(tt, "data"); - QVERIFY(ref.object() == tt); + QCOMPARE(ref.object(), tt); delete tt; - QVERIFY(ref.object() == 0); + QVERIFY(!ref.object()); } } @@ -211,19 +211,19 @@ void tst_qqmllistreference::listElementType() { QQmlListReference ref; - QVERIFY(ref.listElementType() == 0); + QVERIFY(!ref.listElementType()); } { QQmlListReference ref(tt, "blah"); - QVERIFY(ref.listElementType() == 0); + QVERIFY(!ref.listElementType()); } { QQmlListReference ref(tt, "data"); - QVERIFY(ref.listElementType() == &TestType::staticMetaObject); + QCOMPARE(ref.listElementType(), &TestType::staticMetaObject); delete tt; - QVERIFY(ref.listElementType() == 0); + QVERIFY(!ref.listElementType()); } } @@ -419,15 +419,15 @@ void tst_qqmllistreference::append() { QQmlListReference ref(tt, "data"); QVERIFY(ref.append(tt)); - QVERIFY(tt->data.count() == 1); - QVERIFY(tt->data.at(0) == tt); + QCOMPARE(tt->data.count(), 1); + QCOMPARE(tt->data.at(0), tt); QVERIFY(!ref.append(&object)); - QVERIFY(tt->data.count() == 1); - QVERIFY(tt->data.at(0) == tt); + QCOMPARE(tt->data.count(), 1); + QCOMPARE(tt->data.at(0), tt); QVERIFY(ref.append(0)); - QVERIFY(tt->data.count() == 2); - QVERIFY(tt->data.at(0) == tt); - QVERIFY(tt->data.at(1) == 0); + QCOMPARE(tt->data.count(), 2); + QCOMPARE(tt->data.at(0), tt); + QVERIFY(!tt->data.at(1)); delete tt; QVERIFY(!ref.append(0)); } @@ -449,21 +449,21 @@ void tst_qqmllistreference::at() { QQmlListReference ref; - QVERIFY(ref.at(0) == 0); + QVERIFY(!ref.at(0)); } { QQmlListReference ref(tt, "blah"); - QVERIFY(ref.at(0) == 0); + QVERIFY(!ref.at(0)); } { QQmlListReference ref(tt, "data"); - QVERIFY(ref.at(0) == tt); - QVERIFY(ref.at(1) == 0); - QVERIFY(ref.at(2) == tt); + QCOMPARE(ref.at(0), tt); + QVERIFY(!ref.at(1)); + QCOMPARE(ref.at(2), tt); delete tt; - QVERIFY(ref.at(0) == 0); + QVERIFY(!ref.at(0)); } { @@ -471,7 +471,7 @@ void tst_qqmllistreference::at() tt.data.append(&tt); tt.property.at = 0; QQmlListReference ref(&tt, "data"); - QVERIFY(ref.at(0) == 0); + QVERIFY(!ref.at(0)); } } @@ -495,7 +495,7 @@ void tst_qqmllistreference::clear() { QQmlListReference ref(tt, "data"); QVERIFY(ref.clear()); - QVERIFY(tt->data.count() == 0); + QCOMPARE(tt->data.count(), 0); delete tt; QVERIFY(!ref.clear()); } @@ -517,21 +517,21 @@ void tst_qqmllistreference::count() { QQmlListReference ref; - QVERIFY(ref.count() == 0); + QCOMPARE(ref.count(), 0); } { QQmlListReference ref(tt, "blah"); - QVERIFY(ref.count() == 0); + QCOMPARE(ref.count(), 0); } { QQmlListReference ref(tt, "data"); - QVERIFY(ref.count() == 3); + QCOMPARE(ref.count(), 3); tt->data.removeAt(1); - QVERIFY(ref.count() == 2); + QCOMPARE(ref.count(), 2); delete tt; - QVERIFY(ref.count() == 0); + QCOMPARE(ref.count(), 0); } { @@ -539,7 +539,7 @@ void tst_qqmllistreference::count() tt.data.append(&tt); tt.property.count = 0; QQmlListReference ref(&tt, "data"); - QVERIFY(ref.count() == 0); + QCOMPARE(ref.count(), 0); } } @@ -551,24 +551,24 @@ void tst_qqmllistreference::copy() tt.data.append(&tt); QQmlListReference *r1 = new QQmlListReference(&tt, "data"); - QVERIFY(r1->count() == 3); + QCOMPARE(r1->count(), 3); QQmlListReference r2(*r1); QQmlListReference r3; r3 = *r1; - QVERIFY(r2.count() == 3); - QVERIFY(r3.count() == 3); + QCOMPARE(r2.count(), 3); + QCOMPARE(r3.count(), 3); delete r1; - QVERIFY(r2.count() == 3); - QVERIFY(r3.count() == 3); + QCOMPARE(r2.count(), 3); + QCOMPARE(r3.count(), 3); tt.data.removeAt(2); - QVERIFY(r2.count() == 2); - QVERIFY(r3.count() == 2); + QCOMPARE(r2.count(), 2); + QCOMPARE(r3.count(), 2); } void tst_qqmllistreference::qmlmetaproperty() @@ -580,10 +580,10 @@ void tst_qqmllistreference::qmlmetaproperty() QQmlProperty prop(&tt, QLatin1String("data")); QVariant v = prop.read(); - QVERIFY(v.userType() == qMetaTypeId<QQmlListReference>()); + QCOMPARE(v.userType(), qMetaTypeId<QQmlListReference>()); QQmlListReference ref = qvariant_cast<QQmlListReference>(v); - QVERIFY(ref.count() == 3); - QVERIFY(ref.listElementType() == &TestType::staticMetaObject); + QCOMPARE(ref.count(), 3); + QCOMPARE(ref.listElementType(), &TestType::staticMetaObject); } void tst_qqmllistreference::engineTypes() @@ -595,14 +595,14 @@ void tst_qqmllistreference::engineTypes() QVERIFY(o); QQmlProperty p1(o, QLatin1String("myList")); - QVERIFY(p1.propertyTypeCategory() == QQmlProperty::List); + QCOMPARE(p1.propertyTypeCategory(), QQmlProperty::List); QQmlProperty p2(o, QLatin1String("myList"), engine.rootContext()); - QVERIFY(p2.propertyTypeCategory() == QQmlProperty::List); + QCOMPARE(p2.propertyTypeCategory(), QQmlProperty::List); QVariant v = p2.read(); - QVERIFY(v.userType() == qMetaTypeId<QQmlListReference>()); + QCOMPARE(v.userType(), qMetaTypeId<QQmlListReference>()); QQmlListReference ref = qvariant_cast<QQmlListReference>(v); - QVERIFY(ref.count() == 2); + QCOMPARE(ref.count(), 2); QVERIFY(ref.listElementType()); QVERIFY(ref.listElementType() != &QObject::staticMetaObject); @@ -617,7 +617,7 @@ void tst_qqmllistreference::variantToList() QObject *o = component.create(); QVERIFY(o); - QVERIFY(o->property("value").userType() == qMetaTypeId<QQmlListReference>()); + QCOMPARE(o->property("value").userType(), qMetaTypeId<QQmlListReference>()); QCOMPARE(o->property("test").toInt(), 1); delete o; diff --git a/tests/auto/qml/qqmllocale/tst_qqmllocale.cpp b/tests/auto/qml/qqmllocale/tst_qqmllocale.cpp index 011db7b363..ba3f72f2c1 100644 --- a/tests/auto/qml/qqmllocale/tst_qqmllocale.cpp +++ b/tests/auto/qml/qqmllocale/tst_qqmllocale.cpp @@ -451,7 +451,7 @@ void tst_qqmllocale::firstDayOfWeek() Q_ARG(QVariant, QVariant(locale))); QVariant val = obj->property("firstDayOfWeek"); - QVERIFY(val.type() == QVariant::Int); + QCOMPARE(val.type(), QVariant::Int); int day = int(QLocale(locale).firstDayOfWeek()); if (day == 7) // JS Date days in range 0(Sunday) to 6(Saturday) @@ -486,12 +486,12 @@ void tst_qqmllocale::weekDays() Q_ARG(QVariant, QVariant(locale))); QVariant val = obj->property("weekDays"); - QVERIFY(val.userType() == qMetaTypeId<QJSValue>()); + QCOMPARE(val.userType(), qMetaTypeId<QJSValue>()); QList<QVariant> qmlDays = val.toList(); QList<Qt::DayOfWeek> days = QLocale(locale).weekdays(); - QVERIFY(days.count() == qmlDays.count()); + QCOMPARE(days.count(), qmlDays.count()); for (int i = 0; i < days.count(); ++i) { int day = int(days.at(i)); @@ -528,12 +528,12 @@ void tst_qqmllocale::uiLanguages() Q_ARG(QVariant, QVariant(locale))); QVariant val = obj->property("uiLanguages"); - QVERIFY(val.userType() == qMetaTypeId<QJSValue>()); + QCOMPARE(val.userType(), qMetaTypeId<QJSValue>()); QList<QVariant> qmlLangs = val.toList(); QStringList langs = QLocale(locale).uiLanguages(); - QVERIFY(langs.count() == qmlLangs.count()); + QCOMPARE(langs.count(), qmlLangs.count()); for (int i = 0; i < langs.count(); ++i) { QCOMPARE(langs.at(i), qmlLangs.at(i).toString()); diff --git a/tests/auto/qml/qqmlmetatype/tst_qqmlmetatype.cpp b/tests/auto/qml/qqmlmetatype/tst_qqmlmetatype.cpp index f5423582b2..27e92f67a3 100644 --- a/tests/auto/qml/qqmlmetatype/tst_qqmlmetatype.cpp +++ b/tests/auto/qml/qqmlmetatype/tst_qqmlmetatype.cpp @@ -126,7 +126,7 @@ void tst_qqmlmetatype::initTestCase() void tst_qqmlmetatype::qmlParserStatusCast() { - QVERIFY(QQmlMetaType::qmlType(QVariant::Int) == 0); + QVERIFY(!QQmlMetaType::qmlType(QVariant::Int)); QVERIFY(QQmlMetaType::qmlType(qMetaTypeId<TestType *>()) != 0); QCOMPARE(QQmlMetaType::qmlType(qMetaTypeId<TestType *>())->parserStatusCast(), -1); QVERIFY(QQmlMetaType::qmlType(qMetaTypeId<ValueSourceTestType *>()) != 0); @@ -146,7 +146,7 @@ void tst_qqmlmetatype::qmlParserStatusCast() void tst_qqmlmetatype::qmlPropertyValueSourceCast() { - QVERIFY(QQmlMetaType::qmlType(QVariant::Int) == 0); + QVERIFY(!QQmlMetaType::qmlType(QVariant::Int)); QVERIFY(QQmlMetaType::qmlType(qMetaTypeId<TestType *>()) != 0); QCOMPARE(QQmlMetaType::qmlType(qMetaTypeId<TestType *>())->propertyValueSourceCast(), -1); QVERIFY(QQmlMetaType::qmlType(qMetaTypeId<ParserStatusTestType *>()) != 0); @@ -166,7 +166,7 @@ void tst_qqmlmetatype::qmlPropertyValueSourceCast() void tst_qqmlmetatype::qmlPropertyValueInterceptorCast() { - QVERIFY(QQmlMetaType::qmlType(QVariant::Int) == 0); + QVERIFY(!QQmlMetaType::qmlType(QVariant::Int)); QVERIFY(QQmlMetaType::qmlType(qMetaTypeId<TestType *>()) != 0); QCOMPARE(QQmlMetaType::qmlType(qMetaTypeId<TestType *>())->propertyValueInterceptorCast(), -1); QVERIFY(QQmlMetaType::qmlType(qMetaTypeId<ParserStatusTestType *>()) != 0); @@ -224,8 +224,8 @@ void tst_qqmlmetatype::isList() void tst_qqmlmetatype::defaultObject() { - QVERIFY(QQmlMetaType::defaultProperty(&QObject::staticMetaObject).name() == 0); - QVERIFY(QQmlMetaType::defaultProperty(&ParserStatusTestType::staticMetaObject).name() == 0); + QVERIFY(!QQmlMetaType::defaultProperty(&QObject::staticMetaObject).name()); + QVERIFY(!QQmlMetaType::defaultProperty(&ParserStatusTestType::staticMetaObject).name()); QCOMPARE(QString(QQmlMetaType::defaultProperty(&TestType::staticMetaObject).name()), QString("foo")); QObject o; @@ -233,8 +233,8 @@ void tst_qqmlmetatype::defaultObject() ParserStatusTestType p; QVERIFY(QQmlMetaType::defaultProperty((QObject *)0).name() == 0); - QVERIFY(QQmlMetaType::defaultProperty(&o).name() == 0); - QVERIFY(QQmlMetaType::defaultProperty(&p).name() == 0); + QVERIFY(!QQmlMetaType::defaultProperty(&o).name()); + QVERIFY(!QQmlMetaType::defaultProperty(&p).name()); QCOMPARE(QString(QQmlMetaType::defaultProperty(&t).name()), QString("foo")); } @@ -270,8 +270,8 @@ void tst_qqmlmetatype::compositeType() QQmlType *type = QQmlMetaType::qmlType(QString("ImplicitType"), QString(""), 1, 0); QVERIFY(type); - QVERIFY(type->module() == QLatin1String("")); - QVERIFY(type->elementName() == QLatin1String("ImplicitType")); + QVERIFY(type->module().isEmpty()); + QCOMPARE(type->elementName(), QLatin1String("ImplicitType")); QCOMPARE(type->qmlTypeName(), QLatin1String("ImplicitType")); QCOMPARE(type->sourceUrl(), testFileUrl("ImplicitType.qml")); } diff --git a/tests/auto/qml/qqmlproperty/tst_qqmlproperty.cpp b/tests/auto/qml/qqmlproperty/tst_qqmlproperty.cpp index c228adafd4..1d6c2d87ff 100644 --- a/tests/auto/qml/qqmlproperty/tst_qqmlproperty.cpp +++ b/tests/auto/qml/qqmlproperty/tst_qqmlproperty.cpp @@ -187,11 +187,11 @@ void tst_qqmlproperty::qmlmetaproperty() QCOMPARE(prop.propertyTypeCategory(), QQmlProperty::InvalidCategory); QCOMPARE(prop.propertyType(), 0); QCOMPARE(prop.propertyTypeName(), (const char *)0); - QVERIFY(prop.property().name() == 0); - QVERIFY(QQmlPropertyPrivate::binding(prop) == 0); + QVERIFY(!prop.property().name()); + QVERIFY(!QQmlPropertyPrivate::binding(prop)); QQmlPropertyPrivate::setBinding(prop, binding.data()); QVERIFY(binding->ref == 1); - QVERIFY(QQmlPropertyPrivate::signalExpression(prop) == 0); + QVERIFY(!QQmlPropertyPrivate::signalExpression(prop)); QQmlPropertyPrivate::takeSignalExpression(prop, sigExpr); QVERIFY(sigExprWatcher.wasDeleted()); QCOMPARE(prop.index(), -1); @@ -254,7 +254,7 @@ void tst_qqmlproperty::registeredCompositeTypeProperty() QQmlProperty p1e(obj, "first", &engine); QQmlProperty p2e(obj, "second", &engine); QQmlProperty p3e(obj, "third", &engine); - QVERIFY(p1.propertyType() == p2.propertyType()); + QCOMPARE(p1.propertyType(), p2.propertyType()); QVERIFY(p1.propertyType() != p3.propertyType()); // check that the values are retrievable from CPP @@ -292,7 +292,7 @@ void tst_qqmlproperty::registeredCompositeTypeProperty() QQmlProperty lp2e(obj, "sclistOne", &engine); QQmlProperty lp3e(obj, "sclistTwo", &engine); QVERIFY(lp1e.propertyType() != lp2e.propertyType()); - QVERIFY(lp2e.propertyType() == lp3e.propertyType()); + QCOMPARE(lp2e.propertyType(), lp3e.propertyType()); // check that the list values are retrievable from CPP QVariant firstList = obj->property("fclist"); @@ -438,11 +438,11 @@ void tst_qqmlproperty::qmlmetaproperty_object() QCOMPARE(prop.propertyTypeCategory(), QQmlProperty::InvalidCategory); QCOMPARE(prop.propertyType(), 0); QCOMPARE(prop.propertyTypeName(), (const char *)0); - QVERIFY(prop.property().name() == 0); - QVERIFY(QQmlPropertyPrivate::binding(prop) == 0); + QVERIFY(!prop.property().name()); + QVERIFY(!QQmlPropertyPrivate::binding(prop)); QQmlPropertyPrivate::setBinding(prop, binding.data()); QVERIFY(binding->ref == 1); - QVERIFY(QQmlPropertyPrivate::signalExpression(prop) == 0); + QVERIFY(!QQmlPropertyPrivate::signalExpression(prop)); QQmlPropertyPrivate::takeSignalExpression(prop, sigExpr); QVERIFY(sigExprWatcher.wasDeleted()); QCOMPARE(prop.index(), -1); @@ -487,12 +487,12 @@ void tst_qqmlproperty::qmlmetaproperty_object() QCOMPARE(prop.propertyType(), (int)QVariant::Int); QCOMPARE(prop.propertyTypeName(), "int"); QCOMPARE(QString(prop.property().name()), QString("defaultProperty")); - QVERIFY(QQmlPropertyPrivate::binding(prop) == 0); + QVERIFY(!QQmlPropertyPrivate::binding(prop)); QTest::ignoreMessage(QtWarningMsg, "<Unknown File>: Unable to assign null to int"); QQmlPropertyPrivate::setBinding(prop, binding.data()); QVERIFY(binding); - QVERIFY(QQmlPropertyPrivate::binding(prop) == binding.data()); - QVERIFY(QQmlPropertyPrivate::signalExpression(prop) == 0); + QCOMPARE(QQmlPropertyPrivate::binding(prop), binding.data()); + QVERIFY(!QQmlPropertyPrivate::signalExpression(prop)); QQmlPropertyPrivate::takeSignalExpression(prop, sigExpr); QVERIFY(sigExprWatcher.wasDeleted()); QCOMPARE(prop.index(), dobject.metaObject()->indexOfProperty("defaultProperty")); @@ -541,11 +541,11 @@ void tst_qqmlproperty::qmlmetaproperty_object_string() QCOMPARE(prop.propertyTypeCategory(), QQmlProperty::InvalidCategory); QCOMPARE(prop.propertyType(), 0); QCOMPARE(prop.propertyTypeName(), (const char *)0); - QVERIFY(prop.property().name() == 0); - QVERIFY(QQmlPropertyPrivate::binding(prop) == 0); + QVERIFY(!prop.property().name()); + QVERIFY(!QQmlPropertyPrivate::binding(prop)); QQmlPropertyPrivate::setBinding(prop, binding.data()); QVERIFY(binding->ref == 1); - QVERIFY(QQmlPropertyPrivate::signalExpression(prop) == 0); + QVERIFY(!QQmlPropertyPrivate::signalExpression(prop)); QQmlPropertyPrivate::takeSignalExpression(prop, sigExpr); QVERIFY(sigExprWatcher.wasDeleted()); QCOMPARE(prop.index(), -1); @@ -590,12 +590,12 @@ void tst_qqmlproperty::qmlmetaproperty_object_string() QCOMPARE(prop.propertyType(), (int)QVariant::Int); QCOMPARE(prop.propertyTypeName(), "int"); QCOMPARE(QString(prop.property().name()), QString("defaultProperty")); - QVERIFY(QQmlPropertyPrivate::binding(prop) == 0); + QVERIFY(!QQmlPropertyPrivate::binding(prop)); QTest::ignoreMessage(QtWarningMsg, "<Unknown File>: Unable to assign null to int"); QQmlPropertyPrivate::setBinding(prop, binding.data()); QVERIFY(binding); - QVERIFY(QQmlPropertyPrivate::binding(prop) == binding.data()); - QVERIFY(QQmlPropertyPrivate::signalExpression(prop) == 0); + QCOMPARE(QQmlPropertyPrivate::binding(prop), binding.data()); + QVERIFY(!QQmlPropertyPrivate::signalExpression(prop)); QQmlPropertyPrivate::takeSignalExpression(prop, sigExpr); QVERIFY(sigExprWatcher.wasDeleted()); QCOMPARE(prop.index(), dobject.metaObject()->indexOfProperty("defaultProperty")); @@ -640,13 +640,13 @@ void tst_qqmlproperty::qmlmetaproperty_object_string() QCOMPARE(prop.propertyType(), 0); QCOMPARE(prop.propertyTypeName(), (const char *)0); QCOMPARE(prop.property().name(), (const char *)0); - QVERIFY(QQmlPropertyPrivate::binding(prop) == 0); + QVERIFY(!QQmlPropertyPrivate::binding(prop)); QQmlPropertyPrivate::setBinding(prop, binding.data()); QVERIFY(binding->ref == 1); - QVERIFY(QQmlPropertyPrivate::signalExpression(prop) == 0); + QVERIFY(!QQmlPropertyPrivate::signalExpression(prop)); QQmlPropertyPrivate::takeSignalExpression(prop, sigExpr); QVERIFY(!sigExprWatcher.wasDeleted()); - QVERIFY(QQmlPropertyPrivate::signalExpression(prop) == sigExpr); + QCOMPARE(QQmlPropertyPrivate::signalExpression(prop), sigExpr); QCOMPARE(prop.index(), dobject.metaObject()->indexOfMethod("clicked()")); QCOMPARE(QQmlPropertyPrivate::valueTypeCoreIndex(prop), -1); @@ -689,13 +689,13 @@ void tst_qqmlproperty::qmlmetaproperty_object_string() QCOMPARE(prop.propertyType(), 0); QCOMPARE(prop.propertyTypeName(), (const char *)0); QCOMPARE(prop.property().name(), (const char *)0); - QVERIFY(QQmlPropertyPrivate::binding(prop) == 0); + QVERIFY(!QQmlPropertyPrivate::binding(prop)); QQmlPropertyPrivate::setBinding(prop, binding.data()); QVERIFY(binding->ref == 1); - QVERIFY(QQmlPropertyPrivate::signalExpression(prop) == 0); + QVERIFY(!QQmlPropertyPrivate::signalExpression(prop)); QQmlPropertyPrivate::takeSignalExpression(prop, sigExpr); QVERIFY(!sigExprWatcher.wasDeleted()); - QVERIFY(QQmlPropertyPrivate::signalExpression(prop) == sigExpr); + QCOMPARE(QQmlPropertyPrivate::signalExpression(prop), sigExpr); QCOMPARE(prop.index(), dobject.metaObject()->indexOfMethod("oddlyNamedNotifySignal()")); QCOMPARE(QQmlPropertyPrivate::valueTypeCoreIndex(prop), -1); @@ -742,11 +742,11 @@ void tst_qqmlproperty::qmlmetaproperty_object_context() QCOMPARE(prop.propertyTypeCategory(), QQmlProperty::InvalidCategory); QCOMPARE(prop.propertyType(), 0); QCOMPARE(prop.propertyTypeName(), (const char *)0); - QVERIFY(prop.property().name() == 0); - QVERIFY(QQmlPropertyPrivate::binding(prop) == 0); + QVERIFY(!prop.property().name()); + QVERIFY(!QQmlPropertyPrivate::binding(prop)); QQmlPropertyPrivate::setBinding(prop, binding.data()); QVERIFY(binding->ref == 1); - QVERIFY(QQmlPropertyPrivate::signalExpression(prop) == 0); + QVERIFY(!QQmlPropertyPrivate::signalExpression(prop)); QQmlPropertyPrivate::takeSignalExpression(prop, sigExpr); QVERIFY(sigExprWatcher.wasDeleted()); QCOMPARE(prop.index(), -1); @@ -791,12 +791,12 @@ void tst_qqmlproperty::qmlmetaproperty_object_context() QCOMPARE(prop.propertyType(), (int)QVariant::Int); QCOMPARE(prop.propertyTypeName(), "int"); QCOMPARE(QString(prop.property().name()), QString("defaultProperty")); - QVERIFY(QQmlPropertyPrivate::binding(prop) == 0); + QVERIFY(!QQmlPropertyPrivate::binding(prop)); QTest::ignoreMessage(QtWarningMsg, "<Unknown File>: Unable to assign null to int"); QQmlPropertyPrivate::setBinding(prop, binding.data()); QVERIFY(binding); - QVERIFY(QQmlPropertyPrivate::binding(prop) == binding.data()); - QVERIFY(QQmlPropertyPrivate::signalExpression(prop) == 0); + QCOMPARE(QQmlPropertyPrivate::binding(prop), binding.data()); + QVERIFY(!QQmlPropertyPrivate::signalExpression(prop)); QQmlPropertyPrivate::takeSignalExpression(prop, sigExpr); QVERIFY(sigExprWatcher.wasDeleted()); QCOMPARE(prop.index(), dobject.metaObject()->indexOfProperty("defaultProperty")); @@ -845,11 +845,11 @@ void tst_qqmlproperty::qmlmetaproperty_object_string_context() QCOMPARE(prop.propertyTypeCategory(), QQmlProperty::InvalidCategory); QCOMPARE(prop.propertyType(), 0); QCOMPARE(prop.propertyTypeName(), (const char *)0); - QVERIFY(prop.property().name() == 0); - QVERIFY(QQmlPropertyPrivate::binding(prop) == 0); + QVERIFY(!prop.property().name()); + QVERIFY(!QQmlPropertyPrivate::binding(prop)); QQmlPropertyPrivate::setBinding(prop, binding.data()); QVERIFY(binding->ref == 1); - QVERIFY(QQmlPropertyPrivate::signalExpression(prop) == 0); + QVERIFY(!QQmlPropertyPrivate::signalExpression(prop)); QQmlPropertyPrivate::takeSignalExpression(prop, sigExpr); QVERIFY(sigExprWatcher.wasDeleted()); QCOMPARE(prop.index(), -1); @@ -894,12 +894,12 @@ void tst_qqmlproperty::qmlmetaproperty_object_string_context() QCOMPARE(prop.propertyType(), (int)QVariant::Int); QCOMPARE(prop.propertyTypeName(), "int"); QCOMPARE(QString(prop.property().name()), QString("defaultProperty")); - QVERIFY(QQmlPropertyPrivate::binding(prop) == 0); + QVERIFY(!QQmlPropertyPrivate::binding(prop)); QTest::ignoreMessage(QtWarningMsg, "<Unknown File>: Unable to assign null to int"); QQmlPropertyPrivate::setBinding(prop, binding.data()); QVERIFY(binding); - QVERIFY(QQmlPropertyPrivate::binding(prop) == binding.data()); - QVERIFY(QQmlPropertyPrivate::signalExpression(prop) == 0); + QCOMPARE(QQmlPropertyPrivate::binding(prop), binding.data()); + QVERIFY(!QQmlPropertyPrivate::signalExpression(prop)); QQmlPropertyPrivate::takeSignalExpression(prop, sigExpr); QVERIFY(sigExprWatcher.wasDeleted()); QCOMPARE(prop.index(), dobject.metaObject()->indexOfProperty("defaultProperty")); @@ -944,13 +944,13 @@ void tst_qqmlproperty::qmlmetaproperty_object_string_context() QCOMPARE(prop.propertyType(), 0); QCOMPARE(prop.propertyTypeName(), (const char *)0); QCOMPARE(prop.property().name(), (const char *)0); - QVERIFY(QQmlPropertyPrivate::binding(prop) == 0); + QVERIFY(!QQmlPropertyPrivate::binding(prop)); QQmlPropertyPrivate::setBinding(prop, binding.data()); QVERIFY(binding->ref == 1); - QVERIFY(QQmlPropertyPrivate::signalExpression(prop) == 0); + QVERIFY(!QQmlPropertyPrivate::signalExpression(prop)); QQmlPropertyPrivate::takeSignalExpression(prop, sigExpr); QVERIFY(!sigExprWatcher.wasDeleted()); - QVERIFY(QQmlPropertyPrivate::signalExpression(prop) == sigExpr); + QCOMPARE(QQmlPropertyPrivate::signalExpression(prop), sigExpr); QCOMPARE(prop.index(), dobject.metaObject()->indexOfMethod("clicked()")); QCOMPARE(QQmlPropertyPrivate::valueTypeCoreIndex(prop), -1); @@ -993,13 +993,13 @@ void tst_qqmlproperty::qmlmetaproperty_object_string_context() QCOMPARE(prop.propertyType(), 0); QCOMPARE(prop.propertyTypeName(), (const char *)0); QCOMPARE(prop.property().name(), (const char *)0); - QVERIFY(QQmlPropertyPrivate::binding(prop) == 0); + QVERIFY(!QQmlPropertyPrivate::binding(prop)); QQmlPropertyPrivate::setBinding(prop, binding.data()); QVERIFY(binding->ref == 1); - QVERIFY(QQmlPropertyPrivate::signalExpression(prop) == 0); + QVERIFY(!QQmlPropertyPrivate::signalExpression(prop)); QQmlPropertyPrivate::takeSignalExpression(prop, sigExpr); QVERIFY(!sigExprWatcher.wasDeleted()); - QVERIFY(QQmlPropertyPrivate::signalExpression(prop) == sigExpr); + QCOMPARE(QQmlPropertyPrivate::signalExpression(prop), sigExpr); QCOMPARE(prop.index(), dobject.metaObject()->indexOfMethod("oddlyNamedNotifySignal()")); QCOMPARE(QQmlPropertyPrivate::valueTypeCoreIndex(prop), -1); @@ -1202,7 +1202,7 @@ void tst_qqmlproperty::read() QCOMPARE(p.propertyTypeCategory(), QQmlProperty::Object); QCOMPARE(p.propertyType(), qMetaTypeId<MyQmlObject*>()); QVariant v = p.read(); - QVERIFY(v.userType() == QMetaType::QObjectStar); + QCOMPARE(v.userType(), int(QMetaType::QObjectStar)); QVERIFY(qvariant_cast<QObject *>(v) == o.qmlObject()); } { @@ -1216,7 +1216,7 @@ void tst_qqmlproperty::read() QVERIFY(p.propertyType() != QMetaType::QObjectStar); QVariant v = p.read(); - QVERIFY(v.userType() == QMetaType::QObjectStar); + QCOMPARE(v.userType(), int(QMetaType::QObjectStar)); QCOMPARE(qvariant_cast<QObject *>(v)->property("a").toInt(), 10); QCOMPARE(qvariant_cast<QObject *>(v)->property("b").toInt(), 19); } @@ -1226,7 +1226,7 @@ void tst_qqmlproperty::read() QVERIFY(object != 0); QVariant v = QQmlProperty::read(object, "test", &engine); - QVERIFY(v.userType() == QMetaType::QObjectStar); + QCOMPARE(v.userType(), int(QMetaType::QObjectStar)); QCOMPARE(qvariant_cast<QObject *>(v)->property("a").toInt(), 10); QCOMPARE(qvariant_cast<QObject *>(v)->property("b").toInt(), 19); } @@ -1642,7 +1642,7 @@ void tst_qqmlproperty::writeObjectToList() MyContainer *container = qobject_cast<MyContainer*>(containerComponent.create()); QVERIFY(container != 0); QQmlListReference list(container, "children"); - QVERIFY(list.count() == 1); + QCOMPARE(list.count(), 1); MyQmlObject *object = new MyQmlObject; QQmlProperty prop(container, "children"); @@ -1658,7 +1658,7 @@ void tst_qqmlproperty::writeListToList() MyContainer *container = qobject_cast<MyContainer*>(containerComponent.create()); QVERIFY(container != 0); QQmlListReference list(container, "children"); - QVERIFY(list.count() == 1); + QCOMPARE(list.count(), 1); QList<QObject*> objList; objList << new MyQmlObject() << new MyQmlObject() << new MyQmlObject() << new MyQmlObject(); diff --git a/tests/auto/qml/qqmlpropertymap/tst_qqmlpropertymap.cpp b/tests/auto/qml/qqmlpropertymap/tst_qqmlpropertymap.cpp index 4860602a45..2f3754e42d 100644 --- a/tests/auto/qml/qqmlpropertymap/tst_qqmlpropertymap.cpp +++ b/tests/auto/qml/qqmlpropertymap/tst_qqmlpropertymap.cpp @@ -104,7 +104,7 @@ void tst_QQmlPropertyMap::insert() QQmlPropertyMap map; map.insert(QLatin1String("key1"),100); map.insert(QLatin1String("key2"),200); - QVERIFY(map.keys().count() == 2); + QCOMPARE(map.keys().count(), 2); QVERIFY(map.contains(QLatin1String("key1"))); QCOMPARE(map.value(QLatin1String("key1")), QVariant(100)); @@ -117,33 +117,33 @@ void tst_QQmlPropertyMap::insert() //QQmlPropertyMap has an invokable keys() method QTest::ignoreMessage(QtWarningMsg, "Creating property with name \"keys\" is not permitted, conflicts with internal symbols."); map.insert(QLatin1String("keys"), 1); - QVERIFY(map.keys().count() == 2); + QCOMPARE(map.keys().count(), 2); QVERIFY(!map.contains(QLatin1String("keys"))); QVERIFY(map.value(QLatin1String("keys")).isNull()); //QQmlPropertyMap has a deleteLater() slot QTest::ignoreMessage(QtWarningMsg, "Creating property with name \"deleteLater\" is not permitted, conflicts with internal symbols."); map.insert(QLatin1String("deleteLater"), 1); - QVERIFY(map.keys().count() == 2); + QCOMPARE(map.keys().count(), 2); QVERIFY(!map.contains(QLatin1String("deleteLater"))); QVERIFY(map.value(QLatin1String("deleteLater")).isNull()); //QQmlPropertyMap has an valueChanged() signal QTest::ignoreMessage(QtWarningMsg, "Creating property with name \"valueChanged\" is not permitted, conflicts with internal symbols."); map.insert(QLatin1String("valueChanged"), 1); - QVERIFY(map.keys().count() == 2); + QCOMPARE(map.keys().count(), 2); QVERIFY(!map.contains(QLatin1String("valueChanged"))); QVERIFY(map.value(QLatin1String("valueChanged")).isNull()); //but 'valueChange' should be ok map.insert(QLatin1String("valueChange"), 1); - QVERIFY(map.keys().count() == 3); + QCOMPARE(map.keys().count(), 3); QVERIFY(map.contains(QLatin1String("valueChange"))); QCOMPARE(map.value(QLatin1String("valueChange")), QVariant(1)); //'valueCHANGED' should be ok, too map.insert(QLatin1String("valueCHANGED"), 1); - QVERIFY(map.keys().count() == 4); + QCOMPARE(map.keys().count(), 4); QVERIFY(map.contains(QLatin1String("valueCHANGED"))); QCOMPARE(map.value(QLatin1String("valueCHANGED")), QVariant(1)); } @@ -153,7 +153,7 @@ void tst_QQmlPropertyMap::operatorInsert() QQmlPropertyMap map; map[QLatin1String("key1")] = 100; map[QLatin1String("key2")] = 200; - QVERIFY(map.keys().count() == 2); + QCOMPARE(map.keys().count(), 2); QCOMPARE(map.value(QLatin1String("key1")), QVariant(100)); QCOMPARE(map.value(QLatin1String("key2")), QVariant(200)); @@ -167,7 +167,7 @@ void tst_QQmlPropertyMap::operatorValue() QQmlPropertyMap map; map.insert(QLatin1String("key1"),100); map.insert(QLatin1String("key2"),200); - QVERIFY(map.count() == 2); + QCOMPARE(map.count(), 2); QVERIFY(map.contains(QLatin1String("key1"))); const QQmlPropertyMap &constMap = map; @@ -182,12 +182,12 @@ void tst_QQmlPropertyMap::clear() { QQmlPropertyMap map; map.insert(QLatin1String("key1"),100); - QVERIFY(map.keys().count() == 1); + QCOMPARE(map.keys().count(), 1); QCOMPARE(map.value(QLatin1String("key1")), QVariant(100)); map.clear(QLatin1String("key1")); - QVERIFY(map.keys().count() == 1); + QCOMPARE(map.keys().count(), 1); QVERIFY(map.contains(QLatin1String("key1"))); QCOMPARE(map.value(QLatin1String("key1")), QVariant()); } @@ -463,7 +463,7 @@ void tst_QQmlPropertyMap::QTBUG_35906() QScopedPointer<QObject> obj(component.create()); QVERIFY(!obj.isNull()); QVariant value = obj->property("testValue"); - QVERIFY(value.type() == QVariant::Int); + QCOMPARE(value.type(), QVariant::Int); QCOMPARE(value.toInt(), 42); } diff --git a/tests/auto/qml/qqmlqt/tst_qqmlqt.cpp b/tests/auto/qml/qqmlqt/tst_qqmlqt.cpp index 671f7b5e73..b5bdc3a3b9 100644 --- a/tests/auto/qml/qqmlqt/tst_qqmlqt.cpp +++ b/tests/auto/qml/qqmlqt/tst_qqmlqt.cpp @@ -651,7 +651,7 @@ void tst_qqmlqt::createQmlObject() QQuickItem *item = qobject_cast<QQuickItem *>(object); QVERIFY(item != 0); - QVERIFY(item->childItems().count() == 1); + QCOMPARE(item->childItems().count(), 1); delete object; } diff --git a/tests/auto/qml/qqmltimer/tst_qqmltimer.cpp b/tests/auto/qml/qqmltimer/tst_qqmltimer.cpp index 8c0f280116..5a98a6bed8 100644 --- a/tests/auto/qml/qqmltimer/tst_qqmltimer.cpp +++ b/tests/auto/qml/qqmltimer/tst_qqmltimer.cpp @@ -186,7 +186,7 @@ void tst_qqmltimer::repeat() timer->stop(); consistentWait(200); - QVERIFY(helper.count == oldCount); + QCOMPARE(helper.count, oldCount); QVERIFY(!timer->isRunning()); QSignalSpy spy(timer, SIGNAL(repeatChanged())); diff --git a/tests/auto/qml/qqmlvaluetypes/tst_qqmlvaluetypes.cpp b/tests/auto/qml/qqmlvaluetypes/tst_qqmlvaluetypes.cpp index 578004b0a1..52f744578a 100644 --- a/tests/auto/qml/qqmlvaluetypes/tst_qqmlvaluetypes.cpp +++ b/tests/auto/qml/qqmlvaluetypes/tst_qqmlvaluetypes.cpp @@ -1183,7 +1183,7 @@ void tst_qqmlvaluetypes::enums() QQmlComponent component(&engine, testFileUrl("enums.1.qml")); MyTypeObject *object = qobject_cast<MyTypeObject *>(component.create()); QVERIFY(object != 0); - QVERIFY(object->font().capitalization() == QFont::AllUppercase); + QCOMPARE(object->font().capitalization(), QFont::AllUppercase); delete object; } @@ -1191,7 +1191,7 @@ void tst_qqmlvaluetypes::enums() QQmlComponent component(&engine, testFileUrl("enums.2.qml")); MyTypeObject *object = qobject_cast<MyTypeObject *>(component.create()); QVERIFY(object != 0); - QVERIFY(object->font().capitalization() == QFont::AllUppercase); + QCOMPARE(object->font().capitalization(), QFont::AllUppercase); delete object; } @@ -1199,7 +1199,7 @@ void tst_qqmlvaluetypes::enums() QQmlComponent component(&engine, testFileUrl("enums.3.qml")); MyTypeObject *object = qobject_cast<MyTypeObject *>(component.create()); QVERIFY(object != 0); - QVERIFY(object->font().capitalization() == QFont::AllUppercase); + QCOMPARE(object->font().capitalization(), QFont::AllUppercase); delete object; } @@ -1207,7 +1207,7 @@ void tst_qqmlvaluetypes::enums() QQmlComponent component(&engine, testFileUrl("enums.4.qml")); MyTypeObject *object = qobject_cast<MyTypeObject *>(component.create()); QVERIFY(object != 0); - QVERIFY(object->font().capitalization() == QFont::AllUppercase); + QCOMPARE(object->font().capitalization(), QFont::AllUppercase); delete object; } @@ -1215,7 +1215,7 @@ void tst_qqmlvaluetypes::enums() QQmlComponent component(&engine, testFileUrl("enums.5.qml")); MyTypeObject *object = qobject_cast<MyTypeObject *>(component.create()); QVERIFY(object != 0); - QVERIFY(object->font().capitalization() == QFont::AllUppercase); + QCOMPARE(object->font().capitalization(), QFont::AllUppercase); delete object; } } diff --git a/tests/auto/qml/qqmlxmlhttprequest/tst_qqmlxmlhttprequest.cpp b/tests/auto/qml/qqmlxmlhttprequest/tst_qqmlxmlhttprequest.cpp index 22f321654c..ae0350278a 100644 --- a/tests/auto/qml/qqmlxmlhttprequest/tst_qqmlxmlhttprequest.cpp +++ b/tests/auto/qml/qqmlxmlhttprequest/tst_qqmlxmlhttprequest.cpp @@ -850,7 +850,7 @@ void tst_qqmlxmlhttprequest::getBinaryData() component.completeCreate(); QFileInfo fileInfo("data/qml_logo.png"); - QTRY_VERIFY(object->property("readSize").toInt() == fileInfo.size()); + QTRY_COMPARE(object->property("readSize").toInt(), fileInfo.size()); QCOMPARE(object->property("status").toInt(), 200); } diff --git a/tests/auto/qml/qquickfolderlistmodel/tst_qquickfolderlistmodel.cpp b/tests/auto/qml/qquickfolderlistmodel/tst_qquickfolderlistmodel.cpp index 59be469d5b..dc6e2fa561 100644 --- a/tests/auto/qml/qquickfolderlistmodel/tst_qquickfolderlistmodel.cpp +++ b/tests/auto/qml/qquickfolderlistmodel/tst_qquickfolderlistmodel.cpp @@ -295,11 +295,11 @@ void tst_qquickfolderlistmodel::changeDrive() flm->setProperty("folder",QUrl::fromLocalFile(dataDir)); QCOMPARE(flm->property("folder").toUrl(), QUrl::fromLocalFile(dataDir)); - QTRY_VERIFY(folderChangeSpy.count() == 1); + QTRY_COMPARE(folderChangeSpy.count(), 1); flm->setProperty("folder",QUrl::fromLocalFile("X:/resetfiltering/")); QCOMPARE(flm->property("folder").toUrl(), QUrl::fromLocalFile("X:/resetfiltering/")); - QTRY_VERIFY(folderChangeSpy.count() == 2); + QTRY_COMPARE(folderChangeSpy.count(), 2); } #endif |