aboutsummaryrefslogtreecommitdiffstats
path: root/tests/auto/qml/qqmlecmascript/tst_qqmlecmascript.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'tests/auto/qml/qqmlecmascript/tst_qqmlecmascript.cpp')
-rw-r--r--tests/auto/qml/qqmlecmascript/tst_qqmlecmascript.cpp170
1 files changed, 94 insertions, 76 deletions
diff --git a/tests/auto/qml/qqmlecmascript/tst_qqmlecmascript.cpp b/tests/auto/qml/qqmlecmascript/tst_qqmlecmascript.cpp
index eb25eb70f4..b30dfcbd0b 100644
--- a/tests/auto/qml/qqmlecmascript/tst_qqmlecmascript.cpp
+++ b/tests/auto/qml/qqmlecmascript/tst_qqmlecmascript.cpp
@@ -326,6 +326,7 @@ private slots:
void readUnregisteredQObjectProperty();
void writeUnregisteredQObjectProperty();
void switchExpression();
+ void qtbug_46022();
private:
// static void propertyVarWeakRefCallback(v8::Persistent<v8::Value> object, void* parameter);
@@ -521,7 +522,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 +532,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 +886,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 +909,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 +933,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 +942,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 +996,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 +1460,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 +1471,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 +1483,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 +1499,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 +1681,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 +1692,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 +1703,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;
}
}
@@ -1750,9 +1751,9 @@ void tst_qqmlecmascript::objectHasOwnProperty()
// test QObjects in QML
QMetaObject::invokeMethod(object, "testHasOwnPropertySuccess");
- QVERIFY(object->property("result").value<bool>() == true);
+ QVERIFY(object->property("result").value<bool>());
QMetaObject::invokeMethod(object, "testHasOwnPropertyFailure");
- QVERIFY(object->property("result").value<bool>() == false);
+ QVERIFY(!object->property("result").value<bool>());
// now test other types in QML
QObject *child = object->findChild<QObject*>("typeObj");
@@ -1846,7 +1847,7 @@ void tst_qqmlecmascript::uncreatableExtendedObjectFailureCheck()
QQmlComponent component(&engine, testFileUrl("uncreatableExtendedObjectFailureCheck.qml"));
QObject *object = component.create();
- QVERIFY(object == 0);
+ QVERIFY(!object);
}
/*
@@ -2235,7 +2236,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 +2994,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 +3261,7 @@ void tst_qqmlecmascript::ownership()
QCoreApplication::sendPostedEvents(0, QEvent::DeferredDelete);
QCoreApplication::processEvents();
- QVERIFY(own.object == 0);
+ QVERIFY(own.object.isNull());
delete object;
}
@@ -3319,7 +3320,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 +3348,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 +3365,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 +3447,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 +3864,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 +3921,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;
}
@@ -3929,7 +3930,7 @@ void tst_qqmlecmascript::singletonTypeResolution()
QQmlComponent component(&engine, testFileUrl("singletontype/singletonTypeResolution.qml"));
QObject *object = component.create();
QVERIFY(object);
- QVERIFY(object->property("success") == true);
+ QVERIFY(object->property("success").toBool());
delete object;
}
@@ -3941,12 +3942,12 @@ void tst_qqmlecmascript::verifyContextLifetime(QQmlContextData *ctxt) {
QV4::ExecutionEngine *v4 = QV8Engine::getV4(engine);
QV4::Scope scope(v4);
QV4::ScopedArrayObject scripts(scope, ctxt->importedScripts.value());
- QV4::ScopedValue qml(scope);
+ QV4::Scoped<QV4::QmlContextWrapper> qml(scope);
for (quint32 i = 0; i < scripts->getLength(); ++i) {
QQmlContextData *scriptContext, *newContext;
qml = scripts->getIndexed(i);
- scriptContext = QV4::QmlContextWrapper::getContext(qml);
+ scriptContext = qml ? qml->getContext() : 0;
qml = QV4::Encode::undefined();
{
@@ -3957,8 +3958,8 @@ void tst_qqmlecmascript::verifyContextLifetime(QQmlContextData *ctxt) {
ctxt->engine->collectGarbage();
qml = scripts->getIndexed(i);
- newContext = QV4::QmlContextWrapper::getContext(qml);
- QVERIFY(scriptContext == newContext);
+ newContext = qml ? qml->getContext() : 0;
+ QCOMPARE(scriptContext, newContext);
}
}
@@ -4202,9 +4203,7 @@ void tst_qqmlecmascript::importScripts()
QFETCH(QStringList, propertyNames);
QFETCH(QVariantList, propertyValues);
- TestHTTPServer server;
- QVERIFY2(server.listen(), qPrintable(server.errorString()));
- server.serveDirectory(dataDirectory() + "/remote");
+ ThreadedTestHTTPServer server(dataDirectory() + "/remote");
QStringList importPathList = engine.importPathList();
@@ -4232,7 +4231,7 @@ void tst_qqmlecmascript::importScripts()
QObject *object = component.create();
if (!errorMessage.isEmpty()) {
- QVERIFY(object == 0);
+ QVERIFY(!object);
} else {
QVERIFY(object != 0);
@@ -4685,7 +4684,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 +4692,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 +4700,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 +4708,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;
}
@@ -5007,6 +5006,12 @@ void tst_qqmlecmascript::propertyVarCircular()
QObject *object = component.create();
QVERIFY(object != 0);
QMetaObject::invokeMethod(object, "assignCircular"); // cause assignment and gc
+ {
+ QCOMPARE(object->property("canaryInt"), QVariant(5));
+ QVariant canaryResourceVariant = object->property("canaryResource");
+ QVERIFY(canaryResourceVariant.isValid());
+ }
+
QCoreApplication::sendPostedEvents(0, QEvent::DeferredDelete); // process deleteLater() events from QV8QObjectWrapper.
QCoreApplication::processEvents();
QCOMPARE(object->property("canaryInt"), QVariant(5));
@@ -5703,9 +5708,10 @@ void tst_qqmlecmascript::deletedEngine()
delete engine;
- QCOMPARE(object->property("a").toInt(), 117);
+ QCOMPARE(object->property("a").toInt(), 0);
object->setProperty("b", QVariant(10));
- QCOMPARE(object->property("a").toInt(), 117);
+ object->setProperty("b", QVariant());
+ QCOMPARE(object->property("a").toInt(), 0);
delete object;
}
@@ -5747,10 +5753,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 +5807,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 +5854,7 @@ void tst_qqmlecmascript::canAssignNullToQObject()
o->setProperty("runTest", true);
- QVERIFY(o->objectProperty() == 0);
+ QVERIFY(!o->objectProperty());
delete o;
}
@@ -5859,7 +5865,7 @@ void tst_qqmlecmascript::canAssignNullToQObject()
MyQmlObject *o = qobject_cast<MyQmlObject *>(component.create());
QVERIFY(o != 0);
- QVERIFY(o->objectProperty() == 0);
+ QVERIFY(!o->objectProperty());
delete o;
}
@@ -6064,7 +6070,7 @@ void tst_qqmlecmascript::include()
o->setProperty("serverBaseUrl", server.baseUrl().toString());
component.completeCreate();
- QTRY_VERIFY(o->property("done").toBool() == true);
+ QTRY_VERIFY(o->property("done").toBool());
QCOMPARE(o->property("test1").toBool(), true);
QCOMPARE(o->property("test2").toBool(), true);
@@ -6108,8 +6114,8 @@ void tst_qqmlecmascript::includeRemoteSuccess()
o->setProperty("serverBaseUrl", server.baseUrl().toString());
component.completeCreate();
- QTRY_VERIFY(o->property("done").toBool() == true);
- QTRY_VERIFY(o->property("done2").toBool() == true);
+ QTRY_VERIFY(o->property("done").toBool());
+ QTRY_VERIFY(o->property("done2").toBool());
QCOMPARE(o->property("test1").toBool(), true);
QCOMPARE(o->property("test2").toBool(), true);
@@ -6132,7 +6138,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 +6146,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 +6690,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()
@@ -7032,7 +7038,7 @@ void tst_qqmlecmascript::invokableWithQObjectDerived()
QObject *object = component.create();
QVERIFY(object != 0);
- QVERIFY(object->property("result").value<bool>() == true);
+ QVERIFY(object->property("result").value<bool>());
delete object;
}
@@ -7111,6 +7117,7 @@ void tst_qqmlecmascript::onDestruction()
QObject *obj = c.create();
QVERIFY(obj != 0);
delete obj;
+ QCoreApplication::sendPostedEvents(0, QEvent::DeferredDelete);
}
{
@@ -7122,6 +7129,7 @@ void tst_qqmlecmascript::onDestruction()
QQmlComponent c(&engine, testFileUrl("onDestruction.qml"));
QObject *obj = c.create();
QVERIFY(obj != 0);
+ QCoreApplication::sendPostedEvents(0, QEvent::DeferredDelete);
}
}
@@ -7320,7 +7328,7 @@ void tst_qqmlecmascript::sequenceSort_data()
for (size_t t=0 ; t < sizeof(types)/sizeof(types[0]) ; ++t) {
for (size_t s=0 ; s < sizeof(sort)/sizeof(sort[0]) ; ++s) {
for (int c=0 ; c < 2 ; ++c) {
- QString testName = QLatin1String(types[t]) + QLatin1String("_") + QLatin1String(sort[s]);
+ QString testName = QLatin1String(types[t]) + QLatin1Char('_') + QLatin1String(sort[s]);
QString fnName = QLatin1String("test_") + testName;
bool useComparer = c != 0;
testName += useComparer ? QLatin1String("[custom]") : QLatin1String("[default]");
@@ -7344,7 +7352,7 @@ void tst_qqmlecmascript::sequenceSort()
QVariant q;
QMetaObject::invokeMethod(object, function.toAscii().constData(), Q_RETURN_ARG(QVariant, q), Q_ARG(QVariant, useComparer));
- QVERIFY(q.toBool() == true);
+ QVERIFY(q.toBool());
delete object;
}
@@ -7360,10 +7368,10 @@ void tst_qqmlecmascript::dateParse()
QVariant q;
QMetaObject::invokeMethod(object, "test_is_invalid_jsDateTime", Q_RETURN_ARG(QVariant, q));
- QVERIFY(q.toBool() == true);
+ QVERIFY(q.toBool());
QMetaObject::invokeMethod(object, "test_is_invalid_qtDateTime", Q_RETURN_ARG(QVariant, q));
- QVERIFY(q.toBool() == true);
+ QVERIFY(q.toBool());
QMetaObject::invokeMethod(object, "test_rfc2822_date", Q_RETURN_ARG(QVariant, q));
QCOMPARE(q.toLongLong(), 1379512851000LL);
@@ -7381,7 +7389,7 @@ void tst_qqmlecmascript::utcDate()
QVariant q;
QVariant val = QString::fromLatin1("2014-07-16T23:30:31");
QMetaObject::invokeMethod(object, "check_utc", Q_RETURN_ARG(QVariant, q), Q_ARG(QVariant, val));
- QVERIFY(q.toBool() == true);
+ QVERIFY(q.toBool());
}
void tst_qqmlecmascript::negativeYear()
@@ -7478,7 +7486,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 +7499,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()
@@ -7611,13 +7619,13 @@ void tst_qqmlecmascript::miscTypeTest()
QVariant q;
QMetaObject::invokeMethod(object, "test_invalid_url_equal", Q_RETURN_ARG(QVariant, q));
- QVERIFY(q.toBool() == true);
+ QVERIFY(q.toBool());
QMetaObject::invokeMethod(object, "test_invalid_url_strictequal", Q_RETURN_ARG(QVariant, q));
- QVERIFY(q.toBool() == true);
+ QVERIFY(q.toBool());
QMetaObject::invokeMethod(object, "test_valid_url_equal", Q_RETURN_ARG(QVariant, q));
- QVERIFY(q.toBool() == true);
+ QVERIFY(q.toBool());
QMetaObject::invokeMethod(object, "test_valid_url_strictequal", Q_RETURN_ARG(QVariant, q));
- QVERIFY(q.toBool() == true);
+ QVERIFY(q.toBool());
delete object;
}
@@ -7665,7 +7673,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 +7685,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);
}
@@ -7688,7 +7696,7 @@ void tst_qqmlecmascript::varPropertyAccessOnObjectWithInvalidContext()
if (obj.isNull())
qDebug() << component.errors().first().toString();
QVERIFY(!obj.isNull());
- QVERIFY(obj->property("success") == true);
+ QVERIFY(obj->property("success").toBool());
}
void tst_qqmlecmascript::importedScriptsAccessOnObjectWithInvalidContext()
@@ -7698,7 +7706,7 @@ void tst_qqmlecmascript::importedScriptsAccessOnObjectWithInvalidContext()
if (obj.isNull())
qDebug() << component.errors().first().toString();
QVERIFY(!obj.isNull());
- QTRY_VERIFY(obj->property("success") == true);
+ QTRY_VERIFY(obj->property("success").toBool());
}
void tst_qqmlecmascript::importedScriptsWithoutQmlMode()
@@ -7708,7 +7716,7 @@ void tst_qqmlecmascript::importedScriptsWithoutQmlMode()
if (obj.isNull())
qDebug() << component.errors().first().toString();
QVERIFY(!obj.isNull());
- QTRY_VERIFY(obj->property("success") == true);
+ QTRY_VERIFY(obj->property("success").toBool());
}
void tst_qqmlecmascript::contextObjectOnLazyBindings()
@@ -7871,6 +7879,16 @@ void tst_qqmlecmascript::switchExpression()
QCOMPARE(v.toBool(), true);
}
+void tst_qqmlecmascript::qtbug_46022()
+{
+ QQmlComponent component(&engine, testFileUrl("qtbug_46022.qml"));
+
+ QScopedPointer<QObject> obj(component.create());
+ QVERIFY(obj != 0);
+ QCOMPARE(obj->property("test1").toBool(), true);
+ QCOMPARE(obj->property("test2").toBool(), true);
+}
+
QTEST_MAIN(tst_qqmlecmascript)
#include "tst_qqmlecmascript.moc"