summaryrefslogtreecommitdiffstats
path: root/tests/auto/declarative/qdeclarativegridview/tst_qdeclarativegridview.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'tests/auto/declarative/qdeclarativegridview/tst_qdeclarativegridview.cpp')
-rw-r--r--tests/auto/declarative/qdeclarativegridview/tst_qdeclarativegridview.cpp54
1 files changed, 50 insertions, 4 deletions
diff --git a/tests/auto/declarative/qdeclarativegridview/tst_qdeclarativegridview.cpp b/tests/auto/declarative/qdeclarativegridview/tst_qdeclarativegridview.cpp
index a1edc53..385d6f5 100644
--- a/tests/auto/declarative/qdeclarativegridview/tst_qdeclarativegridview.cpp
+++ b/tests/auto/declarative/qdeclarativegridview/tst_qdeclarativegridview.cpp
@@ -703,6 +703,11 @@ void tst_QDeclarativeGridView::currentIndex()
QCOMPARE(gridview->highlightItem()->x(), hlPosX);
QCOMPARE(gridview->highlightItem()->y(), hlPosY);
+ // insert item before currentIndex
+ gridview->setCurrentIndex(28);
+ model.insertItem(0, "Foo", "1111");
+ QCOMPARE(canvas->rootObject()->property("current").toInt(), 29);
+
delete canvas;
}
@@ -944,7 +949,7 @@ void tst_QDeclarativeGridView::positionViewAtIndex()
}
// Position on a currently visible item
- gridview->positionViewAtIndex(4);
+ gridview->positionViewAtIndex(4, QDeclarativeGridView::Beginning);
QCOMPARE(gridview->contentY(), 60.);
// Confirm items positioned correctly
@@ -958,7 +963,7 @@ void tst_QDeclarativeGridView::positionViewAtIndex()
}
// Position on an item beyond the visible items
- gridview->positionViewAtIndex(21);
+ gridview->positionViewAtIndex(21, QDeclarativeGridView::Beginning);
QCOMPARE(gridview->contentY(), 420.);
// Confirm items positioned correctly
@@ -972,7 +977,7 @@ void tst_QDeclarativeGridView::positionViewAtIndex()
}
// Position on an item that would leave empty space if positioned at the top
- gridview->positionViewAtIndex(31);
+ gridview->positionViewAtIndex(31, QDeclarativeGridView::Beginning);
QCOMPARE(gridview->contentY(), 520.);
// Confirm items positioned correctly
@@ -986,7 +991,7 @@ void tst_QDeclarativeGridView::positionViewAtIndex()
}
// Position at the beginning again
- gridview->positionViewAtIndex(0);
+ gridview->positionViewAtIndex(0, QDeclarativeGridView::Beginning);
QCOMPARE(gridview->contentY(), 0.);
// Confirm items positioned correctly
@@ -999,6 +1004,47 @@ void tst_QDeclarativeGridView::positionViewAtIndex()
QCOMPARE(item->y(), (i/3)*60.);
}
+ // Position at End
+ gridview->positionViewAtIndex(30, QDeclarativeGridView::End);
+ QCOMPARE(gridview->contentY(), 340.);
+
+ // Position in Center
+ gridview->positionViewAtIndex(15, QDeclarativeGridView::Center);
+ QCOMPARE(gridview->contentY(), 170.);
+
+ // Ensure at least partially visible
+ gridview->positionViewAtIndex(15, QDeclarativeGridView::Visible);
+ QCOMPARE(gridview->contentY(), 170.);
+
+ gridview->setContentY(302);
+ gridview->positionViewAtIndex(15, QDeclarativeGridView::Visible);
+ QCOMPARE(gridview->contentY(), 302.);
+
+ gridview->setContentY(360);
+ gridview->positionViewAtIndex(15, QDeclarativeGridView::Visible);
+ QCOMPARE(gridview->contentY(), 300.);
+
+ gridview->setContentY(60);
+ gridview->positionViewAtIndex(20, QDeclarativeGridView::Visible);
+ QCOMPARE(gridview->contentY(), 60.);
+
+ gridview->setContentY(20);
+ gridview->positionViewAtIndex(20, QDeclarativeGridView::Visible);
+ QCOMPARE(gridview->contentY(), 100.);
+
+ // Ensure completely visible
+ gridview->setContentY(120);
+ gridview->positionViewAtIndex(20, QDeclarativeGridView::Contain);
+ QCOMPARE(gridview->contentY(), 120.);
+
+ gridview->setContentY(302);
+ gridview->positionViewAtIndex(15, QDeclarativeGridView::Contain);
+ QCOMPARE(gridview->contentY(), 300.);
+
+ gridview->setContentY(60);
+ gridview->positionViewAtIndex(20, QDeclarativeGridView::Contain);
+ QCOMPARE(gridview->contentY(), 100.);
+
delete canvas;
}