aboutsummaryrefslogtreecommitdiffstats
path: root/tests
diff options
context:
space:
mode:
authorAlbert Astals Cid <albert.astals@canonical.com>2013-05-28 10:28:56 +0200
committerThe Qt Project <gerrit-noreply@qt-project.org>2013-07-24 11:30:40 +0200
commit3f01f6ff0396148e753066f481b3828522a94514 (patch)
tree0c1b5223c5d213818c5e1dd6852a913b3278ba89 /tests
parent36e4dbf5bf8f84e86133e001158ed72c0712803b (diff)
Resizing items out of the list viewport should not change the viewport
Consider the old geometry, not the new one to check if an item was outside the viewport or not Change-Id: I108412d560faf86130044f3d091254c07af0c004 Reviewed-by: Alan Alpert <aalpert@blackberry.com>
Diffstat (limited to 'tests')
-rw-r--r--tests/auto/quick/qquicklistview/data/outsideViewportChangeNotAffectingView.qml67
-rw-r--r--tests/auto/quick/qquicklistview/tst_qquicklistview.cpp38
2 files changed, 105 insertions, 0 deletions
diff --git a/tests/auto/quick/qquicklistview/data/outsideViewportChangeNotAffectingView.qml b/tests/auto/quick/qquicklistview/data/outsideViewportChangeNotAffectingView.qml
new file mode 100644
index 0000000000..7903c392d1
--- /dev/null
+++ b/tests/auto/quick/qquicklistview/data/outsideViewportChangeNotAffectingView.qml
@@ -0,0 +1,67 @@
+/****************************************************************************
+**
+** Copyright (C) 2013 Digia Plc and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/legal
+**
+** This file is part of the test suite of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:BSD$
+** 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 Digia Plc and its Subsidiary(-ies) 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.1
+import QtTest 1.0
+
+Item {
+ function resizeThirdItem(size) {
+ resizingListModel.setProperty(3, "size", size)
+ }
+
+ ListView {
+ width: 300
+ height: 542
+ model: ListModel {
+ id: resizingListModel
+ ListElement { size: 300; }
+ ListElement { size: 300; }
+ ListElement { size: 300; }
+ ListElement { size: 300; }
+ ListElement { size: 300; }
+ ListElement { size: 300; }
+ }
+ delegate: Rectangle {
+ width: parent.width
+ color: index % 2 == 0 ? "red" : "blue"
+ height: size
+ }
+ }
+}
diff --git a/tests/auto/quick/qquicklistview/tst_qquicklistview.cpp b/tests/auto/quick/qquicklistview/tst_qquicklistview.cpp
index bec61eaccb..2268f0754c 100644
--- a/tests/auto/quick/qquicklistview/tst_qquicklistview.cpp
+++ b/tests/auto/quick/qquicklistview/tst_qquicklistview.cpp
@@ -209,6 +209,7 @@ private slots:
void defaultHighlightMoveDuration();
void accessEmptyCurrentItem_QTBUG_30227();
void delayedChanges_QTBUG_30555();
+ void outsideViewportChangeNotAffectingView();
private:
template <class T> void items(const QUrl &source);
@@ -6880,6 +6881,43 @@ void tst_QQuickListView::delayedChanges_QTBUG_30555()
delete window;
}
+void tst_QQuickListView::outsideViewportChangeNotAffectingView()
+{
+ QQuickView *window = createView();
+ window->setSource(testFileUrl("outsideViewportChangeNotAffectingView.qml"));
+
+ QQuickListView *listview = window->rootObject()->findChild<QQuickListView*>();
+ QTRY_VERIFY(listview != 0);
+
+ window->show();
+ QVERIFY(QTest::qWaitForWindowExposed(window));
+
+ flick(window, QPoint(20, 200), QPoint(20, 20), 10);
+
+ QTRY_COMPARE(listview->isFlicking(), false);
+
+ QTRY_COMPARE(listview->indexAt(0, listview->contentY()), 4);
+ QTRY_COMPARE(listview->itemAt(0, listview->contentY())->y(), 1200.);
+
+ QMetaObject::invokeMethod(window->rootObject(), "resizeThirdItem", Q_ARG(QVariant, 290));
+ QTRY_COMPARE(listview->indexAt(0, listview->contentY()), 4);
+ QTRY_COMPARE(listview->itemAt(0, listview->contentY())->y(), 1200.);
+
+ QMetaObject::invokeMethod(window->rootObject(), "resizeThirdItem", Q_ARG(QVariant, 300));
+ QTRY_COMPARE(listview->indexAt(0, listview->contentY()), 4);
+ QTRY_COMPARE(listview->itemAt(0, listview->contentY())->y(), 1200.);
+
+ QMetaObject::invokeMethod(window->rootObject(), "resizeThirdItem", Q_ARG(QVariant, 310));
+ QTRY_COMPARE(listview->indexAt(0, listview->contentY()), 4);
+ QTRY_COMPARE(listview->itemAt(0, listview->contentY())->y(), 1200.);
+
+ QMetaObject::invokeMethod(window->rootObject(), "resizeThirdItem", Q_ARG(QVariant, 400));
+ QTRY_COMPARE(listview->indexAt(0, listview->contentY()), 4);
+ QTRY_COMPARE(listview->itemAt(0, listview->contentY())->y(), 1200.);
+
+ delete window;
+}
+
QTEST_MAIN(tst_QQuickListView)
#include "tst_qquicklistview.moc"