From 7ca750fad4e74929c9c34a98c19bde37747a9dc5 Mon Sep 17 00:00:00 2001 From: Martin Jones Date: Tue, 11 Jan 2011 10:55:14 +1000 Subject: Add versioning for new Flickable methods. Task-number: QTBUG-15148 --- .../graphicsitems/qdeclarativeflickable_p.h | 5 +-- .../graphicsitems/qdeclarativeitemsmodule.cpp | 1 + .../tst_qdeclarativeflickable.cpp | 43 ++++++++++++++++++++++ 3 files changed, 46 insertions(+), 3 deletions(-) diff --git a/src/declarative/graphicsitems/qdeclarativeflickable_p.h b/src/declarative/graphicsitems/qdeclarativeflickable_p.h index ece2db7..4d3da92 100644 --- a/src/declarative/graphicsitems/qdeclarativeflickable_p.h +++ b/src/declarative/graphicsitems/qdeclarativeflickable_p.h @@ -149,9 +149,8 @@ public: FlickableDirection flickableDirection() const; void setFlickableDirection(FlickableDirection); - //XXX Added in QtQuick 1.1 - Q_INVOKABLE void resizeContent(qreal w, qreal h, QPointF center); - Q_INVOKABLE void returnToBounds(); + Q_INVOKABLE Q_REVISION(1) void resizeContent(qreal w, qreal h, QPointF center); + Q_INVOKABLE Q_REVISION(1) void returnToBounds(); Q_SIGNALS: void contentWidthChanged(); diff --git a/src/declarative/graphicsitems/qdeclarativeitemsmodule.cpp b/src/declarative/graphicsitems/qdeclarativeitemsmodule.cpp index 0d386c6..ddbde0b 100644 --- a/src/declarative/graphicsitems/qdeclarativeitemsmodule.cpp +++ b/src/declarative/graphicsitems/qdeclarativeitemsmodule.cpp @@ -179,6 +179,7 @@ void QDeclarativeItemModule::defineModule() qmlRegisterType("QtQuick",1,1,"PinchArea"); qmlRegisterType("QtQuick",1,1,"Pinch"); qmlRegisterType(); + qmlRegisterType("QtQuick",1,1,"Flickable"); qmlRegisterType("QtQuick",1,1,"Repeater"); qmlRegisterType("QtQuick",1,1,"TextEdit"); #ifndef QT_NO_LINEEDIT diff --git a/tests/auto/declarative/qdeclarativeflickable/tst_qdeclarativeflickable.cpp b/tests/auto/declarative/qdeclarativeflickable/tst_qdeclarativeflickable.cpp index c1564bc..10ab467 100644 --- a/tests/auto/declarative/qdeclarativeflickable/tst_qdeclarativeflickable.cpp +++ b/tests/auto/declarative/qdeclarativeflickable/tst_qdeclarativeflickable.cpp @@ -72,6 +72,8 @@ private slots: void qgraphicswidget(); void resizeContent(); void returnToBounds(); + void testQtQuick11Attributes(); + void testQtQuick11Attributes_data(); private: QDeclarativeEngine engine; @@ -331,6 +333,47 @@ void tst_qdeclarativeflickable::returnToBounds() delete root; } +void tst_qdeclarativeflickable::testQtQuick11Attributes() +{ + QFETCH(QString, code); + QFETCH(QString, warning); + QFETCH(QString, error); + + QDeclarativeEngine engine; + QObject *obj; + + QDeclarativeComponent invalid(&engine); + invalid.setData("import QtQuick 1.0; Flickable { " + code.toUtf8() + " }", QUrl("")); + QTest::ignoreMessage(QtWarningMsg, warning.toUtf8()); + obj = invalid.create(); + QCOMPARE(invalid.errorString(), error); + delete obj; + + QDeclarativeComponent valid(&engine); + valid.setData("import QtQuick 1.1; Flickable { " + code.toUtf8() + " }", QUrl("")); + obj = valid.create(); + QVERIFY(obj); + QVERIFY(valid.errorString().isEmpty()); + delete obj; +} + +void tst_qdeclarativeflickable::testQtQuick11Attributes_data() +{ + QTest::addColumn("code"); + QTest::addColumn("warning"); + QTest::addColumn("error"); + + QTest::newRow("resizeContent") << "Component.onCompleted: resizeContent(100,100,Qt.point(50,50))" + << ":1: ReferenceError: Can't find variable: resizeContent" + << ""; + + QTest::newRow("returnToBounds") << "Component.onCompleted: returnToBounds()" + << ":1: ReferenceError: Can't find variable: returnToBounds" + << ""; + +} + + template T *tst_qdeclarativeflickable::findItem(QGraphicsObject *parent, const QString &objectName) { -- cgit v0.12