diff options
Diffstat (limited to 'tests/auto/qml/qqmlmetatype/tst_qqmlmetatype.cpp')
-rw-r--r-- | tests/auto/qml/qqmlmetatype/tst_qqmlmetatype.cpp | 42 |
1 files changed, 22 insertions, 20 deletions
diff --git a/tests/auto/qml/qqmlmetatype/tst_qqmlmetatype.cpp b/tests/auto/qml/qqmlmetatype/tst_qqmlmetatype.cpp index 76185a97e0..296d1b14e0 100644 --- a/tests/auto/qml/qqmlmetatype/tst_qqmlmetatype.cpp +++ b/tests/auto/qml/qqmlmetatype/tst_qqmlmetatype.cpp @@ -157,7 +157,7 @@ void tst_qqmlmetatype::initTestCase() void tst_qqmlmetatype::qmlParserStatusCast() { - QVERIFY(!QQmlMetaType::qmlType(QVariant::Int).isValid()); + QVERIFY(!QQmlMetaType::qmlType(QMetaType::Int).isValid()); QVERIFY(QQmlMetaType::qmlType(qMetaTypeId<TestType *>()).isValid()); QCOMPARE(QQmlMetaType::qmlType(qMetaTypeId<TestType *>()).parserStatusCast(), -1); QVERIFY(QQmlMetaType::qmlType(qMetaTypeId<ValueSourceTestType *>()).isValid()); @@ -177,7 +177,7 @@ void tst_qqmlmetatype::qmlParserStatusCast() void tst_qqmlmetatype::qmlPropertyValueSourceCast() { - QVERIFY(!QQmlMetaType::qmlType(QVariant::Int).isValid()); + QVERIFY(!QQmlMetaType::qmlType(QMetaType::Int).isValid()); QVERIFY(QQmlMetaType::qmlType(qMetaTypeId<TestType *>()).isValid()); QCOMPARE(QQmlMetaType::qmlType(qMetaTypeId<TestType *>()).propertyValueSourceCast(), -1); QVERIFY(QQmlMetaType::qmlType(qMetaTypeId<ParserStatusTestType *>()).isValid()); @@ -197,7 +197,7 @@ void tst_qqmlmetatype::qmlPropertyValueSourceCast() void tst_qqmlmetatype::qmlPropertyValueInterceptorCast() { - QVERIFY(!QQmlMetaType::qmlType(QVariant::Int).isValid()); + QVERIFY(!QQmlMetaType::qmlType(QMetaType::Int).isValid()); QVERIFY(QQmlMetaType::qmlType(qMetaTypeId<TestType *>()).isValid()); QCOMPARE(QQmlMetaType::qmlType(qMetaTypeId<TestType *>()).propertyValueInterceptorCast(), -1); QVERIFY(QQmlMetaType::qmlType(qMetaTypeId<ParserStatusTestType *>()).isValid()); @@ -256,8 +256,8 @@ void tst_qqmlmetatype::prettyTypeName() void tst_qqmlmetatype::isList() { - QCOMPARE(QQmlMetaType::isList(QVariant::Invalid), false); - QCOMPARE(QQmlMetaType::isList(QVariant::Int), false); + QCOMPARE(QQmlMetaType::isList(QMetaType::UnknownType), false); + QCOMPARE(QQmlMetaType::isList(QMetaType::Int), false); QQmlListProperty<TestType> list; @@ -307,7 +307,7 @@ void tst_qqmlmetatype::compositeType() //Loading the test file also loads all composite types it imports QQmlComponent c(&engine, testFileUrl("testImplicitComposite.qml")); - QObject* obj = c.create(); + QScopedPointer<QObject> obj(c.create()); QVERIFY(obj); QQmlType type = QQmlMetaType::qmlType(QString("ImplicitType"), QString(""), 1, 0); @@ -324,13 +324,13 @@ void tst_qqmlmetatype::externalEnums() qmlRegisterSingletonType<ExternalEnums>("x.y.z", 1, 0, "ExternalEnums", ExternalEnums::create); QQmlComponent c(&engine, testFileUrl("testExternalEnums.qml")); - QObject *obj = c.create(); + QScopedPointer<QObject> obj(c.create()); QVERIFY(obj); QVariant a = obj->property("a"); - QCOMPARE(a.type(), QVariant::Int); + QCOMPARE(a.userType(), QVariant::Int); QCOMPARE(a.toInt(), int(QStandardPaths::DocumentsLocation)); QVariant b = obj->property("b"); - QCOMPARE(b.type(), QVariant::Int); + QCOMPARE(b.userType(), QVariant::Int); QCOMPARE(b.toInt(), int(QStandardPaths::DocumentsLocation)); } @@ -394,10 +394,10 @@ void tst_qqmlmetatype::unregisterCustomType() QObject *controller = obj->findChild<QObject *>("controller"); QVERIFY(qobject_cast<Controller1 *>(controller)); QVariant stringVal = controller->property("string"); - QCOMPARE(stringVal.type(), QVariant::String); + QCOMPARE(stringVal.userType(), QVariant::String); QCOMPARE(stringVal.toString(), QStringLiteral("Controller #1")); QVariant enumVal = controller->property("enumVal"); - QCOMPARE(enumVal.type(), QVariant::Int); + QCOMPARE(enumVal.userType(), QVariant::Int); QCOMPARE(enumVal.toInt(), 1); } QQmlMetaType::unregisterType(controllerId); @@ -417,10 +417,10 @@ void tst_qqmlmetatype::unregisterCustomType() QObject *controller = obj->findChild<QObject *>("controller"); QVERIFY(qobject_cast<Controller2 *>(controller)); QVariant stringVal = controller->property("string"); - QCOMPARE(stringVal.type(), QVariant::String); + QCOMPARE(stringVal.userType(), QVariant::String); QCOMPARE(stringVal.toString(), QStringLiteral("Controller #2")); QVariant enumVal = controller->property("enumVal"); - QCOMPARE(enumVal.type(), QVariant::Int); + QCOMPARE(enumVal.userType(), QVariant::Int); QCOMPARE(enumVal.toInt(), 111); } QQmlMetaType::unregisterType(controllerId); @@ -440,10 +440,10 @@ void tst_qqmlmetatype::unregisterCustomType() QObject *controller = obj->findChild<QObject *>("controller"); QVERIFY(qobject_cast<Controller1 *>(controller)); QVariant stringVal = controller->property("string"); - QCOMPARE(stringVal.type(), QVariant::String); + QCOMPARE(stringVal.userType(), QVariant::String); QCOMPARE(stringVal.toString(), QStringLiteral("Controller #1")); QVariant enumVal = controller->property("enumVal"); - QCOMPARE(enumVal.type(), QVariant::Int); + QCOMPARE(enumVal.userType(), QVariant::Int); QCOMPARE(enumVal.toInt(), 1); } } @@ -489,7 +489,7 @@ void tst_qqmlmetatype::unregisterCustomSingletonType() QScopedPointer<QObject> obj(c.create()); QVERIFY(obj.data()); QVariant stringVal = obj->property("text"); - QCOMPARE(stringVal.type(), QVariant::String); + QCOMPARE(stringVal.userType(), QVariant::String); QCOMPARE(stringVal.toString(), QStringLiteral("StaticProvider #1")); } QQmlMetaType::unregisterType(staticProviderId); @@ -505,7 +505,7 @@ void tst_qqmlmetatype::unregisterCustomSingletonType() QScopedPointer<QObject> obj(c.create()); QVERIFY(obj.data()); QVariant stringVal = obj->property("text"); - QCOMPARE(stringVal.type(), QVariant::String); + QCOMPARE(stringVal.userType(), QVariant::String); QCOMPARE(stringVal.toString(), QStringLiteral("StaticProvider #2")); } QQmlMetaType::unregisterType(staticProviderId); @@ -521,7 +521,7 @@ void tst_qqmlmetatype::unregisterCustomSingletonType() QScopedPointer<QObject> obj(c.create()); QVERIFY(obj.data()); QVariant stringVal = obj->property("text"); - QCOMPARE(stringVal.type(), QVariant::String); + QCOMPARE(stringVal.userType(), QVariant::String); QCOMPARE(stringVal.toString(), QStringLiteral("StaticProvider #1")); } } @@ -552,7 +552,8 @@ void tst_qqmlmetatype::unregisterAttachedProperties() QCOMPARE(attachedType.attachedPropertiesType(QQmlEnginePrivate::get(&e)), attachedType.metaObject()); - QVERIFY(c.create()); + QScopedPointer<QObject> obj(c.create()); + QVERIFY(obj); } qmlClearTypeRegistrations(); @@ -571,7 +572,8 @@ void tst_qqmlmetatype::unregisterAttachedProperties() QCOMPARE(attachedType.attachedPropertiesType(QQmlEnginePrivate::get(&e)), attachedType.metaObject()); - QVERIFY(c.create()); + QScopedPointer<QObject> obj(c.create()); + QVERIFY(obj); } } |