summaryrefslogtreecommitdiffstats
path: root/tests/auto
diff options
context:
space:
mode:
authorQt Forward Merge Bot <qt_forward_merge_bot@qt-project.org>2019-10-16 01:00:49 +0200
committerQt Forward Merge Bot <qt_forward_merge_bot@qt-project.org>2019-10-16 01:00:49 +0200
commitfaab18c65ab63617c2e03a27a7a03dfae050292f (patch)
tree891a02e8876ee84d999d7d172f0f7c38d174366d /tests/auto
parent06ca5c49e7fb6dd23eab3a02de404c82e03bc5db (diff)
parent9cc040a806fd2e6f1458e801a99311168d594c77 (diff)
Merge remote-tracking branch 'origin/5.14' into 5.15
Diffstat (limited to 'tests/auto')
-rw-r--r--tests/auto/corelib/global/global.pro3
-rw-r--r--tests/auto/corelib/global/qwinregistry/qwinregistry.pro8
-rw-r--r--tests/auto/corelib/global/qwinregistry/tst_qwinregistry.cpp68
-rw-r--r--tests/auto/corelib/io/qfileinfo/tst_qfileinfo.cpp18
-rw-r--r--tests/auto/corelib/io/qsettings/tst_qsettings.cpp43
-rw-r--r--tests/auto/gui/kernel/qtouchevent/tst_qtouchevent.cpp14
-rw-r--r--tests/auto/widgets/graphicsview/qgraphicsitem/tst_qgraphicsitem.cpp2
-rw-r--r--tests/auto/widgets/itemviews/qheaderview/tst_qheaderview.cpp21
-rw-r--r--tests/auto/widgets/kernel/qdesktopwidget/tst_qdesktopwidget.cpp21
-rw-r--r--tests/auto/widgets/kernel/qwidget/tst_qwidget.cpp12
-rw-r--r--tests/auto/widgets/util/qcompleter/tst_qcompleter.cpp4
-rw-r--r--tests/auto/widgets/widgets/qcombobox/tst_qcombobox.cpp10
-rw-r--r--tests/auto/widgets/widgets/qmenubar/tst_qmenubar.cpp5
13 files changed, 156 insertions, 73 deletions
diff --git a/tests/auto/corelib/global/global.pro b/tests/auto/corelib/global/global.pro
index 139e073644..0f77d191ee 100644
--- a/tests/auto/corelib/global/global.pro
+++ b/tests/auto/corelib/global/global.pro
@@ -12,3 +12,6 @@ SUBDIRS=\
qtendian \
qglobalstatic \
qhooks
+
+win32:!winrt: SUBDIRS += \
+ qwinregistry
diff --git a/tests/auto/corelib/global/qwinregistry/qwinregistry.pro b/tests/auto/corelib/global/qwinregistry/qwinregistry.pro
new file mode 100644
index 0000000000..eab5df9dc3
--- /dev/null
+++ b/tests/auto/corelib/global/qwinregistry/qwinregistry.pro
@@ -0,0 +1,8 @@
+CONFIG += testcase
+QT += testlib core-private
+QT -= gui
+
+TARGET = tst_qwinregistry
+CONFIG += console
+
+SOURCES += tst_qwinregistry.cpp
diff --git a/tests/auto/corelib/global/qwinregistry/tst_qwinregistry.cpp b/tests/auto/corelib/global/qwinregistry/tst_qwinregistry.cpp
new file mode 100644
index 0000000000..ac811de2a1
--- /dev/null
+++ b/tests/auto/corelib/global/qwinregistry/tst_qwinregistry.cpp
@@ -0,0 +1,68 @@
+/****************************************************************************
+**
+** Copyright (C) 2019 The Qt Company Ltd.
+** Contact: https://www.qt.io/licensing/
+**
+** This file is part of the test suite of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:GPL-EXCEPT$
+** Commercial License Usage
+** Licensees holding valid commercial Qt licenses may use this file in
+** accordance with the commercial license agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and The Qt Company. For licensing terms
+** and conditions see https://www.qt.io/terms-conditions. For further
+** information use the contact form at https://www.qt.io/contact-us.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 3 as published by the Free Software
+** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
+** included in the packaging of this file. Please review the following
+** information to ensure the GNU General Public License requirements will
+** be met: https://www.gnu.org/licenses/gpl-3.0.html.
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include <QtTest/QtTest>
+
+#include <QtCore/qoperatingsystemversion.h>
+
+#include <QtCore/private/qwinregistry_p.h>
+
+class tst_QWinRegistry : public QObject
+{
+ Q_OBJECT
+
+public Q_SLOTS:
+ void initTestCase();
+
+private Q_SLOTS:
+ void values();
+};
+
+void tst_QWinRegistry::initTestCase()
+{
+ if (QOperatingSystemVersion::current() < QOperatingSystemVersion::Windows10)
+ QSKIP("This test requires registry values present in Windows 10");
+}
+
+void tst_QWinRegistry::values()
+{
+ QWinRegistryKey key(HKEY_LOCAL_MACHINE, LR"(SOFTWARE\Microsoft\Windows NT\CurrentVersion)");
+ QVERIFY(key.isValid());
+ QVERIFY(!key.stringValue(L"ProductName").isEmpty());
+ QVERIFY(key.stringValue(L"NonExistingKey").isEmpty());
+ auto majorVersion = key.dwordValue(L"CurrentMajorVersionNumber");
+ QVERIFY(majorVersion.second);
+ QVERIFY(majorVersion.first > 0);
+ auto nonExistingValue = key.dwordValue(L"NonExistingKey");
+ QVERIFY(!nonExistingValue.second);
+ QCOMPARE(nonExistingValue.first, 0u);
+}
+
+QTEST_APPLESS_MAIN(tst_QWinRegistry);
+
+#include "tst_qwinregistry.moc"
diff --git a/tests/auto/corelib/io/qfileinfo/tst_qfileinfo.cpp b/tests/auto/corelib/io/qfileinfo/tst_qfileinfo.cpp
index 16fcafa248..0597a7d521 100644
--- a/tests/auto/corelib/io/qfileinfo/tst_qfileinfo.cpp
+++ b/tests/auto/corelib/io/qfileinfo/tst_qfileinfo.cpp
@@ -49,6 +49,7 @@
#ifdef Q_OS_WIN
#include <qt_windows.h>
#if !defined(Q_OS_WINRT)
+#include <private/qwinregistry_p.h>
#include <lm.h>
#endif
#endif
@@ -1243,17 +1244,12 @@ void tst_QFileInfo::fileTimes()
//In Vista the last-access timestamp is not updated when the file is accessed/touched (by default).
//To enable this the HKLM\SYSTEM\CurrentControlSet\Control\FileSystem\NtfsDisableLastAccessUpdate
//is set to 0, in the test machine.
- HKEY key;
- if (ERROR_SUCCESS == RegOpenKeyEx(HKEY_LOCAL_MACHINE, L"SYSTEM\\CurrentControlSet\\Control\\FileSystem",
- 0, KEY_READ, &key)) {
- DWORD disabledAccessTimes = 0;
- DWORD size = sizeof(DWORD);
- LONG error = RegQueryValueEx(key, L"NtfsDisableLastAccessUpdate"
- , NULL, NULL, (LPBYTE)&disabledAccessTimes, &size);
- if (ERROR_SUCCESS == error && disabledAccessTimes)
- noAccessTime = true;
- RegCloseKey(key);
- }
+ const auto disabledAccessTimes =
+ QWinRegistryKey(HKEY_LOCAL_MACHINE,
+ LR"(SYSTEM\CurrentControlSet\Control\FileSystem)")
+ .dwordValue(L"NtfsDisableLastAccessUpdate");
+ if (disabledAccessTimes.second && disabledAccessTimes.first != 0)
+ noAccessTime = true;
#endif
if (noAccessTime)
diff --git a/tests/auto/corelib/io/qsettings/tst_qsettings.cpp b/tests/auto/corelib/io/qsettings/tst_qsettings.cpp
index 289590a233..0f07ba4bb2 100644
--- a/tests/auto/corelib/io/qsettings/tst_qsettings.cpp
+++ b/tests/auto/corelib/io/qsettings/tst_qsettings.cpp
@@ -54,6 +54,9 @@
#if defined(Q_OS_WIN)
#include <QtCore/qt_windows.h>
+#ifndef Q_OS_WINRT
+# include <private/qwinregistry_p.h>
+#endif
#else
#include <unistd.h>
#endif
@@ -3623,16 +3626,13 @@ void tst_QSettings::recursionBug()
#if defined(Q_OS_WIN) && !defined(Q_OS_WINRT)
-static DWORD readKeyType(HKEY handle, const QString &rSubKey)
+static DWORD readKeyType(HKEY handle, QStringView rSubKey)
{
DWORD dataType;
DWORD dataSize;
- LONG res = RegQueryValueEx(handle, reinterpret_cast<const wchar_t *>(rSubKey.utf16()), 0, &dataType, 0, &dataSize);
-
- if (res == ERROR_SUCCESS)
- return dataType;
-
- return 0;
+ LONG res = RegQueryValueEx(handle, reinterpret_cast<const wchar_t *>(rSubKey.utf16()),
+ nullptr, &dataType, nullptr, &dataSize);
+ return res == ERROR_SUCCESS ? dataType : 0;
}
// This is a regression test for QTBUG-13249, where QSettings was storing
@@ -3652,29 +3652,12 @@ void tst_QSettings::consistentRegistryStorage()
QCOMPARE(settings1.value("quint64_value").toULongLong(), (quint64)1024);
settings1.sync();
- HKEY handle;
- LONG res;
- QString keyName = "Software\\software.org\\KillerAPP";
- res = RegOpenKeyEx(HKEY_CURRENT_USER, reinterpret_cast<const wchar_t *>(keyName.utf16()), 0, KEY_READ, &handle);
- if (res == ERROR_SUCCESS)
- {
- DWORD dataType;
- dataType = readKeyType(handle, QString("qint32_value"));
- if (dataType != 0) {
- QCOMPARE((int)REG_DWORD, (int)dataType);
- }
- dataType = readKeyType(handle, QString("quint32_value"));
- if (dataType != 0) {
- QCOMPARE((int)REG_DWORD, (int)dataType);
- }
- dataType = readKeyType(handle, QString("qint64_value"));
- if (dataType != 0) {
- QCOMPARE((int)REG_QWORD, (int)dataType);
- }
- dataType = readKeyType(handle, QString("quint64_value"));
- if (dataType != 0) {
- QCOMPARE((int)REG_QWORD, (int)dataType);
- }
+ QWinRegistryKey handle(HKEY_CURRENT_USER, LR"(Software\software.org\KillerAPP)");
+ if (handle.isValid()) {
+ QCOMPARE(readKeyType(handle, L"qint32_value"), DWORD(REG_DWORD));
+ QCOMPARE(readKeyType(handle, L"quint32_value"), DWORD(REG_DWORD));
+ QCOMPARE(readKeyType(handle, L"qint64_value"), DWORD(REG_QWORD));
+ QCOMPARE(readKeyType(handle, L"quint64_value"), DWORD(REG_QWORD));
RegCloseKey(handle);
}
}
diff --git a/tests/auto/gui/kernel/qtouchevent/tst_qtouchevent.cpp b/tests/auto/gui/kernel/qtouchevent/tst_qtouchevent.cpp
index 13dc924f93..54bb8fe0bd 100644
--- a/tests/auto/gui/kernel/qtouchevent/tst_qtouchevent.cpp
+++ b/tests/auto/gui/kernel/qtouchevent/tst_qtouchevent.cpp
@@ -26,7 +26,7 @@
**
****************************************************************************/
-#include <QtWidgets/QDesktopWidget>
+#include <QtGui/QScreen>
#include <QtWidgets/QGraphicsItem>
#include <QtWidgets/QGraphicsScene>
#include <QtWidgets/QGraphicsView>
@@ -617,7 +617,7 @@ void tst_QTouchEvent::basicRawEventTranslation()
QPointF pos = touchWidget.rect().center();
QPointF screenPos = touchWidget.mapToGlobal(pos.toPoint());
QPointF delta(10, 10);
- QRectF screenGeometry = QApplication::desktop()->screenGeometry(&touchWidget);
+ QRectF screenGeometry = touchWidget.screen()->geometry();
QTouchEvent::TouchPoint rawTouchPoint;
rawTouchPoint.setId(0);
@@ -753,7 +753,7 @@ void tst_QTouchEvent::multiPointRawEventTranslationOnTouchScreen()
QPointF leftScreenPos = leftWidget.mapToGlobal(leftPos.toPoint());
QPointF rightScreenPos = rightWidget.mapToGlobal(rightPos.toPoint());
QPointF centerScreenPos = touchWidget.mapToGlobal(centerPos.toPoint());
- QRectF screenGeometry = QApplication::desktop()->screenGeometry(&touchWidget);
+ QRectF screenGeometry = touchWidget.screen()->geometry();
QList<QTouchEvent::TouchPoint> rawTouchPoints;
rawTouchPoints.append(QTouchEvent::TouchPoint(0));
@@ -968,7 +968,7 @@ void tst_QTouchEvent::touchOnMultipleTouchscreens()
QPointF pos = touchWidget.rect().center();
QPointF screenPos = touchWidget.mapToGlobal(pos.toPoint());
QPointF delta(10, 10);
- QRectF screenGeometry = QApplication::desktop()->screenGeometry(&touchWidget);
+ QRectF screenGeometry = touchWidget.screen()->geometry();
QVector<QTouchEvent::TouchPoint> rawTouchPoints(3);
rawTouchPoints[0].setId(0);
@@ -1131,7 +1131,7 @@ void tst_QTouchEvent::multiPointRawEventTranslationOnTouchPad()
QPointF leftScreenPos = leftWidget.mapToGlobal(leftPos.toPoint());
QPointF rightScreenPos = rightWidget.mapToGlobal(rightPos.toPoint());
QPointF centerScreenPos = touchWidget.mapToGlobal(centerPos.toPoint());
- QRectF screenGeometry = QApplication::desktop()->screenGeometry(&touchWidget);
+ QRectF screenGeometry = touchWidget.screen()->geometry();
QList<QTouchEvent::TouchPoint> rawTouchPoints;
rawTouchPoints.append(QTouchEvent::TouchPoint(0));
@@ -1348,7 +1348,7 @@ void tst_QTouchEvent::basicRawEventTranslationOfIds()
screenPos << touchWidget.mapToGlobal(pos[i].toPoint());
}
QPointF delta(10, 10);
- QRectF screenGeometry = QApplication::desktop()->screenGeometry(&touchWidget);
+ QRectF screenGeometry = touchWidget.screen()->geometry();
QVector<QPointF> rawPosList;
rawPosList << QPointF(12, 34) << QPointF(56, 78);
@@ -1629,7 +1629,7 @@ void tst_QTouchEvent::deleteInRawEventTranslation()
QPointF leftScreenPos = leftWidget->mapToGlobal(leftPos.toPoint());
QPointF centerScreenPos = centerWidget->mapToGlobal(centerPos.toPoint());
QPointF rightScreenPos = rightWidget->mapToGlobal(rightPos.toPoint());
- QRectF screenGeometry = QApplication::desktop()->screenGeometry(&touchWidget);
+ QRectF screenGeometry = touchWidget.screen()->geometry();
QList<QTouchEvent::TouchPoint> rawTouchPoints;
rawTouchPoints.append(QTouchEvent::TouchPoint(0));
diff --git a/tests/auto/widgets/graphicsview/qgraphicsitem/tst_qgraphicsitem.cpp b/tests/auto/widgets/graphicsview/qgraphicsitem/tst_qgraphicsitem.cpp
index 864dd9f590..6d415952c9 100644
--- a/tests/auto/widgets/graphicsview/qgraphicsitem/tst_qgraphicsitem.cpp
+++ b/tests/auto/widgets/graphicsview/qgraphicsitem/tst_qgraphicsitem.cpp
@@ -11084,7 +11084,7 @@ static QList<QTouchEvent::TouchPoint>
tp.setStartScreenPos(screenPos);
tp.setLastScreenPos(screenPos);
tp.setEllipseDiameters(ellipseDiameters);
- const QSizeF screenSize = QApplication::desktop()->screenGeometry(&view).size();
+ const QSizeF screenSize = view.screen()->geometry().size();
tp.setNormalizedPos(QPointF(screenPos.x() / screenSize.width(), screenPos.y() / screenSize.height()));
return QList<QTouchEvent::TouchPoint>() << tp;
}
diff --git a/tests/auto/widgets/itemviews/qheaderview/tst_qheaderview.cpp b/tests/auto/widgets/itemviews/qheaderview/tst_qheaderview.cpp
index 3a71b1818b..64bf38d04b 100644
--- a/tests/auto/widgets/itemviews/qheaderview/tst_qheaderview.cpp
+++ b/tests/auto/widgets/itemviews/qheaderview/tst_qheaderview.cpp
@@ -215,6 +215,7 @@ private slots:
void QTBUG14242_hideSectionAutoSize();
void QTBUG50171_visualRegionForSwappedItems();
void QTBUG53221_assertShiftHiddenRow();
+ void QTBUG75615_sizeHintWithStylesheet();
void ensureNoIndexAtLength();
void offsetConsistent();
@@ -2557,6 +2558,26 @@ void tst_QHeaderView::QTBUG53221_assertShiftHiddenRow()
QCOMPARE(tableView.verticalHeader()->isSectionHidden(2), true);
}
+void tst_QHeaderView::QTBUG75615_sizeHintWithStylesheet()
+{
+ QTableView tableView;
+ QStandardItemModel model(1, 1);
+ tableView.setModel(&model);
+ tableView.show();
+
+ const auto headerView = tableView.horizontalHeader();
+ const auto oldSizeHint = headerView->sizeHint();
+ QVERIFY(oldSizeHint.isValid());
+
+ tableView.setStyleSheet("QTableView QHeaderView::section { height: 100px;}");
+ QCOMPARE(headerView->sizeHint().width(), oldSizeHint.width());
+ QCOMPARE(headerView->sizeHint().height(), 100);
+
+ tableView.setStyleSheet("QTableView QHeaderView::section { width: 100px;}");
+ QCOMPARE(headerView->sizeHint().height(), oldSizeHint.height());
+ QCOMPARE(headerView->sizeHint().width(), 100);
+}
+
void protected_QHeaderView::testVisualRegionForSelection()
{
QRegion r = visualRegionForSelection(QItemSelection(model()->index(1, 0), model()->index(1, 2)));
diff --git a/tests/auto/widgets/kernel/qdesktopwidget/tst_qdesktopwidget.cpp b/tests/auto/widgets/kernel/qdesktopwidget/tst_qdesktopwidget.cpp
index 90776dfcb2..a29e8408a3 100644
--- a/tests/auto/widgets/kernel/qdesktopwidget/tst_qdesktopwidget.cpp
+++ b/tests/auto/widgets/kernel/qdesktopwidget/tst_qdesktopwidget.cpp
@@ -42,10 +42,12 @@ class tst_QDesktopWidget : public QObject
private slots:
void cleanup();
+#if QT_DEPRECATED_SINCE(5, 11)
void numScreens();
void primaryScreen();
- void screenNumberForQWidget();
void screenNumberForQPoint();
+#endif
+ void screenNumberForQWidget();
void availableGeometry();
void screenGeometry();
void topLevels();
@@ -56,6 +58,7 @@ void tst_QDesktopWidget::cleanup()
QVERIFY(QApplication::topLevelWidgets().isEmpty());
}
+#if QT_DEPRECATED_SINCE(5, 11)
void tst_QDesktopWidget::numScreens()
{
QDesktopWidget desktop;
@@ -68,14 +71,17 @@ void tst_QDesktopWidget::primaryScreen()
QVERIFY(desktop.primaryScreen() >= 0);
QVERIFY(desktop.primaryScreen() < desktop.numScreens());
}
+#endif
void tst_QDesktopWidget::availableGeometry()
{
QDesktopWidget desktop;
QTest::ignoreMessage(QtWarningMsg, "QDesktopWidget::availableGeometry(): Attempt "
"to get the available geometry of a null widget");
- desktop.availableGeometry((QWidget *)0);
+ QRect r = desktop.availableGeometry(nullptr);
+ QVERIFY(r.isNull());
+#if QT_DEPRECATED_SINCE(5, 11)
QRect total;
QRect available;
@@ -90,13 +96,14 @@ void tst_QDesktopWidget::availableGeometry()
QVERIFY(total.contains(available));
QCOMPARE(desktop.availableGeometry(desktop.primaryScreen()), available);
QCOMPARE(desktop.screenGeometry(desktop.primaryScreen()), total);
+#endif
}
void tst_QDesktopWidget::screenNumberForQWidget()
{
QDesktopWidget desktop;
- QCOMPARE(desktop.screenNumber(0), 0);
+ QCOMPARE(desktop.screenNumber(nullptr), 0);
QWidget widget;
widget.show();
@@ -105,9 +112,10 @@ void tst_QDesktopWidget::screenNumberForQWidget()
int widgetScreen = desktop.screenNumber(&widget);
QVERIFY(widgetScreen > -1);
- QVERIFY(widgetScreen < desktop.numScreens());
+ QVERIFY(widgetScreen < QGuiApplication::screens().size());
}
+#if QT_DEPRECATED_SINCE(5, 11)
void tst_QDesktopWidget::screenNumberForQPoint()
{
// make sure QDesktopWidget::screenNumber(QPoint) returns the correct screen
@@ -131,25 +139,28 @@ void tst_QDesktopWidget::screenNumberForQPoint()
screen = desktopWidget->screenNumber(allScreens.bottomRight() + QPoint(1, 1));
QVERIFY(screen >= 0 && screen < desktopWidget->numScreens());
}
+#endif
void tst_QDesktopWidget::screenGeometry()
{
QDesktopWidget *desktopWidget = QApplication::desktop();
QTest::ignoreMessage(QtWarningMsg, "QDesktopWidget::screenGeometry(): Attempt "
"to get the screen geometry of a null widget");
- QRect r = desktopWidget->screenGeometry((QWidget *)0);
+ QRect r = desktopWidget->screenGeometry(nullptr);
QVERIFY(r.isNull());
QWidget widget;
widget.show();
QVERIFY(QTest::qWaitForWindowExposed(&widget));
r = desktopWidget->screenGeometry(&widget);
+#if QT_DEPRECATED_SINCE(5, 11)
QRect total;
QRect available;
for (int i = 0; i < desktopWidget->screenCount(); ++i) {
total = desktopWidget->screenGeometry(i);
available = desktopWidget->availableGeometry(i);
}
+#endif
}
void tst_QDesktopWidget::topLevels()
diff --git a/tests/auto/widgets/kernel/qwidget/tst_qwidget.cpp b/tests/auto/widgets/kernel/qwidget/tst_qwidget.cpp
index 3e372b76f5..40377eb946 100644
--- a/tests/auto/widgets/kernel/qwidget/tst_qwidget.cpp
+++ b/tests/auto/widgets/kernel/qwidget/tst_qwidget.cpp
@@ -5383,7 +5383,7 @@ void tst_QWidget::moveChild()
parent.setStyle(style.data());
ColorWidget child(&parent, Qt::Widget, Qt::blue);
- parent.setGeometry(QRect(QPoint(QApplication::desktop()->availableGeometry(&parent).topLeft()) + QPoint(50, 50),
+ parent.setGeometry(QRect(parent.screen()->availableGeometry().topLeft() + QPoint(50, 50),
QSize(200, 200)));
child.setGeometry(25, 25, 50, 50);
#ifndef QT_NO_CURSOR // Try to make sure the cursor is not in a taskbar area to prevent tooltips or window highlighting
@@ -5430,8 +5430,7 @@ void tst_QWidget::showAndMoveChild()
const QScopedPointer<QStyle> style(QStyleFactory::create(QLatin1String("Windows")));
parent.setStyle(style.data());
- QDesktopWidget desktop;
- QRect desktopDimensions = desktop.availableGeometry(&parent);
+ QRect desktopDimensions = parent.screen()->availableGeometry();
desktopDimensions = desktopDimensions.adjusted(64, 64, -64, -64);
#ifndef QT_NO_CURSOR // Try to make sure the cursor is not in a taskbar area to prevent tooltips or window highlighting
@@ -7708,7 +7707,7 @@ void tst_QWidget::repaintWhenChildDeleted()
#endif
ColorWidget w(nullptr, Qt::FramelessWindowHint, Qt::red);
w.setWindowTitle(QLatin1String(QTest::currentTestFunction()));
- QPoint startPoint = QApplication::desktop()->availableGeometry(&w).topLeft();
+ QPoint startPoint = w.screen()->availableGeometry().topLeft();
startPoint.rx() += 50;
startPoint.ry() += 50;
w.setGeometry(QRect(startPoint, QSize(100, 100)));
@@ -7733,7 +7732,7 @@ void tst_QWidget::hideOpaqueChildWhileHidden()
{
ColorWidget w(nullptr, Qt::FramelessWindowHint, Qt::red);
w.setWindowTitle(QLatin1String(QTest::currentTestFunction()));
- QPoint startPoint = QApplication::desktop()->availableGeometry(&w).topLeft();
+ QPoint startPoint = w.screen()->availableGeometry().topLeft();
startPoint.rx() += 50;
startPoint.ry() += 50;
w.setGeometry(QRect(startPoint, QSize(100, 100)));
@@ -9601,8 +9600,7 @@ void tst_QWidget::rectOutsideCoordinatesLimit_task144779()
palette.setColor(QPalette::Window, Qt::red);
main.setPalette(palette);
- QDesktopWidget desktop;
- QRect desktopDimensions = desktop.availableGeometry(&main);
+ QRect desktopDimensions = main.screen()->availableGeometry();
QSize mainSize(400, 400);
mainSize = mainSize.boundedTo(desktopDimensions.size());
main.resize(mainSize);
diff --git a/tests/auto/widgets/util/qcompleter/tst_qcompleter.cpp b/tests/auto/widgets/util/qcompleter/tst_qcompleter.cpp
index 4ccbe42353..ec383e42fd 100644
--- a/tests/auto/widgets/util/qcompleter/tst_qcompleter.cpp
+++ b/tests/auto/widgets/util/qcompleter/tst_qcompleter.cpp
@@ -1774,7 +1774,7 @@ void tst_QCompleter::QTBUG_52028_tabAutoCompletes()
auto le = new QLineEdit;
w.layout()->addWidget(le);
- const auto pos = QApplication::desktop()->availableGeometry(&w).topLeft() + QPoint(200,200);
+ const auto pos = w.screen()->availableGeometry().topLeft() + QPoint(200,200);
w.move(pos);
w.show();
QApplication::setActiveWindow(&w);
@@ -1815,7 +1815,7 @@ void tst_QCompleter::QTBUG_51889_activatedSentTwice()
w.layout()->addWidget(new QLineEdit);
- const auto pos = QApplication::desktop()->availableGeometry(&w).topLeft() + QPoint(200,200);
+ const auto pos = w.screen()->availableGeometry().topLeft() + QPoint(200,200);
w.move(pos);
w.show();
QApplication::setActiveWindow(&w);
diff --git a/tests/auto/widgets/widgets/qcombobox/tst_qcombobox.cpp b/tests/auto/widgets/widgets/qcombobox/tst_qcombobox.cpp
index 4e16edaca8..b7869a0653 100644
--- a/tests/auto/widgets/widgets/qcombobox/tst_qcombobox.cpp
+++ b/tests/auto/widgets/widgets/qcombobox/tst_qcombobox.cpp
@@ -34,7 +34,6 @@
#include <qpa/qplatformtheme.h>
#include <qfontcombobox.h>
-#include <qdesktopwidget.h>
#include <qapplication.h>
#include <qpushbutton.h>
#include <qdialog.h>
@@ -2212,15 +2211,13 @@ void tst_QComboBox::itemListPosition()
QFontComboBox combo(&topLevel);
layout->addWidget(&combo);
- //the code to get the available screen space is copied from QComboBox code
- const int scrNumber = QApplication::desktop()->screenNumber(&combo);
bool useFullScreenForPopupMenu = false;
if (const QPlatformTheme *theme = QGuiApplicationPrivate::platformTheme())
useFullScreenForPopupMenu = theme->themeHint(QPlatformTheme::UseFullScreenForPopupMenu).toBool();
const QRect screen = useFullScreenForPopupMenu ?
- QApplication::screens().at(scrNumber)->geometry() :
- QApplication::screens().at(scrNumber)->availableGeometry();
+ combo.screen()->geometry() :
+ combo.screen()->availableGeometry();
topLevel.move(screen.width() - topLevel.sizeHint().width() - 10, 0); //puts the combo to the top-right corner
@@ -2440,8 +2437,7 @@ void tst_QComboBox::task248169_popupWithMinimalSize()
#if defined QT_BUILD_INTERNAL
QFrame *container = comboBox.findChild<QComboBoxPrivateContainer *>();
QVERIFY(container);
- QDesktopWidget desktop;
- QTRY_VERIFY(desktop.screenGeometry(container).contains(container->geometry()));
+ QTRY_VERIFY(container->screen()->geometry().contains(container->geometry()));
#endif
}
diff --git a/tests/auto/widgets/widgets/qmenubar/tst_qmenubar.cpp b/tests/auto/widgets/widgets/qmenubar/tst_qmenubar.cpp
index d6ba85d61f..417d6e3124 100644
--- a/tests/auto/widgets/widgets/qmenubar/tst_qmenubar.cpp
+++ b/tests/auto/widgets/widgets/qmenubar/tst_qmenubar.cpp
@@ -34,7 +34,6 @@
#include <qstyle.h>
#include <qproxystyle.h>
#include <qstylefactory.h>
-#include <qdesktopwidget.h>
#include <qaction.h>
#include <qstyleoption.h>
#include <QVBoxLayout>
@@ -1149,8 +1148,8 @@ void tst_QMenuBar::check_menuPosition()
Menu menu;
menu.setTitle("&menu");
- QRect availRect = QApplication::desktop()->availableGeometry(&w);
- QRect screenRect = QApplication::desktop()->screenGeometry(&w);
+ QRect availRect = w.screen()->availableGeometry();
+ QRect screenRect = w.screen()->geometry();
while(menu.sizeHint().height() < (screenRect.height()*2/3)) {
menu.addAction("item");