diff options
author | Warwick Allison <warwick.allison@nokia.com> | 2010-04-08 05:24:13 (GMT) |
---|---|---|
committer | Warwick Allison <warwick.allison@nokia.com> | 2010-04-08 05:24:13 (GMT) |
commit | 23ca795df373ef41d2b3020c9ea7c38714aaa67b (patch) | |
tree | 78df8d232ae8604a883a181dd813613a37f1db0d /tests | |
parent | 9fd2d52881356fb214213f139a2f25081fc848e4 (diff) | |
download | Qt-23ca795df373ef41d2b3020c9ea7c38714aaa67b.zip Qt-23ca795df373ef41d2b3020c9ea7c38714aaa67b.tar.gz Qt-23ca795df373ef41d2b3020c9ea7c38714aaa67b.tar.bz2 |
Test readonly valuetypes. Fails for field.
Task-number: QTBUG-9685
Diffstat (limited to 'tests')
5 files changed, 51 insertions, 0 deletions
diff --git a/tests/auto/declarative/qdeclarativevaluetypes/data/sizereadonly_read.qml b/tests/auto/declarative/qdeclarativevaluetypes/data/sizereadonly_read.qml new file mode 100644 index 0000000..7abe359 --- /dev/null +++ b/tests/auto/declarative/qdeclarativevaluetypes/data/sizereadonly_read.qml @@ -0,0 +1,8 @@ +import Test 1.0 + +MyTypeObject { + property int s_width: sizereadonly.width + property int s_height: sizereadonly.height + property var copy: sizereadonly +} + diff --git a/tests/auto/declarative/qdeclarativevaluetypes/data/sizereadonly_writeerror.qml b/tests/auto/declarative/qdeclarativevaluetypes/data/sizereadonly_writeerror.qml new file mode 100644 index 0000000..3254557 --- /dev/null +++ b/tests/auto/declarative/qdeclarativevaluetypes/data/sizereadonly_writeerror.qml @@ -0,0 +1,6 @@ +import Test 1.0 + +MyTypeObject { + sizereadonly: "13x88" +} + diff --git a/tests/auto/declarative/qdeclarativevaluetypes/data/sizereadonly_writeerror2.qml b/tests/auto/declarative/qdeclarativevaluetypes/data/sizereadonly_writeerror2.qml new file mode 100644 index 0000000..656d718 --- /dev/null +++ b/tests/auto/declarative/qdeclarativevaluetypes/data/sizereadonly_writeerror2.qml @@ -0,0 +1,7 @@ +import Test 1.0 + +MyTypeObject { + sizereadonly.width: if (true) 13 + sizereadonly.height: if (true) 88 +} + diff --git a/tests/auto/declarative/qdeclarativevaluetypes/testtypes.h b/tests/auto/declarative/qdeclarativevaluetypes/testtypes.h index 64e4980..9057b4f 100644 --- a/tests/auto/declarative/qdeclarativevaluetypes/testtypes.h +++ b/tests/auto/declarative/qdeclarativevaluetypes/testtypes.h @@ -63,6 +63,7 @@ class MyTypeObject : public QObject Q_PROPERTY(QPointF pointf READ pointf WRITE setPointf NOTIFY changed) Q_PROPERTY(QSize size READ size WRITE setSize NOTIFY changed) Q_PROPERTY(QSizeF sizef READ sizef WRITE setSizef NOTIFY changed) + Q_PROPERTY(QSize sizereadonly READ size NOTIFY changed) Q_PROPERTY(QRect rect READ rect WRITE setRect NOTIFY changed) Q_PROPERTY(QRectF rectf READ rectf WRITE setRectf NOTIFY changed) Q_PROPERTY(QVector3D vector READ vector WRITE setVector NOTIFY changed) diff --git a/tests/auto/declarative/qdeclarativevaluetypes/tst_qdeclarativevaluetypes.cpp b/tests/auto/declarative/qdeclarativevaluetypes/tst_qdeclarativevaluetypes.cpp index fb487f0..c74199f 100644 --- a/tests/auto/declarative/qdeclarativevaluetypes/tst_qdeclarativevaluetypes.cpp +++ b/tests/auto/declarative/qdeclarativevaluetypes/tst_qdeclarativevaluetypes.cpp @@ -59,6 +59,7 @@ private slots: void pointf(); void size(); void sizef(); + void sizereadonly(); void rect(); void rectf(); void vector3d(); @@ -193,6 +194,34 @@ void tst_qdeclarativevaluetypes::sizef() } } +void tst_qdeclarativevaluetypes::sizereadonly() +{ + { + QDeclarativeComponent component(&engine, TEST_FILE("sizereadonly_read.qml")); + MyTypeObject *object = qobject_cast<MyTypeObject *>(component.create()); + QVERIFY(object != 0); + + QCOMPARE(object->property("s_width").toInt(), 1912); + QCOMPARE(object->property("s_height").toInt(), 1913); + QCOMPARE(object->property("copy"), QVariant(QSize(1912, 1913))); + + delete object; + } + + { + QDeclarativeComponent component(&engine, TEST_FILE("sizereadonly_writeerror.qml")); + QVERIFY(component.isError()); + QCOMPARE(component.errors().at(0).description(), QLatin1String("Invalid property assignment: \"sizereadonly\" is a read-only property")); + } + + { + QDeclarativeComponent component(&engine, TEST_FILE("sizereadonly_writeerror2.qml")); + QEXPECT_FAIL("", "QTBUG-9685", Abort); + QVERIFY(component.isError()); + QCOMPARE(component.errors().at(0).description(), QLatin1String("Invalid property assignment: \"sizereadonly\" is a read-only property")); + } +} + void tst_qdeclarativevaluetypes::rect() { { |