tst_qqmlmoduleplugin: Clean up memory management
Task-number: QTBUG-115222 Change-Id: Ie0faf6d29e9d76abe72c9d7a0600b25a7fd47d14 Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
This commit is contained in:
parent
3e79bfacee
commit
1284917e72
|
@ -210,10 +210,9 @@ void tst_qqmlmoduleplugin::importsPlugin()
|
|||
foreach (QQmlError err, component.errors())
|
||||
qWarning() << err;
|
||||
VERIFY_ERRORS(0);
|
||||
QObject *object = component.create();
|
||||
QVERIFY(object != nullptr);
|
||||
std::unique_ptr<QObject> object { component.create() };
|
||||
QVERIFY(object.get() != nullptr);
|
||||
QCOMPARE(object->property("value").toInt(),123);
|
||||
delete object;
|
||||
}
|
||||
|
||||
void tst_qqmlmoduleplugin::importsPlugin_data()
|
||||
|
@ -285,9 +284,8 @@ void tst_qqmlmoduleplugin::importPluginWithQmlFile()
|
|||
foreach (QQmlError err, component.errors())
|
||||
qWarning() << err;
|
||||
VERIFY_ERRORS(0);
|
||||
QObject *object = component.create();
|
||||
QVERIFY(object != nullptr);
|
||||
delete object;
|
||||
std::unique_ptr<QObject> object { component.create() };
|
||||
QVERIFY(object.get() != nullptr);
|
||||
}
|
||||
|
||||
void tst_qqmlmoduleplugin::remoteImportWithQuotedUrl()
|
||||
|
@ -300,10 +298,9 @@ void tst_qqmlmoduleplugin::remoteImportWithQuotedUrl()
|
|||
component.setData(qml.toUtf8(), QUrl());
|
||||
|
||||
QTRY_COMPARE(component.status(), QQmlComponent::Ready);
|
||||
QObject *object = component.create();
|
||||
std::unique_ptr<QObject> object { component.create() };
|
||||
QCOMPARE(object->property("width").toInt(), 300);
|
||||
QVERIFY(object != nullptr);
|
||||
delete object;
|
||||
QVERIFY(object.get() != nullptr);
|
||||
|
||||
foreach (QQmlError err, component.errors())
|
||||
qWarning() << err;
|
||||
|
@ -323,10 +320,9 @@ void tst_qqmlmoduleplugin::remoteImportWithUnquotedUri()
|
|||
|
||||
|
||||
QTRY_COMPARE(component.status(), QQmlComponent::Ready);
|
||||
QObject *object = component.create();
|
||||
QVERIFY(object != nullptr);
|
||||
std::unique_ptr<QObject> object { component.create() };
|
||||
QVERIFY(object.get() != nullptr);
|
||||
QCOMPARE(object->property("width").toInt(), 300);
|
||||
delete object;
|
||||
|
||||
foreach (QQmlError err, component.errors())
|
||||
qWarning() << err;
|
||||
|
@ -368,20 +364,18 @@ void tst_qqmlmoduleplugin::importsMixedQmlCppPlugin()
|
|||
{
|
||||
QQmlComponent component(&engine, testFileUrl(QStringLiteral("importsMixedQmlCppPlugin.qml")));
|
||||
|
||||
QObject *o = component.create();
|
||||
QVERIFY2(o != nullptr, msgComponentError(component, &engine));
|
||||
std::unique_ptr<QObject> o { component.create() };
|
||||
QVERIFY2(o.get() != nullptr, msgComponentError(component, &engine));
|
||||
QCOMPARE(o->property("test").toBool(), true);
|
||||
delete o;
|
||||
}
|
||||
|
||||
{
|
||||
QQmlComponent component(&engine, testFileUrl(QStringLiteral("importsMixedQmlCppPlugin.2.qml")));
|
||||
|
||||
QObject *o = component.create();
|
||||
QVERIFY2(o != nullptr, msgComponentError(component, &engine));
|
||||
std::unique_ptr<QObject> o { component.create() };
|
||||
QVERIFY2(o.get() != nullptr, msgComponentError(component, &engine));
|
||||
QCOMPARE(o->property("test").toBool(), true);
|
||||
QCOMPARE(o->property("test2").toBool(), true);
|
||||
delete o;
|
||||
}
|
||||
|
||||
|
||||
|
@ -444,9 +438,8 @@ void tst_qqmlmoduleplugin::implicitQmldir()
|
|||
QList<QQmlError> errors = component.errors();
|
||||
VERIFY_ERRORS(errorFileName.toLatin1().constData());
|
||||
QTest::ignoreMessage(QtWarningMsg, "QQmlComponent: Component is not ready");
|
||||
QObject *obj = component.create();
|
||||
QVERIFY(!obj);
|
||||
delete obj;
|
||||
std::unique_ptr<QObject> obj { component.create() };
|
||||
QVERIFY(!obj.get());
|
||||
}
|
||||
|
||||
void tst_qqmlmoduleplugin::importsNested_data()
|
||||
|
@ -481,17 +474,17 @@ void tst_qqmlmoduleplugin::importsNested()
|
|||
QTest::ignoreMessage(QtWarningMsg, "Module 'org.qtproject.AutoTestQmlNestedPluginType' does not contain a module identifier directive - it cannot be protected from external registrations.");
|
||||
|
||||
QQmlComponent component(&engine, testFile(file));
|
||||
QObject *obj = component.create();
|
||||
std::unique_ptr<QObject> obj { component.create() };
|
||||
|
||||
if (errorFile.isEmpty()) {
|
||||
if (qgetenv("DEBUG") != "" && !component.errors().isEmpty())
|
||||
qWarning() << "Unexpected Errors:" << component.errors();
|
||||
QVERIFY(obj);
|
||||
delete obj;
|
||||
QVERIFY(obj.get());
|
||||
obj.reset();
|
||||
} else {
|
||||
QList<QQmlError> errors = component.errors();
|
||||
VERIFY_ERRORS(errorFile.toLatin1().constData());
|
||||
QVERIFY(!obj);
|
||||
QVERIFY(!obj.get());
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -687,10 +680,9 @@ void tst_qqmlmoduleplugin::importsChildPlugin()
|
|||
foreach (QQmlError err, component.errors())
|
||||
qWarning() << err;
|
||||
VERIFY_ERRORS(0);
|
||||
QObject *object = component.create();
|
||||
QVERIFY(object != nullptr);
|
||||
std::unique_ptr<QObject> object { component.create() };
|
||||
QVERIFY(object.get() != nullptr);
|
||||
QCOMPARE(object->property("value").toInt(),123);
|
||||
delete object;
|
||||
}
|
||||
|
||||
void tst_qqmlmoduleplugin::importsChildPlugin2()
|
||||
|
@ -704,10 +696,9 @@ void tst_qqmlmoduleplugin::importsChildPlugin2()
|
|||
foreach (QQmlError err, component.errors())
|
||||
qWarning() << err;
|
||||
VERIFY_ERRORS(0);
|
||||
QObject *object = component.create();
|
||||
QVERIFY(object != nullptr);
|
||||
std::unique_ptr<QObject> object { component.create() };
|
||||
QVERIFY(object.get() != nullptr);
|
||||
QCOMPARE(object->property("value").toInt(),123);
|
||||
delete object;
|
||||
}
|
||||
|
||||
void tst_qqmlmoduleplugin::importsChildPlugin21()
|
||||
|
@ -721,10 +712,9 @@ void tst_qqmlmoduleplugin::importsChildPlugin21()
|
|||
foreach (QQmlError err, component.errors())
|
||||
qWarning() << err;
|
||||
VERIFY_ERRORS(0);
|
||||
QObject *object = component.create();
|
||||
QVERIFY(object != nullptr);
|
||||
std::unique_ptr<QObject> object { component.create() };
|
||||
QVERIFY(object.get() != nullptr);
|
||||
QCOMPARE(object->property("value").toInt(),123);
|
||||
delete object;
|
||||
}
|
||||
|
||||
void tst_qqmlmoduleplugin::parallelPluginImport()
|
||||
|
@ -780,10 +770,9 @@ void tst_qqmlmoduleplugin::multiSingleton()
|
|||
engine.addImportPath(m_importsDirectory);
|
||||
QQmlComponent component(&engine, testFileUrl("multiSingleton.qml"));
|
||||
QVERIFY2(component.isReady(), qPrintable(component.errorString()));
|
||||
QObject *object = component.create();
|
||||
QVERIFY(object != nullptr);
|
||||
std::unique_ptr<QObject> object { component.create() };
|
||||
QVERIFY(object.get() != nullptr);
|
||||
QCOMPARE(obj.objectName(), QLatin1String("first"));
|
||||
delete object;
|
||||
}
|
||||
|
||||
void tst_qqmlmoduleplugin::optionalPlugin()
|
||||
|
|
Loading…
Reference in New Issue