aboutsummaryrefslogtreecommitdiffstats
path: root/tests/auto/qml/qqmllanguage/tst_qqmllanguage.cpp
diff options
context:
space:
mode:
authorUlf Hermann <ulf.hermann@qt.io>2019-09-05 16:41:11 +0200
committerUlf Hermann <ulf.hermann@qt.io>2019-09-13 15:10:49 +0200
commit28eb0caec23e0c315056cb035535b8806ccb0f37 (patch)
treeef17b4cf984a04c94804cae29e5b546f37060f87 /tests/auto/qml/qqmllanguage/tst_qqmllanguage.cpp
parent122d0367fd96526b3573a3188286153c846680ca (diff)
Force creation of metaobjects for top level objects and components
We want those to be different types, even if they don't add any properties, signals etc. Otherwise you can cross-assign objects of components defined in different files. Fully-dynamic types, such as QQmlPropertyMap are still an exception to this. We need to use the original meta object so that you can still dynamically add properties to any derived types. Therefore, all types derived from QQmlPropertyMap are in fact just aliases of each other. Also, types which aren't addressable from the outside don't get their own meta object. Types are addressable if they live in files and the file name starts with an uppercase character. Otherwise there is no way to refer to the component from anywhere else in QML. Fixes: QTBUG-76021 Change-Id: I96a01fdad13e50e4705520fec46f2b3373e0c365 Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
Diffstat (limited to 'tests/auto/qml/qqmllanguage/tst_qqmllanguage.cpp')
-rw-r--r--tests/auto/qml/qqmllanguage/tst_qqmllanguage.cpp17
1 files changed, 13 insertions, 4 deletions
diff --git a/tests/auto/qml/qqmllanguage/tst_qqmllanguage.cpp b/tests/auto/qml/qqmllanguage/tst_qqmllanguage.cpp
index 8adacd8829..007fb5cef2 100644
--- a/tests/auto/qml/qqmllanguage/tst_qqmllanguage.cpp
+++ b/tests/auto/qml/qqmllanguage/tst_qqmllanguage.cpp
@@ -2500,7 +2500,15 @@ void tst_qqmllanguage::testType(const QString& qml, const QString& type, const Q
VERIFY_ERRORS(0);
QScopedPointer<QObject> object(component.create());
QVERIFY(object != nullptr);
- QCOMPARE(QString(object->metaObject()->className()), type);
+ const QMetaObject *meta = object->metaObject();
+ for (; meta; meta = meta->superClass()) {
+ const QString className(meta->className());
+ if (!className.contains("_QMLTYPE_") && !className.contains("_QML_")) {
+ QCOMPARE(className, type);
+ break;
+ }
+ }
+ QVERIFY(meta != nullptr);
}
engine.setImportPathList(defaultImportPathList);
@@ -4043,10 +4051,12 @@ void tst_qqmllanguage::implicitImportsLast()
VERIFY_ERRORS(0);
QScopedPointer<QObject> object(component.create());
QVERIFY(object != nullptr);
- QVERIFY(QString(object->metaObject()->className()).startsWith(QLatin1String("QQuickMouseArea")));
+ QVERIFY(QString(object->metaObject()->superClass()->superClass()->className())
+ .startsWith(QLatin1String("QQuickMouseArea")));
QObject* object2 = object->property("item").value<QObject*>();
QVERIFY(object2 != nullptr);
- QCOMPARE(QString(object2->metaObject()->className()), QLatin1String("QQuickRectangle"));
+ QCOMPARE(QString(object2->metaObject()->superClass()->className()),
+ QLatin1String("QQuickRectangle"));
engine.setImportPathList(defaultImportPathList);
}
@@ -5030,7 +5040,6 @@ void tst_qqmllanguage::instanceof()
if (QTest::currentDataTag() == QLatin1String("customRectangleWithPropInstance instanceof CustomRectangle") ||
QTest::currentDataTag() == QLatin1String("customRectangleWithPropInstance instanceof CustomImport.CustomRectangle"))
- QEXPECT_FAIL("", "QTBUG-58477: QML type rules are a little lax", Continue);
QCOMPARE(returnValue, expectedValue.toBool());
} else {
QVERIFY(expr.hasError());