diff options
author | Michael Brasser <michael.brasser@nokia.com> | 2011-09-19 13:50:03 +1000 |
---|---|---|
committer | Qt by Nokia <qt-info@nokia.com> | 2011-09-19 06:24:47 +0200 |
commit | 1aa075b6319ded90d79dfe28605294283502bead (patch) | |
tree | 59751e7937657d1544a9a2db1ff71f432195db1e /tests | |
parent | b0539f0ed9e848afd6df2cb4d01eb5af70168df8 (diff) |
Make cellWidth/cellHeight reals rather than ints.
When they were ints, it was relatively easy to end up with a different
row or column count than expected, because of rounding.
Change-Id: Ifc5eba2b5598cbc0220df25f91f031581c3b51a5
Reviewed-on: http://codereview.qt-project.org/5112
Reviewed-by: Qt Sanity Bot <qt_sanity_bot@ovi.com>
Reviewed-by: Bea Lam <bea.lam@nokia.com>
Diffstat (limited to 'tests')
-rw-r--r-- | tests/auto/declarative/qsggridview/data/gridview4.qml | 11 | ||||
-rw-r--r-- | tests/auto/declarative/qsggridview/tst_qsggridview.cpp | 28 |
2 files changed, 35 insertions, 4 deletions
diff --git a/tests/auto/declarative/qsggridview/data/gridview4.qml b/tests/auto/declarative/qsggridview/data/gridview4.qml new file mode 100644 index 0000000000..01b31da082 --- /dev/null +++ b/tests/auto/declarative/qsggridview/data/gridview4.qml @@ -0,0 +1,11 @@ +import QtQuick 2.0 + +GridView { + width: 400 + height: 200 + cellWidth: width/9 + cellHeight: height/2 + + model: 18 + delegate: Rectangle { objectName: "delegate"; width: 10; height: 10; color: "green" } +} diff --git a/tests/auto/declarative/qsggridview/tst_qsggridview.cpp b/tests/auto/declarative/qsggridview/tst_qsggridview.cpp index 98953aef40..5d35ffc542 100644 --- a/tests/auto/declarative/qsggridview/tst_qsggridview.cpp +++ b/tests/auto/declarative/qsggridview/tst_qsggridview.cpp @@ -109,6 +109,7 @@ private slots: void onRemove_data(); void testQtQuick11Attributes(); void testQtQuick11Attributes_data(); + void columnCount(); private: QSGView *createView(); @@ -1455,8 +1456,8 @@ void tst_QSGGridView::defaultValues() QTRY_VERIFY(obj->flow() == 0); QTRY_COMPARE(obj->isWrapEnabled(), false); QTRY_COMPARE(obj->cacheBuffer(), 0); - QTRY_COMPARE(obj->cellWidth(), 100); //### Should 100 be the default? - QTRY_COMPARE(obj->cellHeight(), 100); + QTRY_COMPARE(obj->cellWidth(), qreal(100)); //### Should 100 be the default? + QTRY_COMPARE(obj->cellHeight(), qreal(100)); delete obj; } @@ -1478,8 +1479,8 @@ void tst_QSGGridView::properties() QTRY_VERIFY(obj->flow() == 0); QTRY_COMPARE(obj->isWrapEnabled(), true); QTRY_COMPARE(obj->cacheBuffer(), 200); - QTRY_COMPARE(obj->cellWidth(), 100); - QTRY_COMPARE(obj->cellHeight(), 100); + QTRY_COMPARE(obj->cellWidth(), qreal(100)); + QTRY_COMPARE(obj->cellHeight(), qreal(100)); delete obj; } @@ -2783,6 +2784,25 @@ void tst_QSGGridView::testQtQuick11Attributes_data() << ""; } +void tst_QSGGridView::columnCount() +{ + QSGView canvas; + canvas.setSource(QUrl::fromLocalFile(SRCDIR "/data/gridview4.qml")); + canvas.show(); + canvas.requestActivateWindow(); + QTest::qWaitForWindowShown(&canvas); + + QSGGridView *view = qobject_cast<QSGGridView*>(canvas.rootObject()); + + QCOMPARE(view->cellWidth(), qreal(400)/qreal(9)); + QCOMPARE(view->cellHeight(), qreal(100)); + + QList<QSGItem*> items = findItems<QSGItem>(view, "delegate"); + QCOMPARE(items.size(), 18); + QCOMPARE(items.at(8)->y(), qreal(0)); + QCOMPARE(items.at(9)->y(), qreal(100)); +} + QSGView *tst_QSGGridView::createView() { QSGView *canvas = new QSGView(0); |