summaryrefslogtreecommitdiffstats
path: root/tests/auto/declarative
diff options
context:
space:
mode:
authorMartin Jones <martin.jones@nokia.com>2010-08-16 05:38:15 (GMT)
committerMartin Jones <martin.jones@nokia.com>2010-08-16 05:38:15 (GMT)
commitb83c295650b3f28bc9da542acf4652f4ce2d168b (patch)
tree794a392706234c3bcbfe66ce28bbc9806f2cfa9a /tests/auto/declarative
parent7fcc1daf1762d345ca39f9599a8de2567bb8e788 (diff)
downloadQt-b83c295650b3f28bc9da542acf4652f4ce2d168b.zip
Qt-b83c295650b3f28bc9da542acf4652f4ce2d168b.tar.gz
Qt-b83c295650b3f28bc9da542acf4652f4ce2d168b.tar.bz2
Handle QGraphicsWidgets in Flickable
Task-number: QTBUG-12830 Reviewed-by: Michael Brasser
Diffstat (limited to 'tests/auto/declarative')
-rw-r--r--tests/auto/declarative/qdeclarativeflickable/tst_qdeclarativeflickable.cpp37
1 files changed, 37 insertions, 0 deletions
diff --git a/tests/auto/declarative/qdeclarativeflickable/tst_qdeclarativeflickable.cpp b/tests/auto/declarative/qdeclarativeflickable/tst_qdeclarativeflickable.cpp
index 678996b..e7ded8a 100644
--- a/tests/auto/declarative/qdeclarativeflickable/tst_qdeclarativeflickable.cpp
+++ b/tests/auto/declarative/qdeclarativeflickable/tst_qdeclarativeflickable.cpp
@@ -44,6 +44,7 @@
#include <QtDeclarative/qdeclarativecomponent.h>
#include <private/qdeclarativeflickable_p.h>
#include <private/qdeclarativevaluetype_p.h>
+#include <QtGui/qgraphicswidget.h>
#include <math.h>
#ifdef Q_OS_SYMBIAN
@@ -67,9 +68,13 @@ private slots:
void flickDeceleration();
void pressDelay();
void flickableDirection();
+ void qgraphicswidget();
private:
QDeclarativeEngine engine;
+
+ template<typename T>
+ T *findItem(QGraphicsObject *parent, const QString &objectName);
};
tst_qdeclarativeflickable::tst_qdeclarativeflickable()
@@ -261,6 +266,38 @@ void tst_qdeclarativeflickable::flickableDirection()
QCOMPARE(spy.count(),3);
}
+void tst_qdeclarativeflickable::qgraphicswidget()
+{
+ QDeclarativeEngine engine;
+ QDeclarativeComponent c(&engine, QUrl::fromLocalFile(SRCDIR "/data/flickableqgraphicswidget.qml"));
+ QDeclarativeFlickable *flickable = qobject_cast<QDeclarativeFlickable*>(c.create());
+
+ QVERIFY(flickable != 0);
+ QGraphicsWidget *widget = findItem<QGraphicsWidget>(flickable->contentItem(), "widget1");
+ QVERIFY(widget);
+}
+
+template<typename T>
+T *tst_qdeclarativeflickable::findItem(QGraphicsObject *parent, const QString &objectName)
+{
+ const QMetaObject &mo = T::staticMetaObject;
+ //qDebug() << parent->childItems().count() << "children";
+ for (int i = 0; i < parent->childItems().count(); ++i) {
+ QGraphicsObject *item = qobject_cast<QGraphicsObject*>(parent->childItems().at(i));
+ if(!item)
+ continue;
+ //qDebug() << "try" << item;
+ if (mo.cast(item) && (objectName.isEmpty() || item->objectName() == objectName)) {
+ return static_cast<T*>(item);
+ }
+ item = findItem<T>(item, objectName);
+ if (item)
+ return static_cast<T*>(item);
+ }
+
+ return 0;
+}
+
QTEST_MAIN(tst_qdeclarativeflickable)
#include "tst_qdeclarativeflickable.moc"