aboutsummaryrefslogtreecommitdiffstats
path: root/tests/auto/qml/qqmllanguage
diff options
context:
space:
mode:
Diffstat (limited to 'tests/auto/qml/qqmllanguage')
-rw-r--r--tests/auto/qml/qqmllanguage/CMakeLists.txt71
-rw-r--r--tests/auto/qml/qqmllanguage/data/importVersionMissingBuiltIn.errors.txt1
-rw-r--r--tests/auto/qml/qqmllanguage/data/importVersionMissingInstalled.errors.txt2
-rw-r--r--tests/auto/qml/qqmllanguage/testtypes.cpp2
-rw-r--r--tests/auto/qml/qqmllanguage/tst_qqmllanguage.cpp93
5 files changed, 160 insertions, 9 deletions
diff --git a/tests/auto/qml/qqmllanguage/CMakeLists.txt b/tests/auto/qml/qqmllanguage/CMakeLists.txt
new file mode 100644
index 0000000000..568ab7537e
--- /dev/null
+++ b/tests/auto/qml/qqmllanguage/CMakeLists.txt
@@ -0,0 +1,71 @@
+# Generated from qqmllanguage.pro.
+
+#####################################################################
+## tst_qqmllanguage Test:
+#####################################################################
+
+# Collect test data
+file(GLOB_RECURSE test_data_glob
+ RELATIVE ${CMAKE_CURRENT_SOURCE_DIR}
+ data/*)
+list(APPEND test_data ${test_data_glob})
+
+qt_add_test(tst_qqmllanguage
+ SOURCES
+ ../../shared/testhttpserver.cpp ../../shared/testhttpserver.h
+ ../../shared/util.cpp ../../shared/util.h
+ testtypes.cpp testtypes.h
+ tst_qqmllanguage.cpp
+ INCLUDE_DIRECTORIES
+ ../../shared
+ PUBLIC_LIBRARIES
+ Qt::CorePrivate
+ Qt::Gui
+ Qt::GuiPrivate
+ Qt::Network
+ Qt::QmlPrivate
+ TESTDATA ${test_data}
+)
+
+#### Keys ignored in scope 1:.:.:qqmllanguage.pro:<TRUE>:
+# OTHER_FILES = "data/readonlyObjectProperty.qml"
+# QML_IMPORT_NAME = "StaticTest"
+# QML_IMPORT_VERSION = "1.0"
+
+## Scopes:
+#####################################################################
+
+if(ANDROID)
+ # Resources:
+ set_source_files_properties("data/I18nType30.qml"
+ PROPERTIES QT_RESOURCE_ALIAS "data/I18nTypeÁâãäå.qml"
+ )
+ set(qqmllanguage_resource_files
+ "data/I18nType30.qml"
+ )
+
+ qt_add_resource(tst_qqmllanguage "qqmllanguage"
+ PREFIX
+ "/"
+ FILES
+ ${qqmllanguage_resource_files}
+ )
+endif()
+
+qt_extend_target(tst_qqmllanguage CONDITION ANDROID OR IOS
+ DEFINES
+ QT_QMLTEST_DATADIR=\\\":/data\\\"
+)
+
+qt_extend_target(tst_qqmllanguage CONDITION NOT ANDROID AND NOT IOS
+ DEFINES
+ QT_QMLTEST_DATADIR=\\\"${CMAKE_CURRENT_SOURCE_DIR}/data\\\"
+)
+
+set_target_properties(tst_qqmllanguage PROPERTIES
+ QT_QML_MODULE_INSTALL_QMLTYPES TRUE
+ QT_QML_MODULE_VERSION 1.0
+ QT_QML_MODULE_URI StaticTest
+)
+
+qt6_qml_type_registration(tst_qqmllanguage)
diff --git a/tests/auto/qml/qqmllanguage/data/importVersionMissingBuiltIn.errors.txt b/tests/auto/qml/qqmllanguage/data/importVersionMissingBuiltIn.errors.txt
index c7d880e79e..e69de29bb2 100644
--- a/tests/auto/qml/qqmllanguage/data/importVersionMissingBuiltIn.errors.txt
+++ b/tests/auto/qml/qqmllanguage/data/importVersionMissingBuiltIn.errors.txt
@@ -1 +0,0 @@
-1:16:Library import requires a version
diff --git a/tests/auto/qml/qqmllanguage/data/importVersionMissingInstalled.errors.txt b/tests/auto/qml/qqmllanguage/data/importVersionMissingInstalled.errors.txt
index 59b0b87477..9900700753 100644
--- a/tests/auto/qml/qqmllanguage/data/importVersionMissingInstalled.errors.txt
+++ b/tests/auto/qml/qqmllanguage/data/importVersionMissingInstalled.errors.txt
@@ -1 +1 @@
-1:39:Library import requires a version
+1:1:module "org.qtproject.installedtest" is not installed
diff --git a/tests/auto/qml/qqmllanguage/testtypes.cpp b/tests/auto/qml/qqmllanguage/testtypes.cpp
index 31a4135d89..2c0e5f1d8c 100644
--- a/tests/auto/qml/qqmllanguage/testtypes.cpp
+++ b/tests/auto/qml/qqmllanguage/testtypes.cpp
@@ -149,7 +149,7 @@ void CustomBinding::componentComplete()
int bindingId = binding->value.compiledScriptIndex;
- QQmlContextData *context = QQmlContextData::get(qmlContext(this));
+ QQmlRefPointer<QQmlContextData> context = QQmlContextData::get(qmlContext(this));
QQmlProperty property(m_target, name, qmlContext(this));
QV4::Scope scope(qmlEngine(this)->handle());
diff --git a/tests/auto/qml/qqmllanguage/tst_qqmllanguage.cpp b/tests/auto/qml/qqmllanguage/tst_qqmllanguage.cpp
index 5665775258..8bee4ef260 100644
--- a/tests/auto/qml/qqmllanguage/tst_qqmllanguage.cpp
+++ b/tests/auto/qml/qqmllanguage/tst_qqmllanguage.cpp
@@ -326,6 +326,7 @@ private slots:
void listContainingDeletedObject();
void overrideSingleton();
+ void revisionedPropertyOfAttachedObjectProperty();
void arrayToContainer();
void qualifiedScopeInCustomParser();
@@ -4881,8 +4882,9 @@ static void beginDeferredOnce(QQmlEnginePrivate *enginePriv,
QQmlComponentPrivate::ConstructionState *state = new QQmlComponentPrivate::ConstructionState;
state->completePending = true;
- QQmlContextData *creationContext = nullptr;
- state->creator.reset(new QQmlObjectCreator(deferData->context->parent, deferData->compilationUnit, creationContext));
+ state->creator.reset(new QQmlObjectCreator(
+ deferData->context->parent(), deferData->compilationUnit,
+ QQmlRefPointer<QQmlContextData>()));
enginePriv->inProgressCreations++;
@@ -4914,7 +4916,7 @@ static void testExecuteDeferredOnce(const QQmlProperty &property)
QObject *object = property.object();
QQmlData *data = QQmlData::get(object);
if (data && !data->deferredData.isEmpty() && !data->wasDeleted(object)) {
- QQmlEnginePrivate *ep = QQmlEnginePrivate::get(data->context->engine);
+ QQmlEnginePrivate *ep = QQmlEnginePrivate::get(data->context->engine());
QQmlComponentPrivate::DeferredState state;
beginDeferredOnce(ep, property, &state);
@@ -5451,7 +5453,7 @@ void tst_qqmllanguage::selfReference()
const QMetaObject *metaObject = o->metaObject();
QMetaProperty selfProperty = metaObject->property(metaObject->indexOfProperty("self"));
- QCOMPARE(selfProperty.userType(), compilationUnit->metaTypeId);
+ QCOMPARE(selfProperty.userType(), compilationUnit->metaTypeId.id());
QByteArray typeName = selfProperty.typeName();
QVERIFY(typeName.endsWith('*'));
@@ -5460,7 +5462,7 @@ void tst_qqmllanguage::selfReference()
QMetaMethod selfFunction = metaObject->method(metaObject->indexOfMethod("returnSelf()"));
QVERIFY(selfFunction.isValid());
- QCOMPARE(selfFunction.returnType(), compilationUnit->metaTypeId);
+ QCOMPARE(selfFunction.returnType(), compilationUnit->metaTypeId.id());
QMetaMethod selfSignal;
@@ -5474,7 +5476,7 @@ void tst_qqmllanguage::selfReference()
QVERIFY(selfSignal.isValid());
QCOMPARE(selfSignal.parameterCount(), 1);
- QCOMPARE(selfSignal.parameterType(0), compilationUnit->metaTypeId);
+ QCOMPARE(selfSignal.parameterType(0), compilationUnit->metaTypeId.id());
}
void tst_qqmllanguage::selfReferencingSingleton()
@@ -5551,6 +5553,85 @@ void tst_qqmllanguage::overrideSingleton()
check("uncreatable", "UncreatableSingleton");
}
+class AttachedObject;
+class InnerObject : public QObject
+{
+ Q_OBJECT
+ Q_PROPERTY(bool revisionedProperty READ revisionedProperty WRITE setRevisionedProperty
+ NOTIFY revisionedPropertyChanged REVISION 2)
+
+public:
+ InnerObject(QObject *parent = nullptr) : QObject(parent) {}
+
+ bool revisionedProperty() const { return m_revisionedProperty; }
+ void setRevisionedProperty(bool revisionedProperty)
+ {
+ if (revisionedProperty != m_revisionedProperty) {
+ m_revisionedProperty = revisionedProperty;
+ emit revisionedPropertyChanged();
+ }
+ }
+
+ static AttachedObject *qmlAttachedProperties(QObject *object);
+
+signals:
+ Q_REVISION(2) void revisionedPropertyChanged();
+
+private:
+ bool m_revisionedProperty = false;
+};
+
+class AttachedObject : public QObject
+{
+ Q_OBJECT
+ Q_PROPERTY(InnerObject *attached READ attached CONSTANT)
+
+public:
+ explicit AttachedObject(QObject *parent = nullptr) :
+ QObject(parent),
+ m_attached(new InnerObject(this))
+ {}
+
+ InnerObject *attached() const { return m_attached; }
+
+private:
+ InnerObject *m_attached;
+};
+
+class OuterObject : public QObject
+{
+ Q_OBJECT
+public:
+ explicit OuterObject(QObject *parent = nullptr) : QObject(parent) {}
+};
+
+AttachedObject *InnerObject::qmlAttachedProperties(QObject *object)
+{
+ return new AttachedObject(object);
+}
+
+QML_DECLARE_TYPE(InnerObject)
+QML_DECLARE_TYPEINFO(InnerObject, QML_HAS_ATTACHED_PROPERTIES)
+
+void tst_qqmllanguage::revisionedPropertyOfAttachedObjectProperty()
+{
+ qmlRegisterAnonymousType<AttachedObject>("foo", 2);
+ qmlRegisterType<InnerObject>("foo", 2, 0, "InnerObject");
+ qmlRegisterType<InnerObject, 2>("foo", 2, 2, "InnerObject");
+ qmlRegisterType<OuterObject>("foo", 2, 2, "OuterObject");
+
+ QQmlEngine engine;
+ QQmlComponent component(&engine);
+ component.setData("import foo 2.2\n"
+ "OuterObject {\n"
+ " InnerObject.attached.revisionedProperty: true\n"
+ "}", QUrl());
+
+ QVERIFY(component.isReady());
+ QScopedPointer<QObject> obj(component.create());
+ QVERIFY(!obj.isNull());
+}
+
void tst_qqmllanguage::inlineComponent()
{
QFETCH(QUrl, componentUrl);