aboutsummaryrefslogtreecommitdiffstats
path: root/tests/auto/quick/qquickgridview
diff options
context:
space:
mode:
authorUlf Hermann <ulf.hermann@qt.io>2018-09-28 10:57:35 +0200
committerUlf Hermann <ulf.hermann@qt.io>2018-10-04 07:00:50 +0000
commitb2610d9d04c2a65d60b36ebf43e3a8d469c0397a (patch)
tree20b0dd669ea8eaa7f2128443def81cc2d3066aa1 /tests/auto/quick/qquickgridview
parentbd28fb093c422a802f34a9e8f8a3b031757e8920 (diff)
QQuickGridView: Respect margins
The margin has to be taken into account when calculating the positions for the dimension we are not scrolling and when calculating the number of columns available. Fixes: QTBUG-69863 Change-Id: Id2a53ced263c8926a8bfaf658376be293af3e8c9 Reviewed-by: Richard Moe Gustavsen <richard.gustavsen@qt.io>
Diffstat (limited to 'tests/auto/quick/qquickgridview')
-rw-r--r--tests/auto/quick/qquickgridview/data/margins2.qml80
-rw-r--r--tests/auto/quick/qquickgridview/tst_qquickgridview.cpp17
2 files changed, 97 insertions, 0 deletions
diff --git a/tests/auto/quick/qquickgridview/data/margins2.qml b/tests/auto/quick/qquickgridview/data/margins2.qml
new file mode 100644
index 0000000000..346933d3c9
--- /dev/null
+++ b/tests/auto/quick/qquickgridview/data/margins2.qml
@@ -0,0 +1,80 @@
+/****************************************************************************
+**
+** Copyright (C) 2018 The Qt Company Ltd.
+** Contact: https://www.qt.io/licensing/
+**
+** This file is part of the test suite of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:BSD$
+** Commercial License Usage
+** Licensees holding valid commercial Qt licenses may use this file in
+** accordance with the commercial license agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and The Qt Company. For licensing terms
+** and conditions see https://www.qt.io/terms-conditions. For further
+** information use the contact form at https://www.qt.io/contact-us.
+**
+** BSD License Usage
+** Alternatively, you may use this file under the terms of the BSD license
+** as follows:
+**
+** "Redistribution and use in source and binary forms, with or without
+** modification, are permitted provided that the following conditions are
+** met:
+** * Redistributions of source code must retain the above copyright
+** notice, this list of conditions and the following disclaimer.
+** * Redistributions in binary form must reproduce the above copyright
+** notice, this list of conditions and the following disclaimer in
+** the documentation and/or other materials provided with the
+** distribution.
+** * Neither the name of The Qt Company Ltd nor the names of its
+** contributors may be used to endorse or promote products derived
+** from this software without specific prior written permission.
+**
+**
+** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+import QtQuick 2.7
+
+Item {
+ id: root
+ height: 1000
+ width: 1000
+
+ GridView {
+ id: grid
+ objectName: "grid"
+ height: 500
+ width: parent.width
+ topMargin: 20
+ leftMargin: 200
+ rightMargin: 200
+ bottomMargin: 30
+ cellWidth: (grid.width - grid.leftMargin - grid.rightMargin) / 3
+ model: 9
+ delegate: Rectangle {
+ border.width: 1
+ objectName: "child"
+ width: grid.cellWidth
+ height: 100
+ Text {
+ anchors.centerIn: parent
+ text: modelData
+ }
+ }
+ }
+}
diff --git a/tests/auto/quick/qquickgridview/tst_qquickgridview.cpp b/tests/auto/quick/qquickgridview/tst_qquickgridview.cpp
index 7deed8c5a8..301ec43cb5 100644
--- a/tests/auto/quick/qquickgridview/tst_qquickgridview.cpp
+++ b/tests/auto/quick/qquickgridview/tst_qquickgridview.cpp
@@ -4248,6 +4248,23 @@ void tst_QQuickGridView::margins()
delete window;
}
+ {
+ QQuickView *window = createView();
+
+ window->setSource(testFileUrl("margins2.qml"));
+ window->show();
+ qApp->processEvents();
+
+ QQuickGridView *gridview = findItem<QQuickGridView>(window->rootObject(), "grid");
+ QVERIFY(gridview != nullptr);
+ QQuickItem *contentItem = gridview->contentItem();
+ QVERIFY(contentItem != nullptr);
+ QTRY_COMPARE(QQuickItemPrivate::get(gridview)->polishScheduled, false);
+ QCOMPARE(contentItem->x(), 200);
+ QCOMPARE(contentItem->y(), 20);
+
+ delete window;
+ }
}
void tst_QQuickGridView::creationContext()