From 1148d3acead3c13072876b873fb4ee9440921943 Mon Sep 17 00:00:00 2001 From: Michael Brasser Date: Tue, 1 Mar 2016 21:14:48 -0600 Subject: Add delayed property to Binding. Provide a way to avoid potentially expensive or unexpected intermediate values. [ChangeLog][Binding] Add delayed property to Binding as a way to avoid potentially expensive or unexpected intermediate values. Change-Id: I6aaca570859cc1344eeb9c9f19f32660e8c0b4e0 Reviewed-by: Robin Burchell --- tests/auto/qml/qqmlbinding/tst_qqmlbinding.cpp | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) (limited to 'tests/auto/qml/qqmlbinding/tst_qqmlbinding.cpp') diff --git a/tests/auto/qml/qqmlbinding/tst_qqmlbinding.cpp b/tests/auto/qml/qqmlbinding/tst_qqmlbinding.cpp index 3e8dfbdb12..6f1d82eca5 100644 --- a/tests/auto/qml/qqmlbinding/tst_qqmlbinding.cpp +++ b/tests/auto/qml/qqmlbinding/tst_qqmlbinding.cpp @@ -49,6 +49,7 @@ private slots: void warningOnReadOnlyProperty(); void disabledOnUnknownProperty(); void disabledOnReadonlyProperty(); + void delayed(); private: QQmlEngine engine; @@ -281,6 +282,27 @@ void tst_qqmlbinding::disabledOnReadonlyProperty() QCOMPARE(messageHandler.messages().count(), 0); } +void tst_qqmlbinding::delayed() +{ + QQmlEngine engine; + QQmlComponent c(&engine, testFileUrl("delayed.qml")); + QQuickItem *item = qobject_cast(c.create()); + + QVERIFY(item != 0); + // update on creation + QCOMPARE(item->property("changeCount").toInt(), 1); + + QMetaObject::invokeMethod(item, "updateText"); + // doesn't update immediately + QCOMPARE(item->property("changeCount").toInt(), 1); + + QCoreApplication::processEvents(); + // only updates once (non-delayed would update twice) + QCOMPARE(item->property("changeCount").toInt(), 2); + + delete item; +} + QTEST_MAIN(tst_qqmlbinding) #include "tst_qqmlbinding.moc" -- cgit v1.2.3