summaryrefslogtreecommitdiffstats
path: root/tests/auto/declarative/qdeclarativelanguage
diff options
context:
space:
mode:
authorWarwick Allison <warwick.allison@nokia.com>2010-02-24 05:29:32 (GMT)
committerWarwick Allison <warwick.allison@nokia.com>2010-02-24 05:29:32 (GMT)
commit40256d682e1a552c9566a744a66cc6fe008b578b (patch)
treefde8c15bc9a8622daf240638b351c1960ddf0591 /tests/auto/declarative/qdeclarativelanguage
parent0f93f08d1d2dd8cbaaf80d13244c1b655f122357 (diff)
parent8848b63187cf1b073891bdd6998273a8869bb033 (diff)
downloadQt-40256d682e1a552c9566a744a66cc6fe008b578b.zip
Qt-40256d682e1a552c9566a744a66cc6fe008b578b.tar.gz
Qt-40256d682e1a552c9566a744a66cc6fe008b578b.tar.bz2
Merge branch 'master' of scm.dev.nokia.troll.no:qt/qt-qml
Diffstat (limited to 'tests/auto/declarative/qdeclarativelanguage')
-rw-r--r--tests/auto/declarative/qdeclarativelanguage/data/autoNotifyConnection.qml6
-rw-r--r--tests/auto/declarative/qdeclarativelanguage/testtypes.h6
-rw-r--r--tests/auto/declarative/qdeclarativelanguage/tst_qdeclarativelanguage.cpp17
3 files changed, 29 insertions, 0 deletions
diff --git a/tests/auto/declarative/qdeclarativelanguage/data/autoNotifyConnection.qml b/tests/auto/declarative/qdeclarativelanguage/data/autoNotifyConnection.qml
new file mode 100644
index 0000000..640fb54
--- /dev/null
+++ b/tests/auto/declarative/qdeclarativelanguage/data/autoNotifyConnection.qml
@@ -0,0 +1,6 @@
+import Test 1.0
+MyQmlObject {
+ property bool receivedNotify : false
+ onPropertyWithNotifyChanged: { receivedNotify = true; }
+}
+
diff --git a/tests/auto/declarative/qdeclarativelanguage/testtypes.h b/tests/auto/declarative/qdeclarativelanguage/testtypes.h
index 2c06416..1a8bd11 100644
--- a/tests/auto/declarative/qdeclarativelanguage/testtypes.h
+++ b/tests/auto/declarative/qdeclarativelanguage/testtypes.h
@@ -102,6 +102,7 @@ class MyQmlObject : public QObject, public MyInterface, public QDeclarativeParse
Q_PROPERTY(int onLiteralSignal READ onLiteralSignal WRITE setOnLiteralSignal);
Q_PROPERTY(MyCustomVariantType customType READ customType WRITE setCustomType);
Q_PROPERTY(MyQmlObject *qmlobjectProperty READ qmlobject WRITE setQmlobject)
+ Q_PROPERTY(int propertyWithNotify READ propertyWithNotify WRITE setPropertyWithNotify NOTIFY oddlyNamedNotifySignal)
Q_INTERFACES(MyInterface QDeclarativeParserStatus)
public:
@@ -137,6 +138,9 @@ public:
MyCustomVariantType customType() const { return m_custom; }
void setCustomType(const MyCustomVariantType &v) { m_custom = v; }
+
+ int propertyWithNotify() const { return m_propertyWithNotify; }
+ void setPropertyWithNotify(int i) { m_propertyWithNotify = i; emit oddlyNamedNotifySignal(); }
public slots:
void basicSlot() { qWarning("MyQmlObject::basicSlot"); }
void basicSlotWithArgs(int v) { qWarning("MyQmlObject::basicSlotWithArgs(%d)", v); }
@@ -144,6 +148,7 @@ public slots:
signals:
void basicSignal();
void basicParameterizedSignal(int parameter);
+ void oddlyNamedNotifySignal();
private:
friend class tst_qdeclarativelanguage;
@@ -151,6 +156,7 @@ private:
MyInterface *m_interface;
MyQmlObject *m_qmlobject;
MyCustomVariantType m_custom;
+ int m_propertyWithNotify;
};
QML_DECLARE_TYPEINFO(MyQmlObject, QML_HAS_ATTACHED_PROPERTIES)
QML_DECLARE_TYPE(MyQmlObject);
diff --git a/tests/auto/declarative/qdeclarativelanguage/tst_qdeclarativelanguage.cpp b/tests/auto/declarative/qdeclarativelanguage/tst_qdeclarativelanguage.cpp
index d6b5f0c..9d68ba9 100644
--- a/tests/auto/declarative/qdeclarativelanguage/tst_qdeclarativelanguage.cpp
+++ b/tests/auto/declarative/qdeclarativelanguage/tst_qdeclarativelanguage.cpp
@@ -88,6 +88,7 @@ private slots:
void rootAsQmlComponent();
void inlineQmlComponents();
void idProperty();
+ void autoNotifyConnection();
void assignSignal();
void dynamicProperties();
void dynamicPropertiesNested();
@@ -511,6 +512,22 @@ void tst_qdeclarativelanguage::idProperty()
QCOMPARE(object->property("object"), QVariant::fromValue((QObject *)child));
}
+// Tests automatic connection to notify signals if "onBlahChanged" syntax is used
+// even if the notify signal for "blah" is not called "blahChanged"
+void tst_qdeclarativelanguage::autoNotifyConnection()
+{
+ QDeclarativeComponent component(&engine, TEST_FILE("autoNotifyConnection.qml"));
+ VERIFY_ERRORS(0);
+ MyQmlObject *object = qobject_cast<MyQmlObject *>(component.create());
+ QVERIFY(object != 0);
+ QMetaProperty prop = object->metaObject()->property(object->metaObject()->indexOfProperty("receivedNotify"));
+ QVERIFY(prop.isValid());
+
+ QCOMPARE(prop.read(object), QVariant::fromValue(false));
+ object->setPropertyWithNotify(1);
+ QCOMPARE(prop.read(object), QVariant::fromValue(true));
+}
+
// Tests that signals can be assigned to
void tst_qdeclarativelanguage::assignSignal()
{