summaryrefslogtreecommitdiffstats
path: root/tests/auto/widgets
diff options
context:
space:
mode:
Diffstat (limited to 'tests/auto/widgets')
-rw-r--r--tests/auto/widgets/dialogs/qfiledialog2/tst_qfiledialog2.cpp45
-rw-r--r--tests/auto/widgets/effects/qgraphicseffect/tst_qgraphicseffect.cpp11
-rw-r--r--tests/auto/widgets/graphicsview/qgraphicsitem/tst_qgraphicsitem.cpp103
-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/qabstractscrollarea/tst_qabstractscrollarea.cpp2
-rw-r--r--tests/auto/widgets/widgets/qcombobox/tst_qcombobox.cpp10
-rw-r--r--tests/auto/widgets/widgets/qmenubar/tst_qmenubar.cpp5
10 files changed, 161 insertions, 73 deletions
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");