aboutsummaryrefslogtreecommitdiffstats
path: root/tests/auto
diff options
context:
space:
mode:
Diffstat (limited to 'tests/auto')
-rw-r--r--tests/auto/qtquick2/qquicklistview/data/Page.qml10
-rw-r--r--tests/auto/qtquick2/qquicklistview/data/margins2.qml29
-rw-r--r--tests/auto/qtquick2/qquicklistview/tst_qquicklistview.cpp57
3 files changed, 96 insertions, 0 deletions
diff --git a/tests/auto/qtquick2/qquicklistview/data/Page.qml b/tests/auto/qtquick2/qquicklistview/data/Page.qml
new file mode 100644
index 0000000000..abe4364315
--- /dev/null
+++ b/tests/auto/qtquick2/qquicklistview/data/Page.qml
@@ -0,0 +1,10 @@
+import QtQuick 2.0
+
+Item {
+ anchors.fill: parent
+ default property alias contentArea: contentItem.data
+ Item {
+ id: contentItem
+ anchors.fill: parent
+ }
+}
diff --git a/tests/auto/qtquick2/qquicklistview/data/margins2.qml b/tests/auto/qtquick2/qquicklistview/data/margins2.qml
new file mode 100644
index 0000000000..e11c803c4b
--- /dev/null
+++ b/tests/auto/qtquick2/qquicklistview/data/margins2.qml
@@ -0,0 +1,29 @@
+import QtQuick 2.0
+
+Item {
+ width: 200; height: 200
+ Page {
+ Rectangle {
+ anchors.fill: parent
+ color: "lightsteelblue"
+ }
+ ListView {
+ objectName: "listview"
+ topMargin: 20
+ bottomMargin: 20
+ leftMargin: 20
+ rightMargin: 20
+ anchors.fill: parent
+
+ model: 20
+ delegate: Rectangle {
+ color: "skyblue"
+ width: 60; height: 60
+ Text {
+ id: txt
+ text: "test" + index
+ }
+ }
+ }
+ }
+}
diff --git a/tests/auto/qtquick2/qquicklistview/tst_qquicklistview.cpp b/tests/auto/qtquick2/qquicklistview/tst_qquicklistview.cpp
index 4873a230b9..9dd72aeeaf 100644
--- a/tests/auto/qtquick2/qquicklistview/tst_qquicklistview.cpp
+++ b/tests/auto/qtquick2/qquicklistview/tst_qquicklistview.cpp
@@ -152,6 +152,8 @@ private slots:
void rightToLeft();
void test_mirroring();
void margins();
+ void marginsResize();
+ void marginsResize_data();
void creationContext();
void snapToItem_data();
void snapToItem();
@@ -4287,6 +4289,61 @@ void tst_QQuickListView::margins()
delete canvas;
}
+// QTBUG-24028
+void tst_QQuickListView::marginsResize()
+{
+ QFETCH(QQuickListView::Orientation, orientation);
+ QFETCH(Qt::LayoutDirection, layoutDirection);
+ QFETCH(qreal, start);
+ QFETCH(qreal, end);
+
+ QQuickView *canvas = createView();
+
+ canvas->setSource(testFileUrl("margins2.qml"));
+ canvas->show();
+ qApp->processEvents();
+
+ QQuickListView *listview = findItem<QQuickListView>(canvas->rootObject(), "listview");
+ QTRY_VERIFY(listview != 0);
+
+ listview->setOrientation(orientation);
+ listview->setLayoutDirection(layoutDirection);
+
+ // view is resized after componentCompleted - top margin should still be visible
+ if (orientation == QQuickListView::Vertical)
+ QCOMPARE(listview->contentY(), start);
+ else
+ QCOMPARE(listview->contentX(), start);
+
+ // move to last index and ensure bottom margin is visible.
+ listview->setCurrentIndex(19);
+ if (orientation == QQuickListView::Vertical)
+ QTRY_COMPARE(listview->contentY(), end);
+ else
+ QTRY_COMPARE(listview->contentX(), end);
+
+ // back to top - top margin should be visible.
+ listview->setCurrentIndex(0);
+ if (orientation == QQuickListView::Vertical)
+ QTRY_COMPARE(listview->contentY(), start);
+ else
+ QTRY_COMPARE(listview->contentX(), start);
+
+ delete canvas;
+}
+
+void tst_QQuickListView::marginsResize_data()
+{
+ QTest::addColumn<QQuickListView::Orientation>("orientation");
+ QTest::addColumn<Qt::LayoutDirection>("layoutDirection");
+ QTest::addColumn<qreal>("start");
+ QTest::addColumn<qreal>("end");
+
+ QTest::newRow("vertical") << QQuickListView::Vertical << Qt::LeftToRight << -20.0 << 1020.0;
+ QTest::newRow("horizontal") << QQuickListView::Horizontal << Qt::LeftToRight << -20.0 << 1020.0;
+ QTest::newRow("horizontal, rtl") << QQuickListView::Horizontal << Qt::RightToLeft << -180.0 << -1220.0;
+}
+
void tst_QQuickListView::snapToItem_data()
{
QTest::addColumn<QQuickListView::Orientation>("orientation");