summaryrefslogtreecommitdiffstats
path: root/tests/auto/widgets
diff options
context:
space:
mode:
Diffstat (limited to 'tests/auto/widgets')
-rw-r--r--tests/auto/widgets/dialogs/qdialog/tst_qdialog.cpp3
-rw-r--r--tests/auto/widgets/effects/qgraphicseffect/tst_qgraphicseffect.cpp1
-rw-r--r--tests/auto/widgets/itemviews/qfileiconprovider/tst_qfileiconprovider.cpp12
-rw-r--r--tests/auto/widgets/itemviews/qlistview/tst_qlistview.cpp4
-rw-r--r--tests/auto/widgets/itemviews/qtreeview/tst_qtreeview.cpp24
-rw-r--r--tests/auto/widgets/kernel/qapplication/tst_qapplication.cpp5
-rw-r--r--tests/auto/widgets/kernel/qgridlayout/tst_qgridlayout.cpp51
-rw-r--r--tests/auto/widgets/kernel/qshortcut/CMakeLists.txt1
-rw-r--r--tests/auto/widgets/kernel/qshortcut/tst_qshortcut.cpp8
-rw-r--r--tests/auto/widgets/kernel/qwidget/BLACKLIST2
-rw-r--r--tests/auto/widgets/kernel/qwidget/tst_qwidget.cpp33
-rw-r--r--tests/auto/widgets/kernel/qwidget_window/tst_qwidget_window.cpp5
-rw-r--r--tests/auto/widgets/widgets/qdial/tst_qdial.cpp31
-rw-r--r--tests/auto/widgets/widgets/qdockwidget/tst_qdockwidget.cpp6
-rw-r--r--tests/auto/widgets/widgets/qdoublespinbox/tst_qdoublespinbox.cpp56
-rw-r--r--tests/auto/widgets/widgets/qlabel/tst_qlabel.cpp28
-rw-r--r--tests/auto/widgets/widgets/qmenu/BLACKLIST1
-rw-r--r--tests/auto/widgets/widgets/qmenu/tst_qmenu.cpp13
-rw-r--r--tests/auto/widgets/widgets/qmenubar/tst_qmenubar.cpp3
-rw-r--r--tests/auto/widgets/widgets/qplaintextedit/tst_qplaintextedit.cpp32
-rw-r--r--tests/auto/widgets/widgets/qpushbutton/tst_qpushbutton.cpp25
-rw-r--r--tests/auto/widgets/widgets/qtextbrowser/tst_qtextbrowser.cpp18
22 files changed, 282 insertions, 80 deletions
diff --git a/tests/auto/widgets/dialogs/qdialog/tst_qdialog.cpp b/tests/auto/widgets/dialogs/qdialog/tst_qdialog.cpp
index 53c33255bf..6a59edca10 100644
--- a/tests/auto/widgets/dialogs/qdialog/tst_qdialog.cpp
+++ b/tests/auto/widgets/dialogs/qdialog/tst_qdialog.cpp
@@ -552,10 +552,11 @@ void tst_QDialog::keepPositionOnClose()
dialog.setWindowTitle(QTest::currentTestFunction());
const QRect availableGeometry = QGuiApplication::primaryScreen()->availableGeometry();
dialog.resize(availableGeometry.size() / 4);
- const QPoint pos = availableGeometry.topLeft() + QPoint(100, 100);
+ QPoint pos = availableGeometry.topLeft() + QPoint(100, 100);
dialog.move(pos);
dialog.show();
QVERIFY(QTest::qWaitForWindowExposed(&dialog));
+ pos = dialog.pos();
dialog.close();
dialog.windowHandle()->destroy(); // Emulate a click on close by destroying the window.
QTest::qWait(50);
diff --git a/tests/auto/widgets/effects/qgraphicseffect/tst_qgraphicseffect.cpp b/tests/auto/widgets/effects/qgraphicseffect/tst_qgraphicseffect.cpp
index 16c4ba6058..3ea4a100bb 100644
--- a/tests/auto/widgets/effects/qgraphicseffect/tst_qgraphicseffect.cpp
+++ b/tests/auto/widgets/effects/qgraphicseffect/tst_qgraphicseffect.cpp
@@ -694,6 +694,7 @@ void tst_QGraphicsEffect::prepareGeometryChangeInvalidateCache()
QGraphicsView view(&scene);
view.show();
QVERIFY(QTest::qWaitForWindowExposed(&view));
+ QTRY_VERIFY(view.windowHandle()->isActive());
QTRY_VERIFY(item->nbPaint >= 1);
item->nbPaint = 0;
diff --git a/tests/auto/widgets/itemviews/qfileiconprovider/tst_qfileiconprovider.cpp b/tests/auto/widgets/itemviews/qfileiconprovider/tst_qfileiconprovider.cpp
index 9e9625854e..39f6946b1d 100644
--- a/tests/auto/widgets/itemviews/qfileiconprovider/tst_qfileiconprovider.cpp
+++ b/tests/auto/widgets/itemviews/qfileiconprovider/tst_qfileiconprovider.cpp
@@ -47,7 +47,7 @@ private slots:
void type_data();
void type();
- void taskQTBUG_46755_QFileIconEngine_crash();
+ void iconPixmaps();
};
void tst_QFileIconProvider::qfileiconprovider()
@@ -129,14 +129,14 @@ static QIcon getIcon()
return fip.icon(QFileInfo(QDir::currentPath()));
}
-void tst_QFileIconProvider::taskQTBUG_46755_QFileIconEngine_crash()
+void tst_QFileIconProvider::iconPixmaps()
{
const QIcon &icon = getIcon();
const auto sizes = icon.availableSizes();
- for (const QSize &size : sizes)
- icon.pixmap(size);
-
- // No crash, all good.
+ for (const QSize &size : sizes) {
+ QPixmap pixmap = icon.pixmap(size);
+ QVERIFY(!pixmap.isNull());
+ }
}
QTEST_MAIN(tst_QFileIconProvider)
diff --git a/tests/auto/widgets/itemviews/qlistview/tst_qlistview.cpp b/tests/auto/widgets/itemviews/qlistview/tst_qlistview.cpp
index 0f3671708d..98dec7ded9 100644
--- a/tests/auto/widgets/itemviews/qlistview/tst_qlistview.cpp
+++ b/tests/auto/widgets/itemviews/qlistview/tst_qlistview.cpp
@@ -2675,7 +2675,9 @@ void tst_QListView::internalDragDropMove()
selectedTexts << data.itemData(index).value(Qt::DisplayRole).toString();
return selectedTexts;
};
- QVERIFY(QTest::qWaitForWindowExposed(&list));
+ // The test relies on the global position of mouse events; make sure
+ // the window is properly mapped on X11.
+ QVERIFY(QTest::qWaitForWindowActive(&list));
// execute as soon as the eventloop is running again
// which is the case inside list.startDrag()
QTimer::singleShot(0, [&]()
diff --git a/tests/auto/widgets/itemviews/qtreeview/tst_qtreeview.cpp b/tests/auto/widgets/itemviews/qtreeview/tst_qtreeview.cpp
index 3e22181c2f..579c2d234f 100644
--- a/tests/auto/widgets/itemviews/qtreeview/tst_qtreeview.cpp
+++ b/tests/auto/widgets/itemviews/qtreeview/tst_qtreeview.cpp
@@ -250,6 +250,7 @@ private slots:
void taskQTBUG_7232_AllowUserToControlSingleStep();
void taskQTBUG_8376();
void taskQTBUG_61476();
+ void taskQTBUG_42469_crash();
void testInitialFocus();
void fetchUntilScreenFull();
void expandAfterTake();
@@ -5070,6 +5071,29 @@ void tst_QTreeView::taskQTBUG_61476()
QCOMPARE(lastTopLevel->checkState(), Qt::Checked);
}
+void tst_QTreeView::taskQTBUG_42469_crash()
+{
+ QTreeWidget treeWidget;
+ QTreeWidgetItem *itemOne = new QTreeWidgetItem(QStringList("item1"));
+ QTreeWidgetItem *itemTwo = new QTreeWidgetItem(QStringList("item2"));
+ treeWidget.addTopLevelItem(itemOne);
+ treeWidget.addTopLevelItem(itemTwo);
+ treeWidget.topLevelItem(1)->addChild(new QTreeWidgetItem(QStringList("child1")));
+
+ treeWidget.setAnimated(true);
+ QObject::connect(&treeWidget, &QTreeWidget::itemExpanded, [&](QTreeWidgetItem* p_item) {
+ auto tempCount = treeWidget.topLevelItemCount();
+ for (int j = 0; j < tempCount; ++j)
+ if (treeWidget.topLevelItem(j) != p_item) {
+ auto temp = treeWidget.topLevelItem(j);
+ temp->setHidden(true);
+ }
+ });
+
+ treeWidget.show();
+ itemTwo->setExpanded(true);
+}
+
void tst_QTreeView::fetchUntilScreenFull()
{
class TreeModel : public QAbstractItemModel
diff --git a/tests/auto/widgets/kernel/qapplication/tst_qapplication.cpp b/tests/auto/widgets/kernel/qapplication/tst_qapplication.cpp
index f2c668c153..8216cfbab0 100644
--- a/tests/auto/widgets/kernel/qapplication/tst_qapplication.cpp
+++ b/tests/auto/widgets/kernel/qapplication/tst_qapplication.cpp
@@ -1525,6 +1525,11 @@ void tst_QApplication::desktopSettingsAware()
{
#if QT_CONFIG(process)
QProcess testProcess;
+#ifdef Q_OS_MACOS
+ QStringList environment = QProcess::systemEnvironment();
+ environment += QLatin1String("QT_MAC_DISABLE_FOREGROUND_APPLICATION_TRANSFORM=1");
+ testProcess.setEnvironment(environment);
+#endif
testProcess.start("desktopsettingsaware_helper");
QVERIFY2(testProcess.waitForStarted(),
qPrintable(QString::fromLatin1("Cannot start 'desktopsettingsaware_helper': %1").arg(testProcess.errorString())));
diff --git a/tests/auto/widgets/kernel/qgridlayout/tst_qgridlayout.cpp b/tests/auto/widgets/kernel/qgridlayout/tst_qgridlayout.cpp
index e3bd1d1553..2cf2462fd5 100644
--- a/tests/auto/widgets/kernel/qgridlayout/tst_qgridlayout.cpp
+++ b/tests/auto/widgets/kernel/qgridlayout/tst_qgridlayout.cpp
@@ -75,6 +75,7 @@ private slots:
void taskQTBUG_40609_addingWidgetToItsOwnLayout();
void taskQTBUG_40609_addingLayoutToItself();
void taskQTBUG_52357_spacingWhenItemIsHidden();
+ void taskQTBUG_91261_itemIndexRange();
void replaceWidget();
void dontCrashWhenExtendsToEnd();
};
@@ -1666,6 +1667,56 @@ void tst_QGridLayout::taskQTBUG_52357_spacingWhenItemIsHidden()
QTRY_COMPARE_WITH_TIMEOUT(tempWidth, button1.width() + button3.width() + layout.spacing(), 1000);
}
+void tst_QGridLayout::taskQTBUG_91261_itemIndexRange()
+{
+ QWidget widget;
+ QGridLayout lay(&widget);
+ QPushButton *btn = new QPushButton(&widget);
+ lay.addWidget(btn, 0, 0);
+
+ {
+ auto ptr = lay.itemAt(-1);
+ QCOMPARE(ptr, nullptr);
+
+ ptr = lay.itemAt(0);
+ QCOMPARE(ptr->widget(), btn);
+
+ ptr = lay.itemAt(1);
+ QCOMPARE(ptr, nullptr);
+ }
+
+ {
+ int row = -1;
+ int column = -1;
+ int rowSpan;
+ int columnSpan;
+
+ lay.getItemPosition(-1, &row, &column, &rowSpan, &columnSpan);
+ QCOMPARE(row, -1);
+ QCOMPARE(column, -1);
+
+ lay.getItemPosition(1, &row, &column, &rowSpan, &columnSpan);
+ QCOMPARE(row, -1);
+ QCOMPARE(column, -1);
+
+ lay.getItemPosition(0, &row, &column, &rowSpan, &columnSpan);
+ QCOMPARE(row, 0);
+ QCOMPARE(column, 0);
+ }
+
+ {
+ auto ptr = lay.takeAt(-1);
+ QCOMPARE(ptr, nullptr);
+
+ ptr = lay.takeAt(1);
+ QCOMPARE(ptr, nullptr);
+
+ ptr = lay.takeAt(0);
+ QCOMPARE(ptr->widget(), btn);
+ delete ptr;
+ }
+}
+
void tst_QGridLayout::replaceWidget()
{
QWidget wdg;
diff --git a/tests/auto/widgets/kernel/qshortcut/CMakeLists.txt b/tests/auto/widgets/kernel/qshortcut/CMakeLists.txt
index 06bd2d6ba8..fd97a436d0 100644
--- a/tests/auto/widgets/kernel/qshortcut/CMakeLists.txt
+++ b/tests/auto/widgets/kernel/qshortcut/CMakeLists.txt
@@ -11,5 +11,6 @@ qt_internal_add_test(tst_qshortcut
..
PUBLIC_LIBRARIES
Qt::Gui
+ Qt::GuiPrivate
Qt::Widgets
)
diff --git a/tests/auto/widgets/kernel/qshortcut/tst_qshortcut.cpp b/tests/auto/widgets/kernel/qshortcut/tst_qshortcut.cpp
index 6832f7a05a..1266660cea 100644
--- a/tests/auto/widgets/kernel/qshortcut/tst_qshortcut.cpp
+++ b/tests/auto/widgets/kernel/qshortcut/tst_qshortcut.cpp
@@ -45,6 +45,9 @@
#include <qshortcut.h>
#include <qscreen.h>
+#include <QtGui/private/qguiapplication_p.h>
+#include <QtGui/qpa/qplatformintegration.h>
+
QT_BEGIN_NAMESPACE
class QMainWindow;
class QTextEdit;
@@ -1359,7 +1362,10 @@ void tst_QShortcut::keys()
QSignalSpy spy(sc, &QShortcut::activated);
le.setFocus();
le.show();
- QVERIFY(QTest::qWaitForWindowActive(&le));
+ if (QGuiApplicationPrivate::platformIntegration()->hasCapability(QPlatformIntegration::WindowActivation))
+ QVERIFY(QTest::qWaitForWindowActive(&le));
+ else
+ QTRY_VERIFY(le.windowHandle()->isActive());
QCOMPARE(QApplication::focusWidget(), &le);
QTest::keyEvent(QTest::Press, QApplication::focusWidget(), Qt::Key_Enter);
diff --git a/tests/auto/widgets/kernel/qwidget/BLACKLIST b/tests/auto/widgets/kernel/qwidget/BLACKLIST
index 98d96dda65..7bc17127f5 100644
--- a/tests/auto/widgets/kernel/qwidget/BLACKLIST
+++ b/tests/auto/widgets/kernel/qwidget/BLACKLIST
@@ -1,8 +1,6 @@
# OSX QTBUG-25300 QTBUG-45502
[normalGeometry]
ubuntu-16.04
-[saveRestoreGeometry]
-b2qt
[restoreVersion1Geometry]
ubuntu-16.04
[focusProxyAndInputMethods]
diff --git a/tests/auto/widgets/kernel/qwidget/tst_qwidget.cpp b/tests/auto/widgets/kernel/qwidget/tst_qwidget.cpp
index 7849659e24..8992a0b051 100644
--- a/tests/auto/widgets/kernel/qwidget/tst_qwidget.cpp
+++ b/tests/auto/widgets/kernel/qwidget/tst_qwidget.cpp
@@ -607,6 +607,9 @@ tst_QWidget::tst_QWidget()
palette.setColor(QPalette::ToolTipBase, QColor(12, 13, 14));
palette.setColor(QPalette::Text, QColor(21, 22, 23));
QApplication::setPalette(palette, "QPropagationTestWidget");
+
+ if (QApplication::platformName().startsWith(QLatin1String("wayland")))
+ qputenv("QT_WAYLAND_DISABLE_WINDOWDECORATION", "1");
}
tst_QWidget::~tst_QWidget()
@@ -3345,30 +3348,30 @@ void tst_QWidget::lostUpdatesOnHide()
void tst_QWidget::raise()
{
- QScopedPointer<QWidget> parentPtr(new QWidget);
+ std::unique_ptr<QWidget> parentPtr(new QWidget);
parentPtr->resize(200, 200);
parentPtr->setObjectName(QLatin1String("raise"));
parentPtr->setWindowTitle(parentPtr->objectName());
QList<UpdateWidget *> allChildren;
- UpdateWidget *child1 = new UpdateWidget(parentPtr.data());
+ UpdateWidget *child1 = new UpdateWidget(parentPtr.get());
child1->setAutoFillBackground(true);
allChildren.append(child1);
- UpdateWidget *child2 = new UpdateWidget(parentPtr.data());
+ UpdateWidget *child2 = new UpdateWidget(parentPtr.get());
child2->setAutoFillBackground(true);
allChildren.append(child2);
- UpdateWidget *child3 = new UpdateWidget(parentPtr.data());
+ UpdateWidget *child3 = new UpdateWidget(parentPtr.get());
child3->setAutoFillBackground(true);
allChildren.append(child3);
- UpdateWidget *child4 = new UpdateWidget(parentPtr.data());
+ UpdateWidget *child4 = new UpdateWidget(parentPtr.get());
child4->setAutoFillBackground(true);
allChildren.append(child4);
parentPtr->show();
- QVERIFY(QTest::qWaitForWindowExposed(parentPtr.data()));
+ QVERIFY(QTest::qWaitForWindowExposed(parentPtr.get()));
#ifdef Q_OS_MACOS
if (child1->internalWinId()) {
@@ -3412,7 +3415,7 @@ void tst_QWidget::raise()
// the children underneath doesn't trigger a repaint on the covering widget.
QWidget topLevel;
topLevel.setWindowTitle(QLatin1String(QTest::currentTestFunction()));
- QWidget *parent = parentPtr.take();
+ QWidget *parent = parentPtr.release();
parent->setParent(&topLevel);
topLevel.show();
@@ -6383,6 +6386,9 @@ void tst_QWidget::setCursor()
void tst_QWidget::setToolTip()
{
+ if (QApplication::platformName().startsWith(QLatin1String("wayland")))
+ QSKIP("Setting mouse cursor position is not possible on Wayland");
+
QWidget widget;
widget.resize(200, 200);
// Showing the widget is not required for the tooltip event count test
@@ -10207,9 +10213,16 @@ void tst_QWidget::focusProxy()
window.setFocus();
window.show();
- window.activateWindow();
- if (!QTest::qWaitForWindowExposed(&window) || !QTest::qWaitForWindowActive(&window))
- QSKIP("Window activation failed");
+ if (!QTest::qWaitForWindowExposed(&window))
+ QSKIP("Window exposed failed");
+ if (QGuiApplicationPrivate::platformIntegration()->hasCapability(QPlatformIntegration::WindowActivation)) {
+ window.activateWindow();
+ if (!QTest::qWaitForWindowActive(&window))
+ QSKIP("Window activation failed");
+ } else {
+ if (!QTest::qWaitFor([&]() { return window.windowHandle()->isActive(); }, 5000))
+ QSKIP("Window activation failed");
+ }
// given a widget without focus proxy
QVERIFY(window.hasFocus());
diff --git a/tests/auto/widgets/kernel/qwidget_window/tst_qwidget_window.cpp b/tests/auto/widgets/kernel/qwidget_window/tst_qwidget_window.cpp
index 654d8e58ba..dbd541c736 100644
--- a/tests/auto/widgets/kernel/qwidget_window/tst_qwidget_window.cpp
+++ b/tests/auto/widgets/kernel/qwidget_window/tst_qwidget_window.cpp
@@ -1397,7 +1397,7 @@ void tst_QWidget_window::mouseMoveWithPopup()
QSKIP("Failed to expose window!");
QCOMPARE(QApplication::activePopupWidget(), nullptr);
- QCOMPARE(QApplication::activeWindow(), &topLevel);
+ QTRY_COMPARE(QApplication::activeWindow(), &topLevel);
QPoint mousePos = topLevel.geometry().center();
QWindow *window = nullptr;
@@ -1452,6 +1452,9 @@ void tst_QWidget_window::mouseMoveWithPopup()
topLevel.resetCounters();
topLevel.popup->resetCounters();
+ QTRY_VERIFY(QApplication::activeWindow() == topLevel.popup
+ || QApplication::activePopupWidget() == topLevel.popup);
+
// nested popup, same procedure
QCOMPARE(mouseAction(Qt::RightButton), QEvent::MouseButtonPress);
QVERIFY(topLevel.popup);
diff --git a/tests/auto/widgets/widgets/qdial/tst_qdial.cpp b/tests/auto/widgets/widgets/qdial/tst_qdial.cpp
index 29aee1c397..86928414c8 100644
--- a/tests/auto/widgets/widgets/qdial/tst_qdial.cpp
+++ b/tests/auto/widgets/widgets/qdial/tst_qdial.cpp
@@ -42,6 +42,9 @@ private slots:
void valueChanged();
void sliderMoved();
void wrappingCheck();
+
+ void notchSize_data();
+ void notchSize();
};
// Testing get/set functions
@@ -194,5 +197,33 @@ void tst_QDial::wrappingCheck()
}
}
+/*
+ Verify that the notchSizes calculated don't change compared
+ to Qt 5.15 results for dial sizes at the edge values of the
+ algorithm.
+*/
+void tst_QDial::notchSize_data()
+{
+ QTest::addColumn<int>("diameter");
+ QTest::addColumn<int>("notchSize");
+
+ QTest::newRow("data0") << 50 << 4;
+ QTest::newRow("data1") << 80 << 4;
+ QTest::newRow("data2") << 95 << 4;
+ QTest::newRow("data3") << 110 << 4;
+ QTest::newRow("data4") << 152 << 2;
+ QTest::newRow("data5") << 210 << 2;
+ QTest::newRow("data6") << 228 << 1;
+}
+
+void tst_QDial::notchSize()
+{
+ QFETCH(int, diameter);
+ QFETCH(int, notchSize);
+ QDial dial;
+ dial.setFixedSize(QSize(diameter, diameter));
+ QCOMPARE(dial.notchSize(), notchSize);
+}
+
QTEST_MAIN(tst_QDial)
#include "tst_qdial.moc"
diff --git a/tests/auto/widgets/widgets/qdockwidget/tst_qdockwidget.cpp b/tests/auto/widgets/widgets/qdockwidget/tst_qdockwidget.cpp
index 4aa8e9887e..d726807b7c 100644
--- a/tests/auto/widgets/widgets/qdockwidget/tst_qdockwidget.cpp
+++ b/tests/auto/widgets/widgets/qdockwidget/tst_qdockwidget.cpp
@@ -779,6 +779,9 @@ void tst_QDockWidget::restoreStateWhileStillFloating()
void tst_QDockWidget::restoreDockWidget()
{
+ if (QGuiApplication::platformName().startsWith(QLatin1String("wayland"), Qt::CaseInsensitive))
+ QSKIP("Fails on Wayland: QTBUG-91483");
+
QByteArray geometry;
QByteArray state;
@@ -973,6 +976,9 @@ void tst_QDockWidget::taskQTBUG_1665_closableChanged()
void tst_QDockWidget::taskQTBUG_9758_undockedGeometry()
{
+ if (QGuiApplication::platformName().startsWith(QLatin1String("wayland"), Qt::CaseInsensitive))
+ QSKIP("Fails on Wayland: QTBUG-91483");
+
QMainWindow window;
QDockWidget dock1(&window);
QDockWidget dock2(&window);
diff --git a/tests/auto/widgets/widgets/qdoublespinbox/tst_qdoublespinbox.cpp b/tests/auto/widgets/widgets/qdoublespinbox/tst_qdoublespinbox.cpp
index 6b0c353e3b..09fc8343b5 100644
--- a/tests/auto/widgets/widgets/qdoublespinbox/tst_qdoublespinbox.cpp
+++ b/tests/auto/widgets/widgets/qdoublespinbox/tst_qdoublespinbox.cpp
@@ -134,8 +134,8 @@ public:
virtual ~tst_QDoubleSpinBox();
public slots:
void initTestCase();
- void cleanupTestCase();
void init();
+ void cleanup();
private slots:
void germanTest();
@@ -213,7 +213,6 @@ public slots:
private:
QStringList actualTexts;
QList<double> actualValues;
- QWidget *testFocusWidget;
};
typedef QList<double> DoubleList;
@@ -257,25 +256,18 @@ tst_QDoubleSpinBox::~tst_QDoubleSpinBox()
void tst_QDoubleSpinBox::initTestCase()
{
- testFocusWidget = new QWidget(0);
- testFocusWidget->resize(200, 100);
- testFocusWidget->show();
-
if (QGuiApplication::platformName().startsWith(QLatin1String("wayland"), Qt::CaseInsensitive))
QSKIP("Wayland: This fails. Figure out why.");
-
- QVERIFY(QTest::qWaitForWindowActive(testFocusWidget));
}
-void tst_QDoubleSpinBox::cleanupTestCase()
+void tst_QDoubleSpinBox::init()
{
- delete testFocusWidget;
- testFocusWidget = 0;
+ QLocale::setDefault(QLocale(QLocale::C));
}
-void tst_QDoubleSpinBox::init()
+void tst_QDoubleSpinBox::cleanup()
{
- QLocale::setDefault(QLocale(QLocale::C));
+ QTRY_VERIFY(QApplication::topLevelWidgets().isEmpty());
}
void tst_QDoubleSpinBox::setValue_data()
@@ -878,15 +870,16 @@ void tst_QDoubleSpinBox::setReadOnly()
void tst_QDoubleSpinBox::editingFinished()
{
- QVBoxLayout *layout = new QVBoxLayout(testFocusWidget);
- QDoubleSpinBox *box = new QDoubleSpinBox(testFocusWidget);
+ QWidget testFocusWidget(nullptr);
+ QVBoxLayout *layout = new QVBoxLayout(&testFocusWidget);
+ QDoubleSpinBox *box = new QDoubleSpinBox(&testFocusWidget);
layout->addWidget(box);
- QDoubleSpinBox *box2 = new QDoubleSpinBox(testFocusWidget);
+ QDoubleSpinBox *box2 = new QDoubleSpinBox(&testFocusWidget);
layout->addWidget(box2);
- testFocusWidget->show();
- testFocusWidget->activateWindow();
- QVERIFY(QTest::qWaitForWindowActive(testFocusWidget));
+ testFocusWidget.show();
+ testFocusWidget.activateWindow();
+ QVERIFY(QTest::qWaitForWindowActive(&testFocusWidget));
box->setFocus();
QTRY_VERIFY(box->hasFocus());
@@ -925,14 +918,9 @@ void tst_QDoubleSpinBox::editingFinished()
QTest::keyClick(box2, Qt::Key_Return);
QCOMPARE(editingFinishedSpy1.count(), 4);
QCOMPARE(editingFinishedSpy2.count(), 3);
- testFocusWidget->hide();
+ testFocusWidget.hide();
QCOMPARE(editingFinishedSpy1.count(), 4);
QCOMPARE(editingFinishedSpy2.count(), 4);
-
- // On some platforms this is our root window
- // we need to show it again otherwise subsequent
- // tests will fail
- testFocusWidget->show();
}
void tst_QDoubleSpinBox::removeAll()
@@ -1111,15 +1099,15 @@ public:
void tst_QDoubleSpinBox::task224497_fltMax()
{
- task224497_fltMax_DoubleSpinBox *dspin = new task224497_fltMax_DoubleSpinBox;
- dspin->setMinimum(3);
- dspin->setMaximum(FLT_MAX);
- dspin->show();
- QVERIFY(QTest::qWaitForWindowActive(dspin));
- dspin->lineEdit()->selectAll();
- QTest::keyClick(dspin->lineEdit(), Qt::Key_Delete);
- QTest::keyClick(dspin->lineEdit(), Qt::Key_1);
- QCOMPARE(dspin->cleanText(), QLatin1String("1"));
+ task224497_fltMax_DoubleSpinBox dspin;
+ dspin.setMinimum(3);
+ dspin.setMaximum(FLT_MAX);
+ dspin.show();
+ QVERIFY(QTest::qWaitForWindowActive(&dspin));
+ dspin.lineEdit()->selectAll();
+ QTest::keyClick(dspin.lineEdit(), Qt::Key_Delete);
+ QTest::keyClick(dspin.lineEdit(), Qt::Key_1);
+ QCOMPARE(dspin.cleanText(), QLatin1String("1"));
}
void tst_QDoubleSpinBox::task221221()
diff --git a/tests/auto/widgets/widgets/qlabel/tst_qlabel.cpp b/tests/auto/widgets/widgets/qlabel/tst_qlabel.cpp
index 5eed823a34..c9e71d8388 100644
--- a/tests/auto/widgets/widgets/qlabel/tst_qlabel.cpp
+++ b/tests/auto/widgets/widgets/qlabel/tst_qlabel.cpp
@@ -40,7 +40,6 @@
#include <qmessagebox.h>
#include <qfontmetrics.h>
#include <qmath.h>
-#include <qurlresourceprovider.h>
#include <private/qlabel_p.h>
class Widget : public QWidget
@@ -599,27 +598,22 @@ void tst_QLabel::taskQTBUG_48157_dprMovie()
QCOMPARE(label.sizeHint(), movie.currentPixmap().size() / movie.currentPixmap().devicePixelRatio());
}
-class UrlResourceProvider : public QUrlResourceProvider
-{
-public:
- QVariant resource(const QUrl &url) override
- {
- resourseUrl = url;
- return QVariant();
- }
-
- QUrl resourseUrl;
-};
-
void tst_QLabel::resourceProvider()
{
QLabel label;
- UrlResourceProvider resourceProvider;
- label.setResourceProvider(&resourceProvider);
- QUrl url("test://img");
+ int providerCalled = 0;
+ QUrl providerUrl;
+ label.setResourceProvider([&](const QUrl &url){
+ providerUrl = url;
+ ++providerCalled;
+ return QVariant();
+ });
+
+ const QUrl url("test://img");
label.setText(QStringLiteral("<img src='%1'/>").arg(url.toString()));
label.show();
- QCOMPARE(url, resourceProvider.resourseUrl);
+ QCOMPARE(providerUrl, url);
+ QVERIFY(providerCalled > 0);
}
QTEST_MAIN(tst_QLabel)
diff --git a/tests/auto/widgets/widgets/qmenu/BLACKLIST b/tests/auto/widgets/widgets/qmenu/BLACKLIST
index 837c785141..230512769c 100644
--- a/tests/auto/widgets/widgets/qmenu/BLACKLIST
+++ b/tests/auto/widgets/widgets/qmenu/BLACKLIST
@@ -28,3 +28,4 @@ android
android
[QTBUG_89082_actionTipsHide]
macos ci # Can't move cursor (QTBUG-76312)
+windows-10 ci
diff --git a/tests/auto/widgets/widgets/qmenu/tst_qmenu.cpp b/tests/auto/widgets/widgets/qmenu/tst_qmenu.cpp
index 9b92c27390..1ca51cd1a9 100644
--- a/tests/auto/widgets/widgets/qmenu/tst_qmenu.cpp
+++ b/tests/auto/widgets/widgets/qmenu/tst_qmenu.cpp
@@ -175,7 +175,9 @@ void tst_QMenu::getSetCheck()
tst_QMenu::tst_QMenu()
: m_onStatusTipTimerExecuted(false)
{
+ QApplication::setEffectEnabled(Qt::UI_FadeTooltip, false);
QApplication::setEffectEnabled(Qt::UI_AnimateMenu, false);
+ QApplication::setEffectEnabled(Qt::UI_AnimateTooltip, false);
}
void tst_QMenu::initTestCase()
@@ -1369,10 +1371,15 @@ void tst_QMenu::QTBUG_89082_actionTipsHide()
widget.resize(300, 200);
centerOnScreen(&widget);
widget.show();
+#if QT_CONFIG(cursor)
+ QCursor::setPos(widget.screen()->availableGeometry().topLeft() + QPoint(10, 10));
+#endif
widget.activateWindow();
QVERIFY(QTest::qWaitForWindowExposed(&widget));
menu->popup(widget.geometry().topRight() + QPoint(50, 0));
QVERIFY(QTest::qWaitForWindowExposed(menu));
+ auto menuWindow = menu->windowHandle();
+ QVERIFY(menuWindow != nullptr);
auto actionZero = menu->actions().at(0);
auto actionOne = menu->actions().at(1);
@@ -1386,12 +1393,12 @@ void tst_QMenu::QTBUG_89082_actionTipsHide()
const QRect submenuRect5 = menu->actionGeometry(actionFive);
const QPoint submenuPos5(submenuRect5.topLeft() + QPoint(10, 3));
- QTest::mouseMove(menu, submenuPos1);
- QTest::mouseMove(menu, submenuPos0); //show the tip
+ QTest::mouseMove(menuWindow, submenuPos1);
+ QTest::mouseMove(menuWindow, submenuPos0); //show the tip
QTRY_COMPARE_WITH_TIMEOUT(QToolTip::text(), tipFullName, 1000);
//Move to the fifth action without prompting
- QTest::mouseMove(menu, submenuPos5);
+ QTest::mouseMove(menuWindow, submenuPos5);
//The previous tip was hidden, but now is a new tip to get text, So there should be no content
QTRY_COMPARE_WITH_TIMEOUT(QToolTip::text(), QString(), 1000);
}
diff --git a/tests/auto/widgets/widgets/qmenubar/tst_qmenubar.cpp b/tests/auto/widgets/widgets/qmenubar/tst_qmenubar.cpp
index 0e6689b413..bac7962c6a 100644
--- a/tests/auto/widgets/widgets/qmenubar/tst_qmenubar.cpp
+++ b/tests/auto/widgets/widgets/qmenubar/tst_qmenubar.cpp
@@ -1356,7 +1356,8 @@ void tst_QMenuBar::menubarSizeHint()
{
MyStyle() : QProxyStyle(QStyleFactory::create("windows")) { }
- virtual int pixelMetric(PixelMetric metric, const QStyleOption * option = 0, const QWidget * widget = 0 ) const
+ int pixelMetric(PixelMetric metric, const QStyleOption *option = 0,
+ const QWidget *widget = 0) const override
{
// I chose strange values (prime numbers to be more sure that the size of the menubar is correct)
switch (metric)
diff --git a/tests/auto/widgets/widgets/qplaintextedit/tst_qplaintextedit.cpp b/tests/auto/widgets/widgets/qplaintextedit/tst_qplaintextedit.cpp
index 0cffe14ee4..297eb5ec51 100644
--- a/tests/auto/widgets/widgets/qplaintextedit/tst_qplaintextedit.cpp
+++ b/tests/auto/widgets/widgets/qplaintextedit/tst_qplaintextedit.cpp
@@ -153,6 +153,7 @@ private slots:
#ifndef QT_NO_CLIPBOARD
void updateCursorPositionAfterEdit();
#endif
+ void appendTextWhenInvisible();
private:
void createSelection();
@@ -1805,5 +1806,36 @@ void tst_QPlainTextEdit::updateCursorPositionAfterEdit()
}
#endif
+void tst_QPlainTextEdit::appendTextWhenInvisible()
+{
+ QWidget window;
+ window.resize(640, 480);
+
+ QPlainTextEdit *plainTextEdit = new QPlainTextEdit(&window);
+ plainTextEdit->resize(320, 240);
+
+ window.show();
+ QVERIFY(QTest::qWaitForWindowActive(&window));
+
+ // this should be long enough to let vertical scroll bar show up
+ const QString baseText("text\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\ntext");
+ const QString textToAppend("aaa");
+
+ plainTextEdit->setPlainText(baseText + "\n" + textToAppend);
+ const auto maxAfterSet = plainTextEdit->verticalScrollBar()->maximum();
+ // make sure the vertical scroll bar is visible
+ QVERIFY(maxAfterSet != 0);
+
+ plainTextEdit->clear();
+ plainTextEdit->setPlainText(baseText);
+ plainTextEdit->hide();
+ plainTextEdit->appendPlainText(textToAppend);
+ plainTextEdit->show();
+ const auto maxAfterAppend = plainTextEdit->verticalScrollBar()->maximum();
+ QVERIFY(maxAfterAppend != 0);
+
+ QCOMPARE(maxAfterAppend, maxAfterSet);
+}
+
QTEST_MAIN(tst_QPlainTextEdit)
#include "tst_qplaintextedit.moc"
diff --git a/tests/auto/widgets/widgets/qpushbutton/tst_qpushbutton.cpp b/tests/auto/widgets/widgets/qpushbutton/tst_qpushbutton.cpp
index f8464e2383..e19264abb2 100644
--- a/tests/auto/widgets/widgets/qpushbutton/tst_qpushbutton.cpp
+++ b/tests/auto/widgets/widgets/qpushbutton/tst_qpushbutton.cpp
@@ -73,6 +73,7 @@ private slots:
#endif
void emitReleasedAfterChange();
void hitButton();
+ void iconOnlyStyleSheet();
protected slots:
void resetCounters();
@@ -336,9 +337,6 @@ void tst_QPushButton::toggled()
void tst_QPushButton::setAccel()
{
- if (QGuiApplication::platformName().startsWith(QLatin1String("wayland"), Qt::CaseInsensitive))
- QSKIP("Wayland: This fails. Figure out why.");
-
testWidget->setText("&AccelTest");
QKeySequence seq( Qt::ALT | Qt::Key_A );
testWidget->setShortcut( seq );
@@ -575,6 +573,8 @@ void tst_QPushButton::sizeHint()
button->setDefault(false);
QCOMPARE(button->sizeHint(), initSizeHint);
delete button;
+
+ delete widget;
}
// Test 2
@@ -604,6 +604,8 @@ void tst_QPushButton::sizeHint()
tabWidget->setCurrentWidget(tab1);
QTRY_COMPARE(button1_2->size(), button2_2->size());
+
+ delete dialog;
}
}
@@ -734,5 +736,22 @@ void tst_QPushButton::hitButton()
QVERIFY(!button2->hitButton(QPoint(2, 2)));
}
+/*
+ Test that a style sheet with only icon doesn't crash.
+ QTBUG-91735
+*/
+void tst_QPushButton::iconOnlyStyleSheet()
+{
+ QIcon icon(":/qt-project.org/styles/commonstyle/images/dvd-32.png");
+ QVERIFY(!icon.isNull());
+ QPushButton pb;
+ pb.setStyleSheet("QPushButton {"
+ "icon: url(:/qt-project.org/styles/commonstyle/images/dvd-32.png);"
+ "border: red;"
+ "}");
+ pb.show();
+ QVERIFY(QTest::qWaitForWindowExposed(&pb));
+}
+
QTEST_MAIN(tst_QPushButton)
#include "tst_qpushbutton.moc"
diff --git a/tests/auto/widgets/widgets/qtextbrowser/tst_qtextbrowser.cpp b/tests/auto/widgets/widgets/qtextbrowser/tst_qtextbrowser.cpp
index 73266d77f3..ec187a55b0 100644
--- a/tests/auto/widgets/widgets/qtextbrowser/tst_qtextbrowser.cpp
+++ b/tests/auto/widgets/widgets/qtextbrowser/tst_qtextbrowser.cpp
@@ -466,11 +466,29 @@ void tst_QTextBrowser::textInteractionFlags_vs_readOnly()
void tst_QTextBrowser::inputMethodAttribute_vs_readOnly()
{
QVERIFY(browser->isReadOnly());
+#if defined(Q_OS_ANDROID)
+ QInputMethodQueryEvent query(Qt::ImReadOnly);
+ QCoreApplication::sendEvent(browser, &query);
+ QVERIFY(query.value(Qt::ImReadOnly).toBool());
+#else
QVERIFY(!browser->testAttribute(Qt::WA_InputMethodEnabled));
+#endif
+
browser->setReadOnly(false);
+#if defined(Q_OS_ANDROID)
+ QCoreApplication::sendEvent(browser, &query);
+ QVERIFY(!query.value(Qt::ImReadOnly).toBool());
+#else
QVERIFY(browser->testAttribute(Qt::WA_InputMethodEnabled));
+#endif
+
browser->setReadOnly(true);
+#if defined(Q_OS_ANDROID)
+ QCoreApplication::sendEvent(browser, &query);
+ QVERIFY(query.value(Qt::ImReadOnly).toBool());
+#else
QVERIFY(!browser->testAttribute(Qt::WA_InputMethodEnabled));
+#endif
}
void tst_QTextBrowser::anchorsWithSelfBuiltHtml()