summaryrefslogtreecommitdiffstats
path: root/tests/auto
diff options
context:
space:
mode:
authorQt Continuous Integration System <qt-info@nokia.com>2010-08-17 07:28:56 (GMT)
committerQt Continuous Integration System <qt-info@nokia.com>2010-08-17 07:28:56 (GMT)
commit87e9034caf90fb02ae2564947b9cbf464b3ca97c (patch)
tree10310b5918a8096a726122fc12dcb33b5f0d303e /tests/auto
parent50eefbaad10c217eeff5ac0d4b3581176e88e492 (diff)
parent59d2b0a0a1c836d3371c18a2a857d88c2d28621f (diff)
downloadQt-87e9034caf90fb02ae2564947b9cbf464b3ca97c.zip
Qt-87e9034caf90fb02ae2564947b9cbf464b3ca97c.tar.gz
Qt-87e9034caf90fb02ae2564947b9cbf464b3ca97c.tar.bz2
Merge branch '4.7' of scm.dev.nokia.troll.no:qt/qt-qml into 4.7-integration
* '4.7' of scm.dev.nokia.troll.no:qt/qt-qml: Add missing file Docs - clarify use of PropertyChanges for immediate property changes in Update QtDeclarative def files Update QtGui def files Add missing auto test files. Fix game could not be restarted Handle QGraphicsWidgets in Flickable More positioners with QGraphicsWidgets fixes. Make positioners work with QGraphicsWidgets also emit countChanged where appropriate in Repeater
Diffstat (limited to 'tests/auto')
-rw-r--r--tests/auto/declarative/qdeclarativeflickable/data/flickableqgraphicswidget.qml7
-rw-r--r--tests/auto/declarative/qdeclarativeflickable/tst_qdeclarativeflickable.cpp37
-rw-r--r--tests/auto/declarative/qdeclarativepositioners/data/verticalqgraphicswidget.qml24
-rw-r--r--tests/auto/declarative/qdeclarativepositioners/tst_qdeclarativepositioners.cpp44
-rw-r--r--tests/auto/declarative/qdeclarativerepeater/tst_qdeclarativerepeater.cpp3
5 files changed, 115 insertions, 0 deletions
diff --git a/tests/auto/declarative/qdeclarativeflickable/data/flickableqgraphicswidget.qml b/tests/auto/declarative/qdeclarativeflickable/data/flickableqgraphicswidget.qml
new file mode 100644
index 0000000..8e95a94
--- /dev/null
+++ b/tests/auto/declarative/qdeclarativeflickable/data/flickableqgraphicswidget.qml
@@ -0,0 +1,7 @@
+import Qt 4.7
+
+Flickable {
+ width: 100; height: 100
+
+ QGraphicsWidget { objectName: "widget1"; width: 200; height: 300 }
+}
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"
diff --git a/tests/auto/declarative/qdeclarativepositioners/data/verticalqgraphicswidget.qml b/tests/auto/declarative/qdeclarativepositioners/data/verticalqgraphicswidget.qml
new file mode 100644
index 0000000..c9c8607
--- /dev/null
+++ b/tests/auto/declarative/qdeclarativepositioners/data/verticalqgraphicswidget.qml
@@ -0,0 +1,24 @@
+import Qt 4.7
+
+Item {
+ width: 640
+ height: 480
+ Column {
+ objectName: "column"
+ QGraphicsWidget {
+ objectName: "one"
+ width: 50
+ height: 50
+ }
+ QGraphicsWidget {
+ objectName: "two"
+ width: 20
+ height: 10
+ }
+ QGraphicsWidget {
+ objectName: "three"
+ width: 40
+ height: 20
+ }
+ }
+}
diff --git a/tests/auto/declarative/qdeclarativepositioners/tst_qdeclarativepositioners.cpp b/tests/auto/declarative/qdeclarativepositioners/tst_qdeclarativepositioners.cpp
index 0663991..887be50 100644
--- a/tests/auto/declarative/qdeclarativepositioners/tst_qdeclarativepositioners.cpp
+++ b/tests/auto/declarative/qdeclarativepositioners/tst_qdeclarativepositioners.cpp
@@ -46,6 +46,7 @@
#include <private/qdeclarativepositioners_p.h>
#include <private/qdeclarativetransition_p.h>
#include <qdeclarativeexpression.h>
+#include <QtGui/qgraphicswidget.h>
#include "../../../shared/util.h"
#ifdef Q_OS_SYMBIAN
@@ -77,6 +78,7 @@ private slots:
void test_flow_resize();
void test_flow_implicit_resize();
void test_conflictinganchors();
+ void test_vertical_qgraphicswidget();
private:
QDeclarativeView *createView(const QString &filename);
};
@@ -771,6 +773,48 @@ void tst_QDeclarativePositioners::test_conflictinganchors()
QCOMPARE(warningMessage, QString("file::2:1: QML Flow: Cannot specify anchors for items inside Flow"));
}
+void tst_QDeclarativePositioners::test_vertical_qgraphicswidget()
+{
+ QDeclarativeView *canvas = createView(SRCDIR "/data/verticalqgraphicswidget.qml");
+
+ QGraphicsWidget *one = canvas->rootObject()->findChild<QGraphicsWidget*>("one");
+ QVERIFY(one != 0);
+
+ QGraphicsWidget *two = canvas->rootObject()->findChild<QGraphicsWidget*>("two");
+ QVERIFY(two != 0);
+
+ QGraphicsWidget *three = canvas->rootObject()->findChild<QGraphicsWidget*>("three");
+ QVERIFY(three != 0);
+
+ QCOMPARE(one->x(), 0.0);
+ QCOMPARE(one->y(), 0.0);
+ QCOMPARE(two->x(), 0.0);
+ QCOMPARE(two->y(), 50.0);
+ QCOMPARE(three->x(), 0.0);
+ QCOMPARE(three->y(), 60.0);
+
+ QDeclarativeItem *column = canvas->rootObject()->findChild<QDeclarativeItem*>("column");
+ QVERIFY(column);
+ QCOMPARE(column->height(), 80.0);
+ QCOMPARE(column->width(), 50.0);
+
+ two->resize(QSizeF(two->size().width(), 20.0));
+ QCOMPARE(three->x(), 0.0);
+ QCOMPARE(three->y(), 70.0);
+
+ two->setOpacity(0.0);
+ QCOMPARE(one->x(), 0.0);
+ QCOMPARE(one->y(), 0.0);
+ QCOMPARE(three->x(), 0.0);
+ QCOMPARE(three->y(), 50.0);
+
+ one->setVisible(false);
+ QCOMPARE(three->x(), 0.0);
+ QCOMPARE(three->y(), 0.0);
+
+ delete canvas;
+}
+
QDeclarativeView *tst_QDeclarativePositioners::createView(const QString &filename)
{
QDeclarativeView *canvas = new QDeclarativeView(0);
diff --git a/tests/auto/declarative/qdeclarativerepeater/tst_qdeclarativerepeater.cpp b/tests/auto/declarative/qdeclarativerepeater/tst_qdeclarativerepeater.cpp
index 623b3d7..360d90f 100644
--- a/tests/auto/declarative/qdeclarativerepeater/tst_qdeclarativerepeater.cpp
+++ b/tests/auto/declarative/qdeclarativerepeater/tst_qdeclarativerepeater.cpp
@@ -309,11 +309,14 @@ void tst_QDeclarativeRepeater::dataModel()
QCOMPARE(container->childItems().count(), 4);
+ QSignalSpy repeaterSpy(repeater, SIGNAL(countChanged()));
testModel.addItem("four", "4");
QCOMPARE(container->childItems().count(), 5);
+ QCOMPARE(repeaterSpy.count(),1);
testModel.removeItem(2);
QCOMPARE(container->childItems().count(), 4);
+ QCOMPARE(repeaterSpy.count(),2);
// Check that model changes are propagated
QDeclarativeText *text = findItem<QDeclarativeText>(canvas->rootObject(), "myName", 1);