aboutsummaryrefslogtreecommitdiffstats
path: root/tests/auto/qml/qqmlconnections/tst_qqmlconnections.cpp
diff options
context:
space:
mode:
authorDan Cape <dcape@qnx.com>2015-08-25 13:34:43 -0400
committerDan Cape <dcape@qnx.com>2015-09-09 12:52:05 +0000
commit49c359dd88f962ec04cc7ede8cfa4ae2173e55f7 (patch)
treec7f5570b55c4885af3cf3c774624b705acaa7ec2 /tests/auto/qml/qqmlconnections/tst_qqmlconnections.cpp
parent68607aeeeb6ba84b843a0e3d848a5438a36f55a7 (diff)
Add enabled property to the QML Connections element
Now allows a quick way to enable/disable the signal handlers in the QML Connections element. Updated test file to have objectName and added test for this new functionality. Set to be available as of QtQml2.3. [ChangeLog][QML Elements] Allow enabling/disabling of connections established using a Connections element Change-Id: Ib0de2b3c78bb529ef74d5b4bb4ccb0f335cc50de Task-number: QTBUG-36350 Reviewed-by: Michael Brasser <michael.brasser@live.com>
Diffstat (limited to 'tests/auto/qml/qqmlconnections/tst_qqmlconnections.cpp')
-rw-r--r--tests/auto/qml/qqmlconnections/tst_qqmlconnections.cpp28
1 files changed, 28 insertions, 0 deletions
diff --git a/tests/auto/qml/qqmlconnections/tst_qqmlconnections.cpp b/tests/auto/qml/qqmlconnections/tst_qqmlconnections.cpp
index e529c74acc..b148baab35 100644
--- a/tests/auto/qml/qqmlconnections/tst_qqmlconnections.cpp
+++ b/tests/auto/qml/qqmlconnections/tst_qqmlconnections.cpp
@@ -56,6 +56,7 @@ private slots:
void errors();
void rewriteErrors();
void singletonTypeTarget();
+ void enableDisable_QTBUG_36350();
private:
QQmlEngine engine;
@@ -329,6 +330,33 @@ void tst_qqmlconnections::singletonTypeTarget()
delete object;
}
+void tst_qqmlconnections::enableDisable_QTBUG_36350()
+{
+ QQmlEngine engine;
+ QQmlComponent c(&engine, testFileUrl("test-connection.qml"));
+ QQuickItem *item = qobject_cast<QQuickItem*>(c.create());
+ QVERIFY(item != 0);
+
+ QQmlConnections *connections = item->findChild<QQmlConnections*>("connections");
+ QVERIFY(connections);
+
+ connections->setEnabled(false);
+ QCOMPARE(item->property("tested").toBool(), false);
+ QCOMPARE(item->width(), 50.);
+ emit item->setWidth(100.);
+ QCOMPARE(item->width(), 100.);
+ QCOMPARE(item->property("tested").toBool(), false); //Should not have received signal to change property
+
+ connections->setEnabled(true); //Re-enable the connectSignals()
+ QCOMPARE(item->property("tested").toBool(), false);
+ QCOMPARE(item->width(), 100.);
+ emit item->setWidth(50.);
+ QCOMPARE(item->width(), 50.);
+ QCOMPARE(item->property("tested").toBool(), true); //Should have received signal to change property
+
+ delete item;
+}
+
QTEST_MAIN(tst_qqmlconnections)
#include "tst_qqmlconnections.moc"