diff options
author | Liang Qi <liang.qi@theqtcompany.com> | 2015-09-25 20:56:51 +0200 |
---|---|---|
committer | Liang Qi <liang.qi@theqtcompany.com> | 2015-09-25 20:56:51 +0200 |
commit | f9ef039ad955db67dc3ab6e9056afc4a325aa9a3 (patch) | |
tree | 4928ff85fb630639e306ea4eb7137a2064a80c8b /tests/auto/qml/qqmlbinding | |
parent | 0238c739f81911f0963cf2c40b27dcfc8e3d38b7 (diff) | |
parent | 52fb4685e95e5b44e54d2d0f8ea27dea866c75e9 (diff) |
Merge remote-tracking branch 'origin/5.6' into dev
Conflicts:
src/qml/debugger/qqmldebug.cpp
Change-Id: I93de5a81b18cdece475870cf7cfba1b9baef2304
Diffstat (limited to 'tests/auto/qml/qqmlbinding')
-rw-r--r-- | tests/auto/qml/qqmlbinding/data/readonlyProperty.qml | 13 | ||||
-rw-r--r-- | tests/auto/qml/qqmlbinding/data/unknownProperty.qml | 11 | ||||
-rw-r--r-- | tests/auto/qml/qqmlbinding/tst_qqmlbinding.cpp | 34 |
3 files changed, 58 insertions, 0 deletions
diff --git a/tests/auto/qml/qqmlbinding/data/readonlyProperty.qml b/tests/auto/qml/qqmlbinding/data/readonlyProperty.qml new file mode 100644 index 0000000000..fa8d93d355 --- /dev/null +++ b/tests/auto/qml/qqmlbinding/data/readonlyProperty.qml @@ -0,0 +1,13 @@ +import QtQuick 2.0 + +Item { + id: root + + readonly property string name: "John" + + Binding { + target: root + property: "name" + value: "Doe" + } +} diff --git a/tests/auto/qml/qqmlbinding/data/unknownProperty.qml b/tests/auto/qml/qqmlbinding/data/unknownProperty.qml new file mode 100644 index 0000000000..36157bb4e7 --- /dev/null +++ b/tests/auto/qml/qqmlbinding/data/unknownProperty.qml @@ -0,0 +1,11 @@ +import QtQuick 2.0 + +Item { + id: root + + Binding { + target: root + property: "unknown" + value: 42 + } +} diff --git a/tests/auto/qml/qqmlbinding/tst_qqmlbinding.cpp b/tests/auto/qml/qqmlbinding/tst_qqmlbinding.cpp index 2d267cc668..3e49f3b3c4 100644 --- a/tests/auto/qml/qqmlbinding/tst_qqmlbinding.cpp +++ b/tests/auto/qml/qqmlbinding/tst_qqmlbinding.cpp @@ -50,6 +50,8 @@ private slots: void restoreBindingWithLoop(); void restoreBindingWithoutCrash(); void deletedObject(); + void warningOnUnknownProperty(); + void warningOnReadOnlyProperty(); private: QQmlEngine engine; @@ -224,6 +226,38 @@ void tst_qqmlbinding::deletedObject() delete rect; } +void tst_qqmlbinding::warningOnUnknownProperty() +{ + QQmlTestMessageHandler messageHandler; + + QQmlEngine engine; + QQmlComponent c(&engine, testFileUrl("unknownProperty.qml")); + QQuickItem *item = qobject_cast<QQuickItem*>(c.create()); + QVERIFY(item); + delete item; + + QCOMPARE(messageHandler.messages().count(), 1); + + const QString expectedMessage = c.url().toString() + QLatin1String(":6:5: QML Binding: Property 'unknown' does not exist on Item."); + QCOMPARE(messageHandler.messages().first(), expectedMessage); +} + +void tst_qqmlbinding::warningOnReadOnlyProperty() +{ + QQmlTestMessageHandler messageHandler; + + QQmlEngine engine; + QQmlComponent c(&engine, testFileUrl("readonlyProperty.qml")); + QQuickItem *item = qobject_cast<QQuickItem*>(c.create()); + QVERIFY(item); + delete item; + + QCOMPARE(messageHandler.messages().count(), 1); + + const QString expectedMessage = c.url().toString() + QLatin1String(":8:5: QML Binding: Property 'name' on Item is read-only."); + QCOMPARE(messageHandler.messages().first(), expectedMessage); +} + QTEST_MAIN(tst_qqmlbinding) #include "tst_qqmlbinding.moc" |