aboutsummaryrefslogtreecommitdiffstats
path: root/tests/auto/declarative/qdeclarativeecmascript
diff options
context:
space:
mode:
authorAaron Kennedy <aaron.kennedy@nokia.com>2011-10-26 15:04:58 +0100
committerQt by Nokia <qt-info@nokia.com>2011-10-26 18:38:40 +0200
commitb79ceabb43427ba73fb0d64bd24f46c44e6a9d8d (patch)
treec15e0907029d996cbee83735c3e5bd382ee2a6f9 /tests/auto/declarative/qdeclarativeecmascript
parenta927dc97844fd23e295387f8174367f3f4be2977 (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/qdeclarativeecmascript')
-rw-r--r--tests/auto/declarative/qdeclarativeecmascript/data/readonlyDeclaration.qml45
-rw-r--r--tests/auto/declarative/qdeclarativeecmascript/tst_qdeclarativeecmascript.cpp14
2 files changed, 58 insertions, 1 deletions
diff --git a/tests/auto/declarative/qdeclarativeecmascript/data/readonlyDeclaration.qml b/tests/auto/declarative/qdeclarativeecmascript/data/readonlyDeclaration.qml
new file mode 100644
index 0000000000..5377d2dcbf
--- /dev/null
+++ b/tests/auto/declarative/qdeclarativeecmascript/data/readonlyDeclaration.qml
@@ -0,0 +1,45 @@
+import QtQuick 2.0
+
+QtObject {
+ property int dummy: 13
+
+ readonly property int test1: 19
+ readonly property int test2: dummy * 49
+ readonly property alias test3: other.test
+
+ property bool test: false
+
+ property var dummyObj: QtObject {
+ id: other
+ property int test: 9
+ }
+
+ Component.onCompleted: {
+ if (test1 != 19) return;
+ if (test2 != 637) return;
+ if (test3 != 9) return;
+
+ var caught = false;
+
+ caught = false;
+ try { test1 = 13 } catch (e) { caught = true; }
+ if (!caught) return;
+
+ caught = false;
+ try { test2 = 13 } catch (e) { caught = true; }
+ if (!caught) return;
+
+ caught = false;
+ try { test3 = 13 } catch (e) { caught = true; }
+ if (!caught) return;
+
+ other.test = 13;
+ dummy = 9;
+
+ if (test1 != 19) return;
+ if (test2 != 441) return;
+ if (test3 != 13) return;
+
+ test = true;
+ }
+}
diff --git a/tests/auto/declarative/qdeclarativeecmascript/tst_qdeclarativeecmascript.cpp b/tests/auto/declarative/qdeclarativeecmascript/tst_qdeclarativeecmascript.cpp
index 31aefd264e..c92dc809e9 100644
--- a/tests/auto/declarative/qdeclarativeecmascript/tst_qdeclarativeecmascript.cpp
+++ b/tests/auto/declarative/qdeclarativeecmascript/tst_qdeclarativeecmascript.cpp
@@ -169,7 +169,7 @@ private slots:
void booleanConversion();
void handleReferenceManagement();
void stringArg();
-
+ void readonlyDeclaration();
void bug1();
void bug2();
void dynamicCreationCrash();
@@ -4036,6 +4036,18 @@ void tst_qdeclarativeecmascript::stringArg()
delete object;
}
+void tst_qdeclarativeecmascript::readonlyDeclaration()
+{
+ QDeclarativeComponent component(&engine, TEST_FILE("readonlyDeclaration.qml"));
+
+ QObject *object = component.create();
+ QVERIFY(object != 0);
+
+ QCOMPARE(object->property("test").toBool(), true);
+
+ delete object;
+}
+
// Test that assigning a null object works
// Regressed with: df1788b4dbbb2826ae63f26bdf166342595343f4
void tst_qdeclarativeecmascript::nullObjectBinding()