diff options
Diffstat (limited to 'tests/auto')
16 files changed, 215 insertions, 89 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/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 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"); |