diff options
author | Aaron Kennedy <aaron.kennedy@nokia.com> | 2011-01-27 03:49:12 (GMT) |
---|---|---|
committer | Aaron Kennedy <aaron.kennedy@nokia.com> | 2011-01-27 03:49:12 (GMT) |
commit | d9e4393ef212dba9eeba68277b270d68bcdbc733 (patch) | |
tree | d65ff0df673db66478b081d672f3fe383ae6e5a5 /tests/auto/declarative | |
parent | f15778e60ba538b8715f6433a472ffe08a21d934 (diff) | |
download | Qt-d9e4393ef212dba9eeba68277b270d68bcdbc733.zip Qt-d9e4393ef212dba9eeba68277b270d68bcdbc733.tar.gz Qt-d9e4393ef212dba9eeba68277b270d68bcdbc733.tar.bz2 |
Implement property versioning inside the declarative engine
Task-number: QTBUG-13451
Diffstat (limited to 'tests/auto/declarative')
14 files changed, 53 insertions, 57 deletions
diff --git a/tests/auto/declarative/qdeclarativeitem/tst_qdeclarativeitem.cpp b/tests/auto/declarative/qdeclarativeitem/tst_qdeclarativeitem.cpp index e636383..447b57b 100644 --- a/tests/auto/declarative/qdeclarativeitem/tst_qdeclarativeitem.cpp +++ b/tests/auto/declarative/qdeclarativeitem/tst_qdeclarativeitem.cpp @@ -979,19 +979,19 @@ void tst_QDeclarativeItem::testQtQuick11Attributes_data() QTest::newRow("implicitWidth") << "implicitWidth: 100" << "QDeclarativeComponent: Component is not ready" - << ":1 Property \"implicitWidth\" not available in QtQuick/Item 1.0\n"; + << ":1 \"Item.implicitWidth\" is not available in QtQuick 1.0.\n"; QTest::newRow("implicitHeight") << "implicitHeight: 100" << "QDeclarativeComponent: Component is not ready" - << ":1 Property \"implicitHeight\" not available in QtQuick/Item 1.0\n"; + << ":1 \"Item.implicitHeight\" is not available in QtQuick 1.0.\n"; QTest::newRow("onImplicitWidthChanged") << "onImplicitWidthChanged: x" << "QDeclarativeComponent: Component is not ready" - << ":1 Signal \"onImplicitWidthChanged\" not available in QtQuick/Item 1.0\n"; + << ":1 \"Item.onImplicitWidthChanged\" is not available in QtQuick 1.0.\n"; QTest::newRow("onImplicitHeightChanged") << "onImplicitHeightChanged: x" << "QDeclarativeComponent: Component is not ready" - << ":1 Signal \"onImplicitHeightChanged\" not available in QtQuick/Item 1.0\n"; + << ":1 \"Item.onImplicitHeightChanged\" is not available in QtQuick 1.0.\n"; } diff --git a/tests/auto/declarative/qdeclarativelanguage/data/allowedRevisionOverloads.qml b/tests/auto/declarative/qdeclarativelanguage/data/allowedRevisionOverloads.qml new file mode 100644 index 0000000..64acbd1 --- /dev/null +++ b/tests/auto/declarative/qdeclarativelanguage/data/allowedRevisionOverloads.qml @@ -0,0 +1,6 @@ +import Test 1.0 + +MyRevisionedLegalOverload +{ +} + diff --git a/tests/auto/declarative/qdeclarativelanguage/data/disallowedRevisionOverloads.errors.txt b/tests/auto/declarative/qdeclarativelanguage/data/disallowedRevisionOverloads.errors.txt new file mode 100644 index 0000000..e9b449d --- /dev/null +++ b/tests/auto/declarative/qdeclarativelanguage/data/disallowedRevisionOverloads.errors.txt @@ -0,0 +1 @@ +3:1:Type Test/MyRevisionedIllegalOverload 1.0 contains an illegal property "propA". This is an error in the type's implementation. diff --git a/tests/auto/declarative/qdeclarativelanguage/data/disallowedRevisionOverloads.qml b/tests/auto/declarative/qdeclarativelanguage/data/disallowedRevisionOverloads.qml new file mode 100644 index 0000000..612bcfe --- /dev/null +++ b/tests/auto/declarative/qdeclarativelanguage/data/disallowedRevisionOverloads.qml @@ -0,0 +1,7 @@ +import Test 1.0 + +MyRevisionedIllegalOverload +{ +} + + diff --git a/tests/auto/declarative/qdeclarativelanguage/data/metaobjectRevision.1.errors.txt b/tests/auto/declarative/qdeclarativelanguage/data/metaobjectRevision.1.errors.txt index 6ad6bfa..29342dc 100644 --- a/tests/auto/declarative/qdeclarativelanguage/data/metaobjectRevision.1.errors.txt +++ b/tests/auto/declarative/qdeclarativelanguage/data/metaobjectRevision.1.errors.txt @@ -1 +1 @@ -7:5:Property "prop2" not available in Test/MyRevisionedClass 1.0 +8:5:"MyRevisionedClass.prop2" is not available in Test 1.0. diff --git a/tests/auto/declarative/qdeclarativelanguage/data/metaobjectRevision.1.qml b/tests/auto/declarative/qdeclarativelanguage/data/metaobjectRevision.1.qml index 4662d5e..4b37ed3 100644 --- a/tests/auto/declarative/qdeclarativelanguage/data/metaobjectRevision.1.qml +++ b/tests/auto/declarative/qdeclarativelanguage/data/metaobjectRevision.1.qml @@ -1,3 +1,4 @@ +// Check that a property in a later revision (prop2) cannot be assigned import QtQuick 1.0 import Test 1.0 diff --git a/tests/auto/declarative/qdeclarativelanguage/data/metaobjectRevision.2.errors.txt b/tests/auto/declarative/qdeclarativelanguage/data/metaobjectRevision.2.errors.txt index 92ccd9a..57b5764 100644 --- a/tests/auto/declarative/qdeclarativelanguage/data/metaobjectRevision.2.errors.txt +++ b/tests/auto/declarative/qdeclarativelanguage/data/metaobjectRevision.2.errors.txt @@ -1 +1 @@ -6:5:Signal "onSignal2" not available in Test/MyRevisionedClass 1.0 +6:5:"MyRevisionedClass.onSignal2" is not available in Test 1.0. diff --git a/tests/auto/declarative/qdeclarativelanguage/data/metaobjectRevision.3.errors.txt b/tests/auto/declarative/qdeclarativelanguage/data/metaobjectRevision.3.errors.txt index b3c33c4..45364a0 100644 --- a/tests/auto/declarative/qdeclarativelanguage/data/metaobjectRevision.3.errors.txt +++ b/tests/auto/declarative/qdeclarativelanguage/data/metaobjectRevision.3.errors.txt @@ -1 +1 @@ -9:5:Property "propD" not available in Test/MyRevisionedClass 1.1 +9:5:"MyRevisionedClass.propD" is not available in Test 1.1. diff --git a/tests/auto/declarative/qdeclarativelanguage/data/revisions10.qml b/tests/auto/declarative/qdeclarativelanguage/data/revisions10.qml deleted file mode 100644 index c4974cf..0000000 --- a/tests/auto/declarative/qdeclarativelanguage/data/revisions10.qml +++ /dev/null @@ -1,8 +0,0 @@ -import QtQuick 1.0 -import Test 1.0 - -MyRevisionedClass -{ - property real prop2: 10 - prop1: 1 -} diff --git a/tests/auto/declarative/qdeclarativelanguage/data/revisionssub10.qml b/tests/auto/declarative/qdeclarativelanguage/data/revisionssub10.qml deleted file mode 100644 index b5de4a3..0000000 --- a/tests/auto/declarative/qdeclarativelanguage/data/revisionssub10.qml +++ /dev/null @@ -1,10 +0,0 @@ -import QtQuick 1.0 -import Test 1.0 - -MyRevisionedSubclass -{ - property real prop4: 10 - property real prop2: 10 - prop1: 5 - prop3: 7 -} diff --git a/tests/auto/declarative/qdeclarativelanguage/testtypes.cpp b/tests/auto/declarative/qdeclarativelanguage/testtypes.cpp index 5e91e95..69cba76 100644 --- a/tests/auto/declarative/qdeclarativelanguage/testtypes.cpp +++ b/tests/auto/declarative/qdeclarativelanguage/testtypes.cpp @@ -54,6 +54,8 @@ void registerTypes() qmlRegisterType<MyGroupedObject>(); qmlRegisterType<MyRevisionedClass>("Test",1,0,"MyRevisionedClass"); qmlRegisterType<MyRevisionedClass,1>("Test",1,1,"MyRevisionedClass"); + qmlRegisterType<MyRevisionedIllegalOverload>("Test",1,0,"MyRevisionedIllegalOverload"); + qmlRegisterType<MyRevisionedLegalOverload>("Test",1,0,"MyRevisionedLegalOverload"); // Register the uncreatable base class qmlRegisterRevision<MyRevisionedBaseClassRegistered,1>("Test",1,1); diff --git a/tests/auto/declarative/qdeclarativelanguage/testtypes.h b/tests/auto/declarative/qdeclarativelanguage/testtypes.h index 4f44f81..12424d0 100644 --- a/tests/auto/declarative/qdeclarativelanguage/testtypes.h +++ b/tests/auto/declarative/qdeclarativelanguage/testtypes.h @@ -640,6 +640,18 @@ protected: qreal m_pb; }; +class MyRevisionedIllegalOverload : public MyRevisionedBaseClassRegistered +{ + Q_OBJECT + Q_PROPERTY(qreal propA READ propA WRITE setPropA REVISION 1); +}; + +class MyRevisionedLegalOverload : public MyRevisionedBaseClassRegistered +{ + Q_OBJECT + Q_PROPERTY(qreal propB READ propB WRITE setPropB REVISION 1); +}; + class MyRevisionedBaseClassUnregistered : public MyRevisionedBaseClassRegistered { Q_OBJECT diff --git a/tests/auto/declarative/qdeclarativelanguage/tst_qdeclarativelanguage.cpp b/tests/auto/declarative/qdeclarativelanguage/tst_qdeclarativelanguage.cpp index 67b9d49..f3f41a9 100644 --- a/tests/auto/declarative/qdeclarativelanguage/tst_qdeclarativelanguage.cpp +++ b/tests/auto/declarative/qdeclarativelanguage/tst_qdeclarativelanguage.cpp @@ -154,6 +154,7 @@ private slots: void variantNotify(); void revisions(); + void revisionOverloads(); // regression tests for crashes void crash1(); @@ -1897,18 +1898,6 @@ void tst_qdeclarativelanguage::variantNotify() void tst_qdeclarativelanguage::revisions() { { - QDeclarativeComponent component(&engine, TEST_FILE("revisions10.qml")); - - VERIFY_ERRORS(0); - MyRevisionedClass *object = qobject_cast<MyRevisionedClass*>(component.create()); - QVERIFY(object != 0); - - QCOMPARE(object->prop2(), 2.0); - QCOMPARE(object->property("prop2").toReal(), 10.0); - - delete object; - } - { QDeclarativeComponent component(&engine, TEST_FILE("revisions11.qml")); VERIFY_ERRORS(0); @@ -1920,21 +1909,6 @@ void tst_qdeclarativelanguage::revisions() delete object; } { - QDeclarativeComponent component(&engine, TEST_FILE("revisionssub10.qml")); - - VERIFY_ERRORS(0); - MyRevisionedSubclass *object = qobject_cast<MyRevisionedSubclass*>(component.create()); - QVERIFY(object != 0); - - QCOMPARE(object->prop2(), 2.0); - QCOMPARE(object->property("prop2").toReal(), 10.0); - - QCOMPARE(object->prop4(), 4.0); - QCOMPARE(object->property("prop4").toReal(), 10.0); - - delete object; - } - { QDeclarativeEngine myEngine; QDeclarativeComponent component(&myEngine, TEST_FILE("revisionssub11.qml")); @@ -1950,10 +1924,7 @@ void tst_qdeclarativelanguage::revisions() delete object; } { - // If this is uncommented it will work - // qmlRegisterType<MySubclass,0>("Test",1,1,"MySubclass"); QDeclarativeComponent component(&engine, TEST_FILE("versionedbase.qml")); - QEXPECT_FAIL("", "Class version 1.0 with base class version 1.1 registered", Abort); VERIFY_ERRORS(0); MySubclass *object = qobject_cast<MySubclass*>(component.create()); QVERIFY(object != 0); @@ -1965,6 +1936,20 @@ void tst_qdeclarativelanguage::revisions() } } +void tst_qdeclarativelanguage::revisionOverloads() +{ + { + QDeclarativeComponent component(&engine, TEST_FILE("allowedRevisionOverloads.qml")); + VERIFY_ERRORS(0); + } + { + QDeclarativeComponent component(&engine, TEST_FILE("disallowedRevisionOverloads.qml")); + QEXPECT_FAIL("", "QTBUG-13849", Abort); + QVERIFY(0); + VERIFY_ERRORS("disallowedRevisionOverloads.errors.txt"); + } +} + void tst_qdeclarativelanguage::initTestCase() { registerTypes(); diff --git a/tests/auto/declarative/qdeclarativerepeater/tst_qdeclarativerepeater.cpp b/tests/auto/declarative/qdeclarativerepeater/tst_qdeclarativerepeater.cpp index d94ebbe..6b840a3 100644 --- a/tests/auto/declarative/qdeclarativerepeater/tst_qdeclarativerepeater.cpp +++ b/tests/auto/declarative/qdeclarativerepeater/tst_qdeclarativerepeater.cpp @@ -633,11 +633,11 @@ void tst_QDeclarativeRepeater::testQtQuick11Attributes_data() QTest::newRow("itemAdded") << "onItemAdded: count" << "QDeclarativeComponent: Component is not ready" - << ":1 Signal \"onItemAdded\" not available in QtQuick/Repeater 1.0\n"; + << ":1 \"Repeater.onItemAdded\" is not available in QtQuick 1.0.\n"; QTest::newRow("itemRemoved") << "onItemRemoved: count" << "QDeclarativeComponent: Component is not ready" - << ":1 Signal \"onItemRemoved\" not available in QtQuick/Repeater 1.0\n"; + << ":1 \"Repeater.onItemRemoved\" is not available in QtQuick 1.0.\n"; QTest::newRow("itemAt") << "Component.onCompleted: itemAt(0)" << "<Unknown File>:1: ReferenceError: Can't find variable: itemAt" |