diff options
author | Qt Forward Merge Bot <qt_forward_merge_bot@qt-project.org> | 2019-12-05 01:00:07 +0100 |
---|---|---|
committer | Ulf Hermann <ulf.hermann@qt.io> | 2019-12-05 10:09:17 +0100 |
commit | 88490da44e8afa0f4d03ca79bcc928a14412ef99 (patch) | |
tree | 41b40fe0f36c5ed49d0b8a2ce54421eb4dfbfd3b /tests/auto/quick/qquicklistview | |
parent | 6ad3445f1e159d9beea936b66d267dcaacdc5d6c (diff) | |
parent | e2af7c3b37095e601a84cc52de69a99af8e5d3a2 (diff) |
Merge remote-tracking branch 'origin/5.14' into 5.15
Conflicts:
tests/auto/quick/qquicklistview/tst_qquicklistview.cpp
tests/auto/quick/qquicktableview/tst_qquicktableview.cpp
Change-Id: Ib46bc1c717cf524eea2fb3d876810c8d55747c91
Diffstat (limited to 'tests/auto/quick/qquicklistview')
-rw-r--r-- | tests/auto/quick/qquicklistview/data/moveObjectModelItemToAnotherObjectModel.qml | 140 | ||||
-rw-r--r-- | tests/auto/quick/qquicklistview/tst_qquicklistview.cpp | 35 |
2 files changed, 175 insertions, 0 deletions
diff --git a/tests/auto/quick/qquicklistview/data/moveObjectModelItemToAnotherObjectModel.qml b/tests/auto/quick/qquicklistview/data/moveObjectModelItemToAnotherObjectModel.qml new file mode 100644 index 0000000000..ebdebeb449 --- /dev/null +++ b/tests/auto/quick/qquicklistview/data/moveObjectModelItemToAnotherObjectModel.qml @@ -0,0 +1,140 @@ +/**************************************************************************** +** +** Copyright (C) 2019 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.14 +import QtQml.Models 2.14 + +Item { + id: root + width: 400 + height: 400 + + readonly property int rectCount: 3 + property var rectColors: ["red", "green", "blue"] + + property alias listView1: listView1 + property alias listView2: listView2 + + function moveRedRectToModel2() { + var appItem = objectModel1.get(0) + objectModel1.remove(0, 1) + objectModel2.insert(0, appItem) + } + + function moveRedRectToModel1() { + var appItem = objectModel2.get(0) + objectModel2.remove(0, 1) + objectModel1.insert(0, appItem) + } + + ObjectModel { + id: objectModel1 + objectName: "objectModel1" + + Component.onCompleted: { + for (var i = 0; i < root.rectCount; i++) { + var outerRect = rectComponent.createObject(null, { + "objectName": root.rectColors[i] + "Rect", + "color": root.rectColors[i] + }) + objectModel1.append(outerRect) + } + } + } + + ObjectModel { + id: objectModel2 + objectName: "objectModel2" + } + + ListView { + id: listView1 + objectName: "listView1" + anchors.left: parent.left + anchors.top: parent.top + height: 100 + width: 100 + anchors.margins: 20 + clip: true + cacheBuffer: 0 + model: objectModel1 + orientation: ListView.Horizontal + spacing: 20 + + Component.onCompleted: contentItem.objectName = "listView1ContentItem" + } + + ListView { + id: listView2 + objectName: "listView2" + anchors.right: parent.right + anchors.top: parent.top + height: 100 + width: 100 + anchors.margins: 20 + clip: true + cacheBuffer: 0 + model: objectModel2 + orientation: ListView.Horizontal + spacing: 20 + + Component.onCompleted: contentItem.objectName = "listView2ContentItem" + } + + Component { + id: rectComponent + + Rectangle { + height: 100 + width: 100 + opacity: 0.2 + } + } +} diff --git a/tests/auto/quick/qquicklistview/tst_qquicklistview.cpp b/tests/auto/quick/qquicklistview/tst_qquicklistview.cpp index 4e21edbcb4..4c147b753b 100644 --- a/tests/auto/quick/qquicklistview/tst_qquicklistview.cpp +++ b/tests/auto/quick/qquicklistview/tst_qquicklistview.cpp @@ -288,6 +288,7 @@ private slots: void reuse_reuseIsOffByDefault(); void reuse_checkThatItemsAreReused(); + void moveObjectModelItemToAnotherObjectModel(); private: template <class T> void items(const QUrl &source); @@ -9376,6 +9377,40 @@ void tst_QQuickListView::dragOverFloatingHeaderOrFooter() // QTBUG-74046 releaseView(window); } +void tst_QQuickListView::moveObjectModelItemToAnotherObjectModel() +{ + QScopedPointer<QQuickView> window(createView()); + window->setSource(testFileUrl("moveObjectModelItemToAnotherObjectModel.qml")); + QCOMPARE(window->status(), QQuickView::Ready); + window->show(); + QVERIFY(QTest::qWaitForWindowExposed(window.data())); + + QObject *root = window->rootObject(); + QVERIFY(root); + + const QQuickListView *listView1 = root->property("listView1").value<QQuickListView*>(); + QVERIFY(listView1); + + const QQuickListView *listView2 = root->property("listView2").value<QQuickListView*>(); + QVERIFY(listView2); + + const QQuickItem *redRect = listView1->itemAtIndex(0); + QVERIFY(redRect); + QCOMPARE(redRect->objectName(), QString::fromLatin1("redRect")); + + QVERIFY(QMetaObject::invokeMethod(root, "moveRedRectToModel2")); + QVERIFY(QQuickTest::qIsPolishScheduled(listView2)); + QVERIFY(QQuickTest::qWaitForItemPolished(listView2)); + QVERIFY(redRect->isVisible()); + QVERIFY(!QQuickItemPrivate::get(redRect)->culled); + + QVERIFY(QMetaObject::invokeMethod(root, "moveRedRectToModel1")); + QVERIFY(QQuickTest::qIsPolishScheduled(listView1)); + QVERIFY(QQuickTest::qWaitForItemPolished(listView1)); + QVERIFY(redRect->isVisible()); + QVERIFY(!QQuickItemPrivate::get(redRect)->culled); +} + QTEST_MAIN(tst_QQuickListView) #include "tst_qquicklistview.moc" |