diff options
author | Michael Brasser <michael.brasser@live.com> | 2016-03-01 21:14:48 -0600 |
---|---|---|
committer | Michael Brasser <michael.brasser@live.com> | 2016-04-08 17:12:53 +0000 |
commit | 1148d3acead3c13072876b873fb4ee9440921943 (patch) | |
tree | 8ad210b89a316a72b1b4bac309b2ad20420d7afc /tests/auto/qml/qqmlbinding/tst_qqmlbinding.cpp | |
parent | 49fdb74757e5d9eb9333c10f1b756eed119bbb67 (diff) |
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 <robin.burchell@viroteck.net>
Diffstat (limited to 'tests/auto/qml/qqmlbinding/tst_qqmlbinding.cpp')
-rw-r--r-- | tests/auto/qml/qqmlbinding/tst_qqmlbinding.cpp | 22 |
1 files changed, 22 insertions, 0 deletions
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<QQuickItem*>(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" |