aboutsummaryrefslogtreecommitdiffstats
path: root/tests/auto/qml/qqmlengine
diff options
context:
space:
mode:
authorShawn Rutledge <shawn.rutledge@qt.io>2018-02-21 10:41:54 +0100
committerShawn Rutledge <shawn.rutledge@qt.io>2018-02-26 07:13:18 +0000
commit499ec43937e926e4f2fa57a9baa455fcb3862262 (patch)
tree206c90d47387f8322b68f5e3db613189397e1af3 /tests/auto/qml/qqmlengine
parent53d1e9ed21d25e65a2f13606af479838f5f21fe7 (diff)
use nullptr consistently (clang-tidy)
From now on we prefer nullptr instead of 0 to clarify cases where we are assigning or testing a pointer rather than a numeric zero. Also, replaced cases where 0 was passed as Qt::KeyboardModifiers with Qt::NoModifier (clang-tidy replaced them with nullptr, which waas wrong, so it was just as well to make the tests more readable rather than to revert those lines). Change-Id: I4735d35e4d9f42db5216862ce091429eadc6e65d Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
Diffstat (limited to 'tests/auto/qml/qqmlengine')
-rw-r--r--tests/auto/qml/qqmlengine/tst_qqmlengine.cpp54
1 files changed, 27 insertions, 27 deletions
diff --git a/tests/auto/qml/qqmlengine/tst_qqmlengine.cpp b/tests/auto/qml/qqmlengine/tst_qqmlengine.cpp
index d6d7506c48..bf964a5744 100644
--- a/tests/auto/qml/qqmlengine/tst_qqmlengine.cpp
+++ b/tests/auto/qml/qqmlengine/tst_qqmlengine.cpp
@@ -107,7 +107,7 @@ void tst_qqmlengine::rootContext()
class NetworkAccessManagerFactory : public QQmlNetworkAccessManagerFactory
{
public:
- NetworkAccessManagerFactory() : manager(0) {}
+ NetworkAccessManagerFactory() : manager(nullptr) {}
QNetworkAccessManager *create(QObject *parent) {
manager = new QNetworkAccessManager(parent);
@@ -123,7 +123,7 @@ void tst_qqmlengine::networkAccessManager()
// Test QQmlEngine created manager
QPointer<QNetworkAccessManager> manager = engine->networkAccessManager();
- QVERIFY(manager != 0);
+ QVERIFY(manager != nullptr);
delete engine;
// Test factory created manager
@@ -155,10 +155,10 @@ class ImmediateManager : public QNetworkAccessManager {
Q_OBJECT
public:
- ImmediateManager(QObject *parent = 0) : QNetworkAccessManager(parent) {
+ ImmediateManager(QObject *parent = nullptr) : QNetworkAccessManager(parent) {
}
- QNetworkReply *createRequest(Operation, const QNetworkRequest & , QIODevice * outgoingData = 0) {
+ QNetworkReply *createRequest(Operation, const QNetworkRequest & , QIODevice * outgoingData = nullptr) {
Q_UNUSED(outgoingData);
return new ImmediateReply;
}
@@ -212,17 +212,17 @@ void tst_qqmlengine::contextForObject()
QQmlEngine *engine = new QQmlEngine;
// Test null-object
- QVERIFY(!QQmlEngine::contextForObject(0));
+ QVERIFY(!QQmlEngine::contextForObject(nullptr));
// Test an object with no context
QObject object;
QVERIFY(!QQmlEngine::contextForObject(&object));
// Test setting null-object
- QQmlEngine::setContextForObject(0, engine->rootContext());
+ QQmlEngine::setContextForObject(nullptr, engine->rootContext());
// Test setting null-context
- QQmlEngine::setContextForObject(&object, 0);
+ QQmlEngine::setContextForObject(&object, nullptr);
// Test setting context
QQmlEngine::setContextForObject(&object, engine->rootContext());
@@ -236,7 +236,7 @@ void tst_qqmlengine::contextForObject()
QCOMPARE(QQmlEngine::contextForObject(&object), engine->rootContext());
// Delete context
- delete engine; engine = 0;
+ delete engine; engine = nullptr;
QVERIFY(!QQmlEngine::contextForObject(&object));
}
@@ -313,7 +313,7 @@ void tst_qqmlengine::clearComponentCache()
{
QQmlComponent component(&engine, fileUrl);
QObject *obj = component.create();
- QVERIFY(obj != 0);
+ QVERIFY(obj != nullptr);
QCOMPARE(obj->property("test").toInt(), 10);
delete obj;
}
@@ -336,7 +336,7 @@ void tst_qqmlengine::clearComponentCache()
{
QQmlComponent component(&engine, fileUrl);
QObject *obj = component.create();
- QVERIFY(obj != 0);
+ QVERIFY(obj != nullptr);
QCOMPARE(obj->property("test").toInt(), 10);
delete obj;
}
@@ -348,7 +348,7 @@ void tst_qqmlengine::clearComponentCache()
{
QQmlComponent component(&engine, fileUrl);
QObject *obj = component.create();
- QVERIFY(obj != 0);
+ QVERIFY(obj != nullptr);
QCOMPARE(obj->property("test").toInt(), 11);
delete obj;
}
@@ -371,7 +371,7 @@ public:
Q_INVOKABLE void trim()
{
// Wait for any pending deletions to occur
- QCoreApplication::sendPostedEvents(0, QEvent::DeferredDelete);
+ QCoreApplication::sendPostedEvents(nullptr, QEvent::DeferredDelete);
QCoreApplication::processEvents();
// There might be JS function objects around that hold a last ref to the compilation unit that's
@@ -423,7 +423,7 @@ void tst_qqmlengine::trimComponentCache()
QQmlComponent component(&engine, testFileUrl(file));
QVERIFY(component.isReady());
QScopedPointer<QObject> object(component.create());
- QVERIFY(object != 0);
+ QVERIFY(object != nullptr);
QCOMPARE(object->property("success").toBool(), true);
}
@@ -492,7 +492,7 @@ void tst_qqmlengine::repeatedCompilation()
QQmlComponent component(&engine, testFileUrl("repeatedCompilation.qml"));
QVERIFY(component.isReady());
QScopedPointer<QObject> object(component.create());
- QVERIFY(object != 0);
+ QVERIFY(object != nullptr);
QCOMPARE(object->property("success").toBool(), true);
}
}
@@ -536,7 +536,7 @@ void tst_qqmlengine::outputWarningsToStandardError()
QObject *o = c.create();
- QVERIFY(o != 0);
+ QVERIFY(o != nullptr);
delete o;
QCOMPARE(messageHandler.messages().count(), 1);
@@ -548,7 +548,7 @@ void tst_qqmlengine::outputWarningsToStandardError()
o = c.create();
- QVERIFY(o != 0);
+ QVERIFY(o != nullptr);
delete o;
QVERIFY2(messageHandler.messages().isEmpty(), qPrintable(messageHandler.messageString()));
@@ -557,9 +557,9 @@ void tst_qqmlengine::outputWarningsToStandardError()
void tst_qqmlengine::objectOwnership()
{
{
- QCOMPARE(QQmlEngine::objectOwnership(0), QQmlEngine::CppOwnership);
- QQmlEngine::setObjectOwnership(0, QQmlEngine::JavaScriptOwnership);
- QCOMPARE(QQmlEngine::objectOwnership(0), QQmlEngine::CppOwnership);
+ QCOMPARE(QQmlEngine::objectOwnership(nullptr), QQmlEngine::CppOwnership);
+ QQmlEngine::setObjectOwnership(nullptr, QQmlEngine::JavaScriptOwnership);
+ QCOMPARE(QQmlEngine::objectOwnership(nullptr), QQmlEngine::CppOwnership);
}
{
@@ -579,7 +579,7 @@ void tst_qqmlengine::objectOwnership()
c.setData("import QtQuick 2.0; QtObject { property QtObject object: QtObject {} }", QUrl());
QObject *o = c.create();
- QVERIFY(o != 0);
+ QVERIFY(o != nullptr);
QCOMPARE(QQmlEngine::objectOwnership(o), QQmlEngine::CppOwnership);
@@ -599,7 +599,7 @@ void tst_qqmlengine::objectOwnership()
c.setData("import QtQuick 2.0; Item { property int data: test.createAQObjectForOwnershipTest() ? 0 : 1 }", QUrl());
QVERIFY(c.isReady());
QObject *o = c.create();
- QVERIFY(o != 0);
+ QVERIFY(o != nullptr);
}
QTRY_VERIFY(spy.count());
}
@@ -614,8 +614,8 @@ void tst_qqmlengine::objectOwnership()
c.setData("import QtQuick 2.0; QtObject { property var object: { var i = test; test ? 0 : 1 } }", QUrl());
QVERIFY(c.isReady());
QObject *o = c.create();
- QVERIFY(o != 0);
- engine.rootContext()->setContextProperty("test", 0);
+ QVERIFY(o != nullptr);
+ engine.rootContext()->setContextProperty("test", nullptr);
}
QTRY_VERIFY(spy.count());
}
@@ -634,8 +634,8 @@ void tst_qqmlengine::multipleEngines()
engine1.rootContext()->setContextProperty("object", &o);
engine2.rootContext()->setContextProperty("object", &o);
- QQmlExpression expr1(engine1.rootContext(), 0, QString("object.objectName"));
- QQmlExpression expr2(engine2.rootContext(), 0, QString("object.objectName"));
+ QQmlExpression expr1(engine1.rootContext(), nullptr, QString("object.objectName"));
+ QQmlExpression expr2(engine2.rootContext(), nullptr, QString("object.objectName"));
QCOMPARE(expr1.evaluate().toString(), QString("TestName"));
QCOMPARE(expr2.evaluate().toString(), QString("TestName"));
@@ -645,13 +645,13 @@ void tst_qqmlengine::multipleEngines()
{
QQmlEngine engine1;
engine1.rootContext()->setContextProperty("object", &o);
- QQmlExpression expr1(engine1.rootContext(), 0, QString("object.objectName"));
+ QQmlExpression expr1(engine1.rootContext(), nullptr, QString("object.objectName"));
QCOMPARE(expr1.evaluate().toString(), QString("TestName"));
}
{
QQmlEngine engine1;
engine1.rootContext()->setContextProperty("object", &o);
- QQmlExpression expr1(engine1.rootContext(), 0, QString("object.objectName"));
+ QQmlExpression expr1(engine1.rootContext(), nullptr, QString("object.objectName"));
QCOMPARE(expr1.evaluate().toString(), QString("TestName"));
}
}