summaryrefslogtreecommitdiffstats
path: root/tests/auto/widgets/graphicsview
diff options
context:
space:
mode:
Diffstat (limited to 'tests/auto/widgets/graphicsview')
-rw-r--r--tests/auto/widgets/graphicsview/CMakeLists.txt8
-rw-r--r--tests/auto/widgets/graphicsview/qgraphicsanchorlayout/BLACKLIST2
-rw-r--r--tests/auto/widgets/graphicsview/qgraphicsanchorlayout/CMakeLists.txt11
-rw-r--r--tests/auto/widgets/graphicsview/qgraphicsanchorlayout/tst_qgraphicsanchorlayout.cpp29
-rw-r--r--tests/auto/widgets/graphicsview/qgraphicsanchorlayout1/CMakeLists.txt11
-rw-r--r--tests/auto/widgets/graphicsview/qgraphicsanchorlayout1/tst_qgraphicsanchorlayout1.cpp53
-rw-r--r--tests/auto/widgets/graphicsview/qgraphicseffectsource/CMakeLists.txt11
-rw-r--r--tests/auto/widgets/graphicsview/qgraphicseffectsource/tst_qgraphicseffectsource.cpp33
-rw-r--r--tests/auto/widgets/graphicsview/qgraphicsgridlayout/CMakeLists.txt11
-rw-r--r--tests/auto/widgets/graphicsview/qgraphicsgridlayout/tst_qgraphicsgridlayout.cpp44
-rw-r--r--tests/auto/widgets/graphicsview/qgraphicsitem/BLACKLIST4
-rw-r--r--tests/auto/widgets/graphicsview/qgraphicsitem/CMakeLists.txt13
-rw-r--r--tests/auto/widgets/graphicsview/qgraphicsitem/tst_qgraphicsitem.cpp105
-rw-r--r--tests/auto/widgets/graphicsview/qgraphicsitemanimation/CMakeLists.txt11
-rw-r--r--tests/auto/widgets/graphicsview/qgraphicsitemanimation/tst_qgraphicsitemanimation.cpp29
-rw-r--r--tests/auto/widgets/graphicsview/qgraphicslayout/CMakeLists.txt11
-rw-r--r--tests/auto/widgets/graphicsview/qgraphicslayout/tst_qgraphicslayout.cpp41
-rw-r--r--tests/auto/widgets/graphicsview/qgraphicslayoutitem/CMakeLists.txt11
-rw-r--r--tests/auto/widgets/graphicsview/qgraphicslayoutitem/tst_qgraphicslayoutitem.cpp29
-rw-r--r--tests/auto/widgets/graphicsview/qgraphicslinearlayout/CMakeLists.txt11
-rw-r--r--tests/auto/widgets/graphicsview/qgraphicslinearlayout/tst_qgraphicslinearlayout.cpp37
-rw-r--r--tests/auto/widgets/graphicsview/qgraphicsobject/CMakeLists.txt11
-rw-r--r--tests/auto/widgets/graphicsview/qgraphicsobject/tst_qgraphicsobject.cpp97
-rw-r--r--tests/auto/widgets/graphicsview/qgraphicspixmapitem/CMakeLists.txt11
-rw-r--r--tests/auto/widgets/graphicsview/qgraphicspixmapitem/tst_qgraphicspixmapitem.cpp29
-rw-r--r--tests/auto/widgets/graphicsview/qgraphicspolygonitem/CMakeLists.txt11
-rw-r--r--tests/auto/widgets/graphicsview/qgraphicspolygonitem/tst_qgraphicspolygonitem.cpp29
-rw-r--r--tests/auto/widgets/graphicsview/qgraphicsproxywidget/BLACKLIST8
-rw-r--r--tests/auto/widgets/graphicsview/qgraphicsproxywidget/CMakeLists.txt11
-rw-r--r--tests/auto/widgets/graphicsview/qgraphicsproxywidget/tst_qgraphicsproxywidget.cpp148
-rw-r--r--tests/auto/widgets/graphicsview/qgraphicsscene/BLACKLIST5
-rw-r--r--tests/auto/widgets/graphicsview/qgraphicsscene/CMakeLists.txt53
-rw-r--r--tests/auto/widgets/graphicsview/qgraphicsscene/tst_qgraphicsscene.cpp297
-rw-r--r--tests/auto/widgets/graphicsview/qgraphicssceneindex/CMakeLists.txt14
-rw-r--r--tests/auto/widgets/graphicsview/qgraphicssceneindex/tst_qgraphicssceneindex.cpp84
-rw-r--r--tests/auto/widgets/graphicsview/qgraphicstransform/CMakeLists.txt11
-rw-r--r--tests/auto/widgets/graphicsview/qgraphicstransform/tst_qgraphicstransform.cpp29
-rw-r--r--tests/auto/widgets/graphicsview/qgraphicsview/BLACKLIST26
-rw-r--r--tests/auto/widgets/graphicsview/qgraphicsview/CMakeLists.txt16
-rw-r--r--tests/auto/widgets/graphicsview/qgraphicsview/tst_qgraphicsview.cpp284
-rw-r--r--tests/auto/widgets/graphicsview/qgraphicsview/tst_qgraphicsview.h29
-rw-r--r--tests/auto/widgets/graphicsview/qgraphicsview/tst_qgraphicsview_2.cpp29
-rw-r--r--tests/auto/widgets/graphicsview/qgraphicswidget/BLACKLIST5
-rw-r--r--tests/auto/widgets/graphicsview/qgraphicswidget/CMakeLists.txt11
-rw-r--r--tests/auto/widgets/graphicsview/qgraphicswidget/tst_qgraphicswidget.cpp185
45 files changed, 909 insertions, 1039 deletions
diff --git a/tests/auto/widgets/graphicsview/CMakeLists.txt b/tests/auto/widgets/graphicsview/CMakeLists.txt
index df3c4d4369..b0ea73b65e 100644
--- a/tests/auto/widgets/graphicsview/CMakeLists.txt
+++ b/tests/auto/widgets/graphicsview/CMakeLists.txt
@@ -1,4 +1,5 @@
-# Generated from graphicsview.pro.
+# Copyright (C) 2022 The Qt Company Ltd.
+# SPDX-License-Identifier: BSD-3-Clause
if(QT_FEATURE_private_tests)
add_subdirectory(qgraphicsanchorlayout)
@@ -19,7 +20,4 @@ add_subdirectory(qgraphicspolygonitem)
add_subdirectory(qgraphicstransform)
add_subdirectory(qgraphicsproxywidget)
add_subdirectory(qgraphicswidget)
-# QTBUG-87671 # special case
-if(NOT ANDROID)
- add_subdirectory(qgraphicsview)
-endif()
+add_subdirectory(qgraphicsview)
diff --git a/tests/auto/widgets/graphicsview/qgraphicsanchorlayout/BLACKLIST b/tests/auto/widgets/graphicsview/qgraphicsanchorlayout/BLACKLIST
index ce0e42b3c7..fde971443d 100644
--- a/tests/auto/widgets/graphicsview/qgraphicsanchorlayout/BLACKLIST
+++ b/tests/auto/widgets/graphicsview/qgraphicsanchorlayout/BLACKLIST
@@ -1,2 +1,2 @@
[layoutDirection]
-ubuntu-20.04
+ubuntu-22.04
diff --git a/tests/auto/widgets/graphicsview/qgraphicsanchorlayout/CMakeLists.txt b/tests/auto/widgets/graphicsview/qgraphicsanchorlayout/CMakeLists.txt
index 1d1e576299..2b530d39f3 100644
--- a/tests/auto/widgets/graphicsview/qgraphicsanchorlayout/CMakeLists.txt
+++ b/tests/auto/widgets/graphicsview/qgraphicsanchorlayout/CMakeLists.txt
@@ -1,13 +1,20 @@
-# Generated from qgraphicsanchorlayout.pro.
+# Copyright (C) 2022 The Qt Company Ltd.
+# SPDX-License-Identifier: BSD-3-Clause
#####################################################################
## tst_qgraphicsanchorlayout Test:
#####################################################################
+if(NOT QT_BUILD_STANDALONE_TESTS AND NOT QT_BUILDING_QT)
+ cmake_minimum_required(VERSION 3.16)
+ project(tst_qgraphicsanchorlayout LANGUAGES CXX)
+ find_package(Qt6BuildInternals REQUIRED COMPONENTS STANDALONE_TEST)
+endif()
+
qt_internal_add_test(tst_qgraphicsanchorlayout
SOURCES
tst_qgraphicsanchorlayout.cpp
- PUBLIC_LIBRARIES
+ LIBRARIES
Qt::CorePrivate
Qt::Gui
Qt::GuiPrivate
diff --git a/tests/auto/widgets/graphicsview/qgraphicsanchorlayout/tst_qgraphicsanchorlayout.cpp b/tests/auto/widgets/graphicsview/qgraphicsanchorlayout/tst_qgraphicsanchorlayout.cpp
index 92cffa0226..cf37aa5639 100644
--- a/tests/auto/widgets/graphicsview/qgraphicsanchorlayout/tst_qgraphicsanchorlayout.cpp
+++ b/tests/auto/widgets/graphicsview/qgraphicsanchorlayout/tst_qgraphicsanchorlayout.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 <QTest>
#include <QtWidgets/qgraphicsanchorlayout.h>
diff --git a/tests/auto/widgets/graphicsview/qgraphicsanchorlayout1/CMakeLists.txt b/tests/auto/widgets/graphicsview/qgraphicsanchorlayout1/CMakeLists.txt
index 11d2767c9e..62235c8d1b 100644
--- a/tests/auto/widgets/graphicsview/qgraphicsanchorlayout1/CMakeLists.txt
+++ b/tests/auto/widgets/graphicsview/qgraphicsanchorlayout1/CMakeLists.txt
@@ -1,13 +1,20 @@
-# Generated from qgraphicsanchorlayout1.pro.
+# Copyright (C) 2022 The Qt Company Ltd.
+# SPDX-License-Identifier: BSD-3-Clause
#####################################################################
## tst_qgraphicsanchorlayout1 Test:
#####################################################################
+if(NOT QT_BUILD_STANDALONE_TESTS AND NOT QT_BUILDING_QT)
+ cmake_minimum_required(VERSION 3.16)
+ project(tst_qgraphicsanchorlayout1 LANGUAGES CXX)
+ find_package(Qt6BuildInternals REQUIRED COMPONENTS STANDALONE_TEST)
+endif()
+
qt_internal_add_test(tst_qgraphicsanchorlayout1
SOURCES
tst_qgraphicsanchorlayout1.cpp
- PUBLIC_LIBRARIES
+ LIBRARIES
Qt::CorePrivate
Qt::Gui
Qt::GuiPrivate
diff --git a/tests/auto/widgets/graphicsview/qgraphicsanchorlayout1/tst_qgraphicsanchorlayout1.cpp b/tests/auto/widgets/graphicsview/qgraphicsanchorlayout1/tst_qgraphicsanchorlayout1.cpp
index 9e0293d875..9a047b876d 100644
--- a/tests/auto/widgets/graphicsview/qgraphicsanchorlayout1/tst_qgraphicsanchorlayout1.cpp
+++ b/tests/auto/widgets/graphicsview/qgraphicsanchorlayout1/tst_qgraphicsanchorlayout1.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 <QtGui>
#include <QTest>
@@ -1688,7 +1663,7 @@ void tst_QGraphicsAnchorLayout1::testBasicLayout()
// Determine amount of widgets to add.
int widgetCount = -1;
- for (int i = 0; i < data.count(); ++i) {
+ for (int i = 0; i < data.size(); ++i) {
const BasicLayoutTestData item = data[i];
widgetCount = qMax(widgetCount, item.firstIndex);
widgetCount = qMax(widgetCount, item.secondIndex);
@@ -1703,7 +1678,7 @@ void tst_QGraphicsAnchorLayout1::testBasicLayout()
// Setup anchor layout
TheAnchorLayout *layout = new TheAnchorLayout;
- for (int i = 0; i < data.count(); ++i) {
+ for (int i = 0; i < data.size(); ++i) {
const BasicLayoutTestData item = data[i];
layout->setAnchor(
getItem(item.firstIndex, widgets, layout),
@@ -1720,7 +1695,7 @@ void tst_QGraphicsAnchorLayout1::testBasicLayout()
QCOMPARE(widget->size(), size);
// Validate
- for (int i = 0; i < result.count(); ++i) {
+ for (int i = 0; i < result.size(); ++i) {
const BasicLayoutTestResult item = result[i];
QRectF expected = item.rect;
QRectF actual = widgets[item.index]->geometry();
@@ -1732,7 +1707,7 @@ void tst_QGraphicsAnchorLayout1::testBasicLayout()
widget->setLayoutDirection(Qt::RightToLeft);
layout->activate();
// Validate
- for (int j = 0; j < result.count(); ++j) {
+ for (int j = 0; j < result.size(); ++j) {
const BasicLayoutTestResult item = result[j];
QRectF mirroredRect(item.rect);
// only valid cases are mirrored
@@ -2193,7 +2168,7 @@ void tst_QGraphicsAnchorLayout1::testRemoveCenterAnchor()
// Determine amount of widgets to add.
int widgetCount = -1;
- for (int i = 0; i < data.count(); ++i) {
+ for (int i = 0; i < data.size(); ++i) {
const BasicLayoutTestData item = data[i];
widgetCount = qMax(widgetCount, item.firstIndex);
widgetCount = qMax(widgetCount, item.secondIndex);
@@ -2210,7 +2185,7 @@ void tst_QGraphicsAnchorLayout1::testRemoveCenterAnchor()
// Setup anchor layout
TheAnchorLayout *layout = new TheAnchorLayout;
- for (int i = 0; i < data.count(); ++i) {
+ for (int i = 0; i < data.size(); ++i) {
const BasicLayoutTestData item = data[i];
layout->setAnchor(
getItem(item.firstIndex, widgets, layout),
@@ -2220,7 +2195,7 @@ void tst_QGraphicsAnchorLayout1::testRemoveCenterAnchor()
item.spacing );
}
- for (int i = 0; i < removeData.count(); ++i) {
+ for (int i = 0; i < removeData.size(); ++i) {
const BasicLayoutTestData item = removeData[i];
layout->removeAnchor(
getItem(item.firstIndex, widgets, layout),
@@ -2236,7 +2211,7 @@ void tst_QGraphicsAnchorLayout1::testRemoveCenterAnchor()
QCOMPARE(widget->size(), size);
// Validate
- for (int i = 0; i < result.count(); ++i) {
+ for (int i = 0; i < result.size(); ++i) {
const BasicLayoutTestResult item = result[i];
QCOMPARE(widgets[item.index]->geometry(), item.rect);
@@ -3024,7 +2999,7 @@ void tst_QGraphicsAnchorLayout1::testComplexCases()
// Determine amount of widgets to add.
int widgetCount = -1;
- for (int i = 0; i < data.count(); ++i) {
+ for (int i = 0; i < data.size(); ++i) {
const BasicLayoutTestData item = data[i];
widgetCount = qMax(widgetCount, item.firstIndex);
widgetCount = qMax(widgetCount, item.secondIndex);
@@ -3050,7 +3025,7 @@ void tst_QGraphicsAnchorLayout1::testComplexCases()
// Setup anchor layout
TheAnchorLayout *layout = new TheAnchorLayout;
- for (int i = 0; i < data.count(); ++i) {
+ for (int i = 0; i < data.size(); ++i) {
const BasicLayoutTestData item = data[i];
layout->setAnchor(
getItem(item.firstIndex, widgets, layout),
@@ -3067,7 +3042,7 @@ void tst_QGraphicsAnchorLayout1::testComplexCases()
QCOMPARE(widget->size(), size);
// Validate
- for (int i = 0; i < result.count(); ++i) {
+ for (int i = 0; i < result.size(); ++i) {
const BasicLayoutTestResult item = result[i];
QCOMPARE(widgets[item.index]->geometry(), item.rect);
}
@@ -3076,7 +3051,7 @@ void tst_QGraphicsAnchorLayout1::testComplexCases()
widget->setLayoutDirection(Qt::RightToLeft);
layout->activate();
// Validate
- for (int j = 0; j < result.count(); ++j) {
+ for (int j = 0; j < result.size(); ++j) {
const BasicLayoutTestResult item = result[j];
QRectF mirroredRect(item.rect);
// only valid cases are mirrored
diff --git a/tests/auto/widgets/graphicsview/qgraphicseffectsource/CMakeLists.txt b/tests/auto/widgets/graphicsview/qgraphicseffectsource/CMakeLists.txt
index 5a4fda8234..1e198d7baa 100644
--- a/tests/auto/widgets/graphicsview/qgraphicseffectsource/CMakeLists.txt
+++ b/tests/auto/widgets/graphicsview/qgraphicseffectsource/CMakeLists.txt
@@ -1,13 +1,20 @@
-# Generated from qgraphicseffectsource.pro.
+# Copyright (C) 2022 The Qt Company Ltd.
+# SPDX-License-Identifier: BSD-3-Clause
#####################################################################
## tst_qgraphicseffectsource Test:
#####################################################################
+if(NOT QT_BUILD_STANDALONE_TESTS AND NOT QT_BUILDING_QT)
+ cmake_minimum_required(VERSION 3.16)
+ project(tst_qgraphicseffectsource LANGUAGES CXX)
+ find_package(Qt6BuildInternals REQUIRED COMPONENTS STANDALONE_TEST)
+endif()
+
qt_internal_add_test(tst_qgraphicseffectsource
SOURCES
tst_qgraphicseffectsource.cpp
- PUBLIC_LIBRARIES
+ LIBRARIES
Qt::CorePrivate
Qt::Gui
Qt::GuiPrivate
diff --git a/tests/auto/widgets/graphicsview/qgraphicseffectsource/tst_qgraphicseffectsource.cpp b/tests/auto/widgets/graphicsview/qgraphicseffectsource/tst_qgraphicseffectsource.cpp
index ba8a309674..28c439dbcd 100644
--- a/tests/auto/widgets/graphicsview/qgraphicseffectsource/tst_qgraphicseffectsource.cpp
+++ b/tests/auto/widgets/graphicsview/qgraphicseffectsource/tst_qgraphicseffectsource.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 <QTest>
#include <QtWidgets/qgraphicseffect.h>
@@ -179,11 +154,11 @@ void tst_QGraphicsEffectSource::init()
QVERIFY(effect);
QVERIFY(item);
QVERIFY(effect->source());
- effect->reset();
effect->storeDeviceDependentStuff = false;
effect->doNothingInDraw = false;
- item->reset();
QCoreApplication::processEvents(); // Process all queued paint events
+ effect->reset();
+ item->reset();
}
void tst_QGraphicsEffectSource::graphicsItem()
diff --git a/tests/auto/widgets/graphicsview/qgraphicsgridlayout/CMakeLists.txt b/tests/auto/widgets/graphicsview/qgraphicsgridlayout/CMakeLists.txt
index 0554d62807..c4ffe216f5 100644
--- a/tests/auto/widgets/graphicsview/qgraphicsgridlayout/CMakeLists.txt
+++ b/tests/auto/widgets/graphicsview/qgraphicsgridlayout/CMakeLists.txt
@@ -1,13 +1,20 @@
-# Generated from qgraphicsgridlayout.pro.
+# Copyright (C) 2022 The Qt Company Ltd.
+# SPDX-License-Identifier: BSD-3-Clause
#####################################################################
## tst_qgraphicsgridlayout Test:
#####################################################################
+if(NOT QT_BUILD_STANDALONE_TESTS AND NOT QT_BUILDING_QT)
+ cmake_minimum_required(VERSION 3.16)
+ project(tst_qgraphicsgridlayout LANGUAGES CXX)
+ find_package(Qt6BuildInternals REQUIRED COMPONENTS STANDALONE_TEST)
+endif()
+
qt_internal_add_test(tst_qgraphicsgridlayout
SOURCES
tst_qgraphicsgridlayout.cpp
- PUBLIC_LIBRARIES
+ LIBRARIES
Qt::Gui
Qt::Widgets
)
diff --git a/tests/auto/widgets/graphicsview/qgraphicsgridlayout/tst_qgraphicsgridlayout.cpp b/tests/auto/widgets/graphicsview/qgraphicsgridlayout/tst_qgraphicsgridlayout.cpp
index effd8a28c1..c91a0803ee 100644
--- a/tests/auto/widgets/graphicsview/qgraphicsgridlayout/tst_qgraphicsgridlayout.cpp
+++ b/tests/auto/widgets/graphicsview/qgraphicsgridlayout/tst_qgraphicsgridlayout.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 <QTest>
@@ -1683,7 +1658,7 @@ void tst_QGraphicsGridLayout::sizeHint()
widget->setContentsMargins(0, 0, 0, 0);
int i;
- for (i = 0; i < itemDescriptions.count(); ++i) {
+ for (i = 0; i < itemDescriptions.size(); ++i) {
ItemDesc desc = itemDescriptions.at(i);
RectWidget *item = new RectWidget(widget);
desc.apply(layout, item);
@@ -2184,7 +2159,7 @@ void tst_QGraphicsGridLayout::defaultStretchFactors()
widget->setContentsMargins(0, 0, 0, 0);
int i;
- for (i = 0; i < itemDescriptions.count(); ++i) {
+ for (i = 0; i < itemDescriptions.size(); ++i) {
ItemDesc desc = itemDescriptions.at(i);
RectWidget *item = new RectWidget(widget);
desc.apply(layout, item);
@@ -2199,7 +2174,7 @@ void tst_QGraphicsGridLayout::defaultStretchFactors()
widget->resize(newSize);
QApplication::sendPostedEvents(0, 0);
- for (i = 0; i < expectedSizes.count(); ++i) {
+ for (i = 0; i < expectedSizes.size(); ++i) {
QSizeF itemSize = layout->itemAt(i)->geometry().size();
QCOMPARE(itemSize, expectedSizes.at(i));
}
@@ -2343,7 +2318,7 @@ void tst_QGraphicsGridLayout::alignment2()
widget->setContentsMargins(0, 0, 0, 0);
int i;
- for (i = 0; i < itemDescriptions.count(); ++i) {
+ for (i = 0; i < itemDescriptions.size(); ++i) {
ItemDesc desc = itemDescriptions.at(i);
RectWidget *item = new RectWidget(widget);
desc.apply(layout, item);
@@ -2358,7 +2333,7 @@ void tst_QGraphicsGridLayout::alignment2()
widget->resize(newSize);
QApplication::sendPostedEvents(0, 0);
- for (i = 0; i < expectedGeometries.count(); ++i) {
+ for (i = 0; i < expectedGeometries.size(); ++i) {
QRectF itemRect = layout->itemAt(i)->geometry();
QCOMPARE(itemRect, expectedGeometries.at(i));
}
@@ -2921,7 +2896,7 @@ void tst_QGraphicsGridLayout::geometries()
widget->setContentsMargins(0, 0, 0, 0);
int i;
- for (i = 0; i < itemDescriptions.count(); ++i) {
+ for (i = 0; i < itemDescriptions.size(); ++i) {
ItemDesc desc = itemDescriptions.at(i);
RectWidget *item = new RectWidget(widget);
desc.apply(layout, item);
@@ -2936,7 +2911,7 @@ void tst_QGraphicsGridLayout::geometries()
widget->resize(newSize);
QApplication::processEvents();
- for (i = 0; i < expectedGeometries.count(); ++i) {
+ for (i = 0; i < expectedGeometries.size(); ++i) {
QRectF itemRect = layout->itemAt(i)->geometry();
QCOMPARE(itemRect, expectedGeometries.at(i));
}
@@ -3181,7 +3156,6 @@ void tst_QGraphicsGridLayout::heightForWidthWithSpanning()
QCOMPARE(layout->effectiveSizeHint(Qt::MaximumSize, QSizeF(200, -1)), QSizeF(200, 100));
}
-Q_DECLARE_METATYPE(QSizePolicy::Policy)
void tst_QGraphicsGridLayout::spanningItem2x2_data()
{
QTest::addColumn<QSizePolicy::Policy>("sizePolicy");
diff --git a/tests/auto/widgets/graphicsview/qgraphicsitem/BLACKLIST b/tests/auto/widgets/graphicsview/qgraphicsitem/BLACKLIST
index 31dbb38a5d..c3de568a24 100644
--- a/tests/auto/widgets/graphicsview/qgraphicsitem/BLACKLIST
+++ b/tests/auto/widgets/graphicsview/qgraphicsitem/BLACKLIST
@@ -1,4 +1,6 @@
# QTBUG-74760
[sorting]
-opensuse-42.3
osx
+# QTBUG-115293
+[itemUsesExtendedStyleOption]
+wayland
diff --git a/tests/auto/widgets/graphicsview/qgraphicsitem/CMakeLists.txt b/tests/auto/widgets/graphicsview/qgraphicsitem/CMakeLists.txt
index 02a667eb9c..3ee507cd46 100644
--- a/tests/auto/widgets/graphicsview/qgraphicsitem/CMakeLists.txt
+++ b/tests/auto/widgets/graphicsview/qgraphicsitem/CMakeLists.txt
@@ -1,15 +1,22 @@
-# Generated from qgraphicsitem.pro.
+# Copyright (C) 2022 The Qt Company Ltd.
+# SPDX-License-Identifier: BSD-3-Clause
#####################################################################
## tst_qgraphicsitem Test:
#####################################################################
+if(NOT QT_BUILD_STANDALONE_TESTS AND NOT QT_BUILDING_QT)
+ cmake_minimum_required(VERSION 3.16)
+ project(tst_qgraphicsitem LANGUAGES CXX)
+ find_package(Qt6BuildInternals REQUIRED COMPONENTS STANDALONE_TEST)
+endif()
+
qt_internal_add_test(tst_qgraphicsitem
SOURCES
tst_qgraphicsitem.cpp
DEFINES
QT_NO_CAST_TO_ASCII
- PUBLIC_LIBRARIES
+ LIBRARIES
Qt::CorePrivate
Qt::Gui
Qt::GuiPrivate
@@ -22,6 +29,6 @@ qt_internal_add_test(tst_qgraphicsitem
#####################################################################
qt_internal_extend_target(tst_qgraphicsitem CONDITION WIN32
- PUBLIC_LIBRARIES
+ LIBRARIES
user32
)
diff --git a/tests/auto/widgets/graphicsview/qgraphicsitem/tst_qgraphicsitem.cpp b/tests/auto/widgets/graphicsview/qgraphicsitem/tst_qgraphicsitem.cpp
index bc8369e284..35356adcfc 100644
--- a/tests/auto/widgets/graphicsview/qgraphicsitem/tst_qgraphicsitem.cpp
+++ b/tests/auto/widgets/graphicsview/qgraphicsitem/tst_qgraphicsitem.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 <QTest>
@@ -65,6 +40,8 @@
#include <QtGui/private/qeventpoint_p.h>
+#include <QtWidgets/private/qapplication_p.h>
+
using AbstractGraphicsShapeItemPtr = QSharedPointer<QAbstractGraphicsShapeItem>;
using GraphicsItems = QList<QGraphicsItem *>;
using GraphicsItemsList = QList<QGraphicsItem *>;
@@ -1016,7 +993,6 @@ void tst_QGraphicsItem::inputMethodHints()
scene.addItem(item);
scene.addItem(item2);
QGraphicsView view(&scene);
- QApplication::setActiveWindow(&view);
view.setWindowTitle(QLatin1String(QTest::currentTestFunction()));
view.show();
QVERIFY(QTest::qWaitForWindowExposed(&view));
@@ -1073,7 +1049,6 @@ void tst_QGraphicsItem::toolTip()
view.setWindowTitle(QLatin1String(QTest::currentTestFunction()));
view.setFixedSize(200, 200);
view.show();
- QApplication::setActiveWindow(&view);
QVERIFY(QTest::qWaitForWindowExposed(&view));
QVERIFY(QTest::qWaitForWindowActive(&view));
{
@@ -2231,7 +2206,7 @@ void tst_QGraphicsItem::setTransform()
scene.update(scene.sceneRect());
QCoreApplication::processEvents();
- QCOMPARE(spy.count(), 1);
+ QCOMPARE(spy.size(), 1);
item.setTransform(QTransform().rotate(qreal(12.34)));
QRectF rotatedRect = scene.sceneRect();
@@ -2239,14 +2214,14 @@ void tst_QGraphicsItem::setTransform()
scene.update(scene.sceneRect());
QCoreApplication::processEvents();
- QCOMPARE(spy.count(), 2);
+ QCOMPARE(spy.size(), 2);
item.setTransform(QTransform());
scene.update(scene.sceneRect());
QCoreApplication::processEvents();
- QCOMPARE(spy.count(), 3);
+ QCOMPARE(spy.size(), 3);
QList<QRectF> rlist = qvariant_cast<QList<QRectF> >(spy.last().at(0));
QCOMPARE(rlist.size(), 2);
@@ -3399,7 +3374,7 @@ void tst_QGraphicsItem::childrenBoundingRect()
childChild->setPos(500, 500);
child->setTransform(QTransform().rotate(90), true);
- scene.addPolygon(parent->mapToScene(parent->boundingRect() | parent->childrenBoundingRect()))->setPen(QPen(Qt::red));;
+ scene.addPolygon(parent->mapToScene(parent->boundingRect() | parent->childrenBoundingRect()))->setPen(QPen(Qt::red));
QGraphicsView view(&scene);
view.setWindowTitle(QLatin1String(QTest::currentTestFunction()));
@@ -3626,7 +3601,7 @@ void tst_QGraphicsItem::group()
view.fitInView(scene.itemsBoundingRect());
- for (QGraphicsItem *item : qAsConst(newItems)) {
+ for (QGraphicsItem *item : std::as_const(newItems)) {
group->addToGroup(item);
QCOMPARE(item->group(), group);
}
@@ -4969,7 +4944,6 @@ void tst_QGraphicsItem::sceneEventFilter()
QGraphicsView view(&scene);
view.setWindowTitle(QLatin1String(QTest::currentTestFunction()));
view.show();
- QApplication::setActiveWindow(&view);
QVERIFY(QTest::qWaitForWindowExposed(&view));
QVERIFY(QTest::qWaitForWindowActive(&view));
@@ -5362,8 +5336,9 @@ void tst_QGraphicsItem::deleteItemInEventHandlers()
#ifndef QT_NO_CONTEXTMENU
if (!HarakiriItem::dead) {
- QContextMenuEvent event(QContextMenuEvent::Other,
- view.mapFromScene(item->scenePos()));
+ auto viewPos = view.mapFromScene(item->scenePos());
+ QContextMenuEvent event(QContextMenuEvent::Other, viewPos,
+ view.mapToGlobal(viewPos));
QCoreApplication::sendEvent(view.viewport(), &event);
}
#endif // QT_NO_CONTEXTMENU
@@ -5589,7 +5564,6 @@ void tst_QGraphicsItem::itemClipsChildrenToShape4()
scene.addEllipse( 100, 100, 100, 50 ); // <-- this is important to trigger the right codepath*
//now the label is shown
outerWidget->setFlag(QGraphicsItem::ItemClipsChildrenToShape, false );
- QApplication::setActiveWindow(&view);
view.setWindowTitle(QLatin1String(QTest::currentTestFunction()));
view.show();
QTRY_COMPARE(QApplication::activeWindow(), &view);
@@ -5705,7 +5679,7 @@ void tst_QGraphicsItem::itemClipsChildrenToShape5()
}
const QList<QGraphicsItem *> children = parent->childItems();
- const int childrenCount = children.count();
+ const int childrenCount = children.size();
for (int i = 0; i < 5; ++i) {
QString clipString;
@@ -6933,8 +6907,10 @@ void tst_QGraphicsItem::opacityZeroUpdates()
view.setWindowTitle(QLatin1String(QTest::currentTestFunction()));
view.show();
QVERIFY(QTest::qWaitForWindowExposed(&view));
- if (QGuiApplicationPrivate::platformIntegration()->hasCapability(QPlatformIntegration::WindowActivation))
+ if (QGuiApplicationPrivate::platformIntegration()->hasCapability(QPlatformIntegration::WindowActivation)) {
+ view.window()->activateWindow();
QVERIFY(QTest::qWaitForWindowActive(&view));
+ }
QCoreApplication::processEvents(); // Process all queued paint events
QTRY_VERIFY(view.repaints > 0);
@@ -7290,6 +7266,7 @@ void tst_QGraphicsItem::tabChangesFocus()
widget.setWindowTitle(QLatin1String(QTest::currentTestFunction()));
widget.setLayout(layout);
widget.show();
+ view->window()->activateWindow();
QVERIFY(QTest::qWaitForWindowActive(&widget));
QTRY_VERIFY(scene.isActive());
@@ -7324,7 +7301,7 @@ void tst_QGraphicsItem::cacheMode()
view.setWindowTitle(QLatin1String(QTest::currentTestFunction()));
view.resize(150, 150);
view.show();
- QApplication::setActiveWindow(&view);
+ view.window()->activateWindow();
QVERIFY(QTest::qWaitForWindowExposed(&view));
QVERIFY(QTest::qWaitForWindowActive(&view));
QCoreApplication::processEvents(); // Process all queued paint events
@@ -7508,7 +7485,7 @@ void tst_QGraphicsItem::cacheMode2()
view.setWindowTitle(QLatin1String(QTest::currentTestFunction()));
view.resize(150, 150);
view.show();
- QApplication::setActiveWindow(&view);
+ view.window()->activateWindow();
QVERIFY(QTest::qWaitForWindowExposed(&view));
QVERIFY(QTest::qWaitForWindowActive(&view));
QCoreApplication::processEvents(); // Process all queued paint events
@@ -8169,9 +8146,11 @@ void tst_QGraphicsItem::moveLineItem()
MyGraphicsView view(&scene);
view.setWindowTitle(QLatin1String(QTest::currentTestFunction()));
view.show();
- QVERIFY(QTest::qWaitForWindowExposed(&view));
- if (QGuiApplicationPrivate::platformIntegration()->hasCapability(QPlatformIntegration::WindowActivation))
+ if (QGuiApplicationPrivate::platformIntegration()->hasCapability(QPlatformIntegration::WindowActivation)) {
+ view.window()->activateWindow();
QVERIFY(QTest::qWaitForWindowActive(&view));
+ }
+ QVERIFY(QTest::qWaitForWindowExposed(&view));
QCoreApplication::processEvents(); // Process all queued paint events
view.reset();
@@ -8241,11 +8220,11 @@ void tst_QGraphicsItem::sorting()
view.setFrameStyle(0);
view.show();
if (QGuiApplicationPrivate::platformIntegration()->hasCapability(QPlatformIntegration::WindowActivation)) {
- qApp->setActiveWindow(&view);
+ view.window()->activateWindow();
QVERIFY(QTest::qWaitForWindowActive(&view));
}
QVERIFY(QTest::qWaitForWindowExposed(&view));
- QTRY_VERIFY(_paintedItems.count() > 0);
+ QTRY_VERIFY(_paintedItems.size() > 0);
_paintedItems.clear();
@@ -8275,7 +8254,7 @@ void tst_QGraphicsItem::itemHasNoContents()
view.setWindowTitle(QLatin1String(QTest::currentTestFunction()));
view.show();
if (QGuiApplicationPrivate::platformIntegration()->hasCapability(QPlatformIntegration::WindowActivation)) {
- qApp->setActiveWindow(&view);
+ view.window()->activateWindow();
QVERIFY(QTest::qWaitForWindowActive(&view));
}
QVERIFY(QTest::qWaitForWindowExposed(&view));
@@ -9295,7 +9274,7 @@ void tst_QGraphicsItem::ensureDirtySceneTransform()
view.setWindowTitle(QLatin1String(QTest::currentTestFunction()));
view.show();
if (QGuiApplicationPrivate::platformIntegration()->hasCapability(QPlatformIntegration::WindowActivation)) {
- QApplication::setActiveWindow(&view);
+ view.window()->activateWindow();
QVERIFY(QTest::qWaitForWindowActive(&view));
QCOMPARE(QApplication::activeWindow(), static_cast<QWidget *>(&view));
}
@@ -9693,7 +9672,7 @@ void tst_QGraphicsItem::QTBUG_4233_updateCachedWithSceneRect()
QGraphicsView view(&scene);
view.setWindowTitle(QLatin1String(QTest::currentTestFunction()));
view.show();
- QApplication::setActiveWindow(&view);
+ view.window()->activateWindow();
QVERIFY(QTest::qWaitForWindowExposed(&view));
QVERIFY(QTest::qWaitForWindowActive(&view));
QCOMPARE(QApplication::activeWindow(), &view);
@@ -10773,6 +10752,10 @@ void tst_QGraphicsItem::textItem_shortcuts()
item->setFlag(QGraphicsItem::ItemIsFocusable);
item->setTextInteractionFlags(Qt::TextEditorInteraction);
w.show();
+ if (QGuiApplicationPrivate::platformIntegration()->hasCapability(QPlatformIntegration::WindowActivation)) {
+ view.window()->activateWindow();
+ QVERIFY(QTest::qWaitForWindowActive(&view));
+ }
QVERIFY(QTest::qWaitForWindowExposed(&w));
item->setFocus();
@@ -10827,8 +10810,10 @@ void tst_QGraphicsItem::scroll()
view.setFrameStyle(0);
view.show();
QVERIFY(QTest::qWaitForWindowExposed(&view));
- if (QGuiApplicationPrivate::platformIntegration()->hasCapability(QPlatformIntegration::WindowActivation))
+ if (QGuiApplicationPrivate::platformIntegration()->hasCapability(QPlatformIntegration::WindowActivation)) {
+ view.window()->activateWindow();
QVERIFY(QTest::qWaitForWindowActive(&view));
+ }
QTRY_VERIFY(view.repaints > 0);
view.reset();
@@ -10942,7 +10927,6 @@ void tst_QGraphicsItem::focusHandling()
view.show();
QVERIFY(QTest::qWaitForWindowExposed(&view));
- QApplication::setActiveWindow(&view);
QTRY_COMPARE(QApplication::activeWindow(), static_cast<QWidget *>(&view));
QVERIFY(itemWithFocus->hasFocus());
@@ -11347,7 +11331,7 @@ void tst_QGraphicsItem::QTBUG_6738_missingUpdateWithSetParent()
view.setWindowTitle(QLatin1String(QTest::currentTestFunction()));
view.show();
if (QGuiApplicationPrivate::platformIntegration()->hasCapability(QPlatformIntegration::WindowActivation)) {
- qApp->setActiveWindow(&view);
+ view.window()->activateWindow();
QVERIFY(QTest::qWaitForWindowActive(&view));
}
QVERIFY(QTest::qWaitForWindowExposed(&view));
@@ -11401,8 +11385,10 @@ void tst_QGraphicsItem::QT_2653_fullUpdateDiscardingOpacityUpdate()
view.show();
QVERIFY(QTest::qWaitForWindowExposed(&view));
- if (QGuiApplicationPrivate::platformIntegration()->hasCapability(QPlatformIntegration::WindowActivation))
+ if (QGuiApplicationPrivate::platformIntegration()->hasCapability(QPlatformIntegration::WindowActivation)) {
+ view.window()->activateWindow();
QVERIFY(QTest::qWaitForWindowActive(&view));
+ }
QCoreApplication::processEvents(); // Process all queued paint events
view.reset();
@@ -11437,8 +11423,10 @@ void tst_QGraphicsItem::QTBUG_7714_fullUpdateDiscardingOpacityUpdate2()
scene.addItem(parentGreen);
origView.show();
- if (QGuiApplicationPrivate::platformIntegration()->hasCapability(QPlatformIntegration::WindowActivation))
+ if (QGuiApplicationPrivate::platformIntegration()->hasCapability(QPlatformIntegration::WindowActivation)) {
+ view.window()->activateWindow();
QVERIFY(QTest::qWaitForWindowActive(&origView));
+ }
QVERIFY(QTest::qWaitForWindowExposed(&origView));
QCoreApplication::processEvents(); // Process all queued paint events
@@ -11454,7 +11442,7 @@ void tst_QGraphicsItem::QTBUG_7714_fullUpdateDiscardingOpacityUpdate2()
view.show();
if (QGuiApplicationPrivate::platformIntegration()->hasCapability(QPlatformIntegration::WindowActivation)) {
- qApp->setActiveWindow(&view);
+ QApplicationPrivate::setActiveWindow(&view);
QVERIFY(QTest::qWaitForWindowActive(&view));
}
QVERIFY(QTest::qWaitForWindowExposed(&view));
@@ -11595,6 +11583,7 @@ void tst_QGraphicsItem::doNotMarkFullUpdateIfNotInScene()
item2->setParentItem(item);
scene.addItem(item);
view.show();
+ view.window()->activateWindow();
QVERIFY(QTest::qWaitForWindowExposed(view.windowHandle()));
QVERIFY(QTest::qWaitForWindowActive(view.windowHandle()));
QCoreApplication::processEvents(); // Process all queued paint events
@@ -11629,7 +11618,7 @@ void tst_QGraphicsItem::itemDiesDuringDraggingOperation()
scene.addItem(item);
view.show();
if (QGuiApplicationPrivate::platformIntegration()->hasCapability(QPlatformIntegration::WindowActivation)) {
- QApplication::setActiveWindow(&view);
+ view.window()->activateWindow();
QVERIFY(QTest::qWaitForWindowActive(&view));
QCOMPARE(QApplication::activeWindow(), &view);
}
@@ -11660,7 +11649,7 @@ void tst_QGraphicsItem::QTBUG_12112_focusItem()
view.show();
if (QGuiApplicationPrivate::platformIntegration()->hasCapability(QPlatformIntegration::WindowActivation)) {
- QApplication::setActiveWindow(&view);
+ view.window()->activateWindow();
QVERIFY(QTest::qWaitForWindowActive(&view));
QCOMPARE(QApplication::activeWindow(), &view);
}
@@ -11710,7 +11699,7 @@ public:
QLatin1String wiseWords("AZ BUKI VEDI");
QString sentence(wiseWords);
QStringList words = sentence.split(QLatin1Char(' '), Qt::SkipEmptyParts);
- for (int i = 0; i < words.count(); ++i) {
+ for (int i = 0; i < words.size(); ++i) {
QGraphicsProxyWidget *proxy = new QGraphicsProxyWidget(this);
QLabel *label = new QLabel(words.at(i));
proxy->setWidget(label);
diff --git a/tests/auto/widgets/graphicsview/qgraphicsitemanimation/CMakeLists.txt b/tests/auto/widgets/graphicsview/qgraphicsitemanimation/CMakeLists.txt
index 48bb84d1bb..04bfb3f54a 100644
--- a/tests/auto/widgets/graphicsview/qgraphicsitemanimation/CMakeLists.txt
+++ b/tests/auto/widgets/graphicsview/qgraphicsitemanimation/CMakeLists.txt
@@ -1,15 +1,22 @@
-# Generated from qgraphicsitemanimation.pro.
+# Copyright (C) 2022 The Qt Company Ltd.
+# SPDX-License-Identifier: BSD-3-Clause
#####################################################################
## tst_qgraphicsitemanimation Test:
#####################################################################
+if(NOT QT_BUILD_STANDALONE_TESTS AND NOT QT_BUILDING_QT)
+ cmake_minimum_required(VERSION 3.16)
+ project(tst_qgraphicsitemanimation LANGUAGES CXX)
+ find_package(Qt6BuildInternals REQUIRED COMPONENTS STANDALONE_TEST)
+endif()
+
qt_internal_add_test(tst_qgraphicsitemanimation
SOURCES
tst_qgraphicsitemanimation.cpp
DEFINES
QT_NO_CAST_TO_ASCII
- PUBLIC_LIBRARIES
+ LIBRARIES
Qt::Gui
Qt::Widgets
)
diff --git a/tests/auto/widgets/graphicsview/qgraphicsitemanimation/tst_qgraphicsitemanimation.cpp b/tests/auto/widgets/graphicsview/qgraphicsitemanimation/tst_qgraphicsitemanimation.cpp
index 46e834afdb..9cf74c23fe 100644
--- a/tests/auto/widgets/graphicsview/qgraphicsitemanimation/tst_qgraphicsitemanimation.cpp
+++ b/tests/auto/widgets/graphicsview/qgraphicsitemanimation/tst_qgraphicsitemanimation.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 <QTest>
diff --git a/tests/auto/widgets/graphicsview/qgraphicslayout/CMakeLists.txt b/tests/auto/widgets/graphicsview/qgraphicslayout/CMakeLists.txt
index 768898549e..4951558423 100644
--- a/tests/auto/widgets/graphicsview/qgraphicslayout/CMakeLists.txt
+++ b/tests/auto/widgets/graphicsview/qgraphicslayout/CMakeLists.txt
@@ -1,15 +1,22 @@
-# Generated from qgraphicslayout.pro.
+# Copyright (C) 2022 The Qt Company Ltd.
+# SPDX-License-Identifier: BSD-3-Clause
#####################################################################
## tst_qgraphicslayout Test:
#####################################################################
+if(NOT QT_BUILD_STANDALONE_TESTS AND NOT QT_BUILDING_QT)
+ cmake_minimum_required(VERSION 3.16)
+ project(tst_qgraphicslayout LANGUAGES CXX)
+ find_package(Qt6BuildInternals REQUIRED COMPONENTS STANDALONE_TEST)
+endif()
+
qt_internal_add_test(tst_qgraphicslayout
SOURCES
tst_qgraphicslayout.cpp
DEFINES
QT_USE_USING_NAMESPACE
- PUBLIC_LIBRARIES
+ LIBRARIES
Qt::Gui
Qt::Widgets
)
diff --git a/tests/auto/widgets/graphicsview/qgraphicslayout/tst_qgraphicslayout.cpp b/tests/auto/widgets/graphicsview/qgraphicslayout/tst_qgraphicslayout.cpp
index 167f418c3d..268195d7d3 100644
--- a/tests/auto/widgets/graphicsview/qgraphicslayout/tst_qgraphicslayout.cpp
+++ b/tests/auto/widgets/graphicsview/qgraphicslayout/tst_qgraphicslayout.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 <QTest>
@@ -695,7 +670,7 @@ public:
private slots:
void valueChanged(qreal value) {
- for (int i = 0; i < fromGeoms.count(); ++i) {
+ for (int i = 0; i < fromGeoms.size(); ++i) {
QGraphicsLayoutItem *li = itemAt(i);
QRectF from = fromGeoms.at(i);
QRectF to = toGeoms.at(i);
@@ -850,7 +825,7 @@ CustomLayout(QGraphicsLayoutItem *parent)
int count() const override
{
- return items.count();
+ return items.size();
}
QGraphicsLayoutItem* itemAt(int index) const override
@@ -866,12 +841,12 @@ void removeAt(int index) override
void addItem(QGraphicsLayoutItem *item)
{
- insertItem(items.count(), item);
+ insertItem(items.size(), item);
}
void insertItem(int index, QGraphicsLayoutItem *item)
{
- index = qBound(0, index, items.count());
+ index = qBound(0, index, items.size());
item->setParentLayoutItem(this);
@@ -879,7 +854,7 @@ void insertItem(int index, QGraphicsLayoutItem *item)
updateParentWidget(widget);
- if (index == items.count()) {
+ if (index == items.size()) {
items.append(item);
} else {
items.insert(index, item);
@@ -947,7 +922,7 @@ void tst_QGraphicsLayout::ownership()
destructedSet.clear();
window->setLayout(0);
- QCOMPARE(destructedSet.count(), 0);
+ QCOMPARE(destructedSet.size(), 0);
delete window;
}
diff --git a/tests/auto/widgets/graphicsview/qgraphicslayoutitem/CMakeLists.txt b/tests/auto/widgets/graphicsview/qgraphicslayoutitem/CMakeLists.txt
index d927ec59aa..7bd25cecf2 100644
--- a/tests/auto/widgets/graphicsview/qgraphicslayoutitem/CMakeLists.txt
+++ b/tests/auto/widgets/graphicsview/qgraphicslayoutitem/CMakeLists.txt
@@ -1,13 +1,20 @@
-# Generated from qgraphicslayoutitem.pro.
+# Copyright (C) 2022 The Qt Company Ltd.
+# SPDX-License-Identifier: BSD-3-Clause
#####################################################################
## tst_qgraphicslayoutitem Test:
#####################################################################
+if(NOT QT_BUILD_STANDALONE_TESTS AND NOT QT_BUILDING_QT)
+ cmake_minimum_required(VERSION 3.16)
+ project(tst_qgraphicslayoutitem LANGUAGES CXX)
+ find_package(Qt6BuildInternals REQUIRED COMPONENTS STANDALONE_TEST)
+endif()
+
qt_internal_add_test(tst_qgraphicslayoutitem
SOURCES
tst_qgraphicslayoutitem.cpp
- PUBLIC_LIBRARIES
+ LIBRARIES
Qt::Gui
Qt::Widgets
)
diff --git a/tests/auto/widgets/graphicsview/qgraphicslayoutitem/tst_qgraphicslayoutitem.cpp b/tests/auto/widgets/graphicsview/qgraphicslayoutitem/tst_qgraphicslayoutitem.cpp
index 7e0a8b6033..87b703a286 100644
--- a/tests/auto/widgets/graphicsview/qgraphicslayoutitem/tst_qgraphicslayoutitem.cpp
+++ b/tests/auto/widgets/graphicsview/qgraphicslayoutitem/tst_qgraphicslayoutitem.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 <QTest>
diff --git a/tests/auto/widgets/graphicsview/qgraphicslinearlayout/CMakeLists.txt b/tests/auto/widgets/graphicsview/qgraphicslinearlayout/CMakeLists.txt
index 6c2e734348..b63bbb6f33 100644
--- a/tests/auto/widgets/graphicsview/qgraphicslinearlayout/CMakeLists.txt
+++ b/tests/auto/widgets/graphicsview/qgraphicslinearlayout/CMakeLists.txt
@@ -1,13 +1,20 @@
-# Generated from qgraphicslinearlayout.pro.
+# Copyright (C) 2022 The Qt Company Ltd.
+# SPDX-License-Identifier: BSD-3-Clause
#####################################################################
## tst_qgraphicslinearlayout Test:
#####################################################################
+if(NOT QT_BUILD_STANDALONE_TESTS AND NOT QT_BUILDING_QT)
+ cmake_minimum_required(VERSION 3.16)
+ project(tst_qgraphicslinearlayout LANGUAGES CXX)
+ find_package(Qt6BuildInternals REQUIRED COMPONENTS STANDALONE_TEST)
+endif()
+
qt_internal_add_test(tst_qgraphicslinearlayout
SOURCES
tst_qgraphicslinearlayout.cpp
- PUBLIC_LIBRARIES
+ LIBRARIES
Qt::Gui
Qt::Widgets
)
diff --git a/tests/auto/widgets/graphicsview/qgraphicslinearlayout/tst_qgraphicslinearlayout.cpp b/tests/auto/widgets/graphicsview/qgraphicslinearlayout/tst_qgraphicslinearlayout.cpp
index eef554ad87..65212e94cc 100644
--- a/tests/auto/widgets/graphicsview/qgraphicslinearlayout/tst_qgraphicslinearlayout.cpp
+++ b/tests/auto/widgets/graphicsview/qgraphicslinearlayout/tst_qgraphicslinearlayout.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 <QTest>
@@ -748,7 +723,7 @@ void tst_QGraphicsLinearLayout::orientation()
// important to resize to preferredsize when orientation is switched
widget->resize(widget->effectiveSizeHint(Qt::PreferredSize));
qApp->processEvents();
- for (i = 0; i < positions.count(); ++i) {
+ for (i = 0; i < positions.size(); ++i) {
QGraphicsWidget *item = static_cast<QGraphicsWidget*>(layout.itemAt(i));
if (initialOrientation == Qt::Horizontal)
QCOMPARE(item->pos().y(), positions.at(i));
@@ -1146,7 +1121,7 @@ void tst_QGraphicsLinearLayout::setStretchFactor()
int i;
- for (i = 0; i < stretches.count(); ++i) {
+ for (i = 0; i < stretches.size(); ++i) {
QGraphicsWidget *item = new RectWidget(widget);
item->setMinimumSize(5,5);
item->setPreferredSize(10,5);
@@ -1164,7 +1139,7 @@ void tst_QGraphicsLinearLayout::setStretchFactor()
qreal firstStretch = -1;
qreal firstExtent = -1.;
qreal sumExtent = 0;
- for (i = 0; i < stretches.count(); ++i) {
+ for (i = 0; i < stretches.size(); ++i) {
QGraphicsWidget *item = static_cast<QGraphicsWidget*>(layout.itemAt(i));
qreal extent = item->size().width();
qreal stretch = (qreal)stretches.at(i);
@@ -1322,7 +1297,7 @@ void tst_QGraphicsLinearLayout::defaultStretchFactors()
QSizeF itemSize = layout->itemAt(i)->geometry().size();
if (orientation == Qt::Vertical)
itemSize.transpose();
- if (i < expectedSizes.count())
+ if (i < expectedSizes.size())
QCOMPARE(itemSize.width(), qreal(expectedSizes.at(i)));
}
diff --git a/tests/auto/widgets/graphicsview/qgraphicsobject/CMakeLists.txt b/tests/auto/widgets/graphicsview/qgraphicsobject/CMakeLists.txt
index 9b7bf4c63c..0c21d9febc 100644
--- a/tests/auto/widgets/graphicsview/qgraphicsobject/CMakeLists.txt
+++ b/tests/auto/widgets/graphicsview/qgraphicsobject/CMakeLists.txt
@@ -1,13 +1,20 @@
-# Generated from qgraphicsobject.pro.
+# Copyright (C) 2022 The Qt Company Ltd.
+# SPDX-License-Identifier: BSD-3-Clause
#####################################################################
## tst_qgraphicsobject Test:
#####################################################################
+if(NOT QT_BUILD_STANDALONE_TESTS AND NOT QT_BUILDING_QT)
+ cmake_minimum_required(VERSION 3.16)
+ project(tst_qgraphicsobject LANGUAGES CXX)
+ find_package(Qt6BuildInternals REQUIRED COMPONENTS STANDALONE_TEST)
+endif()
+
qt_internal_add_test(tst_qgraphicsobject
SOURCES
tst_qgraphicsobject.cpp
- PUBLIC_LIBRARIES
+ LIBRARIES
Qt::CorePrivate
Qt::Gui
Qt::Widgets
diff --git a/tests/auto/widgets/graphicsview/qgraphicsobject/tst_qgraphicsobject.cpp b/tests/auto/widgets/graphicsview/qgraphicsobject/tst_qgraphicsobject.cpp
index 58c965a7d0..674a7f73d5 100644
--- a/tests/auto/widgets/graphicsview/qgraphicsobject/tst_qgraphicsobject.cpp
+++ b/tests/auto/widgets/graphicsview/qgraphicsobject/tst_qgraphicsobject.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 <QTest>
@@ -66,28 +41,28 @@ void tst_QGraphicsObject::pos()
QSignalSpy ySpy(&object, SIGNAL(yChanged()));
QVERIFY(object.pos() == QPointF(0, 0));
object.setPos(10, 10);
- QCOMPARE(xSpy.count(), 1);
- QCOMPARE(ySpy.count(), 1);
+ QCOMPARE(xSpy.size(), 1);
+ QCOMPARE(ySpy.size(), 1);
QCOMPARE(object.pos(), QPointF(10,10));
object.setPos(10, 10);
- QCOMPARE(xSpy.count(), 1);
- QCOMPARE(ySpy.count(), 1);
+ QCOMPARE(xSpy.size(), 1);
+ QCOMPARE(ySpy.size(), 1);
object.setProperty("pos", QPointF(0, 0));
- QCOMPARE(xSpy.count(), 2);
- QCOMPARE(ySpy.count(), 2);
+ QCOMPARE(xSpy.size(), 2);
+ QCOMPARE(ySpy.size(), 2);
QCOMPARE(object.property("pos").toPointF(), QPointF(0,0));
object.setProperty("pos", QPointF(10, 0));
- QCOMPARE(xSpy.count(), 3);
- QCOMPARE(ySpy.count(), 2);
+ QCOMPARE(xSpy.size(), 3);
+ QCOMPARE(ySpy.size(), 2);
QCOMPARE(object.property("pos").toPointF(), QPointF(10,0));
object.setProperty("pos", QPointF(10, 10));
- QCOMPARE(xSpy.count(), 3);
- QCOMPARE(ySpy.count(), 3);
+ QCOMPARE(xSpy.size(), 3);
+ QCOMPARE(ySpy.size(), 3);
QVERIFY(object.property("pos") == QPointF(10, 10));
}
@@ -98,19 +73,19 @@ void tst_QGraphicsObject::x()
QSignalSpy ySpy(&object, SIGNAL(yChanged()));
QVERIFY(object.pos() == QPointF(0, 0));
object.setX(10);
- QCOMPARE(xSpy.count(), 1);
- QCOMPARE(ySpy.count(), 0);
+ QCOMPARE(xSpy.size(), 1);
+ QCOMPARE(ySpy.size(), 0);
QVERIFY(object.pos() == QPointF(10, 0));
QCOMPARE(object.x(), qreal(10));
object.setX(10);
- QCOMPARE(xSpy.count(), 1);
- QCOMPARE(ySpy.count(), 0);
+ QCOMPARE(xSpy.size(), 1);
+ QCOMPARE(ySpy.size(), 0);
object.setProperty("x", 0);
- QCOMPARE(xSpy.count(), 2);
- QCOMPARE(ySpy.count(), 0);
+ QCOMPARE(xSpy.size(), 2);
+ QCOMPARE(ySpy.size(), 0);
QCOMPARE(object.property("x").toDouble(), double(0));
}
@@ -121,19 +96,19 @@ void tst_QGraphicsObject::y()
QSignalSpy ySpy(&object, SIGNAL(yChanged()));
QVERIFY(object.pos() == QPointF(0, 0));
object.setY(10);
- QCOMPARE(xSpy.count(), 0);
- QCOMPARE(ySpy.count(), 1);
+ QCOMPARE(xSpy.size(), 0);
+ QCOMPARE(ySpy.size(), 1);
QVERIFY(object.pos() == QPointF(0, 10));
QCOMPARE(object.y(), qreal(10));
object.setY(10);
- QCOMPARE(xSpy.count(), 0);
- QCOMPARE(ySpy.count(), 1);
+ QCOMPARE(xSpy.size(), 0);
+ QCOMPARE(ySpy.size(), 1);
object.setProperty("y", 0);
- QCOMPARE(xSpy.count(), 0);
- QCOMPARE(ySpy.count(), 2);
+ QCOMPARE(xSpy.size(), 0);
+ QCOMPARE(ySpy.size(), 2);
QCOMPARE(object.property("y").toDouble(), qreal(0));
}
@@ -143,15 +118,15 @@ void tst_QGraphicsObject::z()
QSignalSpy zSpy(&object, SIGNAL(zChanged()));
QCOMPARE(object.zValue(), qreal(0));
object.setZValue(10);
- QCOMPARE(zSpy.count(), 1);
+ QCOMPARE(zSpy.size(), 1);
QCOMPARE(object.zValue(), qreal(10));
object.setZValue(10);
- QCOMPARE(zSpy.count(), 1);
+ QCOMPARE(zSpy.size(), 1);
object.setProperty("z", 0);
- QCOMPARE(zSpy.count(), 2);
+ QCOMPARE(zSpy.size(), 2);
QCOMPARE(object.property("z").toDouble(), double(0));
}
@@ -161,15 +136,15 @@ void tst_QGraphicsObject::opacity()
QSignalSpy spy(&object, SIGNAL(opacityChanged()));
QCOMPARE(object.opacity(), 1.);
object.setOpacity(0);
- QCOMPARE(spy.count(), 1);
+ QCOMPARE(spy.size(), 1);
QCOMPARE(object.opacity(), 0.);
object.setOpacity(0);
- QCOMPARE(spy.count(), 1);
+ QCOMPARE(spy.size(), 1);
object.setProperty("opacity", .5);
- QCOMPARE(spy.count(), 2);
+ QCOMPARE(spy.size(), 2);
QCOMPARE(object.property("opacity").toDouble(), .5);
}
@@ -179,15 +154,15 @@ void tst_QGraphicsObject::enabled()
QSignalSpy spy(&object, SIGNAL(enabledChanged()));
QVERIFY(object.isEnabled());
object.setEnabled(false);
- QCOMPARE(spy.count(), 1);
+ QCOMPARE(spy.size(), 1);
QVERIFY(!object.isEnabled());
object.setEnabled(false);
- QCOMPARE(spy.count(), 1);
+ QCOMPARE(spy.size(), 1);
object.setProperty("enabled", true);
- QCOMPARE(spy.count(), 2);
+ QCOMPARE(spy.size(), 2);
QVERIFY(object.property("enabled").toBool());
}
@@ -197,15 +172,15 @@ void tst_QGraphicsObject::visible()
QSignalSpy spy(&object, SIGNAL(visibleChanged()));
QVERIFY(object.isVisible());
object.setVisible(false);
- QCOMPARE(spy.count(), 1);
+ QCOMPARE(spy.size(), 1);
QVERIFY(!object.isVisible());
object.setVisible(false);
- QCOMPARE(spy.count(), 1);
+ QCOMPARE(spy.size(), 1);
object.setProperty("visible", true);
- QCOMPARE(spy.count(), 2);
+ QCOMPARE(spy.size(), 2);
QVERIFY(object.property("visible").toBool());
}
diff --git a/tests/auto/widgets/graphicsview/qgraphicspixmapitem/CMakeLists.txt b/tests/auto/widgets/graphicsview/qgraphicspixmapitem/CMakeLists.txt
index a848a8dd77..b60958f4f1 100644
--- a/tests/auto/widgets/graphicsview/qgraphicspixmapitem/CMakeLists.txt
+++ b/tests/auto/widgets/graphicsview/qgraphicspixmapitem/CMakeLists.txt
@@ -1,13 +1,20 @@
-# Generated from qgraphicspixmapitem.pro.
+# Copyright (C) 2022 The Qt Company Ltd.
+# SPDX-License-Identifier: BSD-3-Clause
#####################################################################
## tst_qgraphicspixmapitem Test:
#####################################################################
+if(NOT QT_BUILD_STANDALONE_TESTS AND NOT QT_BUILDING_QT)
+ cmake_minimum_required(VERSION 3.16)
+ project(tst_qgraphicspixmapitem LANGUAGES CXX)
+ find_package(Qt6BuildInternals REQUIRED COMPONENTS STANDALONE_TEST)
+endif()
+
qt_internal_add_test(tst_qgraphicspixmapitem
SOURCES
tst_qgraphicspixmapitem.cpp
- PUBLIC_LIBRARIES
+ LIBRARIES
Qt::Gui
Qt::Widgets
)
diff --git a/tests/auto/widgets/graphicsview/qgraphicspixmapitem/tst_qgraphicspixmapitem.cpp b/tests/auto/widgets/graphicsview/qgraphicspixmapitem/tst_qgraphicspixmapitem.cpp
index 22b81773b9..fd8f8bd37d 100644
--- a/tests/auto/widgets/graphicsview/qgraphicspixmapitem/tst_qgraphicspixmapitem.cpp
+++ b/tests/auto/widgets/graphicsview/qgraphicspixmapitem/tst_qgraphicspixmapitem.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 <QTest>
diff --git a/tests/auto/widgets/graphicsview/qgraphicspolygonitem/CMakeLists.txt b/tests/auto/widgets/graphicsview/qgraphicspolygonitem/CMakeLists.txt
index 8a3c88a8a2..116378decb 100644
--- a/tests/auto/widgets/graphicsview/qgraphicspolygonitem/CMakeLists.txt
+++ b/tests/auto/widgets/graphicsview/qgraphicspolygonitem/CMakeLists.txt
@@ -1,13 +1,20 @@
-# Generated from qgraphicspolygonitem.pro.
+# Copyright (C) 2022 The Qt Company Ltd.
+# SPDX-License-Identifier: BSD-3-Clause
#####################################################################
## tst_qgraphicspolygonitem Test:
#####################################################################
+if(NOT QT_BUILD_STANDALONE_TESTS AND NOT QT_BUILDING_QT)
+ cmake_minimum_required(VERSION 3.16)
+ project(tst_qgraphicspolygonitem LANGUAGES CXX)
+ find_package(Qt6BuildInternals REQUIRED COMPONENTS STANDALONE_TEST)
+endif()
+
qt_internal_add_test(tst_qgraphicspolygonitem
SOURCES
tst_qgraphicspolygonitem.cpp
- PUBLIC_LIBRARIES
+ LIBRARIES
Qt::Gui
Qt::Widgets
)
diff --git a/tests/auto/widgets/graphicsview/qgraphicspolygonitem/tst_qgraphicspolygonitem.cpp b/tests/auto/widgets/graphicsview/qgraphicspolygonitem/tst_qgraphicspolygonitem.cpp
index 90d69ca853..9412fab0ee 100644
--- a/tests/auto/widgets/graphicsview/qgraphicspolygonitem/tst_qgraphicspolygonitem.cpp
+++ b/tests/auto/widgets/graphicsview/qgraphicspolygonitem/tst_qgraphicspolygonitem.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 <QTest>
diff --git a/tests/auto/widgets/graphicsview/qgraphicsproxywidget/BLACKLIST b/tests/auto/widgets/graphicsview/qgraphicsproxywidget/BLACKLIST
index afb6dd5e2d..731b3ae253 100644
--- a/tests/auto/widgets/graphicsview/qgraphicsproxywidget/BLACKLIST
+++ b/tests/auto/widgets/graphicsview/qgraphicsproxywidget/BLACKLIST
@@ -1,7 +1,11 @@
[scrollUpdate]
android
b2qt
-[hoverEnterLeaveEvent]
-macos ci
[windowOpacity]
macos ci
+[wheelEventPropagation]
+android
+[forwardTouchEvent]
+android
+[touchEventPropagation]
+android
diff --git a/tests/auto/widgets/graphicsview/qgraphicsproxywidget/CMakeLists.txt b/tests/auto/widgets/graphicsview/qgraphicsproxywidget/CMakeLists.txt
index a1bf1270c2..f28ff74cfa 100644
--- a/tests/auto/widgets/graphicsview/qgraphicsproxywidget/CMakeLists.txt
+++ b/tests/auto/widgets/graphicsview/qgraphicsproxywidget/CMakeLists.txt
@@ -1,15 +1,22 @@
-# Generated from qgraphicsproxywidget.pro.
+# Copyright (C) 2022 The Qt Company Ltd.
+# SPDX-License-Identifier: BSD-3-Clause
#####################################################################
## tst_qgraphicsproxywidget Test:
#####################################################################
+if(NOT QT_BUILD_STANDALONE_TESTS AND NOT QT_BUILDING_QT)
+ cmake_minimum_required(VERSION 3.16)
+ project(tst_qgraphicsproxywidget LANGUAGES CXX)
+ find_package(Qt6BuildInternals REQUIRED COMPONENTS STANDALONE_TEST)
+endif()
+
qt_internal_add_test(tst_qgraphicsproxywidget
SOURCES
tst_qgraphicsproxywidget.cpp
DEFINES
QTEST_QPA_MOUSE_HANDLING
- PUBLIC_LIBRARIES
+ LIBRARIES
Qt::CorePrivate
Qt::Gui
Qt::GuiPrivate
diff --git a/tests/auto/widgets/graphicsview/qgraphicsproxywidget/tst_qgraphicsproxywidget.cpp b/tests/auto/widgets/graphicsview/qgraphicsproxywidget/tst_qgraphicsproxywidget.cpp
index cd4a30c9bf..e39437d8c7 100644
--- a/tests/auto/widgets/graphicsview/qgraphicsproxywidget/tst_qgraphicsproxywidget.cpp
+++ b/tests/auto/widgets/graphicsview/qgraphicsproxywidget/tst_qgraphicsproxywidget.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 <QTest>
@@ -34,6 +9,8 @@
#include <private/qgraphicsproxywidget_p.h>
#include <private/qlayoutengine_p.h> // qSmartMin functions...
+#include <QtWidgets/private/qapplication_p.h>
+
Q_LOGGING_CATEGORY(lcTests, "qt.widgets.tests")
/*
@@ -358,7 +335,7 @@ void tst_QGraphicsProxyWidget::setWidget()
widget->setStyle(style.data());
widget->setFont(QFont("Times"));
widget->setVisible(true);
- QApplication::setActiveWindow(widget);
+ QApplicationPrivate::setActiveWindow(widget);
widget->activateWindow();
widget->setEnabled(true);
widget->resize(325, 241);
@@ -732,7 +709,6 @@ void tst_QGraphicsProxyWidget::focusNextPrevChild()
QGraphicsScene scene;
QGraphicsView view(&scene);
view.show();
- QApplication::setActiveWindow(&view);
QVERIFY(QTest::qWaitForWindowActive(&view));
if (hasScene) {
scene.addItem(proxyGuard.release());
@@ -774,7 +750,6 @@ void tst_QGraphicsProxyWidget::focusOutEvent()
SubQGraphicsProxyWidget *proxy = new SubQGraphicsProxyWidget;
scene.addItem(proxy);
view.show();
- QApplication::setActiveWindow(&view);
view.activateWindow();
view.setFocus();
QVERIFY(QTest::qWaitForWindowActive(&view));
@@ -807,6 +782,9 @@ void tst_QGraphicsProxyWidget::focusOutEvent()
void tst_QGraphicsProxyWidget::focusProxy_QTBUG_51856()
{
+#ifdef ANDROID
+ QSKIP("This test leads to failures on subsequent test cases, QTBUG-119574");
+#endif
// QSpinBox has an internal QLineEdit; this QLineEdit has the spinbox
// as its focus proxy.
struct FocusedSpinBox : QSpinBox
@@ -829,6 +807,9 @@ void tst_QGraphicsProxyWidget::focusProxy_QTBUG_51856()
}
};
+ if (!QGuiApplicationPrivate::platformIntegration()->hasCapability(QPlatformIntegration::WindowActivation))
+ QSKIP("QWindow::requestActivate() is not supported.");
+
QGraphicsScene scene;
QGraphicsView view(&scene);
SubQGraphicsProxyWidget *proxy = new SubQGraphicsProxyWidget;
@@ -950,7 +931,6 @@ void tst_QGraphicsProxyWidget::hoverEnterLeaveEvent()
QGraphicsScene scene;
QGraphicsView view(&scene);
view.show();
- QApplication::setActiveWindow(&view);
QVERIFY(QTest::qWaitForWindowActive(&view));
SubQGraphicsProxyWidget *proxy = new SubQGraphicsProxyWidget;
@@ -965,7 +945,7 @@ void tst_QGraphicsProxyWidget::hoverEnterLeaveEvent()
proxy->setPos(50, 0);
QSignalSpy sceneChangedSpy(&scene, &QGraphicsScene::changed);
scene.addItem(proxy);
- QTRY_VERIFY(sceneChangedSpy.count() > 0);
+ QTRY_VERIFY(sceneChangedSpy.size() > 0);
// outside graphics item
QTest::mouseMove(&view, QPoint(10, 10));
@@ -1004,7 +984,6 @@ void tst_QGraphicsProxyWidget::keyPressEvent()
QGraphicsView view(&scene);
view.show();
view.viewport()->setFocus();
- QApplication::setActiveWindow(&view);
QVERIFY(QTest::qWaitForWindowActive(&view));
QCOMPARE(QApplication::activeWindow(), (QWidget*)&view);
@@ -1043,7 +1022,6 @@ void tst_QGraphicsProxyWidget::keyReleaseEvent()
QGraphicsScene scene;
QGraphicsView view(&scene);
view.show();
- QApplication::setActiveWindow(&view);
QVERIFY(QTest::qWaitForWindowActive(&view));
QCOMPARE(QApplication::activeWindow(), (QWidget*)&view);
@@ -1063,9 +1041,9 @@ void tst_QGraphicsProxyWidget::keyReleaseEvent()
proxy->setFocus();
QTest::keyPress(view.viewport(), Qt::Key_Space);
- QTRY_COMPARE(spy.count(), 0);
+ QTRY_COMPARE(spy.size(), 0);
QTest::keyRelease(view.viewport(), Qt::Key_Space);
- QTRY_COMPARE(spy.count(), hasWidget ? 1 : 0);
+ QTRY_COMPARE(spy.size(), hasWidget ? 1 : 0);
}
// protected void mouseDoubleClickEvent(QGraphicsSceneMouseEvent* event)
@@ -1089,11 +1067,10 @@ void tst_QGraphicsProxyWidget::mouseDoubleClickEvent()
view.resize(100, 100);
view.show();
- QApplication::setActiveWindow(&view);
QVERIFY(QTest::qWaitForWindowActive(&view));
QCOMPARE(QApplication::activeWindow(), (QWidget*)&view);
// wait for scene to be updated before doing any coordinate mappings on it
- QTRY_VERIFY(sceneChangedSpy.count() > 0);
+ QTRY_VERIFY(sceneChangedSpy.size() > 0);
QPoint pointInLineEdit = view.mapFromScene(proxy->mapToScene(15, proxy->boundingRect().center().y()));
QTest::mousePress(view.viewport(), Qt::LeftButton, {}, pointInLineEdit);
@@ -1134,13 +1111,13 @@ void tst_QGraphicsProxyWidget::mousePressReleaseEvent()
proxy->setFocus();
// wait for scene to be updated before doing any coordinate mappings on it
- QTRY_VERIFY(sceneChangedSpy.count() > 0);
+ QTRY_VERIFY(sceneChangedSpy.size() > 0);
QPoint buttonCenter = view.mapFromScene(proxy->mapToScene(proxy->boundingRect().center()));
QTest::mousePress(view.viewport(), Qt::LeftButton, {}, buttonCenter);
- QTRY_COMPARE(spy.count(), 0);
+ QTRY_COMPARE(spy.size(), 0);
QTest::mouseRelease(view.viewport(), Qt::LeftButton, {}, buttonCenter);
- QTRY_COMPARE(spy.count(), hasWidget ? 1 : 0);
+ QTRY_COMPARE(spy.size(), hasWidget ? 1 : 0);
}
void tst_QGraphicsProxyWidget::resizeEvent_data()
@@ -1175,7 +1152,6 @@ void tst_QGraphicsProxyWidget::paintEvent()
QGraphicsScene scene;
QGraphicsView view(&scene);
view.show();
- QApplication::setActiveWindow(&view);
QVERIFY(QTest::qWaitForWindowActive(&view));
QVERIFY(view.isActiveWindow());
@@ -1191,7 +1167,7 @@ void tst_QGraphicsProxyWidget::paintEvent()
QSignalSpy sceneChangedSpy(&scene, &QGraphicsScene::changed);
scene.addItem(&proxy);
- QTRY_VERIFY(sceneChangedSpy.count() > 0); // make sure the scene is ready
+ QTRY_VERIFY(sceneChangedSpy.size() > 0); // make sure the scene is ready
proxy.paintCount = 0;
w->update();
@@ -1346,6 +1322,9 @@ static QList<QRect> rects(const QRegion &region)
void tst_QGraphicsProxyWidget::scrollUpdate()
{
+ if (!QGuiApplicationPrivate::platformIntegration()->hasCapability(QPlatformIntegration::WindowActivation))
+ QSKIP("QWindow::requestActivate() is not supported.");
+
ScrollWidget *widget = new ScrollWidget;
QGraphicsScene scene;
@@ -1559,7 +1538,6 @@ void tst_QGraphicsProxyWidget::tabFocus_simpleWidget()
window.setLayout(layout);
window.show();
- QApplication::setActiveWindow(&window);
window.activateWindow();
QVERIFY(QTest::qWaitForWindowActive(&window));
@@ -1643,7 +1621,6 @@ void tst_QGraphicsProxyWidget::tabFocus_simpleTwoWidgets()
window.setLayout(layout);
window.show();
- QApplication::setActiveWindow(&window);
window.activateWindow();
QVERIFY(QTest::qWaitForWindowActive(&window));
@@ -1776,7 +1753,6 @@ void tst_QGraphicsProxyWidget::tabFocus_complexWidget()
window.setLayout(layout);
window.show();
- QApplication::setActiveWindow(&window);
window.activateWindow();
QVERIFY(QTest::qWaitForWindowActive(&window));
@@ -1913,7 +1889,6 @@ void tst_QGraphicsProxyWidget::tabFocus_complexTwoWidgets()
window.setLayout(layout);
window.show();
- QApplication::setActiveWindow(&window);
window.activateWindow();
QVERIFY(QTest::qWaitForWindowActive(&window));
@@ -2087,7 +2062,7 @@ void tst_QGraphicsProxyWidget::setFocus_simpleWidget()
window.setLayout(layout);
window.show();
- QApplication::setActiveWindow(&window);
+ QApplicationPrivate::setActiveWindow(&window);
window.activateWindow();
QVERIFY(QTest::qWaitForWindowActive(&window));
QCOMPARE(QApplication::activeWindow(), &window);
@@ -2159,7 +2134,7 @@ void tst_QGraphicsProxyWidget::setFocus_simpleTwoWidgets()
window.setLayout(layout);
window.show();
- QApplication::setActiveWindow(&window);
+ QApplicationPrivate::setActiveWindow(&window);
window.activateWindow();
QVERIFY(QTest::qWaitForWindowActive(&window));
QCOMPARE(QApplication::activeWindow(), &window);
@@ -2238,7 +2213,7 @@ void tst_QGraphicsProxyWidget::setFocus_complexTwoWidgets()
window.setLayout(layout);
window.show();
- QApplication::setActiveWindow(&window);
+ QApplicationPrivate::setActiveWindow(&window);
window.activateWindow();
QVERIFY(QTest::qWaitForWindowActive(&window));
QCOMPARE(QApplication::activeWindow(), &window);
@@ -2330,7 +2305,7 @@ void tst_QGraphicsProxyWidget::popup_basic()
box->setGeometry(0, 0, 320, 40);
box->addItems(QStringList() << "monday" << "tuesday" << "wednesday"
<< "thursday" << "saturday" << "sunday");
- QCOMPARE(proxy->childItems().count(), 0);
+ QCOMPARE(proxy->childItems().size(), 0);
proxy->setWidget(boxGuard.release());
proxy->show();
scene.addItem(proxy);
@@ -2347,7 +2322,7 @@ void tst_QGraphicsProxyWidget::popup_basic()
QTRY_COMPARE(box->pos(), QPoint());
- QCOMPARE(proxy->childItems().count(), 1);
+ QCOMPARE(proxy->childItems().size(), 1);
QGraphicsProxyWidget *child = (QGraphicsProxyWidget*)(proxy->childItems())[0];
QVERIFY(child->isWidget());
QVERIFY(child->widget());
@@ -2427,7 +2402,7 @@ void tst_QGraphicsProxyWidget::changingCursor_basic()
proxy->setWidget(widget);
QSignalSpy sceneChangedSpy(&scene, &QGraphicsScene::changed);
scene.addItem(proxy);
- QTRY_VERIFY(sceneChangedSpy.count() > 0); // make sure the scene is ready
+ QTRY_VERIFY(sceneChangedSpy.size() > 0); // make sure the scene is ready
// in
QTest::mouseMove(view.viewport(), view.mapFromScene(proxy->mapToScene(proxy->boundingRect().center())));
@@ -2483,7 +2458,7 @@ void tst_QGraphicsProxyWidget::tooltip_basic()
QGraphicsView view(&scene);
view.setFixedSize(200, 200);
view.show();
- QApplication::setActiveWindow(&view);
+ QApplicationPrivate::setActiveWindow(&view);
QVERIFY(QTest::qWaitForWindowActive(&view));
{
QHelpEvent helpEvent(QEvent::ToolTip, view.viewport()->rect().topLeft(),
@@ -2493,7 +2468,8 @@ void tst_QGraphicsProxyWidget::tooltip_basic()
bool foundView = false;
bool foundTipLabel = false;
- foreach (QWidget *widget, QApplication::topLevelWidgets()) {
+ const auto widgets = QApplication::topLevelWidgets();
+ for (QWidget *widget : widgets) {
if (widget == &view)
foundView = true;
if (widget->inherits("QTipLabel"))
@@ -2620,7 +2596,7 @@ void tst_QGraphicsProxyWidget::windowOpacity()
QGraphicsProxyWidget *proxy = scene.addWidget(widget);
proxy->setCacheMode(QGraphicsItem::ItemCoordinateCache);
- QApplication::setActiveWindow(&view);
+ QApplicationPrivate::setActiveWindow(&view);
view.show();
QVERIFY(QTest::qWaitForWindowActive(&view));
QVERIFY(view.isActiveWindow());
@@ -2645,7 +2621,7 @@ void tst_QGraphicsProxyWidget::windowOpacity()
QTRY_COMPARE(eventSpy.counts[QEvent::UpdateRequest], 0);
QTRY_COMPARE(eventSpy.counts[QEvent::Paint], paints);
- QTRY_COMPARE(signalSpy.count(), 1);
+ QTRY_COMPARE(signalSpy.size(), 1);
const QList<QVariant> arguments = signalSpy.takeFirst();
const QList<QRectF> updateRects = qvariant_cast<QList<QRectF> >(arguments.at(0));
QCOMPARE(updateRects.size(), 1);
@@ -2920,10 +2896,10 @@ void tst_QGraphicsProxyWidget::createProxyForChildWidget()
QTest::mousePress(view.viewport(), Qt::LeftButton, {},
view.mapFromScene(checkboxProxy->mapToScene(QPointF(8,8))));
- QTRY_COMPARE(spy.count(), 0);
+ QTRY_COMPARE(spy.size(), 0);
QTest::mouseRelease(view.viewport(), Qt::LeftButton, {},
view.mapFromScene(checkboxProxy->mapToScene(QPointF(8,8))));
- QTRY_COMPARE(spy.count(), 1);
+ QTRY_COMPARE(spy.size(), 1);
@@ -3018,7 +2994,7 @@ void tst_QGraphicsProxyWidget::actionsContextMenu()
view.resize(200, 200);
view.move(QGuiApplication::primaryScreen()->geometry().center() - QPoint(100, 100));
view.show();
- QApplication::setActiveWindow(&view);
+ QApplicationPrivate::setActiveWindow(&view);
QVERIFY(QTest::qWaitForWindowActive(&view));
view.setFocus();
QTRY_VERIFY(view.hasFocus());
@@ -3088,6 +3064,9 @@ void tst_QGraphicsProxyWidget::bypassGraphicsProxyWidget_data()
void tst_QGraphicsProxyWidget::bypassGraphicsProxyWidget()
{
+ if (!QGuiApplicationPrivate::platformIntegration()->hasCapability(QPlatformIntegration::WindowActivation))
+ QSKIP("QWindow::requestActivate() is not supported.");
+
QFETCH(bool, bypass);
std::unique_ptr<QWidget> widgetGuard(new QWidget);
@@ -3097,7 +3076,7 @@ void tst_QGraphicsProxyWidget::bypassGraphicsProxyWidget()
QGraphicsScene scene;
QGraphicsView view(&scene);
view.show();
- QApplication::setActiveWindow(&view);
+ QApplicationPrivate::setActiveWindow(&view);
QVERIFY(QTest::qWaitForWindowActive(&view));
QGraphicsProxyWidget *proxy = scene.addWidget(widgetGuard.release());
@@ -3301,6 +3280,9 @@ public:
void tst_QGraphicsProxyWidget::inputMethod()
{
+ if (!QGuiApplicationPrivate::platformIntegration()->hasCapability(QPlatformIntegration::WindowActivation))
+ QSKIP("QWindow::requestActivate() is not supported.");
+
QGraphicsScene scene;
// check that the proxy is initialized with the correct input method sensitivity
@@ -3360,7 +3342,6 @@ void tst_QGraphicsProxyWidget::clickFocus()
view.setFrameStyle(0);
view.resize(300, 300);
view.show();
- QApplication::setActiveWindow(&view);
QVERIFY(QTest::qWaitForWindowActive(&view));
QVERIFY(!proxy->hasFocus());
@@ -3504,7 +3485,6 @@ void tst_QGraphicsProxyWidget::QTBUG_6986_sendMouseEventToAlienWidget()
QGraphicsView view(&scene);
view.resize(600, 600);
- QApplication::setActiveWindow(&view);
view.show();
QVERIFY(QTest::qWaitForWindowActive(&view));
@@ -3548,7 +3528,6 @@ void tst_QGraphicsProxyWidget::mapToGlobal() // QTBUG-41135
childWidget->resize(embeddedWidget->size() / 2);
childWidget->move(embeddedWidget->width() / 4, embeddedWidget->height() / 4); // center in embeddedWidget
scene.addWidget(embeddedWidget);
- QApplication::setActiveWindow(&view);
view.show();
QVERIFY(QTest::qWaitForWindowExposed(&view));
const QPoint embeddedCenter = embeddedWidget->rect().center();
@@ -3556,8 +3535,9 @@ void tst_QGraphicsProxyWidget::mapToGlobal() // QTBUG-41135
QCOMPARE(embeddedWidget->mapFromGlobal(embeddedCenterGlobal), embeddedCenter);
// This should be equivalent to the view center give or take rounding
// errors due to odd window margins
+ const int Tolerance = qCeil(4 * view.devicePixelRatio());
const QPoint viewCenter = view.geometry().center();
- QVERIFY2((viewCenter - embeddedCenterGlobal).manhattanLength() <= 3,
+ QVERIFY2((viewCenter - embeddedCenterGlobal).manhattanLength() <= Tolerance,
msgPointMismatch(embeddedCenterGlobal, viewCenter).constData());
// Same test with child centered on embeddedWidget. Also make sure
@@ -3567,7 +3547,7 @@ void tst_QGraphicsProxyWidget::mapToGlobal() // QTBUG-41135
const QPoint childCenter = childWidget->rect().center();
const QPoint childCenterGlobal = childWidget->mapToGlobal(childCenter);
QCOMPARE(childWidget->mapFromGlobal(childCenterGlobal), childCenter);
- QVERIFY2((viewCenter - childCenterGlobal).manhattanLength() <= 4,
+ QVERIFY2((viewCenter - childCenterGlobal).manhattanLength() <= Tolerance,
msgPointMismatch(childCenterGlobal, viewCenter).constData());
}
@@ -3712,27 +3692,27 @@ void tst_QGraphicsProxyWidget::wheelEventPropagation()
// accepted by the embedded widget
QCOMPARE(view.itemAt(wheelPosition), nullptr);
wheelUp(Qt::NoScrollPhase);
- QCOMPARE(scrollSpy.count(), ++scrollCount);
+ QCOMPARE(scrollSpy.size(), ++scrollCount);
// wheeling on the label, which ignores the event, should scroll the view
QCOMPARE(view.itemAt(wheelPosition), labelProxy);
wheelUp(Qt::NoScrollPhase);
- QCOMPARE(scrollSpy.count(), ++scrollCount);
+ QCOMPARE(scrollSpy.size(), ++scrollCount);
QCOMPARE(view.itemAt(wheelPosition), labelProxy);
wheelUp(Qt::NoScrollPhase);
- QCOMPARE(scrollSpy.count(), ++scrollCount);
+ QCOMPARE(scrollSpy.size(), ++scrollCount);
// left the widget
QCOMPARE(view.itemAt(wheelPosition), nullptr);
wheelUp(Qt::NoScrollPhase);
- QCOMPARE(scrollSpy.count(), ++scrollCount);
+ QCOMPARE(scrollSpy.size(), ++scrollCount);
// reached the nested widget, which accepts the wheel event, so no more scrolling
QCOMPARE(view.itemAt(wheelPosition), nestedProxy);
// remember this position for later
const int scrollBarValueOnNestedProxy = view.verticalScrollBar()->value();
wheelUp(Qt::NoScrollPhase);
- QCOMPARE(scrollSpy.count(), scrollCount);
+ QCOMPARE(scrollSpy.size(), scrollCount);
QCOMPARE(nestedWidget->wheelEventCount, 1);
// reset, try with kinetic events
@@ -3743,41 +3723,41 @@ void tst_QGraphicsProxyWidget::wheelEventPropagation()
// no matter if the widget accepts wheel events - the view has the grab
QCOMPARE(view.itemAt(wheelPosition), nullptr);
wheelUp(Qt::ScrollBegin);
- QCOMPARE(scrollSpy.count(), ++scrollCount);
+ QCOMPARE(scrollSpy.size(), ++scrollCount);
for (int i = 0; i < 5; ++i) {
wheelUp(Qt::ScrollUpdate);
- QCOMPARE(scrollSpy.count(), ++scrollCount);
+ QCOMPARE(scrollSpy.size(), ++scrollCount);
}
wheelUp(Qt::ScrollEnd);
- QCOMPARE(scrollSpy.count(), ++scrollCount);
+ QCOMPARE(scrollSpy.size(), ++scrollCount);
// reset
view.verticalScrollBar()->setValue(0);
- scrollCount = scrollSpy.count();
+ scrollCount = scrollSpy.size();
// starting a scroll on a widget that doesn't accept wheel events
// should also scroll the view, which still gets the grab
wheelUp(Qt::NoScrollPhase);
- scrollCount = scrollSpy.count();
+ scrollCount = scrollSpy.size();
QCOMPARE(view.itemAt(wheelPosition), labelProxy);
wheelUp(Qt::ScrollBegin);
- QCOMPARE(scrollSpy.count(), ++scrollCount);
+ QCOMPARE(scrollSpy.size(), ++scrollCount);
for (int i = 0; i < 5; ++i) {
wheelUp(Qt::ScrollUpdate);
- QCOMPARE(scrollSpy.count(), ++scrollCount);
+ QCOMPARE(scrollSpy.size(), ++scrollCount);
}
wheelUp(Qt::ScrollEnd);
- QCOMPARE(scrollSpy.count(), ++scrollCount);
+ QCOMPARE(scrollSpy.size(), ++scrollCount);
// starting a scroll on a widget that does accept wheel events
// should not scroll the view
view.verticalScrollBar()->setValue(scrollBarValueOnNestedProxy);
- scrollCount = scrollSpy.count();
+ scrollCount = scrollSpy.size();
QCOMPARE(view.itemAt(wheelPosition), nestedProxy);
wheelUp(Qt::ScrollBegin);
- QCOMPARE(scrollSpy.count(), scrollCount);
+ QCOMPARE(scrollSpy.size(), scrollCount);
}
#endif // QT_CONFIG(wheelevent)
@@ -3875,7 +3855,7 @@ void tst_QGraphicsProxyWidget::touchEventPropagation()
QHash<int, QList<TouchRecord>> records;
QWidget *mousePressReceiver = nullptr;
- int count(int id = 0) const { return records.value(id).count(); }
+ int count(int id = 0) const { return records.value(id).size(); }
TouchRecord at(int i, int id = 0) const { return records.value(id).at(i); }
void clear()
{
@@ -3979,7 +3959,7 @@ void tst_QGraphicsProxyWidget::touchEventPropagation()
QCOMPARE(record.receiver, view.windowHandle());
QCOMPARE(record.eventType, QEvent::TouchEnd);
QCOMPARE(eventSpy.mousePressReceiver, pushButton1);
- QCOMPARE(clickedSpy.count(), 1);
+ QCOMPARE(clickedSpy.size(), 1);
eventSpy.clear();
clickedSpy.clear();
@@ -4047,7 +4027,7 @@ void tst_QGraphicsProxyWidget::touchEventPropagation()
QCOMPARE(eventSpy.at(0, 3).receiver, touchWidget2);
QCOMPARE(eventSpy.at(1, 3).receiver, touchWidget2);
QCOMPARE(eventSpy.at(2, 3).receiver, touchWidget2);
- QCOMPARE(clickedSpy.count(), 0); // multi-touch event does not synthesize a mouse event
+ QCOMPARE(clickedSpy.size(), 0); // multi-touch event does not synthesize a mouse event
}
QTEST_MAIN(tst_QGraphicsProxyWidget)
diff --git a/tests/auto/widgets/graphicsview/qgraphicsscene/BLACKLIST b/tests/auto/widgets/graphicsview/qgraphicsscene/BLACKLIST
deleted file mode 100644
index c3797c9d57..0000000000
--- a/tests/auto/widgets/graphicsview/qgraphicsscene/BLACKLIST
+++ /dev/null
@@ -1,5 +0,0 @@
-[isActive]
-opensuse-42.3 ci
-[tabFocus_sceneWithNestedFocusWidgets]
-opensuse-42.3
-
diff --git a/tests/auto/widgets/graphicsview/qgraphicsscene/CMakeLists.txt b/tests/auto/widgets/graphicsview/qgraphicsscene/CMakeLists.txt
index 3c870e473e..c0dd8995b8 100644
--- a/tests/auto/widgets/graphicsview/qgraphicsscene/CMakeLists.txt
+++ b/tests/auto/widgets/graphicsview/qgraphicsscene/CMakeLists.txt
@@ -1,35 +1,20 @@
-# Generated from qgraphicsscene.pro.
+# Copyright (C) 2022 The Qt Company Ltd.
+# SPDX-License-Identifier: BSD-3-Clause
#####################################################################
## tst_qgraphicsscene Test:
#####################################################################
-qt_internal_add_test(tst_qgraphicsscene
- LOWDPI # special case
- SOURCES
- tst_qgraphicsscene.cpp
- DEFINES
- QT_NO_CAST_TO_ASCII
- PUBLIC_LIBRARIES
- Qt::CorePrivate
- Qt::Gui
- Qt::GuiPrivate
- Qt::Widgets
- Qt::WidgetsPrivate
-)
+if(NOT QT_BUILD_STANDALONE_TESTS AND NOT QT_BUILDING_QT)
+ cmake_minimum_required(VERSION 3.16)
+ project(tst_qgraphicsscene LANGUAGES CXX)
+ find_package(Qt6BuildInternals REQUIRED COMPONENTS STANDALONE_TEST)
+endif()
# Resources:
-set(images_resource_files
- "Ash_European.jpg"
-)
-qt_internal_add_resource(tst_qgraphicsscene "images"
- PREFIX
- "/"
- FILES
- ${images_resource_files}
-)
set(testdata_resource_files
+ "Ash_European.jpg"
"testData/render/all-all-45-deg-left.png"
"testData/render/all-all-45-deg-right.png"
"testData/render/all-all-scale-2x.png"
@@ -60,18 +45,26 @@ set(testdata_resource_files
"testData/render/topright-topleft-untransformed.png"
)
-qt_internal_add_resource(tst_qgraphicsscene "testdata"
- PREFIX
- "/"
- FILES
- ${testdata_resource_files}
+qt_internal_add_test(tst_qgraphicsscene
+ LOWDPI
+ SOURCES
+ tst_qgraphicsscene.cpp
+ DEFINES
+ QT_NO_CAST_TO_ASCII
+ LIBRARIES
+ Qt::CorePrivate
+ Qt::Gui
+ Qt::GuiPrivate
+ Qt::Widgets
+ Qt::WidgetsPrivate
+ TESTDATA ${testdata_resource_files}
+ BUILTIN_TESTDATA
)
-
## Scopes:
#####################################################################
qt_internal_extend_target(tst_qgraphicsscene CONDITION WIN32
- PUBLIC_LIBRARIES
+ LIBRARIES
user32
)
diff --git a/tests/auto/widgets/graphicsview/qgraphicsscene/tst_qgraphicsscene.cpp b/tests/auto/widgets/graphicsview/qgraphicsscene/tst_qgraphicsscene.cpp
index b8991b5a9a..515ba80bbe 100644
--- a/tests/auto/widgets/graphicsview/qgraphicsscene/tst_qgraphicsscene.cpp
+++ b/tests/auto/widgets/graphicsview/qgraphicsscene/tst_qgraphicsscene.cpp
@@ -1,30 +1,5 @@
-/****************************************************************************
-**
-** Copyright (C) 2021 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) 2021 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only
#include <QtWidgets/QApplication>
#include <QtWidgets/QDial>
@@ -56,6 +31,8 @@
#include "../../../shared/platforminputcontext.h"
#include <private/qinputmethod_p.h>
+#include <QtWidgets/private/qapplication_p.h>
+
#if defined(Q_OS_WIN)
#include <QtCore/qt_windows.h>
#define Q_CHECK_PAINTEVENTS \
@@ -278,6 +255,7 @@ private slots:
void focusItemChangedSignal();
void minimumRenderSize();
void focusOnTouch();
+ void clearSelection();
// task specific tests below me
void task139710_bspTreeCrash();
@@ -294,6 +272,8 @@ private slots:
void taskQTBUG_42915_focusNextPrevChild();
void taskQTBUG_85088_previewTextfailWhenLostFocus();
+ void deleteItemsOnChange();
+
private:
QRect m_availableGeometry = QGuiApplication::primaryScreen()->availableGeometry();
QSize m_testSize;
@@ -341,27 +321,27 @@ void tst_QGraphicsScene::sceneRect()
QGraphicsScene scene;
QSignalSpy sceneRectChanged(&scene, &QGraphicsScene::sceneRectChanged);
QCOMPARE(scene.sceneRect(), QRectF());
- QCOMPARE(sceneRectChanged.count(), 0);
+ QCOMPARE(sceneRectChanged.size(), 0);
QGraphicsRectItem *item = scene.addRect(QRectF(0, 0, 10, 10));
item->setPen(QPen(Qt::black, 0));
item->setPos(-5, -5);
- QCOMPARE(sceneRectChanged.count(), 0);
+ QCOMPARE(sceneRectChanged.size(), 0);
QCOMPARE(itemAt(scene, 0, 0), item);
QVERIFY(scene.items(QPointF(10, 10)).isEmpty());
- QCOMPARE(sceneRectChanged.count(), 0);
+ QCOMPARE(sceneRectChanged.size(), 0);
QCOMPARE(scene.sceneRect(), QRectF(-5, -5, 10, 10));
- QCOMPARE(sceneRectChanged.count(), 1);
+ QCOMPARE(sceneRectChanged.size(), 1);
QCOMPARE(sceneRectChanged.last().at(0).toRectF(), scene.sceneRect());
item->setPos(0, 0);
QCOMPARE(scene.sceneRect(), QRectF(-5, -5, 15, 15));
- QCOMPARE(sceneRectChanged.count(), 2);
+ QCOMPARE(sceneRectChanged.size(), 2);
QCOMPARE(sceneRectChanged.last().at(0).toRectF(), scene.sceneRect());
scene.setSceneRect(-100, -100, 10, 10);
- QCOMPARE(sceneRectChanged.count(), 3);
+ QCOMPARE(sceneRectChanged.size(), 3);
QCOMPARE(sceneRectChanged.last().at(0).toRectF(), scene.sceneRect());
QCOMPARE(itemAt(scene, 0, 0), item);
@@ -369,16 +349,16 @@ void tst_QGraphicsScene::sceneRect()
QCOMPARE(scene.sceneRect(), QRectF(-100, -100, 10, 10));
item->setPos(10, 10);
QCOMPARE(scene.sceneRect(), QRectF(-100, -100, 10, 10));
- QCOMPARE(sceneRectChanged.count(), 3);
+ QCOMPARE(sceneRectChanged.size(), 3);
QCOMPARE(sceneRectChanged.last().at(0).toRectF(), scene.sceneRect());
scene.setSceneRect(QRectF());
QCOMPARE(itemAt(scene, 10, 10), item);
QVERIFY(scene.items(QPointF(20, 20)).isEmpty());
- QCOMPARE(sceneRectChanged.count(), 4);
+ QCOMPARE(sceneRectChanged.size(), 4);
QCOMPARE(scene.sceneRect(), QRectF(-5, -5, 25, 25));
- QCOMPARE(sceneRectChanged.count(), 5);
+ QCOMPARE(sceneRectChanged.size(), 5);
QCOMPARE(sceneRectChanged.last().at(0).toRectF(), scene.sceneRect());
}
@@ -554,7 +534,7 @@ void tst_QGraphicsScene::itemsBoundingRect()
QGraphicsScene scene;
- for (const auto &rect : qAsConst(rects)) {
+ for (const auto &rect : std::as_const(rects)) {
QPainterPath path;
path.addRect(rect);
QGraphicsPathItem *item = scene.addPath(path);
@@ -619,7 +599,7 @@ void tst_QGraphicsScene::items_QPointF()
int n = 0;
QList<QGraphicsItem *> addedItems;
- for (const auto &rect : qAsConst(items)) {
+ for (const auto &rect : std::as_const(items)) {
QPainterPath path;
path.addRect(0, 0, rect.width(), rect.height());
@@ -966,32 +946,32 @@ void tst_QGraphicsScene::selectionChanged()
{
QGraphicsScene scene(0, 0, 1000, 1000);
QSignalSpy spy(&scene, &QGraphicsScene::selectionChanged);
- QCOMPARE(spy.count(), 0);
+ QCOMPARE(spy.size(), 0);
QPainterPath path;
path.addRect(scene.sceneRect());
QCOMPARE(scene.selectionArea(), QPainterPath());
scene.setSelectionArea(path);
QCOMPARE(scene.selectionArea(), path);
- QCOMPARE(spy.count(), 0); // selection didn't change
+ QCOMPARE(spy.size(), 0); // selection didn't change
QVERIFY(scene.selectedItems().isEmpty());
QGraphicsItem *rect = scene.addRect(QRectF(0, 0, 100, 100));
- QCOMPARE(spy.count(), 0); // selection didn't change
+ QCOMPARE(spy.size(), 0); // selection didn't change
rect->setSelected(true);
QVERIFY(!rect->isSelected());
- QCOMPARE(spy.count(), 0); // selection didn't change, item isn't selectable
+ QCOMPARE(spy.size(), 0); // selection didn't change, item isn't selectable
rect->setFlag(QGraphicsItem::ItemIsSelectable);
rect->setSelected(true);
QVERIFY(rect->isSelected());
- QCOMPARE(spy.count(), 1); // selection changed
+ QCOMPARE(spy.size(), 1); // selection changed
QCOMPARE(scene.selectedItems(), {rect});
rect->setSelected(false);
QVERIFY(!rect->isSelected());
- QCOMPARE(spy.count(), 2); // selection changed
+ QCOMPARE(spy.size(), 2); // selection changed
QVERIFY(scene.selectedItems().isEmpty());
QGraphicsEllipseItem *parentItem = new QGraphicsEllipseItem(QRectF(0, 0, 100, 100));
@@ -1003,33 +983,33 @@ void tst_QGraphicsScene::selectionChanged()
grandChildItem->setSelected(true);
scene.addItem(parentItem);
- QCOMPARE(spy.count(), 3); // the grandchild was added, so the selection changed once
+ QCOMPARE(spy.size(), 3); // the grandchild was added, so the selection changed once
scene.removeItem(parentItem);
- QCOMPARE(spy.count(), 4); // the grandchild was removed, so the selection changed
+ QCOMPARE(spy.size(), 4); // the grandchild was removed, so the selection changed
rect->setSelected(true);
- QCOMPARE(spy.count(), 5); // the rect was reselected, so the selection changed
+ QCOMPARE(spy.size(), 5); // the rect was reselected, so the selection changed
scene.clearSelection();
- QCOMPARE(spy.count(), 6); // the scene selection was cleared
+ QCOMPARE(spy.size(), 6); // the scene selection was cleared
rect->setSelected(true);
- QCOMPARE(spy.count(), 7); // the rect was reselected, so the selection changed
+ QCOMPARE(spy.size(), 7); // the rect was reselected, so the selection changed
rect->setFlag(QGraphicsItem::ItemIsSelectable, false);
- QCOMPARE(spy.count(), 8); // the rect was unselected, so the selection changed
+ QCOMPARE(spy.size(), 8); // the rect was unselected, so the selection changed
rect->setSelected(true);
- QCOMPARE(spy.count(), 8); // the rect is not longer selectable, so the selection does not change
+ QCOMPARE(spy.size(), 8); // the rect is not longer selectable, so the selection does not change
rect->setFlag(QGraphicsItem::ItemIsSelectable, true);
rect->setSelected(true);
- QCOMPARE(spy.count(), 9); // the rect is again selectable, so the selection changed
+ QCOMPARE(spy.size(), 9); // the rect is again selectable, so the selection changed
delete rect;
- QCOMPARE(spy.count(), 10); // a selected item was deleted; selection changed
+ QCOMPARE(spy.size(), 10); // a selected item was deleted; selection changed
}
void tst_QGraphicsScene::selectionChanged2()
@@ -1042,7 +1022,7 @@ void tst_QGraphicsScene::selectionChanged2()
item1->setFlag(QGraphicsItem::ItemIsSelectable);
item2->setFlag(QGraphicsItem::ItemIsSelectable);
- QCOMPARE(spy.count(), 0);
+ QCOMPARE(spy.size(), 0);
{
QGraphicsSceneMouseEvent event(QEvent::GraphicsSceneMousePress);
event.setScenePos(QPointF(50, 50));
@@ -1057,7 +1037,7 @@ void tst_QGraphicsScene::selectionChanged2()
}
QVERIFY(item1->isSelected());
QVERIFY(!item2->isSelected());
- QCOMPARE(spy.count(), 1);
+ QCOMPARE(spy.size(), 1);
{
QGraphicsSceneMouseEvent event(QEvent::GraphicsSceneMousePress);
event.setScenePos(QPointF(150, 150));
@@ -1072,7 +1052,7 @@ void tst_QGraphicsScene::selectionChanged2()
}
QVERIFY(!item1->isSelected());
QVERIFY(item2->isSelected());
- QCOMPARE(spy.count(), 2);
+ QCOMPARE(spy.size(), 2);
{
QGraphicsSceneMouseEvent event(QEvent::GraphicsSceneMousePress);
event.setScenePos(QPointF(50, 50));
@@ -1082,7 +1062,7 @@ void tst_QGraphicsScene::selectionChanged2()
}
QVERIFY(!item1->isSelected());
QVERIFY(item2->isSelected());
- QCOMPARE(spy.count(), 2);
+ QCOMPARE(spy.size(), 2);
{
QGraphicsSceneMouseEvent event(QEvent::GraphicsSceneMouseRelease);
event.setScenePos(QPointF(50, 50));
@@ -1091,7 +1071,7 @@ void tst_QGraphicsScene::selectionChanged2()
}
QVERIFY(item1->isSelected());
QVERIFY(!item2->isSelected());
- QCOMPARE(spy.count(), 3);
+ QCOMPARE(spy.size(), 3);
}
void tst_QGraphicsScene::addItem()
@@ -1314,7 +1294,6 @@ void tst_QGraphicsScene::removeItem()
view.setWindowTitle(QTest::currentTestFunction());
view.setFixedSize(150, 150);
view.show();
- QApplication::setActiveWindow(&view);
QVERIFY(QTest::qWaitForWindowActive(&view));
QTest::mouseMove(view.windowHandle(), view.mapFromScene(hoverItem->scenePos() + QPointF(20, 20)));
QTRY_VERIFY(!hoverItem->isHovered);
@@ -1622,7 +1601,6 @@ void tst_QGraphicsScene::hoverEvents_siblings()
view.rotate(10);
view.scale(1.7, 1.7);
view.show();
- QApplication::setActiveWindow(&view);
view.activateWindow();
QVERIFY(QTest::qWaitForWindowActive(&view));
@@ -1692,7 +1670,6 @@ void tst_QGraphicsScene::hoverEvents_parentChild()
view.rotate(10);
view.scale(1.7, 1.7);
view.show();
- QApplication::setActiveWindow(&view);
QVERIFY(QTest::qWaitForWindowActive(&view));
QGraphicsSceneMouseEvent mouseEvent(QEvent::GraphicsSceneMouseMove);
@@ -1754,7 +1731,7 @@ void tst_QGraphicsScene::createItemGroup()
// All items in children1 are children of parent1
QGraphicsItem *parent1 = scene.addRect(QRectF(-10, -10, 20, 20));
- for (QGraphicsItem *item : qAsConst(children1))
+ for (QGraphicsItem *item : std::as_const(children1))
item->setParentItem(parent1);
QGraphicsItemGroup *group = scene.createItemGroup(children1);
@@ -1770,7 +1747,7 @@ void tst_QGraphicsScene::createItemGroup()
// All items in children2 are children of parent2
QGraphicsItem *parent2 = scene.addRect(QRectF(-10, -10, 20, 20));
- for (QGraphicsItem *item : qAsConst(children2))
+ for (QGraphicsItem *item : std::as_const(children2))
item->setParentItem(parent2);
// Now make parent2 a child of parent1, so all children2 are also children
@@ -1794,7 +1771,7 @@ void tst_QGraphicsScene::createItemGroup()
QCOMPARE(children2.first()->parentItem(), parent1);
// Fixup the parent-child chain
- for (QGraphicsItem *item : qAsConst(children2))
+ for (QGraphicsItem *item : std::as_const(children2))
item->setParentItem(parent2);
// These share no common parent
@@ -1804,7 +1781,7 @@ void tst_QGraphicsScene::createItemGroup()
// Make children3 children of parent3
QGraphicsItem *parent3 = scene.addRect(QRectF(-10, -10, 20, 20));
- for (QGraphicsItem *item : qAsConst(children3))
+ for (QGraphicsItem *item : std::as_const(children3))
item->setParentItem(parent3);
// These should have parent3 as a parent
@@ -2700,6 +2677,9 @@ void tst_QGraphicsScene::renderItemsWithNegativeWidthOrHeight()
#ifdef Q_OS_ANDROID
QSKIP("Test only works on platforms with resizable windows");
#endif
+ if (QGuiApplication::platformName().startsWith(QLatin1String("eglfs"), Qt::CaseInsensitive))
+ QSKIP("EGLFS does not allow resizing on top window");
+
QGraphicsScene scene(0, 0, m_testSize.width(), m_testSize.height());
// Add item with negative width.
@@ -2854,7 +2834,7 @@ void tst_QGraphicsScene::update()
QCoreApplication::processEvents();
// Check that the update region is correct
- QCOMPARE(spy.count(), 1);
+ QCOMPARE(spy.size(), 1);
QRectF region;
const auto &rects = qvariant_cast<QList<QRectF> >(spy.at(0).at(0));
for (const auto &rectF : rects)
@@ -2871,7 +2851,6 @@ void tst_QGraphicsScene::update2()
view.resize(m_testSize);
view.setScene(&scene);
view.show();
- QApplication::setActiveWindow(&view);
QVERIFY(QTest::qWaitForWindowActive(&view));
QTRY_VERIFY(view.repaints >= 1);
view.repaints = 0;
@@ -3061,7 +3040,6 @@ void tst_QGraphicsScene::tabFocus_emptyScene()
widget.setLayout(layout);
widget.setWindowTitle(QTest::currentTestFunction());
widget.show();
- QApplication::setActiveWindow(&widget);
widget.activateWindow();
QVERIFY(QTest::qWaitForWindowActive(&widget));
@@ -3113,7 +3091,6 @@ void tst_QGraphicsScene::tabFocus_sceneWithFocusableItems()
widget.setWindowTitle(QTest::currentTestFunction());
widget.setLayout(layout);
widget.show();
- QApplication::setActiveWindow(&widget);
widget.activateWindow();
QVERIFY(QTest::qWaitForWindowActive(&widget));
@@ -3167,7 +3144,7 @@ void tst_QGraphicsScene::tabFocus_sceneWithFocusableItems()
// Check that the correct item regains focus.
widget.show();
- QApplication::setActiveWindow(&widget);
+ QApplicationPrivate::setActiveWindow(&widget);
widget.activateWindow();
QVERIFY(QTest::qWaitForWindowActive(&widget));
QVERIFY(view->hasFocus());
@@ -3251,7 +3228,7 @@ void tst_QGraphicsScene::tabFocus_sceneWithFocusWidgets()
widget.setWindowTitle(QTest::currentTestFunction());
widget.setLayout(layout);
widget.show();
- QApplication::setActiveWindow(&widget);
+ QApplicationPrivate::setActiveWindow(&widget);
widget.activateWindow();
QVERIFY(QTest::qWaitForWindowActive(&widget));
@@ -3290,7 +3267,7 @@ void tst_QGraphicsScene::tabFocus_sceneWithFocusWidgets()
widget.hide();
QTest::qWait(15);
widget.show();
- QApplication::setActiveWindow(&widget);
+ QApplicationPrivate::setActiveWindow(&widget);
widget.activateWindow();
QVERIFY(QTest::qWaitForWindowActive(&widget));
QTRY_VERIFY(widget1->hasFocus());
@@ -3339,7 +3316,7 @@ void tst_QGraphicsScene::tabFocus_sceneWithNestedFocusWidgets()
widget.setWindowTitle(QTest::currentTestFunction());
widget.setLayout(layout);
widget.show();
- QApplication::setActiveWindow(&widget);
+ QApplicationPrivate::setActiveWindow(&widget);
widget.activateWindow();
QVERIFY(QTest::qWaitForWindowActive(&widget));
@@ -3424,7 +3401,7 @@ void tst_QGraphicsScene::tabFocus_sceneWithNestedFocusWidgets()
widget.hide();
QTest::qWait(12);
widget.show();
- QApplication::setActiveWindow(&widget);
+ QApplicationPrivate::setActiveWindow(&widget);
widget.activateWindow();
QVERIFY(QTest::qWaitForWindowActive(&widget));
QTRY_VERIFY(widget1->hasFocus());
@@ -3553,7 +3530,7 @@ void tst_QGraphicsScene::task160653_selectionChanged()
QVERIFY(QTest::qWaitForWindowActive(&view));
QTest::mouseClick(
view.viewport(), Qt::LeftButton, {}, view.mapFromScene(scene.items().first()->scenePos()));
- QCOMPARE(spy.count(), 1);
+ QCOMPARE(spy.size(), 1);
}
void tst_QGraphicsScene::task250680_childClip()
@@ -3684,8 +3661,8 @@ void tst_QGraphicsScene::insertionOrder()
{
QList<QGraphicsItem*> itemList = scene.items();
- QCOMPARE(itemList.count(), numItems);
- for (int i = 0; i < itemList.count(); ++i) {
+ QCOMPARE(itemList.size(), numItems);
+ for (int i = 0; i < itemList.size(); ++i) {
QCOMPARE(numItems-1-i, itemList.at(i)->data(0).toInt());
}
}
@@ -3698,8 +3675,8 @@ void tst_QGraphicsScene::insertionOrder()
{
QList<QGraphicsItem*> itemList = scene.items();
- QCOMPARE(itemList.count(), numItems);
- for (int i = 0; i < itemList.count(); ++i) {
+ QCOMPARE(itemList.size(), numItems);
+ for (int i = 0; i < itemList.size(); ++i) {
QCOMPARE(numItems-1-i, itemList.at(i)->data(0).toInt());
}
}
@@ -3842,7 +3819,6 @@ void tst_QGraphicsScene::inputMethod()
view.resize(m_testSize);
view.show();
view.setWindowTitle(QTest::currentTestFunction());
- QApplication::setActiveWindow(&view);
view.setFocus();
QVERIFY(QTest::qWaitForWindowActive(&view));
QCOMPARE(QApplication::activeWindow(), &view);
@@ -4047,7 +4023,7 @@ void tst_QGraphicsScene::polishItems2()
// added 10 new children. These should be polished in the next
// event loop iteration.
const QList<QGraphicsItem *> children = item->childItems();
- QCOMPARE(children.count(), 10);
+ QCOMPARE(children.size(), 10);
for (QGraphicsItem *child : children)
QVERIFY(!static_cast<PolishItem *>(child)->polished);
@@ -4086,7 +4062,6 @@ void tst_QGraphicsScene::isActive()
view1->setVisible(false);
toplevel1.show();
- QApplication::setActiveWindow(&toplevel1);
QVERIFY(QTest::qWaitForWindowActive(&toplevel1));
QCOMPARE(QApplication::activeWindow(), &toplevel1);
@@ -4115,7 +4090,7 @@ void tst_QGraphicsScene::isActive()
QVERIFY(!scene2.hasFocus());
toplevel1.show();
- QApplication::setActiveWindow(&toplevel1);
+ QApplicationPrivate::setActiveWindow(&toplevel1);
QVERIFY(QTest::qWaitForWindowActive(&toplevel1));
QCOMPARE(QApplication::activeWindow(), &toplevel1);
@@ -4155,7 +4130,7 @@ void tst_QGraphicsScene::isActive()
toplevel2.move(m_availableGeometry.topLeft() + QPoint(50, 50));
toplevel2.show();
- QApplication::setActiveWindow(&toplevel2);
+ QApplicationPrivate::setActiveWindow(&toplevel2);
QVERIFY(QTest::qWaitForWindowActive(&toplevel2));
QCOMPARE(QApplication::activeWindow(), &toplevel2);
@@ -4205,7 +4180,7 @@ void tst_QGraphicsScene::isActive()
topLevelView.move(toplevel2.geometry().topRight() + QPoint(100, 50));
topLevelView.resize(m_testSize);
topLevelView.show();
- QApplication::setActiveWindow(&topLevelView);
+ QApplicationPrivate::setActiveWindow(&topLevelView);
topLevelView.setFocus();
QVERIFY(QTest::qWaitForWindowActive(&topLevelView));
QCOMPARE(QApplication::activeWindow(), &topLevelView);
@@ -4233,7 +4208,7 @@ void tst_QGraphicsScene::isActive()
QVERIFY(scene1.hasFocus());
QVERIFY(!scene2.hasFocus());
- QApplication::setActiveWindow(&toplevel2);
+ QApplicationPrivate::setActiveWindow(&toplevel2);
QVERIFY(QTest::qWaitForWindowActive(&toplevel2));
QVERIFY(!scene1.isActive());
@@ -4263,7 +4238,6 @@ void tst_QGraphicsScene::isActive()
toplevel3.show();
- QApplication::setActiveWindow(&toplevel3);
QVERIFY(QTest::qWaitForWindowActive(&toplevel3));
QCOMPARE(QApplication::activeWindow(), &toplevel3);
@@ -4376,7 +4350,6 @@ void tst_QGraphicsScene::removeFullyTransparentItem()
view.resize(m_testSize);
view.setScene(&scene);
view.show();
- QApplication::setActiveWindow(&view);
QVERIFY(QTest::qWaitForWindowActive(&view));
QCoreApplication::processEvents(); // Process all queued paint events
@@ -4626,13 +4599,13 @@ void tst_QGraphicsScene::zeroScale()
rect1->setScale(0.00000001);
QApplication::processEvents();
- QTRY_COMPARE(cl.changes.count(), 1);
+ QTRY_COMPARE(cl.changes.size(), 1);
QGraphicsRectItem *rect2 = new QGraphicsRectItem(-0.0000001, -0.0000001, 0.0000001, 0.0000001);
rect2->setScale(0.00000001);
scene.addItem(rect2);
rect1->setPos(20,20);
QApplication::processEvents();
- QTRY_COMPARE(cl.changes.count(), 2);
+ QTRY_COMPARE(cl.changes.size(), 2);
}
void tst_QGraphicsScene::focusItemChangedSignal()
@@ -4643,17 +4616,17 @@ void tst_QGraphicsScene::focusItemChangedSignal()
QGraphicsScene scene;
QSignalSpy spy(&scene, &QGraphicsScene::focusItemChanged);
QVERIFY(spy.isValid());
- QCOMPARE(spy.count(), 0);
+ QCOMPARE(spy.size(), 0);
scene.setFocus();
- QCOMPARE(spy.count(), 0);
+ QCOMPARE(spy.size(), 0);
QEvent activateEvent(QEvent::WindowActivate);
QCoreApplication::sendEvent(&scene, &activateEvent);
- QCOMPARE(spy.count(), 0);
+ QCOMPARE(spy.size(), 0);
QGraphicsRectItem *topLevelItem1 = new QGraphicsRectItem;
topLevelItem1->setFlag(QGraphicsItem::ItemIsFocusable);
scene.addItem(topLevelItem1);
- QCOMPARE(spy.count(), 0);
+ QCOMPARE(spy.size(), 0);
QVERIFY(!topLevelItem1->hasFocus());
QGraphicsRectItem *topLevelItem2 = new QGraphicsRectItem;
@@ -4661,7 +4634,7 @@ void tst_QGraphicsScene::focusItemChangedSignal()
topLevelItem2->setFocus();
QVERIFY(!topLevelItem2->hasFocus());
scene.addItem(topLevelItem2);
- QCOMPARE(spy.count(), 1);
+ QCOMPARE(spy.size(), 1);
QList<QVariant> arguments = spy.takeFirst();
QCOMPARE(arguments.size(), 3);
QCOMPARE(qvariant_cast<QGraphicsItem *>(arguments.at(0)), topLevelItem2);
@@ -4670,7 +4643,7 @@ void tst_QGraphicsScene::focusItemChangedSignal()
QVERIFY(topLevelItem2->hasFocus());
scene.clearFocus();
- QCOMPARE(spy.count(), 1);
+ QCOMPARE(spy.size(), 1);
arguments = spy.takeFirst();
QCOMPARE(arguments.size(), 3);
QCOMPARE(qvariant_cast<QGraphicsItem *>(arguments.at(0)), nullptr);
@@ -4678,7 +4651,7 @@ void tst_QGraphicsScene::focusItemChangedSignal()
QCOMPARE(qvariant_cast<Qt::FocusReason>(arguments.at(2)), Qt::OtherFocusReason);
scene.setFocus(Qt::MenuBarFocusReason);
- QCOMPARE(spy.count(), 1);
+ QCOMPARE(spy.size(), 1);
arguments = spy.takeFirst();
QCOMPARE(arguments.size(), 3);
QCOMPARE(qvariant_cast<QGraphicsItem *>(arguments.at(0)), topLevelItem2);
@@ -4707,16 +4680,16 @@ void tst_QGraphicsScene::focusItemChangedSignal()
QEvent deactivateEvent(QEvent::WindowDeactivate);
QCoreApplication::sendEvent(&scene, &deactivateEvent);
QEXPECT_FAIL("", "QTBUG-28346", Continue);
- QCOMPARE(spy.count(), 1);
+ QCOMPARE(spy.size(), 1);
QCoreApplication::sendEvent(&scene, &activateEvent);
QEXPECT_FAIL("", "QTBUG-28346", Continue);
- QCOMPARE(spy.count(), 1);
+ QCOMPARE(spy.size(), 1);
QGraphicsRectItem *panel1 = new QGraphicsRectItem;
panel1->setFlags(QGraphicsItem::ItemIsPanel | QGraphicsItem::ItemIsFocusable);
panel1->setFocus();
scene.addItem(panel1);
- QCOMPARE(spy.count(), 1);
+ QCOMPARE(spy.size(), 1);
arguments = spy.takeFirst();
QCOMPARE(arguments.size(), 3);
QCOMPARE(qvariant_cast<QGraphicsItem *>(arguments.at(0)), panel1);
@@ -4726,11 +4699,11 @@ void tst_QGraphicsScene::focusItemChangedSignal()
QGraphicsRectItem *panel2 = new QGraphicsRectItem;
panel2->setFlags(QGraphicsItem::ItemIsPanel | QGraphicsItem::ItemIsFocusable);
scene.addItem(panel2);
- QCOMPARE(spy.count(), 0);
+ QCOMPARE(spy.size(), 0);
for (int i = 0; i < 3; ++i) {
scene.setActivePanel(panel2);
- QCOMPARE(spy.count(), 1);
+ QCOMPARE(spy.size(), 1);
arguments = spy.takeFirst();
QCOMPARE(arguments.size(), 3);
QCOMPARE(qvariant_cast<QGraphicsItem *>(arguments.at(0)), panel2);
@@ -4738,7 +4711,7 @@ void tst_QGraphicsScene::focusItemChangedSignal()
QCOMPARE(qvariant_cast<Qt::FocusReason>(arguments.at(2)), Qt::ActiveWindowFocusReason);
scene.setActivePanel(panel1);
- QCOMPARE(spy.count(), 1);
+ QCOMPARE(spy.size(), 1);
arguments = spy.takeFirst();
QCOMPARE(arguments.size(), 3);
QCOMPARE(qvariant_cast<QGraphicsItem *>(arguments.at(0)), panel1);
@@ -4834,7 +4807,6 @@ void tst_QGraphicsScene::focusOnTouch()
rect->setFlag(QGraphicsItem::ItemIsFocusable, true);
view.show();
- QApplication::setActiveWindow(&view);
QVERIFY(QTest::qWaitForWindowActive(&view));
QVERIFY(!rect->hasFocus());
@@ -4857,6 +4829,53 @@ void tst_QGraphicsScene::focusOnTouch()
QVERIFY(rect->hasFocus());
}
+void tst_QGraphicsScene::clearSelection()
+{
+ class AlwaysSelectedItem : public QGraphicsRectItem
+ {
+ public:
+ using QGraphicsRectItem::QGraphicsRectItem;
+ protected:
+ QVariant itemChange(GraphicsItemChange change, const QVariant& value) override
+ {
+ if (change == ItemSelectedChange)
+ return true;
+ return QGraphicsRectItem::itemChange(change, value);
+ }
+ };
+ QGraphicsScene scene;
+ QSignalSpy spy(&scene, &QGraphicsScene::selectionChanged);
+
+ QGraphicsRectItem *regularRect = new QGraphicsRectItem;
+ regularRect->setFlag(QGraphicsItem::ItemIsSelectable);
+ regularRect->setRect(0, 0, 50, 50);
+ regularRect->setSelected(true);
+ AlwaysSelectedItem *selectedRect = new AlwaysSelectedItem;
+ selectedRect->setFlag(QGraphicsItem::ItemIsSelectable);
+ selectedRect->setRect(50, 50, 50, 50);
+ selectedRect->setSelected(true);
+ scene.addItem(regularRect);
+ scene.addItem(selectedRect);
+
+ QCOMPARE(spy.size(), 2);
+
+ QCOMPARE(scene.selectedItems().size(), 2);
+ scene.clearSelection();
+ QVERIFY(!regularRect->isSelected());
+ QVERIFY(selectedRect->isSelected());
+ QCOMPARE(scene.selectedItems().size(), 1);
+ QCOMPARE(spy.size(), 3);
+
+ delete regularRect;
+ QCOMPARE(spy.size(), 3);
+
+ scene.clearSelection();
+ QCOMPARE(spy.size(), 3);
+
+ delete selectedRect;
+ QCOMPARE(spy.size(), 4);
+}
+
void tst_QGraphicsScene::taskQTBUG_15977_renderWithDeviceCoordinateCache()
{
QGraphicsScene scene;
@@ -4888,7 +4907,6 @@ void tst_QGraphicsScene::taskQTBUG_16401_focusItem()
rect->setFlag(QGraphicsItem::ItemIsFocusable);
view.show();
- QApplication::setActiveWindow(&view);
QVERIFY(QTest::qWaitForWindowActive(&view));
QVERIFY(!scene.focusItem());
@@ -4930,7 +4948,6 @@ void tst_QGraphicsScene::taskQTBUG_42915_focusNextPrevChild()
widget2->setFocusPolicy(Qt::NoFocus);
view.show();
- QApplication::setActiveWindow(&view);
QVERIFY(QTest::qWaitForWindowActive(&view));
QTest::keyEvent(QTest::Click, &view, Qt::Key_Tab);
@@ -4960,6 +4977,7 @@ void tst_QGraphicsScene::taskQTBUG_85088_previewTextfailWhenLostFocus()
// focusItem will lose focus
QMouseEvent pressEvent(QEvent::MouseButtonPress, QPointF(0, 0),
+ view.viewport()->mapToGlobal(QPointF()),
Qt::LeftButton, Qt::NoButton, Qt::NoModifier);
QApplication::sendEvent(view.viewport(), &pressEvent);
@@ -4969,5 +4987,72 @@ void tst_QGraphicsScene::taskQTBUG_85088_previewTextfailWhenLostFocus()
QCOMPARE(simpleTextItem->toPlainText(), str + str);
}
+void tst_QGraphicsScene::deleteItemsOnChange()
+{
+ QGraphicsScene scene;
+
+ class SelectionItem : public QGraphicsRectItem {
+ public:
+ QRectF boundingRect() const override { return QRectF(); }
+ };
+
+ class ChangeItem : public QGraphicsItem
+ {
+ public:
+ ChangeItem()
+ {
+ setFlag(QGraphicsItem::ItemIsSelectable, true);
+ setFlag(QGraphicsItem::ItemIsMovable, true);
+ }
+ QRectF boundingRect() const override
+ {
+ return QRectF(0,0,100,100);
+ }
+
+ protected:
+ void paint(QPainter *painter, const QStyleOptionGraphicsItem *, QWidget *) override
+ {
+ painter->fillRect(boundingRect().toRect(), isSelected() ? Qt::yellow : Qt::cyan);
+ }
+
+ QVariant itemChange(GraphicsItemChange change, const QVariant &value) override
+ {
+ if (change != QGraphicsItem::ItemSelectedHasChanged)
+ return QGraphicsItem::itemChange(change, value);
+ if (value.toBool()) {
+ selectionRect = new SelectionItem;
+ scene()->addItem(selectionRect);
+ } else {
+ // this recreates the selectedItems QSet inside of QGraphicsScene,
+ // invalidating iterators. See QTBUG-101651.
+ scene()->selectedItems();
+ delete selectionRect;
+ selectionRect = nullptr;
+ }
+ return QGraphicsItem::itemChange(change, value);
+ }
+ private:
+ SelectionItem *selectionRect = nullptr;
+ };
+
+ ChangeItem item1;
+ item1.setPos(0, 0);
+ ChangeItem item2;
+ item1.setPos(50, 50);
+
+ scene.addItem(&item1);
+ scene.addItem(&item2);
+
+ QGraphicsView view;
+ view.setScene(&scene);
+ view.show();
+
+ QVERIFY(QTest::qWaitForWindowExposed(&view));
+
+ // this should not crash - see QTBUG-101651
+ QTest::mouseClick(view.viewport(), Qt::LeftButton, {}, QPoint(120, 120));
+ QTest::mouseClick(view.viewport(), Qt::LeftButton, {}, QPoint(25, 25));
+}
+
QTEST_MAIN(tst_QGraphicsScene)
#include "tst_qgraphicsscene.moc"
diff --git a/tests/auto/widgets/graphicsview/qgraphicssceneindex/CMakeLists.txt b/tests/auto/widgets/graphicsview/qgraphicssceneindex/CMakeLists.txt
index f95e618a16..867831d898 100644
--- a/tests/auto/widgets/graphicsview/qgraphicssceneindex/CMakeLists.txt
+++ b/tests/auto/widgets/graphicsview/qgraphicssceneindex/CMakeLists.txt
@@ -1,4 +1,11 @@
-# Generated from qgraphicssceneindex.pro.
+# Copyright (C) 2022 The Qt Company Ltd.
+# SPDX-License-Identifier: BSD-3-Clause
+
+if(NOT QT_BUILD_STANDALONE_TESTS AND NOT QT_BUILDING_QT)
+ cmake_minimum_required(VERSION 3.16)
+ project(tst_qgraphicssceneindex LANGUAGES CXX)
+ find_package(Qt6BuildInternals REQUIRED COMPONENTS STANDALONE_TEST)
+endif()
if(NOT QT_FEATURE_private_tests)
return()
@@ -11,13 +18,10 @@ endif()
qt_internal_add_test(tst_qgraphicssceneindex
SOURCES
tst_qgraphicssceneindex.cpp
- PUBLIC_LIBRARIES
+ LIBRARIES
Qt::CorePrivate
Qt::Gui
Qt::GuiPrivate
Qt::Widgets
Qt::WidgetsPrivate
)
-
-#### Keys ignored in scope 1:.:.:qgraphicssceneindex.pro:<TRUE>:
-# _REQUIREMENTS = "qtConfig(private_tests)"
diff --git a/tests/auto/widgets/graphicsview/qgraphicssceneindex/tst_qgraphicssceneindex.cpp b/tests/auto/widgets/graphicsview/qgraphicssceneindex/tst_qgraphicssceneindex.cpp
index 9645b9a7fb..b6d48b52d5 100644
--- a/tests/auto/widgets/graphicsview/qgraphicssceneindex/tst_qgraphicssceneindex.cpp
+++ b/tests/auto/widgets/graphicsview/qgraphicssceneindex/tst_qgraphicssceneindex.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 <QTest>
@@ -33,6 +8,7 @@
#include <private/qgraphicsscenebsptreeindex_p.h>
#include <private/qgraphicssceneindex_p.h>
#include <private/qgraphicsscenelinearindex_p.h>
+#include <QtWidgets/private/qapplication_p.h>
class tst_QGraphicsSceneIndex : public QObject
{
@@ -99,13 +75,13 @@ void tst_QGraphicsSceneIndex::scatteredItems()
for (int i = 0; i < 10; ++i)
scene.addRect(i*50, i*50, 40, 35);
- QCOMPARE(scene.items(QPointF(5, 5)).count(), 1);
- QCOMPARE(scene.items(QPointF(55, 55)).count(), 1);
- QCOMPARE(scene.items(QPointF(-100, -100)).count(), 0);
+ QCOMPARE(scene.items(QPointF(5, 5)).size(), 1);
+ QCOMPARE(scene.items(QPointF(55, 55)).size(), 1);
+ QCOMPARE(scene.items(QPointF(-100, -100)).size(), 0);
- QCOMPARE(scene.items(QRectF(0, 0, 10, 10)).count(), 1);
- QCOMPARE(scene.items(QRectF(0, 0, 1000, 1000)).count(), 10);
- QCOMPARE(scene.items(QRectF(-100, -1000, 0, 0)).count(), 0);
+ QCOMPARE(scene.items(QRectF(0, 0, 10, 10)).size(), 1);
+ QCOMPARE(scene.items(QRectF(0, 0, 1000, 1000)).size(), 10);
+ QCOMPARE(scene.items(QRectF(-100, -1000, 0, 0)).size(), 0);
}
void tst_QGraphicsSceneIndex::overlappedItems_data()
@@ -124,17 +100,17 @@ void tst_QGraphicsSceneIndex::overlappedItems()
for (int j = 0; j < 10; ++j)
scene.addRect(i*50, j*50, 200, 200)->setPen(QPen(Qt::black, 0));
- QCOMPARE(scene.items(QPointF(5, 5)).count(), 1);
- QCOMPARE(scene.items(QPointF(55, 55)).count(), 4);
- QCOMPARE(scene.items(QPointF(105, 105)).count(), 9);
- QCOMPARE(scene.items(QPointF(-100, -100)).count(), 0);
-
- QCOMPARE(scene.items(QRectF(0, 0, 1000, 1000)).count(), 100);
- QCOMPARE(scene.items(QRectF(-100, -1000, 0, 0)).count(), 0);
- QCOMPARE(scene.items(QRectF(0, 0, 200, 200)).count(), 16);
- QCOMPARE(scene.items(QRectF(0, 0, 100, 100)).count(), 4);
- QCOMPARE(scene.items(QRectF(0, 0, 1, 100)).count(), 2);
- QCOMPARE(scene.items(QRectF(0, 0, 1, 1000)).count(), 10);
+ QCOMPARE(scene.items(QPointF(5, 5)).size(), 1);
+ QCOMPARE(scene.items(QPointF(55, 55)).size(), 4);
+ QCOMPARE(scene.items(QPointF(105, 105)).size(), 9);
+ QCOMPARE(scene.items(QPointF(-100, -100)).size(), 0);
+
+ QCOMPARE(scene.items(QRectF(0, 0, 1000, 1000)).size(), 100);
+ QCOMPARE(scene.items(QRectF(-100, -1000, 0, 0)).size(), 0);
+ QCOMPARE(scene.items(QRectF(0, 0, 200, 200)).size(), 16);
+ QCOMPARE(scene.items(QRectF(0, 0, 100, 100)).size(), 4);
+ QCOMPARE(scene.items(QRectF(0, 0, 1, 100)).size(), 2);
+ QCOMPARE(scene.items(QRectF(0, 0, 1, 1000)).size(), 10);
}
void tst_QGraphicsSceneIndex::movingItems_data()
@@ -153,20 +129,20 @@ void tst_QGraphicsSceneIndex::movingItems()
scene.addRect(i*50, i*50, 40, 35);
QGraphicsRectItem *box = scene.addRect(0, 0, 10, 10);
- QCOMPARE(scene.items(QPointF(5, 5)).count(), 2);
- QCOMPARE(scene.items(QPointF(-1, -1)).count(), 0);
- QCOMPARE(scene.items(QRectF(0, 0, 5, 5)).count(), 2);
+ QCOMPARE(scene.items(QPointF(5, 5)).size(), 2);
+ QCOMPARE(scene.items(QPointF(-1, -1)).size(), 0);
+ QCOMPARE(scene.items(QRectF(0, 0, 5, 5)).size(), 2);
box->setPos(10, 10);
- QCOMPARE(scene.items(QPointF(9, 9)).count(), 1);
- QCOMPARE(scene.items(QPointF(15, 15)).count(), 2);
- QCOMPARE(scene.items(QRectF(0, 0, 1, 1)).count(), 1);
+ QCOMPARE(scene.items(QPointF(9, 9)).size(), 1);
+ QCOMPARE(scene.items(QPointF(15, 15)).size(), 2);
+ QCOMPARE(scene.items(QRectF(0, 0, 1, 1)).size(), 1);
box->setPos(-5, -5);
- QCOMPARE(scene.items(QPointF(-1, -1)).count(), 1);
- QCOMPARE(scene.items(QRectF(0, 0, 1, 1)).count(), 2);
+ QCOMPARE(scene.items(QPointF(-1, -1)).size(), 1);
+ QCOMPARE(scene.items(QRectF(0, 0, 1, 1)).size(), 2);
- QCOMPARE(scene.items(QRectF(0, 0, 1000, 1000)).count(), 11);
+ QCOMPARE(scene.items(QRectF(0, 0, 1000, 1000)).size(), 11);
}
void tst_QGraphicsSceneIndex::connectedToSceneRectChanged()
@@ -315,7 +291,6 @@ void tst_QGraphicsSceneIndex::removeItems()
QGraphicsView view(&scene);
view.resize(600, 600);
view.show();
- QApplication::setActiveWindow(&view);
QVERIFY(QTest::qWaitForWindowActive(&view));
scene.removeItem(widgetChild1);
@@ -347,7 +322,6 @@ void tst_QGraphicsSceneIndex::clear()
QGraphicsView view(&scene);
view.show();
- qApp->setActiveWindow(&view);
QVERIFY(QTest::qWaitForWindowActive(&view));
scene.clear();
diff --git a/tests/auto/widgets/graphicsview/qgraphicstransform/CMakeLists.txt b/tests/auto/widgets/graphicsview/qgraphicstransform/CMakeLists.txt
index 12ba7dd834..a11036b30f 100644
--- a/tests/auto/widgets/graphicsview/qgraphicstransform/CMakeLists.txt
+++ b/tests/auto/widgets/graphicsview/qgraphicstransform/CMakeLists.txt
@@ -1,13 +1,20 @@
-# Generated from qgraphicstransform.pro.
+# Copyright (C) 2022 The Qt Company Ltd.
+# SPDX-License-Identifier: BSD-3-Clause
#####################################################################
## tst_qgraphicstransform Test:
#####################################################################
+if(NOT QT_BUILD_STANDALONE_TESTS AND NOT QT_BUILDING_QT)
+ cmake_minimum_required(VERSION 3.16)
+ project(tst_qgraphicstransform LANGUAGES CXX)
+ find_package(Qt6BuildInternals REQUIRED COMPONENTS STANDALONE_TEST)
+endif()
+
qt_internal_add_test(tst_qgraphicstransform
SOURCES
tst_qgraphicstransform.cpp
- PUBLIC_LIBRARIES
+ LIBRARIES
Qt::Gui
Qt::Widgets
)
diff --git a/tests/auto/widgets/graphicsview/qgraphicstransform/tst_qgraphicstransform.cpp b/tests/auto/widgets/graphicsview/qgraphicstransform/tst_qgraphicstransform.cpp
index 5d5323a3a2..3ee63d288b 100644
--- a/tests/auto/widgets/graphicsview/qgraphicstransform/tst_qgraphicstransform.cpp
+++ b/tests/auto/widgets/graphicsview/qgraphicstransform/tst_qgraphicstransform.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 <QTest>
diff --git a/tests/auto/widgets/graphicsview/qgraphicsview/BLACKLIST b/tests/auto/widgets/graphicsview/qgraphicsview/BLACKLIST
index fe3d929e9e..ae5cbf7d6a 100644
--- a/tests/auto/widgets/graphicsview/qgraphicsview/BLACKLIST
+++ b/tests/auto/widgets/graphicsview/qgraphicsview/BLACKLIST
@@ -1,23 +1,7 @@
-[task255529_transformationAnchorMouseAndViewportMargins]
-opensuse-leap
-[cursor]
-opensuse-leap
[cursor2]
-ubuntu-16.04
-[sendEvent]
-ubuntu-16.04
-opensuse-42.3
-[resizeAnchor]
-opensuse-leap
-rhel-7.6
-ubuntu
-[update2]
-opensuse-42.3
-[itemsInRect_cosmeticAdjust]
-# QTBUG-66815
-ubuntu-16.04
-[fitInView]
osx
+[resizeAnchor]
+rhel
# QTBUG-87397
[itemsAtPoint]
android
@@ -45,3 +29,9 @@ android
android
[update_ancestorClipsChildrenToShape2]
android
+[QTBUG_70255_scrollTo]
+android # QTBUG-87397
+[embeddedViewsWithFocus]
+android # QTBUG-87397
+[viewportUpdateMode2]
+android # QTBUG-87397
diff --git a/tests/auto/widgets/graphicsview/qgraphicsview/CMakeLists.txt b/tests/auto/widgets/graphicsview/qgraphicsview/CMakeLists.txt
index be9c4a3bc4..cf33de0b33 100644
--- a/tests/auto/widgets/graphicsview/qgraphicsview/CMakeLists.txt
+++ b/tests/auto/widgets/graphicsview/qgraphicsview/CMakeLists.txt
@@ -1,16 +1,23 @@
-# Generated from qgraphicsview.pro.
+# Copyright (C) 2022 The Qt Company Ltd.
+# SPDX-License-Identifier: BSD-3-Clause
#####################################################################
## tst_qgraphicsview Test:
#####################################################################
+if(NOT QT_BUILD_STANDALONE_TESTS AND NOT QT_BUILDING_QT)
+ cmake_minimum_required(VERSION 3.16)
+ project(tst_qgraphicsview LANGUAGES CXX)
+ find_package(Qt6BuildInternals REQUIRED COMPONENTS STANDALONE_TEST)
+endif()
+
qt_internal_add_test(tst_qgraphicsview
SOURCES
tst_qgraphicsview.cpp tst_qgraphicsview.h
tst_qgraphicsview_2.cpp
DEFINES
QT_NO_CAST_TO_ASCII
- PUBLIC_LIBRARIES
+ LIBRARIES
Qt::CorePrivate
Qt::Gui
Qt::GuiPrivate
@@ -19,14 +26,11 @@ qt_internal_add_test(tst_qgraphicsview
Qt::WidgetsPrivate
)
-#### Keys ignored in scope 1:.:.:qgraphicsview.pro:<TRUE>:
-# testcase.timeout = "500"
-
## Scopes:
#####################################################################
qt_internal_extend_target(tst_qgraphicsview CONDITION QT_FEATURE_opengl
- PUBLIC_LIBRARIES
+ LIBRARIES
Qt::OpenGL
Qt::OpenGLWidgets
)
diff --git a/tests/auto/widgets/graphicsview/qgraphicsview/tst_qgraphicsview.cpp b/tests/auto/widgets/graphicsview/qgraphicsview/tst_qgraphicsview.cpp
index 8e44912d37..7ed1f28b0a 100644
--- a/tests/auto/widgets/graphicsview/qgraphicsview/tst_qgraphicsview.cpp
+++ b/tests/auto/widgets/graphicsview/qgraphicsview/tst_qgraphicsview.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 <QTest>
@@ -65,6 +40,8 @@
#include <QtTest/private/qtesthelpers_p.h>
+#include <QtWidgets/private/qapplication_p.h>
+
using namespace QTestPrivate;
Q_DECLARE_METATYPE(ExpectedValueDescription)
@@ -102,6 +79,12 @@ static void sendMouseRelease(QWidget *widget, const QPoint &point, Qt::MouseButt
QApplication::sendEvent(widget, &event);
}
+static bool isPlatformEGLFS()
+{
+ static const bool isEGLFS = !QGuiApplication::platformName().compare(QLatin1String("eglfs"), Qt::CaseInsensitive);
+ return isEGLFS;
+}
+
class EventSpy : public QObject
{
Q_OBJECT
@@ -271,6 +254,8 @@ private slots:
#ifndef QT_NO_CURSOR
void QTBUG_7438_cursor();
#endif
+ void resizeContentsOnItemDrag_data();
+ void resizeContentsOnItemDrag();
public slots:
void dummySlot() {}
@@ -669,6 +654,8 @@ void tst_QGraphicsView::openGLViewport()
{
if (!QGuiApplicationPrivate::platformIntegration()->hasCapability(QPlatformIntegration::OpenGL))
QSKIP("QOpenGL is not supported on this platform.");
+ if (isPlatformEGLFS())
+ QSKIP("", "Resizing does not work on EGLFS on top level window", Continue);
QGraphicsScene scene;
scene.setBackgroundBrush(Qt::white);
@@ -690,16 +677,16 @@ void tst_QGraphicsView::openGLViewport()
view.show();
QVERIFY(QTest::qWaitForWindowExposed(&view));
- QTRY_VERIFY(spy1.count() > 0);
- QTRY_VERIFY(spy2.count() >= spy1.count());
+ QTRY_VERIFY(spy1.size() > 0);
+ QTRY_VERIFY(spy2.size() >= spy1.size());
spy1.clear();
spy2.clear();
// Now test for resize (QTBUG-52419). This is special when the viewport is
// a QOpenGLWidget since the underlying FBO must also be maintained.
view.resize(300, 300);
- QTRY_VERIFY(spy1.count() > 0);
- QTRY_VERIFY(spy2.count() >= spy1.count());
+ QTRY_VERIFY(spy1.size() > 0);
+ QTRY_VERIFY(spy2.size() >= spy1.size());
// There is no sane way to check if the framebuffer contents got updated
// (grabFramebuffer is no good for the viewport case as that does not go
// through paintGL). So skip the actual verification.
@@ -743,8 +730,9 @@ void tst_QGraphicsView::dragMode_scrollHand()
int verticalScrollBarValue = view.verticalScrollBar()->value();
{
// Press
- QMouseEvent event(QEvent::MouseButtonPress,
- view.viewport()->rect().center(),
+ auto pos = view.viewport()->rect().center();
+ QMouseEvent event(QEvent::MouseButtonPress, pos,
+ view.viewport()->mapToGlobal(pos),
Qt::LeftButton, Qt::LeftButton, {});
event.setAccepted(true);
QApplication::sendEvent(view.viewport(), &event);
@@ -760,8 +748,9 @@ void tst_QGraphicsView::dragMode_scrollHand()
#endif
{
// Move
- QMouseEvent event(QEvent::MouseMove,
- view.viewport()->rect().center() + QPoint(10, 0),
+ auto pos = view.viewport()->rect().center() + QPoint(10, 0);
+ QMouseEvent event(QEvent::MouseMove, pos,
+ view.viewport()->mapToGlobal(pos),
Qt::LeftButton, Qt::LeftButton, {});
event.setAccepted(true);
QApplication::sendEvent(view.viewport(), &event);
@@ -772,8 +761,9 @@ void tst_QGraphicsView::dragMode_scrollHand()
QCOMPARE(view.verticalScrollBar()->value(), verticalScrollBarValue);
{
// Move
- QMouseEvent event(QEvent::MouseMove,
- view.viewport()->rect().center() + QPoint(10, 10),
+ auto pos = view.viewport()->rect().center() + QPoint(10, 10);
+ QMouseEvent event(QEvent::MouseMove, pos,
+ view.viewport()->mapToGlobal(pos),
Qt::LeftButton, Qt::LeftButton, {});
event.setAccepted(true);
QApplication::sendEvent(view.viewport(), &event);
@@ -786,8 +776,9 @@ void tst_QGraphicsView::dragMode_scrollHand()
{
// Release
- QMouseEvent event(QEvent::MouseButtonRelease,
- view.viewport()->rect().center() + QPoint(10, 10),
+ auto pos = view.viewport()->rect().center() + QPoint(10, 10);
+ QMouseEvent event(QEvent::MouseButtonRelease, pos,
+ view.viewport()->mapToGlobal(pos),
Qt::LeftButton, Qt::LeftButton, {});
event.setAccepted(true);
QApplication::sendEvent(view.viewport(), &event);
@@ -808,15 +799,17 @@ void tst_QGraphicsView::dragMode_scrollHand()
// Check that a click will still unselect the item.
{
// Press
- QMouseEvent event(QEvent::MouseButtonPress,
- view.viewport()->rect().center() + QPoint(10, 10),
+ auto pos = view.viewport()->rect().center() + QPoint(10, 10);
+ QMouseEvent event(QEvent::MouseButtonPress, pos,
+ view.viewport()->mapToGlobal(pos),
Qt::LeftButton, Qt::LeftButton, {});
QApplication::sendEvent(view.viewport(), &event);
}
{
// Release
- QMouseEvent event(QEvent::MouseButtonRelease,
- view.viewport()->rect().center() + QPoint(10, 10),
+ auto pos = view.viewport()->rect().center() + QPoint(10, 10);
+ QMouseEvent event(QEvent::MouseButtonRelease, pos,
+ view.viewport()->mapToGlobal(pos),
Qt::LeftButton, Qt::LeftButton, {});
QApplication::sendEvent(view.viewport(), &event);
}
@@ -865,8 +858,9 @@ void tst_QGraphicsView::dragMode_rubberBand()
int verticalScrollBarValue = view.verticalScrollBar()->value();
{
// Press
- QMouseEvent event(QEvent::MouseButtonPress,
- view.viewport()->rect().center(),
+ auto pos = view.viewport()->rect().center();
+ QMouseEvent event(QEvent::MouseButtonPress, pos,
+ view.viewport()->mapToGlobal(pos),
Qt::LeftButton, Qt::LeftButton, {});
event.setAccepted(true);
QApplication::sendEvent(view.viewport(), &event);
@@ -880,8 +874,9 @@ void tst_QGraphicsView::dragMode_rubberBand()
{
// Move
- QMouseEvent event(QEvent::MouseMove,
- view.viewport()->rect().center() + QPoint(100, 0),
+ auto pos = view.viewport()->rect().center() + QPoint(100, 0);
+ QMouseEvent event(QEvent::MouseMove, pos,
+ view.viewport()->mapToGlobal(pos),
Qt::LeftButton, Qt::LeftButton, {});
event.setAccepted(true);
QApplication::sendEvent(view.viewport(), &event);
@@ -895,8 +890,9 @@ void tst_QGraphicsView::dragMode_rubberBand()
{
// Move
- QMouseEvent event(QEvent::MouseMove,
- view.viewport()->rect().center() + QPoint(100, 100),
+ auto pos = view.viewport()->rect().center() + QPoint(100, 100);
+ QMouseEvent event(QEvent::MouseMove, pos,
+ view.viewport()->mapToGlobal(pos),
Qt::LeftButton, Qt::LeftButton, {});
event.setAccepted(true);
QApplication::sendEvent(view.viewport(), &event);
@@ -907,8 +903,9 @@ void tst_QGraphicsView::dragMode_rubberBand()
{
// Release
- QMouseEvent event(QEvent::MouseButtonRelease,
- view.viewport()->rect().center() + QPoint(100, 100),
+ auto pos = view.viewport()->rect().center() + QPoint(100, 100);
+ QMouseEvent event(QEvent::MouseButtonRelease, pos,
+ view.viewport()->mapToGlobal(pos),
Qt::LeftButton, Qt::LeftButton, {});
event.setAccepted(true);
QApplication::sendEvent(view.viewport(), &event);
@@ -1059,10 +1056,10 @@ void tst_QGraphicsView::rotated_rubberBand()
sendMousePress(view.viewport(), QPoint(midWidth - 2, 0), Qt::LeftButton);
sendMouseMove(view.viewport(), QPoint(midWidth + 2, view.viewport()->height()),
Qt::LeftButton, Qt::LeftButton);
- QCOMPARE(scene.selectedItems().count(), dim);
- foreach (const QGraphicsItem *item, scene.items()) {
+ QCOMPARE(scene.selectedItems().size(), dim);
+ const auto items = scene.items();
+ for (const QGraphicsItem *item : items)
QCOMPARE(item->isSelected(), item->data(0).toBool());
- }
sendMouseRelease(view.viewport(), QPoint(), Qt::LeftButton);
}
@@ -1640,6 +1637,9 @@ void tst_QGraphicsView::itemsInRect_cosmeticAdjust_data()
void tst_QGraphicsView::itemsInRect_cosmeticAdjust()
{
+ if (isPlatformEGLFS())
+ QSKIP("", "Resizing does not work on EGLFS on top level window", Continue);
+
QFETCH(QRect, updateRect);
QFETCH(int, numPaints);
QFETCH(bool, adjustForAntialiasing);
@@ -1933,6 +1933,9 @@ void tst_QGraphicsView::mapToSceneRect_data()
void tst_QGraphicsView::mapToSceneRect()
{
+ if (isPlatformEGLFS())
+ QSKIP("", "Resizing does not work on EGLFS on top level window", Continue);
+
QFETCH(QRect, viewRect);
QFETCH(QPolygonF, scenePoly);
QFETCH(qreal, rotation);
@@ -2150,7 +2153,6 @@ void tst_QGraphicsView::sendEvent()
QGraphicsView view(&scene);
view.show();
- QApplication::setActiveWindow(&view);
QVERIFY(QTest::qWaitForWindowExposed(&view));
QVERIFY(QTest::qWaitForWindowActive(&view));
QCOMPARE(QApplication::activeWindow(), static_cast<QWidget *>(&view));
@@ -2218,7 +2220,6 @@ void tst_QGraphicsView::wheelEvent()
// Assign a view.
QGraphicsView view(&scene);
view.show();
- QApplication::setActiveWindow(&view);
QVERIFY(QTest::qWaitForWindowExposed(&view));
QVERIFY(QTest::qWaitForWindowActive(&view));
QCOMPARE(QApplication::activeWindow(), static_cast<QWidget *>(&view));
@@ -2455,7 +2456,6 @@ void tst_QGraphicsView::viewportUpdateMode()
// Show the view, and initialize our test.
view.show();
- qApp->setActiveWindow(&view);
QVERIFY(QTest::qWaitForWindowExposed(&view));
QVERIFY(QTest::qWaitForWindowActive(&view));
QTRY_VERIFY(!view.lastUpdateRegions.isEmpty());
@@ -2538,7 +2538,6 @@ void tst_QGraphicsView::viewportUpdateMode2()
const QMargins margins = view.contentsMargins();
view.resize(200 + margins.left() + margins.right(), 200 + margins.top() + margins.bottom());
toplevel.show();
- qApp->setActiveWindow(&toplevel);
QVERIFY(QTest::qWaitForWindowExposed(&toplevel));
QVERIFY(QTest::qWaitForWindowActive(&toplevel));
QTRY_VERIFY(view.painted);
@@ -2750,7 +2749,8 @@ void tst_QGraphicsView::optimizationFlags_dontSavePainterState2()
rectB->setTransform(QTransform::fromTranslate(200, 200));
rectB->setPen(QPen(Qt::black, 0));
- foreach (QGraphicsItem *item, scene.items())
+ const auto items = scene.items();
+ for (QGraphicsItem *item : items)
item->setOpacity(0.6);
CustomView view(&scene);
@@ -2887,6 +2887,9 @@ public:
void tst_QGraphicsView::scrollBarRanges()
{
+ if (isPlatformEGLFS())
+ QSKIP("", "Resizing does not work on EGLFS on top level window", Continue);
+
QFETCH(QByteArray, style);
QFETCH(QSize, viewportSize);
QFETCH(QRectF, sceneRect);
@@ -3182,7 +3185,6 @@ void tst_QGraphicsView::task172231_untransformableItems()
view.scale(2, 1);
view.show();
- QApplication::setActiveWindow(&view);
QVERIFY(QTest::qWaitForWindowExposed(&view));
QVERIFY(QTest::qWaitForWindowActive(&view));
QCOMPARE(QApplication::activeWindow(), static_cast<QWidget *>(&view));
@@ -3244,7 +3246,6 @@ void tst_QGraphicsView::task187791_setSceneCausesUpdate()
QGraphicsScene scene(0, 0, 200, 200);
QGraphicsView view(&scene);
view.show();
- qApp->setActiveWindow(&view);
QVERIFY(QTest::qWaitForWindowExposed(&view));
EventSpy updateSpy(view.viewport(), QEvent::Paint);
@@ -3269,7 +3270,8 @@ protected:
{
++mouseMoves;
QGraphicsView::mouseMoveEvent(event);
- foreach (QGraphicsItem *item, scene()->items()) {
+ const auto items = scene()->items();
+ for (QGraphicsItem *item : items) {
scene()->removeItem(item);
delete item;
}
@@ -3295,7 +3297,8 @@ void tst_QGraphicsView::task186827_deleteReplayedItem()
QCOMPARE(view.mouseMoves, 0);
{
- QMouseEvent event(QEvent::MouseMove, view.mapFromScene(25, 25), Qt::NoButton, {}, {});
+ auto pos = view.mapFromScene(25, 25);
+ QMouseEvent event(QEvent::MouseMove, pos, view.viewport()->mapToGlobal(pos), Qt::NoButton, {}, {});
QApplication::sendEvent(view.viewport(), &event);
}
QCOMPARE(view.mouseMoves, 1);
@@ -3303,7 +3306,8 @@ void tst_QGraphicsView::task186827_deleteReplayedItem()
QTRY_COMPARE(view.mouseMoves, 1);
QTest::qWait(25);
{
- QMouseEvent event(QEvent::MouseMove, view.mapFromScene(25, 25), Qt::NoButton, {}, {});
+ auto pos = view.mapFromScene(25, 25);
+ QMouseEvent event(QEvent::MouseMove, pos, view.viewport()->mapToGlobal(pos), Qt::NoButton, {}, {});
QApplication::sendEvent(view.viewport(), &event);
}
QCOMPARE(view.mouseMoves, 2);
@@ -3328,7 +3332,6 @@ void tst_QGraphicsView::task207546_focusCrash()
widget.layout()->addWidget(gr2);
widget.show();
widget.activateWindow();
- QApplication::setActiveWindow(&widget);
QVERIFY(QTest::qWaitForWindowActive(&widget));
QCOMPARE(QApplication::activeWindow(), static_cast<QWidget *>(&widget));
widget.focusNextPrevChild(true);
@@ -3349,8 +3352,10 @@ void tst_QGraphicsView::task210599_unsetDragWhileDragging()
// Enable and do a drag
{
view.setDragMode(QGraphicsView::ScrollHandDrag);
- QMouseEvent press(QEvent::MouseButtonPress, origPos, Qt::LeftButton, {}, {});
- QMouseEvent move(QEvent::MouseMove, step1Pos, Qt::LeftButton, {}, {});
+ QMouseEvent press(QEvent::MouseButtonPress, origPos,
+ view.viewport()->mapToGlobal(origPos), Qt::LeftButton, {}, {});
+ QMouseEvent move(QEvent::MouseMove, step1Pos,
+ view.viewport()->mapToGlobal(step1Pos), Qt::LeftButton, {}, {});
QApplication::sendEvent(view.viewport(), &press);
QApplication::sendEvent(view.viewport(), &move);
}
@@ -3358,7 +3363,8 @@ void tst_QGraphicsView::task210599_unsetDragWhileDragging()
// unset drag and release mouse, inverse order
{
view.setDragMode(QGraphicsView::NoDrag);
- QMouseEvent release(QEvent::MouseButtonRelease, step1Pos, Qt::LeftButton, {}, {});
+ QMouseEvent release(QEvent::MouseButtonRelease, step1Pos,
+ view.viewport()->mapToGlobal(step1Pos), Qt::LeftButton, {}, {});
QApplication::sendEvent(view.viewport(), &release);
}
@@ -3367,7 +3373,8 @@ void tst_QGraphicsView::task210599_unsetDragWhileDragging()
// reset drag, and move mouse without holding button down.
{
view.setDragMode(QGraphicsView::ScrollHandDrag);
- QMouseEvent move(QEvent::MouseMove, step2Pos, Qt::LeftButton, {}, {});
+ QMouseEvent move(QEvent::MouseMove, step2Pos,
+ view.viewport()->mapToGlobal(step2Pos), Qt::LeftButton, {}, {});
QApplication::sendEvent(view.viewport(), &move);
}
@@ -3416,7 +3423,6 @@ void tst_QGraphicsView::task239729_noViewUpdate()
QCOMPARE(spy.count(), 0);
view->show();
- qApp->setActiveWindow(view);
QVERIFY(QTest::qWaitForWindowActive(view));
QTRY_VERIFY(spy.count() >= 1);
@@ -3548,6 +3554,9 @@ void tst_QGraphicsView::embeddedViewsWithFocus()
void focusOutEvent(QFocusEvent *) override { --focusCount; }
};
+ if (!QGuiApplicationPrivate::platformIntegration()->hasCapability(QPlatformIntegration::WindowActivation))
+ QSKIP("QWindow::requestActivate() is not supported.");
+
QGraphicsScene innerScene;
FocusWidget *innerWidget = new FocusWidget;
innerScene.addWidget(innerWidget);
@@ -3649,6 +3658,9 @@ void tst_QGraphicsView::moveItemWhileScrolling_data()
void tst_QGraphicsView::moveItemWhileScrolling()
{
+ if (isPlatformEGLFS())
+ QSKIP("", "Resizing does not work on EGLFS on top level window", Continue);
+
QFETCH(bool, adjustForAntialiasing);
QFETCH(bool, changedConnected);
@@ -3871,8 +3883,9 @@ void tst_QGraphicsView::mouseTracking2()
EventSpy spy(&scene, QEvent::GraphicsSceneMouseMove);
QCOMPARE(spy.count(), 0);
- QMouseEvent event(QEvent::MouseMove,view.viewport()->rect().center(), Qt::NoButton,
- Qt::MouseButtons(Qt::NoButton), {});
+ auto pos = view.viewport()->rect().center();
+ QMouseEvent event(QEvent::MouseMove, pos, view.viewport()->mapToGlobal(pos),
+ Qt::NoButton, Qt::MouseButtons(Qt::NoButton), {});
QApplication::sendEvent(view.viewport(), &event);
QCOMPARE(spy.count(), 1);
}
@@ -4040,7 +4053,7 @@ void tst_QGraphicsView::exposeRegion()
CustomView view;
view.setScene(&scene);
view.show();
- qApp->setActiveWindow(&view);
+ QApplicationPrivate::setActiveWindow(&view);
QVERIFY(QTest::qWaitForWindowExposed(&view));
QVERIFY(QTest::qWaitForWindowActive(&view));
@@ -4114,7 +4127,6 @@ void tst_QGraphicsView::update()
QVERIFY(QTest::qWaitForWindowExposed(&toplevel));
- QApplication::setActiveWindow(&toplevel);
QApplication::processEvents();
QTRY_COMPARE(QApplication::activeWindow(), static_cast<QWidget *>(&toplevel));
@@ -4171,6 +4183,9 @@ void tst_QGraphicsView::update2_data()
void tst_QGraphicsView::update2()
{
+ if (isPlatformEGLFS())
+ QSKIP("", "Resizing does not work on EGLFS on top level window", Continue);
+
QFETCH(qreal, penWidth);
QFETCH(bool, antialiasing);
QFETCH(bool, changedConnected);
@@ -4196,7 +4211,7 @@ void tst_QGraphicsView::update2()
view.setFrameStyle(0);
view.resize(200, 200);
view.show();
- qApp->setActiveWindow(&view);
+ QApplicationPrivate::setActiveWindow(&view);
QVERIFY(QTest::qWaitForWindowExposed(&view));
QVERIFY(QTest::qWaitForWindowActive(&view));
QTRY_VERIFY(rect->numPaints > 0);
@@ -4266,7 +4281,7 @@ void tst_QGraphicsView::update_ancestorClipsChildrenToShape()
CustomView view(&scene);
view.show();
- qApp->setActiveWindow(&view);
+ QApplicationPrivate::setActiveWindow(&view);
QVERIFY(QTest::qWaitForWindowExposed(&view));
QVERIFY(QTest::qWaitForWindowActive(&view));
QTRY_VERIFY(view.painted);
@@ -4320,7 +4335,7 @@ void tst_QGraphicsView::update_ancestorClipsChildrenToShape2()
CustomView view(&scene);
view.show();
- qApp->setActiveWindow(&view);
+ QApplicationPrivate::setActiveWindow(&view);
QVERIFY(QTest::qWaitForWindowExposed(&view));
QVERIFY(QTest::qWaitForWindowActive(&view));
QTRY_VERIFY(view.painted);
@@ -4381,7 +4396,6 @@ void tst_QGraphicsView::inputMethodSensitivity()
QGraphicsScene scene;
QGraphicsView view(&scene);
view.show();
- QApplication::setActiveWindow(&view);
QVERIFY(QTest::qWaitForWindowExposed(&view));
QVERIFY(QTest::qWaitForWindowActive(&view));
QCOMPARE(QApplication::activeWindow(), static_cast<QWidget *>(&view));
@@ -4479,7 +4493,6 @@ void tst_QGraphicsView::inputContextReset()
QVERIFY(view.testAttribute(Qt::WA_InputMethodEnabled));
view.show();
- QApplication::setActiveWindow(&view);
QVERIFY(QTest::qWaitForWindowExposed(&view));
QVERIFY(QTest::qWaitForWindowActive(&view));
QCOMPARE(QApplication::activeWindow(), static_cast<QWidget *>(&view));
@@ -4627,7 +4640,6 @@ void tst_QGraphicsView::task255529_transformationAnchorMouseAndViewportMargins()
VpGraphicsView view(&scene);
view.setWindowFlags(Qt::X11BypassWindowManagerHint);
view.show();
- qApp->setActiveWindow(&view);
QVERIFY(QTest::qWaitForWindowExposed(&view));
const bool isActiveWindow = QTest::qWaitForWindowActive(&view);
if (!isActiveWindow)
@@ -4770,6 +4782,9 @@ void tst_QGraphicsView::QTBUG_4151_clipAndIgnore()
void tst_QGraphicsView::QTBUG_5859_exposedRect()
{
+ if (isPlatformEGLFS())
+ QSKIP("", "Resizing does not work on EGLFS on top level window", Continue);
+
class CustomScene : public QGraphicsScene
{
public:
@@ -4798,7 +4813,6 @@ void tst_QGraphicsView::QTBUG_5859_exposedRect()
QGraphicsView view(&scene);
view.scale(4.15, 4.15);
view.showNormal();
- QApplication::setActiveWindow(&view);
QVERIFY(QTest::qWaitForWindowExposed(&view));
QVERIFY(QTest::qWaitForWindowActive(&view));
@@ -4870,7 +4884,6 @@ void tst_QGraphicsView::hoverLeave()
scene.addItem(item);
view.showNormal();
- qApp->setActiveWindow(&view);
QVERIFY(QTest::qWaitForWindowExposed(&view));
QWindow *viewWindow = view.window()->windowHandle();
@@ -4949,7 +4962,6 @@ void tst_QGraphicsView::QTBUG_70255_scrollTo()
view.centerOn(0, 0);
view.show();
- QApplication::setActiveWindow(&view);
if (!QTest::qWaitForWindowExposed(&view) || !QTest::qWaitForWindowActive(&view))
QSKIP("Failed to show and activate window");
@@ -4963,5 +4975,111 @@ void tst_QGraphicsView::QTBUG_70255_scrollTo()
QCOMPARE(point, QPoint(0, -500));
}
+void tst_QGraphicsView::resizeContentsOnItemDrag_data()
+{
+ QTest::addColumn<Qt::Alignment>("alignment");
+ QTest::addColumn<Qt::Orientation>("orientation");
+ QTest::addRow("Center right") << Qt::Alignment(Qt::AlignCenter) << Qt::Horizontal;
+ QTest::addRow("Center down") << Qt::Alignment(Qt::AlignCenter) << Qt::Vertical;
+ QTest::addRow("BottomLeft right") << (Qt::AlignBottom | Qt::AlignLeft) << Qt::Horizontal;
+ QTest::addRow("TopRight down") << (Qt::AlignTop | Qt::AlignRight) << Qt::Vertical;
+}
+
+void tst_QGraphicsView::resizeContentsOnItemDrag()
+{
+ QFETCH(Qt::Alignment, alignment);
+ QFETCH(Qt::Orientation, orientation);
+
+ QGraphicsView view;
+ QGraphicsScene scene;
+ view.setFixedSize(200, 200);
+ view.setScene(&scene);
+
+ view.setAlignment(alignment);
+
+ class MovableItem : public QGraphicsEllipseItem
+ {
+ public:
+ using QGraphicsEllipseItem::QGraphicsEllipseItem;
+
+ QList<QPointF> scenePositions;
+
+ protected:
+ void mousePressEvent(QGraphicsSceneMouseEvent *event) override
+ {
+ scenePositions << event->scenePos();
+ }
+ void mouseMoveEvent(QGraphicsSceneMouseEvent *event) override
+ {
+ scenePositions << event->scenePos();
+ QGraphicsEllipseItem::mouseMoveEvent(event);
+ }
+ };
+
+ MovableItem item(-10, -10, 20, 20);
+ item.setFlags(QGraphicsItem::ItemIsMovable);
+ scene.addItem(&item);
+ view.show();
+ QVERIFY(QTest::qWaitForWindowExposed(&view));
+
+ // Position the item near the relevant edge of the view, with a few pixels
+ // to go until the scrollbars should be showing.
+ if (orientation == Qt::Horizontal)
+ item.setPos(view.width() - item.rect().width() - 5, 0);
+ else
+ item.setPos(0, view.height() - item.rect().height() - 5);
+ QApplication::processEvents(); // queued connection used to trigger recalculateContentSize
+ QPoint mousePos = view.mapFromScene(item.pos());
+
+ QTest::mousePress(view.viewport(), Qt::LeftButton, {}, mousePos);
+ QCOMPARE(item.scenePositions.count(), 1);
+ QCOMPARE(item.scenePositions.takeLast(), view.mapToScene(mousePos));
+
+ auto lastItemPos = item.pos();
+ auto lastScenePos = view.mapToScene(mousePos);
+ int overshoot = 0;
+ const QScrollBar *scrollBar = orientation == Qt::Horizontal
+ ? view.horizontalScrollBar()
+ : view.verticalScrollBar();
+ // Drag the item until the scroll bars become visible, and then for a few more pixels.
+ // Verify that the item doesn't jump when the scrollbar shows.
+ while (overshoot < 10) {
+ if (orientation == Qt::Horizontal)
+ mousePos.rx() += 1;
+ else
+ mousePos.ry() += 1;
+ QTest::mouseMove(view.viewport(), mousePos);
+ QApplication::processEvents(); // queued connection used to trigger recalculateContentSize
+ const bool scrollbarAvailable = scrollBar->maximum() > scrollBar->minimum();
+ bool allowMoreEvents = false;
+ if (scrollbarAvailable) {
+ if (!overshoot) {
+ QTRY_VERIFY(scrollBar->isVisible());
+ // scrollbar becoming visible triggers event replay, so we get more than one
+ allowMoreEvents = true;
+ }
+ ++overshoot;
+ }
+ if (allowMoreEvents)
+ QCOMPARE_GE(item.scenePositions.count(), 1);
+ else
+ QCOMPARE(item.scenePositions.count(), 1);
+ const auto scenePos = item.scenePositions.takeLast();
+ item.scenePositions.clear();
+
+ const auto same = orientation == Qt::Horizontal ? &QPointF::y : &QPointF::x;
+ const auto moved = orientation == Qt::Horizontal ? &QPointF::x : &QPointF::y;
+ QCOMPARE((item.pos().*same)(), (lastItemPos.*same)());
+ QCOMPARE_GE((item.pos().*moved)() - (lastItemPos.*moved)(), 1);
+ QCOMPARE_LE((item.pos().*moved)() - (lastItemPos.*moved)(), 2);
+ lastItemPos = item.pos();
+
+ QCOMPARE((scenePos.*same)(), (lastScenePos.*same)());
+ QCOMPARE_GE((scenePos.*moved)() - (lastScenePos.*moved)(), 1);
+ QCOMPARE_LE((scenePos.*moved)() - (lastScenePos.*moved)(), 2);
+ lastScenePos = scenePos;
+ }
+}
+
QTEST_MAIN(tst_QGraphicsView)
#include "tst_qgraphicsview.moc"
diff --git a/tests/auto/widgets/graphicsview/qgraphicsview/tst_qgraphicsview.h b/tests/auto/widgets/graphicsview/qgraphicsview/tst_qgraphicsview.h
index 42e9e6e2a3..2fb5ed638c 100644
--- a/tests/auto/widgets/graphicsview/qgraphicsview/tst_qgraphicsview.h
+++ b/tests/auto/widgets/graphicsview/qgraphicsview/tst_qgraphicsview.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 TST_QGRAPHICSVIEW_H
#define TST_QGRAPHICSVIEW_H
diff --git a/tests/auto/widgets/graphicsview/qgraphicsview/tst_qgraphicsview_2.cpp b/tests/auto/widgets/graphicsview/qgraphicsview/tst_qgraphicsview_2.cpp
index 72b5acc654..1380e007e7 100644
--- a/tests/auto/widgets/graphicsview/qgraphicsview/tst_qgraphicsview_2.cpp
+++ b/tests/auto/widgets/graphicsview/qgraphicsview/tst_qgraphicsview_2.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 <QTest>
#include <QtCore/QSize>
#include <QtCore/QRectF>
diff --git a/tests/auto/widgets/graphicsview/qgraphicswidget/BLACKLIST b/tests/auto/widgets/graphicsview/qgraphicswidget/BLACKLIST
index c49c0ea089..cad381b7b7 100644
--- a/tests/auto/widgets/graphicsview/qgraphicswidget/BLACKLIST
+++ b/tests/auto/widgets/graphicsview/qgraphicswidget/BLACKLIST
@@ -2,8 +2,7 @@
macos ci
android
b2qt
+# QTBUG-100930
[updateFocusChainWhenChildDie]
b2qt
-[initialShow]
-macos ci
-opensuse-leap
+qnx
diff --git a/tests/auto/widgets/graphicsview/qgraphicswidget/CMakeLists.txt b/tests/auto/widgets/graphicsview/qgraphicswidget/CMakeLists.txt
index 8cf7f92cc3..42e30e4f5d 100644
--- a/tests/auto/widgets/graphicsview/qgraphicswidget/CMakeLists.txt
+++ b/tests/auto/widgets/graphicsview/qgraphicswidget/CMakeLists.txt
@@ -1,13 +1,20 @@
-# Generated from qgraphicswidget.pro.
+# Copyright (C) 2022 The Qt Company Ltd.
+# SPDX-License-Identifier: BSD-3-Clause
#####################################################################
## tst_qgraphicswidget Test:
#####################################################################
+if(NOT QT_BUILD_STANDALONE_TESTS AND NOT QT_BUILDING_QT)
+ cmake_minimum_required(VERSION 3.16)
+ project(tst_qgraphicswidget LANGUAGES CXX)
+ find_package(Qt6BuildInternals REQUIRED COMPONENTS STANDALONE_TEST)
+endif()
+
qt_internal_add_test(tst_qgraphicswidget
SOURCES
tst_qgraphicswidget.cpp
- PUBLIC_LIBRARIES
+ LIBRARIES
Qt::CorePrivate
Qt::Gui
Qt::GuiPrivate
diff --git a/tests/auto/widgets/graphicsview/qgraphicswidget/tst_qgraphicswidget.cpp b/tests/auto/widgets/graphicsview/qgraphicswidget/tst_qgraphicswidget.cpp
index 45aa0f567b..9fd93ca91d 100644
--- a/tests/auto/widgets/graphicsview/qgraphicswidget/tst_qgraphicswidget.cpp
+++ b/tests/auto/widgets/graphicsview/qgraphicswidget/tst_qgraphicswidget.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 <QTest>
@@ -43,6 +18,8 @@
#include <qscreen.h>
#include <qsignalspy.h>
+#include <QtWidgets/private/qapplication_p.h>
+
typedef QList<QGraphicsItem *> QGraphicsItemList;
class EventSpy : public QObject
@@ -169,8 +146,16 @@ private slots:
void QT_BUG_6544_tabFocusFirstUnsetWhenRemovingItems();
void QT_BUG_12056_tabFocusFirstUnsetWhenRemovingItems();
void QTBUG_45867_send_itemChildAddedChange_to_parent();
+
+private:
+ static bool hasWindowActivation();
};
+bool tst_QGraphicsWidget::hasWindowActivation()
+{
+ return (QGuiApplicationPrivate::platformIntegration()->hasCapability(QPlatformIntegration::WindowActivation));
+}
+
// Subclass that exposes the protected functions.
class SubQGraphicsWidget : public QGraphicsWidget {
public:
@@ -965,9 +950,9 @@ void tst_QGraphicsWidget::geometry()
widget.setPos(pos);
widget.resize(size);
if (!size.isNull() && !pos.isNull())
- QCOMPARE(spy.count(), 2);
+ QCOMPARE(spy.size(), 2);
if (!size.isNull() && pos.isNull())
- QCOMPARE(spy.count(), 1);
+ QCOMPARE(spy.size(), 1);
QCOMPARE(widget.geometry(), QRectF(pos, size));
}
@@ -978,10 +963,10 @@ void tst_QGraphicsWidget::geometryChanged()
QCOMPARE(w.geometry(), QRectF(0, 0, 200, 200));
QSignalSpy spy(&w, SIGNAL(geometryChanged()));
w.setGeometry(0, 0, 100, 100);
- QCOMPARE(spy.count(), 1);
+ QCOMPARE(spy.size(), 1);
QCOMPARE(w.geometry(), QRectF(0, 0, 100, 100));
w.setPos(10, 10);
- QCOMPARE(spy.count(), 2);
+ QCOMPARE(spy.size(), 2);
QCOMPARE(w.geometry(), QRectF(10, 10, 100, 100));
}
@@ -993,10 +978,10 @@ void tst_QGraphicsWidget::width()
QSignalSpy spy(&w, SIGNAL(widthChanged()));
w.setProperty("width", qreal(50));
QCOMPARE(w.property("width").toReal(), qreal(50));
- QCOMPARE(spy.count(), 1);
+ QCOMPARE(spy.size(), 1);
//calling old school setGeometry should work too
w.setGeometry(0, 0, 200, 200);
- QCOMPARE(spy.count(), 2);
+ QCOMPARE(spy.size(), 2);
}
void tst_QGraphicsWidget::height()
@@ -1006,10 +991,10 @@ void tst_QGraphicsWidget::height()
QSignalSpy spy(&w, SIGNAL(heightChanged()));
w.setProperty("height", qreal(50));
QCOMPARE(w.property("height").toReal(), qreal(50));
- QCOMPARE(spy.count(), 1);
+ QCOMPARE(spy.size(), 1);
//calling old school setGeometry should work too
w.setGeometry(0, 0, 200, 200);
- QCOMPARE(spy.count(), 2);
+ QCOMPARE(spy.size(), 2);
}
void tst_QGraphicsWidget::getContentsMargins_data()
@@ -1074,7 +1059,10 @@ void tst_QGraphicsWidget::initStyleOption()
QGraphicsView view(&scene);
view.resize(300, 300);
view.show();
- QVERIFY(QTest::qWaitForWindowActive(&view));
+ if (hasWindowActivation())
+ QVERIFY(QTest::qWaitForWindowActive(&view));
+ else
+ QVERIFY(QTest::qWaitForWindowExposed(&view));
view.setAlignment(Qt::AlignTop | Qt::AlignLeft);
SubQGraphicsWidget *widget = new SubQGraphicsWidget;
@@ -1088,10 +1076,12 @@ void tst_QGraphicsWidget::initStyleOption()
QFETCH(bool, enabled);
widget->setEnabled(enabled);
QFETCH(bool, focus);
- if (focus) {
- widget->setFlag(QGraphicsItem::ItemIsFocusable, true);
- widget->setFocus();
- QVERIFY(widget->hasFocus());
+ if (hasWindowActivation()) {
+ if (focus) {
+ widget->setFlag(QGraphicsItem::ItemIsFocusable, true);
+ widget->setFocus();
+ QVERIFY(widget->hasFocus());
+ }
}
QFETCH(bool, underMouse);
if (underMouse) {
@@ -1110,8 +1100,10 @@ void tst_QGraphicsWidget::initStyleOption()
bool isEnabled = option.state & QStyle::State_Enabled;
QCOMPARE(isEnabled, enabled);
- bool hasFocus = option.state & QStyle::State_HasFocus;
- QCOMPARE(hasFocus, focus);
+ if (hasWindowActivation()) {
+ bool hasFocus = option.state & QStyle::State_HasFocus;
+ QCOMPARE(hasFocus, focus);
+ }
bool isUnderMouse = option.state & QStyle::State_MouseOver;
QCOMPARE(isUnderMouse, underMouse);
// if (layoutDirection != Qt::LeftToRight)
@@ -1148,12 +1140,12 @@ void tst_QGraphicsWidget::layout()
widget.setLayout(layout);
QTRY_COMPARE(widget.layout(), static_cast<QGraphicsLayout*>(layout));
- for (int i = 0; i < children.count(); ++i) {
+ for (int i = 0; i < children.size(); ++i) {
SubQGraphicsWidget *item = children[i];
QCOMPARE(item->parentWidget(), (QGraphicsWidget *)&widget);
QVERIFY(item->geometry() != QRectF(0, 0, -1, -1));
}
- QCOMPARE(spy.count(), 1);
+ QCOMPARE(spy.size(), 1);
// don't crash
widget.setLayout(0);
}
@@ -1186,7 +1178,7 @@ void tst_QGraphicsWidget::layoutDirection()
QCOMPARE(widget.testAttribute(Qt::WA_SetLayoutDirection), true);
view->show();
QVERIFY(QTest::qWaitForWindowExposed(view.data()));
- for (int i = 0; i < children.count(); ++i) {
+ for (int i = 0; i < children.size(); ++i) {
QTRY_COMPARE(children[i]->layoutDirection(), layoutDirection);
QTRY_COMPARE(children[i]->testAttribute(Qt::WA_SetLayoutDirection), false);
view->update();
@@ -1396,7 +1388,6 @@ void tst_QGraphicsWidget::setTabOrder()
QGraphicsScene scene;
QGraphicsView view(&scene);
view.show();
- QApplication::setActiveWindow(&view);
QVERIFY(QTest::qWaitForWindowActive(&view));
QGraphicsWidget *lastItem = nullptr;
@@ -1424,7 +1415,7 @@ void tst_QGraphicsWidget::setTabOrder()
QVERIFY(view.viewport()->hasFocus());
int currentItem = 0;
- while (currentItem < children.count() - 1) {
+ while (currentItem < children.size() - 1) {
QTest::keyPress(view.viewport(), Qt::Key_Tab);
++currentItem;
QVERIFY(children[currentItem % children.size()]->hasFocus());
@@ -1468,7 +1459,6 @@ void tst_QGraphicsWidget::setTabOrderAndReparent()
QGraphicsScene scene;
QGraphicsView view(&scene);
view.show();
- QApplication::setActiveWindow(&view);
QVERIFY(QTest::qWaitForWindowActive(&view));
QCOMPARE(QApplication::activeWindow(), (QWidget*)&view);
@@ -1573,7 +1563,7 @@ void tst_QGraphicsWidget::unsetLayoutDirection()
widget.setLayoutDirection(layoutDirection);
widget.unsetLayoutDirection();
QCOMPARE(widget.testAttribute(Qt::WA_SetLayoutDirection), false);
- for (int i = 0; i < children.count(); ++i) {
+ for (int i = 0; i < children.size(); ++i) {
QCOMPARE(children[i]->layoutDirection(), Qt::LeftToRight);
}
}
@@ -1598,7 +1588,6 @@ void tst_QGraphicsWidget::verifyFocusChain()
QGraphicsScene scene;
QGraphicsView view(&scene);
view.show();
- QApplication::setActiveWindow(&view);
QVERIFY(QTest::qWaitForWindowActive(&view));
{
@@ -1690,7 +1679,6 @@ void tst_QGraphicsWidget::verifyFocusChain()
w1_2->setFocusPolicy(Qt::StrongFocus);
scene.addItem(w1_2);
window->show();
- QApplication::setActiveWindow(window.data());
QVERIFY(QTest::qWaitForWindowActive(window.data()));
lineEdit->setFocus();
@@ -1738,13 +1726,16 @@ void tst_QGraphicsWidget::verifyFocusChain()
void tst_QGraphicsWidget::updateFocusChainWhenChildDie()
{
+ if (!hasWindowActivation())
+ QSKIP("Window activation is not supported");
+
const QRect availableGeometry = QGuiApplication::primaryScreen()->availableGeometry();
QGraphicsScene scene;
QGraphicsView view(&scene);
view.resize(200, 150);
view.move(availableGeometry.topLeft() + QPoint(50, 50));
view.show();
- QApplication::setActiveWindow(&view);
+ view.activateWindow();
QVERIFY(QTest::qWaitForWindowActive(&view));
// delete item in focus chain with no focus and verify chain
@@ -1773,13 +1764,8 @@ void tst_QGraphicsWidget::updateFocusChainWhenChildDie()
w->setParentItem(parent);
//We don't crash perfect
QVERIFY(w);
- const QPoint center(view.viewport()->width() / 2, view.viewport()->height() / 2);
- QTest::mouseMove(view.viewport(), center);
- QTest::mouseClick(view.viewport(), Qt::LeftButton, {}, center);
-#ifdef Q_OS_MAC
- QEXPECT_FAIL("", "QTBUG-23699", Continue);
-#endif
- QTRY_COMPARE(qApp->activeWindow(), static_cast<QWidget *>(&view));
+ view.activateWindow();
+ QVERIFY(QTest::qWaitForWindowActive(&view));
QTRY_COMPARE(scene.focusItem(), static_cast<QGraphicsItem *>(w));
}
@@ -1865,7 +1851,7 @@ enum WhichSize {
MinimumSizeHint,
PreferredSizeHint,
MaximumSizeHint,
- Size,
+ WidgetSize,
None,
};
@@ -1880,48 +1866,48 @@ void tst_QGraphicsWidget::setSizes_data()
QTest::addColumn<QList<Inst>>("compareInstructions");
QTest::newRow("minSize1") << (QList<Inst>()
- << Inst(Size, QSize(25, 25)) << Inst(MinimumSize, QSize(10, 10)))
- << (QList<Inst>() << Inst(Size, QSize(25, 25)));
- QTest::newRow("minSize2") << (QList<Inst>() << Inst(Size, QSizeF(20, 20))
+ << Inst(WidgetSize, QSize(25, 25)) << Inst(MinimumSize, QSize(10, 10)))
+ << (QList<Inst>() << Inst(WidgetSize, QSize(25, 25)));
+ QTest::newRow("minSize2") << (QList<Inst>() << Inst(WidgetSize, QSizeF(20, 20))
<< Inst(MinimumSize, QSizeF(25, 25)))
- << (QList<Inst>() << Inst(Size, QSizeF(25, 25)));
+ << (QList<Inst>() << Inst(WidgetSize, QSizeF(25, 25)));
QTest::newRow("minWidth1") << (QList<Inst>()
- << Inst(Size, QSizeF(20, 20)) << Inst(MinimumWidth, 5.0))
- << (QList<Inst>() << Inst(Size, QSizeF(20, 20)));
+ << Inst(WidgetSize, QSizeF(20, 20)) << Inst(MinimumWidth, 5.0))
+ << (QList<Inst>() << Inst(WidgetSize, QSizeF(20, 20)));
QTest::newRow("minWidth2") << (QList<Inst>()
- << Inst(Size, QSizeF(20, 20)) << Inst(MinimumWidth, 25.0))
- << (QList<Inst>() << Inst(Size, QSizeF(25, 20)));
+ << Inst(WidgetSize, QSizeF(20, 20)) << Inst(MinimumWidth, 25.0))
+ << (QList<Inst>() << Inst(WidgetSize, QSizeF(25, 20)));
QTest::newRow("minHeight1") << (QList<Inst>()
- << Inst(Size, QSizeF(20, 20)) << Inst(MinimumHeight, 5.0))
- << (QList<Inst>() << Inst(Size, QSizeF(20, 20)));
+ << Inst(WidgetSize, QSizeF(20, 20)) << Inst(MinimumHeight, 5.0))
+ << (QList<Inst>() << Inst(WidgetSize, QSizeF(20, 20)));
QTest::newRow("minHeight2") << (QList<Inst>()
- << Inst(Size, QSizeF(20, 20)) << Inst(MinimumHeight, 25.0))
- << (QList<Inst>() << Inst(Size, QSizeF(20, 25)));
- QTest::newRow("maxSize1") << (QList<Inst>() << Inst(Size, QSizeF(40, 40))
+ << Inst(WidgetSize, QSizeF(20, 20)) << Inst(MinimumHeight, 25.0))
+ << (QList<Inst>() << Inst(WidgetSize, QSizeF(20, 25)));
+ QTest::newRow("maxSize1") << (QList<Inst>() << Inst(WidgetSize, QSizeF(40, 40))
<< Inst(MaximumSize, QSizeF(30, 30)))
- << (QList<Inst>() << Inst(Size, QSizeF(30, 30)));
- QTest::newRow("maxSize2") << (QList<Inst>() << Inst(Size, QSizeF(40, 40))
+ << (QList<Inst>() << Inst(WidgetSize, QSizeF(30, 30)));
+ QTest::newRow("maxSize2") << (QList<Inst>() << Inst(WidgetSize, QSizeF(40, 40))
<< Inst(MaximumSize, QSizeF(30, -1)))
- << (QList<Inst>() << Inst(Size, QSizeF(30, 40)));
- QTest::newRow("maxSize3") << (QList<Inst>() << Inst(Size, QSizeF(40, 40))
+ << (QList<Inst>() << Inst(WidgetSize, QSizeF(30, 40)));
+ QTest::newRow("maxSize3") << (QList<Inst>() << Inst(WidgetSize, QSizeF(40, 40))
<< Inst(MaximumSize, QSizeF(-1, 30)))
- << (QList<Inst>() << Inst(Size, QSizeF(40, 30)));
+ << (QList<Inst>() << Inst(WidgetSize, QSizeF(40, 30)));
QTest::newRow("maxWidth1") << (QList<Inst>()
- << Inst(Size, QSizeF(40, 40)) << Inst(MaximumWidth, 30))
- << (QList<Inst>() << Inst(Size, QSizeF(30, 40)));
+ << Inst(WidgetSize, QSizeF(40, 40)) << Inst(MaximumWidth, 30))
+ << (QList<Inst>() << Inst(WidgetSize, QSizeF(30, 40)));
QTest::newRow("maxHeight") << (QList<Inst>()
- << Inst(Size, QSizeF(40, 40)) << Inst(MaximumHeight, 20))
- << (QList<Inst>() << Inst(Size, QSizeF(40, 20)));
- QTest::newRow("unsetMinSize") << (QList<Inst>() << Inst(Size, QSizeF(40, 40))
+ << Inst(WidgetSize, QSizeF(40, 40)) << Inst(MaximumHeight, 20))
+ << (QList<Inst>() << Inst(WidgetSize, QSizeF(40, 20)));
+ QTest::newRow("unsetMinSize") << (QList<Inst>() << Inst(WidgetSize, QSizeF(40, 40))
<< Inst(MinimumSize, QSizeF(-1, -1)))
<< (QList<Inst>() << Inst(MinimumSize, QSizeF(5, 5)));
- QTest::newRow("unsetMaxSize") << (QList<Inst>() << Inst(Size, QSizeF(40, 40))
+ QTest::newRow("unsetMaxSize") << (QList<Inst>() << Inst(WidgetSize, QSizeF(40, 40))
<< Inst(MaximumSize, QSizeF(-1, -1)))
<< (QList<Inst>() << Inst(MaximumSize, QSizeF(500, 500)));
QTest::newRow("unsetMinSize, expand size to minimumSizeHint")
- << (QList<Inst>() << Inst(MinimumSize, QSize(0, 0)) << Inst(Size, QSize(1, 1))
+ << (QList<Inst>() << Inst(MinimumSize, QSize(0, 0)) << Inst(WidgetSize, QSize(1, 1))
<< Inst(MinimumSize, QSize(-1.0, -1.0)))
- << (QList<Inst>() << Inst(Size, QSize(5, 5)) << Inst(MinimumSize, QSize(5, 5)));
+ << (QList<Inst>() << Inst(WidgetSize, QSize(5, 5)) << Inst(MinimumSize, QSize(5, 5)));
}
void tst_QGraphicsWidget::setSizes()
@@ -1937,7 +1923,7 @@ void tst_QGraphicsWidget::setSizes()
QSizeF max = QSizeF(50, 50);
int i;
- for (i = 0; i < inputInstructions.count(); ++i) {
+ for (i = 0; i < inputInstructions.size(); ++i) {
Inst input = inputInstructions.at(i);
// defaults
@@ -1951,7 +1937,7 @@ void tst_QGraphicsWidget::setSizes()
case MaximumSize:
max = input.second.toSizeF();
break;
- case Size:
+ case WidgetSize :
widget->resize(input.second.toSizeF());
break;
case MinimumWidth:
@@ -1991,7 +1977,7 @@ void tst_QGraphicsWidget::setSizes()
widget->setPreferredSize(pref);
widget->setMaximumSize(max);
- for (i = 0; i < compareInstructions.count(); ++i) {
+ for (i = 0; i < compareInstructions.size(); ++i) {
Inst input = compareInstructions.at(i);
switch (input.first) {
case MinimumSize:
@@ -2003,7 +1989,7 @@ void tst_QGraphicsWidget::setSizes()
case MaximumSize:
QTRY_COMPARE(widget->maximumSize(), input.second.toSizeF());
break;
- case Size:
+ case WidgetSize:
QTRY_COMPARE(widget->size(), input.second.toSizeF());
break;
case MinimumWidth:
@@ -2704,7 +2690,6 @@ void tst_QGraphicsWidget::task250119_shortcutContext()
QGraphicsView view;
view.setScene(&scene);
view.show();
- QApplication::setActiveWindow(&view);
QTRY_COMPARE(QApplication::activeWindow(), (QWidget*)&view);
@@ -2741,11 +2726,11 @@ void tst_QGraphicsWidget::task250119_shortcutContext()
w_signal.setFocus();
QTest::keyPress(&view, Qt::Key_B);
- QCOMPARE(spy.count(), 1);
+ QCOMPARE(spy.size(), 1);
w_signal.clearFocus();
QTest::keyPress(&view, Qt::Key_B);
- QCOMPARE(spy.count(), 1);
+ QCOMPARE(spy.size(), 1);
scene.removeItem(&w_signal);
}
@@ -2962,11 +2947,9 @@ void tst_QGraphicsWidget::respectHFW()
view->grabMouse();
// move both mouse cursor and set correct event in order to emulate resize
QTest::mouseMove(view->viewport(), view->mapFromScene(60, 30), 200);
- QMouseEvent e = QMouseEvent(QEvent::MouseMove,
- view->mapFromScene(60, 20),
- Qt::NoButton,
- Qt::LeftButton,
- Qt::NoModifier);
+ auto pos = view->mapFromScene(60, 20);
+ QMouseEvent e(QEvent::MouseMove, pos, view->mapToGlobal(pos),
+ Qt::NoButton, Qt::LeftButton, Qt::NoModifier);
QApplication::sendEvent(view->viewport(), &e);
view->releaseMouse();
}
@@ -3125,8 +3108,7 @@ void tst_QGraphicsWidget::initialShow()
dummyView->setWindowFlags(Qt::X11BypassWindowManagerHint);
EventSpy paintSpy(dummyView->viewport(), QEvent::Paint);
dummyView->show();
- qApp->setActiveWindow(dummyView.data());
- QVERIFY(QTest::qWaitForWindowActive(dummyView.data()));
+ QVERIFY(QTest::qWaitForWindowExposed(dummyView.data()));
const int expectedRepaintCount = paintSpy.count();
dummyView.reset();
@@ -3139,8 +3121,7 @@ void tst_QGraphicsWidget::initialShow()
QGraphicsView view(&scene);
view.setWindowFlags(view.windowFlags()|Qt::X11BypassWindowManagerHint);
view.show();
- qApp->setActiveWindow(&view);
- QVERIFY(QTest::qWaitForWindowActive(&view));
+ QVERIFY(QTest::qWaitForWindowExposed(&view));
QTRY_COMPARE(widget->repaints, expectedRepaintCount);
}