diff options
author | Yann Bodson <yann.bodson@nokia.com> | 2009-11-13 05:06:52 (GMT) |
---|---|---|
committer | Yann Bodson <yann.bodson@nokia.com> | 2009-11-13 05:06:52 (GMT) |
commit | 2c393c60f0d309edab31cd1998a0baf6d5749d9d (patch) | |
tree | 145fce682d16eff9df38ad8415deb7d938a1e3aa /tests | |
parent | ee4278059939902482c7f457089aaf484358113b (diff) | |
download | Qt-2c393c60f0d309edab31cd1998a0baf6d5749d9d.zip Qt-2c393c60f0d309edab31cd1998a0baf6d5749d9d.tar.gz Qt-2c393c60f0d309edab31cd1998a0baf6d5749d9d.tar.bz2 |
More GridView autotests
Diffstat (limited to 'tests')
3 files changed, 83 insertions, 0 deletions
diff --git a/tests/auto/declarative/qmlgraphicsgridview/data/gridview2.qml b/tests/auto/declarative/qmlgraphicsgridview/data/gridview2.qml new file mode 100644 index 0000000..62b5bd3 --- /dev/null +++ b/tests/auto/declarative/qmlgraphicsgridview/data/gridview2.qml @@ -0,0 +1,26 @@ +import Qt 4.6 + +GridView { + anchors.fill: parent + width: 320; height: 200 + cellWidth: 100; cellHeight: 100; cacheBuffer: 200; focus: true + keyNavigationWraps: true; highlightFollowsCurrentItem: false + + model: ListModel { + id: appModel + ListElement { lColor: "red" } + ListElement { lColor: "yellow" } + ListElement { lColor: "green" } + ListElement { lColor: "blue" } + } + + delegate: Item { + width: 100; height: 100 + Rectangle { + color: lColor; x: 4; y: 4 + width: 92; height: 92 + } + } + + highlight: Rectangle { width: 100; height: 100; color: "black" } +} diff --git a/tests/auto/declarative/qmlgraphicsgridview/data/gridview3.qml b/tests/auto/declarative/qmlgraphicsgridview/data/gridview3.qml new file mode 100644 index 0000000..b133d55 --- /dev/null +++ b/tests/auto/declarative/qmlgraphicsgridview/data/gridview3.qml @@ -0,0 +1,6 @@ +import Qt 4.6 + +GridView { + anchors.fill: parent + width: 320; height: 200 +} diff --git a/tests/auto/declarative/qmlgraphicsgridview/tst_qmlgraphicsgridview.cpp b/tests/auto/declarative/qmlgraphicsgridview/tst_qmlgraphicsgridview.cpp index d99b16f..d09aad7 100644 --- a/tests/auto/declarative/qmlgraphicsgridview/tst_qmlgraphicsgridview.cpp +++ b/tests/auto/declarative/qmlgraphicsgridview/tst_qmlgraphicsgridview.cpp @@ -38,6 +38,9 @@ ** $QT_END_LICENSE$ ** ****************************************************************************/ + +#include <qmlengine.h> +#include <qmlcomponent.h> #include <QtTest/QtTest> #include <private/qlistmodelinterface_p.h> #include <qmlview.h> @@ -60,6 +63,8 @@ private slots: void moved(); void currentIndex(); void changeFlow(); + void defaultValues(); + void properties(); private: QmlView *createView(const QString &filename); @@ -690,6 +695,52 @@ void tst_QmlGraphicsGridView::changeFlow() delete canvas; } +void tst_QmlGraphicsGridView::defaultValues() +{ + QmlEngine engine; + QmlComponent c(&engine, QUrl("file://" SRCDIR "/data/gridview3.qml")); + QmlGraphicsGridView *obj = qobject_cast<QmlGraphicsGridView*>(c.create()); + + QVERIFY(obj != 0); + QVERIFY(obj->model() == QVariant()); + QVERIFY(obj->delegate() == 0); + QCOMPARE(obj->currentIndex(), -1); + QVERIFY(obj->currentItem() == 0); + QCOMPARE(obj->count(), 0); + QVERIFY(obj->highlight() == 0); + QVERIFY(obj->highlightItem() == 0); + QCOMPARE(obj->highlightFollowsCurrentItem(), true); + QVERIFY(obj->flow() == 0); + QCOMPARE(obj->isWrapEnabled(), false); + QCOMPARE(obj->cacheBuffer(), 0); + QCOMPARE(obj->cellWidth(), 100); //### Should 100 be the default? + QCOMPARE(obj->cellHeight(), 100); + delete obj; +} + +void tst_QmlGraphicsGridView::properties() +{ + QmlEngine engine; + QmlComponent c(&engine, QUrl("file://" SRCDIR "/data/gridview2.qml")); + QmlGraphicsGridView *obj = qobject_cast<QmlGraphicsGridView*>(c.create()); + + QVERIFY(obj != 0); + QVERIFY(obj->model() != QVariant()); + QVERIFY(obj->delegate() != 0); + QCOMPARE(obj->currentIndex(), 0); + QVERIFY(obj->currentItem() != 0); + QCOMPARE(obj->count(), 4); + QVERIFY(obj->highlight() != 0); + QVERIFY(obj->highlightItem() != 0); + QCOMPARE(obj->highlightFollowsCurrentItem(), false); + QVERIFY(obj->flow() == 0); + QCOMPARE(obj->isWrapEnabled(), true); + QCOMPARE(obj->cacheBuffer(), 200); + QCOMPARE(obj->cellWidth(), 100); + QCOMPARE(obj->cellHeight(), 100); + delete obj; +} + QmlView *tst_QmlGraphicsGridView::createView(const QString &filename) { QmlView *canvas = new QmlView(0); |