diff options
author | Simon Hausmann <simon.hausmann@qt.io> | 2019-10-17 09:41:36 +0200 |
---|---|---|
committer | Simon Hausmann <simon.hausmann@qt.io> | 2019-10-17 09:41:36 +0200 |
commit | 02164e0288f714f1ea93afb32548548686773d1d (patch) | |
tree | d7ed16267f7659af63e78c8de8915ed0208b598b /tests | |
parent | 4a7e7103e713448c05d9d30cab8b7e52406b46a6 (diff) | |
parent | 6f27bb135246b7fe9d11ba58e05d2b7661bc2080 (diff) |
Merge remote-tracking branch 'origin/dev' into wip/cmake
Change-Id: Ia1da879a7bd8f71a649661a1844144dd67d60b3a
Diffstat (limited to 'tests')
21 files changed, 306 insertions, 131 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 34439aa93b..744e047c45 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/corelib/itemmodels/qabstractitemmodel/tst_qabstractitemmodel.cpp b/tests/auto/corelib/itemmodels/qabstractitemmodel/tst_qabstractitemmodel.cpp index f305edb2c5..9fab36deaa 100644 --- a/tests/auto/corelib/itemmodels/qabstractitemmodel/tst_qabstractitemmodel.cpp +++ b/tests/auto/corelib/itemmodels/qabstractitemmodel/tst_qabstractitemmodel.cpp @@ -458,6 +458,34 @@ void tst_QAbstractItemModel::match() res = model.match(start, Qt::DisplayRole, QVariant("bat"), -1, Qt::MatchFixedString | Qt::MatchCaseSensitive); QCOMPARE(res.count(), 1); + + res = model.match(start, Qt::DisplayRole, QVariant(".*O.*"), -1, + Qt::MatchRegularExpression); + QCOMPARE(res.count(), 2); + res = model.match(start, Qt::DisplayRole, QVariant(".*O.*"), -1, + Qt::MatchRegularExpression | Qt::MatchCaseSensitive); + QCOMPARE(res.count(), 0); + + res = model.match(start, Qt::DisplayRole, QVariant(QRegularExpression(".*O.*")), + -1, Qt::MatchRegularExpression); + QCOMPARE(res.count(), 0); + res = model.match(start, + Qt::DisplayRole, + QVariant(QRegularExpression(".*O.*", + QRegularExpression::CaseInsensitiveOption)), + -1, + Qt::MatchRegularExpression); + QCOMPARE(res.count(), 2); + + // Ensure that the case sensitivity is properly ignored when passing a + // QRegularExpression object. + res = model.match(start, + Qt::DisplayRole, + QVariant(QRegularExpression(".*O.*", + QRegularExpression::CaseInsensitiveOption)), + -1, + Qt::MatchRegularExpression | Qt::MatchCaseSensitive); + QCOMPARE(res.count(), 2); } typedef QPair<int, int> Position; 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/dialogs/qfiledialog2/tst_qfiledialog2.cpp b/tests/auto/widgets/dialogs/qfiledialog2/tst_qfiledialog2.cpp index 40eff1e4c3..52354eda42 100644 --- a/tests/auto/widgets/dialogs/qfiledialog2/tst_qfiledialog2.cpp +++ b/tests/auto/widgets/dialogs/qfiledialog2/tst_qfiledialog2.cpp @@ -53,7 +53,10 @@ #include "../../../../../src/widgets/dialogs/qfilesystemmodel_p.h" #include "../../../../../src/widgets/dialogs/qfiledialog_p.h" +#include <private/qguiapplication_p.h> + #include <qpa/qplatformdialoghelper.h> +#include <qpa/qplatformintegration.h> #if defined(Q_OS_WIN) #include "../../../network-settings.h" @@ -365,7 +368,7 @@ void tst_QFileDialog2::task143519_deleteAndRenameActionBehavior() fd.selectFile(ctx.file.fileName()); fd.show(); - QVERIFY(QTest::qWaitForWindowActive(&fd)); + QVERIFY(QTest::qWaitForWindowExposed(&fd)); // grab some internals: QAction *rm = fd.findChild<QAction*>("qt_delete_action"); @@ -548,7 +551,7 @@ void tst_QFileDialog2::task227304_proxyOnFileDialog() QFileDialog fd(0, "", QDir::currentPath(), 0); fd.setProxyModel(new FilterDirModel(QDir::currentPath())); fd.show(); - QVERIFY(QTest::qWaitForWindowActive(&fd)); + QVERIFY(QTest::qWaitForWindowExposed(&fd)); QLineEdit *edit = fd.findChild<QLineEdit*>("fileNameEdit"); QVERIFY(edit); QTest::keyClick(edit, Qt::Key_T); @@ -558,7 +561,7 @@ void tst_QFileDialog2::task227304_proxyOnFileDialog() CrashDialog *dialog = new CrashDialog(0, QString("crash dialog test"), QDir::homePath(), QString("*") ); dialog->setFileMode(QFileDialog::ExistingFile); dialog->show(); - QVERIFY(QTest::qWaitForWindowActive(dialog)); + QVERIFY(QTest::qWaitForWindowExposed(dialog)); QListView *list = dialog->findChild<QListView*>("listView"); QVERIFY(list); @@ -600,7 +603,7 @@ void tst_QFileDialog2::task227930_correctNavigationKeyboardBehavior() fd.setViewMode(QFileDialog::List); fd.setDirectory(current.absolutePath()); fd.show(); - QVERIFY(QTest::qWaitForWindowActive(&fd)); + QVERIFY(QTest::qWaitForWindowExposed(&fd)); // Ensure LayoutRequest event is processed so that the list view // is sorted correctly to have the directory entires at the top. @@ -765,7 +768,7 @@ void tst_QFileDialog2::task235069_hideOnEscape() fd.setDirectory(current.absolutePath()); fd.setAcceptMode(QFileDialog::AcceptSave); fd.show(); - QVERIFY(QTest::qWaitForWindowActive(&fd)); + QVERIFY(QTest::qWaitForWindowExposed(&fd)); QWidget *child = fd.findChild<QWidget *>(childName); QVERIFY(child); child->setFocus(); @@ -787,7 +790,7 @@ void tst_QFileDialog2::task236402_dontWatchDeletedDir() fd.setDirectory(current.absolutePath()); fd.setAcceptMode( QFileDialog::AcceptSave); fd.show(); - QVERIFY(QTest::qWaitForWindowActive(&fd)); + QVERIFY(QTest::qWaitForWindowExposed(&fd)); QListView *list = fd.findChild<QListView*>("listView"); QVERIFY(list); list->setFocus(); @@ -808,7 +811,7 @@ void tst_QFileDialog2::task203703_returnProperSeparator() fd.setViewMode(QFileDialog::List); fd.setFileMode(QFileDialog::Directory); fd.show(); - QVERIFY(QTest::qWaitForWindowActive(&fd)); + QVERIFY(QTest::qWaitForWindowExposed(&fd)); QListView *list = fd.findChild<QListView*>("listView"); QVERIFY(list); list->setFocus(); @@ -844,7 +847,7 @@ void tst_QFileDialog2::task228844_ensurePreviousSorting() fd.setDirectory(current.absolutePath()); fd.setViewMode(QFileDialog::Detail); fd.show(); - QVERIFY(QTest::qWaitForWindowActive(&fd)); + QVERIFY(QTest::qWaitForWindowExposed(&fd)); QTreeView *tree = fd.findChild<QTreeView*>("treeView"); QVERIFY(tree); tree->header()->setSortIndicator(3,Qt::DescendingOrder); @@ -859,7 +862,7 @@ void tst_QFileDialog2::task228844_ensurePreviousSorting() current.cd("aaaaaaaaaaaaaaaaaa"); fd2.setDirectory(current.absolutePath()); fd2.show(); - QVERIFY(QTest::qWaitForWindowActive(&fd2)); + QVERIFY(QTest::qWaitForWindowExposed(&fd2)); QTreeView *tree2 = fd2.findChild<QTreeView*>("treeView"); QVERIFY(tree2); tree2->setFocus(); @@ -878,7 +881,7 @@ void tst_QFileDialog2::task228844_ensurePreviousSorting() fd3.restoreState(fd.saveState()); fd3.setFileMode(QFileDialog::Directory); fd3.show(); - QVERIFY(QTest::qWaitForWindowActive(&fd3)); + QVERIFY(QTest::qWaitForWindowExposed(&fd3)); QTreeView *tree3 = fd3.findChild<QTreeView*>("treeView"); QVERIFY(tree3); tree3->setFocus(); @@ -912,7 +915,7 @@ void tst_QFileDialog2::task239706_editableFilterCombo() QFileDialog d; d.setNameFilter("*.cpp *.h"); d.show(); - QVERIFY(QTest::qWaitForWindowActive(&d)); + QVERIFY(QTest::qWaitForWindowExposed(&d)); QList<QComboBox *> comboList = d.findChildren<QComboBox *>(); QComboBox *filterCombo = 0; @@ -963,7 +966,7 @@ void tst_QFileDialog2::task251321_sideBarHiddenEntries() urls << QUrl::fromLocalFile(hiddenSubDir.absolutePath()); fd.setSidebarUrls(urls); fd.show(); - QVERIFY(QTest::qWaitForWindowActive(&fd)); + QVERIFY(QTest::qWaitForWindowExposed(&fd)); QSidebar *sidebar = fd.findChild<QSidebar*>("sidebar"); QVERIFY(sidebar); @@ -1017,7 +1020,7 @@ void tst_QFileDialog2::task251341_sideBarRemoveEntries() urls << QUrl::fromLocalFile("NotFound"); fd.setSidebarUrls(urls); fd.show(); - QVERIFY(QTest::qWaitForWindowActive(&fd)); + QVERIFY(QTest::qWaitForWindowExposed(&fd)); QSidebar *sidebar = fd.findChild<QSidebar*>("sidebar"); QVERIFY(sidebar); @@ -1089,7 +1092,7 @@ void tst_QFileDialog2::task254490_selectFileMultipleTimes() fd.selectFile("new_file.txt"); fd.show(); - QVERIFY(QTest::qWaitForWindowActive(&fd)); + QVERIFY(QTest::qWaitForWindowExposed(&fd)); QLineEdit *lineEdit = fd.findChild<QLineEdit*>("fileNameEdit"); QVERIFY(lineEdit); @@ -1133,7 +1136,7 @@ void tst_QFileDialog2::task259105_filtersCornerCases() fd.setNameFilter(QLatin1String("All Files! (*);;Text Files (*.txt)")); fd.setOption(QFileDialog::HideNameFilterDetails, true); fd.show(); - QVERIFY(QTest::qWaitForWindowActive(&fd)); + QVERIFY(QTest::qWaitForWindowExposed(&fd)); //Extensions are hidden QComboBox *filters = fd.findChild<QComboBox*>("fileTypeCombo"); @@ -1170,6 +1173,9 @@ void tst_QFileDialog2::task259105_filtersCornerCases() void tst_QFileDialog2::QTBUG4419_lineEditSelectAll() { + if (!QGuiApplicationPrivate::platformIntegration()->hasCapability(QPlatformIntegration::WindowActivation)) + QSKIP("Window activation is not supported"); + QString tempPath = tempDir.path(); QTemporaryFile temporaryFile(tempPath + "/tst_qfiledialog2_lineEditSelectAll.XXXXXX"); QVERIFY2(temporaryFile.open(), qPrintable(temporaryFile.errorString())); @@ -1195,6 +1201,9 @@ void tst_QFileDialog2::QTBUG4419_lineEditSelectAll() void tst_QFileDialog2::QTBUG6558_showDirsOnly() { + if (!QGuiApplicationPrivate::platformIntegration()->hasCapability(QPlatformIntegration::WindowActivation)) + QSKIP("Window activation is not supported"); + const QString tempPath = tempDir.path(); QDir dirTemp(tempPath); const QString tempName = QLatin1String("showDirsOnly.") + QString::number(QRandomGenerator::global()->generate()); @@ -1261,6 +1270,9 @@ void tst_QFileDialog2::QTBUG6558_showDirsOnly() void tst_QFileDialog2::QTBUG4842_selectFilterWithHideNameFilterDetails() { + if (!QGuiApplicationPrivate::platformIntegration()->hasCapability(QPlatformIntegration::WindowActivation)) + QSKIP("Window activation is not supported"); + QStringList filtersStr; filtersStr << "Images (*.png *.xpm *.jpg)" << "Text files (*.txt)" << "XML files (*.xml)"; QString chosenFilterString("Text files (*.txt)"); @@ -1301,6 +1313,9 @@ void tst_QFileDialog2::QTBUG4842_selectFilterWithHideNameFilterDetails() void tst_QFileDialog2::dontShowCompleterOnRoot() { + if (!QGuiApplicationPrivate::platformIntegration()->hasCapability(QPlatformIntegration::WindowActivation)) + QSKIP("Window activation is not supported"); + QFileDialog fd(0, "TestFileDialog"); fd.setAcceptMode(QFileDialog::AcceptSave); fd.show(); diff --git a/tests/auto/widgets/effects/qgraphicseffect/tst_qgraphicseffect.cpp b/tests/auto/widgets/effects/qgraphicseffect/tst_qgraphicseffect.cpp index c4b6e22c37..19288d07a7 100644 --- a/tests/auto/widgets/effects/qgraphicseffect/tst_qgraphicseffect.cpp +++ b/tests/auto/widgets/effects/qgraphicseffect/tst_qgraphicseffect.cpp @@ -311,7 +311,7 @@ void tst_QGraphicsEffect::draw() QGraphicsView view(&scene); view.show(); - QVERIFY(QTest::qWaitForWindowActive(&view)); + QVERIFY(QTest::qWaitForWindowExposed(&view)); QTRY_VERIFY(item->numRepaints > 0); QCoreApplication::processEvents(); // Process all queued paint events item->reset(); @@ -668,8 +668,7 @@ void tst_QGraphicsEffect::childrenVisibilityShouldInvalidateCache() scene.addItem(&parent); QGraphicsView view(&scene); view.show(); - QApplication::setActiveWindow(&view); - QVERIFY(QTest::qWaitForWindowActive(&view)); + QVERIFY(QTest::qWaitForWindowExposed(&view)); QTRY_VERIFY(parent.nbPaint >= 1); //we set an effect on the parent parent.setGraphicsEffect(new QGraphicsDropShadowEffect(&parent)); @@ -694,8 +693,7 @@ void tst_QGraphicsEffect::prepareGeometryChangeInvalidateCache() QGraphicsView view(&scene); view.show(); - qApp->setActiveWindow(&view); - QVERIFY(QTest::qWaitForWindowActive(&view)); + QVERIFY(QTest::qWaitForWindowExposed(&view)); QTRY_VERIFY(item->nbPaint >= 1); item->nbPaint = 0; @@ -726,8 +724,7 @@ void tst_QGraphicsEffect::itemHasNoContents() QGraphicsView view(&scene); view.show(); - qApp->setActiveWindow(&view); - QVERIFY(QTest::qWaitForWindowActive(&view)); + QVERIFY(QTest::qWaitForWindowExposed(&view)); QTRY_VERIFY(child->nbPaint >= 1); CustomEffect *effect = new CustomEffect; diff --git a/tests/auto/widgets/graphicsview/qgraphicsitem/tst_qgraphicsitem.cpp b/tests/auto/widgets/graphicsview/qgraphicsitem/tst_qgraphicsitem.cpp index 5d380c899b..6d415952c9 100644 --- a/tests/auto/widgets/graphicsview/qgraphicsitem/tst_qgraphicsitem.cpp +++ b/tests/auto/widgets/graphicsview/qgraphicsitem/tst_qgraphicsitem.cpp @@ -1003,6 +1003,9 @@ class ImhTester : public QGraphicsItem void tst_QGraphicsItem::inputMethodHints() { + if (!QGuiApplicationPrivate::platformIntegration()->hasCapability(QPlatformIntegration::WindowActivation)) + QSKIP("Window activation is not supported"); + ImhTester *item = new ImhTester; item->setFlag(QGraphicsItem::ItemAcceptsInputMethod, true); item->setFlag(QGraphicsItem::ItemIsFocusable, true); @@ -1055,6 +1058,9 @@ void tst_QGraphicsItem::inputMethodHints() void tst_QGraphicsItem::toolTip() { + if (!QGuiApplicationPrivate::platformIntegration()->hasCapability(QPlatformIntegration::WindowActivation)) + QSKIP("Window activation is not supported"); + QString toolTip = "Qt rocks!"; QGraphicsRectItem *item = new QGraphicsRectItem(QRectF(0, 0, 100, 100)); @@ -1764,7 +1770,9 @@ void tst_QGraphicsItem::selected_multi() view.setWindowTitle(QLatin1String(QTest::currentTestFunction())); view.show(); view.fitInView(scene.sceneRect()); - QVERIFY(QTest::qWaitForWindowActive(&view)); + QVERIFY(QTest::qWaitForWindowExposed(&view)); + if (QGuiApplicationPrivate::platformIntegration()->hasCapability(QPlatformIntegration::WindowActivation)) + QVERIFY(QTest::qWaitForWindowActive(&view)); QVERIFY(!item1->isSelected()); QVERIFY(!item2->isSelected()); @@ -3267,7 +3275,8 @@ void tst_QGraphicsItem::hoverEventsGenerateRepaints() view.setWindowTitle(QLatin1String(QTest::currentTestFunction())); view.show(); QVERIFY(QTest::qWaitForWindowExposed(&view)); - QVERIFY(QTest::qWaitForWindowActive(&view)); + if (QGuiApplicationPrivate::platformIntegration()->hasCapability(QPlatformIntegration::WindowActivation)) + QVERIFY(QTest::qWaitForWindowActive(&view)); QCoreApplication::processEvents(); // Process all queued paint events EventTester *tester = new EventTester; @@ -4994,6 +5003,9 @@ protected: void tst_QGraphicsItem::sceneEventFilter() { + if (!QGuiApplicationPrivate::platformIntegration()->hasCapability(QPlatformIntegration::WindowActivation)) + QSKIP("Window activation is not supported"); + QGraphicsScene scene; QGraphicsView view(&scene); @@ -6887,7 +6899,8 @@ void tst_QGraphicsItem::opacity2() view.setWindowTitle(QLatin1String(QTest::currentTestFunction())); view.show(); QVERIFY(QTest::qWaitForWindowExposed(&view)); - QVERIFY(QTest::qWaitForWindowActive(&view)); + if (QGuiApplicationPrivate::platformIntegration()->hasCapability(QPlatformIntegration::WindowActivation)) + QVERIFY(QTest::qWaitForWindowActive(&view)); QCoreApplication::processEvents(); // Process all queued paint events QTRY_VERIFY(view.repaints >= 1); @@ -6962,7 +6975,8 @@ void tst_QGraphicsItem::opacityZeroUpdates() view.setWindowTitle(QLatin1String(QTest::currentTestFunction())); view.show(); QVERIFY(QTest::qWaitForWindowExposed(&view)); - QVERIFY(QTest::qWaitForWindowActive(&view)); + if (QGuiApplicationPrivate::platformIntegration()->hasCapability(QPlatformIntegration::WindowActivation)) + QVERIFY(QTest::qWaitForWindowActive(&view)); QCoreApplication::processEvents(); // Process all queued paint events QTRY_VERIFY(view.repaints > 0); @@ -7297,6 +7311,9 @@ void tst_QGraphicsItem::tabChangesFocus_data() void tst_QGraphicsItem::tabChangesFocus() { + if (!QGuiApplicationPrivate::platformIntegration()->hasCapability(QPlatformIntegration::WindowActivation)) + QSKIP("Window activation is not supported"); + QFETCH(bool, tabChangesFocus); QGraphicsScene scene; @@ -7344,6 +7361,9 @@ void tst_QGraphicsItem::tabChangesFocus() void tst_QGraphicsItem::cacheMode() { + if (QGuiApplication::platformName().startsWith(QLatin1String("wayland"), Qt::CaseInsensitive)) + QSKIP("Wayland: This fails. Figure out why."); + QGraphicsScene scene(0, 0, 100, 100); QGraphicsView view(&scene); view.setWindowTitle(QLatin1String(QTest::currentTestFunction())); @@ -7525,6 +7545,9 @@ void tst_QGraphicsItem::cacheMode() void tst_QGraphicsItem::cacheMode2() { + if (QGuiApplication::platformName().startsWith(QLatin1String("wayland"), Qt::CaseInsensitive)) + QSKIP("Wayland: This fails. Figure out why."); + QGraphicsScene scene(0, 0, 100, 100); QGraphicsView view(&scene); view.setWindowTitle(QLatin1String(QTest::currentTestFunction())); @@ -8192,7 +8215,8 @@ void tst_QGraphicsItem::moveLineItem() view.setWindowTitle(QLatin1String(QTest::currentTestFunction())); view.show(); QVERIFY(QTest::qWaitForWindowExposed(&view)); - QVERIFY(QTest::qWaitForWindowActive(&view)); + if (QGuiApplicationPrivate::platformIntegration()->hasCapability(QPlatformIntegration::WindowActivation)) + QVERIFY(QTest::qWaitForWindowActive(&view)); QCoreApplication::processEvents(); // Process all queued paint events view.reset(); @@ -8264,9 +8288,11 @@ void tst_QGraphicsItem::sorting() view.resize(120, 100); view.setFrameStyle(0); view.show(); - qApp->setActiveWindow(&view); + if (QGuiApplicationPrivate::platformIntegration()->hasCapability(QPlatformIntegration::WindowActivation)) { + qApp->setActiveWindow(&view); + QVERIFY(QTest::qWaitForWindowActive(&view)); + } QVERIFY(QTest::qWaitForWindowExposed(&view)); - QVERIFY(QTest::qWaitForWindowActive(&view)); QTRY_VERIFY(_paintedItems.count() > 0); _paintedItems.clear(); @@ -8302,9 +8328,11 @@ void tst_QGraphicsItem::itemHasNoContents() QGraphicsView view(&scene); view.setWindowTitle(QLatin1String(QTest::currentTestFunction())); view.show(); - qApp->setActiveWindow(&view); + if (QGuiApplicationPrivate::platformIntegration()->hasCapability(QPlatformIntegration::WindowActivation)) { + qApp->setActiveWindow(&view); + QVERIFY(QTest::qWaitForWindowActive(&view)); + } QVERIFY(QTest::qWaitForWindowExposed(&view)); - QVERIFY(QTest::qWaitForWindowActive(&view)); QTRY_VERIFY(!_paintedItems.isEmpty()); _paintedItems.clear(); @@ -9326,10 +9354,12 @@ void tst_QGraphicsItem::ensureDirtySceneTransform() QGraphicsView view(&scene); view.setWindowTitle(QLatin1String(QTest::currentTestFunction())); view.show(); - QApplication::setActiveWindow(&view); + if (QGuiApplicationPrivate::platformIntegration()->hasCapability(QPlatformIntegration::WindowActivation)) { + QApplication::setActiveWindow(&view); + QVERIFY(QTest::qWaitForWindowActive(&view)); + QCOMPARE(QApplication::activeWindow(), static_cast<QWidget *>(&view)); + } QVERIFY(QTest::qWaitForWindowExposed(&view)); - QVERIFY(QTest::qWaitForWindowActive(&view)); - QCOMPARE(QApplication::activeWindow(), static_cast<QWidget *>(&view)); //We move the parent parent->move(); @@ -9710,6 +9740,9 @@ void tst_QGraphicsItem::stackBefore() void tst_QGraphicsItem::QTBUG_4233_updateCachedWithSceneRect() { + if (!QGuiApplicationPrivate::platformIntegration()->hasCapability(QPlatformIntegration::WindowActivation)) + QSKIP("Window activation is not supported"); + EventTester *tester = new EventTester; tester->setCacheMode(QGraphicsItem::ItemCoordinateCache); @@ -10782,6 +10815,9 @@ void tst_QGraphicsItem::scenePosChange() void tst_QGraphicsItem::textItem_shortcuts() { + if (!QGuiApplicationPrivate::platformIntegration()->hasCapability(QPlatformIntegration::WindowActivation)) + QSKIP("Window activation is not supported"); + QWidget w; w.setWindowTitle(QLatin1String(QTest::currentTestFunction())); auto l = new QVBoxLayout(&w); @@ -10847,7 +10883,8 @@ void tst_QGraphicsItem::scroll() view.setFrameStyle(0); view.show(); QVERIFY(QTest::qWaitForWindowExposed(&view)); - QVERIFY(QTest::qWaitForWindowActive(&view)); + if (QGuiApplicationPrivate::platformIntegration()->hasCapability(QPlatformIntegration::WindowActivation)) + QVERIFY(QTest::qWaitForWindowActive(&view)); QTRY_VERIFY(view.repaints > 0); view.reset(); @@ -11047,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; } @@ -11373,9 +11410,11 @@ void tst_QGraphicsItem::QTBUG_6738_missingUpdateWithSetParent() MyGraphicsView view(&scene); view.setWindowTitle(QLatin1String(QTest::currentTestFunction())); view.show(); - qApp->setActiveWindow(&view); + if (QGuiApplicationPrivate::platformIntegration()->hasCapability(QPlatformIntegration::WindowActivation)) { + qApp->setActiveWindow(&view); + QVERIFY(QTest::qWaitForWindowActive(&view)); + } QVERIFY(QTest::qWaitForWindowExposed(&view)); - QVERIFY(QTest::qWaitForWindowActive(&view)); QCoreApplication::processEvents(); // Process all queued paint events QTRY_VERIFY(view.repaints > 0); @@ -11426,7 +11465,8 @@ void tst_QGraphicsItem::QT_2653_fullUpdateDiscardingOpacityUpdate() view.show(); QVERIFY(QTest::qWaitForWindowExposed(&view)); - QVERIFY(QTest::qWaitForWindowActive(&view)); + if (QGuiApplicationPrivate::platformIntegration()->hasCapability(QPlatformIntegration::WindowActivation)) + QVERIFY(QTest::qWaitForWindowActive(&view)); QCoreApplication::processEvents(); // Process all queued paint events view.reset(); @@ -11461,7 +11501,9 @@ void tst_QGraphicsItem::QTBUG_7714_fullUpdateDiscardingOpacityUpdate2() scene.addItem(parentGreen); origView.show(); - QVERIFY(QTest::qWaitForWindowActive(&origView)); + if (QGuiApplicationPrivate::platformIntegration()->hasCapability(QPlatformIntegration::WindowActivation)) + QVERIFY(QTest::qWaitForWindowActive(&origView)); + QVERIFY(QTest::qWaitForWindowExposed(&origView)); QCoreApplication::processEvents(); // Process all queued paint events origView.setGeometry(origView.x() + origView.width() + 20, origView.y() + 20, @@ -11475,9 +11517,11 @@ void tst_QGraphicsItem::QTBUG_7714_fullUpdateDiscardingOpacityUpdate2() QTRY_VERIFY(origView.repaints > 0); view.show(); - qApp->setActiveWindow(&view); + if (QGuiApplicationPrivate::platformIntegration()->hasCapability(QPlatformIntegration::WindowActivation)) { + qApp->setActiveWindow(&view); + QVERIFY(QTest::qWaitForWindowActive(&view)); + } QVERIFY(QTest::qWaitForWindowExposed(&view)); - QVERIFY(QTest::qWaitForWindowActive(&view)); view.reset(); origView.reset(); @@ -11591,6 +11635,9 @@ void tst_QGraphicsItem::sortItemsWhileAdding() void tst_QGraphicsItem::doNotMarkFullUpdateIfNotInScene() { + if (!QGuiApplicationPrivate::platformIntegration()->hasCapability(QPlatformIntegration::WindowActivation)) + QSKIP("Window activation is not supported"); + struct Item : public QGraphicsTextItem { int painted = 0; @@ -11649,10 +11696,12 @@ void tst_QGraphicsItem::itemDiesDuringDraggingOperation() item->setAcceptDrops(true); scene.addItem(item); view.show(); - QApplication::setActiveWindow(&view); + if (QGuiApplicationPrivate::platformIntegration()->hasCapability(QPlatformIntegration::WindowActivation)) { + QApplication::setActiveWindow(&view); + QVERIFY(QTest::qWaitForWindowActive(&view)); + QCOMPARE(QApplication::activeWindow(), &view); + } QVERIFY(QTest::qWaitForWindowExposed(&view)); - QVERIFY(QTest::qWaitForWindowActive(&view)); - QCOMPARE(QApplication::activeWindow(), &view); QGraphicsSceneDragDropEvent dragEnter(QEvent::GraphicsSceneDragEnter); dragEnter.setScenePos(item->boundingRect().center()); QCoreApplication::sendEvent(&scene, &dragEnter); @@ -11678,10 +11727,12 @@ void tst_QGraphicsItem::QTBUG_12112_focusItem() scene.addItem(item1); view.show(); - QApplication::setActiveWindow(&view); + if (QGuiApplicationPrivate::platformIntegration()->hasCapability(QPlatformIntegration::WindowActivation)) { + QApplication::setActiveWindow(&view); + QVERIFY(QTest::qWaitForWindowActive(&view)); + QCOMPARE(QApplication::activeWindow(), &view); + } QVERIFY(QTest::qWaitForWindowExposed(&view)); - QVERIFY(QTest::qWaitForWindowActive(&view)); - QCOMPARE(QApplication::activeWindow(), &view); QVERIFY(item1->focusItem()); QVERIFY(!item2->focusItem()); diff --git a/tests/auto/widgets/itemviews/qheaderview/tst_qheaderview.cpp b/tests/auto/widgets/itemviews/qheaderview/tst_qheaderview.cpp index df1b271f2a..4f4e2194a5 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/qabstractscrollarea/tst_qabstractscrollarea.cpp b/tests/auto/widgets/widgets/qabstractscrollarea/tst_qabstractscrollarea.cpp index a17a9f6c33..01ecfb2ca9 100644 --- a/tests/auto/widgets/widgets/qabstractscrollarea/tst_qabstractscrollarea.cpp +++ b/tests/auto/widgets/widgets/qabstractscrollarea/tst_qabstractscrollarea.cpp @@ -356,7 +356,7 @@ void tst_QAbstractScrollArea::patternBackground() widget.resize(600, 600); scrollArea.setWidget(&widget); topLevel.show(); - QVERIFY(QTest::qWaitForWindowActive(&topLevel)); + QVERIFY(QTest::qWaitForWindowExposed(&topLevel)); QLinearGradient linearGrad(QPointF(250, 250), QPointF(300, 300)); linearGrad.setColorAt(0, Qt::yellow); 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"); diff --git a/tests/manual/dialogs/printdialogpanel.cpp b/tests/manual/dialogs/printdialogpanel.cpp index 8d64d2f6a6..b7447e3d64 100644 --- a/tests/manual/dialogs/printdialogpanel.cpp +++ b/tests/manual/dialogs/printdialogpanel.cpp @@ -710,8 +710,7 @@ void PrintDialogPanel::showPreviewDialog() applySettings(m_printer.data()); PrintPreviewDialog dialog(m_printer.data(), this); #if QT_VERSION >= 0x050000 - const int screenNumber = QApplication::desktop()->screenNumber(this); - const QSize availableSize = QGuiApplication::screens().at(screenNumber)->availableSize(); + const QSize availableSize = screen()->availableSize(); #else const QSize availableSize = QApplication::desktop()->availableGeometry().size(); #endif diff --git a/tests/manual/qcursor/qcursorhighdpi/main.cpp b/tests/manual/qcursor/qcursorhighdpi/main.cpp index 3b18bff91c..e70be333fd 100644 --- a/tests/manual/qcursor/qcursorhighdpi/main.cpp +++ b/tests/manual/qcursor/qcursorhighdpi/main.cpp @@ -218,7 +218,7 @@ protected: VerticalRuler::VerticalRuler(QWidget *parent) : QWidget(parent) { - const int screenWidth = QApplication::desktop()->screenGeometry(this).width(); + const int screenWidth = screen()->geometry().width(); setFixedWidth(screenWidth / 48); // 1920 pixel monitor ->40 } @@ -356,15 +356,12 @@ int main(int argc, char *argv[]) QApplication app(argc, argv); MainWindowPtrList windows; - - QDesktopWidget *desktopWidget = app.desktop(); - const int lastScreen = arguments.contains("-p") ? 0 // Primary screen only - : desktopWidget->screenCount() - 1; // All screens + : QGuiApplication::screens().size() - 1; // All screens for (int s = lastScreen; s >= 0; --s) { - MainWindowPtr window(new MainWindow(desktopWidget->screen(s))); - const QPoint pos = desktopWidget->screenGeometry(s).center() - QPoint(200, 100); + MainWindowPtr window(new MainWindow()); + const QPoint pos = QGuiApplication::screens().at(s)->geometry().center() - QPoint(200, 100); window->move(pos); windows.append(window); window->show(); diff --git a/tests/manual/qdesktopwidget/main.cpp b/tests/manual/qdesktopwidget/main.cpp index f4c82c5f72..978dc62b0e 100644 --- a/tests/manual/qdesktopwidget/main.cpp +++ b/tests/manual/qdesktopwidget/main.cpp @@ -34,6 +34,7 @@ class DesktopView : public QGraphicsView { +#if QT_DEPRECATED_SINCE(5, 11) Q_OBJECT public: DesktopView() @@ -195,6 +196,7 @@ private: QGraphicsScene *scene; QGraphicsRectItem *that; QPoint thatRoot; +#endif }; #include "main.moc" diff --git a/tests/manual/qscreen/main.cpp b/tests/manual/qscreen/main.cpp index 6fba872b12..0728d66bf9 100644 --- a/tests/manual/qscreen/main.cpp +++ b/tests/manual/qscreen/main.cpp @@ -61,8 +61,10 @@ public: QLatin1String("Left-click to test QGuiApplication::topLevelAt(click pos)\nRight-click to ungrab\n") : QLatin1String("Left-click to grab mouse\n"); if (!m_cursorPos.isNull()) { + const auto screen = QGuiApplication::screenAt(m_cursorPos); + const auto screenNum = screen ? QGuiApplication::screens().indexOf(screen) : 0; txt += QString(QLatin1String("Current mouse position: %1, %2 on screen %3\n")) - .arg(m_cursorPos.x()).arg(m_cursorPos.y()).arg(QApplication::desktop()->screenNumber(m_cursorPos)); + .arg(m_cursorPos.x()).arg(m_cursorPos.y()).arg(screenNum); if (QGuiApplication::mouseButtons() & Qt::LeftButton) { QWindow *win = QGuiApplication::topLevelAt(m_cursorPos); txt += QString(QLatin1String("Top-level window found? %1\n")) @@ -234,6 +236,7 @@ void screenAdded(QScreen* screen) QList<QScreen *> screens = QGuiApplication::screens(); int screenNumber = screens.indexOf(screen); Q_ASSERT(screenNumber >= 0); + // ### Qt 6: Find a replacement for QDesktopWidget::screen() w->setParent(qApp->desktop()->screen(screenNumber)); w->show(); |