diff options
author | Aaron Kennedy <aaron.kennedy@nokia.com> | 2011-10-26 15:04:58 +0100 |
---|---|---|
committer | Qt by Nokia <qt-info@nokia.com> | 2011-10-26 18:38:40 +0200 |
commit | b79ceabb43427ba73fb0d64bd24f46c44e6a9d8d (patch) | |
tree | c15e0907029d996cbee83735c3e5bd382ee2a6f9 /tests/auto/declarative/qdeclarativelanguage | |
parent | a927dc97844fd23e295387f8174367f3f4be2977 (diff) |
Readonly QML property support
Task-number: QTBUG-15257
Change-Id: I539b6e6a9e0e0172b68e8002aaa3f7c7e6648769
Reviewed-by: Aaron Kennedy <aaron.kennedy@nokia.com>
Diffstat (limited to 'tests/auto/declarative/qdeclarativelanguage')
7 files changed, 60 insertions, 12 deletions
diff --git a/tests/auto/declarative/qdeclarativelanguage/data/ReadOnlyType.qml b/tests/auto/declarative/qdeclarativelanguage/data/ReadOnlyType.qml new file mode 100644 index 0000000000..456ac762fc --- /dev/null +++ b/tests/auto/declarative/qdeclarativelanguage/data/ReadOnlyType.qml @@ -0,0 +1,5 @@ +import QtQuick 2.0 + +QtObject { + readonly property int readOnlyProperty: 19 +} diff --git a/tests/auto/declarative/qdeclarativelanguage/data/property.5.errors.txt b/tests/auto/declarative/qdeclarativelanguage/data/property.5.errors.txt deleted file mode 100644 index 32a8dc11e1..0000000000 --- a/tests/auto/declarative/qdeclarativelanguage/data/property.5.errors.txt +++ /dev/null @@ -1 +0,0 @@ -4:5:Readonly not yet supported diff --git a/tests/auto/declarative/qdeclarativelanguage/data/property.5.qml b/tests/auto/declarative/qdeclarativelanguage/data/property.5.qml deleted file mode 100644 index a1401d2fdc..0000000000 --- a/tests/auto/declarative/qdeclarativelanguage/data/property.5.qml +++ /dev/null @@ -1,6 +0,0 @@ -import QtQuick 2.0 - -QtObject { - readonly property int a: value -} - diff --git a/tests/auto/declarative/qdeclarativelanguage/data/readOnly.5.errors.txt b/tests/auto/declarative/qdeclarativelanguage/data/readOnly.5.errors.txt index baf47667bc..e71ae4447c 100644 --- a/tests/auto/declarative/qdeclarativelanguage/data/readOnly.5.errors.txt +++ b/tests/auto/declarative/qdeclarativelanguage/data/readOnly.5.errors.txt @@ -1 +1 @@ -3:27:Invalid property assignment: "readOnlyEnumProperty" is a read-only property +2:23:Invalid property assignment: "readOnlyProperty" is a read-only property diff --git a/tests/auto/declarative/qdeclarativelanguage/data/readOnly.5.qml b/tests/auto/declarative/qdeclarativelanguage/data/readOnly.5.qml index 422d13d8d0..d80b27a1e3 100644 --- a/tests/auto/declarative/qdeclarativelanguage/data/readOnly.5.qml +++ b/tests/auto/declarative/qdeclarativelanguage/data/readOnly.5.qml @@ -1,4 +1,3 @@ -import Test 1.0 -MyTypeObject { - readOnlyEnumProperty: MyTypeObject.EnumValue1 +ReadOnlyType { + readOnlyProperty: 13 } diff --git a/tests/auto/declarative/qdeclarativelanguage/data/readonly.qml b/tests/auto/declarative/qdeclarativelanguage/data/readonly.qml new file mode 100644 index 0000000000..493a9ad502 --- /dev/null +++ b/tests/auto/declarative/qdeclarativelanguage/data/readonly.qml @@ -0,0 +1,17 @@ +import Test 1.0 + +MyQmlObject { + property int testData: 9 + property alias testData2: myObject.test1 + + readonly property int test1: 10 + readonly property int test2: testData + 9 + readonly property alias test3: myObject.test1 + + + property variant dummy: MyQmlObject { + id: myObject + property int test1: 13 + } +} + diff --git a/tests/auto/declarative/qdeclarativelanguage/tst_qdeclarativelanguage.cpp b/tests/auto/declarative/qdeclarativelanguage/tst_qdeclarativelanguage.cpp index 538ebbb1a3..64ab5d8d39 100644 --- a/tests/auto/declarative/qdeclarativelanguage/tst_qdeclarativelanguage.cpp +++ b/tests/auto/declarative/qdeclarativelanguage/tst_qdeclarativelanguage.cpp @@ -156,6 +156,7 @@ private slots: void inlineAssignmentsOverrideBindings(); void nestedComponentRoots(); void registrationOrder(); + void readonly(); void basicRemote_data(); void basicRemote(); @@ -364,7 +365,6 @@ void tst_qdeclarativelanguage::errors_data() QTest::newRow("property.2") << "property.2.qml" << "property.2.errors.txt" << false; QTest::newRow("property.3") << "property.3.qml" << "property.3.errors.txt" << false; QTest::newRow("property.4") << "property.4.qml" << "property.4.errors.txt" << false; - QTest::newRow("property.5") << "property.5.qml" << "property.5.errors.txt" << false; QTest::newRow("property.6") << "property.6.qml" << "property.6.errors.txt" << false; QTest::newRow("property.7") << "property.7.qml" << "property.7.errors.txt" << false; @@ -2142,6 +2142,40 @@ void tst_qdeclarativelanguage::registrationOrder() delete o; } +void tst_qdeclarativelanguage::readonly() +{ + QDeclarativeComponent component(&engine, TEST_FILE("readonly.qml")); + + QObject *o = component.create(); + QVERIFY(o != 0); + + QCOMPARE(o->property("test1").toInt(), 10); + QCOMPARE(o->property("test2").toInt(), 18); + QCOMPARE(o->property("test3").toInt(), 13); + + o->setProperty("testData", 13); + + QCOMPARE(o->property("test1").toInt(), 10); + QCOMPARE(o->property("test2").toInt(), 22); + QCOMPARE(o->property("test3").toInt(), 13); + + o->setProperty("testData2", 2); + + QCOMPARE(o->property("test1").toInt(), 10); + QCOMPARE(o->property("test2").toInt(), 22); + QCOMPARE(o->property("test3").toInt(), 2); + + o->setProperty("test1", 11); + o->setProperty("test2", 11); + o->setProperty("test3", 11); + + QCOMPARE(o->property("test1").toInt(), 10); + QCOMPARE(o->property("test2").toInt(), 22); + QCOMPARE(o->property("test3").toInt(), 2); + + delete o; +} + // QTBUG-18268 void tst_qdeclarativelanguage::remoteLoadCrash() { |