summaryrefslogtreecommitdiffstats
path: root/tests/auto/declarative/qdeclarativeecmascript
diff options
context:
space:
mode:
Diffstat (limited to 'tests/auto/declarative/qdeclarativeecmascript')
-rw-r--r--tests/auto/declarative/qdeclarativeecmascript/data/canAssignNullToQObject.1.qml9
-rw-r--r--tests/auto/declarative/qdeclarativeecmascript/data/canAssignNullToQObject.2.qml11
-rw-r--r--tests/auto/declarative/qdeclarativeecmascript/data/extensionObjectsPropertyOverride.qml7
-rw-r--r--tests/auto/declarative/qdeclarativeecmascript/testtypes.cpp10
-rw-r--r--tests/auto/declarative/qdeclarativeecmascript/testtypes.h25
-rw-r--r--tests/auto/declarative/qdeclarativeecmascript/tst_qdeclarativeecmascript.cpp41
6 files changed, 103 insertions, 0 deletions
diff --git a/tests/auto/declarative/qdeclarativeecmascript/data/canAssignNullToQObject.1.qml b/tests/auto/declarative/qdeclarativeecmascript/data/canAssignNullToQObject.1.qml
new file mode 100644
index 0000000..3fd9131
--- /dev/null
+++ b/tests/auto/declarative/qdeclarativeecmascript/data/canAssignNullToQObject.1.qml
@@ -0,0 +1,9 @@
+import Qt.test 1.0
+
+MyQmlObject {
+ property bool runTest: false
+
+ property variant a: MyQmlObject {}
+
+ objectProperty: (runTest == false)?a:null
+}
diff --git a/tests/auto/declarative/qdeclarativeecmascript/data/canAssignNullToQObject.2.qml b/tests/auto/declarative/qdeclarativeecmascript/data/canAssignNullToQObject.2.qml
new file mode 100644
index 0000000..19b0c42
--- /dev/null
+++ b/tests/auto/declarative/qdeclarativeecmascript/data/canAssignNullToQObject.2.qml
@@ -0,0 +1,11 @@
+import Qt.test 1.0
+import Qt 4.6
+
+MyQmlObject {
+ objectProperty: MyQmlObject {}
+
+ Component.onCompleted: {
+ objectProperty = null;
+ }
+}
+
diff --git a/tests/auto/declarative/qdeclarativeecmascript/data/extensionObjectsPropertyOverride.qml b/tests/auto/declarative/qdeclarativeecmascript/data/extensionObjectsPropertyOverride.qml
new file mode 100644
index 0000000..3c443cb
--- /dev/null
+++ b/tests/auto/declarative/qdeclarativeecmascript/data/extensionObjectsPropertyOverride.qml
@@ -0,0 +1,7 @@
+import Qt.test 1.0
+
+OverrideDefaultPropertyObject
+{
+ MyBaseExtendedObject {
+ }
+}
diff --git a/tests/auto/declarative/qdeclarativeecmascript/testtypes.cpp b/tests/auto/declarative/qdeclarativeecmascript/testtypes.cpp
index 0d07055..154ff4d 100644
--- a/tests/auto/declarative/qdeclarativeecmascript/testtypes.cpp
+++ b/tests/auto/declarative/qdeclarativeecmascript/testtypes.cpp
@@ -72,6 +72,14 @@ private:
int m_value;
};
+class DefaultPropertyExtensionObject : public QObject
+{
+ Q_OBJECT
+ Q_CLASSINFO("DefaultProperty", "firstProperty")
+public:
+ DefaultPropertyExtensionObject(QObject *parent) : QObject(parent) {}
+};
+
void registerTypes()
{
qmlRegisterType<MyQmlObject>("Qt.test", 1,0, "MyQmlObject");
@@ -81,6 +89,8 @@ void registerTypes()
qmlRegisterExtendedType<MyExtendedObject, ExtensionObject>("Qt.test", 1,0, "MyExtendedObject");
qmlRegisterType<MyTypeObject>("Qt.test", 1,0, "MyTypeObject");
qmlRegisterType<NumberAssignment>("Qt.test", 1,0, "NumberAssignment");
+ qmlRegisterExtendedType<DefaultPropertyExtendedObject, DefaultPropertyExtensionObject>("Qt.test", 1,0, "DefaultPropertyExtendedObject");
+ qmlRegisterType<OverrideDefaultPropertyObject>("Qt.test", 1,0, "OverrideDefaultPropertyObject");
}
#include "testtypes.moc"
diff --git a/tests/auto/declarative/qdeclarativeecmascript/testtypes.h b/tests/auto/declarative/qdeclarativeecmascript/testtypes.h
index 79d3226..1381d57 100644
--- a/tests/auto/declarative/qdeclarativeecmascript/testtypes.h
+++ b/tests/auto/declarative/qdeclarativeecmascript/testtypes.h
@@ -659,6 +659,31 @@ public:
void setTest12(unsigned int v) { _test12 = v; }
};
+class DefaultPropertyExtendedObject : public QObject
+{
+ Q_OBJECT
+ Q_PROPERTY(QObject *firstProperty READ firstProperty WRITE setFirstProperty)
+ Q_PROPERTY(QObject *secondProperty READ secondProperty WRITE setSecondProperty)
+public:
+ DefaultPropertyExtendedObject(QObject *parent = 0) : QObject(parent), m_firstProperty(0), m_secondProperty(0) {}
+
+ QObject *firstProperty() const { return m_firstProperty; }
+ QObject *secondProperty() const { return m_secondProperty; }
+ void setFirstProperty(QObject *property) { m_firstProperty = property; }
+ void setSecondProperty(QObject *property) { m_secondProperty = property; }
+private:
+ QObject* m_firstProperty;
+ QObject* m_secondProperty;
+};
+
+class OverrideDefaultPropertyObject : public DefaultPropertyExtendedObject
+{
+ Q_OBJECT
+ Q_CLASSINFO("DefaultProperty", "secondProperty")
+public:
+ OverrideDefaultPropertyObject() {}
+};
+
void registerTypes();
#endif // TESTTYPES_H
diff --git a/tests/auto/declarative/qdeclarativeecmascript/tst_qdeclarativeecmascript.cpp b/tests/auto/declarative/qdeclarativeecmascript/tst_qdeclarativeecmascript.cpp
index 33629b8..6939290 100644
--- a/tests/auto/declarative/qdeclarativeecmascript/tst_qdeclarativeecmascript.cpp
+++ b/tests/auto/declarative/qdeclarativeecmascript/tst_qdeclarativeecmascript.cpp
@@ -90,6 +90,7 @@ private slots:
void objectPropertiesTriggerReeval();
void deferredProperties();
void extensionObjects();
+ void overrideExtensionProperties();
void attachedProperties();
void enums();
void valueTypeFunctions();
@@ -140,6 +141,7 @@ private slots:
void variantsAssignedUndefined();
void qtbug_9792();
void noSpuriousWarningsAtShutdown();
+ void canAssignNullToQObject();
void callQtInvokables();
private:
@@ -565,6 +567,16 @@ void tst_qdeclarativeecmascript::extensionObjects()
}
+void tst_qdeclarativeecmascript::overrideExtensionProperties()
+{
+ QDeclarativeComponent component(&engine, TEST_FILE("extensionObjectsPropertyOverride.qml"));
+ OverrideDefaultPropertyObject *object =
+ qobject_cast<OverrideDefaultPropertyObject *>(component.create());
+ QVERIFY(object != 0);
+ QVERIFY(object->secondProperty() != 0);
+ QVERIFY(object->firstProperty() == 0);
+}
+
void tst_qdeclarativeecmascript::attachedProperties()
{
QDeclarativeComponent component(&engine, TEST_FILE("attachedProperty.qml"));
@@ -2179,6 +2191,35 @@ void tst_qdeclarativeecmascript::noSpuriousWarningsAtShutdown()
}
}
+void tst_qdeclarativeecmascript::canAssignNullToQObject()
+{
+ {
+ QDeclarativeComponent component(&engine, TEST_FILE("canAssignNullToQObject.1.qml"));
+
+ MyQmlObject *o = qobject_cast<MyQmlObject *>(component.create());
+ QVERIFY(o != 0);
+
+ QVERIFY(o->objectProperty() != 0);
+
+ o->setProperty("runTest", true);
+
+ QVERIFY(o->objectProperty() == 0);
+
+ delete o;
+ }
+
+ {
+ QDeclarativeComponent component(&engine, TEST_FILE("canAssignNullToQObject.2.qml"));
+
+ MyQmlObject *o = qobject_cast<MyQmlObject *>(component.create());
+ QVERIFY(o != 0);
+
+ QVERIFY(o->objectProperty() == 0);
+
+ delete o;
+ }
+}
+
QTEST_MAIN(tst_qdeclarativeecmascript)
#include "tst_qdeclarativeecmascript.moc"