summaryrefslogtreecommitdiffstats
path: root/tests
diff options
context:
space:
mode:
authorAaron Kennedy <aaron.kennedy@nokia.com>2010-03-09 06:07:27 (GMT)
committerAaron Kennedy <aaron.kennedy@nokia.com>2010-03-09 06:07:27 (GMT)
commitd660cb7978785e8aeed59bc781f4a3df1289bb84 (patch)
tree68c4e7351e093798cb8d73f7f5a6fb3dd78cd1ad /tests
parent782422352f5e2280345054eacd6a001cca164570 (diff)
parent9abf138562c583617205c60e05d5ed2c2874d4be (diff)
downloadQt-d660cb7978785e8aeed59bc781f4a3df1289bb84.zip
Qt-d660cb7978785e8aeed59bc781f4a3df1289bb84.tar.gz
Qt-d660cb7978785e8aeed59bc781f4a3df1289bb84.tar.bz2
Merge branch '4.7' of scm.dev.nokia.troll.no:qt/qt-qml into 4.7
Diffstat (limited to 'tests')
-rw-r--r--tests/auto/declarative/qdeclarativeitem/data/propertychanges.qml10
-rw-r--r--tests/auto/declarative/qdeclarativeitem/tst_qdeclarativeitem.cpp92
-rw-r--r--tests/auto/declarative/qdeclarativerepeater/tst_qdeclarativerepeater.cpp2
3 files changed, 101 insertions, 3 deletions
diff --git a/tests/auto/declarative/qdeclarativeitem/data/propertychanges.qml b/tests/auto/declarative/qdeclarativeitem/data/propertychanges.qml
new file mode 100644
index 0000000..bf4dd85
--- /dev/null
+++ b/tests/auto/declarative/qdeclarativeitem/data/propertychanges.qml
@@ -0,0 +1,10 @@
+import Qt 4.6
+
+Item {
+ Item {
+ objectName: "item"
+ }
+ Item {
+ objectName: "parentItem"
+ }
+} \ No newline at end of file
diff --git a/tests/auto/declarative/qdeclarativeitem/tst_qdeclarativeitem.cpp b/tests/auto/declarative/qdeclarativeitem/tst_qdeclarativeitem.cpp
index bbcc86e..45d670f 100644
--- a/tests/auto/declarative/qdeclarativeitem/tst_qdeclarativeitem.cpp
+++ b/tests/auto/declarative/qdeclarativeitem/tst_qdeclarativeitem.cpp
@@ -60,6 +60,7 @@ private slots:
void clip();
void mapCoordinates();
void mapCoordinates_data();
+ void propertyChanges();
private:
template<typename T>
@@ -289,7 +290,7 @@ void tst_QDeclarativeItem::smooth()
QDeclarativeComponent component(&engine);
component.setData("import Qt 4.6; Item { smooth: false; }", QUrl::fromLocalFile(""));
QDeclarativeItem *item = qobject_cast<QDeclarativeItem*>(component.create());
- QSignalSpy spy(item, SIGNAL(smoothChanged()));
+ QSignalSpy spy(item, SIGNAL(smoothChanged(bool)));
QVERIFY(item);
QVERIFY(!item->smooth());
@@ -297,6 +298,10 @@ void tst_QDeclarativeItem::smooth()
item->setSmooth(true);
QVERIFY(item->smooth());
QCOMPARE(spy.count(),1);
+ QList<QVariant> arguments = spy.first();
+ QVERIFY(arguments.count() == 1);
+ QVERIFY(arguments.at(0).toBool() == true);
+
item->setSmooth(true);
QCOMPARE(spy.count(),1);
@@ -314,13 +319,18 @@ void tst_QDeclarativeItem::clip()
QDeclarativeComponent component(&engine);
component.setData("import Qt 4.6\nItem { clip: false\n }", QUrl::fromLocalFile(""));
QDeclarativeItem *item = qobject_cast<QDeclarativeItem*>(component.create());
- QSignalSpy spy(item, SIGNAL(clipChanged()));
+ QSignalSpy spy(item, SIGNAL(clipChanged(bool)));
QVERIFY(item);
QVERIFY(!item->clip());
item->setClip(true);
QVERIFY(item->clip());
+
+ QList<QVariant> arguments = spy.first();
+ QVERIFY(arguments.count() == 1);
+ QVERIFY(arguments.at(0).toBool() == true);
+
QCOMPARE(spy.count(),1);
item->setClip(true);
QCOMPARE(spy.count(),1);
@@ -392,6 +402,84 @@ void tst_QDeclarativeItem::mapCoordinates_data()
QTest::newRow(QTest::toString(i)) << i << i;
}
+void tst_QDeclarativeItem::propertyChanges()
+{
+ QDeclarativeView *canvas = new QDeclarativeView(0);
+ canvas->setFixedSize(240,320);
+ canvas->setSource(QUrl::fromLocalFile(SRCDIR "/data/propertychanges.qml"));
+ canvas->show();
+
+ QEvent wa(QEvent::WindowActivate);
+ QApplication::sendEvent(canvas, &wa);
+ QFocusEvent fe(QEvent::FocusIn);
+ QApplication::sendEvent(canvas, &fe);
+
+ QDeclarativeItem *item = findItem<QDeclarativeItem>(canvas->rootObject(), "item");
+ QDeclarativeItem *parentItem = findItem<QDeclarativeItem>(canvas->rootObject(), "parentItem");
+
+ QVERIFY(item);
+ QVERIFY(parentItem);
+
+ QSignalSpy parentSpy(item, SIGNAL(parentChanged(QDeclarativeItem *)));
+ QSignalSpy widthSpy(item, SIGNAL(widthChanged(qreal)));
+ QSignalSpy heightSpy(item, SIGNAL(heightChanged(qreal)));
+ QSignalSpy baselineOffsetSpy(item, SIGNAL(baselineOffsetChanged(qreal)));
+ QSignalSpy childrenRectSpy(parentItem, SIGNAL(childrenRectChanged(QRectF)));
+ QSignalSpy focusSpy(item, SIGNAL(focusChanged(bool)));
+ QSignalSpy wantsFocusSpy(parentItem, SIGNAL(wantsFocusChanged(bool)));
+
+ item->setParentItem(parentItem);
+ item->setWidth(100.0);
+ item->setHeight(200.0);
+ item->setFocus(true);
+ item->setBaselineOffset(10.0);
+
+ QCOMPARE(item->parentItem(), parentItem);
+ QCOMPARE(parentSpy.count(),1);
+ QList<QVariant> parentArguments = parentSpy.first();
+ QVERIFY(parentArguments.count() == 1);
+ QCOMPARE(item->parentItem(), qvariant_cast<QDeclarativeItem *>(parentArguments.at(0)));
+
+ QCOMPARE(item->width(), 100.0);
+ QCOMPARE(widthSpy.count(),1);
+ QList<QVariant> widthArguments = widthSpy.first();
+ QVERIFY(widthArguments.count() == 1);
+ QCOMPARE(item->width(), widthArguments.at(0).toReal());
+
+ QCOMPARE(item->height(), 200.0);
+ QCOMPARE(heightSpy.count(),1);
+ QList<QVariant> heightArguments = heightSpy.first();
+ QVERIFY(heightArguments.count() == 1);
+ QCOMPARE(item->height(), heightArguments.at(0).toReal());
+
+ QCOMPARE(item->baselineOffset(), 10.0);
+ QCOMPARE(baselineOffsetSpy.count(),1);
+ QList<QVariant> baselineOffsetArguments = baselineOffsetSpy.first();
+ QVERIFY(baselineOffsetArguments.count() == 1);
+ QCOMPARE(item->baselineOffset(), baselineOffsetArguments.at(0).toReal());
+
+ QCOMPARE(parentItem->childrenRect(), QRectF(0.0,0.0,100.0,200.0));
+ QCOMPARE(childrenRectSpy.count(),2);
+ QList<QVariant> childrenRectArguments = childrenRectSpy.at(1);
+ QVERIFY(childrenRectArguments.count() == 1);
+ QCOMPARE(parentItem->childrenRect(), childrenRectArguments.at(0).toRectF());
+
+ QCOMPARE(item->hasFocus(), true);
+ QCOMPARE(focusSpy.count(),1);
+ QList<QVariant> focusArguments = focusSpy.first();
+ QVERIFY(focusArguments.count() == 1);
+ QCOMPARE(focusArguments.at(0).toBool(), true);
+
+ QCOMPARE(parentItem->hasFocus(), false);
+ QCOMPARE(parentItem->wantsFocus(), true);
+ QCOMPARE(wantsFocusSpy.count(),1);
+ QList<QVariant> wantsFocusArguments = wantsFocusSpy.first();
+ QVERIFY(wantsFocusArguments.count() == 1);
+ QCOMPARE(wantsFocusArguments.at(0).toBool(), true);
+
+ delete canvas;
+}
+
template<typename T>
T *tst_QDeclarativeItem::findItem(QGraphicsObject *parent, const QString &objectName)
{
diff --git a/tests/auto/declarative/qdeclarativerepeater/tst_qdeclarativerepeater.cpp b/tests/auto/declarative/qdeclarativerepeater/tst_qdeclarativerepeater.cpp
index 7a97e60..7da9454 100644
--- a/tests/auto/declarative/qdeclarativerepeater/tst_qdeclarativerepeater.cpp
+++ b/tests/auto/declarative/qdeclarativerepeater/tst_qdeclarativerepeater.cpp
@@ -109,7 +109,7 @@ public:
setRoleNames(roles);
}
- int rowCount(const QModelIndex &parent=QModelIndex()) const { return list.count(); }
+ int rowCount(const QModelIndex &parent=QModelIndex()) const { Q_UNUSED(parent); return list.count(); }
QVariant data(const QModelIndex &index, int role=Qt::DisplayRole) const {
QVariant rv;
if (role == Name)