diff options
Diffstat (limited to 'tests/auto/quick/qquicklistview')
43 files changed, 685 insertions, 1531 deletions
diff --git a/tests/auto/quick/qquicklistview/BLACKLIST b/tests/auto/quick/qquicklistview/BLACKLIST index 6ef69550a4..e4da77acba 100644 --- a/tests/auto/quick/qquicklistview/BLACKLIST +++ b/tests/auto/quick/qquicklistview/BLACKLIST @@ -4,11 +4,12 @@ opensuse-leap #QTBUG-53863 [populateTransitions] opensuse-42.1 +# QTBUG-75202 [contentHeightWithDelayRemove] -macos -#QTBUG-75960 -#QTBUG-76652 -[currentIndex] -macos -opensuse-leap -ubuntu-18.04 +macos ci + +# QTBUG-103089 +[QTBUG_48044_currentItemNotVisibleAfterTransition] +android +[contentHeightWithDelayRemove] +android diff --git a/tests/auto/quick/qquicklistview/CMakeLists.txt b/tests/auto/quick/qquicklistview/CMakeLists.txt index 761d515eaf..cee287ae41 100644 --- a/tests/auto/quick/qquicklistview/CMakeLists.txt +++ b/tests/auto/quick/qquicklistview/CMakeLists.txt @@ -1,9 +1,18 @@ +# Copyright (C) 2022 The Qt Company Ltd. +# SPDX-License-Identifier: BSD-3-Clause + # Generated from qquicklistview.pro. ##################################################################### ## tst_qquicklistview Test: ##################################################################### +if(NOT QT_BUILD_STANDALONE_TESTS AND NOT QT_BUILDING_QT) + cmake_minimum_required(VERSION 3.16) + project(tst_qquicklistview LANGUAGES CXX) + find_package(Qt6BuildInternals REQUIRED COMPONENTS STANDALONE_TEST) +endif() + # Collect test data file(GLOB_RECURSE test_data_glob RELATIVE ${CMAKE_CURRENT_SOURCE_DIR} @@ -12,20 +21,12 @@ list(APPEND test_data ${test_data_glob}) qt_internal_add_test(tst_qquicklistview SOURCES - ../../shared/util.cpp ../../shared/util.h - ../shared/geometrytestutil.cpp ../shared/geometrytestutil.h - ../shared/viewtestutil.cpp ../shared/viewtestutil.h - ../shared/visualtestutil.cpp ../shared/visualtestutil.h incrementalmodel.cpp incrementalmodel.h proxytestinnermodel.cpp proxytestinnermodel.h randomsortmodel.cpp randomsortmodel.h reusemodel.h tst_qquicklistview.cpp - DEFINES - QT_QMLTEST_DATADIR=\\\"${CMAKE_CURRENT_SOURCE_DIR}/data\\\" - INCLUDE_DIRECTORIES - ../../shared - PUBLIC_LIBRARIES + LIBRARIES Qt::CorePrivate Qt::Gui Qt::GuiPrivate @@ -33,6 +34,7 @@ qt_internal_add_test(tst_qquicklistview Qt::QmlPrivate Qt::QuickPrivate Qt::QuickTest + Qt::QuickTestUtilsPrivate TESTDATA ${test_data} ) @@ -45,10 +47,10 @@ qt_internal_add_test(tst_qquicklistview qt_internal_extend_target(tst_qquicklistview CONDITION ANDROID OR IOS DEFINES - QT_QMLTEST_DATADIR=\\\":/data\\\" + QT_QMLTEST_DATADIR=":/data" ) qt_internal_extend_target(tst_qquicklistview CONDITION NOT ANDROID AND NOT IOS DEFINES - QT_QMLTEST_DATADIR=\\\"${CMAKE_CURRENT_SOURCE_DIR}/data\\\" + QT_QMLTEST_DATADIR="${CMAKE_CURRENT_SOURCE_DIR}/data" ) diff --git a/tests/auto/quick/qquicklistview/data/addoncompleted.qml b/tests/auto/quick/qquicklistview/data/addoncompleted.qml index 2341295868..34ee459aa4 100644 --- a/tests/auto/quick/qquicklistview/data/addoncompleted.qml +++ b/tests/auto/quick/qquicklistview/data/addoncompleted.qml @@ -1,52 +1,5 @@ -/**************************************************************************** -** -** Copyright (C) 2017 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$ -** -****************************************************************************/ +// Copyright (C) 2017 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only import QtQuick 2.9 diff --git a/tests/auto/quick/qquicklistview/data/appendDuringScrollDown.qml b/tests/auto/quick/qquicklistview/data/appendDuringScrollDown.qml index af35c29143..6ba6480297 100644 --- a/tests/auto/quick/qquicklistview/data/appendDuringScrollDown.qml +++ b/tests/auto/quick/qquicklistview/data/appendDuringScrollDown.qml @@ -1,10 +1,11 @@ import QtQuick 2.6 ListView { + id: listView width: 320; height: 240 focus: true delegate: Text { - height: 40; width: parent.width + height: 40; width: listView.width text: model.text verticalAlignment: Text.AlignVCenter horizontalAlignment: Text.AlignHCenter diff --git a/tests/auto/quick/qquicklistview/data/attachedProperties.qml b/tests/auto/quick/qquicklistview/data/attachedProperties.qml index 09714b2c6e..72fdc009e0 100644 --- a/tests/auto/quick/qquicklistview/data/attachedProperties.qml +++ b/tests/auto/quick/qquicklistview/data/attachedProperties.qml @@ -1,52 +1,5 @@ -/**************************************************************************** -** -** Copyright (C) 2017 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$ -** -****************************************************************************/ +// Copyright (C) 2017 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only import QtQuick 2.0 diff --git a/tests/auto/quick/qquicklistview/data/contentHeightWithDelayRemove.qml b/tests/auto/quick/qquicklistview/data/contentHeightWithDelayRemove.qml index 06011519b2..f74075f9c7 100644 --- a/tests/auto/quick/qquicklistview/data/contentHeightWithDelayRemove.qml +++ b/tests/auto/quick/qquicklistview/data/contentHeightWithDelayRemove.qml @@ -35,9 +35,12 @@ Item { delegate: Text { id: wrapper height: 100 - text: index + listView.count + text: index ListView.delayRemove: listView.useDelayRemove - ListView.onRemove: SequentialAnimation { + ListView.onRemove: sequentialAnimation.start() + + SequentialAnimation { + id: sequentialAnimation PauseAnimation { duration: wrapper.ListView.delayRemove ? 100 : 0 } PropertyAction { target: wrapper; property: "ListView.delayRemove"; value: false } } diff --git a/tests/auto/quick/qquicklistview/data/displayMargin.qml b/tests/auto/quick/qquicklistview/data/displayMargin.qml index aafbb4235f..64b668326f 100644 --- a/tests/auto/quick/qquicklistview/data/displayMargin.qml +++ b/tests/auto/quick/qquicklistview/data/displayMargin.qml @@ -1,30 +1,5 @@ -/**************************************************************************** -** -** Copyright (C) 2016 Jolla Ltd. -** Contact: https://www.qt.io/licensing/ -** -** This file is part of the test suite of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:GPL-EXCEPT$ -** 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. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU -** General Public License version 3 as published by the Free Software -** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT -** included in the packaging of this file. Please review the following -** information to ensure the GNU General Public License requirements will -** be met: https://www.gnu.org/licenses/gpl-3.0.html. -** -** $QT_END_LICENSE$ -** -****************************************************************************/ +// Copyright (C) 2016 Jolla Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only import QtQuick 2.3 @@ -44,7 +19,7 @@ Item { model: 100 delegate: Rectangle { objectName: "delegate" - width: parent.width + width: view.width height: 25 color: index % 2 ? "steelblue" : "lightsteelblue" Text { diff --git a/tests/auto/quick/qquicklistview/data/flickBothDirections.qml b/tests/auto/quick/qquicklistview/data/flickBothDirections.qml index b491981edb..a9905adba5 100644 --- a/tests/auto/quick/qquicklistview/data/flickBothDirections.qml +++ b/tests/auto/quick/qquicklistview/data/flickBothDirections.qml @@ -1,52 +1,5 @@ -/**************************************************************************** -** -** Copyright (C) 2017 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$ -** -****************************************************************************/ +// Copyright (C) 2017 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only import QtQuick 2.9 Rectangle { diff --git a/tests/auto/quick/qquicklistview/data/headerCrash.qml b/tests/auto/quick/qquicklistview/data/headerCrash.qml index 124fa894f2..972ecb2906 100644 --- a/tests/auto/quick/qquicklistview/data/headerCrash.qml +++ b/tests/auto/quick/qquicklistview/data/headerCrash.qml @@ -12,7 +12,7 @@ ListView { } delegate: Rectangle { - width: parent.width; height: 20 + width: myList.width; height: 20 color: index % 2 ? "green" : "red" } diff --git a/tests/auto/quick/qquicklistview/data/listview-itematindex.qml b/tests/auto/quick/qquicklistview/data/listview-itematindex.qml index fba8b11933..2194f1edff 100644 --- a/tests/auto/quick/qquicklistview/data/listview-itematindex.qml +++ b/tests/auto/quick/qquicklistview/data/listview-itematindex.qml @@ -1,13 +1,14 @@ import QtQuick 2.0 ListView { + id: listView width: 400 height: 400 focus: true model: 3 delegate: Text { - width: parent.width + width: listView.width height: 10 property int idx: index text: index diff --git a/tests/auto/quick/qquicklistview/data/listview-sections_delegate.qml b/tests/auto/quick/qquicklistview/data/listview-sections_delegate.qml index 11da286f4d..0ac8adc2b0 100644 --- a/tests/auto/quick/qquicklistview/data/listview-sections_delegate.qml +++ b/tests/auto/quick/qquicklistview/data/listview-sections_delegate.qml @@ -17,6 +17,17 @@ Rectangle { property string prevSection: ListView.previousSection height: 20; width: 240 + + ListView.onRemove: sequentialAnimation.start() + + SequentialAnimation { + id: sequentialAnimation + + PropertyAction { target: wrapper; property: "ListView.delayRemove"; value: true } + NumberAnimation { target: wrapper; property: "height"; to: 0; duration: 100; easing.type: Easing.InOutQuad } + PropertyAction { target: wrapper; property: "ListView.delayRemove"; value: false } + } + Rectangle { height: 20 width: parent.width @@ -46,11 +57,6 @@ Rectangle { text: wrapper.y } } - ListView.onRemove: SequentialAnimation { - PropertyAction { target: wrapper; property: "ListView.delayRemove"; value: true } - NumberAnimation { target: wrapper; property: "height"; to: 0; duration: 100; easing.type: Easing.InOutQuad } - PropertyAction { target: wrapper; property: "ListView.delayRemove"; value: false } - } } } ] diff --git a/tests/auto/quick/qquicklistview/data/listview-sections_delegate_required.qml b/tests/auto/quick/qquicklistview/data/listview-sections_delegate_required.qml index 18ce406e3f..6b4dd733d2 100644 --- a/tests/auto/quick/qquicklistview/data/listview-sections_delegate_required.qml +++ b/tests/auto/quick/qquicklistview/data/listview-sections_delegate_required.qml @@ -17,6 +17,16 @@ Rectangle { property string prevSection: ListView.previousSection height: 20; width: 240 + + ListView.onRemove: sequentialAnimation.start() + + SequentialAnimation { + id: sequentialAnimation + PropertyAction { target: wrapper; property: "ListView.delayRemove"; value: true } + NumberAnimation { target: wrapper; property: "height"; to: 0; duration: 100; easing.type: Easing.InOutQuad } + PropertyAction { target: wrapper; property: "ListView.delayRemove"; value: false } + } + Rectangle { height: 20 width: parent.width @@ -46,11 +56,6 @@ Rectangle { text: wrapper.y } } - ListView.onRemove: SequentialAnimation { - PropertyAction { target: wrapper; property: "ListView.delayRemove"; value: true } - NumberAnimation { target: wrapper; property: "height"; to: 0; duration: 100; easing.type: Easing.InOutQuad } - PropertyAction { target: wrapper; property: "ListView.delayRemove"; value: false } - } } } ] diff --git a/tests/auto/quick/qquicklistview/data/listviewtest-package.qml b/tests/auto/quick/qquicklistview/data/listviewtest-package.qml index c26bbece03..bc3dfa0843 100644 --- a/tests/auto/quick/qquicklistview/data/listviewtest-package.qml +++ b/tests/auto/quick/qquicklistview/data/listviewtest-package.qml @@ -79,7 +79,20 @@ Rectangle { objectName: "wrapper" height: 20 width: 240 + color: ListView.isCurrentItem ? "lightsteelblue" : "white" + Package.name: "package" + + ListView.onRemove: sequentialAnimation.start() + + SequentialAnimation { + id: sequentialAnimation + PropertyAction { target: wrapper; property: "ListView.delayRemove"; value: true } + NumberAnimation { target: wrapper; property: "scale"; to: 0; duration: 250; easing.type: "InOutQuad" } + PropertyAction { target: wrapper; property: "ListView.delayRemove"; value: false } + + } + Text { text: index } @@ -99,13 +112,6 @@ Rectangle { x: 200 text: wrapper.y } - color: ListView.isCurrentItem ? "lightsteelblue" : "white" - ListView.onRemove: SequentialAnimation { - PropertyAction { target: wrapper; property: "ListView.delayRemove"; value: true } - NumberAnimation { target: wrapper; property: "scale"; to: 0; duration: 250; easing.type: "InOutQuad" } - PropertyAction { target: wrapper; property: "ListView.delayRemove"; value: false } - - } } } }, diff --git a/tests/auto/quick/qquicklistview/data/moveObjectModelItemToAnotherObjectModel.qml b/tests/auto/quick/qquicklistview/data/moveObjectModelItemToAnotherObjectModel.qml index ebdebeb449..6f5160f13d 100644 --- a/tests/auto/quick/qquicklistview/data/moveObjectModelItemToAnotherObjectModel.qml +++ b/tests/auto/quick/qquicklistview/data/moveObjectModelItemToAnotherObjectModel.qml @@ -1,52 +1,5 @@ -/**************************************************************************** -** -** 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$ -** -****************************************************************************/ +// Copyright (C) 2019 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only import QtQuick 2.14 import QtQml.Models 2.14 diff --git a/tests/auto/quick/qquicklistview/data/negativeDisplayMargin.qml b/tests/auto/quick/qquicklistview/data/negativeDisplayMargin.qml index 380fd500dc..d34069d721 100644 --- a/tests/auto/quick/qquicklistview/data/negativeDisplayMargin.qml +++ b/tests/auto/quick/qquicklistview/data/negativeDisplayMargin.qml @@ -1,30 +1,5 @@ -/**************************************************************************** -** -** Copyright (C) 2016 Canonical Limited and/or its subsidiary(-ies). -** Contact: https://www.qt.io/licensing/ -** -** This file is part of the test suite of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:GPL-EXCEPT$ -** 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. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU -** General Public License version 3 as published by the Free Software -** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT -** included in the packaging of this file. Please review the following -** information to ensure the GNU General Public License requirements will -** be met: https://www.gnu.org/licenses/gpl-3.0.html. -** -** $QT_END_LICENSE$ -** -****************************************************************************/ +// Copyright (C) 2016 Canonical Limited and/or its subsidiary(-ies). +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only import QtQuick 2.3 @@ -88,8 +63,8 @@ ListView { onHeightChanged: updatedDelegateCreationRange(); Connections { target: list - onContentYChanged: updatedDelegateCreationRange(); - onHeightChanged: updatedDelegateCreationRange(); + function onContentYChanged() { updatedDelegateCreationRange(); } + function onHeightChanged() { updatedDelegateCreationRange(); } } } diff --git a/tests/auto/quick/qquicklistview/data/objectModelCulling.qml b/tests/auto/quick/qquicklistview/data/objectModelCulling.qml index c0a70ec485..9ca79ec8e4 100644 --- a/tests/auto/quick/qquicklistview/data/objectModelCulling.qml +++ b/tests/auto/quick/qquicklistview/data/objectModelCulling.qml @@ -3,6 +3,7 @@ import QtQuick 2.12 import QtQml.Models 2.12 Item { + anchors.fill: parent ObjectModel { id: model1 diff --git a/tests/auto/quick/qquicklistview/data/outsideViewportChangeNotAffectingView.qml b/tests/auto/quick/qquicklistview/data/outsideViewportChangeNotAffectingView.qml index e0acaf49e4..2215252aef 100644 --- a/tests/auto/quick/qquicklistview/data/outsideViewportChangeNotAffectingView.qml +++ b/tests/auto/quick/qquicklistview/data/outsideViewportChangeNotAffectingView.qml @@ -1,52 +1,5 @@ -/**************************************************************************** -** -** Copyright (C) 2017 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$ -** -****************************************************************************/ +// Copyright (C) 2017 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only import QtQuick 2.1 import QtTest 1.1 @@ -72,7 +25,7 @@ Item { ListElement { size: 300; } } delegate: Rectangle { - width: parent.width + width: list.width color: index % 2 == 0 ? "red" : "blue" height: size Text { anchors.centerIn: parent; text: index } diff --git a/tests/auto/quick/qquicklistview/data/proxytest.qml b/tests/auto/quick/qquicklistview/data/proxytest.qml index 2cd95cab74..dad5dbad8a 100644 --- a/tests/auto/quick/qquicklistview/data/proxytest.qml +++ b/tests/auto/quick/qquicklistview/data/proxytest.qml @@ -1,30 +1,5 @@ -/**************************************************************************** -** -** Copyright (C) 2016 Canonical Limited and/or its subsidiary(-ies). -** Contact: https://www.qt.io/licensing/ -** -** This file is part of the test suite of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:GPL-EXCEPT$ -** 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. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU -** General Public License version 3 as published by the Free Software -** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT -** included in the packaging of this file. Please review the following -** information to ensure the GNU General Public License requirements will -** be met: https://www.gnu.org/licenses/gpl-3.0.html. -** -** $QT_END_LICENSE$ -** -****************************************************************************/ +// Copyright (C) 2016 Canonical Limited and/or its subsidiary(-ies). +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only import QtQuick 2.1 import Proxy 1.0 diff --git a/tests/auto/quick/qquicklistview/data/qtbug34576.qml b/tests/auto/quick/qquicklistview/data/qtbug34576.qml index f407d8ebe3..fdc94c0c0b 100644 --- a/tests/auto/quick/qquicklistview/data/qtbug34576.qml +++ b/tests/auto/quick/qquicklistview/data/qtbug34576.qml @@ -1,30 +1,5 @@ -/**************************************************************************** -** -** Copyright (C) 2017 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:GPL-EXCEPT$ -** 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. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU -** General Public License version 3 as published by the Free Software -** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT -** included in the packaging of this file. Please review the following -** information to ensure the GNU General Public License requirements will -** be met: https://www.gnu.org/licenses/gpl-3.0.html. -** -** $QT_END_LICENSE$ -** -****************************************************************************/ +// Copyright (C) 2017 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only import QtQuick 2.7 diff --git a/tests/auto/quick/qquicklistview/data/qtbug48044.qml b/tests/auto/quick/qquicklistview/data/qtbug48044.qml index d318643c1c..368b6bd4bd 100644 --- a/tests/auto/quick/qquicklistview/data/qtbug48044.qml +++ b/tests/auto/quick/qquicklistview/data/qtbug48044.qml @@ -116,7 +116,7 @@ Item { color: header ? "yellow" : "cyan" border.color: "black" height: 50 - width: parent.width + width: listView.width Text { anchors.centerIn: parent diff --git a/tests/auto/quick/qquicklistview/data/qtbug61537_modelChangesAsync.qml b/tests/auto/quick/qquicklistview/data/qtbug61537_modelChangesAsync.qml index 0dc9e6fdb5..c385a9b4b8 100644 --- a/tests/auto/quick/qquicklistview/data/qtbug61537_modelChangesAsync.qml +++ b/tests/auto/quick/qquicklistview/data/qtbug61537_modelChangesAsync.qml @@ -1,52 +1,5 @@ -/**************************************************************************** -** -** Copyright (C) 2017 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$ -** -****************************************************************************/ +// Copyright (C) 2017 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only import QtQuick 2.0 Item { diff --git a/tests/auto/quick/qquicklistview/data/repositionListViewOnPopulateTransition.qml b/tests/auto/quick/qquicklistview/data/repositionListViewOnPopulateTransition.qml new file mode 100644 index 0000000000..7a313f7f87 --- /dev/null +++ b/tests/auto/quick/qquicklistview/data/repositionListViewOnPopulateTransition.qml @@ -0,0 +1,51 @@ +import QtQuick +import QtQuick.Controls.Basic + +ListView { + id: listView + + width: 100 + height: 100 + + verticalLayoutDirection: ListView.BottomToTop + interactive: true + reuseItems: false + + model: ListModel { + ListElement {index: 0; text: "Item0"} + } + + delegate: Button { + id: button + + required text + + property alias yScale: scaleTransform.yScale + property bool inverted: ListView.view.verticalLayoutDirection === ListView.BottomToTop + + transform: Scale { + id: scaleTransform + origin.y: button.inverted ? button.implicitHeight : 0 + } + } + + populate: Transition { + id: populateTransition + + NumberAnimation { + // in this case we do want to animate y to achieve a smooth + // transition from y=0 to its assigned y location + property: "y" + duration: 500 + easing.type: Easing.InOutQuad + } + NumberAnimation { + property: "yScale" + from: 0 + to: 1 + duration: 500 + easing.type: Easing.InOutQuad + } + } +} + diff --git a/tests/auto/quick/qquicklistview/data/resizeAfterComponentComplete.qml b/tests/auto/quick/qquicklistview/data/resizeAfterComponentComplete.qml index 851d8f9a0c..fdeca4454a 100644 --- a/tests/auto/quick/qquicklistview/data/resizeAfterComponentComplete.qml +++ b/tests/auto/quick/qquicklistview/data/resizeAfterComponentComplete.qml @@ -1,52 +1,5 @@ -/**************************************************************************** -** -** 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$ -** -****************************************************************************/ +// Copyright (C) 2019 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only import QtQuick 2.12 @@ -56,7 +9,7 @@ ListView { anchors.fill: parent model: 10 delegate: Rectangle { - width: parent.width + width: listView.width height: 40 border.color: "lightsteelblue" Text { diff --git a/tests/auto/quick/qquicklistview/data/reusedelegateitems.qml b/tests/auto/quick/qquicklistview/data/reusedelegateitems.qml index 773fb50f81..c54d10f88c 100644 --- a/tests/auto/quick/qquicklistview/data/reusedelegateitems.qml +++ b/tests/auto/quick/qquicklistview/data/reusedelegateitems.qml @@ -1,52 +1,5 @@ -/**************************************************************************** -** -** 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$ -** -****************************************************************************/ +// Copyright (C) 2019 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only import QtQuick 2.15 Rectangle { diff --git a/tests/auto/quick/qquicklistview/data/roundingErrors.qml b/tests/auto/quick/qquicklistview/data/roundingErrors.qml index 4545fcd617..f850b3573a 100644 --- a/tests/auto/quick/qquicklistview/data/roundingErrors.qml +++ b/tests/auto/quick/qquicklistview/data/roundingErrors.qml @@ -1,52 +1,5 @@ -/**************************************************************************** -** -** Copyright (C) 2017 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$ -** -****************************************************************************/ +// Copyright (C) 2017 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only import QtQuick 2.0 import QtQml.Models 2.1 @@ -127,7 +80,7 @@ ListView { DropArea { anchors.fill: parent - onPositionChanged: { + onPositionChanged: (drag) => { var to = listview.indexAt(drag.x + listview.contentX, 0) if (to !== -1) { var from = drag.source.DelegateModel.itemsIndex diff --git a/tests/auto/quick/qquicklistview/data/sectionSnapping.qml b/tests/auto/quick/qquicklistview/data/sectionSnapping.qml index 2583cc0377..48a893f88c 100644 --- a/tests/auto/quick/qquicklistview/data/sectionSnapping.qml +++ b/tests/auto/quick/qquicklistview/data/sectionSnapping.qml @@ -1,6 +1,7 @@ import QtQuick 2.0 ListView { + id: listView width: 400 height: 400 preferredHighlightBegin: 100 @@ -17,7 +18,7 @@ ListView { } delegate: Rectangle { - width: parent.width + width: listView.width height: 50 color: index % 2 ? "lightsteelblue" : "steelblue" Text { diff --git a/tests/auto/quick/qquicklistview/data/setpositiononlayout.qml b/tests/auto/quick/qquicklistview/data/setpositiononlayout.qml index 6e12eeafca..a605b2103d 100644 --- a/tests/auto/quick/qquicklistview/data/setpositiononlayout.qml +++ b/tests/auto/quick/qquicklistview/data/setpositiononlayout.qml @@ -1,52 +1,5 @@ -/**************************************************************************** -** -** 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$ -** -****************************************************************************/ +// Copyright (C) 2018 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only import QtQuick 2.0 diff --git a/tests/auto/quick/qquicklistview/data/sizeTransitions.qml b/tests/auto/quick/qquicklistview/data/sizeTransitions.qml index 44e4dada60..d1bddb2047 100644 --- a/tests/auto/quick/qquicklistview/data/sizeTransitions.qml +++ b/tests/auto/quick/qquicklistview/data/sizeTransitions.qml @@ -1,52 +1,5 @@ -/**************************************************************************** -** -** Copyright (C) 2017 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$ -** -****************************************************************************/ +// Copyright (C) 2017 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only import QtQuick 2.2 import QtQuick.Window 2.1 diff --git a/tests/auto/quick/qquicklistview/data/snapOneItemResize.qml b/tests/auto/quick/qquicklistview/data/snapOneItemResize.qml index 7ecc833a64..4603cd9f34 100644 --- a/tests/auto/quick/qquicklistview/data/snapOneItemResize.qml +++ b/tests/auto/quick/qquicklistview/data/snapOneItemResize.qml @@ -2,6 +2,7 @@ import QtQuick 2.0 ListView { id: list + anchors.fill: parent currentIndex: 5 snapMode: ListView.SnapOneItem orientation: ListView.Horizontal diff --git a/tests/auto/quick/qquicklistview/data/snapOneItemWrongDirection.qml b/tests/auto/quick/qquicklistview/data/snapOneItemWrongDirection.qml index f5b7b35d0c..1dfbfe0feb 100644 --- a/tests/auto/quick/qquicklistview/data/snapOneItemWrongDirection.qml +++ b/tests/auto/quick/qquicklistview/data/snapOneItemWrongDirection.qml @@ -1,13 +1,14 @@ import QtQuick 2.0 ListView { + id: listView width: 400 height: 400 focus: true model: 10 delegate: Rectangle { - width: parent.width + width: listView.width height: 50 color: index % 2 ? "blue" : "green" } diff --git a/tests/auto/quick/qquicklistview/data/stickyPositioning-both.qml b/tests/auto/quick/qquicklistview/data/stickyPositioning-both.qml index 57e7578ba5..ece0e2527b 100644 --- a/tests/auto/quick/qquicklistview/data/stickyPositioning-both.qml +++ b/tests/auto/quick/qquicklistview/data/stickyPositioning-both.qml @@ -1,52 +1,5 @@ -/**************************************************************************** -** -** Copyright (C) 2017 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$ -** -****************************************************************************/ +// Copyright (C) 2017 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only import QtQuick 2.4 Rectangle { diff --git a/tests/auto/quick/qquicklistview/data/stickyPositioning-footer.qml b/tests/auto/quick/qquicklistview/data/stickyPositioning-footer.qml index fd815ea79e..568762b445 100644 --- a/tests/auto/quick/qquicklistview/data/stickyPositioning-footer.qml +++ b/tests/auto/quick/qquicklistview/data/stickyPositioning-footer.qml @@ -1,52 +1,5 @@ -/**************************************************************************** -** -** Copyright (C) 2017 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$ -** -****************************************************************************/ +// Copyright (C) 2017 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only import QtQuick 2.4 Rectangle { diff --git a/tests/auto/quick/qquicklistview/data/stickyPositioning-header.qml b/tests/auto/quick/qquicklistview/data/stickyPositioning-header.qml index 94fb294474..6b5889a808 100644 --- a/tests/auto/quick/qquicklistview/data/stickyPositioning-header.qml +++ b/tests/auto/quick/qquicklistview/data/stickyPositioning-header.qml @@ -1,52 +1,5 @@ -/**************************************************************************** -** -** Copyright (C) 2017 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$ -** -****************************************************************************/ +// Copyright (C) 2017 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only import QtQuick 2.4 Rectangle { diff --git a/tests/auto/quick/qquicklistview/data/strictlyenforcerange-resize.qml b/tests/auto/quick/qquicklistview/data/strictlyenforcerange-resize.qml index 338af38475..16b9c72b16 100644 --- a/tests/auto/quick/qquicklistview/data/strictlyenforcerange-resize.qml +++ b/tests/auto/quick/qquicklistview/data/strictlyenforcerange-resize.qml @@ -1,6 +1,7 @@ import QtQuick 2.0 ListView { + id: listView width: 400 height: 400 focus: true @@ -15,7 +16,7 @@ ListView { model: 10 delegate: Item { - width: parent.width + width: listView.width height: ListView.isCurrentItem ? 100 : 50 Text { diff --git a/tests/auto/quick/qquicklistview/data/usechooserwithoutdefault.qml b/tests/auto/quick/qquicklistview/data/usechooserwithoutdefault.qml index 45164222f2..cba0ad5720 100644 --- a/tests/auto/quick/qquicklistview/data/usechooserwithoutdefault.qml +++ b/tests/auto/quick/qquicklistview/data/usechooserwithoutdefault.qml @@ -1,41 +1,5 @@ -/**************************************************************************** -** -** Copyright (C) 2018 The Qt Company Ltd. -** Contact: https://www.qt.io/licensing/ -** -** This file is part of the QtQuick module of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** 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. -** -** GNU Lesser General Public License Usage -** Alternatively, this file may be used under the terms of the GNU Lesser -** General Public License version 3 as published by the Free Software -** Foundation and appearing in the file LICENSE.LGPL3 included in the -** packaging of this file. Please review the following information to -** ensure the GNU Lesser General Public License version 3 requirements -** will be met: https://www.gnu.org/licenses/lgpl-3.0.html. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU -** General Public License version 2.0 or (at your option) the GNU General -** Public license version 3 or any later version approved by the KDE Free -** Qt Foundation. The licenses are as published by the Free Software -** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3 -** included in the packaging of this file. Please review the following -** information to ensure the GNU General Public License requirements will -** be met: https://www.gnu.org/licenses/gpl-2.0.html and -** https://www.gnu.org/licenses/gpl-3.0.html. -** -** $QT_END_LICENSE$ -** -****************************************************************************/ +// Copyright (C) 2018 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only import QtQuick 2.12 import QtQuick.Window 2.3 diff --git a/tests/auto/quick/qquicklistview/incrementalmodel.cpp b/tests/auto/quick/qquicklistview/incrementalmodel.cpp index 3f6f9681f5..f2c6219711 100644 --- a/tests/auto/quick/qquicklistview/incrementalmodel.cpp +++ b/tests/auto/quick/qquicklistview/incrementalmodel.cpp @@ -1,30 +1,5 @@ -/**************************************************************************** -** -** Copyright (C) 2016 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:GPL-EXCEPT$ -** 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. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU -** General Public License version 3 as published by the Free Software -** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT -** included in the packaging of this file. Please review the following -** information to ensure the GNU General Public License requirements will -** be met: https://www.gnu.org/licenses/gpl-3.0.html. -** -** $QT_END_LICENSE$ -** -****************************************************************************/ +// Copyright (C) 2016 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only #include "incrementalmodel.h" #include <QGuiApplication> diff --git a/tests/auto/quick/qquicklistview/incrementalmodel.h b/tests/auto/quick/qquicklistview/incrementalmodel.h index 1494575edc..f61d38a3d1 100644 --- a/tests/auto/quick/qquicklistview/incrementalmodel.h +++ b/tests/auto/quick/qquicklistview/incrementalmodel.h @@ -1,30 +1,5 @@ -/**************************************************************************** -** -** Copyright (C) 2016 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:GPL-EXCEPT$ -** 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. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU -** General Public License version 3 as published by the Free Software -** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT -** included in the packaging of this file. Please review the following -** information to ensure the GNU General Public License requirements will -** be met: https://www.gnu.org/licenses/gpl-3.0.html. -** -** $QT_END_LICENSE$ -** -****************************************************************************/ +// Copyright (C) 2016 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only #ifndef IncrementalModel_H #define IncrementalModel_H @@ -38,14 +13,14 @@ class IncrementalModel : public QAbstractListModel Q_OBJECT public: - IncrementalModel(QObject *parent = 0); + IncrementalModel(QObject *parent = nullptr); - int rowCount(const QModelIndex &parent = QModelIndex()) const; - QVariant data(const QModelIndex &index, int role = Qt::DisplayRole) const; + int rowCount(const QModelIndex &parent = QModelIndex()) const override; + QVariant data(const QModelIndex &index, int role = Qt::DisplayRole) const override; protected: - bool canFetchMore(const QModelIndex &parent) const; - void fetchMore(const QModelIndex &parent); + bool canFetchMore(const QModelIndex &parent) const override; + void fetchMore(const QModelIndex &parent) override; private: QStringList list; diff --git a/tests/auto/quick/qquicklistview/proxytestinnermodel.cpp b/tests/auto/quick/qquicklistview/proxytestinnermodel.cpp index 66f4f28812..e142a8a58b 100644 --- a/tests/auto/quick/qquicklistview/proxytestinnermodel.cpp +++ b/tests/auto/quick/qquicklistview/proxytestinnermodel.cpp @@ -1,30 +1,5 @@ -/**************************************************************************** -** -** Copyright (C) 2016 Canonical Limited and/or its subsidiary(-ies). -** Contact: https://www.qt.io/licensing/ -** -** This file is part of the test suite of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:GPL-EXCEPT$ -** 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. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU -** General Public License version 3 as published by the Free Software -** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT -** included in the packaging of this file. Please review the following -** information to ensure the GNU General Public License requirements will -** be met: https://www.gnu.org/licenses/gpl-3.0.html. -** -** $QT_END_LICENSE$ -** -****************************************************************************/ +// Copyright (C) 2016 Canonical Limited and/or its subsidiary(-ies). +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only #include "proxytestinnermodel.h" @@ -53,7 +28,7 @@ int ProxyTestInnerModel::rowCount(const QModelIndex &parent) const if (parent.isValid()) return 0; - return m_values.count(); + return m_values.size(); } int ProxyTestInnerModel::columnCount(const QModelIndex &parent) const @@ -74,7 +49,7 @@ QVariant ProxyTestInnerModel::data(const QModelIndex &index, int role) const void ProxyTestInnerModel::append(const QString &s) { - beginInsertRows(QModelIndex(), m_values.count(), m_values.count()); + beginInsertRows(QModelIndex(), m_values.size(), m_values.size()); m_values << s; endInsertRows(); } diff --git a/tests/auto/quick/qquicklistview/proxytestinnermodel.h b/tests/auto/quick/qquicklistview/proxytestinnermodel.h index 8599db4c87..5ea78ae864 100644 --- a/tests/auto/quick/qquicklistview/proxytestinnermodel.h +++ b/tests/auto/quick/qquicklistview/proxytestinnermodel.h @@ -1,30 +1,5 @@ -/**************************************************************************** -** -** Copyright (C) 2016 Canonical Limited and/or its subsidiary(-ies). -** Contact: https://www.qt.io/licensing/ -** -** This file is part of the test suite of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:GPL-EXCEPT$ -** 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. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU -** General Public License version 3 as published by the Free Software -** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT -** included in the packaging of this file. Please review the following -** information to ensure the GNU General Public License requirements will -** be met: https://www.gnu.org/licenses/gpl-3.0.html. -** -** $QT_END_LICENSE$ -** -****************************************************************************/ +// Copyright (C) 2016 Canonical Limited and/or its subsidiary(-ies). +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only #ifndef INNERMODEL_H #define INNERMODEL_H @@ -36,11 +11,11 @@ class ProxyTestInnerModel : public QAbstractItemModel Q_OBJECT public: ProxyTestInnerModel(); - virtual QModelIndex index(int row, int column, const QModelIndex &parent = QModelIndex()) const; - virtual QModelIndex parent(const QModelIndex & /*parent*/) const; - virtual int rowCount(const QModelIndex &parent = QModelIndex()) const; - virtual int columnCount(const QModelIndex &parent) const; - virtual QVariant data(const QModelIndex &index, int role = Qt::DisplayRole) const; + QModelIndex index(int row, int column, const QModelIndex &parent = QModelIndex()) const override; + QModelIndex parent(const QModelIndex & /*parent*/) const override; + int rowCount(const QModelIndex &parent = QModelIndex()) const override; + int columnCount(const QModelIndex &parent) const override; + QVariant data(const QModelIndex &index, int role = Qt::DisplayRole) const override; Q_INVOKABLE void doStuff(); diff --git a/tests/auto/quick/qquicklistview/randomsortmodel.cpp b/tests/auto/quick/qquicklistview/randomsortmodel.cpp index 65d7fdb6e8..0e5f562e4b 100644 --- a/tests/auto/quick/qquicklistview/randomsortmodel.cpp +++ b/tests/auto/quick/qquicklistview/randomsortmodel.cpp @@ -1,30 +1,5 @@ -/**************************************************************************** -** -** Copyright (C) 2016 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:GPL-EXCEPT$ -** 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. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU -** General Public License version 3 as published by the Free Software -** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT -** included in the packaging of this file. Please review the following -** information to ensure the GNU General Public License requirements will -** be met: https://www.gnu.org/licenses/gpl-3.0.html. -** -** $QT_END_LICENSE$ -** -****************************************************************************/ +// Copyright (C) 2016 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only #include "randomsortmodel.h" #include <QRandomGenerator> @@ -48,7 +23,7 @@ QHash<int, QByteArray> RandomSortModel::roleNames() const int RandomSortModel::rowCount(const QModelIndex& parent) const { if (!parent.isValid()) - return mData.count(); + return mData.size(); return 0; } @@ -59,7 +34,7 @@ QVariant RandomSortModel::data(const QModelIndex& index, int role) const return QVariant(); } - if (index.row() >= mData.count()) { + if (index.row() >= mData.size()) { return QVariant(); } @@ -74,14 +49,14 @@ QVariant RandomSortModel::data(const QModelIndex& index, int role) const void RandomSortModel::randomize() { - const int row = QRandomGenerator::global()->bounded(int(mData.count())); + const int row = QRandomGenerator::global()->bounded(mData.size()); int random; bool exists = false; // Make sure we won't end up with two items with the same weight, as that // would make unit-testing much harder do { exists = false; - random = QRandomGenerator::global()->bounded(int(mData.count() * 10)); + random = QRandomGenerator::global()->bounded(mData.size() * 10); QList<QPair<QString, int> >::ConstIterator iter, end; for (iter = mData.constBegin(), end = mData.constEnd(); iter != end; ++iter) { if ((*iter).second == random) { diff --git a/tests/auto/quick/qquicklistview/randomsortmodel.h b/tests/auto/quick/qquicklistview/randomsortmodel.h index 2430e87f20..9d53a8cff3 100644 --- a/tests/auto/quick/qquicklistview/randomsortmodel.h +++ b/tests/auto/quick/qquicklistview/randomsortmodel.h @@ -1,30 +1,5 @@ -/**************************************************************************** -** -** Copyright (C) 2016 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:GPL-EXCEPT$ -** 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. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU -** General Public License version 3 as published by the Free Software -** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT -** included in the packaging of this file. Please review the following -** information to ensure the GNU General Public License requirements will -** be met: https://www.gnu.org/licenses/gpl-3.0.html. -** -** $QT_END_LICENSE$ -** -****************************************************************************/ +// Copyright (C) 2016 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only #ifndef RANDOMSORTMODEL_H #define RANDOMSORTMODEL_H @@ -36,11 +11,11 @@ class RandomSortModel : public QAbstractListModel Q_OBJECT public: - explicit RandomSortModel(QObject* parent = 0); - QHash<int, QByteArray> roleNames() const; + explicit RandomSortModel(QObject *parent = nullptr); + QHash<int, QByteArray> roleNames() const override; - QVariant data(const QModelIndex& index, int role) const; - int rowCount(const QModelIndex& parent = QModelIndex()) const; + QVariant data(const QModelIndex& index, int role) const override; + int rowCount(const QModelIndex& parent = QModelIndex()) const override; void randomize(); diff --git a/tests/auto/quick/qquicklistview/reusemodel.h b/tests/auto/quick/qquicklistview/reusemodel.h index 21e6739384..0a23a2bda4 100644 --- a/tests/auto/quick/qquicklistview/reusemodel.h +++ b/tests/auto/quick/qquicklistview/reusemodel.h @@ -1,30 +1,5 @@ -/**************************************************************************** -** -** 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:GPL-EXCEPT$ -** 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. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU -** General Public License version 3 as published by the Free Software -** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT -** included in the packaging of this file. Please review the following -** information to ensure the GNU General Public License requirements will -** be met: https://www.gnu.org/licenses/gpl-3.0.html. -** -** $QT_END_LICENSE$ -** -****************************************************************************/ +// Copyright (C) 2019 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only #ifndef REUSEMODEL_H #define REUSEMODEL_H diff --git a/tests/auto/quick/qquicklistview/tst_qquicklistview.cpp b/tests/auto/quick/qquicklistview/tst_qquicklistview.cpp index d99459a4af..48171266de 100644 --- a/tests/auto/quick/qquicklistview/tst_qquicklistview.cpp +++ b/tests/auto/quick/qquicklistview/tst_qquicklistview.cpp @@ -1,30 +1,5 @@ -/**************************************************************************** -** -** Copyright (C) 2020 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:GPL-EXCEPT$ -** 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. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU -** General Public License version 3 as published by the Free Software -** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT -** included in the packaging of this file. Please review the following -** information to ensure the GNU General Public License requirements will -** be met: https://www.gnu.org/licenses/gpl-3.0.html. -** -** $QT_END_LICENSE$ -** -****************************************************************************/ +// Copyright (C) 2020 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only #include <QtTest/QtTest> #include <QtCore/QStringListModel> @@ -37,18 +12,20 @@ #include <QtQml/qqmlcontext.h> #include <QtQml/qqmlexpression.h> #include <QtQml/qqmlincubator.h> +#include <QtQml/qqmlcomponent.h> #include <QtQuick/private/qquickitemview_p_p.h> #include <QtQuick/private/qquicklistview_p.h> #include <QtQuick/private/qquickmousearea_p.h> #include <QtQuick/private/qquicktext_p.h> #include <QtQuick/private/qquickrectangle_p.h> +#include <QtQuick/private/qquicktransition_p.h> #include <QtQmlModels/private/qqmlobjectmodel_p.h> #include <QtQmlModels/private/qqmllistmodel_p.h> #include <QtQmlModels/private/qqmldelegatemodel_p.h> #include <qpa/qwindowsysteminterface.h> -#include "../../shared/util.h" -#include "../shared/viewtestutil.h" -#include "../shared/visualtestutil.h" +#include <QtQuickTestUtils/private/qmlutils_p.h> +#include <QtQuickTestUtils/private/viewtestutils_p.h> +#include <QtQuickTestUtils/private/visualtestutils_p.h> #include "incrementalmodel.h" #include "proxytestinnermodel.h" #include "randomsortmodel.h" @@ -62,8 +39,8 @@ Q_DECLARE_METATYPE(QQuickListView::Orientation) Q_DECLARE_METATYPE(QQuickFlickable::FlickableDirection) Q_DECLARE_METATYPE(Qt::Key) -using namespace QQuickViewTestUtil; -using namespace QQuickVisualTestUtil; +using namespace QQuickViewTestUtils; +using namespace QQuickVisualTestUtils; #define SHARE_VIEWS @@ -72,9 +49,12 @@ class tst_QQuickListView : public QQmlDataTest Q_OBJECT public: tst_QQuickListView(); + ~tst_QQuickListView() { delete touchDevice; } private slots: - void init(); + // WARNING: please add new tests to tst_qquicklistview2; this file is too slow to work with. + + void init() override; void cleanupTestCase(); // Test QAbstractItemModel model types void qAbstractItemModel_package_items(); @@ -207,6 +187,7 @@ private slots: void populateTransitions(); void populateTransitions_data(); + void repositionFirstItemOnPopulateTransition(); void sizeTransitions(); void sizeTransitions_data(); @@ -301,6 +282,8 @@ private slots: void clickHeaderAndFooterWhenClip(); void animatedDelegate(); + // WARNING: please add new tests to tst_qquicklistview2; this file is too slow to work with. + private: template <class T> void items(const QUrl &source); template <class T> void changed(const QUrl &source); @@ -397,12 +380,16 @@ public: int mCacheBuffer; }; -tst_QQuickListView::tst_QQuickListView() : m_view(nullptr) +tst_QQuickListView::tst_QQuickListView() + : QQmlDataTest(QT_QMLTEST_DATADIR, FailOnWarningsPolicy::FailOnWarnings) + , m_view(nullptr) { } void tst_QQuickListView::init() { + QQmlDataTest::init(); + #ifdef SHARE_VIEWS if (m_view && QString(QTest::currentTestFunction()) != testForView) { testForView = QString(); @@ -427,6 +414,9 @@ void tst_QQuickListView::cleanupTestCase() template <class T> void tst_QQuickListView::items(const QUrl &source) { + // Make sure we outlive the view, or the context property will become null. + QScopedPointer<TestObject> testObject(new TestObject); + QScopedPointer<QQuickView> window(createView()); T model; @@ -437,7 +427,6 @@ void tst_QQuickListView::items(const QUrl &source) QQmlContext *ctxt = window->rootContext(); ctxt->setContextProperty("testModel", &model); - QScopedPointer<TestObject> testObject(new TestObject); ctxt->setContextProperty("testObject", testObject.data()); window->setSource(source); @@ -457,7 +446,7 @@ void tst_QQuickListView::items(const QUrl &source) QTRY_COMPARE(listview->count(), model.count()); QTRY_COMPARE(window->rootObject()->property("count").toInt(), model.count()); listview->forceLayout(); - QTRY_COMPARE(contentItem->childItems().count(), model.count()+1); // assumes all are visible, +1 for the (default) highlight item + QTRY_COMPARE(contentItem->childItems().size(), model.count()+1); // assumes all are visible, +1 for the (default) highlight item // current item should be first item QTRY_COMPARE(listview->currentItem(), findItem<QQuickItem>(contentItem, "wrapper", 0)); @@ -508,6 +497,8 @@ void tst_QQuickListView::items(const QUrl &source) template <class T> void tst_QQuickListView::changed(const QUrl &source) { + QScopedPointer<TestObject> testObject(new TestObject); + QScopedPointer<QQuickView> window(createView()); T model; @@ -518,7 +509,6 @@ void tst_QQuickListView::changed(const QUrl &source) QQmlContext *ctxt = window->rootContext(); ctxt->setContextProperty("testModel", &model); - QScopedPointer<TestObject> testObject(new TestObject); ctxt->setContextProperty("testObject", testObject.data()); window->setSource(source); @@ -546,6 +536,8 @@ void tst_QQuickListView::changed(const QUrl &source) template <class T> void tst_QQuickListView::inserted(const QUrl &source) { + QScopedPointer<TestObject> testObject(new TestObject); + QScopedPointer<QQuickView> window(createView()); window->show(); QVERIFY(QTest::qWaitForWindowExposed(window.data())); @@ -558,7 +550,6 @@ void tst_QQuickListView::inserted(const QUrl &source) QQmlContext *ctxt = window->rootContext(); ctxt->setContextProperty("testModel", &model); - QScopedPointer<TestObject> testObject(new TestObject); ctxt->setContextProperty("testObject", testObject.data()); window->setSource(source); @@ -573,7 +564,7 @@ void tst_QQuickListView::inserted(const QUrl &source) model.insertItem(1, "Will", "9876"); QTRY_COMPARE(window->rootObject()->property("count").toInt(), model.count()); - QTRY_COMPARE(contentItem->childItems().count(), model.count()+1); // assumes all are visible, +1 for the (default) highlight item + QTRY_COMPARE(contentItem->childItems().size(), model.count()+1); // assumes all are visible, +1 for the (default) highlight item QQuickText *name = findItem<QQuickText>(contentItem, "textName", 1); QTRY_VERIFY(name != nullptr); @@ -591,7 +582,7 @@ void tst_QQuickListView::inserted(const QUrl &source) model.insertItem(0, "Foo", "1111"); // zero index, and current item QTRY_COMPARE(window->rootObject()->property("count").toInt(), model.count()); - QTRY_COMPARE(contentItem->childItems().count(), model.count()+1); // assumes all are visible, +1 for the (default) highlight item + QTRY_COMPARE(contentItem->childItems().size(), model.count()+1); // assumes all are visible, +1 for the (default) highlight item name = findItem<QQuickText>(contentItem, "textName", 0); QTRY_VERIFY(name != nullptr); @@ -650,11 +641,12 @@ void tst_QQuickListView::inserted_more(QQuickItemView::VerticalLayoutDirection v for (int i = 0; i < 30; i++) model.addItem("Item" + QString::number(i), ""); + QScopedPointer<TestObject> testObject(new TestObject); + QQuickView *window = getView(); QQmlContext *ctxt = window->rootContext(); ctxt->setContextProperty("testModel", &model); - QScopedPointer<TestObject> testObject(new TestObject); ctxt->setContextProperty("testObject", testObject.data()); window->setSource(testFileUrl("listviewtest.qml")); @@ -668,7 +660,7 @@ void tst_QQuickListView::inserted_more(QQuickItemView::VerticalLayoutDirection v if (verticalLayoutDirection == QQuickItemView::BottomToTop) { listview->setVerticalLayoutDirection(verticalLayoutDirection); - QVERIFY(QQuickTest::qWaitForItemPolished(listview)); + QVERIFY(QQuickTest::qWaitForPolish(listview)); contentY = -listview->height() - contentY; } listview->setContentY(contentY); @@ -681,7 +673,7 @@ void tst_QQuickListView::inserted_more(QQuickItemView::VerticalLayoutDirection v model.insertItems(insertIndex, newData); //Wait for polish (updates list to the model changes) - QVERIFY(QQuickTest::qWaitForItemPolished(listview)); + QVERIFY(QQuickTest::qWaitForPolish(listview)); QTRY_COMPARE(listview->property("count").toInt(), model.count()); @@ -706,7 +698,7 @@ void tst_QQuickListView::inserted_more(QQuickItemView::VerticalLayoutDirection v QList<QQuickItem*> items = findItems<QQuickItem>(contentItem, "wrapper"); int firstVisibleIndex = -1; - for (int i=0; i<items.count(); i++) { + for (int i=0; i<items.size(); i++) { QQuickItem *item = findItem<QQuickItem>(contentItem, "wrapper", i); if (item && !QQuickItemPrivate::get(item)->culled) { firstVisibleIndex = i; @@ -720,7 +712,7 @@ void tst_QQuickListView::inserted_more(QQuickItemView::VerticalLayoutDirection v QQuickText *number; const qreal visibleFromPos = listview->contentY() - listview->displayMarginBeginning() - listview->cacheBuffer(); const qreal visibleToPos = listview->contentY() + listview->height() + listview->displayMarginEnd() + listview->cacheBuffer(); - for (int i = firstVisibleIndex; i < model.count() && i < items.count(); ++i) { + for (int i = firstVisibleIndex; i < model.count() && i < items.size(); ++i) { QQuickItem *item = findItem<QQuickItem>(contentItem, "wrapper", i); QVERIFY2(item, qPrintable(QString("Item %1 not found").arg(i))); qreal pos = i*20.0 + itemsOffsetAfterMove; @@ -861,7 +853,7 @@ void tst_QQuickListView::insertBeforeVisible() QTRY_VERIFY(contentItem != nullptr); listview->setCacheBuffer(cacheBuffer); - QVERIFY(QQuickTest::qWaitForItemPolished(listview)); + QVERIFY(QQuickTest::qWaitForPolish(listview)); // trigger a refill (not just setting contentY) so that the visibleItems grid is updated int firstVisibleIndex = 20; // move to an index where the top item is not visible @@ -869,7 +861,7 @@ void tst_QQuickListView::insertBeforeVisible() listview->setCurrentIndex(firstVisibleIndex); qApp->processEvents(); - QVERIFY(QQuickTest::qWaitForItemPolished(listview)); + QVERIFY(QQuickTest::qWaitForPolish(listview)); QTRY_COMPARE(listview->currentIndex(), firstVisibleIndex); QQuickItem *item = findItem<QQuickItem>(contentItem, "wrapper", firstVisibleIndex); QVERIFY(item); @@ -889,12 +881,12 @@ void tst_QQuickListView::insertBeforeVisible() // now, moving to the top of the view should position the inserted items correctly int itemsOffsetAfterMove = (removeCount - insertCount) * 20; listview->setCurrentIndex(0); - QVERIFY(QQuickTest::qWaitForItemPolished(listview)); + QVERIFY(QQuickTest::qWaitForPolish(listview)); QTRY_COMPARE(listview->currentIndex(), 0); QTRY_COMPARE(listview->contentY(), 0.0 + itemsOffsetAfterMove); // Confirm items positioned correctly and indexes correct - int itemCount = findItems<QQuickItem>(contentItem, "wrapper").count(); + int itemCount = findItems<QQuickItem>(contentItem, "wrapper").size(); for (int i = 0; i < model.count() && i < itemCount; ++i) { item = findItem<QQuickItem>(contentItem, "wrapper", i); QVERIFY2(item, qPrintable(QString("Item %1 not found").arg(i))); @@ -951,6 +943,8 @@ void tst_QQuickListView::insertBeforeVisible_data() template <class T> void tst_QQuickListView::removed(const QUrl &source, bool /* animated */) { + QScopedPointer<TestObject> testObject(new TestObject); + QScopedPointer<QQuickView> window(createView()); T model; @@ -960,7 +954,6 @@ void tst_QQuickListView::removed(const QUrl &source, bool /* animated */) QQmlContext *ctxt = window->rootContext(); ctxt->setContextProperty("testModel", &model); - QScopedPointer<TestObject> testObject(new TestObject); ctxt->setContextProperty("testObject", testObject.data()); window->setSource(source); @@ -971,7 +964,7 @@ void tst_QQuickListView::removed(const QUrl &source, bool /* animated */) QTRY_VERIFY(listview != nullptr); QQuickItem *contentItem = listview->contentItem(); QTRY_VERIFY(contentItem != nullptr); - QVERIFY(QQuickTest::qWaitForItemPolished(listview)); + QVERIFY(QQuickTest::qWaitForPolish(listview)); model.removeItem(1); QTRY_COMPARE(window->rootObject()->property("count").toInt(), model.count()); @@ -984,7 +977,7 @@ void tst_QQuickListView::removed(const QUrl &source, bool /* animated */) QTRY_COMPARE(number->text(), model.number(1)); // Confirm items positioned correctly - int itemCount = findItems<QQuickItem>(contentItem, "wrapper").count(); + int itemCount = findItems<QQuickItem>(contentItem, "wrapper").size(); for (int i = 0; i < model.count() && i < itemCount; ++i) { QQuickItem *item = findItem<QQuickItem>(contentItem, "wrapper", i); if (!item) qWarning() << "Item" << i << "not found"; @@ -1004,7 +997,7 @@ void tst_QQuickListView::removed(const QUrl &source, bool /* animated */) QTRY_COMPARE(number->text(), model.number(0)); // Confirm items positioned correctly - itemCount = findItems<QQuickItem>(contentItem, "wrapper").count(); + itemCount = findItems<QQuickItem>(contentItem, "wrapper").size(); for (int i = 0; i < model.count() && i < itemCount; ++i) { QQuickItem *item = findItem<QQuickItem>(contentItem, "wrapper", i); if (!item) qWarning() << "Item" << i << "not found"; @@ -1017,7 +1010,7 @@ void tst_QQuickListView::removed(const QUrl &source, bool /* animated */) QTRY_COMPARE(window->rootObject()->property("count").toInt(), model.count()); // Confirm items positioned correctly - itemCount = findItems<QQuickItem>(contentItem, "wrapper").count(); + itemCount = findItems<QQuickItem>(contentItem, "wrapper").size(); for (int i = 0; i < model.count() && i < itemCount; ++i) { QQuickItem *item = findItem<QQuickItem>(contentItem, "wrapper", i); if (!item) qWarning() << "Item" << i << "not found"; @@ -1050,10 +1043,10 @@ void tst_QQuickListView::removed(const QUrl &source, bool /* animated */) listview->setContentY(20); // That's the top now // let transitions settle. - QVERIFY(QQuickTest::qWaitForItemPolished(listview)); + QVERIFY(QQuickTest::qWaitForPolish(listview)); // Confirm items positioned correctly - itemCount = findItems<QQuickItem>(contentItem, "wrapper").count(); + itemCount = findItems<QQuickItem>(contentItem, "wrapper").size(); for (int i = 0; i < model.count() && i < itemCount; ++i) { QQuickItem *item = findItem<QQuickItem>(contentItem, "wrapper", i); if (!item) qWarning() << "Item" << i << "not found"; @@ -1064,7 +1057,7 @@ void tst_QQuickListView::removed(const QUrl &source, bool /* animated */) // remove current item beyond visible items. listview->setCurrentIndex(20); listview->setContentY(40); - QVERIFY(QQuickTest::qWaitForItemPolished(listview)); + QVERIFY(QQuickTest::qWaitForPolish(listview)); model.removeItem(20); QTRY_COMPARE(listview->currentIndex(), 20); @@ -1072,7 +1065,7 @@ void tst_QQuickListView::removed(const QUrl &source, bool /* animated */) // remove item before current, but visible listview->setCurrentIndex(8); - QVERIFY(QQuickTest::qWaitForItemPolished(listview)); + QVERIFY(QQuickTest::qWaitForPolish(listview)); oldCurrent = listview->currentItem(); model.removeItem(6); @@ -1080,14 +1073,14 @@ void tst_QQuickListView::removed(const QUrl &source, bool /* animated */) QTRY_COMPARE(listview->currentItem(), oldCurrent); listview->setContentY(80); - QVERIFY(QQuickTest::qWaitForItemPolished(listview)); + QVERIFY(QQuickTest::qWaitForPolish(listview)); // remove all visible items model.removeItems(1, 18); QTRY_COMPARE(listview->count() , model.count()); // Confirm items positioned correctly - itemCount = findItems<QQuickItem>(contentItem, "wrapper").count(); + itemCount = findItems<QQuickItem>(contentItem, "wrapper").size(); for (int i = 0; i < model.count() && i < itemCount-1; ++i) { QQuickItem *item = findItem<QQuickItem>(contentItem, "wrapper", i+1); if (!item) qWarning() << "Item" << i+1 << "not found"; @@ -1122,7 +1115,7 @@ void tst_QQuickListView::removed(const QUrl &source, bool /* animated */) listview->positionViewAtEnd(); for (int i = 0; i < 18; ++i) model.removeItems(model.count() - 1, 1); - QTRY_VERIFY(findItems<QQuickItem>(contentItem, "wrapper").count() > 16); + QTRY_VERIFY(findItems<QQuickItem>(contentItem, "wrapper").size() > 16); } template <class T> @@ -1156,14 +1149,14 @@ void tst_QQuickListView::removed_more(const QUrl &source, QQuickItemView::Vertic if (verticalLayoutDirection == QQuickItemView::BottomToTop) { listview->setVerticalLayoutDirection(verticalLayoutDirection); - QVERIFY(QQuickTest::qWaitForItemPolished(listview)); + QVERIFY(QQuickTest::qWaitForPolish(listview)); contentY = -listview->height() - contentY; } listview->setContentY(contentY); model.removeItems(removeIndex, removeCount); //Wait for polish (updates list to the model changes) - QVERIFY(QQuickTest::qWaitForItemPolished(listview)); + QVERIFY(QQuickTest::qWaitForPolish(listview)); QTRY_COMPARE(listview->property("count").toInt(), model.count()); @@ -1178,9 +1171,9 @@ void tst_QQuickListView::removed_more(const QUrl &source, QQuickItemView::Vertic QList<QQuickItem*> items = findItems<QQuickItem>(contentItem, "wrapper"); int firstVisibleIndex = -1; - for (int i=0; i<items.count(); i++) { + for (int i=0; i<items.size(); i++) { QQuickItem *item = findItem<QQuickItem>(contentItem, "wrapper", i); - if (item && delegateVisible(item)) { + if (item && isDelegateVisible(item)) { firstVisibleIndex = i; break; } @@ -1190,7 +1183,7 @@ void tst_QQuickListView::removed_more(const QUrl &source, QQuickItemView::Vertic // Confirm items positioned correctly and indexes correct QQuickText *name; QQuickText *number; - for (int i = firstVisibleIndex; i < model.count() && i < items.count(); ++i) { + for (int i = firstVisibleIndex; i < model.count() && i < items.size(); ++i) { QQuickItem *item = findItem<QQuickItem>(contentItem, "wrapper", i); QVERIFY2(item, qPrintable(QString("Item %1 not found").arg(i))); qreal pos = i*20.0 + itemsOffsetAfterMove; @@ -1314,6 +1307,8 @@ void tst_QQuickListView::removed_more_data() template <class T> void tst_QQuickListView::clear(const QUrl &source, QQuickItemView::VerticalLayoutDirection verticalLayoutDirection) { + QScopedPointer<TestObject> testObject(new TestObject); + QScopedPointer<QQuickView> window(createView()); T model; @@ -1323,7 +1318,6 @@ void tst_QQuickListView::clear(const QUrl &source, QQuickItemView::VerticalLayou QQmlContext *ctxt = window->rootContext(); ctxt->setContextProperty("testModel", &model); - QScopedPointer<TestObject> testObject(new TestObject); ctxt->setContextProperty("testObject", testObject.data()); window->setSource(source); @@ -1336,11 +1330,11 @@ void tst_QQuickListView::clear(const QUrl &source, QQuickItemView::VerticalLayou QTRY_VERIFY(contentItem != nullptr); listview->setVerticalLayoutDirection(verticalLayoutDirection); - QVERIFY(QQuickTest::qWaitForItemPolished(listview)); + QVERIFY(QQuickTest::qWaitForPolish(listview)); model.clear(); - QTRY_COMPARE(findItems<QQuickListView>(contentItem, "wrapper").count(), 0); + QTRY_COMPARE(findItems<QQuickListView>(contentItem, "wrapper").size(), 0); QTRY_COMPARE(listview->count(), 0); QTRY_VERIFY(!listview->currentItem()); if (verticalLayoutDirection == QQuickItemView::TopToBottom) @@ -1392,26 +1386,26 @@ void tst_QQuickListView::moved(const QUrl &source, QQuickItemView::VerticalLayou QTRY_VERIFY(contentItem != nullptr); // always need to wait for view to be painted before the first move() - QVERIFY(QQuickTest::qWaitForItemPolished(listview)); + QVERIFY(QQuickTest::qWaitForPolish(listview)); bool waitForPolish = (contentY != 0); if (verticalLayoutDirection == QQuickItemView::BottomToTop) { listview->setVerticalLayoutDirection(verticalLayoutDirection); - QVERIFY(QQuickTest::qWaitForItemPolished(listview)); + QVERIFY(QQuickTest::qWaitForPolish(listview)); contentY = -listview->height() - contentY; } listview->setContentY(contentY); if (waitForPolish) - QVERIFY(QQuickTest::qWaitForItemPolished(listview)); + QVERIFY(QQuickTest::qWaitForPolish(listview)); model.moveItems(from, to, count); - QVERIFY(QQuickTest::qWaitForItemPolished(listview)); + QVERIFY(QQuickTest::qWaitForPolish(listview)); QList<QQuickItem*> items = findItems<QQuickItem>(contentItem, "wrapper"); int firstVisibleIndex = -1; - for (int i=0; i<items.count(); i++) { + for (int i=0; i<items.size(); i++) { QQuickItem *item = findItem<QQuickItem>(contentItem, "wrapper", i); - if (item && delegateVisible(item)) { + if (item && isDelegateVisible(item)) { firstVisibleIndex = i; break; } @@ -1419,7 +1413,7 @@ void tst_QQuickListView::moved(const QUrl &source, QQuickItemView::VerticalLayou QVERIFY2(firstVisibleIndex >= 0, QByteArray::number(firstVisibleIndex)); // Confirm items positioned correctly and indexes correct - for (int i = firstVisibleIndex; i < model.count() && i < items.count(); ++i) { + for (int i = firstVisibleIndex; i < model.count() && i < items.size(); ++i) { QQuickItem *item = findItem<QQuickItem>(contentItem, "wrapper", i); QVERIFY2(item, qPrintable(QString("Item %1 not found").arg(i))); qreal pos = i*20.0 + itemsOffsetAfterMove; @@ -1617,9 +1611,9 @@ void tst_QQuickListView::multipleChanges(bool condensed) QQuickListView *listview = findItem<QQuickListView>(window->rootObject(), "list"); QTRY_VERIFY(listview != nullptr); - QVERIFY(QQuickTest::qWaitForItemPolished(listview)); + QVERIFY(QQuickTest::qWaitForPolish(listview)); - for (int i=0; i<changes.count(); i++) { + for (int i=0; i<changes.size(); i++) { switch (changes[i].type) { case ListChange::Inserted: { @@ -1645,10 +1639,10 @@ void tst_QQuickListView::multipleChanges(bool condensed) continue; } if (!condensed) { - QVERIFY(QQuickTest::qWaitForItemPolished(listview)); + QVERIFY(QQuickTest::qWaitForPolish(listview)); } } - QVERIFY(QQuickTest::qWaitForItemPolished(listview)); + QVERIFY(QQuickTest::qWaitForPolish(listview)); QCOMPARE(listview->count(), newCount); QCOMPARE(listview->count(), model.count()); @@ -1658,7 +1652,7 @@ void tst_QQuickListView::multipleChanges(bool condensed) QQuickText *number; QQuickItem *contentItem = listview->contentItem(); QTRY_VERIFY(contentItem != nullptr); - int itemCount = findItems<QQuickItem>(contentItem, "wrapper").count(); + int itemCount = findItems<QQuickItem>(contentItem, "wrapper").size(); for (int i=0; i < model.count() && i < itemCount; ++i) { QQuickItem *item = findItem<QQuickItem>(contentItem, "wrapper", i); QVERIFY2(item, qPrintable(QString("Item %1 not found").arg(i))); @@ -1846,6 +1840,8 @@ void tst_QQuickListView::multipleChanges_data() void tst_QQuickListView::swapWithFirstItem() { + QScopedPointer<TestObject> testObject(new TestObject); + QScopedPointer<QQuickView> window(createView()); QaimModel model; @@ -1855,7 +1851,6 @@ void tst_QQuickListView::swapWithFirstItem() QQmlContext *ctxt = window->rootContext(); ctxt->setContextProperty("testModel", &model); - QScopedPointer<TestObject> testObject(new TestObject); ctxt->setContextProperty("testObject", testObject.data()); window->setSource(testFileUrl("listviewtest.qml")); @@ -1864,7 +1859,7 @@ void tst_QQuickListView::swapWithFirstItem() QQuickListView *listview = findItem<QQuickListView>(window->rootObject(), "list"); QTRY_VERIFY(listview != nullptr); - QVERIFY(QQuickTest::qWaitForItemPolished(listview)); + QVERIFY(QQuickTest::qWaitForPolish(listview)); // ensure content position is stable listview->setContentY(0); @@ -1874,6 +1869,8 @@ void tst_QQuickListView::swapWithFirstItem() void tst_QQuickListView::checkCountForMultiColumnModels() { + QScopedPointer<TestObject> testObject(new TestObject); + // Check that a list view will only load items for the first // column, even if the model reports that it got several columns. // We test this since QQmlDelegateModel has been changed to @@ -1891,7 +1888,6 @@ void tst_QQuickListView::checkCountForMultiColumnModels() QQmlContext *ctxt = window->rootContext(); ctxt->setContextProperty("testModel", &model); - QScopedPointer<TestObject> testObject(new TestObject); ctxt->setContextProperty("testObject", testObject.data()); window->setSource(testFileUrl("listviewtest.qml")); @@ -1925,7 +1921,7 @@ void tst_QQuickListView::enforceRange() QTRY_COMPARE(listview->preferredHighlightBegin(), 100.0); QTRY_COMPARE(listview->preferredHighlightEnd(), 100.0); QTRY_COMPARE(listview->highlightRangeMode(), QQuickListView::StrictlyEnforceRange); - QVERIFY(QQuickTest::qWaitForItemPolished(listview)); + QVERIFY(QQuickTest::qWaitForPolish(listview)); QQuickItem *contentItem = listview->contentItem(); QTRY_VERIFY(contentItem != nullptr); @@ -2005,7 +2001,7 @@ void tst_QQuickListView::enforceRange_withoutHighlight() QQuickListView *listview = findItem<QQuickListView>(window->rootObject(), "list"); QTRY_VERIFY(listview != nullptr); - QVERIFY(QQuickTest::qWaitForItemPolished(listview)); + QVERIFY(QQuickTest::qWaitForPolish(listview)); qreal expectedPos = -100.0; @@ -2028,6 +2024,8 @@ void tst_QQuickListView::enforceRange_withoutHighlight() void tst_QQuickListView::spacing() { + QScopedPointer<TestObject> testObject(new TestObject); + QScopedPointer<QQuickView> window(createView()); QaimModel model; @@ -2037,7 +2035,6 @@ void tst_QQuickListView::spacing() QQmlContext *ctxt = window->rootContext(); ctxt->setContextProperty("testModel", &model); - QScopedPointer<TestObject> testObject(new TestObject); ctxt->setContextProperty("testObject", testObject.data()); window->setSource(testFileUrl("listviewtest.qml")); @@ -2049,10 +2046,10 @@ void tst_QQuickListView::spacing() QQuickItem *contentItem = listview->contentItem(); QTRY_VERIFY(contentItem != nullptr); - QVERIFY(QQuickTest::qWaitForItemPolished(listview)); + QVERIFY(QQuickTest::qWaitForPolish(listview)); // Confirm items positioned correctly - int itemCount = findItems<QQuickItem>(contentItem, "wrapper").count(); + int itemCount = findItems<QQuickItem>(contentItem, "wrapper").size(); for (int i = 0; i < model.count() && i < itemCount; ++i) { QQuickItem *item = findItem<QQuickItem>(contentItem, "wrapper", i); if (!item) qWarning() << "Item" << i << "not found"; @@ -2064,7 +2061,7 @@ void tst_QQuickListView::spacing() QTRY_COMPARE(listview->spacing(), qreal(10)); // Confirm items positioned correctly - QTRY_VERIFY(findItems<QQuickItem>(contentItem, "wrapper").count() == 11); + QTRY_VERIFY(findItems<QQuickItem>(contentItem, "wrapper").size() == 11); for (int i = 0; i < 11; ++i) { QQuickItem *item = findItem<QQuickItem>(contentItem, "wrapper", i); if (!item) qWarning() << "Item" << i << "not found"; @@ -2075,7 +2072,7 @@ void tst_QQuickListView::spacing() listview->setSpacing(0); // Confirm items positioned correctly - QTRY_VERIFY(findItems<QQuickItem>(contentItem, "wrapper").count() >= 16); + QTRY_VERIFY(findItems<QQuickItem>(contentItem, "wrapper").size() >= 16); for (int i = 0; i < 16; ++i) { QQuickItem *item = findItem<QQuickItem>(contentItem, "wrapper", i); if (!item) qWarning() << "Item" << i << "not found"; @@ -2106,10 +2103,10 @@ void tst_QQuickListView::sections(const QUrl &source) QQuickItem *contentItem = listview->contentItem(); QTRY_VERIFY(contentItem != nullptr); - QVERIFY(QQuickTest::qWaitForItemPolished(listview)); + QVERIFY(QQuickTest::qWaitForPolish(listview)); // Confirm items positioned correctly - int itemCount = findItems<QQuickItem>(contentItem, "wrapper").count(); + int itemCount = findItems<QQuickItem>(contentItem, "wrapper").size(); for (int i = 0; i < model.count() && i < itemCount; ++i) { QQuickItem *item = findItem<QQuickItem>(contentItem, "wrapper", i); QVERIFY(item); @@ -2163,12 +2160,12 @@ void tst_QQuickListView::sections(const QUrl &source) listview->setContentY(140); QTRY_COMPARE(listview->currentSection(), QString("1")); - QTRY_COMPARE(currentSectionChangedSpy.count(), 1); + QTRY_COMPARE(currentSectionChangedSpy.size(), 1); listview->setContentY(20); QTRY_COMPARE(listview->currentSection(), QString("0")); - QTRY_COMPARE(currentSectionChangedSpy.count(), 2); + QTRY_COMPARE(currentSectionChangedSpy.size(), 2); item = findItem<QQuickItem>(contentItem, "wrapper", 1); QTRY_VERIFY(item); @@ -2176,9 +2173,9 @@ void tst_QQuickListView::sections(const QUrl &source) // check that headers change when item changes listview->setContentY(0); - QVERIFY(QQuickTest::qWaitForItemPolished(listview)); + QVERIFY(QQuickTest::qWaitForPolish(listview)); model.modifyItem(0, "changed", "2"); - QVERIFY(QQuickTest::qWaitForItemPolished(listview)); + QVERIFY(QQuickTest::qWaitForPolish(listview)); item = findItem<QQuickItem>(contentItem, "wrapper", 1); QTRY_VERIFY(item); @@ -2215,10 +2212,10 @@ void tst_QQuickListView::sectionsDelegate() QQuickItem *contentItem = listview->contentItem(); QTRY_VERIFY(contentItem != nullptr); - QVERIFY(QQuickTest::qWaitForItemPolished(listview)); + QVERIFY(QQuickTest::qWaitForPolish(listview)); // Confirm items positioned correctly - int itemCount = findItems<QQuickItem>(contentItem, "wrapper").count(); + int itemCount = findItems<QQuickItem>(contentItem, "wrapper").size(); for (int i = 0; i < model.count() && i < itemCount; ++i) { QQuickItem *item = findItem<QQuickItem>(contentItem, "wrapper", i); QTRY_VERIFY(item); @@ -2239,7 +2236,7 @@ void tst_QQuickListView::sectionsDelegate() model.modifyItem(2, "Three", "aaa"); model.modifyItem(3, "Four", "aaa"); model.modifyItem(4, "Five", "aaa"); - QVERIFY(QQuickTest::qWaitForItemPolished(listview)); + QVERIFY(QQuickTest::qWaitForPolish(listview)); for (int i = 0; i < 3; ++i) { QQuickItem *item = findItem<QQuickItem>(contentItem, @@ -2260,7 +2257,7 @@ void tst_QQuickListView::sectionsDelegate() // QTBUG-17606 QList<QQuickItem*> items = findItems<QQuickItem>(contentItem, "sect_1"); - QCOMPARE(items.count(), 1); + QCOMPARE(items.size(), 1); // QTBUG-17759 model.modifyItem(0, "One", "aaa"); @@ -2275,11 +2272,11 @@ void tst_QQuickListView::sectionsDelegate() model.modifyItem(9, "Two", "aaa"); model.modifyItem(10, "Two", "aaa"); model.modifyItem(11, "Two", "aaa"); - QVERIFY(QQuickTest::qWaitForItemPolished(listview)); - QTRY_COMPARE(findItems<QQuickItem>(contentItem, "sect_aaa").count(), 1); + QVERIFY(QQuickTest::qWaitForPolish(listview)); + QTRY_COMPARE(findItems<QQuickItem>(contentItem, "sect_aaa").size(), 1); window->rootObject()->setProperty("sectionProperty", "name"); // ensure view has settled. - QTRY_COMPARE(findItems<QQuickItem>(contentItem, "sect_Four").count(), 1); + QTRY_COMPARE(findItems<QQuickItem>(contentItem, "sect_Four").size(), 1); for (int i = 0; i < 4; ++i) { QQuickItem *item = findItem<QQuickItem>(contentItem, "sect_" + model.name(i*3)); @@ -2305,7 +2302,7 @@ void tst_QQuickListView::sectionsDragOutsideBounds() QFETCH(int, cacheBuffer); QQuickView *window = getView(); - QQuickViewTestUtil::moveMouseAway(window); + QQuickViewTestUtils::moveMouseAway(window); QaimModel model; for (int i = 0; i < 10; i++) @@ -2325,7 +2322,7 @@ void tst_QQuickListView::sectionsDragOutsideBounds() QQuickItem *contentItem = listview->contentItem(); QTRY_VERIFY(contentItem != nullptr); - QVERIFY(QQuickTest::qWaitForItemPolished(listview)); + QVERIFY(QQuickTest::qWaitForPolish(listview)); // QTBUG-17769 // Drag view up beyond bounds @@ -2340,8 +2337,15 @@ void tst_QQuickListView::sectionsDragOutsideBounds() QTest::mousePress(window, Qt::LeftButton, Qt::NoModifier, QPoint(20,0)); QTest::mouseMove(window, QPoint(20,20)); QTest::mouseMove(window, QPoint(20,70)); + // This should also apply to the negative coordinates above, but: QTBUG-104046. + static const QRegularExpression warningRegex("Mouse event at \\d+, \\d+ occurs outside target window \\(\\d+x\\d+\\).*"); + QVERIFY(warningRegex.isValid()); + if (distance >= window->size().height()) + QTest::ignoreMessage(QtWarningMsg, warningRegex); QTest::mouseMove(window, QPoint(20,distance)); + if (distance >= window->size().height()) + QTest::ignoreMessage(QtWarningMsg, warningRegex); QTest::mouseRelease(window, Qt::LeftButton, Qt::NoModifier, QPoint(20,distance)); // view should settle back at 0 QTRY_COMPARE(listview->contentY(), 0.0); @@ -2371,11 +2375,11 @@ void tst_QQuickListView::sectionsDelegate_headerVisibility() QQuickItem *contentItem = listview->contentItem(); QTRY_VERIFY(contentItem != nullptr); - QVERIFY(QQuickTest::qWaitForItemPolished(listview)); + QVERIFY(QQuickTest::qWaitForPolish(listview)); // ensure section header is maintained in view listview->setCurrentIndex(20); - QVERIFY(QQuickTest::qWaitForItemPolished(listview)); + QVERIFY(QQuickTest::qWaitForPolish(listview)); QTRY_VERIFY(qFuzzyCompare(listview->contentY(), 200.0)); QTRY_VERIFY(!listview->isMoving()); listview->setCurrentIndex(0); @@ -2402,7 +2406,7 @@ void tst_QQuickListView::sectionsPositioning() QTRY_VERIFY(listview != nullptr); QQuickItem *contentItem = listview->contentItem(); QTRY_VERIFY(contentItem != nullptr); - QVERIFY(QQuickTest::qWaitForItemPolished(listview)); + QVERIFY(QQuickTest::qWaitForPolish(listview)); for (int i = 0; i < 3; ++i) { QQuickItem *item = findItem<QQuickItem>(contentItem, "sect_" + QString::number(i)); @@ -2420,12 +2424,12 @@ void tst_QQuickListView::sectionsPositioning() // move down a little and check that section header is at top listview->setContentY(10); - QVERIFY(QQuickTest::qWaitForItemPolished(listview)); + QVERIFY(QQuickTest::qWaitForPolish(listview)); QCOMPARE(topItem->y(), 0.); // push the top header up listview->setContentY(110); - QVERIFY(QQuickTest::qWaitForItemPolished(listview)); + QVERIFY(QQuickTest::qWaitForPolish(listview)); topItem = findVisibleChild(contentItem, "sect_0"); // section header QVERIFY(topItem); QCOMPARE(topItem->y(), 100.); @@ -2440,13 +2444,13 @@ void tst_QQuickListView::sectionsPositioning() // Move past section 0 listview->setContentY(120); - QVERIFY(QQuickTest::qWaitForItemPolished(listview)); + QVERIFY(QQuickTest::qWaitForPolish(listview)); topItem = findVisibleChild(contentItem, "sect_0"); // section header QVERIFY(!topItem); // Push section footer down listview->setContentY(70); - QVERIFY(QQuickTest::qWaitForItemPolished(listview)); + QVERIFY(QQuickTest::qWaitForPolish(listview)); bottomItem = findVisibleChild(contentItem, "sect_4"); // section footer QVERIFY(bottomItem); QCOMPARE(bottomItem->y(), 380.); @@ -2458,7 +2462,7 @@ void tst_QQuickListView::sectionsPositioning() model.modifyItem(2, "Three", "aAa"); model.modifyItem(3, "Four", "aaA"); model.modifyItem(4, "Five", "Aaa"); - QVERIFY(QQuickTest::qWaitForItemPolished(listview)); + QVERIFY(QQuickTest::qWaitForPolish(listview)); QTRY_COMPARE(listview->currentSection(), QString("aaa")); @@ -2474,7 +2478,7 @@ void tst_QQuickListView::sectionsPositioning() // remove section boundary listview->setContentY(120); - QVERIFY(QQuickTest::qWaitForItemPolished(listview)); + QVERIFY(QQuickTest::qWaitForPolish(listview)); model.removeItem(5); listview->forceLayout(); QTRY_COMPARE(listview->count(), model.count()); @@ -2491,27 +2495,27 @@ void tst_QQuickListView::sectionsPositioning() // Change the next section listview->setContentY(0); - QVERIFY(QQuickTest::qWaitForItemPolished(listview)); + QVERIFY(QQuickTest::qWaitForPolish(listview)); bottomItem = findVisibleChild(contentItem, "sect_3"); // section footer QVERIFY(bottomItem); QTRY_COMPARE(bottomItem->y(), 300.); model.modifyItem(14, "New", "new"); - QVERIFY(QQuickTest::qWaitForItemPolished(listview)); + QVERIFY(QQuickTest::qWaitForPolish(listview)); QTRY_VERIFY(bottomItem = findVisibleChild(contentItem, "sect_new")); // section footer QTRY_COMPARE(bottomItem->y(), 300.); // delegate size increase should push section footer down listview->setContentY(70); - QVERIFY(QQuickTest::qWaitForItemPolished(listview)); + QVERIFY(QQuickTest::qWaitForPolish(listview)); QTRY_VERIFY(bottomItem = findVisibleChild(contentItem, "sect_3")); // section footer QTRY_COMPARE(bottomItem->y(), 370.); QQuickItem *inlineSection = findVisibleChild(contentItem, "sect_new"); item = findItem<QQuickItem>(contentItem, "wrapper", 13); QVERIFY(item); item->setHeight(40.); - QVERIFY(QQuickTest::qWaitForItemPolished(listview)); + QVERIFY(QQuickTest::qWaitForPolish(listview)); QTRY_COMPARE(bottomItem->y(), 380.); QCOMPARE(inlineSection->y(), 360.); item->setHeight(20.); @@ -2519,14 +2523,14 @@ void tst_QQuickListView::sectionsPositioning() // Turn sticky footer off listview->setContentY(20); window->rootObject()->setProperty("sectionPositioning", QVariant(int(QQuickViewSection::InlineLabels | QQuickViewSection::CurrentLabelAtStart))); - QVERIFY(QQuickTest::qWaitForItemPolished(listview)); + QVERIFY(QQuickTest::qWaitForPolish(listview)); QTRY_VERIFY(item = findVisibleChild(contentItem, "sect_new")); // inline label restored QCOMPARE(item->y(), 340.); // Turn sticky header off listview->setContentY(30); window->rootObject()->setProperty("sectionPositioning", QVariant(int(QQuickViewSection::InlineLabels))); - QVERIFY(QQuickTest::qWaitForItemPolished(listview)); + QVERIFY(QQuickTest::qWaitForPolish(listview)); QTRY_VERIFY(item = findVisibleChild(contentItem, "sect_aaa")); // inline label restored QCOMPARE(item->y(), 0.); @@ -2562,7 +2566,7 @@ void tst_QQuickListView::sectionPropertyChange() QQuickItem *contentItem = listview->contentItem(); QTRY_VERIFY(contentItem != nullptr); - QVERIFY(QQuickTest::qWaitForItemPolished(listview)); + QVERIFY(QQuickTest::qWaitForPolish(listview)); // Confirm items positioned correctly for (int i = 0; i < 2; ++i) { @@ -2572,7 +2576,7 @@ void tst_QQuickListView::sectionPropertyChange() } QMetaObject::invokeMethod(window->rootObject(), "switchGroups"); - QVERIFY(QQuickTest::qWaitForItemPolished(listview)); + QVERIFY(QQuickTest::qWaitForPolish(listview)); // Confirm items positioned correctly for (int i = 0; i < 2; ++i) { @@ -2582,7 +2586,7 @@ void tst_QQuickListView::sectionPropertyChange() } QMetaObject::invokeMethod(window->rootObject(), "switchGroups"); - QVERIFY(QQuickTest::qWaitForItemPolished(listview)); + QVERIFY(QQuickTest::qWaitForPolish(listview)); // Confirm items positioned correctly for (int i = 0; i < 2; ++i) { @@ -2592,7 +2596,7 @@ void tst_QQuickListView::sectionPropertyChange() } QMetaObject::invokeMethod(window->rootObject(), "switchGrouped"); - QVERIFY(QQuickTest::qWaitForItemPolished(listview)); + QVERIFY(QQuickTest::qWaitForPolish(listview)); // Confirm items positioned correctly for (int i = 0; i < 2; ++i) { @@ -2602,7 +2606,7 @@ void tst_QQuickListView::sectionPropertyChange() } QMetaObject::invokeMethod(window->rootObject(), "switchGrouped"); - QVERIFY(QQuickTest::qWaitForItemPolished(listview)); + QVERIFY(QQuickTest::qWaitForPolish(listview)); // Confirm items positioned correctly for (int i = 0; i < 2; ++i) { @@ -2626,10 +2630,10 @@ void tst_QQuickListView::sectionDelegateChange() QQuickItem *contentItem = listview->contentItem(); QVERIFY(contentItem != nullptr); - QQuickTest::qWaitForItemPolished(listview); + QQuickTest::qWaitForPolish(listview); - QVERIFY(findItems<QQuickItem>(contentItem, "section1").count() > 0); - QCOMPARE(findItems<QQuickItem>(contentItem, "section2").count(), 0); + QVERIFY(findItems<QQuickItem>(contentItem, "section1").size() > 0); + QCOMPARE(findItems<QQuickItem>(contentItem, "section2").size(), 0); for (int i = 0; i < 3; ++i) { QQuickItem *item = findItem<QQuickItem>(contentItem, "item", i); @@ -2638,10 +2642,10 @@ void tst_QQuickListView::sectionDelegateChange() } QMetaObject::invokeMethod(window->rootObject(), "switchDelegates"); - QQuickTest::qWaitForItemPolished(listview); + QQuickTest::qWaitForPolish(listview); - QCOMPARE(findItems<QQuickItem>(contentItem, "section1").count(), 0); - QVERIFY(findItems<QQuickItem>(contentItem, "section2").count() > 0); + QCOMPARE(findItems<QQuickItem>(contentItem, "section1").size(), 0); + QVERIFY(findItems<QQuickItem>(contentItem, "section2").size() > 0); for (int i = 0; i < 3; ++i) { QQuickItem *item = findItem<QQuickItem>(contentItem, "item", i); @@ -2670,7 +2674,7 @@ void tst_QQuickListView::sectionsItemInsertion() QTRY_VERIFY(listview != nullptr); QQuickItem *contentItem = listview->contentItem(); QTRY_VERIFY(contentItem != nullptr); - QVERIFY(QQuickTest::qWaitForItemPolished(listview)); + QVERIFY(QQuickTest::qWaitForPolish(listview)); for (int i = 0; i < 3; ++i) { QQuickItem *item = findItem<QQuickItem>(contentItem, "sect_" + QString::number(i)); @@ -2686,9 +2690,9 @@ void tst_QQuickListView::sectionsItemInsertion() for (int i = 0; i < 10; i++) model.insertItem(i, "Item" + QString::number(i), QLatin1String("A")); - QVERIFY(QQuickTest::qWaitForItemPolished(listview)); + QVERIFY(QQuickTest::qWaitForPolish(listview)); - int itemCount = findItems<QQuickItem>(contentItem, "wrapper").count(); + int itemCount = findItems<QQuickItem>(contentItem, "wrapper").size(); QVERIFY(itemCount > 10); // Verify that the new items are postioned correctly, and have the correct attached section properties @@ -2736,7 +2740,7 @@ void tst_QQuickListView::sectionsSnap() QTRY_VERIFY(listview != nullptr); listview->setSnapMode(snapMode); - QTRY_COMPARE(QQuickItemPrivate::get(listview)->polishScheduled, false); + QTRY_VERIFY(!QQuickItemPrivate::get(listview)->polishScheduled); QTRY_COMPARE(listview->currentIndex(), 0); QCOMPARE(listview->contentY(), qreal(-50)); @@ -2788,7 +2792,7 @@ void tst_QQuickListView::currentIndex_delayedItemCreation() QSignalSpy spy(listview, SIGNAL(currentItemChanged())); //QCOMPARE(listview->currentIndex(), 0); listview->forceLayout(); - QTRY_COMPARE(spy.count(), 1); + QTRY_COMPARE(spy.size(), 1); releaseView(window); } @@ -2824,7 +2828,7 @@ void tst_QQuickListView::currentIndex() QTRY_VERIFY(listview != nullptr); QQuickItem *contentItem = listview->contentItem(); QTRY_VERIFY(contentItem != nullptr); - QVERIFY(QQuickTest::qWaitForItemPolished(listview)); + QVERIFY(QQuickTest::qWaitForPolish(listview)); // currentIndex is initialized to 20 // currentItem should be in view @@ -2894,9 +2898,9 @@ void tst_QQuickListView::currentIndex() // moving currentItem out of view should make it invisible listview->setCurrentIndex(0); - QTRY_VERIFY(delegateVisible(listview->currentItem())); + QTRY_VERIFY(isDelegateVisible(listview->currentItem())); listview->setContentY(200); - QTRY_VERIFY(!delegateVisible(listview->currentItem())); + QTRY_VERIFY(!isDelegateVisible(listview->currentItem())); // empty model should reset currentIndex to -1 QaimModel emptyModel; @@ -2929,7 +2933,7 @@ void tst_QQuickListView::noCurrentIndex() QTRY_VERIFY(listview != nullptr); QQuickItem *contentItem = listview->contentItem(); QTRY_VERIFY(contentItem != nullptr); - QVERIFY(QQuickTest::qWaitForItemPolished(listview)); + QVERIFY(QQuickTest::qWaitForPolish(listview)); // current index should be -1 at startup // and we should not have a currentItem or highlightItem @@ -2958,8 +2962,8 @@ void tst_QQuickListView::keyNavigation() for (int i = 0; i < 30; i++) model.addItem("Item" + QString::number(i), ""); - QQuickView *window = getView(); QScopedPointer<TestObject> testObject(new TestObject); + QQuickView *window = getView(); window->rootContext()->setContextProperty("testModel", &model); window->rootContext()->setContextProperty("testObject", testObject.data()); window->setSource(testFileUrl("listviewtest.qml")); @@ -2972,7 +2976,7 @@ void tst_QQuickListView::keyNavigation() listview->setOrientation(orientation); listview->setLayoutDirection(layoutDirection); listview->setVerticalLayoutDirection(verticalLayoutDirection); - QVERIFY(QQuickTest::qWaitForItemPolished(listview)); + QVERIFY(QQuickTest::qWaitForPolish(listview)); window->requestActivate(); QVERIFY(QTest::qWaitForWindowActive(window)); @@ -3128,41 +3132,43 @@ void tst_QQuickListView::itemListFlicker() QQuickItem *item = findItem<QQuickItem>(contentItem, "item1"); QVERIFY(item); - QVERIFY(delegateVisible(item)); + QVERIFY(isDelegateVisible(item)); item = findItem<QQuickItem>(contentItem, "item2"); QVERIFY(item); - QVERIFY(delegateVisible(item)); + QVERIFY(isDelegateVisible(item)); item = findItem<QQuickItem>(contentItem, "item3"); QVERIFY(item); - QVERIFY(delegateVisible(item)); + QVERIFY(isDelegateVisible(item)); listview->setCurrentIndex(1); item = findItem<QQuickItem>(contentItem, "item1"); QVERIFY(item); - QVERIFY(delegateVisible(item)); + QVERIFY(isDelegateVisible(item)); item = findItem<QQuickItem>(contentItem, "item2"); QVERIFY(item); - QVERIFY(delegateVisible(item)); + QVERIFY(isDelegateVisible(item)); item = findItem<QQuickItem>(contentItem, "item3"); QVERIFY(item); - QVERIFY(delegateVisible(item)); + QVERIFY(isDelegateVisible(item)); listview->setCurrentIndex(2); item = findItem<QQuickItem>(contentItem, "item1"); QVERIFY(item); - QVERIFY(delegateVisible(item)); + QVERIFY(isDelegateVisible(item)); item = findItem<QQuickItem>(contentItem, "item2"); QVERIFY(item); - QVERIFY(delegateVisible(item)); + QVERIFY(isDelegateVisible(item)); item = findItem<QQuickItem>(contentItem, "item3"); QVERIFY(item); - QVERIFY(delegateVisible(item)); + QVERIFY(isDelegateVisible(item)); } void tst_QQuickListView::cacheBuffer() { + QScopedPointer<TestObject> testObject(new TestObject); + QScopedPointer<QQuickView> window(createView()); QaimModel model; @@ -3172,7 +3178,6 @@ void tst_QQuickListView::cacheBuffer() QQmlContext *ctxt = window->rootContext(); ctxt->setContextProperty("testModel", &model); - QScopedPointer<TestObject> testObject(new TestObject); ctxt->setContextProperty("testObject", testObject.data()); window->setSource(testFileUrl("listviewtest.qml")); @@ -3189,7 +3194,7 @@ void tst_QQuickListView::cacheBuffer() QTRY_VERIFY(listview->highlight() != nullptr); // Confirm items positioned correctly - int itemCount = findItems<QQuickItem>(contentItem, "wrapper").count(); + int itemCount = findItems<QQuickItem>(contentItem, "wrapper").size(); for (int i = 0; i < model.count() && i < itemCount; ++i) { QQuickItem *item = findItem<QQuickItem>(contentItem, "wrapper", i); if (!item) qWarning() << "Item" << i << "not found"; @@ -3220,7 +3225,7 @@ void tst_QQuickListView::cacheBuffer() } int newItemCount = 0; - newItemCount = findItems<QQuickItem>(contentItem, "wrapper").count(); + newItemCount = findItems<QQuickItem>(contentItem, "wrapper").size(); // Confirm items positioned correctly for (int i = 0; i < model.count() && i < newItemCount; ++i) { @@ -3258,13 +3263,16 @@ void tst_QQuickListView::cacheBuffer() controller.incubateWhile(&b); } - // negative cache buffer is ignored + // it should warn when setting a negative cache buffer + QTest::ignoreMessage(QtWarningMsg, QRegularExpression(".*Cannot set a negative cache buffer")); listview->setCacheBuffer(-1); QCOMPARE(listview->cacheBuffer(), 200); } void tst_QQuickListView::positionViewAtBeginningEnd() { + QScopedPointer<TestObject> testObject(new TestObject); + QScopedPointer<QQuickView> window(createView()); QaimModel model; @@ -3274,7 +3282,6 @@ void tst_QQuickListView::positionViewAtBeginningEnd() QQmlContext *ctxt = window->rootContext(); ctxt->setContextProperty("testModel", &model); - QScopedPointer<TestObject> testObject(new TestObject); ctxt->setContextProperty("testObject", testObject.data()); window->show(); window->setSource(testFileUrl("listviewtest.qml")); @@ -3284,7 +3291,7 @@ void tst_QQuickListView::positionViewAtBeginningEnd() QTRY_VERIFY(listview != nullptr); QQuickItem *contentItem = listview->contentItem(); QTRY_VERIFY(contentItem != nullptr); - QVERIFY(QQuickTest::qWaitForItemPolished(listview)); + QVERIFY(QQuickTest::qWaitForPolish(listview)); listview->setContentY(100); @@ -3323,6 +3330,8 @@ void tst_QQuickListView::positionViewAtIndex() QFETCH(QQuickListView::PositionMode, mode); QFETCH(qreal, contentY); + QScopedPointer<TestObject> testObject(new TestObject); + QQuickView *window = getView(); QaimModel model; @@ -3332,7 +3341,6 @@ void tst_QQuickListView::positionViewAtIndex() QQmlContext *ctxt = window->rootContext(); ctxt->setContextProperty("testModel", &model); - QScopedPointer<TestObject> testObject(new TestObject); ctxt->setContextProperty("testObject", testObject.data()); window->show(); window->setSource(testFileUrl("listviewtest.qml")); @@ -3342,10 +3350,10 @@ void tst_QQuickListView::positionViewAtIndex() QTRY_VERIFY(listview != nullptr); QQuickItem *contentItem = listview->contentItem(); QTRY_VERIFY(contentItem != nullptr); - QVERIFY(QQuickTest::qWaitForItemPolished(listview)); + QVERIFY(QQuickTest::qWaitForPolish(listview)); window->rootObject()->setProperty("enforceRange", enforceRange); - QVERIFY(QQuickTest::qWaitForItemPolished(listview)); + QVERIFY(QQuickTest::qWaitForPolish(listview)); listview->setContentY(initContentY); @@ -3353,7 +3361,7 @@ void tst_QQuickListView::positionViewAtIndex() QTRY_COMPARE(listview->contentY(), contentY); // Confirm items positioned correctly - int itemCount = findItems<QQuickItem>(contentItem, "wrapper").count(); + int itemCount = findItems<QQuickItem>(contentItem, "wrapper").size(); for (int i = index; i < model.count() && i < itemCount-index-1; ++i) { QQuickItem *item = findItem<QQuickItem>(contentItem, "wrapper", i); if (!item) qWarning() << "Item" << i << "not found"; @@ -3422,7 +3430,7 @@ void tst_QQuickListView::resetModel() QTRY_VERIFY(listview != nullptr); QQuickItem *contentItem = listview->contentItem(); QTRY_VERIFY(contentItem != nullptr); - QVERIFY(QQuickTest::qWaitForItemPolished(listview)); + QVERIFY(QQuickTest::qWaitForPolish(listview)); QTRY_COMPARE(listview->count(), model.rowCount()); @@ -3486,13 +3494,13 @@ void tst_QQuickListView::propertyChanges() QTRY_COMPARE(listView->cacheBuffer(), 3); QTRY_COMPARE(listView->snapMode(), QQuickListView::SnapOneItem); - QTRY_COMPARE(highlightFollowsCurrentItemSpy.count(),1); - QTRY_COMPARE(preferredHighlightBeginSpy.count(),1); - QTRY_COMPARE(preferredHighlightEndSpy.count(),1); - QTRY_COMPARE(highlightRangeModeSpy.count(),1); - QTRY_COMPARE(keyNavigationWrapsSpy.count(),1); - QTRY_COMPARE(cacheBufferSpy.count(),1); - QTRY_COMPARE(snapModeSpy.count(),1); + QTRY_COMPARE(highlightFollowsCurrentItemSpy.size(),1); + QTRY_COMPARE(preferredHighlightBeginSpy.size(),1); + QTRY_COMPARE(preferredHighlightEndSpy.size(),1); + QTRY_COMPARE(highlightRangeModeSpy.size(),1); + QTRY_COMPARE(keyNavigationWrapsSpy.size(),1); + QTRY_COMPARE(cacheBufferSpy.size(),1); + QTRY_COMPARE(snapModeSpy.size(),1); listView->setHighlightFollowsCurrentItem(false); listView->setPreferredHighlightBegin(1.0); @@ -3502,13 +3510,13 @@ void tst_QQuickListView::propertyChanges() listView->setCacheBuffer(3); listView->setSnapMode(QQuickListView::SnapOneItem); - QTRY_COMPARE(highlightFollowsCurrentItemSpy.count(),1); - QTRY_COMPARE(preferredHighlightBeginSpy.count(),1); - QTRY_COMPARE(preferredHighlightEndSpy.count(),1); - QTRY_COMPARE(highlightRangeModeSpy.count(),1); - QTRY_COMPARE(keyNavigationWrapsSpy.count(),1); - QTRY_COMPARE(cacheBufferSpy.count(),1); - QTRY_COMPARE(snapModeSpy.count(),1); + QTRY_COMPARE(highlightFollowsCurrentItemSpy.size(),1); + QTRY_COMPARE(preferredHighlightBeginSpy.size(),1); + QTRY_COMPARE(preferredHighlightEndSpy.size(),1); + QTRY_COMPARE(highlightRangeModeSpy.size(),1); + QTRY_COMPARE(keyNavigationWrapsSpy.size(),1); + QTRY_COMPARE(cacheBufferSpy.size(),1); + QTRY_COMPARE(snapModeSpy.size(),1); } void tst_QQuickListView::componentChanges() @@ -3540,20 +3548,20 @@ void tst_QQuickListView::componentChanges() QTRY_COMPARE(listView->footer(), &component); QTRY_COMPARE(listView->delegate(), &delegateComponent); - QTRY_COMPARE(highlightSpy.count(),1); - QTRY_COMPARE(delegateSpy.count(),1); - QTRY_COMPARE(headerSpy.count(),1); - QTRY_COMPARE(footerSpy.count(),1); + QTRY_COMPARE(highlightSpy.size(),1); + QTRY_COMPARE(delegateSpy.size(),1); + QTRY_COMPARE(headerSpy.size(),1); + QTRY_COMPARE(footerSpy.size(),1); listView->setHighlight(&component); listView->setHeader(&component); listView->setFooter(&component); listView->setDelegate(&delegateComponent); - QTRY_COMPARE(highlightSpy.count(),1); - QTRY_COMPARE(delegateSpy.count(),1); - QTRY_COMPARE(headerSpy.count(),1); - QTRY_COMPARE(footerSpy.count(),1); + QTRY_COMPARE(highlightSpy.size(),1); + QTRY_COMPARE(delegateSpy.size(),1); + QTRY_COMPARE(headerSpy.size(),1); + QTRY_COMPARE(footerSpy.size(),1); } void tst_QQuickListView::modelChanges() @@ -3571,13 +3579,13 @@ void tst_QQuickListView::modelChanges() listView->setModel(modelVariant); QTRY_COMPARE(listView->model(), modelVariant); - QTRY_COMPARE(modelSpy.count(),1); + QTRY_COMPARE(modelSpy.size(),1); listView->setModel(modelVariant); - QTRY_COMPARE(modelSpy.count(),1); + QTRY_COMPARE(modelSpy.size(),1); listView->setModel(QVariant()); - QTRY_COMPARE(modelSpy.count(),2); + QTRY_COMPARE(modelSpy.size(),2); } void tst_QQuickListView::QTBUG_9791() @@ -3599,7 +3607,7 @@ void tst_QQuickListView::QTBUG_9791() qApp->processEvents(); // Confirm items positioned correctly - int itemCount = findItems<QQuickItem>(contentItem, "wrapper", false).count(); + int itemCount = findItems<QQuickItem>(contentItem, "wrapper", false).size(); QCOMPARE(itemCount, 3); for (int i = 0; i < itemCount; ++i) { @@ -3628,12 +3636,12 @@ void tst_QQuickListView::QTBUG_33568() listview->incrementCurrentIndex(); QTRY_COMPARE(listview->contentY(), -100.0); - QVERIFY(spy.count() > 1); + QVERIFY(spy.size() > 1); spy.clear(); listview->incrementCurrentIndex(); QTRY_COMPARE(listview->contentY(), -50.0); - QVERIFY(spy.count() > 1); + QVERIFY(spy.size() > 1); } void tst_QQuickListView::manualHighlight() @@ -3672,6 +3680,8 @@ void tst_QQuickListView::manualHighlight() void tst_QQuickListView::QTBUG_11105() { + QScopedPointer<TestObject> testObject(new TestObject); + QScopedPointer<QQuickView> window(createView()); QaimModel model; for (int i = 0; i < 30; i++) @@ -3680,7 +3690,6 @@ void tst_QQuickListView::QTBUG_11105() QQmlContext *ctxt = window->rootContext(); ctxt->setContextProperty("testModel", &model); - QScopedPointer<TestObject> testObject(new TestObject); ctxt->setContextProperty("testObject", testObject.data()); window->setSource(testFileUrl("listviewtest.qml")); @@ -3691,10 +3700,10 @@ void tst_QQuickListView::QTBUG_11105() QTRY_VERIFY(listview != nullptr); QQuickItem *contentItem = listview->contentItem(); QTRY_VERIFY(contentItem != nullptr); - QVERIFY(QQuickTest::qWaitForItemPolished(listview)); + QVERIFY(QQuickTest::qWaitForPolish(listview)); // Confirm items positioned correctly - int itemCount = findItems<QQuickItem>(contentItem, "wrapper").count(); + int itemCount = findItems<QQuickItem>(contentItem, "wrapper").size(); for (int i = 0; i < model.count() && i < itemCount; ++i) { QQuickItem *item = findItem<QQuickItem>(contentItem, "wrapper", i); if (!item) qWarning() << "Item" << i << "not found"; @@ -3711,7 +3720,7 @@ void tst_QQuickListView::QTBUG_11105() ctxt->setContextProperty("testModel", &model2); - itemCount = findItems<QQuickItem>(contentItem, "wrapper").count(); + itemCount = findItems<QQuickItem>(contentItem, "wrapper").size(); QCOMPARE(itemCount, 5); } @@ -3781,7 +3790,7 @@ void tst_QQuickListView::header() listview->setOrientation(orientation); listview->setLayoutDirection(layoutDirection); listview->setVerticalLayoutDirection(verticalLayoutDirection); - QVERIFY(QQuickTest::qWaitForItemPolished(listview)); + QVERIFY(QQuickTest::qWaitForPolish(listview)); QQuickItem *contentItem = listview->contentItem(); QTRY_VERIFY(contentItem != nullptr); @@ -3819,7 +3828,7 @@ void tst_QQuickListView::header() QSignalSpy headerItemSpy(listview, SIGNAL(headerItemChanged())); QMetaObject::invokeMethod(window->rootObject(), "changeHeader"); - QCOMPARE(headerItemSpy.count(), 1); + QCOMPARE(headerItemSpy.size(), 1); header = findItem<QQuickText>(contentItem, "header"); QVERIFY(!header); @@ -3860,7 +3869,7 @@ void tst_QQuickListView::header() listview->setOrientation(orientation); listview->setLayoutDirection(layoutDirection); listview->setVerticalLayoutDirection(verticalLayoutDirection); - QVERIFY(QQuickTest::qWaitForItemPolished(listview)); + QVERIFY(QQuickTest::qWaitForPolish(listview)); listview->setWidth(240); listview->setHeight(320); @@ -3967,7 +3976,7 @@ void tst_QQuickListView::headerChangesViewport() QQuickListView *listview = findItem<QQuickListView>(window->rootObject(), "list"); QTRY_VERIFY(listview != nullptr); - QVERIFY(QQuickTest::qWaitForItemPolished(listview)); + QVERIFY(QQuickTest::qWaitForPolish(listview)); QQuickItem *contentItem = listview->contentItem(); QTRY_VERIFY(contentItem != nullptr); @@ -4017,7 +4026,7 @@ void tst_QQuickListView::footer() listview->setOrientation(orientation); listview->setLayoutDirection(layoutDirection); listview->setVerticalLayoutDirection(verticalLayoutDirection); - QVERIFY(QQuickTest::qWaitForItemPolished(listview)); + QVERIFY(QQuickTest::qWaitForPolish(listview)); QQuickItem *contentItem = listview->contentItem(); QTRY_VERIFY(contentItem != nullptr); @@ -4078,7 +4087,7 @@ void tst_QQuickListView::footer() QSignalSpy footerItemSpy(listview, SIGNAL(footerItemChanged())); QMetaObject::invokeMethod(window->rootObject(), "changeFooter"); - QCOMPARE(footerItemSpy.count(), 1); + QCOMPARE(footerItemSpy.size(), 1); footer = findItem<QQuickText>(contentItem, "footer"); QVERIFY(!footer); @@ -4221,7 +4230,7 @@ void tst_QQuickListView::extents() listview->setOrientation(orientation); listview->setLayoutDirection(layoutDirection); listview->setVerticalLayoutDirection(verticalLayoutDirection); - QVERIFY(QQuickTest::qWaitForItemPolished(listview)); + QVERIFY(QQuickTest::qWaitForPolish(listview)); QQuickItem *contentItem = listview->contentItem(); QTRY_VERIFY(contentItem != nullptr); @@ -4277,26 +4286,24 @@ void tst_QQuickListView::extents_data() QTest::newRow("Vertical, TopToBottom") << QQuickListView::Vertical << Qt::LeftToRight << QQuickItemView::TopToBottom - << QPointF(0, -20) << QPointF(0, 0) - << QPointF(0, 20) << QPointF(240, 20) + << QPointF(0, -20) << QPointF(0, 0) << QPointF(0, 20) << QPointF(0, 20) << QPointF(0, -20) << QPointF(0, -20) << QPointF(0, -20); QTest::newRow("Vertical, BottomToTop") << QQuickListView::Vertical << Qt::LeftToRight << QQuickItemView::BottomToTop - << QPointF(0, 0) << QPointF(0, -30) - << QPointF(0, 320 - 20) << QPointF(240, 320 - 20) // content flow is reversed + << QPointF(0, 0) << QPointF(0, -30) << QPointF(0, 320 - 20) + << QPointF(0, 320 - 20) // content flow is reversed << QPointF(0, -30) << QPointF(0, (-30.0 * 3) - 30) << QPointF(0, (-30.0 * 30) - 30); QTest::newRow("Horizontal, LeftToRight") << QQuickListView::Horizontal << Qt::LeftToRight << QQuickItemView::TopToBottom - << QPointF(-20, 0) << QPointF(0, 0) - << QPointF(20, 0) << QPointF(20, 320) + << QPointF(-20, 0) << QPointF(0, 0) << QPointF(20, 0) << QPointF(20, 0) << QPointF(-20, 0) << QPointF(-20, 0) << QPointF(-20, 0); QTest::newRow("Horizontal, RightToLeft") << QQuickListView::Horizontal << Qt::RightToLeft << QQuickItemView::TopToBottom - << QPointF(0, 0) << QPointF(-30, 0) - << QPointF(240 - 20, 0) << QPointF(240 - 20, 320) // content flow is reversed + << QPointF(0, 0) << QPointF(-30, 0) << QPointF(240 - 20, 0) + << QPointF(240 - 20, 0) // content flow is reversed << QPointF(-30, 0) << QPointF((-240.0 * 3) - 30, 0) << QPointF((-240.0 * 30) - 30, 0); } @@ -4342,6 +4349,8 @@ void tst_QQuickListView::resetModel_headerFooter() void tst_QQuickListView::resizeView() { + QScopedPointer<TestObject> testObject(new TestObject); + QScopedPointer<QQuickView> window(createView()); QaimModel model; for (int i = 0; i < 40; i++) @@ -4350,7 +4359,6 @@ void tst_QQuickListView::resizeView() QQmlContext *ctxt = window->rootContext(); ctxt->setContextProperty("testModel", &model); - QScopedPointer<TestObject> testObject(new TestObject); ctxt->setContextProperty("testObject", testObject.data()); window->setSource(testFileUrl("listviewtest.qml")); @@ -4361,10 +4369,10 @@ void tst_QQuickListView::resizeView() QTRY_VERIFY(listview != nullptr); QQuickItem *contentItem = listview->contentItem(); QTRY_VERIFY(contentItem != nullptr); - QVERIFY(QQuickTest::qWaitForItemPolished(listview)); + QVERIFY(QQuickTest::qWaitForPolish(listview)); // Confirm items positioned correctly - int itemCount = findItems<QQuickItem>(contentItem, "wrapper").count(); + int itemCount = findItems<QQuickItem>(contentItem, "wrapper").size(); for (int i = 0; i < model.count() && i < itemCount; ++i) { QQuickItem *item = findItem<QQuickItem>(contentItem, "wrapper", i); if (!item) qWarning() << "Item" << i << "not found"; @@ -4377,42 +4385,42 @@ void tst_QQuickListView::resizeView() QCOMPARE(heightRatio.toReal(), 0.4); listview->setHeight(200); - QVERIFY(QQuickTest::qWaitForItemPolished(listview)); + QVERIFY(QQuickTest::qWaitForPolish(listview)); QMetaObject::invokeMethod(window->rootObject(), "heightRatio", Q_RETURN_ARG(QVariant, heightRatio)); QCOMPARE(heightRatio.toReal(), 0.25); // Ensure we handle -ve sizes listview->setHeight(-100); - QTRY_COMPARE(findItems<QQuickItem>(contentItem, "wrapper", false).count(), 1); + QTRY_COMPARE(findItems<QQuickItem>(contentItem, "wrapper", false).size(), 1); listview->setCacheBuffer(200); - QTRY_COMPARE(findItems<QQuickItem>(contentItem, "wrapper", false).count(), 11); + QTRY_COMPARE(findItems<QQuickItem>(contentItem, "wrapper", false).size(), 11); // ensure items in cache become visible listview->setHeight(200); - QTRY_COMPARE(findItems<QQuickItem>(contentItem, "wrapper", false).count(), 21); + QTRY_COMPARE(findItems<QQuickItem>(contentItem, "wrapper", false).size(), 21); - itemCount = findItems<QQuickItem>(contentItem, "wrapper", false).count(); + itemCount = findItems<QQuickItem>(contentItem, "wrapper", false).size(); for (int i = 0; i < model.count() && i < itemCount; ++i) { QQuickItem *item = findItem<QQuickItem>(contentItem, "wrapper", i); if (!item) qWarning() << "Item" << i << "not found"; QTRY_VERIFY(item); QTRY_COMPARE(item->y(), i*20.); - QCOMPARE(delegateVisible(item), i < 11); // inside view visible, outside not visible + QCOMPARE(isDelegateVisible(item), i < 11); // inside view visible, outside not visible } // ensure items outside view become invisible listview->setHeight(100); - QTRY_COMPARE(findItems<QQuickItem>(contentItem, "wrapper", false).count(), 16); + QTRY_COMPARE(findItems<QQuickItem>(contentItem, "wrapper", false).size(), 16); - itemCount = findItems<QQuickItem>(contentItem, "wrapper", false).count(); + itemCount = findItems<QQuickItem>(contentItem, "wrapper", false).size(); for (int i = 0; i < model.count() && i < itemCount; ++i) { QQuickItem *item = findItem<QQuickItem>(contentItem, "wrapper", i); if (!item) qWarning() << "Item" << i << "not found"; QTRY_VERIFY(item); QTRY_COMPARE(item->y(), i*20.); - QCOMPARE(delegateVisible(item), i < 6); // inside view visible, outside not visible + QCOMPARE(isDelegateVisible(item), i < 6); // inside view visible, outside not visible } } @@ -4436,7 +4444,7 @@ void tst_QQuickListView::resizeViewAndRepaint() QTRY_VERIFY(listview != nullptr); QQuickItem *contentItem = listview->contentItem(); QTRY_VERIFY(contentItem != nullptr); - QVERIFY(QQuickTest::qWaitForItemPolished(listview)); + QVERIFY(QQuickTest::qWaitForPolish(listview)); // item at index 10 should not be currently visible QVERIFY(!findItem<QQuickItem>(contentItem, "wrapper", 10)); @@ -4451,6 +4459,8 @@ void tst_QQuickListView::resizeViewAndRepaint() void tst_QQuickListView::sizeLessThan1() { + QScopedPointer<TestObject> testObject(new TestObject); + QScopedPointer<QQuickView> window(createView()); QaimModel model; @@ -4460,7 +4470,6 @@ void tst_QQuickListView::sizeLessThan1() QQmlContext *ctxt = window->rootContext(); ctxt->setContextProperty("testModel", &model); - QScopedPointer<TestObject> testObject(new TestObject); ctxt->setContextProperty("testObject", testObject.data()); window->setSource(testFileUrl("sizelessthan1.qml")); @@ -4471,10 +4480,10 @@ void tst_QQuickListView::sizeLessThan1() QTRY_VERIFY(listview != nullptr); QQuickItem *contentItem = listview->contentItem(); QTRY_VERIFY(contentItem != nullptr); - QVERIFY(QQuickTest::qWaitForItemPolished(listview)); + QVERIFY(QQuickTest::qWaitForPolish(listview)); // Confirm items positioned correctly - int itemCount = findItems<QQuickItem>(contentItem, "wrapper").count(); + int itemCount = findItems<QQuickItem>(contentItem, "wrapper").size(); for (int i = 0; i < model.count() && i < itemCount; ++i) { QQuickItem *item = findItem<QQuickItem>(contentItem, "wrapper", i); if (!item) qWarning() << "Item" << i << "not found"; @@ -4521,13 +4530,13 @@ void tst_QQuickListView::resizeDelegate() QVERIFY(listview != nullptr); QQuickItem *contentItem = listview->contentItem(); QVERIFY(contentItem != nullptr); - QVERIFY(QQuickTest::qWaitForItemPolished(listview)); + QVERIFY(QQuickTest::qWaitForPolish(listview)); QCOMPARE(listview->count(), model.rowCount()); listview->setCurrentIndex(25); listview->setContentY(0); - QVERIFY(QQuickTest::qWaitForItemPolished(listview)); + QVERIFY(QQuickTest::qWaitForPolish(listview)); for (int i = 0; i < 16; ++i) { QQuickItem *item = findItem<QQuickItem>(contentItem, "wrapper", i); @@ -4539,7 +4548,7 @@ void tst_QQuickListView::resizeDelegate() QTRY_COMPARE(listview->highlightItem()->y(), 500.0); window->rootObject()->setProperty("delegateHeight", 30); - QVERIFY(QQuickTest::qWaitForItemPolished(listview)); + QVERIFY(QQuickTest::qWaitForPolish(listview)); for (int i = 0; i < 11; ++i) { QQuickItem *item = findItem<QQuickItem>(contentItem, "wrapper", i); @@ -4553,7 +4562,7 @@ void tst_QQuickListView::resizeDelegate() listview->setCurrentIndex(1); listview->positionViewAtIndex(25, QQuickListView::Beginning); listview->positionViewAtIndex(5, QQuickListView::Beginning); - QVERIFY(QQuickTest::qWaitForItemPolished(listview)); + QVERIFY(QQuickTest::qWaitForPolish(listview)); for (int i = 5; i < 16; ++i) { QQuickItem *item = findItem<QQuickItem>(contentItem, "wrapper", i); @@ -4565,7 +4574,7 @@ void tst_QQuickListView::resizeDelegate() QTRY_COMPARE(listview->highlightItem()->y(), 30.0); window->rootObject()->setProperty("delegateHeight", 20); - QVERIFY(QQuickTest::qWaitForItemPolished(listview)); + QVERIFY(QQuickTest::qWaitForPolish(listview)); for (int i = 5; i < 11; ++i) { QQuickItem *item = findItem<QQuickItem>(contentItem, "wrapper", i); @@ -4581,6 +4590,8 @@ void tst_QQuickListView::resizeFirstDelegate() { // QTBUG-20712: Content Y jumps constantly if first delegate height == 0 // and other delegates have height > 0 + QScopedPointer<TestObject> testObject(new TestObject); + QScopedPointer<QQuickView> window(createView()); // bug only occurs when all items in the model are visible @@ -4591,7 +4602,6 @@ void tst_QQuickListView::resizeFirstDelegate() QQmlContext *ctxt = window->rootContext(); ctxt->setContextProperty("testModel", &model); - QScopedPointer<TestObject> testObject(new TestObject); ctxt->setContextProperty("testObject", testObject.data()); window->setSource(testFileUrl("listviewtest.qml")); @@ -4602,7 +4612,7 @@ void tst_QQuickListView::resizeFirstDelegate() QVERIFY(listview != nullptr); QQuickItem *contentItem = listview->contentItem(); QVERIFY(contentItem != nullptr); - QVERIFY(QQuickTest::qWaitForItemPolished(listview)); + QVERIFY(QQuickTest::qWaitForPolish(listview)); QQuickItem *item = nullptr; for (int i = 0; i < model.count(); ++i) { @@ -4618,7 +4628,7 @@ void tst_QQuickListView::resizeFirstDelegate() QCOMPARE(listview->contentY(), 0.0); QSignalSpy spy(listview, SIGNAL(contentYChanged())); QTest::qWait(100); - QCOMPARE(spy.count(), 0); + QCOMPARE(spy.size(), 0); for (int i = 1; i < model.count(); ++i) { item = findItem<QQuickItem>(contentItem, "wrapper", i); @@ -4641,7 +4651,7 @@ void tst_QQuickListView::resizeFirstDelegate() listview->setCurrentIndex(19); qApp->processEvents(); - QVERIFY(QQuickTest::qWaitForItemPolished(listview)); + QVERIFY(QQuickTest::qWaitForPolish(listview)); // items 0-2 should have been deleted for (int i=0; i<3; i++) { @@ -4670,7 +4680,7 @@ void tst_QQuickListView::repositionResizedDelegate() QQuickListView *listview = qobject_cast<QQuickListView*>(window->rootObject()); QTRY_VERIFY(listview != nullptr); - QVERIFY(QQuickTest::qWaitForItemPolished(listview)); + QVERIFY(QQuickTest::qWaitForPolish(listview)); QQuickItem *positioner = findItem<QQuickItem>(window->rootObject(), "positioner"); QVERIFY(positioner); @@ -4685,14 +4695,14 @@ void tst_QQuickListView::repositionResizedDelegate() listview->setContentX(contentPos_itemFirstHalfVisible.x()); listview->setContentY(contentPos_itemFirstHalfVisible.y()); - QVERIFY(QQuickTest::qWaitForItemPolished(listview)); - prevSpyCount = spy.count(); + QVERIFY(QQuickTest::qWaitForPolish(listview)); + prevSpyCount = spy.size(); QVERIFY(QMetaObject::invokeMethod(window->rootObject(), "incrementRepeater")); QTRY_COMPARE(positioner->boundingRect().size(), resizedPositionerRect.size()); QTRY_COMPARE(positioner->position(), resizedPositionerRect.topLeft()); QCOMPARE(listview->contentX(), contentPos_itemFirstHalfVisible.x()); QCOMPARE(listview->contentY(), contentPos_itemFirstHalfVisible.y()); - QCOMPARE(spy.count(), prevSpyCount); + QCOMPARE(spy.size(), prevSpyCount); QVERIFY(QMetaObject::invokeMethod(window->rootObject(), "decrementRepeater")); QTRY_COMPARE(positioner->boundingRect().size(), origPositionerRect.size()); @@ -4702,8 +4712,8 @@ void tst_QQuickListView::repositionResizedDelegate() listview->setContentX(contentPos_itemSecondHalfVisible.x()); listview->setContentY(contentPos_itemSecondHalfVisible.y()); - QVERIFY(QQuickTest::qWaitForItemPolished(listview)); - prevSpyCount = spy.count(); + QVERIFY(QQuickTest::qWaitForPolish(listview)); + prevSpyCount = spy.size(); QVERIFY(QMetaObject::invokeMethod(window->rootObject(), "incrementRepeater")); positioner = findItem<QQuickItem>(window->rootObject(), "positioner"); @@ -4712,7 +4722,7 @@ void tst_QQuickListView::repositionResizedDelegate() QCOMPARE(listview->contentX(), contentPos_itemSecondHalfVisible.x()); QCOMPARE(listview->contentY(), contentPos_itemSecondHalfVisible.y()); qApp->processEvents(); - QCOMPARE(spy.count(), prevSpyCount); + QCOMPARE(spy.size(), prevSpyCount); releaseView(window); } @@ -4789,6 +4799,8 @@ void tst_QQuickListView::indexAt_itemAt() QFETCH(qreal, y); QFETCH(int, index); + QScopedPointer<TestObject> testObject(new TestObject); + QQuickView *window = getView(); QaimModel model; @@ -4798,7 +4810,6 @@ void tst_QQuickListView::indexAt_itemAt() QQmlContext *ctxt = window->rootContext(); ctxt->setContextProperty("testModel", &model); - QScopedPointer<TestObject> testObject(new TestObject); ctxt->setContextProperty("testObject", testObject.data()); window->setSource(testFileUrl("listviewtest.qml")); @@ -4810,7 +4821,7 @@ void tst_QQuickListView::indexAt_itemAt() QQuickItem *contentItem = listview->contentItem(); QTRY_VERIFY(contentItem != nullptr); - QVERIFY(QQuickTest::qWaitForItemPolished(listview)); + QVERIFY(QQuickTest::qWaitForPolish(listview)); QQuickItem *item = nullptr; if (index >= 0) { @@ -4901,8 +4912,8 @@ void tst_QQuickListView::onAdd() QTRY_COMPARE(listview->property("count").toInt(), model.count()); QVariantList result = listview->property("addedDelegates").toList(); - QCOMPARE(result.count(), items.count()); - for (int i=0; i<items.count(); i++) + QCOMPARE(result.size(), items.size()); + for (int i=0; i<items.size(); i++) QCOMPARE(result[i].toString(), items[i].first); } @@ -4990,7 +5001,7 @@ void tst_QQuickListView::rightToLeft() QQuickItem *contentItem = listview->contentItem(); QTRY_VERIFY(contentItem != nullptr); - QVERIFY(QQuickTest::qWaitForItemPolished(listview)); + QVERIFY(QQuickTest::qWaitForPolish(listview)); QQmlObjectModel *model = window->rootObject()->findChild<QQmlObjectModel*>("itemModel"); QTRY_VERIFY(model != nullptr); @@ -5048,14 +5059,14 @@ void tst_QQuickListView::test_mirroring() QCOMPARE(listviewA->layoutDirection(), listviewA->effectiveLayoutDirection()); // LTR != RTL - foreach (const QString objectName, objectNames) + for (const QString &objectName : std::as_const(objectNames)) QVERIFY(findItem<QQuickItem>(listviewA, objectName)->x() != findItem<QQuickItem>(listviewB, objectName)->x()); listviewA->setProperty("layoutDirection", Qt::LeftToRight); listviewB->setProperty("layoutDirection", Qt::LeftToRight); // LTR == LTR - foreach (const QString objectName, objectNames) + for (const QString &objectName : std::as_const(objectNames)) QCOMPARE(findItem<QQuickItem>(listviewA, objectName)->x(), findItem<QQuickItem>(listviewB, objectName)->x()); QCOMPARE(listviewB->layoutDirection(), listviewB->effectiveLayoutDirection()); @@ -5063,25 +5074,25 @@ void tst_QQuickListView::test_mirroring() QVERIFY(listviewB->layoutDirection() != listviewB->effectiveLayoutDirection()); // LTR != LTR+mirror - foreach (const QString objectName, objectNames) + for (const QString &objectName : std::as_const(objectNames)) QVERIFY(findItem<QQuickItem>(listviewA, objectName)->x() != findItem<QQuickItem>(listviewB, objectName)->x()); listviewA->setProperty("layoutDirection", Qt::RightToLeft); // RTL == LTR+mirror - foreach (const QString objectName, objectNames) + for (const QString &objectName : std::as_const(objectNames)) QCOMPARE(findItem<QQuickItem>(listviewA, objectName)->x(), findItem<QQuickItem>(listviewB, objectName)->x()); listviewB->setProperty("layoutDirection", Qt::RightToLeft); // RTL != RTL+mirror - foreach (const QString objectName, objectNames) + for (const QString &objectName : std::as_const(objectNames)) QVERIFY(findItem<QQuickItem>(listviewA, objectName)->x() != findItem<QQuickItem>(listviewB, objectName)->x()); listviewA->setProperty("layoutDirection", Qt::LeftToRight); // LTR == RTL+mirror - foreach (const QString objectName, objectNames) + for (const QString &objectName : std::as_const(objectNames)) QCOMPARE(findItem<QQuickItem>(listviewA, objectName)->x(), findItem<QQuickItem>(listviewB, objectName)->x()); } @@ -5103,7 +5114,7 @@ void tst_QQuickListView::margins() QTRY_VERIFY(listview != nullptr); QQuickItem *contentItem = listview->contentItem(); QTRY_VERIFY(contentItem != nullptr); - QVERIFY(QQuickTest::qWaitForItemPolished(listview)); + QVERIFY(QQuickTest::qWaitForPolish(listview)); QCOMPARE(listview->contentY(), -30.); QCOMPARE(listview->originY(), 0.); @@ -5112,7 +5123,7 @@ void tst_QQuickListView::margins() listview->positionViewAtEnd(); qreal pos = listview->contentY(); listview->setContentY(pos + 80); - QVERIFY(QQuickTest::qWaitForItemPolished(listview)); + QVERIFY(QQuickTest::qWaitForPolish(listview)); listview->returnToBounds(); QTRY_COMPARE(listview->contentY(), pos + 50); @@ -5123,7 +5134,7 @@ void tst_QQuickListView::margins() listview->forceLayout(); QTRY_COMPARE(listview->count(), model.count()); listview->setContentY(-50); - QVERIFY(QQuickTest::qWaitForItemPolished(listview)); + QVERIFY(QQuickTest::qWaitForPolish(listview)); listview->returnToBounds(); QCOMPARE(listview->originY(), 20.); QTRY_COMPARE(listview->contentY(), -10.); @@ -5158,15 +5169,17 @@ void tst_QQuickListView::marginsResize() QPoint flickStart(20, 20); QPoint flickEnd(20, 20); + // We use 179 instead of 180 as we want to avoid the "Mouse event occurs outside target window" warning. + const int flickDistance = 179; if (orientation == QQuickListView::Vertical) - flickStart.ry() += (verticalLayoutDirection == QQuickItemView::TopToBottom) ? 180 : -180; + flickStart.ry() += (verticalLayoutDirection == QQuickItemView::TopToBottom) ? flickDistance : -flickDistance; else - flickStart.rx() += (layoutDirection == Qt::LeftToRight) ? 180 : -180; + flickStart.rx() += (layoutDirection == Qt::LeftToRight) ? flickDistance : -flickDistance; QQuickView *window = getView(); window->setSource(testFileUrl("margins2.qml")); - QQuickViewTestUtil::moveMouseAway(window); + QQuickViewTestUtils::moveMouseAway(window); window->show(); QVERIFY(QTest::qWaitForWindowExposed(window)); @@ -5176,7 +5189,7 @@ void tst_QQuickListView::marginsResize() listview->setOrientation(orientation); listview->setLayoutDirection(layoutDirection); listview->setVerticalLayoutDirection(verticalLayoutDirection); - QVERIFY(QQuickTest::qWaitForItemPolished(listview)); + QVERIFY(QQuickTest::qWaitForPolish(listview)); // view is resized after componentCompleted - top margin should still be visible if (orientation == QQuickListView::Vertical) @@ -5192,7 +5205,7 @@ void tst_QQuickListView::marginsResize() QTRY_COMPARE(listview->contentX(), end); // flick past the end and check content pos still settles on correct extents - flick(window, flickStart, flickEnd, 180); + flick(window, flickStart, flickEnd, flickDistance); QTRY_VERIFY(!listview->isMoving()); if (orientation == QQuickListView::Vertical) QTRY_COMPARE(listview->contentY(), end); @@ -5207,7 +5220,7 @@ void tst_QQuickListView::marginsResize() QTRY_COMPARE(listview->contentX(), start); // flick past the beginning and check content pos still settles on correct extents - flick(window, flickEnd, flickStart, 180); + flick(window, flickEnd, flickStart, flickDistance); QTRY_VERIFY(!listview->isMoving()); if (orientation == QQuickListView::Vertical) QTRY_COMPARE(listview->contentY(), start); @@ -5302,7 +5315,7 @@ void tst_QQuickListView::snapToItem() QFETCH(qreal, startExtent); QQuickView *window = getView(); - QQuickViewTestUtil::moveMouseAway(window); + QQuickViewTestUtils::moveMouseAway(window); window->setSource(testFileUrl("snapToItem.qml")); window->show(); @@ -5316,7 +5329,7 @@ void tst_QQuickListView::snapToItem() listview->setLayoutDirection(layoutDirection); listview->setVerticalLayoutDirection(verticalLayoutDirection); listview->setHighlightRangeMode(QQuickItemView::HighlightRangeMode(highlightRangeMode)); - QVERIFY(QQuickTest::qWaitForItemPolished(listview)); + QVERIFY(QQuickTest::qWaitForPolish(listview)); QQuickItem *contentItem = listview->contentItem(); QTRY_VERIFY(contentItem != nullptr); @@ -5368,7 +5381,7 @@ void tst_QQuickListView::snapToItemWithSpacing_QTBUG_59852() auto *listView = qobject_cast<QQuickListView*>(window->rootObject()); QVERIFY(listView); - QVERIFY(QQuickTest::qWaitForItemPolished(listView)); + QVERIFY(QQuickTest::qWaitForPolish(listView)); // each item in the list is 100 pixels tall, and the spacing is 100 @@ -5467,7 +5480,7 @@ void tst_QQuickListView::headerSnapToItem() listview->setVerticalLayoutDirection(static_cast<QQuickItemView::VerticalLayoutDirection>(layoutDirection)); listview->setHeaderPositioning(headerPositioning); - QVERIFY(QQuickTest::qWaitForItemPolished(listview)); + QVERIFY(QQuickTest::qWaitForPolish(listview)); QQuickItem *contentItem = listview->contentItem(); QVERIFY(contentItem != nullptr); @@ -5986,7 +5999,7 @@ void tst_QQuickListView::snapOneItemResize_QTBUG_43555() QScopedPointer<QQuickView> window(createView()); window->resize(QSize(100, 320)); window->setResizeMode(QQuickView::SizeRootObjectToView); - QQuickViewTestUtil::moveMouseAway(window.data()); + QQuickVisualTestUtils::moveMouseAway(window.data()); window->setSource(testFileUrl("snapOneItemResize.qml")); window->show(); @@ -5997,17 +6010,17 @@ void tst_QQuickListView::snapOneItemResize_QTBUG_43555() QSignalSpy currentIndexSpy(listview, SIGNAL(currentIndexChanged())); - QVERIFY(QQuickTest::qWaitForItemPolished(listview)); + QVERIFY(QQuickTest::qWaitForPolish(listview)); QTRY_COMPARE(listview->currentIndex(), 5); currentIndexSpy.clear(); window->resize(QSize(400, 320)); QTRY_COMPARE(int(listview->width()), 400); - QVERIFY(QQuickTest::qWaitForItemPolished(listview)); + QVERIFY(QQuickTest::qWaitForPolish(listview)); QTRY_COMPARE(listview->currentIndex(), 5); - QCOMPARE(currentIndexSpy.count(), 0); + QCOMPARE(currentIndexSpy.size(), 0); } void tst_QQuickListView::qAbstractItemModel_package_items() @@ -6300,7 +6313,7 @@ void tst_QQuickListView::snapOneItem() qreal flickDuration = 180 * flickSlowdown; QQuickView *window = getView(); - QQuickViewTestUtil::moveMouseAway(window); + QQuickViewTestUtils::moveMouseAway(window); window->setSource(testFileUrl("snapOneItem.qml")); window->show(); @@ -6314,7 +6327,7 @@ void tst_QQuickListView::snapOneItem() listview->setLayoutDirection(layoutDirection); listview->setVerticalLayoutDirection(verticalLayoutDirection); listview->setHighlightRangeMode(QQuickItemView::HighlightRangeMode(highlightRangeMode)); - QVERIFY(QQuickTest::qWaitForItemPolished(listview)); + QVERIFY(QQuickTest::qWaitForPolish(listview)); QQuickItem *contentItem = listview->contentItem(); QTRY_VERIFY(contentItem != nullptr); @@ -6331,7 +6344,7 @@ void tst_QQuickListView::snapOneItem() if (QQuickItemView::HighlightRangeMode(highlightRangeMode) == QQuickItemView::StrictlyEnforceRange) { QCOMPARE(listview->currentIndex(), 1); - QCOMPARE(currentIndexSpy.count(), 1); + QCOMPARE(currentIndexSpy.size(), 1); } // flick to end @@ -6349,7 +6362,7 @@ void tst_QQuickListView::snapOneItem() if (QQuickItemView::HighlightRangeMode(highlightRangeMode) == QQuickItemView::StrictlyEnforceRange) { QCOMPARE(listview->currentIndex(), 3); - QCOMPARE(currentIndexSpy.count(), 3); + QCOMPARE(currentIndexSpy.size(), 3); } // flick to start @@ -6367,7 +6380,7 @@ void tst_QQuickListView::snapOneItem() if (QQuickItemView::HighlightRangeMode(highlightRangeMode) == QQuickItemView::StrictlyEnforceRange) { QCOMPARE(listview->currentIndex(), 0); - QCOMPARE(currentIndexSpy.count(), 6); + QCOMPARE(currentIndexSpy.size(), 6); } releaseView(window); @@ -6383,17 +6396,17 @@ void tst_QQuickListView::snapOneItemCurrentIndexRemoveAnimation() QQuickListView *listview = qobject_cast<QQuickListView*>(window->rootObject()); QTRY_VERIFY(listview != nullptr); - QVERIFY(QQuickTest::qWaitForItemPolished(listview)); + QVERIFY(QQuickTest::qWaitForPolish(listview)); QTRY_COMPARE(listview->currentIndex(), 0); QSignalSpy currentIndexSpy(listview, SIGNAL(currentIndexChanged())); QMetaObject::invokeMethod(window->rootObject(), "removeItemZero"); QTRY_COMPARE(listview->property("transitionsRun").toInt(), 1); - QVERIFY(QQuickTest::qWaitForItemPolished(listview)); + QVERIFY(QQuickTest::qWaitForPolish(listview)); QCOMPARE(listview->currentIndex(), 0); - QCOMPARE(currentIndexSpy.count(), 0); + QCOMPARE(currentIndexSpy.size(), 0); } void tst_QQuickListView::snapOneItemWrongDirection() @@ -6406,7 +6419,7 @@ void tst_QQuickListView::snapOneItemWrongDirection() QQuickListView *listview = qobject_cast<QQuickListView*>(window->rootObject()); QTRY_VERIFY(listview != nullptr); - QVERIFY(QQuickTest::qWaitForItemPolished(listview)); + QVERIFY(QQuickTest::qWaitForPolish(listview)); QTRY_COMPARE(listview->currentIndex(), 0); listview->flick(0,500); @@ -6483,30 +6496,30 @@ void tst_QQuickListView::unrequestedVisibility() const QString wrapperObjectName = QStringLiteral("wrapper"); QQuickItem *item = findItem<QQuickItem>(leftContent, wrapperObjectName, 1); QVERIFY(item); - QCOMPARE(delegateVisible(item), true); + QCOMPARE(isDelegateVisible(item), true); item = findItem<QQuickItem>(rightContent, wrapperObjectName, 1); QVERIFY(item); - QCOMPARE(delegateVisible(item), false); + QCOMPARE(isDelegateVisible(item), false); item = findItem<QQuickItem>(leftContent, wrapperObjectName, 19); QVERIFY(item); - QCOMPARE(delegateVisible(item), false); + QCOMPARE(isDelegateVisible(item), false); item = findItem<QQuickItem>(rightContent, wrapperObjectName, 19); QVERIFY(item); - QCOMPARE(delegateVisible(item), true); + QCOMPARE(isDelegateVisible(item), true); item = findItem<QQuickItem>(leftContent, wrapperObjectName, 16); QVERIFY(item); - QCOMPARE(delegateVisible(item), true); + QCOMPARE(isDelegateVisible(item), true); item = findItem<QQuickItem>(leftContent, wrapperObjectName, 17); QVERIFY(item); - QCOMPARE(delegateVisible(item), false); + QCOMPARE(isDelegateVisible(item), false); item = findItem<QQuickItem>(rightContent, wrapperObjectName, 3); QVERIFY(item); - QCOMPARE(delegateVisible(item), false); + QCOMPARE(isDelegateVisible(item), false); item = findItem<QQuickItem>(rightContent, wrapperObjectName, 4); QVERIFY(item); - QCOMPARE(delegateVisible(item), true); + QCOMPARE(isDelegateVisible(item), true); rightview->setCurrentIndex(0); @@ -6515,10 +6528,10 @@ void tst_QQuickListView::unrequestedVisibility() item = findItem<QQuickItem>(leftContent, wrapperObjectName, 1); QVERIFY(item); - QCOMPARE(delegateVisible(item), true); + QCOMPARE(isDelegateVisible(item), true); item = findItem<QQuickItem>(rightContent, wrapperObjectName, 1); QVERIFY(item); - QTRY_COMPARE(delegateVisible(item), true); + QTRY_COMPARE(isDelegateVisible(item), true); QVERIFY(!findItem<QQuickItem>(leftContent, wrapperObjectName, 19)); QVERIFY(!findItem<QQuickItem>(rightContent, wrapperObjectName, 19)); @@ -6530,123 +6543,123 @@ void tst_QQuickListView::unrequestedVisibility() item = findItem<QQuickItem>(leftContent, wrapperObjectName, 1); QVERIFY(item); - QTRY_COMPARE(delegateVisible(item), false); + QTRY_COMPARE(isDelegateVisible(item), false); item = findItem<QQuickItem>(rightContent, wrapperObjectName, 1); QVERIFY(item); - QCOMPARE(delegateVisible(item), true); + QCOMPARE(isDelegateVisible(item), true); item = findItem<QQuickItem>(leftContent, wrapperObjectName, 19); QVERIFY(item); - QCOMPARE(delegateVisible(item), true); + QCOMPARE(isDelegateVisible(item), true); item = findItem<QQuickItem>(rightContent, wrapperObjectName, 19); QVERIFY(item); - QCOMPARE(delegateVisible(item), false); + QCOMPARE(isDelegateVisible(item), false); item = findItem<QQuickItem>(leftContent, wrapperObjectName, 3); QVERIFY(item); - QCOMPARE(delegateVisible(item), false); + QCOMPARE(isDelegateVisible(item), false); item = findItem<QQuickItem>(leftContent, wrapperObjectName, 4); QVERIFY(item); - QCOMPARE(delegateVisible(item), true); + QCOMPARE(isDelegateVisible(item), true); item = findItem<QQuickItem>(rightContent, wrapperObjectName, 16); QVERIFY(item); - QCOMPARE(delegateVisible(item), true); + QCOMPARE(isDelegateVisible(item), true); item = findItem<QQuickItem>(rightContent, wrapperObjectName, 17); QVERIFY(item); - QCOMPARE(delegateVisible(item), false); + QCOMPARE(isDelegateVisible(item), false); model.moveItems(19, 1, 1); - QVERIFY(QQuickTest::qWaitForItemPolished(leftview)); + QVERIFY(QQuickTest::qWaitForPolish(leftview)); QTRY_VERIFY((item = findItem<QQuickItem>(leftContent, wrapperObjectName, 1))); - QCOMPARE(delegateVisible(item), false); + QCOMPARE(isDelegateVisible(item), false); item = findItem<QQuickItem>(rightContent, wrapperObjectName, 1); QVERIFY(item); - QCOMPARE(delegateVisible(item), true); + QCOMPARE(isDelegateVisible(item), true); item = findItem<QQuickItem>(leftContent, wrapperObjectName, 19); QVERIFY(item); - QCOMPARE(delegateVisible(item), true); + QCOMPARE(isDelegateVisible(item), true); item = findItem<QQuickItem>(rightContent, wrapperObjectName, 19); QVERIFY(item); - QCOMPARE(delegateVisible(item), false); + QCOMPARE(isDelegateVisible(item), false); item = findItem<QQuickItem>(leftContent, wrapperObjectName, 4); QVERIFY(item); - QCOMPARE(delegateVisible(item), false); + QCOMPARE(isDelegateVisible(item), false); item = findItem<QQuickItem>(leftContent, wrapperObjectName, 5); QVERIFY(item); - QCOMPARE(delegateVisible(item), true); + QCOMPARE(isDelegateVisible(item), true); item = findItem<QQuickItem>(rightContent, wrapperObjectName, 16); QVERIFY(item); - QCOMPARE(delegateVisible(item), true); + QCOMPARE(isDelegateVisible(item), true); item = findItem<QQuickItem>(rightContent, wrapperObjectName, 17); QVERIFY(item); - QCOMPARE(delegateVisible(item), false); + QCOMPARE(isDelegateVisible(item), false); model.moveItems(3, 4, 1); - QVERIFY(QQuickTest::qWaitForItemPolished(leftview)); + QVERIFY(QQuickTest::qWaitForPolish(leftview)); item = findItem<QQuickItem>(leftContent, wrapperObjectName, 4); QVERIFY(item); - QCOMPARE(delegateVisible(item), false); + QCOMPARE(isDelegateVisible(item), false); item = findItem<QQuickItem>(leftContent, wrapperObjectName, 5); QVERIFY(item); - QCOMPARE(delegateVisible(item), true); + QCOMPARE(isDelegateVisible(item), true); item = findItem<QQuickItem>(rightContent, wrapperObjectName, 16); QVERIFY(item); - QCOMPARE(delegateVisible(item), true); + QCOMPARE(isDelegateVisible(item), true); item = findItem<QQuickItem>(rightContent, wrapperObjectName, 17); QVERIFY(item); - QCOMPARE(delegateVisible(item), false); + QCOMPARE(isDelegateVisible(item), false); model.moveItems(4, 3, 1); - QVERIFY(QQuickTest::qWaitForItemPolished(leftview)); + QVERIFY(QQuickTest::qWaitForPolish(leftview)); item = findItem<QQuickItem>(leftContent, wrapperObjectName, 4); QVERIFY(item); - QCOMPARE(delegateVisible(item), false); + QCOMPARE(isDelegateVisible(item), false); item = findItem<QQuickItem>(leftContent, wrapperObjectName, 5); QVERIFY(item); - QCOMPARE(delegateVisible(item), true); + QCOMPARE(isDelegateVisible(item), true); item = findItem<QQuickItem>(rightContent, wrapperObjectName, 16); QVERIFY(item); - QCOMPARE(delegateVisible(item), true); + QCOMPARE(isDelegateVisible(item), true); item = findItem<QQuickItem>(rightContent, wrapperObjectName, 17); QVERIFY(item); - QCOMPARE(delegateVisible(item), false); + QCOMPARE(isDelegateVisible(item), false); model.moveItems(16, 17, 1); - QVERIFY(QQuickTest::qWaitForItemPolished(leftview)); + QVERIFY(QQuickTest::qWaitForPolish(leftview)); item = findItem<QQuickItem>(leftContent, wrapperObjectName, 4); QVERIFY(item); - QCOMPARE(delegateVisible(item), false); + QCOMPARE(isDelegateVisible(item), false); item = findItem<QQuickItem>(leftContent, wrapperObjectName, 5); QVERIFY(item); - QCOMPARE(delegateVisible(item), true); + QCOMPARE(isDelegateVisible(item), true); item = findItem<QQuickItem>(rightContent, wrapperObjectName, 16); QVERIFY(item); - QCOMPARE(delegateVisible(item), true); + QCOMPARE(isDelegateVisible(item), true); item = findItem<QQuickItem>(rightContent, wrapperObjectName, 17); QVERIFY(item); - QCOMPARE(delegateVisible(item), false); + QCOMPARE(isDelegateVisible(item), false); model.moveItems(17, 16, 1); - QVERIFY(QQuickTest::qWaitForItemPolished(leftview)); + QVERIFY(QQuickTest::qWaitForPolish(leftview)); item = findItem<QQuickItem>(leftContent, wrapperObjectName, 4); QVERIFY(item); - QCOMPARE(delegateVisible(item), false); + QCOMPARE(isDelegateVisible(item), false); item = findItem<QQuickItem>(leftContent, wrapperObjectName, 5); QVERIFY(item); - QCOMPARE(delegateVisible(item), true); + QCOMPARE(isDelegateVisible(item), true); item = findItem<QQuickItem>(rightContent, wrapperObjectName, 16); QVERIFY(item); - QCOMPARE(delegateVisible(item), true); + QCOMPARE(isDelegateVisible(item), true); item = findItem<QQuickItem>(rightContent, wrapperObjectName, 17); QVERIFY(item); - QCOMPARE(delegateVisible(item), false); + QCOMPARE(isDelegateVisible(item), false); } void tst_QQuickListView::populateTransitions() @@ -6666,8 +6679,8 @@ void tst_QQuickListView::populateTransitions() model.addItem("item" + QString::number(i), ""); } + QScopedPointer<TestObject> testObject(new TestObject()); QQuickView *window = getView(); - QScopedPointer<TestObject> testObject(new TestObject(window->rootContext())); window->rootContext()->setContextProperty("testModel", &model); window->rootContext()->setContextProperty("testObject", testObject.data()); window->rootContext()->setContextProperty("usePopulateTransition", usePopulateTransition); @@ -6692,12 +6705,12 @@ void tst_QQuickListView::populateTransitions() QTRY_COMPARE(listview->property("countPopulateTransitions").toInt(), 0); QTRY_COMPARE(listview->property("countAddTransitions").toInt(), 16); } else { - QVERIFY(QQuickTest::qWaitForItemPolished(listview)); + QVERIFY(QQuickTest::qWaitForPolish(listview)); QCOMPARE(listview->property("countPopulateTransitions").toInt(), 0); QCOMPARE(listview->property("countAddTransitions").toInt(), 0); } - int itemCount = findItems<QQuickItem>(contentItem, "wrapper").count(); + int itemCount = findItems<QQuickItem>(contentItem, "wrapper").size(); for (int i=0; i < model.count() && i < itemCount; ++i) { QQuickItem *item = findItem<QQuickItem>(contentItem, "wrapper", i); QVERIFY2(item, qPrintable(QString("Item %1 not found").arg(i))); @@ -6720,7 +6733,7 @@ void tst_QQuickListView::populateTransitions() window->rootContext()->setContextProperty("testModel", QVariant()); listview->forceLayout(); QTRY_COMPARE(listview->count(), 0); - QTRY_COMPARE(findItems<QQuickItem>(contentItem, "wrapper").count(), 0); + QTRY_COMPARE(findItems<QQuickItem>(contentItem, "wrapper").size(), 0); listview->setProperty("countPopulateTransitions", 0); listview->setProperty("countAddTransitions", 0); @@ -6732,7 +6745,7 @@ void tst_QQuickListView::populateTransitions() QTRY_COMPARE(listview->property("countPopulateTransitions").toInt(), usePopulateTransition ? 16 : 0); QTRY_COMPARE(listview->property("countAddTransitions").toInt(), 0); - itemCount = findItems<QQuickItem>(contentItem, "wrapper").count(); + itemCount = findItems<QQuickItem>(contentItem, "wrapper").size(); for (int i=0; i < model.count() && i < itemCount; ++i) { QQuickItem *item = findItem<QQuickItem>(contentItem, "wrapper", i); QVERIFY2(item, qPrintable(QString("Item %1 not found").arg(i))); @@ -6750,7 +6763,7 @@ void tst_QQuickListView::populateTransitions() QTRY_COMPARE(listview->property("countPopulateTransitions").toInt(), usePopulateTransition ? 16 : 0); QTRY_COMPARE(listview->property("countAddTransitions").toInt(), 0); - itemCount = findItems<QQuickItem>(contentItem, "wrapper").count(); + itemCount = findItems<QQuickItem>(contentItem, "wrapper").size(); for (int i=0; i < model.count() && i < itemCount; ++i) { QQuickItem *item = findItem<QQuickItem>(contentItem, "wrapper", i); QVERIFY2(item, qPrintable(QString("Item %1 not found").arg(i))); @@ -6780,6 +6793,20 @@ void tst_QQuickListView::populateTransitions_data() QTest::newRow("empty to start with, no populate") << false << false << false; } +// QTBUG-111050 +/* Reposition first visible item in list view on populate transition + Note: Occurs only in BottomToTop or RightToLeft layout */ +void tst_QQuickListView::repositionFirstItemOnPopulateTransition() +{ + QScopedPointer<QQuickView> window(createView()); + window->setSource(testFileUrl("repositionListViewOnPopulateTransition.qml")); + window->show(); + QVERIFY(QTest::qWaitForWindowExposed(window.data())); + + QQuickListView *listview = qobject_cast<QQuickListView*>(window->rootObject()); + QTRY_VERIFY(listview != nullptr); + QTRY_COMPARE(listview->contentY(), -100.0); +} /* * Tests if the first visible item is not repositioned if the same item @@ -6790,12 +6817,12 @@ void tst_QQuickListView::populateTransitions_data() void tst_QQuickListView::sizeTransitions() { QFETCH(bool, topToBottom); + QScopedPointer<TestObject> testObject(new TestObject); QQuickView *window = getView(); QQmlContext *ctxt = window->rootContext(); QaimModel model; ctxt->setContextProperty("testModel", &model); ctxt->setContextProperty("topToBottom", topToBottom); - QScopedPointer<TestObject> testObject(new TestObject); ctxt->setContextProperty("testObject", &model); window->setSource(testFileUrl("sizeTransitions.qml")); window->show(); @@ -6803,7 +6830,7 @@ void tst_QQuickListView::sizeTransitions() QQuickListView *listview = findItem<QQuickListView>(window->rootObject(), "list"); QTRY_VERIFY(listview != nullptr); - QVERIFY(QQuickTest::qWaitForItemPolished(listview)); + QVERIFY(QQuickTest::qWaitForPolish(listview)); // the following will start the transition model.addItem(QLatin1String("Test"), ""); @@ -6850,9 +6877,9 @@ void tst_QQuickListView::addTransitions() QaimModel model_targetItems_transitionFrom; QaimModel model_displacedItems_transitionVia; + QScopedPointer<TestObject> testObject(new TestObject); QQuickView *window = getView(); QQmlContext *ctxt = window->rootContext(); - QScopedPointer<TestObject> testObject(new TestObject); ctxt->setContextProperty("testModel", &model); ctxt->setContextProperty("model_targetItems_transitionFrom", &model_targetItems_transitionFrom); ctxt->setContextProperty("model_displacedItems_transitionVia", &model_displacedItems_transitionVia); @@ -6867,11 +6894,11 @@ void tst_QQuickListView::addTransitions() QTRY_VERIFY(listview != nullptr); QQuickItem *contentItem = listview->contentItem(); QVERIFY(contentItem != nullptr); - QVERIFY(QQuickTest::qWaitForItemPolished(listview)); + QVERIFY(QQuickTest::qWaitForPolish(listview)); if (contentY != 0) { listview->setContentY(contentY); - QVERIFY(QQuickTest::qWaitForItemPolished(listview)); + QVERIFY(QQuickTest::qWaitForPolish(listview)); } QList<QPair<QString,QString> > expectedDisplacedValues = expectedDisplacedIndexes.getModelDataValues(model); @@ -6889,7 +6916,7 @@ void tst_QQuickListView::addTransitions() targetIndexes << i; } } - QVERIFY(expectedTargetData.count() > 0); + QVERIFY(expectedTargetData.size() > 0); } // start animation @@ -6902,7 +6929,7 @@ void tst_QQuickListView::addTransitions() QList<QQuickItem *> targetItems = findItems<QQuickItem>(contentItem, "wrapper", targetIndexes); if (shouldAnimateTargets) { - QTRY_COMPARE(listview->property("targetTransitionsDone").toInt(), expectedTargetData.count()); + QTRY_COMPARE(listview->property("targetTransitionsDone").toInt(), expectedTargetData.size()); QTRY_COMPARE(listview->property("displaceTransitionsDone").toInt(), expectedDisplacedIndexes.isValid() ? expectedDisplacedIndexes.count() : 0); @@ -6929,8 +6956,8 @@ void tst_QQuickListView::addTransitions() QList<QQuickItem*> items = findItems<QQuickItem>(contentItem, "wrapper"); int firstVisibleIndex = -1; - int itemCount = items.count(); - for (int i=0; i<items.count(); i++) { + int itemCount = items.size(); + for (int i=0; i<items.size(); i++) { if (items[i]->y() >= contentY) { QQmlExpression e(qmlContext(items[i]), items[i], "index"); firstVisibleIndex = e.evaluate().toInt(); @@ -7045,9 +7072,9 @@ void tst_QQuickListView::moveTransitions() QaimModel model_targetItems_transitionVia; QaimModel model_displacedItems_transitionVia; + QScopedPointer<TestObject> testObject(new TestObject); QQuickView *window = getView(); QQmlContext *ctxt = window->rootContext(); - QScopedPointer<TestObject> testObject(new TestObject); ctxt->setContextProperty("testModel", &model); ctxt->setContextProperty("model_targetItems_transitionVia", &model_targetItems_transitionVia); ctxt->setContextProperty("model_displacedItems_transitionVia", &model_displacedItems_transitionVia); @@ -7066,7 +7093,7 @@ void tst_QQuickListView::moveTransitions() if (contentY != 0) { listview->setContentY(contentY); - QVERIFY(QQuickTest::qWaitForItemPolished(listview)); + QVERIFY(QQuickTest::qWaitForPolish(listview)); } QList<QPair<QString,QString> > expectedDisplacedValues = expectedDisplacedIndexes.getModelDataValues(model); @@ -7089,7 +7116,7 @@ void tst_QQuickListView::moveTransitions() // start animation model.moveItems(moveFrom, moveTo, moveCount); - QTRY_COMPARE(listview->property("targetTransitionsDone").toInt(), expectedTargetData.count()); + QTRY_COMPARE(listview->property("targetTransitionsDone").toInt(), expectedTargetData.size()); QTRY_COMPARE(listview->property("displaceTransitionsDone").toInt(), expectedDisplacedIndexes.isValid() ? expectedDisplacedIndexes.count() : 0); @@ -7113,7 +7140,7 @@ void tst_QQuickListView::moveTransitions() QList<QQuickItem*> items = findItems<QQuickItem>(contentItem, "wrapper"); int firstVisibleIndex = -1; - for (int i=0; i<items.count(); i++) { + for (int i=0; i<items.size(); i++) { if (items[i]->y() >= contentY) { QQmlExpression e(qmlContext(items[i]), items[i], "index"); firstVisibleIndex = e.evaluate().toInt(); @@ -7123,7 +7150,7 @@ void tst_QQuickListView::moveTransitions() QVERIFY2(firstVisibleIndex >= 0, QByteArray::number(firstVisibleIndex)); // verify all items moved to the correct final positions - int itemCount = findItems<QQuickItem>(contentItem, "wrapper").count(); + int itemCount = findItems<QQuickItem>(contentItem, "wrapper").size(); for (int i=firstVisibleIndex; i < model.count() && i < itemCount; ++i) { QQuickItem *item = findItem<QQuickItem>(contentItem, "wrapper", i); QVERIFY2(item, qPrintable(QString("Item %1 not found").arg(i))); @@ -7247,9 +7274,9 @@ void tst_QQuickListView::removeTransitions() QaimModel model_targetItems_transitionTo; QaimModel model_displacedItems_transitionVia; + QScopedPointer<TestObject> testObject(new TestObject); QQuickView *window = getView(); QQmlContext *ctxt = window->rootContext(); - QScopedPointer<TestObject> testObject(new TestObject); ctxt->setContextProperty("testModel", &model); ctxt->setContextProperty("model_targetItems_transitionTo", &model_targetItems_transitionTo); ctxt->setContextProperty("model_displacedItems_transitionVia", &model_displacedItems_transitionVia); @@ -7264,11 +7291,11 @@ void tst_QQuickListView::removeTransitions() QTRY_VERIFY(listview != nullptr); QQuickItem *contentItem = listview->contentItem(); QVERIFY(contentItem != nullptr); - QVERIFY(QQuickTest::qWaitForItemPolished(listview)); + QVERIFY(QQuickTest::qWaitForPolish(listview)); if (contentY != 0) { listview->setContentY(contentY); - QVERIFY(QQuickTest::qWaitForItemPolished(listview)); + QVERIFY(QQuickTest::qWaitForPolish(listview)); } QList<QPair<QString,QString> > expectedDisplacedValues = expectedDisplacedIndexes.getModelDataValues(model); @@ -7283,13 +7310,13 @@ void tst_QQuickListView::removeTransitions() targetIndexes << i; } } - QVERIFY(expectedTargetData.count() > 0); + QVERIFY(expectedTargetData.size() > 0); } // calculate targetItems and expectedTargets before model changes QList<QQuickItem *> targetItems = findItems<QQuickItem>(contentItem, "wrapper", targetIndexes); QVariantMap expectedTargets; - for (int i=0; i<targetIndexes.count(); i++) + for (int i=0; i<targetIndexes.size(); i++) expectedTargets[model.name(targetIndexes[i])] = targetIndexes[i]; // start animation @@ -7297,7 +7324,7 @@ void tst_QQuickListView::removeTransitions() QTRY_COMPARE(model.count(), listview->count()); if (shouldAnimateTargets) { - QTRY_COMPARE(listview->property("targetTransitionsDone").toInt(), expectedTargetData.count()); + QTRY_COMPARE(listview->property("targetTransitionsDone").toInt(), expectedTargetData.size()); QTRY_COMPARE(listview->property("displaceTransitionsDone").toInt(), expectedDisplacedIndexes.isValid() ? expectedDisplacedIndexes.count() : 0); @@ -7323,9 +7350,9 @@ void tst_QQuickListView::removeTransitions() QList<QQuickItem*> items = findItems<QQuickItem>(contentItem, "wrapper"); int firstVisibleIndex = -1; - int itemCount = items.count(); + int itemCount = items.size(); - for (int i=0; i<items.count(); i++) { + for (int i=0; i<items.size(); i++) { QQmlExpression e(qmlContext(items[i]), items[i], "index"); int index = e.evaluate().toInt(); if (firstVisibleIndex < 0 && items[i]->y() >= contentY) @@ -7445,9 +7472,9 @@ void tst_QQuickListView::displacedTransitions() QPointF moveDisplaced_transitionVia(50, -100); QPointF removeDisplaced_transitionVia(150, 100); + QScopedPointer<TestObject> testObject(new TestObject()); QQuickView *window = getView(); QQmlContext *ctxt = window->rootContext(); - QScopedPointer<TestObject> testObject(new TestObject(window)); ctxt->setContextProperty("testModel", &model); ctxt->setContextProperty("testObject", testObject.data()); ctxt->setContextProperty("model_displaced_transitionVia", &model_displaced_transitionVia); @@ -7474,7 +7501,7 @@ void tst_QQuickListView::displacedTransitions() QTRY_VERIFY(listview != nullptr); QQuickItem *contentItem = listview->contentItem(); QVERIFY(contentItem != nullptr); - QVERIFY(QQuickTest::qWaitForItemPolished(listview)); + QVERIFY(QQuickTest::qWaitForPolish(listview)); QList<QPair<QString,QString> > expectedDisplacedValues = expectedDisplacedIndexes.getModelDataValues(model); listview->setProperty("displaceTransitionsDone", false); @@ -7495,7 +7522,7 @@ void tst_QQuickListView::displacedTransitions() break; case ListChange::Moved: model.moveItems(change.index, change.to, change.count); - QVERIFY(QQuickTest::qWaitForItemPolished(listview)); + QVERIFY(QQuickTest::qWaitForPolish(listview)); break; case ListChange::SetCurrent: case ListChange::SetContentY: @@ -7514,15 +7541,15 @@ void tst_QQuickListView::displacedTransitions() QTRY_VERIFY(listview->property("displaceTransitionsDone").toBool()); // check the correct number of target items and indexes were received - QCOMPARE(resultTargetIndexes.count(), expectedDisplacedIndexes.count()); - for (int i=0; i<resultTargetIndexes.count(); i++) - QCOMPARE(resultTargetIndexes[i].value<QList<int> >().count(), change.count); - QCOMPARE(resultTargetItems.count(), expectedDisplacedIndexes.count()); - for (int i=0; i<resultTargetItems.count(); i++) - QCOMPARE(resultTargetItems[i].toList().count(), change.count); + QCOMPARE(resultTargetIndexes.size(), expectedDisplacedIndexes.count()); + for (int i=0; i<resultTargetIndexes.size(); i++) + QCOMPARE(resultTargetIndexes[i].value<QList<int> >().size(), change.count); + QCOMPARE(resultTargetItems.size(), expectedDisplacedIndexes.count()); + for (int i=0; i<resultTargetItems.size(); i++) + QCOMPARE(resultTargetItems[i].toList().size(), change.count); } else { - QCOMPARE(resultTargetIndexes.count(), 0); - QCOMPARE(resultTargetItems.count(), 0); + QCOMPARE(resultTargetIndexes.size(), 0); + QCOMPARE(resultTargetItems.size(), 0); } if (change.type == ListChange::Inserted && useAddDisplaced && addDisplacedEnabled) @@ -7549,7 +7576,7 @@ void tst_QQuickListView::displacedTransitions() // verify all items moved to the correct final positions QList<QQuickItem*> items = findItems<QQuickItem>(contentItem, "wrapper"); - for (int i=0; i < model.count() && i < items.count(); ++i) { + for (int i=0; i < model.count() && i < items.size(); ++i) { QQuickItem *item = findItem<QQuickItem>(contentItem, "wrapper", i); QVERIFY2(item, qPrintable(QString("Item %1 not found").arg(i))); QCOMPARE(item->x(), 0.0); @@ -7671,9 +7698,9 @@ void tst_QQuickListView::multipleTransitions() for (int i = 0; i < initialCount; i++) model.addItem("Original item" + QString::number(i), ""); + QScopedPointer<TestObject> testObject(new TestObject); QQuickView *window = getView(); QQmlContext *ctxt = window->rootContext(); - QScopedPointer<TestObject> testObject(new TestObject); ctxt->setContextProperty("testModel", &model); ctxt->setContextProperty("testObject", testObject.data()); ctxt->setContextProperty("addTargets_transitionFrom", addTargets_transitionFrom); @@ -7694,16 +7721,16 @@ void tst_QQuickListView::multipleTransitions() QTRY_VERIFY(listview != nullptr); QQuickItem *contentItem = listview->contentItem(); QVERIFY(contentItem != nullptr); - QVERIFY(QQuickTest::qWaitForItemPolished(listview)); + QVERIFY(QQuickTest::qWaitForPolish(listview)); if (contentY != 0) { listview->setContentY(contentY); - QVERIFY(QQuickTest::qWaitForItemPolished(listview)); + QVERIFY(QQuickTest::qWaitForPolish(listview)); } int timeBetweenActions = window->rootObject()->property("timeBetweenActions").toInt(); - for (int i=0; i<changes.count(); i++) { + for (int i=0; i<changes.size(); i++) { switch (changes[i].type) { case ListChange::Inserted: { @@ -7712,7 +7739,7 @@ void tst_QQuickListView::multipleTransitions() targetItems << qMakePair(QString("new item %1").arg(j), QString::number(j)); model.insertItems(changes[i].index, targetItems); QTRY_COMPARE(model.count(), listview->count()); - if (i == changes.count() - 1) { + if (i == changes.size() - 1) { QTRY_VERIFY(!listview->property("runningAddTargets").toBool()); QTRY_VERIFY(!listview->property("runningAddDisplaced").toBool()); } else { @@ -7723,7 +7750,7 @@ void tst_QQuickListView::multipleTransitions() case ListChange::Removed: model.removeItems(changes[i].index, changes[i].count); QTRY_COMPARE(model.count(), listview->count()); - if (i == changes.count() - 1) { + if (i == changes.size() - 1) { QTRY_VERIFY(!listview->property("runningRemoveTargets").toBool()); QTRY_VERIFY(!listview->property("runningRemoveDisplaced").toBool()); } else { @@ -7732,8 +7759,8 @@ void tst_QQuickListView::multipleTransitions() break; case ListChange::Moved: model.moveItems(changes[i].index, changes[i].to, changes[i].count); - QVERIFY(QQuickTest::qWaitForItemPolished(listview)); - if (i == changes.count() - 1) { + QVERIFY(QQuickTest::qWaitForPolish(listview)); + if (i == changes.size() - 1) { QTRY_VERIFY(!listview->property("runningMoveTargets").toBool()); QTRY_VERIFY(!listview->property("runningMoveDisplaced").toBool()); } else { @@ -7745,7 +7772,7 @@ void tst_QQuickListView::multipleTransitions() break; case ListChange::SetContentY: listview->setContentY(changes[i].pos); - QVERIFY(QQuickTest::qWaitForItemPolished(listview)); + QVERIFY(QQuickTest::qWaitForPolish(listview)); break; case ListChange::Polish: break; @@ -7757,7 +7784,7 @@ void tst_QQuickListView::multipleTransitions() // verify all items moved to the correct final positions QList<QQuickItem*> items = findItems<QQuickItem>(contentItem, "wrapper"); - for (int i=0; i < model.count() && i < items.count(); ++i) { + for (int i=0; i < model.count() && i < items.size(); ++i) { QQuickItem *item = findItem<QQuickItem>(contentItem, "wrapper", i); QVERIFY2(item, qPrintable(QString("Item %1 not found").arg(i))); QTRY_COMPARE(item->x(), 0.0); @@ -7838,9 +7865,9 @@ void tst_QQuickListView::multipleDisplaced() for (int i = 0; i < 30; i++) model.addItem("Original item" + QString::number(i), ""); + QScopedPointer<TestObject> testObject(new TestObject()); QQuickView *window = getView(); QQmlContext *ctxt = window->rootContext(); - QScopedPointer<TestObject> testObject(new TestObject(window)); ctxt->setContextProperty("testModel", &model); ctxt->setContextProperty("testObject", testObject.data()); window->setSource(testFileUrl("multipleDisplaced.qml")); @@ -7851,7 +7878,7 @@ void tst_QQuickListView::multipleDisplaced() QTRY_VERIFY(listview != nullptr); QQuickItem *contentItem = listview->contentItem(); QVERIFY(contentItem != nullptr); - QVERIFY(QQuickTest::qWaitForItemPolished(listview)); + QVERIFY(QQuickTest::qWaitForPolish(listview)); model.moveItems(12, 8, 1); QTest::qWait(window->rootObject()->property("duration").toInt() / 2); @@ -7859,14 +7886,15 @@ void tst_QQuickListView::multipleDisplaced() QTRY_VERIFY(listview->property("displaceTransitionsDone").toBool()); QVariantMap transitionsStarted = listview->property("displaceTransitionsStarted").toMap(); - foreach (const QString &name, transitionsStarted.keys()) { + const QStringList keys = transitionsStarted.keys(); + for (const QString &name : keys) { QVERIFY2(transitionsStarted[name] == 1, qPrintable(QString("%1 was displaced %2 times").arg(name).arg(transitionsStarted[name].toInt()))); } // verify all items moved to the correct final positions QList<QQuickItem*> items = findItems<QQuickItem>(contentItem, "wrapper"); - for (int i=0; i < model.count() && i < items.count(); ++i) { + for (int i=0; i < model.count() && i < items.size(); ++i) { QQuickItem *item = findItem<QQuickItem>(contentItem, "wrapper", i); QVERIFY2(item, qPrintable(QString("Item %1 not found").arg(i))); QTRY_COMPARE(item->x(), 0.0); @@ -7883,7 +7911,7 @@ QList<int> tst_QQuickListView::toIntList(const QVariantList &list) { QList<int> ret; bool ok = true; - for (int i=0; i<list.count(); i++) { + for (int i=0; i<list.size(); i++) { ret << list[i].toInt(&ok); if (!ok) qWarning() << "tst_QQuickListView::toIntList(): not a number:" << list[i]; @@ -7895,7 +7923,7 @@ QList<int> tst_QQuickListView::toIntList(const QVariantList &list) void tst_QQuickListView::matchIndexLists(const QVariantList &indexLists, const QList<int> &expectedIndexes) { const QSet<int> expectedIndexSet(expectedIndexes.cbegin(), expectedIndexes.cend()); - for (int i=0; i<indexLists.count(); i++) { + for (int i=0; i<indexLists.size(); i++) { const auto ¤tList = indexLists[i].value<QList<int> >(); const QSet<int> current(currentList.cbegin(), currentList.cend()); if (current != expectedIndexSet) @@ -7915,27 +7943,27 @@ void tst_QQuickListView::matchItemsAndIndexes(const QVariantMap &items, const Qa qDebug() << itemIndex; QCOMPARE(model.name(itemIndex), name); } - QCOMPARE(items.count(), expectedIndexes.count()); + QCOMPARE(items.size(), expectedIndexes.size()); } void tst_QQuickListView::matchItemLists(const QVariantList &itemLists, const QList<QQuickItem *> &expectedItems) { - for (int i=0; i<itemLists.count(); i++) { + for (int i=0; i<itemLists.size(); i++) { QCOMPARE(itemLists[i].typeId(), QMetaType::QVariantList); QVariantList current = itemLists[i].toList(); - for (int j=0; j<current.count(); j++) { + for (int j=0; j<current.size(); j++) { QQuickItem *o = qobject_cast<QQuickItem*>(current[j].value<QObject*>()); QVERIFY2(o, qPrintable(QString("Invalid actual item at %1").arg(j))); QVERIFY2(expectedItems.contains(o), qPrintable(QString("Cannot match item %1").arg(j))); } - QCOMPARE(current.count(), expectedItems.count()); + QCOMPARE(current.size(), expectedItems.size()); } } void tst_QQuickListView::flickBeyondBounds() { QScopedPointer<QQuickView> window(createView()); - QQuickViewTestUtil::moveMouseAway(window.data()); + QQuickVisualTestUtils::moveMouseAway(window.data()); window->setSource(testFileUrl("flickBeyondBoundsBug.qml")); window->show(); @@ -7947,7 +7975,7 @@ void tst_QQuickListView::flickBeyondBounds() QQuickItem *contentItem = listview->contentItem(); QTRY_VERIFY(contentItem != nullptr); - QVERIFY(QQuickTest::qWaitForItemPolished(listview)); + QVERIFY(QQuickTest::qWaitForPolish(listview)); // Flick view up beyond bounds flick(window.data(), QPoint(10, 10), QPoint(10, -2000), 180); @@ -7958,7 +7986,7 @@ void tst_QQuickListView::flickBeyondBounds() // We're really testing that we don't get stuck in a loop, // but also confirm items positioned correctly. - QTRY_COMPARE(findItems<QQuickItem>(contentItem, "wrapper").count(), 2); + QTRY_COMPARE(findItems<QQuickItem>(contentItem, "wrapper").size(), 2); for (int i = 0; i < 2; ++i) { QQuickItem *item = findItem<QQuickItem>(contentItem, "wrapper", i); if (!item) qWarning() << "Item" << i << "not found"; @@ -7977,7 +8005,7 @@ void tst_QQuickListView::flickBothDirections() QFETCH(QPointF, targetPos); QQuickView *window = getView(); - QQuickViewTestUtil::moveMouseAway(window); + QQuickViewTestUtils::moveMouseAway(window); QQmlContext *ctxt = window->rootContext(); ctxt->setContextProperty("initialOrientation", initValues ? orientation : QQuickListView::Vertical); @@ -8001,7 +8029,7 @@ void tst_QQuickListView::flickBothDirections() listview->setContentHeight(contentHeight); } - flick(window, QPoint(100, 100), QPoint(25, 25), 50); + flick(window, QPoint(140, 140), QPoint(25, 25), 50); QVERIFY(listview->isMoving()); QTRY_VERIFY(!listview->isMoving()); QCOMPARE(listview->contentX(), targetPos.x()); @@ -8059,13 +8087,13 @@ void tst_QQuickListView::destroyItemOnCreation() QQuickItem *contentItem = listview->contentItem(); QVERIFY(contentItem != nullptr); - QVERIFY(QQuickTest::qWaitForItemPolished(listview)); + QVERIFY(QQuickTest::qWaitForPolish(listview)); QCOMPARE(window->rootObject()->property("createdIndex").toInt(), -1); model.addItem("new item", ""); QTRY_COMPARE(window->rootObject()->property("createdIndex").toInt(), 0); - QTRY_COMPARE(findItems<QQuickItem>(contentItem, "wrapper").count(), 0); + QTRY_COMPARE(findItems<QQuickItem>(contentItem, "wrapper").size(), 0); QCOMPARE(model.count(), 0); } @@ -8090,7 +8118,7 @@ void tst_QQuickListView::parentBinding() QQuickItem *contentItem = listview->contentItem(); QVERIFY(contentItem != nullptr); - QVERIFY(QQuickTest::qWaitForItemPolished(listview)); + QVERIFY(QQuickTest::qWaitForPolish(listview)); QQuickItem *item = findItem<QQuickItem>(contentItem, "wrapper", 0); QVERIFY(item); @@ -8150,7 +8178,7 @@ void tst_QQuickListView::delayedChanges_QTBUG_30555() void tst_QQuickListView::outsideViewportChangeNotAffectingView() { QScopedPointer<QQuickView> window(createView()); - QQuickViewTestUtil::moveMouseAway(window.data()); + QQuickVisualTestUtils::moveMouseAway(window.data()); window->setSource(testFileUrl("outsideViewportChangeNotAffectingView.qml")); QQuickListView *listview = window->rootObject()->findChild<QQuickListView*>(); @@ -8184,7 +8212,7 @@ void tst_QQuickListView::outsideViewportChangeNotAffectingView() void tst_QQuickListView::testProxyModelChangedAfterMove() { QScopedPointer<QQuickView> window(createView()); - QQuickViewTestUtil::moveMouseAway(window.data()); + QQuickVisualTestUtils::moveMouseAway(window.data()); window->setSource(testFileUrl("proxytest.qml")); QQuickListView *listview = window->rootObject()->findChild<QQuickListView*>(); @@ -8229,24 +8257,24 @@ void tst_QQuickListView::displayMargin() QQuickItem *item0 = findItem<QQuickItem>(content, "delegate", 0); QVERIFY(item0); - QCOMPARE(delegateVisible(item0), true); + QCOMPARE(isDelegateVisible(item0), true); // the 14th item should be within the end margin QQuickItem *item14 = findItem<QQuickItem>(content, "delegate", 13); QVERIFY(item14); - QCOMPARE(delegateVisible(item14), true); + QCOMPARE(isDelegateVisible(item14), true); // the 15th item should be outside the end margin QVERIFY(findItem<QQuickItem>(content, "delegate", 14) == nullptr); // the first delegate should still be within the begin margin listview->positionViewAtIndex(3, QQuickListView::Beginning); - QCOMPARE(delegateVisible(item0), true); + QCOMPARE(isDelegateVisible(item0), true); // the first delegate should now be outside the begin margin listview->positionViewAtIndex(4, QQuickListView::Beginning); - QCOMPARE(delegateVisible(item0), false); + QCOMPARE(isDelegateVisible(item0), false); } void tst_QQuickListView::negativeDisplayMargin() @@ -8268,29 +8296,29 @@ void tst_QQuickListView::negativeDisplayMargin() QQuickItem *item = findItem<QQuickItem>(content, "delegate", 0); QVERIFY(item); - QCOMPARE(delegateVisible(item), true); + QCOMPARE(isDelegateVisible(item), true); item = findItem<QQuickItem>(content, "delegate", 7); QVERIFY(item); - QCOMPARE(delegateVisible(item), true); + QCOMPARE(isDelegateVisible(item), true); item = findItem<QQuickItem>(content, "delegate", 8); QVERIFY(item); - QCOMPARE(delegateVisible(item), false); + QCOMPARE(isDelegateVisible(item), false); // Flick until contentY means that delegate8 should be visible listview->setProperty("contentY", 500); item = findItem<QQuickItem>(content, "delegate", 8); QVERIFY(item); - QTRY_COMPARE(delegateVisible(item), true); + QTRY_COMPARE(isDelegateVisible(item), true); listview->setProperty("contentY", 1000); QTRY_VERIFY((item = findItem<QQuickItem>(content, "delegate", 14))); - QTRY_COMPARE(delegateVisible(item), true); + QTRY_COMPARE(isDelegateVisible(item), true); listview->setProperty("contentY", 0); QTRY_VERIFY(item = findItem<QQuickItem>(content, "delegate", 4)); - QTRY_COMPARE(delegateVisible(item), true); + QTRY_COMPARE(isDelegateVisible(item), true); } void tst_QQuickListView::highlightItemGeometryChanges() @@ -8392,7 +8420,7 @@ void tst_QQuickListView::stickyPositioning() listview->positionViewAtIndex(positionIndex, positionMode); - foreach (const QPointF &offset, movement) { + for (const QPointF &offset : std::as_const(movement)) { listview->setContentX(listview->contentX() + offset.x()); listview->setContentY(listview->contentY() + offset.y()); } @@ -8833,7 +8861,7 @@ void tst_QQuickListView::QTBUG_38209() listview->flick(0, 1000); // ensure we move more than just a couple pixels - QTRY_VERIFY(contentY - listview->contentY() > qreal(100.0)); + QTRY_COMPARE_GE(contentY - listview->contentY(), 100); } void tst_QQuickListView::programmaticFlickAtBounds() @@ -9056,11 +9084,11 @@ void tst_QQuickListView::jsArrayChange() } view->setModel(QVariant::fromValue(array1)); - QCOMPARE(spy.count(), 1); + QCOMPARE(spy.size(), 1); // no change view->setModel(QVariant::fromValue(array2)); - QCOMPARE(spy.count(), 1); + QCOMPARE(spy.size(), 1); } static bool compareObjectModel(QQuickListView *listview, QQmlObjectModel *model) @@ -9245,7 +9273,7 @@ void tst_QQuickListView::keyNavigationEnabled() // of disabling both mouse and keyboard interaction. QSignalSpy enabledSpy(listView, SIGNAL(keyNavigationEnabledChanged())); listView->setInteractive(false); - QCOMPARE(enabledSpy.count(), 1); + QCOMPARE(enabledSpy.size(), 1); QCOMPARE(listView->isKeyNavigationEnabled(), false); flick(window.data(), QPoint(200, 200), QPoint(200, 50), 100); @@ -9258,17 +9286,17 @@ void tst_QQuickListView::keyNavigationEnabled() // Check that isKeyNavigationEnabled implicitly follows the value of interactive. listView->setInteractive(true); - QCOMPARE(enabledSpy.count(), 2); + QCOMPARE(enabledSpy.size(), 2); QCOMPARE(listView->isKeyNavigationEnabled(), true); // Change it back again for the next check. listView->setInteractive(false); - QCOMPARE(enabledSpy.count(), 3); + QCOMPARE(enabledSpy.size(), 3); QCOMPARE(listView->isKeyNavigationEnabled(), false); // Setting keyNavigationEnabled to true shouldn't enable mouse interaction. listView->setKeyNavigationEnabled(true); - QCOMPARE(enabledSpy.count(), 4); + QCOMPARE(enabledSpy.size(), 4); flick(window.data(), QPoint(200, 200), QPoint(200, 50), 100); QVERIFY(!listView->isMoving()); QCOMPARE(listView->contentY(), 0.0); @@ -9282,7 +9310,7 @@ void tst_QQuickListView::keyNavigationEnabled() // Changing interactive now shouldn't result in keyNavigationEnabled changing, // since we broke the "binding". listView->setInteractive(true); - QCOMPARE(enabledSpy.count(), 4); + QCOMPARE(enabledSpy.size(), 4); // Keyboard interaction shouldn't work now. listView->setKeyNavigationEnabled(false); @@ -9459,7 +9487,7 @@ void tst_QQuickListView::QTBUG_66163_setModelViewPortSizeChange() delegate: Rectangle { color: index % 2 ? "green" : "orange" - width: parent.width + width: view.width height: 50 } @@ -9478,7 +9506,7 @@ void tst_QQuickListView::QTBUG_66163_setModelViewPortSizeChange() QVERIFY(QTest::qWaitForWindowExposed(window.data())); auto view = root->findChild<QQuickListView *>("view"); QVERIFY(view); - QVERIFY(QQuickTest::qWaitForItemPolished(view)); + QVERIFY(QQuickTest::qWaitForPolish(view)); QSignalSpy spy(view, &QQuickListView::contentYChanged); auto transition = view->property("populate").value<QQuickTransition*>(); QVERIFY(transition); @@ -9490,7 +9518,7 @@ void tst_QQuickListView::QTBUG_66163_setModelViewPortSizeChange() QTest::qWait(1100); // animation takes 1000ms, + 10% extra delay /* the viewport should not have changed, thus there should not have been any contentYChanged signal*/ - QCOMPARE(spy.count(), 0); + QCOMPARE(spy.size(), 0); } void tst_QQuickListView::itemFiltered() @@ -9511,8 +9539,8 @@ void tst_QQuickListView::itemFiltered() QScopedPointer<QQuickView> window(createView()); window->engine()->rootContext()->setContextProperty("_model", &proxy2); QQmlComponent component(window->engine()); - component.setData("import QtQuick 2.4; ListView { " - "anchors.fill: parent; model: _model; delegate: Text { width: parent.width;" + component.setData("import QtQuick 2.4; ListView { id: listView; " + "anchors.fill: parent; model: _model; delegate: Text { width: listView.width;" "text: model.display; } }", QUrl()); window->setContent(QUrl(), &component, component.create()); @@ -9550,7 +9578,7 @@ void tst_QQuickListView::QTBUG_34576_velocityZero() QVERIFY(listview); QQuickItem *contentItem = listview->contentItem(); QVERIFY(contentItem); - QVERIFY(QQuickTest::qWaitForItemPolished(listview)); + QVERIFY(QQuickTest::qWaitForPolish(listview)); QSignalSpy horizontalVelocitySpy(listview, SIGNAL(horizontalVelocityChanged())); @@ -9561,7 +9589,7 @@ void tst_QQuickListView::QTBUG_34576_velocityZero() window->rootObject()->setProperty("horizontalVelocityZeroCount", QVariant(0)); listview->setCurrentIndex(2); QTRY_COMPARE(window->rootObject()->property("current").toInt(), 2); - QCOMPARE(horizontalVelocitySpy.count(), 0); + QCOMPARE(horizontalVelocitySpy.size(), 0); QCOMPARE(window->rootObject()->property("horizontalVelocityZeroCount").toInt(), 0); QSignalSpy currentIndexChangedSpy(listview, SIGNAL(currentIndexChanged())); @@ -9571,11 +9599,11 @@ void tst_QQuickListView::QTBUG_34576_velocityZero() QTest::mouseRelease(window.data(), Qt::LeftButton, Qt::NoModifier, QPoint(295,215)); // verify that currentIndexChanged is triggered - QTRY_VERIFY(currentIndexChangedSpy.count() > 0); + QTRY_VERIFY(currentIndexChangedSpy.size() > 0); // since we have set currentIndex to an item out of view, the listview will scroll QTRY_COMPARE(window->rootObject()->property("current").toInt(), 3); - QTRY_VERIFY(horizontalVelocitySpy.count() > 0); + QTRY_VERIFY(horizontalVelocitySpy.size() > 0); // velocity should be always > 0.0 QTRY_COMPARE(window->rootObject()->property("horizontalVelocityZeroCount").toInt(), 0); @@ -9604,7 +9632,7 @@ void tst_QQuickListView::QTBUG_61537_modelChangesAsync() // Check that the number of delegates we expect to be visible in // the listview matches the number of items we find if we count. int reportedCount = listView->count(); - int actualCount = findItems<QQuickItem>(listView, "delegate").count(); + int actualCount = findItems<QQuickItem>(listView, "delegate").size(); QCOMPARE(reportedCount, actualCount); } @@ -9679,7 +9707,7 @@ void tst_QQuickListView::touchCancel() // QTBUG-74679 QPoint p1(300, 300); QTest::touchEvent(window.data(), touchDevice).press(0, p1, window.data()); QQuickTouchUtils::flush(window.data()); - QTRY_VERIFY(mouseArea->pressed()); + QTRY_VERIFY(mouseArea->isPressed()); // and because Flickable filtered it, QQuickFlickablePrivate::pressed // should be true, but it's not easily tested here @@ -9735,7 +9763,7 @@ public: m_animals.push_back(Animal {5, QLatin1String("Cherry")}); } - int rowCount(const QModelIndex & = QModelIndex()) const override {return m_animals.count();} + int rowCount(const QModelIndex & = QModelIndex()) const override {return m_animals.size();} QVariant data(const QModelIndex & index, int role = Qt::DisplayRole) const override { if (!checkIndex(index)) @@ -9795,12 +9823,24 @@ void tst_QQuickListView::delegateWithRequiredProperties() void tst_QQuickListView::reuse_reuseIsOffByDefault() { + QScopedPointer<TestObject> testObject(new TestObject); + // Check that delegate recycling is off by default. The reason is that // ListView needs to be backwards compatible with legacy applications. And // when using delegate recycling, there are certain differences, like that // a delegates Component.onCompleted will just be called the first time the // item is created, and not when it's reused. QScopedPointer<QQuickView> window(createView()); + + QaimModel model; + for (int i = 0; i < 40; i++) + model.addItem("Item" + QString::number(i), ""); + + QQmlContext *ctxt = window->rootContext(); + ctxt->setContextProperty("testModel", &model); + + ctxt->setContextProperty("testObject", testObject.data()); + window->setSource(testFileUrl("listviewtest.qml")); window->resize(640, 480); window->show(); @@ -9839,14 +9879,14 @@ void tst_QQuickListView::reuse_checkThatItemsAreReused() QVERIFY(listView->reuseItems()); auto items = findItems<QQuickItem>(listView, "delegate"); - const int initialItemCount = items.count(); + const int initialItemCount = items.size(); QVERIFY(initialItemCount > 0); // Sanity check that the size of the initial list of items match the count we tracked from QML QCOMPARE(listView->property("delegatesCreatedCount").toInt(), initialItemCount); // Go through all the initial items and check that they have not been reused yet - for (const auto item : qAsConst(items)) + for (const auto item : std::as_const(items)) QCOMPARE(item->property("reusedCount").toInt(), 0); // Flick one page down and count how many items we have created thus @@ -9855,7 +9895,7 @@ void tst_QQuickListView::reuse_checkThatItemsAreReused() const qreal delegateHeight = items.at(0)->height(); const qreal flickDistance = (initialItemCount * delegateHeight) + 1; listView->setContentY(flickDistance); - QVERIFY(QQuickTest::qWaitForItemPolished(listView)); + QVERIFY(QQuickTest::qWaitForPolish(listView)); const int countAfterDownFlick = listView->property("delegatesCreatedCount").toInt(); QCOMPARE(countAfterDownFlick, initialItemCount * 2); @@ -9870,7 +9910,7 @@ void tst_QQuickListView::reuse_checkThatItemsAreReused() // QML model classes, we need to catch it through a binding instead (which is // OK, since then we can also check that bindings are updated when reused). items = findItems<QQuickItem>(listView, "delegate"); - for (const auto item : qAsConst(items)) { + for (const auto item : std::as_const(items)) { const QString display = item->property("displayBinding").toString(); const int modelIndex = item->property("modelIndex").toInt(); QVERIFY(modelIndex >= initialItemCount); @@ -9882,7 +9922,7 @@ void tst_QQuickListView::reuse_checkThatItemsAreReused() // in the pool during the flick, we also fill it up again with all the items that // were inside the page that was flicked out. listView->setContentY(0); - QVERIFY(QQuickTest::qWaitForItemPolished(listView)); + QVERIFY(QQuickTest::qWaitForPolish(listView)); const int countAfterUpFlick = listView->property("delegatesCreatedCount").toInt(); const int poolSizeAfterUpFlick = itemView_d->model->poolSize(); QCOMPARE(countAfterUpFlick, countAfterDownFlick); @@ -9892,7 +9932,7 @@ void tst_QQuickListView::reuse_checkThatItemsAreReused() // (except for ListView.currentItem, which was never released). const auto listViewCurrentItem = listView->currentItem(); items = findItems<QQuickItem>(listView, "delegate"); - for (const auto item : qAsConst(items)) { + for (const auto item : std::as_const(items)) { const int reusedCount = item->property("reusedCount").toInt(); if (item == listViewCurrentItem) QCOMPARE(reusedCount, 0); @@ -9903,7 +9943,7 @@ void tst_QQuickListView::reuse_checkThatItemsAreReused() // Go through all items again and check that all model data inside the delegate // have correct values now that they have been reused. items = findItems<QQuickItem>(listView, "delegate"); - for (const auto item : qAsConst(items)) { + for (const auto item : std::as_const(items)) { const QString display = item->property("displayBinding").toString(); const int modelIndex = item->property("modelIndex").toInt(); QVERIFY(modelIndex < initialItemCount); @@ -9914,7 +9954,7 @@ void tst_QQuickListView::reuse_checkThatItemsAreReused() void tst_QQuickListView::dragOverFloatingHeaderOrFooter() // QTBUG-74046 { QQuickView *window = getView(); - QQuickViewTestUtil::moveMouseAway(window); + QQuickViewTestUtils::moveMouseAway(window); window->setSource(testFileUrl("qtbug63974.qml")); window->show(); QVERIFY(QTest::qWaitForWindowExposed(window)); @@ -9973,13 +10013,13 @@ void tst_QQuickListView::moveObjectModelItemToAnotherObjectModel() QVERIFY(QMetaObject::invokeMethod(root, "moveRedRectToModel2")); QVERIFY(QQuickTest::qIsPolishScheduled(listView2)); - QVERIFY(QQuickTest::qWaitForItemPolished(listView2)); + QVERIFY(QQuickTest::qWaitForPolish(listView2)); QVERIFY(redRect->isVisible()); QVERIFY(!QQuickItemPrivate::get(redRect)->culled); QVERIFY(QMetaObject::invokeMethod(root, "moveRedRectToModel1")); QVERIFY(QQuickTest::qIsPolishScheduled(listView1)); - QVERIFY(QQuickTest::qWaitForItemPolished(listView1)); + QVERIFY(QQuickTest::qWaitForPolish(listView1)); QVERIFY(redRect->isVisible()); QVERIFY(!QQuickItemPrivate::get(redRect)->culled); } @@ -9995,7 +10035,7 @@ void tst_QQuickListView::changeModelAndDestroyTheOldOne() // QTBUG-80203 QQuickItem *root = window->rootObject(); QVERIFY(root); - QVERIFY(QQuickTest::qWaitForItemPolished(root)); + QVERIFY(QQuickTest::qWaitForPolish(root)); // no crash } @@ -10064,9 +10104,9 @@ void tst_QQuickListView::requiredObjectListModel() const auto *root = qobject_cast<QQuickListView *>(view.rootObject()); QVERIFY(root); - QCOMPARE(root->count(), dataList.count()); + QCOMPARE(root->count(), dataList.size()); - for (int i = 0, end = dataList.count(); i != end; ++i) { + for (int i = 0, end = dataList.size(); i != end; ++i) { const auto *rect = qobject_cast<QQuickRectangle *>(root->itemAtIndex(i)); QVERIFY(rect); const auto *data = qobject_cast<DataObject *>(dataList.at(i)); @@ -10117,6 +10157,8 @@ void tst_QQuickListView::animatedDelegate() } } +// WARNING: please add new tests to tst_qquicklistview2; this file is too slow to work with. + QTEST_MAIN(tst_QQuickListView) #include "tst_qquicklistview.moc" |