diff options
author | Michael Brasser <michael.brasser@nokia.com> | 2010-10-04 06:44:32 (GMT) |
---|---|---|
committer | Michael Brasser <michael.brasser@nokia.com> | 2010-10-04 06:48:29 (GMT) |
commit | f25391e52af3eef68abfa3941fc48da0c52bb010 (patch) | |
tree | 0b8f02830dc0b81b144867c33253823ecc60ca2f /tests/auto/declarative | |
parent | da45259dbfa05c4f3b6c8c0472a65851692060e4 (diff) | |
download | Qt-f25391e52af3eef68abfa3941fc48da0c52bb010.zip Qt-f25391e52af3eef68abfa3941fc48da0c52bb010.tar.gz Qt-f25391e52af3eef68abfa3941fc48da0c52bb010.tar.bz2 |
Improve test coverage for declarative module.
Add additional autotests, and remove unreachable functions.
Diffstat (limited to 'tests/auto/declarative')
8 files changed, 75 insertions, 2 deletions
diff --git a/tests/auto/declarative/qdeclarativeitem/data/keystest.qml b/tests/auto/declarative/qdeclarativeitem/data/keystest.qml index aedccd9..3927f42 100644 --- a/tests/auto/declarative/qdeclarativeitem/data/keystest.qml +++ b/tests/auto/declarative/qdeclarativeitem/data/keystest.qml @@ -2,6 +2,9 @@ import QtQuick 1.0 Item { focus: true + + property bool isEnabled: Keys.enabled + Keys.onPressed: keysTestObject.keyPress(event.key, event.text, event.modifiers) Keys.onReleased: { keysTestObject.keyRelease(event.key, event.text, event.modifiers); event.accepted = true; } Keys.onReturnPressed: keysTestObject.keyPress(event.key, "Return", event.modifiers) diff --git a/tests/auto/declarative/qdeclarativeitem/tst_qdeclarativeitem.cpp b/tests/auto/declarative/qdeclarativeitem/tst_qdeclarativeitem.cpp index e9dad6b..bbbf73e 100644 --- a/tests/auto/declarative/qdeclarativeitem/tst_qdeclarativeitem.cpp +++ b/tests/auto/declarative/qdeclarativeitem/tst_qdeclarativeitem.cpp @@ -214,6 +214,9 @@ void tst_QDeclarativeItem::keys() QFocusEvent fe(QEvent::FocusIn); QApplication::sendEvent(canvas, &fe); + QVERIFY(canvas->rootObject()); + QCOMPARE(canvas->rootObject()->property("isEnabled").toBool(), true); + QKeyEvent key(QEvent::KeyPress, Qt::Key_A, Qt::NoModifier, "A", false, 1); QApplication::sendEvent(canvas, &key); QCOMPARE(testObject->mKey, int(Qt::Key_A)); @@ -285,6 +288,7 @@ void tst_QDeclarativeItem::keys() testObject->reset(); canvas->rootContext()->setContextProperty("enableKeyHanding", QVariant(false)); + QCOMPARE(canvas->rootObject()->property("isEnabled").toBool(), false); key = QKeyEvent(QEvent::KeyPress, Qt::Key_Return, Qt::NoModifier, "", false, 1); QApplication::sendEvent(canvas, &key); @@ -292,6 +296,7 @@ void tst_QDeclarativeItem::keys() QVERIFY(!key.isAccepted()); canvas->rootContext()->setContextProperty("enableKeyHanding", QVariant(true)); + QCOMPARE(canvas->rootObject()->property("isEnabled").toBool(), true); key = QKeyEvent(QEvent::KeyPress, Qt::Key_Return, Qt::NoModifier, "", false, 1); QApplication::sendEvent(canvas, &key); diff --git a/tests/auto/declarative/qdeclarativelayoutitem/tst_qdeclarativelayoutitem.cpp b/tests/auto/declarative/qdeclarativelayoutitem/tst_qdeclarativelayoutitem.cpp index bbdba74..cc0f633 100644 --- a/tests/auto/declarative/qdeclarativelayoutitem/tst_qdeclarativelayoutitem.cpp +++ b/tests/auto/declarative/qdeclarativelayoutitem/tst_qdeclarativelayoutitem.cpp @@ -82,6 +82,11 @@ void tst_qdeclarativelayoutitem::test_resizing() QDeclarativeEngine engine; QDeclarativeComponent c(&engine, QUrl::fromLocalFile(SRCDIR "/data/layoutItem.qml")); QDeclarativeLayoutItem* obj = static_cast<QDeclarativeLayoutItem*>(c.create()); + QVERIFY(obj); + QCOMPARE(obj->minimumSize(), QSizeF(100,100)); + QCOMPARE(obj->preferredSize(), QSizeF(200,200)); + QCOMPARE(obj->maximumSize(), QSizeF(300,300)); + layout->addItem(obj); layout->setContentsMargins(0,0,0,0); widget->setContentsMargins(0,0,0,0); diff --git a/tests/auto/declarative/qdeclarativemousearea/tst_qdeclarativemousearea.cpp b/tests/auto/declarative/qdeclarativemousearea/tst_qdeclarativemousearea.cpp index e4ec01f..5e88450 100644 --- a/tests/auto/declarative/qdeclarativemousearea/tst_qdeclarativemousearea.cpp +++ b/tests/auto/declarative/qdeclarativemousearea/tst_qdeclarativemousearea.cpp @@ -356,6 +356,7 @@ void tst_QDeclarativeMouseArea::onMousePressRejected() canvas->show(); canvas->setFocus(); QVERIFY(canvas->rootObject() != 0); + QVERIFY(canvas->rootObject()->property("enabled").toBool()); QVERIFY(!canvas->rootObject()->property("mr1_pressed").toBool()); QVERIFY(!canvas->rootObject()->property("mr1_released").toBool()); diff --git a/tests/auto/declarative/qdeclarativepathview/data/closedPath.qml b/tests/auto/declarative/qdeclarativepathview/data/closedPath.qml new file mode 100644 index 0000000..08b0d2a --- /dev/null +++ b/tests/auto/declarative/qdeclarativepathview/data/closedPath.qml @@ -0,0 +1,24 @@ +import QtQuick 1.0 + +Path { + startY: 120 + startX: 160 + PathQuad { + y: 120 + x: 80 + controlY: 330 + controlX: 100 + } + PathLine { + y: 160 + x: 20 + } + PathCubic { + y: 120 + x: 160 + control1Y: 0 + control1X: 100 + control2Y: 000 + control2X: 200 + } +} diff --git a/tests/auto/declarative/qdeclarativepathview/data/openPath.qml b/tests/auto/declarative/qdeclarativepathview/data/openPath.qml new file mode 100644 index 0000000..328e3cd --- /dev/null +++ b/tests/auto/declarative/qdeclarativepathview/data/openPath.qml @@ -0,0 +1,10 @@ +import QtQuick 1.0 + +Path { + startY: 120 + startX: 160 + PathLine { + y: 160 + x: 20 + } +} diff --git a/tests/auto/declarative/qdeclarativepathview/tst_qdeclarativepathview.cpp b/tests/auto/declarative/qdeclarativepathview/tst_qdeclarativepathview.cpp index 3b5d438..65007a6 100644 --- a/tests/auto/declarative/qdeclarativepathview/tst_qdeclarativepathview.cpp +++ b/tests/auto/declarative/qdeclarativepathview/tst_qdeclarativepathview.cpp @@ -85,6 +85,7 @@ private slots: void pathUpdateOnStartChanged(); void package(); void emptyModel(); + void closed(); private: QDeclarativeView *createView(); @@ -786,6 +787,26 @@ void tst_QDeclarativePathView::emptyModel() delete canvas; } +void tst_QDeclarativePathView::closed() +{ + QDeclarativeEngine engine; + + { + QDeclarativeComponent c(&engine, QUrl::fromLocalFile(SRCDIR "/data/openPath.qml")); + QDeclarativePath *obj = qobject_cast<QDeclarativePath*>(c.create()); + QVERIFY(obj); + QCOMPARE(obj->isClosed(), false); + delete obj; + } + + { + QDeclarativeComponent c(&engine, QUrl::fromLocalFile(SRCDIR "/data/closedPath.qml")); + QDeclarativePath *obj = qobject_cast<QDeclarativePath*>(c.create()); + QVERIFY(obj); + QCOMPARE(obj->isClosed(), true); + delete obj; + } +} QDeclarativeView *tst_QDeclarativePathView::createView() { diff --git a/tests/auto/declarative/qdeclarativepositioners/tst_qdeclarativepositioners.cpp b/tests/auto/declarative/qdeclarativepositioners/tst_qdeclarativepositioners.cpp index 57a8354..254349f 100644 --- a/tests/auto/declarative/qdeclarativepositioners/tst_qdeclarativepositioners.cpp +++ b/tests/auto/declarative/qdeclarativepositioners/tst_qdeclarativepositioners.cpp @@ -322,7 +322,8 @@ void tst_QDeclarativePositioners::test_grid() QCOMPARE(five->x(), 50.0); QCOMPARE(five->y(), 50.0); - QDeclarativeItem *grid = canvas->rootObject()->findChild<QDeclarativeItem*>("grid"); + QDeclarativeGrid *grid = canvas->rootObject()->findChild<QDeclarativeGrid*>("grid"); + QCOMPARE(grid->flow(), QDeclarativeGrid::LeftToRight); QCOMPARE(grid->width(), 120.0); QCOMPARE(grid->height(), 100.0); @@ -355,7 +356,8 @@ void tst_QDeclarativePositioners::test_grid_topToBottom() QCOMPARE(five->x(), 50.0); QCOMPARE(five->y(), 50.0); - QDeclarativeItem *grid = canvas->rootObject()->findChild<QDeclarativeItem*>("grid"); + QDeclarativeGrid *grid = canvas->rootObject()->findChild<QDeclarativeGrid*>("grid"); + QCOMPARE(grid->flow(), QDeclarativeGrid::TopToBottom); QCOMPARE(grid->width(), 100.0); QCOMPARE(grid->height(), 120.0); @@ -670,10 +672,12 @@ void tst_QDeclarativePositioners::test_flow_implicit_resize() QCOMPARE(flow->height(), 120.0); canvas->rootObject()->setProperty("leftToRight", true); + QCOMPARE(flow->flow(), QDeclarativeFlow::LeftToRight); QCOMPARE(flow->width(), 220.0); QCOMPARE(flow->height(), 50.0); canvas->rootObject()->setProperty("leftToRight", false); + QCOMPARE(flow->flow(), QDeclarativeFlow::TopToBottom); QCOMPARE(flow->width(), 100.0); QCOMPARE(flow->height(), 120.0); |