diff options
Diffstat (limited to 'tests/auto/widgets')
117 files changed, 894 insertions, 273 deletions
diff --git a/tests/auto/widgets/dialogs/qfiledialog2/tst_qfiledialog2.cpp b/tests/auto/widgets/dialogs/qfiledialog2/tst_qfiledialog2.cpp index b950bf3957..eafd4d7cea 100644 --- a/tests/auto/widgets/dialogs/qfiledialog2/tst_qfiledialog2.cpp +++ b/tests/auto/widgets/dialogs/qfiledialog2/tst_qfiledialog2.cpp @@ -48,6 +48,7 @@ #include <qlineedit.h> #include <qlayout.h> #include <qmenu.h> +#include <qrandom.h> #include "../../../../../src/widgets/dialogs/qsidebar_p.h" #include "../../../../../src/widgets/dialogs/qfilesystemmodel_p.h" #include "../../../../../src/widgets/dialogs/qfiledialog_p.h" @@ -367,7 +368,7 @@ void tst_QFileDialog2::task143519_deleteAndRenameActionBehavior() fd.selectFile(ctx.file.fileName()); fd.show(); - QTest::qWaitForWindowActive(&fd); + QVERIFY(QTest::qWaitForWindowActive(&fd)); // grab some internals: QAction *rm = fd.findChild<QAction*>("qt_delete_action"); @@ -1196,7 +1197,7 @@ void tst_QFileDialog2::QTBUG6558_showDirsOnly() { const QString tempPath = tempDir.path(); QDir dirTemp(tempPath); - const QString tempName = QLatin1String("showDirsOnly.") + QString::number(qrand()); + const QString tempName = QLatin1String("showDirsOnly.") + QString::number(QRandomGenerator::global()->generate()); dirTemp.mkdir(tempName); dirTemp.cd(tempName); QTRY_VERIFY(dirTemp.exists()); diff --git a/tests/auto/widgets/dialogs/qinputdialog/tst_qinputdialog.cpp b/tests/auto/widgets/dialogs/qinputdialog/tst_qinputdialog.cpp index 8da6ef0363..62286d703f 100644 --- a/tests/auto/widgets/dialogs/qinputdialog/tst_qinputdialog.cpp +++ b/tests/auto/widgets/dialogs/qinputdialog/tst_qinputdialog.cpp @@ -47,6 +47,7 @@ class tst_QInputDialog : public QObject static void testFuncGetDouble(QInputDialog *dialog); static void testFuncGetText(QInputDialog *dialog); static void testFuncGetItem(QInputDialog *dialog); + static void testFuncSingleStepDouble(QInputDialog *dialog); void timerEvent(QTimerEvent *event); private slots: void getInt_data(); @@ -61,6 +62,8 @@ private slots: void getItem(); void task256299_getTextReturnNullStringOnRejected(); void inputMethodHintsOfChildWidget(); + void setDoubleStep_data(); + void setDoubleStep(); }; QString stripFraction(const QString &s) @@ -498,5 +501,45 @@ void tst_QInputDialog::inputMethodHintsOfChildWidget() QCOMPARE(editWidget->inputMethodHints(), Qt::ImhDigitsOnly); } +void tst_QInputDialog::testFuncSingleStepDouble(QInputDialog *dialog) +{ + QDoubleSpinBox *sbox = dialog->findChild<QDoubleSpinBox *>(); + QVERIFY(sbox); + QTest::keyClick(sbox, Qt::Key_Up); +} + +void tst_QInputDialog::setDoubleStep_data() +{ + QTest::addColumn<double>("min"); + QTest::addColumn<double>("max"); + QTest::addColumn<int>("decimals"); + QTest::addColumn<double>("doubleStep"); + QTest::addColumn<double>("actualResult"); + QTest::newRow("step 2.0") << 0.0 << 10.0 << 0 << 2.0 << 2.0; + QTest::newRow("step 2.5") << 0.5 << 10.5 << 1 << 2.5 << 3.0; + QTest::newRow("step 2.25") << 10.05 << 20.05 << 2 << 2.25 << 12.30; + QTest::newRow("step 2.25 fewer decimals") << 0.5 << 10.5 << 1 << 2.25 << 2.75; +} + +void tst_QInputDialog::setDoubleStep() +{ + QFETCH(double, min); + QFETCH(double, max); + QFETCH(int, decimals); + QFETCH(double, doubleStep); + QFETCH(double, actualResult); + QWidget p; + parent = &p; + doneCode = QDialog::Accepted; + testFunc = &tst_QInputDialog::testFuncSingleStepDouble; + startTimer(0); + bool ok = false; + const double result = QInputDialog::getDouble(parent, QString(), QString(), min, min, + max, decimals, &ok, QFlags<Qt::WindowType>(), + doubleStep); + QVERIFY(ok); + QCOMPARE(result, actualResult); +} + QTEST_MAIN(tst_QInputDialog) #include "tst_qinputdialog.moc" diff --git a/tests/auto/widgets/dialogs/qmessagebox/BLACKLIST b/tests/auto/widgets/dialogs/qmessagebox/BLACKLIST new file mode 100644 index 0000000000..36e47830d0 --- /dev/null +++ b/tests/auto/widgets/dialogs/qmessagebox/BLACKLIST @@ -0,0 +1,2 @@ +[defaultButton] +osx ci diff --git a/tests/auto/widgets/dialogs/qmessagebox/tst_qmessagebox.cpp b/tests/auto/widgets/dialogs/qmessagebox/tst_qmessagebox.cpp index d6c4841b22..6a16e48394 100644 --- a/tests/auto/widgets/dialogs/qmessagebox/tst_qmessagebox.cpp +++ b/tests/auto/widgets/dialogs/qmessagebox/tst_qmessagebox.cpp @@ -185,6 +185,12 @@ void tst_QMessageBox::cleanup() void tst_QMessageBox::sanityTest() { +#if defined(Q_OS_MACOS) + if (QSysInfo::productVersion() == QLatin1String("10.12")) { + QSKIP("Test hangs on macOS 10.12 -- QTQAINFRA-1362"); + return; + } +#endif QMessageBox msgBox; msgBox.setText("This is insane"); for (int i = 0; i < 10; i++) @@ -588,7 +594,7 @@ void tst_QMessageBox::detailsText() box.setDetailedText(text); QCOMPARE(box.detailedText(), text); box.show(); - QTest::qWaitForWindowExposed(&box); + QVERIFY(QTest::qWaitForWindowExposed(&box)); // QTBUG-39334, the box should now have the default "Ok" button as well as // the "Show Details.." button. QCOMPARE(box.findChildren<QAbstractButton *>().size(), 2); @@ -641,7 +647,7 @@ void tst_QMessageBox::expandDetails_QTBUG_32473() // that the window manager is also done manipulating the first QMessageBox. QWidget fleece; fleece.show(); - QTest::qWaitForWindowExposed(&fleece); + QVERIFY(QTest::qWaitForWindowExposed(&fleece)); if (geom.topLeft() == box.geometry().topLeft()) QTest::qWait(500); QCOMPARE(geom.topLeft(), box.geometry().topLeft()); diff --git a/tests/auto/widgets/gestures/gestures.pro b/tests/auto/widgets/gestures/gestures.pro deleted file mode 100644 index 5a87a01ee2..0000000000 --- a/tests/auto/widgets/gestures/gestures.pro +++ /dev/null @@ -1,6 +0,0 @@ -TEMPLATE=subdirs -SUBDIRS=\ - qgesturerecognizer \ - -mac: SUBDIRS -= \ # Uses native recognizers - qgesturerecognizer \ diff --git a/tests/auto/widgets/graphicsview/qgraphicsitem/tst_qgraphicsitem.cpp b/tests/auto/widgets/graphicsview/qgraphicsitem/tst_qgraphicsitem.cpp index 0fc1a643b4..2220ef8d2f 100644 --- a/tests/auto/widgets/graphicsview/qgraphicsitem/tst_qgraphicsitem.cpp +++ b/tests/auto/widgets/graphicsview/qgraphicsitem/tst_qgraphicsitem.cpp @@ -33,6 +33,7 @@ #include <private/qgraphicsitem_p.h> #include <private/qgraphicsview_p.h> #include <private/qgraphicsscene_p.h> +#include <QRandomGenerator> #include <QStyleOptionGraphicsItem> #include <QAbstractTextDocumentLayout> #include <QBitmap> @@ -3585,12 +3586,12 @@ void tst_QGraphicsItem::group() QList<QGraphicsItem *> newItems; for (int i = 0; i < 100; ++i) { QGraphicsItem *item = scene.addRect(QRectF(-25, -25, 50, 50), QPen(Qt::black, 0), - QBrush(QColor(rand() % 255, rand() % 255, - rand() % 255, rand() % 255))); + QBrush(QColor(QRandomGenerator::global()->bounded(255), QRandomGenerator::global()->bounded(255), + QRandomGenerator::global()->bounded(255), QRandomGenerator::global()->bounded(255)))); newItems << item; - item->setPos(-1000 + rand() % 2000, - -1000 + rand() % 2000); - item->setTransform(QTransform().rotate(rand() % 90), true); + item->setPos(-1000 + QRandomGenerator::global()->bounded(2000), + -1000 + QRandomGenerator::global()->bounded(2000)); + item->setTransform(QTransform().rotate(QRandomGenerator::global()->bounded(90)), true); } view.fitInView(scene.itemsBoundingRect()); @@ -4133,8 +4134,8 @@ void tst_QGraphicsItem::ensureVisible() for (int x = -100; x < 100; x += 25) { for (int y = -100; y < 100; y += 25) { - int xmargin = rand() % 75; - int ymargin = rand() % 75; + int xmargin = QRandomGenerator::global()->bounded(75); + int ymargin = QRandomGenerator::global()->bounded(75); item->ensureVisible(x, y, 25, 25, xmargin, ymargin); QApplication::processEvents(); @@ -7127,7 +7128,7 @@ public: : QGraphicsRectItem(QRectF(-10, -10, 20, 20)) { setPen(QPen(Qt::black, 0)); - setBrush(QColor(qrand() % 256, qrand() % 256, qrand() % 256)); + setBrush(QColor(QRandomGenerator::global()->bounded(256), QRandomGenerator::global()->bounded(256), QRandomGenerator::global()->bounded(256))); } QTransform x; @@ -11409,7 +11410,7 @@ void tst_QGraphicsItem::doNotMarkFullUpdateIfNotInScene() item2->setParentItem(item); scene.addItem(item); view.show(); - QTest::qWaitForWindowActive(view.windowHandle()); + QVERIFY(QTest::qWaitForWindowActive(view.windowHandle())); view.activateWindow(); QTRY_VERIFY(view.isActiveWindow()); QTRY_VERIFY(view.repaints >= 1); diff --git a/tests/auto/widgets/graphicsview/qgraphicsproxywidget/tst_qgraphicsproxywidget.cpp b/tests/auto/widgets/graphicsview/qgraphicsproxywidget/tst_qgraphicsproxywidget.cpp index e49cd87941..07d195b3e8 100644 --- a/tests/auto/widgets/graphicsview/qgraphicsproxywidget/tst_qgraphicsproxywidget.cpp +++ b/tests/auto/widgets/graphicsview/qgraphicsproxywidget/tst_qgraphicsproxywidget.cpp @@ -824,7 +824,7 @@ void tst_QGraphicsProxyWidget::focusOutEvent() QApplication::setActiveWindow(&view); view.activateWindow(); view.setFocus(); - QTest::qWaitForWindowActive(&view); + QVERIFY(QTest::qWaitForWindowActive(&view)); QTRY_VERIFY(view.isVisible()); QTRY_COMPARE(QApplication::activeWindow(), (QWidget*)&view); diff --git a/tests/auto/widgets/graphicsview/qgraphicsscene/BLACKLIST b/tests/auto/widgets/graphicsview/qgraphicsscene/BLACKLIST index c6f69a51a5..70170d2822 100644 --- a/tests/auto/widgets/graphicsview/qgraphicsscene/BLACKLIST +++ b/tests/auto/widgets/graphicsview/qgraphicsscene/BLACKLIST @@ -1,3 +1,5 @@ [removeItem] # QTBUG-60754, QTest::mouseMove is not always respected, or the CI moves the cursor osx-10.11 ci +[isActive] +opensuse-42.3 ci diff --git a/tests/auto/widgets/graphicsview/qgraphicsscene/tst_qgraphicsscene.cpp b/tests/auto/widgets/graphicsview/qgraphicsscene/tst_qgraphicsscene.cpp index 7615c5e821..968233438a 100644 --- a/tests/auto/widgets/graphicsview/qgraphicsscene/tst_qgraphicsscene.cpp +++ b/tests/auto/widgets/graphicsview/qgraphicsscene/tst_qgraphicsscene.cpp @@ -1507,10 +1507,10 @@ void tst_QGraphicsScene::mouseGrabberItem() QCOMPARE(scene.mouseGrabberItem(), topMostItem); // Geometrical changes should not affect the mouse grabber. - item->setZValue(rand() % 500); - item2->setZValue(rand() % 500); - item->setPos(rand() % 50000, rand() % 50000); - item2->setPos(rand() % 50000, rand() % 50000); + item->setZValue(QRandomGenerator::global()->bounded(500)); + item2->setZValue(QRandomGenerator::global()->bounded(500)); + item->setPos(QRandomGenerator::global()->bounded(50000), QRandomGenerator::global()->bounded(50000)); + item2->setPos(QRandomGenerator::global()->bounded(50000), QRandomGenerator::global()->bounded(50000)); } QGraphicsSceneMouseEvent releaseEvent(QEvent::GraphicsSceneMouseRelease); @@ -3424,7 +3424,7 @@ void tst_QGraphicsScene::task139710_bspTreeCrash() // add 1000 more items - the BSP tree is now resized for (int i = 0; i < 1000; ++i) { QGraphicsRectItem *item = scene.addRect(QRectF(0, 0, 200, 200)); - item->setPos(qrand() % 10000, qrand() % 10000); + item->setPos(QRandomGenerator::global()->bounded(10000), QRandomGenerator::global()->bounded(10000)); } // trigger delayed item indexing for the first 1000 items @@ -3433,7 +3433,7 @@ void tst_QGraphicsScene::task139710_bspTreeCrash() // add 1000 more items - the BSP tree is now resized for (int i = 0; i < 1000; ++i) { QGraphicsRectItem *item = scene.addRect(QRectF(0, 0, 200, 200)); - item->setPos(qrand() % 10000, qrand() % 10000); + item->setPos(QRandomGenerator::global()->bounded(10000), QRandomGenerator::global()->bounded(10000)); } // get items from the BSP tree and use them. there was junk in the tree @@ -3543,15 +3543,15 @@ void tst_QGraphicsScene::sorting() QGraphicsRectItem *c_2_1 = new QGraphicsRectItem(0, 0, 30, 30, c_2); QGraphicsRectItem *c_2_1_1 = new QGraphicsRectItem(0, 0, 20, 20, c_2_1); QGraphicsRectItem *c_2_2 = new QGraphicsRectItem(0, 0, 30, 30, c_2); - t_1->setBrush(QColor(qrand() % 256, qrand() % 256, qrand() % 256)); - c_1->setBrush(QColor(qrand() % 256, qrand() % 256, qrand() % 256)); - c_1_1->setBrush(QColor(qrand() % 256, qrand() % 256, qrand() % 256)); - c_1_1_1->setBrush(QColor(qrand() % 256, qrand() % 256, qrand() % 256)); - c_1_2->setBrush(QColor(qrand() % 256, qrand() % 256, qrand() % 256)); - c_2->setBrush(QColor(qrand() % 256, qrand() % 256, qrand() % 256)); - c_2_1->setBrush(QColor(qrand() % 256, qrand() % 256, qrand() % 256)); - c_2_1_1->setBrush(QColor(qrand() % 256, qrand() % 256, qrand() % 256)); - c_2_2->setBrush(QColor(qrand() % 256, qrand() % 256, qrand() % 256)); + t_1->setBrush(QColor(QRandomGenerator::global()->bounded(256), QRandomGenerator::global()->bounded(256), QRandomGenerator::global()->bounded(256))); + c_1->setBrush(QColor(QRandomGenerator::global()->bounded(256), QRandomGenerator::global()->bounded(256), QRandomGenerator::global()->bounded(256))); + c_1_1->setBrush(QColor(QRandomGenerator::global()->bounded(256), QRandomGenerator::global()->bounded(256), QRandomGenerator::global()->bounded(256))); + c_1_1_1->setBrush(QColor(QRandomGenerator::global()->bounded(256), QRandomGenerator::global()->bounded(256), QRandomGenerator::global()->bounded(256))); + c_1_2->setBrush(QColor(QRandomGenerator::global()->bounded(256), QRandomGenerator::global()->bounded(256), QRandomGenerator::global()->bounded(256))); + c_2->setBrush(QColor(QRandomGenerator::global()->bounded(256), QRandomGenerator::global()->bounded(256), QRandomGenerator::global()->bounded(256))); + c_2_1->setBrush(QColor(QRandomGenerator::global()->bounded(256), QRandomGenerator::global()->bounded(256), QRandomGenerator::global()->bounded(256))); + c_2_1_1->setBrush(QColor(QRandomGenerator::global()->bounded(256), QRandomGenerator::global()->bounded(256), QRandomGenerator::global()->bounded(256))); + c_2_2->setBrush(QColor(QRandomGenerator::global()->bounded(256), QRandomGenerator::global()->bounded(256), QRandomGenerator::global()->bounded(256))); c_1->setPos(23, 18); c_1_1->setPos(24, 28); diff --git a/tests/auto/widgets/graphicsview/qgraphicsview/tst_qgraphicsview.cpp b/tests/auto/widgets/graphicsview/qgraphicsview/tst_qgraphicsview.cpp index 5b557dba58..f624bb6a5f 100644 --- a/tests/auto/widgets/graphicsview/qgraphicsview/tst_qgraphicsview.cpp +++ b/tests/auto/widgets/graphicsview/qgraphicsview/tst_qgraphicsview.cpp @@ -684,7 +684,7 @@ void tst_QGraphicsView::openGLViewport() view.setViewport(glw); view.show(); - QTest::qWaitForWindowExposed(&view); + QVERIFY(QTest::qWaitForWindowExposed(&view)); QTRY_VERIFY(spy1.count() > 0); QTRY_VERIFY(spy2.count() >= spy1.count()); spy1.clear(); @@ -2899,7 +2899,7 @@ void tst_QGraphicsView::scrollBarRanges() QFETCH(ExpectedValueDescription, vmax); QFETCH(bool, useStyledPanel); - if (useStyledPanel && style == "Macintosh" && platformName == QStringLiteral("cocoa")) + if (useStyledPanel && style == "macintosh" && platformName == QStringLiteral("cocoa")) QSKIP("Insignificant on OSX"); QScopedPointer<QStyle> stylePtr; diff --git a/tests/auto/widgets/itemviews/qabstractitemview/tst_qabstractitemview.cpp b/tests/auto/widgets/itemviews/qabstractitemview/tst_qabstractitemview.cpp index 165c4b079e..1ac66ed5cb 100644 --- a/tests/auto/widgets/itemviews/qabstractitemview/tst_qabstractitemview.cpp +++ b/tests/auto/widgets/itemviews/qabstractitemview/tst_qabstractitemview.cpp @@ -620,7 +620,9 @@ void tst_QAbstractItemView::rowDelegate() QVERIFY(QTest::qWaitForWindowExposed(&view)); QModelIndex index = model.index(3, 0); + QVERIFY(!view.isPersistentEditorOpen(index)); view.openPersistentEditor(index); + QVERIFY(view.isPersistentEditorOpen(index)); QWidget *w = view.indexWidget(index); QVERIFY(w); QCOMPARE(w->metaObject()->className(), "QWidget"); @@ -640,7 +642,9 @@ void tst_QAbstractItemView::columnDelegate() QVERIFY(QTest::qWaitForWindowExposed(&view)); QModelIndex index = model.index(0, 3); + QVERIFY(!view.isPersistentEditorOpen(index)); view.openPersistentEditor(index); + QVERIFY(view.isPersistentEditorOpen(index)); QWidget *w = view.indexWidget(index); QVERIFY(w); QCOMPARE(w->metaObject()->className(), "QWidget"); @@ -1228,8 +1232,8 @@ void tst_QAbstractItemView::task200665_itemEntered() moveCursorAway(&view); view.show(); QVERIFY(QTest::qWaitForWindowExposed(&view)); - QCursor::setPos( view.geometry().center() ); - QCoreApplication::processEvents(); + QCursor::setPos(view.geometry().center()); + QTRY_COMPARE(QCursor::pos(), view.geometry().center()); QSignalSpy spy(&view, SIGNAL(entered(QModelIndex))); view.verticalScrollBar()->setValue(view.verticalScrollBar()->maximum()); @@ -1800,7 +1804,7 @@ void tst_QAbstractItemView::shiftSelectionAfterChangingModelContents() view.setModel(&proxyModel); view.setSelectionMode(QAbstractItemView::ExtendedSelection); view.show(); - QTest::qWaitForWindowExposed(&view); + QVERIFY(QTest::qWaitForWindowExposed(&view)); // Click "C" QTest::mouseClick(view.viewport(), Qt::LeftButton, Qt::NoModifier, view.visualRect(indexC).center()); @@ -1914,7 +1918,7 @@ void tst_QAbstractItemView::QTBUG48968_reentrant_updateEditorGeometries() tree.setRootIsDecorated(false); QObject::connect(&tree, SIGNAL(doubleClicked(QModelIndex)), &tree, SLOT(setRootIndex(QModelIndex))); tree.show(); - QTest::qWaitForWindowActive(&tree); + QVERIFY(QTest::qWaitForWindowActive(&tree)); // Trigger editing idx QModelIndex idx = m->index(1, 0); @@ -2156,7 +2160,7 @@ void tst_QAbstractItemView::testClickToSelect() SetSelectionTestView view; view.setModel(&model); view.show(); - QTest::qWaitForWindowExposed(&view); + QVERIFY(QTest::qWaitForWindowExposed(&view)); QSignalSpy spy(&view, &SetSelectionTestView::setSelectionCalled); diff --git a/tests/auto/widgets/itemviews/qitemdelegate/tst_qitemdelegate.cpp b/tests/auto/widgets/itemviews/qitemdelegate/tst_qitemdelegate.cpp index 5b353bb2ae..2a5895583d 100644 --- a/tests/auto/widgets/itemviews/qitemdelegate/tst_qitemdelegate.cpp +++ b/tests/auto/widgets/itemviews/qitemdelegate/tst_qitemdelegate.cpp @@ -1021,7 +1021,7 @@ void tst_QItemDelegate::decoration() } case QVariant::Image: { QImage img(size, QImage::Format_Mono); - memset(img.bits(), 0, img.byteCount()); + memset(img.bits(), 0, img.sizeInBytes()); value = img; break; } diff --git a/tests/auto/widgets/itemviews/qitemview/tst_qitemview.cpp b/tests/auto/widgets/itemviews/qitemview/tst_qitemview.cpp index 1fd7b31e22..f1239b2e7c 100644 --- a/tests/auto/widgets/itemviews/qitemview/tst_qitemview.cpp +++ b/tests/auto/widgets/itemviews/qitemview/tst_qitemview.cpp @@ -30,16 +30,6 @@ #include <QtTest/QtTest> #include <QtCore/QtCore> #include "viewstotest.cpp" -#include <stdlib.h> - -#if defined(Q_OS_UNIX) || defined(Q_OS_WIN) -#include <time.h> -#endif - -#if defined(Q_OS_WIN) -# define random rand -# define srandom srand -#endif /*! See viewstotest.cpp for instructions on how to have your view tested with these tests. @@ -410,13 +400,15 @@ void touch(QWidget *widget, Qt::KeyboardModifier modifier, Qt::Key keyPress){ int width = widget->width(); int height = widget->height(); for (int i = 0; i < 5; ++i) { - QTest::mouseClick(widget, Qt::LeftButton, modifier, QPoint(random() % width, random() % height)); - QTest::mouseDClick(widget, Qt::LeftButton, modifier, QPoint(random() % width, random() % height)); - QPoint press(random() % width, random() % height); - QPoint releasePoint(random() % width, random() % height); + QTest::mouseClick(widget, Qt::LeftButton, modifier, + QPoint(QRandomGenerator::global()->bounded(width), QRandomGenerator::global()->bounded(height))); + QTest::mouseDClick(widget, Qt::LeftButton, modifier, + QPoint(QRandomGenerator::global()->bounded(width), QRandomGenerator::global()->bounded(height))); + QPoint press(QRandomGenerator::global()->bounded(width), QRandomGenerator::global()->bounded(height)); + QPoint releasePoint(QRandomGenerator::global()->bounded(width), QRandomGenerator::global()->bounded(height)); QTest::mousePress(widget, Qt::LeftButton, modifier, press); QTest::mouseMove(widget, releasePoint); - if (random() % 1 == 0) + if (QRandomGenerator::global()->bounded(1) == 0) QTest::mouseRelease(widget, Qt::LeftButton, 0, releasePoint); else QTest::mouseRelease(widget, Qt::LeftButton, modifier, releasePoint); @@ -443,7 +435,6 @@ void tst_QItemView::spider() view->setModel(treeModel); view->show(); QVERIFY(QTest::qWaitForWindowActive(view)); - srandom(time(0)); touch(view->viewport(), Qt::NoModifier, Qt::Key_Left); touch(view->viewport(), Qt::ShiftModifier, Qt::Key_Enter); touch(view->viewport(), Qt::ControlModifier, Qt::Key_Backspace); diff --git a/tests/auto/widgets/itemviews/qlistview/tst_qlistview.cpp b/tests/auto/widgets/itemviews/qlistview/tst_qlistview.cpp index d8b8546d86..5e0d99f25e 100644 --- a/tests/auto/widgets/itemviews/qlistview/tst_qlistview.cpp +++ b/tests/auto/widgets/itemviews/qlistview/tst_qlistview.cpp @@ -2157,7 +2157,7 @@ void tst_QListView::draggablePaintPairs() view.setModel(&model); view.show(); - QTest::qWaitForWindowExposed(&view); + QVERIFY(QTest::qWaitForWindowExposed(&view)); QModelIndex expectedIndex = model.index(row, 0); QListViewPrivate *privateClass = static_cast<QListViewPrivate *>(QListViewPrivate::get(&view)); @@ -2201,7 +2201,7 @@ void tst_QListView::taskQTBUG_21804_hiddenItemsAndScrollingWithKeys() lv.setSpacing(spacing); lv.setModel(&model); lv.show(); - QTest::qWaitForWindowExposed(&lv); + QVERIFY(QTest::qWaitForWindowExposed(&lv)); // hide every odd number row for (int i = 1; i < model.rowCount(); i+=2) @@ -2273,7 +2273,7 @@ void tst_QListView::spacing() lv.setModel(&model); lv.setSpacing(spacing); lv.show(); - QTest::qWaitForWindowExposed(&lv); + QVERIFY(QTest::qWaitForWindowExposed(&lv)); // check size and position of first two items QRect item1 = lv.visualRect(lv.model()->index(0, 0)); @@ -2304,7 +2304,7 @@ void tst_QListView::testScrollToWithHidden() lv.setSpacing(5); lv.showNormal(); - QTest::qWaitForWindowExposed(&lv); + QVERIFY(QTest::qWaitForWindowExposed(&lv)); QCOMPARE(lv.verticalScrollBar()->value(), 0); @@ -2449,7 +2449,7 @@ void tst_QListView::horizontalScrollingByVerticalWheelEvents() lv.resize(300, 300); lv.show(); - QTest::qWaitForWindowExposed(&lv); + QVERIFY(QTest::qWaitForWindowExposed(&lv)); QPoint globalPos = lv.geometry().center(); QPoint pos = lv.viewport()->geometry().center(); diff --git a/tests/auto/widgets/itemviews/qlistwidget/tst_qlistwidget.cpp b/tests/auto/widgets/itemviews/qlistwidget/tst_qlistwidget.cpp index 6547bb8985..d4cb54b9ff 100644 --- a/tests/auto/widgets/itemviews/qlistwidget/tst_qlistwidget.cpp +++ b/tests/auto/widgets/itemviews/qlistwidget/tst_qlistwidget.cpp @@ -1710,12 +1710,11 @@ void tst_QListWidget::QTBUG50891_ensureSelectionModelSignalConnectionsAreSet() list.setSelectionModel(new QItemSelectionModel(list.model())); list.show(); + QVERIFY(QTest::qWaitForWindowExposed(&list)); QSignalSpy currentItemChangedSpy(&list, SIGNAL(currentItemChanged(QListWidgetItem*,QListWidgetItem*))); QSignalSpy itemSelectionChangedSpy(&list, SIGNAL(itemSelectionChanged())); - QVERIFY(QTest::qWaitForWindowExposed(&list)); - QCOMPARE(currentItemChangedSpy.count(), 0); QCOMPARE(itemSelectionChangedSpy.count(), 0); diff --git a/tests/auto/widgets/itemviews/qtreeview/tst_qtreeview.cpp b/tests/auto/widgets/itemviews/qtreeview/tst_qtreeview.cpp index 6ee0e50cce..929b80ba15 100644 --- a/tests/auto/widgets/itemviews/qtreeview/tst_qtreeview.cpp +++ b/tests/auto/widgets/itemviews/qtreeview/tst_qtreeview.cpp @@ -163,6 +163,9 @@ private slots: void styleOptionViewItem(); void keyboardNavigationWithDisabled(); + void statusTip_data(); + void statusTip(); + // task-specific tests: void task174627_moveLeftToRoot(); void task171902_expandWith1stColHidden(); @@ -205,23 +208,23 @@ public: QtTestModel(int _rows, int _cols, QObject *parent = 0): QAbstractItemModel(parent), fetched(false), rows(_rows), cols(_cols), levels(INT_MAX), wrongIndex(false) { init(); } - void init() { + void init() + { decorationsEnabled = false; + statusTipsEnabled = false; } - inline qint32 level(const QModelIndex &index) const { + inline qint32 level(const QModelIndex &index) const + { return index.isValid() ? qint32(index.internalId()) : qint32(-1); } - bool canFetchMore(const QModelIndex &) const { - return !fetched; - } + bool canFetchMore(const QModelIndex &) const override { return !fetched; } - void fetchMore(const QModelIndex &) { - fetched = true; - } + void fetchMore(const QModelIndex &) override { fetched = true; } - bool hasChildren(const QModelIndex &parent = QModelIndex()) const { + bool hasChildren(const QModelIndex &parent = QModelIndex()) const override + { bool hasFetched = fetched; fetched = true; bool r = QAbstractItemModel::hasChildren(parent); @@ -229,26 +232,29 @@ public: return r; } - int rowCount(const QModelIndex& parent = QModelIndex()) const { + int rowCount(const QModelIndex& parent = QModelIndex()) const override + { if (!fetched) qFatal("%s: rowCount should not be called before fetching", Q_FUNC_INFO); if ((parent.column() > 0) || (level(parent) > levels)) return 0; return rows; } - int columnCount(const QModelIndex& parent = QModelIndex()) const { + int columnCount(const QModelIndex& parent = QModelIndex()) const override + { if ((parent.column() > 0) || (level(parent) > levels)) return 0; return cols; } - bool isEditable(const QModelIndex &index) const { + bool isEditable(const QModelIndex &index) const + { if (index.isValid()) return true; return false; } - QModelIndex index(int row, int column, const QModelIndex &parent = QModelIndex()) const + QModelIndex index(int row, int column, const QModelIndex &parent = QModelIndex()) const override { if (row < 0 || column < 0 || (level(parent) > levels) || column >= cols || row >= rows) { return QModelIndex(); @@ -258,14 +264,14 @@ public: return i; } - QModelIndex parent(const QModelIndex &index) const + QModelIndex parent(const QModelIndex &index) const override { if (!parentHash.contains(index)) return QModelIndex(); return parentHash[index]; } - QVariant data(const QModelIndex &idx, int role) const + QVariant data(const QModelIndex &idx, int role) const override { if (!idx.isValid()) return QVariant(); @@ -288,6 +294,19 @@ public: pm.fill(QColor::fromHsv((idx.column() % 16)*8 + 64, 254, (idx.row() % 16)*8 + 32)); return pm; } + if (statusTipsEnabled && role == Qt::StatusTipRole) + return QString("[%1,%2,%3] -- Status").arg(idx.row()).arg(idx.column()).arg(level(idx)); + return QVariant(); + } + + QVariant headerData(int section, Qt::Orientation orientation, + int role = Qt::DisplayRole) const override + { + Q_UNUSED(orientation); + if (section < 0 || section >= columnCount()) + return QVariant(); + if (statusTipsEnabled && role == Qt::StatusTipRole) + return QString("Header %1 -- Status").arg(section); return QVariant(); } @@ -333,6 +352,7 @@ public: mutable bool fetched; bool decorationsEnabled; + bool statusTipsEnabled; int rows, cols; int levels; mutable bool wrongIndex; @@ -4214,7 +4234,7 @@ void tst_QTreeView::testInitialFocus() treeWidget.header()->hideSection(0); // make sure we skip hidden section(s) treeWidget.header()->swapSections(1, 2); // make sure that we look for first visual index (and not first logical) treeWidget.show(); - QTest::qWaitForWindowExposed(&treeWidget); + QVERIFY(QTest::qWaitForWindowExposed(&treeWidget)); QApplication::processEvents(); QCOMPARE(treeWidget.currentIndex().column(), 2); } @@ -4237,7 +4257,7 @@ void tst_QTreeView::quickExpandCollapse() QVERIFY(rootIndex.isValid()); tree.show(); - QTest::qWaitForWindowExposed(&tree); + QVERIFY(QTest::qWaitForWindowExposed(&tree)); const QAbstractItemView::State initialState = tree.state(); @@ -4399,5 +4419,52 @@ void tst_QTreeView::taskQTBUG_7232_AllowUserToControlSingleStep() QCOMPARE(hStep1, t.horizontalScrollBar()->singleStep()); } +void tst_QTreeView::statusTip_data() +{ + QTest::addColumn<bool>("intermediateParent"); + QTest::newRow("noIntermediate") << false; + QTest::newRow("intermediate") << true; +} + +void tst_QTreeView::statusTip() +{ + QFETCH(bool, intermediateParent); + QMainWindow mw; + QtTestModel model; + model.statusTipsEnabled = true; + model.rows = model.cols = 5; + QTreeView *view = new QTreeView; + view->setModel(&model); + view->viewport()->setMouseTracking(true); + view->header()->viewport()->setMouseTracking(true); + if (intermediateParent) { + QWidget *inter = new QWidget; + QVBoxLayout *vbox = new QVBoxLayout; + inter->setLayout(vbox); + vbox->addWidget(view); + mw.setCentralWidget(inter); + } else { + mw.setCentralWidget(view); + } + mw.statusBar(); + mw.setGeometry(QRect(QPoint(QApplication::desktop()->geometry().center() - QPoint(250, 250)), + QSize(500, 500))); + mw.show(); + qApp->setActiveWindow(&mw); + QVERIFY(QTest::qWaitForWindowActive(&mw)); + // Ensure it is moved away first and then moved to the relevant section + QTest::mouseMove(mw.windowHandle(), view->mapTo(&mw, view->rect().bottomLeft() + QPoint(20, 20))); + QPoint centerPoint = view->viewport()->mapTo(&mw, view->visualRect(model.index(0, 0)).center()); + QTest::mouseMove(mw.windowHandle(), centerPoint); + QTRY_COMPARE(mw.statusBar()->currentMessage(), QLatin1String("[0,0,0] -- Status")); + centerPoint = view->viewport()->mapTo(&mw, view->visualRect(model.index(0, 1)).center()); + QTest::mouseMove(mw.windowHandle(), centerPoint); + QTRY_COMPARE(mw.statusBar()->currentMessage(), QLatin1String("[0,1,0] -- Status")); + centerPoint = view->header()->viewport()->mapTo(&mw, + QPoint(view->header()->sectionViewportPosition(0) + view->header()->sectionSize(0) / 2, + view->header()->height() / 2)); + QTest::mouseMove(mw.windowHandle(), centerPoint); + QTRY_COMPARE(mw.statusBar()->currentMessage(), QLatin1String("Header 0 -- Status")); +} QTEST_MAIN(tst_QTreeView) #include "tst_qtreeview.moc" diff --git a/tests/auto/widgets/kernel/kernel.pro b/tests/auto/widgets/kernel/kernel.pro index 20720dc928..73fd934502 100644 --- a/tests/auto/widgets/kernel/kernel.pro +++ b/tests/auto/widgets/kernel/kernel.pro @@ -6,6 +6,7 @@ SUBDIRS=\ qboxlayout \ qdesktopwidget \ qformlayout \ + qgesturerecognizer \ qgridlayout \ qlayout \ qstackedlayout \ @@ -19,4 +20,7 @@ SUBDIRS=\ qshortcut \ qsizepolicy +darwin:SUBDIRS -= \ # Uses native recognizers + qgesturerecognizer \ + SUBDIRS -= qsound diff --git a/tests/auto/widgets/kernel/qaction/tst_qaction.cpp b/tests/auto/widgets/kernel/qaction/tst_qaction.cpp index 88ddb7c11d..ac0174d19a 100644 --- a/tests/auto/widgets/kernel/qaction/tst_qaction.cpp +++ b/tests/auto/widgets/kernel/qaction/tst_qaction.cpp @@ -64,6 +64,7 @@ private slots: void task229128TriggeredSignalWhenInActiongroup(); void repeat(); void setData(); + void keysequence(); // QTBUG-53381 void disableShortcutsWithBlockedWidgets_data(); void disableShortcutsWithBlockedWidgets(); @@ -280,6 +281,40 @@ void tst_QAction::alternateShortcuts() QTest::keyClick(&testWidget, Qt::Key_A, Qt::ControlModifier); } +void tst_QAction::keysequence() +{ + MyWidget testWidget(this); + testWidget.show(); + QApplication::setActiveWindow(&testWidget); + + { + QAction act(&testWidget); + testWidget.addAction(&act); + + QKeySequence ks(QKeySequence::SelectAll); + + act.setShortcut(ks); + + QSignalSpy spy(&act, &QAction::triggered); + + act.setAutoRepeat(true); + QTest::keySequence(&testWidget, ks); + QCoreApplication::processEvents(); + QCOMPARE(spy.count(), 1); // act should have been triggered + + act.setAutoRepeat(false); + QTest::keySequence(&testWidget, ks); + QCoreApplication::processEvents(); + QCOMPARE(spy.count(), 2); //act should have been triggered a 2nd time + + // end of the scope of the action, it will be destroyed and removed from widget + // This action should also unregister its shortcuts + } + + // this tests a crash (if the action did not unregister its alternate shortcuts) + QTest::keyClick(&testWidget, Qt::Key_A, Qt::ControlModifier); +} + void tst_QAction::enabledVisibleInteraction() { MyWidget testWidget(this); diff --git a/tests/auto/widgets/kernel/qboxlayout/tst_qboxlayout.cpp b/tests/auto/widgets/kernel/qboxlayout/tst_qboxlayout.cpp index 1dac242114..7262817d23 100644 --- a/tests/auto/widgets/kernel/qboxlayout/tst_qboxlayout.cpp +++ b/tests/auto/widgets/kernel/qboxlayout/tst_qboxlayout.cpp @@ -156,7 +156,7 @@ void tst_QBoxLayout::sizeHint() lay1->addLayout(lay2); window.setLayout(lay1); window.show(); - QTest::qWaitForWindowExposed(&window); + QVERIFY(QTest::qWaitForWindowExposed(&window)); label->setText("foooooooo baaaaaaar"); QSize sh = lay1->sizeHint(); QApplication::processEvents(); @@ -177,7 +177,7 @@ void tst_QBoxLayout::sizeConstraints() lay->setSizeConstraint(QLayout::SetFixedSize); window.setLayout(lay); window.show(); - QTest::qWaitForWindowExposed(&window); + QVERIFY(QTest::qWaitForWindowExposed(&window)); QSize sh = window.sizeHint(); delete lay->takeAt(1); QVERIFY(sh.width() >= window.sizeHint().width() && @@ -224,7 +224,7 @@ void tst_QBoxLayout::setStyleShouldChangeSpacing() style1->hspacing = 6; window.setStyle(style1.data()); window.show(); - QTest::qWaitForWindowExposed(&window); + QVERIFY(QTest::qWaitForWindowExposed(&window)); int spacing = pb2->geometry().left() - pb1->geometry().right() - 1; QCOMPARE(spacing, 6); diff --git a/tests/auto/widgets/gestures/qgesturerecognizer/BLACKLIST b/tests/auto/widgets/kernel/qgesturerecognizer/BLACKLIST index 7f55c2dae0..7f55c2dae0 100644 --- a/tests/auto/widgets/gestures/qgesturerecognizer/BLACKLIST +++ b/tests/auto/widgets/kernel/qgesturerecognizer/BLACKLIST diff --git a/tests/auto/widgets/gestures/qgesturerecognizer/qgesturerecognizer.pro b/tests/auto/widgets/kernel/qgesturerecognizer/qgesturerecognizer.pro index 7c9ddcfb03..7c9ddcfb03 100644 --- a/tests/auto/widgets/gestures/qgesturerecognizer/qgesturerecognizer.pro +++ b/tests/auto/widgets/kernel/qgesturerecognizer/qgesturerecognizer.pro diff --git a/tests/auto/widgets/gestures/qgesturerecognizer/tst_qgesturerecognizer.cpp b/tests/auto/widgets/kernel/qgesturerecognizer/tst_qgesturerecognizer.cpp index c3ebb838bb..c3ebb838bb 100644 --- a/tests/auto/widgets/gestures/qgesturerecognizer/tst_qgesturerecognizer.cpp +++ b/tests/auto/widgets/kernel/qgesturerecognizer/tst_qgesturerecognizer.cpp diff --git a/tests/auto/widgets/kernel/qwidget/BLACKLIST b/tests/auto/widgets/kernel/qwidget/BLACKLIST index a04a67e4be..0b1d7b4437 100644 --- a/tests/auto/widgets/kernel/qwidget/BLACKLIST +++ b/tests/auto/widgets/kernel/qwidget/BLACKLIST @@ -74,7 +74,7 @@ osx [setClearAndResizeMask] osx [setToolTip] -osx-10.9 +osx [moveInResizeEvent] ubuntu-14.04 [moveChild:right] diff --git a/tests/auto/widgets/kernel/qwidget/qwidget.pro b/tests/auto/widgets/kernel/qwidget/qwidget.pro index 3e4e96760b..c1908af2a2 100644 --- a/tests/auto/widgets/kernel/qwidget/qwidget.pro +++ b/tests/auto/widgets/kernel/qwidget/qwidget.pro @@ -12,7 +12,7 @@ aix-g++*:QMAKE_CXXFLAGS+=-fpermissive CONFIG += x11inc mac { - LIBS += -framework Security -framework AppKit -framework Carbon + LIBS += -framework Security -framework AppKit OBJECTIVE_SOURCES += tst_qwidget_mac_helpers.mm } diff --git a/tests/auto/widgets/kernel/qwidget/tst_qwidget.cpp b/tests/auto/widgets/kernel/qwidget/tst_qwidget.cpp index c1bff5b00a..cf2794903e 100644 --- a/tests/auto/widgets/kernel/qwidget/tst_qwidget.cpp +++ b/tests/auto/widgets/kernel/qwidget/tst_qwidget.cpp @@ -50,6 +50,7 @@ #include <qcalendarwidget.h> #include <qmainwindow.h> #include <qdockwidget.h> +#include <qrandom.h> #include <qtoolbar.h> #include <qtoolbutton.h> #include <QtGui/qpaintengine.h> @@ -183,7 +184,10 @@ private slots: void mapFromAndTo(); void focusChainOnHide(); void focusChainOnReparent(); - void setTabOrder(); + void defaultTabOrder(); + void reverseTabOrder(); + void tabOrderWithProxy(); + void tabOrderWithCompoundWidgets(); #ifdef Q_OS_WIN void activation(); #endif @@ -1650,79 +1654,281 @@ public: class Composite : public QFrame { public: - Composite(QWidget* parent = 0, const char* name = 0) + Composite(QWidget* parent = 0, const QString &name = 0) : QFrame(parent) { setObjectName(name); - //QHBoxLayout* hbox = new QHBoxLayout(this, 2, 0); - //hbox->setAutoAdd(true); + + lineEdit1 = new QLineEdit; + lineEdit2 = new QLineEdit; + lineEdit3 = new QLineEdit; + lineEdit3->setEnabled(false); + QHBoxLayout* hbox = new QHBoxLayout(this); + hbox->addWidget(lineEdit1); + hbox->addWidget(lineEdit2); + hbox->addWidget(lineEdit3); + } - lineEdit = new QLineEdit(this); - hbox->addWidget(lineEdit); +public: + QLineEdit *lineEdit1; + QLineEdit *lineEdit2; + QLineEdit *lineEdit3; +}; - button = new QPushButton(this); - hbox->addWidget(button); - button->setFocusPolicy( Qt::NoFocus ); +void tst_QWidget::defaultTabOrder() +{ + const int compositeCount = 2; + Container container; + Composite *composite[compositeCount]; - setFocusProxy( lineEdit ); - setFocusPolicy( Qt::StrongFocus ); + QLineEdit *firstEdit = new QLineEdit; + container.box->addWidget(firstEdit); - setTabOrder(lineEdit, button); + for (int i = 0; i < compositeCount; i++) { + composite[i] = new Composite(); + container.box->addWidget(composite[i]); } -private: - QLineEdit* lineEdit; - QPushButton* button; -}; + QLineEdit *lastEdit = new QLineEdit(); + container.box->addWidget(lastEdit); -#define NUM_WIDGETS 4 + container.show(); + container.activateWindow(); + qApp->setActiveWindow(&container); + QVERIFY(QTest::qWaitForWindowActive(&container)); -void tst_QWidget::setTabOrder() -{ - QTest::qWait(100); + QTRY_VERIFY(firstEdit->hasFocus()); + // Check that focus moves between the line edits when we tab forward + for (int i = 0; i < compositeCount; ++i) { + container.tab(); + QVERIFY(composite[i]->lineEdit1->hasFocus()); + QVERIFY(!composite[i]->lineEdit2->hasFocus()); + container.tab(); + QVERIFY(!composite[i]->lineEdit1->hasFocus()); + QVERIFY(composite[i]->lineEdit2->hasFocus()); + } + + container.tab(); + QVERIFY(lastEdit->hasFocus()); + + // Check that focus moves between the line edits in reverse + // order when we tab backwards + for (int i = compositeCount - 1; i >= 0; --i) { + container.backTab(); + QVERIFY(!composite[i]->lineEdit1->hasFocus()); + QVERIFY(composite[i]->lineEdit2->hasFocus()); + + container.backTab(); + QVERIFY(composite[i]->lineEdit1->hasFocus()); + QVERIFY(!composite[i]->lineEdit2->hasFocus()); + } + + container.backTab(); + QVERIFY(firstEdit->hasFocus()); +} + +void tst_QWidget::reverseTabOrder() +{ + const int compositeCount = 2; Container container; - container.setObjectName("setTabOrder"); - container.setWindowTitle(container.objectName()); + Composite* composite[compositeCount]; + + QLineEdit *firstEdit = new QLineEdit(); + container.box->addWidget(firstEdit); + + for (int i = 0; i < compositeCount; i++) { + composite[i] = new Composite(); + container.box->addWidget(composite[i]); + } + + QLineEdit *lastEdit = new QLineEdit(); + container.box->addWidget(lastEdit); - Composite* comp[NUM_WIDGETS]; + // Reverse tab order inside each composite + for (int i = 0; i < compositeCount; ++i) + QWidget::setTabOrder(composite[i]->lineEdit2, composite[i]->lineEdit1); - QLineEdit *firstEdit = new QLineEdit(&container); + container.show(); + container.activateWindow(); + qApp->setActiveWindow(&container); + QVERIFY(QTest::qWaitForWindowActive(&container)); + + QTRY_VERIFY(firstEdit->hasFocus()); + + // Check that focus moves in reverse order when tabbing inside the composites + // (but in the correct order when tabbing between them) + for (int i = 0; i < compositeCount; ++i) { + container.tab(); + QVERIFY(!composite[i]->lineEdit1->hasFocus()); + QVERIFY(composite[i]->lineEdit2->hasFocus()); + container.tab(); + QVERIFY(composite[i]->lineEdit1->hasFocus()); + QVERIFY(!composite[i]->lineEdit2->hasFocus()); + } + + container.tab(); + QVERIFY(lastEdit->hasFocus()); + + // Check that focus moves in "normal" order when tabbing backwards inside the + // composites (since backwards of reversed order cancels each other out), + // but in the reverse order when tabbing between them. + for (int i = compositeCount - 1; i >= 0; --i) { + container.backTab(); + QVERIFY(composite[i]->lineEdit1->hasFocus()); + QVERIFY(!composite[i]->lineEdit2->hasFocus()); + container.backTab(); + QVERIFY(!composite[i]->lineEdit1->hasFocus()); + QVERIFY(composite[i]->lineEdit2->hasFocus()); + } + + container.backTab(); + QVERIFY(firstEdit->hasFocus()); +} + +void tst_QWidget::tabOrderWithProxy() +{ + const int compositeCount = 2; + Container container; + Composite* composite[compositeCount]; + + QLineEdit *firstEdit = new QLineEdit(); container.box->addWidget(firstEdit); - int i = 0; - for(i = 0; i < NUM_WIDGETS; i++) { - comp[i] = new Composite(&container); - container.box->addWidget(comp[i]); + for (int i = 0; i < compositeCount; i++) { + composite[i] = new Composite(); + container.box->addWidget(composite[i]); + + // Set second child as focus proxy + composite[i]->setFocusPolicy(Qt::StrongFocus); + composite[i]->setFocusProxy(composite[i]->lineEdit2); } - QLineEdit *lastEdit = new QLineEdit(&container); + QLineEdit *lastEdit = new QLineEdit(); container.box->addWidget(lastEdit); - container.setTabOrder(lastEdit, comp[NUM_WIDGETS-1]); - for(i = NUM_WIDGETS-1; i > 0; i--) { - container.setTabOrder(comp[i], comp[i-1]); + container.show(); + container.activateWindow(); + qApp->setActiveWindow(&container); + QVERIFY(QTest::qWaitForWindowActive(&container)); + + QTRY_VERIFY(firstEdit->hasFocus()); + + // Check that focus moves between the second line edits + // (the focus proxies) when we tab forward + for (int i = 0; i < compositeCount; ++i) { + container.tab(); + QVERIFY(!composite[i]->lineEdit1->hasFocus()); + QVERIFY(composite[i]->lineEdit2->hasFocus()); } - container.setTabOrder(comp[0], firstEdit); - int current = NUM_WIDGETS-1; - lastEdit->setFocus(); + container.tab(); + QVERIFY(lastEdit->hasFocus()); + + // Check that focus moves between the line edits + // in reverse order when we tab backwards. + // Note that in this case, the focus proxies should not + // be taken into consideration, since they only take + // effect when tabbing forward + for (int i = compositeCount - 1; i >= 0; --i) { + container.backTab(); + QVERIFY(!composite[i]->lineEdit1->hasFocus()); + QVERIFY(composite[i]->lineEdit2->hasFocus()); + container.backTab(); + QVERIFY(composite[i]->lineEdit1->hasFocus()); + QVERIFY(!composite[i]->lineEdit2->hasFocus()); + } + + container.backTab(); + QVERIFY(firstEdit->hasFocus()); +} + +void tst_QWidget::tabOrderWithCompoundWidgets() +{ + const int compositeCount = 4; + Container container; + Composite *composite[compositeCount]; + + QLineEdit *firstEdit = new QLineEdit(); + container.box->addWidget(firstEdit); + + for (int i = 0; i < compositeCount; i++) { + composite[i] = new Composite(0, QStringLiteral("Composite: ") + QString::number(i)); + container.box->addWidget(composite[i]); + + // Let the composite handle focus, and set a child as focus proxy (use the second child, just + // to ensure that we don't just tab to the first child by coinsidence). This will make the + // composite "compound". Also enable the last line edit to have a bit more data to check when + // tabbing forwards. + composite[i]->setFocusPolicy(Qt::StrongFocus); + composite[i]->setFocusProxy(composite[i]->lineEdit2); + composite[i]->lineEdit3->setEnabled(true); + } + + QLineEdit *lastEdit = new QLineEdit(); + container.box->addWidget(lastEdit); + + // Reverse tab order between each composite + // (but not inside them), including first and last line edit. + // The result should not affect local tab order inside each + // composite, only between them. + QWidget::setTabOrder(lastEdit, composite[compositeCount - 1]); + for (int i = compositeCount - 1; i >= 1; --i) + QWidget::setTabOrder(composite[i], composite[i-1]); + QWidget::setTabOrder(composite[0], firstEdit); container.show(); container.activateWindow(); qApp->setActiveWindow(&container); QVERIFY(QTest::qWaitForWindowActive(&container)); + lastEdit->setFocus(); QTRY_VERIFY(lastEdit->hasFocus()); - container.tab(); - do { - QVERIFY(comp[current]->focusProxy()->hasFocus()); + + // Check that focus moves between the line edits in the normal + // order when tabbing inside each compound, but in the reverse + // order when tabbing between them. Since the composites have + // lineEdit2 as focus proxy, lineEdit2 will be the first with focus + // when the compound gets focus, and lineEdit1 will therefore be skipped. + for (int i = compositeCount - 1; i >= 0; --i) { + container.tab(); + Composite *c = composite[i]; + QVERIFY(!c->lineEdit1->hasFocus()); + QVERIFY(c->lineEdit2->hasFocus()); + QVERIFY(!c->lineEdit3->hasFocus()); container.tab(); - current--; - } while (current >= 0); + QVERIFY(!c->lineEdit1->hasFocus()); + QVERIFY(!c->lineEdit2->hasFocus()); + QVERIFY(c->lineEdit3->hasFocus()); + } + container.tab(); QVERIFY(firstEdit->hasFocus()); + + // Check that focus moves in reverse order when backTab inside the composites, but + // in the 'correct' order when backTab between them (since the composites are in reverse tab + // order from before, which cancels it out). Note that when we backtab into a compound, we start + // at lineEdit3 rather than the focus proxy, since that is the reverse of what happens when we tab + // forward. And this time we will also backtab to lineEdit1, since there is no focus proxy that interferes. + for (int i = 0; i < compositeCount; ++i) { + container.backTab(); + Composite *c = composite[i]; + QVERIFY(!c->lineEdit1->hasFocus()); + QVERIFY(!c->lineEdit2->hasFocus()); + QVERIFY(c->lineEdit3->hasFocus()); + container.backTab(); + QVERIFY(!c->lineEdit1->hasFocus()); + QVERIFY(c->lineEdit2->hasFocus()); + QVERIFY(!c->lineEdit3->hasFocus()); + container.backTab(); + QVERIFY(c->lineEdit1->hasFocus()); + QVERIFY(!c->lineEdit2->hasFocus()); + QVERIFY(!c->lineEdit3->hasFocus()); + } + + container.backTab(); + QVERIFY(lastEdit->hasFocus()); } #ifdef Q_OS_WIN @@ -1787,9 +1993,11 @@ void tst_QWidget::windowState() QCOMPARE(widget1.pos(), pos); QCOMPARE(widget1.size(), size); -#define VERIFY_STATE(s) QCOMPARE(int(widget1.windowState() & stateMask), int(s)) +#define VERIFY_STATE(s) \ + QCOMPARE(int(widget1.windowState() & stateMask), int(s)); \ + QCOMPARE(int(widget1.windowHandle()->windowStates() & stateMask), int(s)) - const int stateMask = Qt::WindowMaximized|Qt::WindowMinimized|Qt::WindowFullScreen; + const auto stateMask = Qt::WindowMaximized | Qt::WindowMinimized | Qt::WindowFullScreen; widget1.setWindowState(Qt::WindowMaximized); QTest::qWait(100); @@ -2079,7 +2287,7 @@ void tst_QWidget::resizeEvent() wParent.resize(200, 200); ResizeWidget wChild(&wParent); wParent.show(); - QTest::qWaitForWindowExposed(&wParent); + QVERIFY(QTest::qWaitForWindowExposed(&wParent)); QCOMPARE (wChild.m_resizeEventCount, 1); // initial resize event before paint wParent.hide(); QSize safeSize(640,480); @@ -2095,7 +2303,7 @@ void tst_QWidget::resizeEvent() ResizeWidget wTopLevel; wTopLevel.resize(200, 200); wTopLevel.show(); - QTest::qWaitForWindowExposed(&wTopLevel); + QVERIFY(QTest::qWaitForWindowExposed(&wTopLevel)); QCOMPARE (wTopLevel.m_resizeEventCount, 1); // initial resize event before paint for toplevels wTopLevel.hide(); QSize safeSize(640,480); @@ -2104,7 +2312,7 @@ void tst_QWidget::resizeEvent() wTopLevel.resize(safeSize); QCOMPARE (wTopLevel.m_resizeEventCount, 1); wTopLevel.show(); - QTest::qWaitForWindowExposed(&wTopLevel); + QVERIFY(QTest::qWaitForWindowExposed(&wTopLevel)); QCOMPARE (wTopLevel.m_resizeEventCount, 2); } } @@ -8060,8 +8268,8 @@ void tst_QWidget::setMaskInResizeEvent() QRegion expectedParentUpdate(0, 0, 100, 10); // Old testWidget area. expectedParentUpdate += testWidget.geometry(); // New testWidget area. - QCOMPARE(w.paintedRegion, expectedParentUpdate); - QCOMPARE(testWidget.paintedRegion, testWidget.mask()); + QTRY_COMPARE(w.paintedRegion, expectedParentUpdate); + QTRY_COMPARE(testWidget.paintedRegion, testWidget.mask()); testWidget.paintedRegion = QRegion(); // Now resize the widget again, but in the oposite direction @@ -9609,7 +9817,7 @@ void tst_QWidget::grab() for (int row = 0; row < image.height(); ++row) { QRgb *line = reinterpret_cast<QRgb *>(image.scanLine(row)); for (int col = 0; col < image.width(); ++col) - line[col] = qRgba(rand() & 255, row, col, opaque ? 255 : 127); + line[col] = qRgba(QRandomGenerator::global()->bounded(255), row, col, opaque ? 255 : 127); } QPalette pal = widget.palette(); @@ -10489,6 +10697,8 @@ void tst_QWidget::qmlSetParentHelper() void tst_QWidget::testForOutsideWSRangeFlag() { + QSKIP("Test assumes QWindows can have 0x0 size, see QTBUG-61953"); + // QTBUG-49445 { QWidget widget; 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 e4564a8640..b76c4d35a8 100644 --- a/tests/auto/widgets/kernel/qwidget_window/tst_qwidget_window.cpp +++ b/tests/auto/widgets/kernel/qwidget_window/tst_qwidget_window.cpp @@ -96,6 +96,11 @@ private slots: void QTBUG_50561_QCocoaBackingStore_paintDevice_crash(); + void setWindowState_data(); + void setWindowState(); + + void nativeShow(); + void QTBUG_56277_resize_on_showEvent(); }; @@ -842,7 +847,7 @@ void tst_QWidget_window::QTBUG_50561_QCocoaBackingStore_paintDevice_crash() QMainWindow w; w.addToolBar(new QToolBar(&w)); w.show(); - QTest::qWaitForWindowExposed(&w); + QVERIFY(QTest::qWaitForWindowExposed(&w)); // Simulate window system close QCloseEvent *e = new QCloseEvent; @@ -859,6 +864,72 @@ void tst_QWidget_window::QTBUG_50561_QCocoaBackingStore_paintDevice_crash() w.close(); } +void tst_QWidget_window::setWindowState_data() +{ + QString platformName = QGuiApplication::platformName().toLower(); + + QTest::addColumn<Qt::WindowStates>("state"); + QTest::newRow("0") << Qt::WindowStates(); + QTest::newRow("Qt::WindowMaximized") << Qt::WindowStates(Qt::WindowMaximized); + QTest::newRow("Qt::WindowMinimized") << Qt::WindowStates(Qt::WindowMinimized); + QTest::newRow("Qt::WindowFullScreen") << Qt::WindowStates(Qt::WindowFullScreen); + + if (platformName != "xcb" && platformName != "windows" && !platformName.startsWith("wayland") + && platformName != "offscreen") + return; // Combination of states is not preserved on all platforms. + if (platformName == "xcb" && qgetenv("XDG_CURRENT_DESKTOP") != "KDE" + && qgetenv("XDG_CURRENT_DESKTOP") != "Unity") + return; // Not all window managers support state combinations. + + QTest::newRow("Qt::WindowMaximized|Qt::WindowMinimized") + << (Qt::WindowMaximized | Qt::WindowMinimized); + QTest::newRow("Qt::WindowFullScreen|Qt::WindowMinimized") + << (Qt::WindowFullScreen | Qt::WindowMinimized); + QTest::newRow("Qt::WindowMaximized|Qt::WindowFullScreen") + << (Qt::WindowMaximized | Qt::WindowFullScreen); + QTest::newRow("Qt::WindowMaximized|Qt::WindowFullScreen|Qt::WindowMinimized") + << (Qt::WindowMaximized | Qt::WindowFullScreen | Qt::WindowMinimized); +} + +void tst_QWidget_window::setWindowState() +{ + QFETCH(Qt::WindowStates, state); + + // This tests make sure that the states are preserved when the window is shown. + + QWidget w; + w.setWindowState(state); + QCOMPARE(w.windowState(), state); + w.show(); + QCOMPARE(w.windowState(), state); + QCOMPARE(w.windowHandle()->windowStates(), state); + if (!(state & Qt::WindowMinimized)) + QVERIFY(QTest::qWaitForWindowExposed(&w)); + QTRY_COMPARE(w.windowState(), state); + QCOMPARE(w.windowHandle()->windowStates(), state); + + // Minimizing keeps other states + w.showMinimized(); + QCOMPARE(w.windowState(), state | Qt::WindowMinimized); + QTest::qWait(100); + QCOMPARE(w.windowState(), state | Qt::WindowMinimized); + QCOMPARE(w.windowHandle()->windowStates(), state | Qt::WindowMinimized); +} + +void tst_QWidget_window::nativeShow() +{ + // Verify that a native widget can be shown using the QWindow::setVisible() API + QWidget w; + w.winId(); + w.windowHandle()->setVisible(true); + QVERIFY(QTest::qWaitForWindowExposed(&w)); + QVERIFY(w.isVisible()); + + // ... and that we can hide it + w.windowHandle()->setVisible(false); + QTRY_VERIFY(!w.isVisible()); +} + class ResizedOnShowEventWidget : public QWidget { public: diff --git a/tests/auto/widgets/styles/qmacstyle/qmacstyle.pro b/tests/auto/widgets/styles/qmacstyle/qmacstyle.pro index 4cd85ab7f2..90bf134ef1 100644 --- a/tests/auto/widgets/styles/qmacstyle/qmacstyle.pro +++ b/tests/auto/widgets/styles/qmacstyle/qmacstyle.pro @@ -1,4 +1,4 @@ CONFIG += testcase TARGET = tst_qmacstyle -QT += widgets testlib +QT += widgets-private testlib SOURCES += tst_qmacstyle.cpp diff --git a/tests/auto/widgets/styles/qmacstyle/tst_qmacstyle.cpp b/tests/auto/widgets/styles/qmacstyle/tst_qmacstyle.cpp index fbd1505b30..2ab2fa4c86 100644 --- a/tests/auto/widgets/styles/qmacstyle/tst_qmacstyle.cpp +++ b/tests/auto/widgets/styles/qmacstyle/tst_qmacstyle.cpp @@ -29,12 +29,11 @@ #include <QtTest/QtTest> #include <QtWidgets> +#include <private/qstylehelper_p.h> const int N = 1; -enum Size { Normal, Small, Mini }; - -Q_DECLARE_METATYPE(Size); +Q_DECLARE_METATYPE(QStyleHelper::WidgetSizePolicy); #define CT(E) \ static const ControlType E = QSizePolicy::E; @@ -63,7 +62,7 @@ class tst_QMacStyle : public QObject Q_OBJECT public: - tst_QMacStyle() { qRegisterMetaType<Size>("Size"); } + tst_QMacStyle() { qRegisterMetaType<QStyleHelper::WidgetSizePolicy>("WidgetSizePolicy"); } private slots: void sizeHints_data(); @@ -85,27 +84,27 @@ private: static QSize gap(QWidget *widget1, QWidget *widget2); static int hgap(QWidget *widget1, QWidget *widget2) { return gap(widget1, widget2).width(); } static int vgap(QWidget *widget1, QWidget *widget2) { return gap(widget1, widget2).height(); } - static void setSize(QWidget *widget, Size size); + static void setSize(QWidget *widget, QStyleHelper::WidgetSizePolicy size); static int spacing(ControlType control1, ControlType control2, Qt::Orientation orientation, QStyleOption *option = 0, QWidget *widget = 0); - static int hspacing(ControlType control1, ControlType control2, Size size = Normal); - static int vspacing(ControlType control1, ControlType control2, Size size = Normal); + static int hspacing(ControlType control1, ControlType control2, QStyleHelper::WidgetSizePolicy size = QStyleHelper::SizeLarge); + static int vspacing(ControlType control1, ControlType control2, QStyleHelper::WidgetSizePolicy size = QStyleHelper::SizeLarge); }; #define SIZE(x, y, z) \ - ((size == Normal) ? (x) : (size == Small) ? (y) : (z)) + ((size == QStyleHelper::SizeLarge) ? (x) : (size == QStyleHelper::SizeSmall) ? (y) : (z)) void tst_QMacStyle::sizeHints_data() { - QTest::addColumn<Size>("size"); - QTest::newRow("normal") << Normal; -// QTest::newRow("small") << Small; -// QTest::newRow("mini") << Mini; + QTest::addColumn<QStyleHelper::WidgetSizePolicy>("size"); + QTest::newRow("normal") << QStyleHelper::SizeLarge; +// QTest::newRow("small") << QStyleHelper::SizeSmall; +// QTest::newRow("mini") << QStyleHelper::SizeMini; } void tst_QMacStyle::sizeHints() { - QFETCH(Size, size); + QFETCH(QStyleHelper::WidgetSizePolicy, size); QDialog w; setSize(&w, size); @@ -160,7 +159,7 @@ void tst_QMacStyle::sizeHints() QPushButton cancel1("Cancel", &w); QSize s1 = sh(&ok1); - if (size == Normal) { + if (size == QStyleHelper::SizeLarge) { // AHIG says 68, Builder does 70, and Qt seems to do 69 QVERIFY(s1.width() >= 68 && s1.width() <= 70); } @@ -222,7 +221,7 @@ void tst_QMacStyle::layoutMargins_data() void tst_QMacStyle::layoutMargins() { - QFETCH(Size, size); + QFETCH(QStyleHelper::WidgetSizePolicy, size); QWidget w; setSize(&w, size); @@ -235,7 +234,7 @@ void tst_QMacStyle::layoutSpacings_data() void tst_QMacStyle::layoutSpacings() { - QFETCH(Size, size); + QFETCH(QStyleHelper::WidgetSizePolicy, size); /* Constraints specified by AHIG. @@ -304,16 +303,16 @@ QSize tst_QMacStyle::gap(QWidget *widget1, QWidget *widget2) return s + QSize(d.x(), d.y()); } -void tst_QMacStyle::setSize(QWidget *widget, Size size) +void tst_QMacStyle::setSize(QWidget *widget, QStyleHelper::WidgetSizePolicy size) { switch (size) { - case Normal: + case QStyleHelper::SizeLarge: widget->setAttribute(Qt::WA_MacNormalSize, true); break; - case Small: + case QStyleHelper::SizeSmall: widget->setAttribute(Qt::WA_MacSmallSize, true); break; - case Mini: + case QStyleHelper::SizeMini: widget->setAttribute(Qt::WA_MacMiniSize, true); } } @@ -324,7 +323,7 @@ int tst_QMacStyle::spacing(ControlType control1, ControlType control2, Qt::Orien return QApplication::style()->layoutSpacing(control1, control2, orientation, option, widget); } -int tst_QMacStyle::hspacing(ControlType control1, ControlType control2, Size size) +int tst_QMacStyle::hspacing(ControlType control1, ControlType control2, QStyleHelper::WidgetSizePolicy size) { QWidget w; setSize(&w, size); @@ -335,7 +334,7 @@ int tst_QMacStyle::hspacing(ControlType control1, ControlType control2, Size siz return spacing(control1, control2, Qt::Horizontal, &opt); } -int tst_QMacStyle::vspacing(ControlType control1, ControlType control2, Size size) +int tst_QMacStyle::vspacing(ControlType control1, ControlType control2, QStyleHelper::WidgetSizePolicy size) { QWidget w; setSize(&w, size); diff --git a/tests/auto/widgets/styles/qstyle/tst_qstyle.cpp b/tests/auto/widgets/styles/qstyle/tst_qstyle.cpp index 5369101dae..cd8ba95b06 100644 --- a/tests/auto/widgets/styles/qstyle/tst_qstyle.cpp +++ b/tests/auto/widgets/styles/qstyle/tst_qstyle.cpp @@ -82,9 +82,6 @@ private slots: void testFusionStyle(); #endif void testWindowsStyle(); -#if defined(Q_OS_WIN) && !defined(QT_NO_STYLE_WINDOWSXP) - void testWindowsXPStyle(); -#endif #if defined(Q_OS_WIN) && !defined(QT_NO_STYLE_WINDOWSVISTA) void testWindowsVistaStyle(); #endif @@ -142,14 +139,6 @@ void tst_QStyle::testStyleFactory() #ifndef QT_NO_STYLE_WINDOWS QVERIFY(keys.contains("Windows")); #endif -#ifdef Q_OS_WIN - if (QSysInfo::WindowsVersion >= QSysInfo::WV_XP && - (QSysInfo::WindowsVersion & QSysInfo::WV_NT_based)) - QVERIFY(keys.contains("WindowsXP")); - if (QSysInfo::WindowsVersion >= QSysInfo::WV_VISTA && - (QSysInfo::WindowsVersion & QSysInfo::WV_NT_based)) - QVERIFY(keys.contains("WindowsVista")); -#endif foreach (QString styleName , keys) { QStyle *style = QStyleFactory::create(styleName); @@ -295,16 +284,22 @@ bool tst_QStyle::testAllFunctions(QStyle *style) bool tst_QStyle::testScrollBarSubControls() { + const auto *style = testWidget->style(); + const bool isMacStyle = style->objectName().toLower() == "macintosh"; QScrollBar scrollBar; setFrameless(&scrollBar); scrollBar.show(); const QStyleOptionSlider opt = qt_qscrollbarStyleOption(&scrollBar); - foreach (int subControl, QList<int>() << 1 << 2 << 4 << 8) { - QRect sr = testWidget->style()->subControlRect(QStyle::CC_ScrollBar, &opt, - QStyle::SubControl(subControl), &scrollBar); + foreach (int sc, QList<int>() << 1 << 2 << 4 << 8) { + const auto subControl = static_cast<QStyle::SubControl>(sc); + const QRect sr = style->subControlRect(QStyle::CC_ScrollBar, &opt, subControl, &scrollBar); if (sr.isNull()) { - qWarning("Null rect for subcontrol %d", subControl); - return false; + // macOS scrollbars no longer have these, so there's no reason to fail + if (!(isMacStyle && (subControl == QStyle::SC_ScrollBarAddLine || + subControl == QStyle::SC_ScrollBarSubLine))) { + qWarning() << "Unexpected null rect for subcontrol" << subControl; + return false; + } } } return true; @@ -335,17 +330,6 @@ void tst_QStyle::testWindowsStyle() delete wstyle; } -#if defined(Q_OS_WIN) && !defined(QT_NO_STYLE_WINDOWSXP) -// WindowsXP style -void tst_QStyle::testWindowsXPStyle() -{ - QStyle *xpstyle = QStyleFactory::create("WindowsXP"); - QVERIFY(testAllFunctions(xpstyle)); - lineUpLayoutTest(xpstyle); - delete xpstyle; -} -#endif - void writeImage(const QString &fileName, QImage image) { QImageWriter imageWriter(fileName); @@ -368,8 +352,6 @@ void tst_QStyle::testWindowsVistaStyle() if (QSysInfo::WindowsVersion == QSysInfo::WV_VISTA) testPainting(vistastyle, "vista"); - else if (QSysInfo::WindowsVersion == QSysInfo::WV_XP) - testPainting(vistastyle, "xp"); delete vistastyle; } #endif diff --git a/tests/auto/widgets/widgets.pro b/tests/auto/widgets/widgets.pro index efcc47171d..8b6c4722be 100644 --- a/tests/auto/widgets/widgets.pro +++ b/tests/auto/widgets/widgets.pro @@ -8,4 +8,3 @@ SUBDIRS=\ styles \ util \ widgets \ - gestures \ diff --git a/tests/auto/widgets/widgets/qcombobox/BLACKLIST b/tests/auto/widgets/widgets/qcombobox/BLACKLIST index 4a270c085b..c04351e5ca 100644 --- a/tests/auto/widgets/widgets/qcombobox/BLACKLIST +++ b/tests/auto/widgets/widgets/qcombobox/BLACKLIST @@ -1,3 +1,7 @@ QTBUG-45531 [task260974_menuItemRectangleForComboBoxPopup] osx-10.10 + +[task_QTBUG_56693_itemFontFromModel] +# Counts draw calls, but we could have multiple expose events QTBUG-62080 +osx diff --git a/tests/auto/widgets/widgets/qcombobox/tst_qcombobox.cpp b/tests/auto/widgets/widgets/qcombobox/tst_qcombobox.cpp index 2195f43ef1..b6007482ae 100644 --- a/tests/auto/widgets/widgets/qcombobox/tst_qcombobox.cpp +++ b/tests/auto/widgets/widgets/qcombobox/tst_qcombobox.cpp @@ -164,6 +164,7 @@ private slots: void task_QTBUG_49831_scrollerNotActivated(); void task_QTBUG_56693_itemFontFromModel(); void inputMethodUpdate(); + void task_QTBUG_52027_mapCompleterIndex(); private: PlatformInputContext m_platformInputContext; @@ -2256,7 +2257,7 @@ void tst_QComboBox::task190351_layout() listCombo.setCurrentIndex(70); listCombo.showPopup(); QTRY_VERIFY(listCombo.view()); - QTest::qWaitForWindowExposed(listCombo.view()); + QVERIFY(QTest::qWaitForWindowExposed(listCombo.view())); QTRY_VERIFY(listCombo.view()->isVisible()); QApplication::processEvents(); @@ -2403,7 +2404,7 @@ void tst_QComboBox::task248169_popupWithMinimalSize() QTRY_VERIFY(comboBox.isVisible()); comboBox.showPopup(); QTRY_VERIFY(comboBox.view()); - QTest::qWaitForWindowExposed(comboBox.view()); + QVERIFY(QTest::qWaitForWindowExposed(comboBox.view())); QTRY_VERIFY(comboBox.view()->isVisible()); #if defined QT_BUILD_INTERNAL @@ -3249,12 +3250,12 @@ void tst_QComboBox::task_QTBUG_49831_scrollerNotActivated() box.setModel(&model); box.setCurrentIndex(500); box.show(); - QTest::qWaitForWindowExposed(&box); + QVERIFY(QTest::qWaitForWindowExposed(&box)); QTest::mouseMove(&box, QPoint(5, 5), 100); box.showPopup(); QFrame *container = box.findChild<QComboBoxPrivateContainer *>(); QVERIFY(container); - QTest::qWaitForWindowExposed(container); + QVERIFY(QTest::qWaitForWindowExposed(container)); QList<QComboBoxPrivateScroller *> scrollers = container->findChildren<QComboBoxPrivateScroller *>(); // Not all styles support scrollers. We rely only on those platforms that do to catch any regression. @@ -3330,11 +3331,11 @@ void tst_QComboBox::task_QTBUG_56693_itemFontFromModel() box.addItem(QLatin1String("Item ") + QString::number(i)); box.show(); - QTest::qWaitForWindowExposed(&box); + QVERIFY(QTest::qWaitForWindowExposed(&box)); box.showPopup(); QFrame *container = box.findChild<QComboBoxPrivateContainer *>(); QVERIFY(container); - QTest::qWaitForWindowExposed(container); + QVERIFY(QTest::qWaitForWindowExposed(container)); QCOMPARE(proxyStyle->italicItemsNo, 5); @@ -3395,5 +3396,62 @@ void tst_QComboBox::inputMethodUpdate() QVERIFY(m_platformInputContext.m_updateCallCount >= 1); } +void tst_QComboBox::task_QTBUG_52027_mapCompleterIndex() +{ + QStringList words; + words << "" << "foobar1" << "foobar2"; + + QStringList altWords; + altWords << "foobar2" << "hello" << "," << "world" << "" << "foobar0" << "foobar1"; + + QComboBox cbox; + setFrameless(&cbox); + cbox.setEditable(true); + cbox.setInsertPolicy(QComboBox::NoInsert); + cbox.addItems(words); + + QCompleter *completer = new QCompleter(altWords); + completer->setCaseSensitivity(Qt::CaseInsensitive); + cbox.setCompleter(completer); + + QSignalSpy spy(&cbox, SIGNAL(activated(int))); + QCOMPARE(spy.count(), 0); + cbox.move(200, 200); + cbox.show(); + QApplication::setActiveWindow(&cbox); + QVERIFY(QTest::qWaitForWindowActive(&cbox)); + + QTest::keyClicks(&cbox, "foobar2"); + QApplication::processEvents(); + QTRY_VERIFY(completer->popup()); + QTest::keyClick(completer->popup(), Qt::Key_Down); + QApplication::processEvents(); + QTest::keyClick(completer->popup(), Qt::Key_Return); + QApplication::processEvents(); + QList<QVariant> arguments = spy.takeLast(); + QCOMPARE(arguments.at(0).toInt(), 2); + + cbox.lineEdit()->selectAll(); + cbox.lineEdit()->del(); + + QSortFilterProxyModel* model = new QSortFilterProxyModel(); + model->setSourceModel(cbox.model()); + model->setFilterFixedString("foobar1"); + completer->setModel(model); + + QApplication::setActiveWindow(&cbox); + QVERIFY(QTest::qWaitForWindowActive(&cbox)); + + QTest::keyClicks(&cbox, "foobar1"); + QApplication::processEvents(); + QTRY_VERIFY(completer->popup()); + QTest::keyClick(completer->popup(), Qt::Key_Down); + QApplication::processEvents(); + QTest::keyClick(completer->popup(), Qt::Key_Return); + QApplication::processEvents(); + arguments = spy.takeLast(); + QCOMPARE(arguments.at(0).toInt(), 1); +} + QTEST_MAIN(tst_QComboBox) #include "tst_qcombobox.moc" diff --git a/tests/auto/widgets/widgets/qdatetimeedit/tst_qdatetimeedit.cpp b/tests/auto/widgets/widgets/qdatetimeedit/tst_qdatetimeedit.cpp index 94e4fc005c..a3571cd9c5 100644 --- a/tests/auto/widgets/widgets/qdatetimeedit/tst_qdatetimeedit.cpp +++ b/tests/auto/widgets/widgets/qdatetimeedit/tst_qdatetimeedit.cpp @@ -239,6 +239,8 @@ private slots: void deleteCalendarWidget(); + void setLocaleOnCalendarWidget(); + #ifdef QT_BUILD_INTERNAL void dateEditCorrectSectionSize_data(); void dateEditCorrectSectionSize(); @@ -3409,6 +3411,25 @@ void tst_QDateTimeEdit::deleteCalendarWidget() } } +void tst_QDateTimeEdit::setLocaleOnCalendarWidget() +{ + QDateEdit dateEdit; + QList<QLocale> allLocales = QLocale::matchingLocales( + QLocale::AnyLanguage, + QLocale::AnyScript, + QLocale::AnyCountry); + QLocale c = QLocale::c(); + dateEdit.setCalendarPopup(true); + dateEdit.setLocale(c); + for (const QLocale& l : allLocales) { + dateEdit.setLocale(l); + const QLocale locCal = dateEdit.calendarWidget()->locale(); + const QLocale locEdit = dateEdit.locale(); + QCOMPARE(locCal.name(), locEdit.name()); + QVERIFY(locCal == locEdit); + } +} + #ifdef QT_BUILD_INTERNAL typedef QPair<Qt::Key, Qt::KeyboardModifier> KeyPair; diff --git a/tests/auto/widgets/widgets/qframe/images/box_noshadow_0_0.png b/tests/auto/widgets/widgets/qframe/images/box_noshadow_0_0.png Binary files differindex f1d6392779..2647ac98b2 100644 --- a/tests/auto/widgets/widgets/qframe/images/box_noshadow_0_0.png +++ b/tests/auto/widgets/widgets/qframe/images/box_noshadow_0_0.png diff --git a/tests/auto/widgets/widgets/qframe/images/box_noshadow_0_1.png b/tests/auto/widgets/widgets/qframe/images/box_noshadow_0_1.png Binary files differindex f1d6392779..2647ac98b2 100644 --- a/tests/auto/widgets/widgets/qframe/images/box_noshadow_0_1.png +++ b/tests/auto/widgets/widgets/qframe/images/box_noshadow_0_1.png diff --git a/tests/auto/widgets/widgets/qframe/images/box_noshadow_0_2.png b/tests/auto/widgets/widgets/qframe/images/box_noshadow_0_2.png Binary files differindex f1d6392779..2647ac98b2 100644 --- a/tests/auto/widgets/widgets/qframe/images/box_noshadow_0_2.png +++ b/tests/auto/widgets/widgets/qframe/images/box_noshadow_0_2.png diff --git a/tests/auto/widgets/widgets/qframe/images/box_noshadow_1_0.png b/tests/auto/widgets/widgets/qframe/images/box_noshadow_1_0.png Binary files differindex 0cc9090e3b..84be445138 100644 --- a/tests/auto/widgets/widgets/qframe/images/box_noshadow_1_0.png +++ b/tests/auto/widgets/widgets/qframe/images/box_noshadow_1_0.png diff --git a/tests/auto/widgets/widgets/qframe/images/box_noshadow_1_1.png b/tests/auto/widgets/widgets/qframe/images/box_noshadow_1_1.png Binary files differindex 0cc9090e3b..84be445138 100644 --- a/tests/auto/widgets/widgets/qframe/images/box_noshadow_1_1.png +++ b/tests/auto/widgets/widgets/qframe/images/box_noshadow_1_1.png diff --git a/tests/auto/widgets/widgets/qframe/images/box_noshadow_1_2.png b/tests/auto/widgets/widgets/qframe/images/box_noshadow_1_2.png Binary files differindex 0cc9090e3b..84be445138 100644 --- a/tests/auto/widgets/widgets/qframe/images/box_noshadow_1_2.png +++ b/tests/auto/widgets/widgets/qframe/images/box_noshadow_1_2.png diff --git a/tests/auto/widgets/widgets/qframe/images/box_noshadow_2_0.png b/tests/auto/widgets/widgets/qframe/images/box_noshadow_2_0.png Binary files differindex 61f683df52..8c29cd9965 100644 --- a/tests/auto/widgets/widgets/qframe/images/box_noshadow_2_0.png +++ b/tests/auto/widgets/widgets/qframe/images/box_noshadow_2_0.png diff --git a/tests/auto/widgets/widgets/qframe/images/box_noshadow_2_1.png b/tests/auto/widgets/widgets/qframe/images/box_noshadow_2_1.png Binary files differindex 61f683df52..8c29cd9965 100644 --- a/tests/auto/widgets/widgets/qframe/images/box_noshadow_2_1.png +++ b/tests/auto/widgets/widgets/qframe/images/box_noshadow_2_1.png diff --git a/tests/auto/widgets/widgets/qframe/images/box_noshadow_2_2.png b/tests/auto/widgets/widgets/qframe/images/box_noshadow_2_2.png Binary files differindex 61f683df52..8c29cd9965 100644 --- a/tests/auto/widgets/widgets/qframe/images/box_noshadow_2_2.png +++ b/tests/auto/widgets/widgets/qframe/images/box_noshadow_2_2.png diff --git a/tests/auto/widgets/widgets/qframe/images/box_plain_0_0.png b/tests/auto/widgets/widgets/qframe/images/box_plain_0_0.png Binary files differindex f1d6392779..2647ac98b2 100644 --- a/tests/auto/widgets/widgets/qframe/images/box_plain_0_0.png +++ b/tests/auto/widgets/widgets/qframe/images/box_plain_0_0.png diff --git a/tests/auto/widgets/widgets/qframe/images/box_plain_0_1.png b/tests/auto/widgets/widgets/qframe/images/box_plain_0_1.png Binary files differindex f1d6392779..2647ac98b2 100644 --- a/tests/auto/widgets/widgets/qframe/images/box_plain_0_1.png +++ b/tests/auto/widgets/widgets/qframe/images/box_plain_0_1.png diff --git a/tests/auto/widgets/widgets/qframe/images/box_plain_0_2.png b/tests/auto/widgets/widgets/qframe/images/box_plain_0_2.png Binary files differindex f1d6392779..2647ac98b2 100644 --- a/tests/auto/widgets/widgets/qframe/images/box_plain_0_2.png +++ b/tests/auto/widgets/widgets/qframe/images/box_plain_0_2.png diff --git a/tests/auto/widgets/widgets/qframe/images/box_plain_1_0.png b/tests/auto/widgets/widgets/qframe/images/box_plain_1_0.png Binary files differindex 0cc9090e3b..84be445138 100644 --- a/tests/auto/widgets/widgets/qframe/images/box_plain_1_0.png +++ b/tests/auto/widgets/widgets/qframe/images/box_plain_1_0.png diff --git a/tests/auto/widgets/widgets/qframe/images/box_plain_1_1.png b/tests/auto/widgets/widgets/qframe/images/box_plain_1_1.png Binary files differindex 0cc9090e3b..84be445138 100644 --- a/tests/auto/widgets/widgets/qframe/images/box_plain_1_1.png +++ b/tests/auto/widgets/widgets/qframe/images/box_plain_1_1.png diff --git a/tests/auto/widgets/widgets/qframe/images/box_plain_1_2.png b/tests/auto/widgets/widgets/qframe/images/box_plain_1_2.png Binary files differindex 0cc9090e3b..84be445138 100644 --- a/tests/auto/widgets/widgets/qframe/images/box_plain_1_2.png +++ b/tests/auto/widgets/widgets/qframe/images/box_plain_1_2.png diff --git a/tests/auto/widgets/widgets/qframe/images/box_plain_2_0.png b/tests/auto/widgets/widgets/qframe/images/box_plain_2_0.png Binary files differindex 61f683df52..8c29cd9965 100644 --- a/tests/auto/widgets/widgets/qframe/images/box_plain_2_0.png +++ b/tests/auto/widgets/widgets/qframe/images/box_plain_2_0.png diff --git a/tests/auto/widgets/widgets/qframe/images/box_plain_2_1.png b/tests/auto/widgets/widgets/qframe/images/box_plain_2_1.png Binary files differindex 61f683df52..8c29cd9965 100644 --- a/tests/auto/widgets/widgets/qframe/images/box_plain_2_1.png +++ b/tests/auto/widgets/widgets/qframe/images/box_plain_2_1.png diff --git a/tests/auto/widgets/widgets/qframe/images/box_plain_2_2.png b/tests/auto/widgets/widgets/qframe/images/box_plain_2_2.png Binary files differindex 61f683df52..8c29cd9965 100644 --- a/tests/auto/widgets/widgets/qframe/images/box_plain_2_2.png +++ b/tests/auto/widgets/widgets/qframe/images/box_plain_2_2.png diff --git a/tests/auto/widgets/widgets/qframe/images/box_raised_0_0.png b/tests/auto/widgets/widgets/qframe/images/box_raised_0_0.png Binary files differindex f1d6392779..2647ac98b2 100644 --- a/tests/auto/widgets/widgets/qframe/images/box_raised_0_0.png +++ b/tests/auto/widgets/widgets/qframe/images/box_raised_0_0.png diff --git a/tests/auto/widgets/widgets/qframe/images/box_raised_0_1.png b/tests/auto/widgets/widgets/qframe/images/box_raised_0_1.png Binary files differindex b2ab941d30..e35498674c 100644 --- a/tests/auto/widgets/widgets/qframe/images/box_raised_0_1.png +++ b/tests/auto/widgets/widgets/qframe/images/box_raised_0_1.png diff --git a/tests/auto/widgets/widgets/qframe/images/box_raised_0_2.png b/tests/auto/widgets/widgets/qframe/images/box_raised_0_2.png Binary files differindex 21ebe53eff..b958b62259 100644 --- a/tests/auto/widgets/widgets/qframe/images/box_raised_0_2.png +++ b/tests/auto/widgets/widgets/qframe/images/box_raised_0_2.png diff --git a/tests/auto/widgets/widgets/qframe/images/box_raised_1_0.png b/tests/auto/widgets/widgets/qframe/images/box_raised_1_0.png Binary files differindex 4f097cee48..879f6ddc31 100644 --- a/tests/auto/widgets/widgets/qframe/images/box_raised_1_0.png +++ b/tests/auto/widgets/widgets/qframe/images/box_raised_1_0.png diff --git a/tests/auto/widgets/widgets/qframe/images/box_raised_1_1.png b/tests/auto/widgets/widgets/qframe/images/box_raised_1_1.png Binary files differindex 86f9ed6186..343caa06e4 100644 --- a/tests/auto/widgets/widgets/qframe/images/box_raised_1_1.png +++ b/tests/auto/widgets/widgets/qframe/images/box_raised_1_1.png diff --git a/tests/auto/widgets/widgets/qframe/images/box_raised_1_2.png b/tests/auto/widgets/widgets/qframe/images/box_raised_1_2.png Binary files differindex 51a7899d05..377e1377f2 100644 --- a/tests/auto/widgets/widgets/qframe/images/box_raised_1_2.png +++ b/tests/auto/widgets/widgets/qframe/images/box_raised_1_2.png diff --git a/tests/auto/widgets/widgets/qframe/images/box_raised_2_0.png b/tests/auto/widgets/widgets/qframe/images/box_raised_2_0.png Binary files differindex 8c3769c32d..d59309bb3e 100644 --- a/tests/auto/widgets/widgets/qframe/images/box_raised_2_0.png +++ b/tests/auto/widgets/widgets/qframe/images/box_raised_2_0.png diff --git a/tests/auto/widgets/widgets/qframe/images/box_raised_2_1.png b/tests/auto/widgets/widgets/qframe/images/box_raised_2_1.png Binary files differindex 81e0c2a152..36f6c0a9f3 100644 --- a/tests/auto/widgets/widgets/qframe/images/box_raised_2_1.png +++ b/tests/auto/widgets/widgets/qframe/images/box_raised_2_1.png diff --git a/tests/auto/widgets/widgets/qframe/images/box_raised_2_2.png b/tests/auto/widgets/widgets/qframe/images/box_raised_2_2.png Binary files differindex 107272d0b9..c6bdab7eb4 100644 --- a/tests/auto/widgets/widgets/qframe/images/box_raised_2_2.png +++ b/tests/auto/widgets/widgets/qframe/images/box_raised_2_2.png diff --git a/tests/auto/widgets/widgets/qframe/images/box_sunken_0_0.png b/tests/auto/widgets/widgets/qframe/images/box_sunken_0_0.png Binary files differindex f1d6392779..2647ac98b2 100644 --- a/tests/auto/widgets/widgets/qframe/images/box_sunken_0_0.png +++ b/tests/auto/widgets/widgets/qframe/images/box_sunken_0_0.png diff --git a/tests/auto/widgets/widgets/qframe/images/box_sunken_0_1.png b/tests/auto/widgets/widgets/qframe/images/box_sunken_0_1.png Binary files differindex b2ab941d30..e35498674c 100644 --- a/tests/auto/widgets/widgets/qframe/images/box_sunken_0_1.png +++ b/tests/auto/widgets/widgets/qframe/images/box_sunken_0_1.png diff --git a/tests/auto/widgets/widgets/qframe/images/box_sunken_0_2.png b/tests/auto/widgets/widgets/qframe/images/box_sunken_0_2.png Binary files differindex 21ebe53eff..b958b62259 100644 --- a/tests/auto/widgets/widgets/qframe/images/box_sunken_0_2.png +++ b/tests/auto/widgets/widgets/qframe/images/box_sunken_0_2.png diff --git a/tests/auto/widgets/widgets/qframe/images/box_sunken_1_0.png b/tests/auto/widgets/widgets/qframe/images/box_sunken_1_0.png Binary files differindex 6905baa1fd..7e57872d19 100644 --- a/tests/auto/widgets/widgets/qframe/images/box_sunken_1_0.png +++ b/tests/auto/widgets/widgets/qframe/images/box_sunken_1_0.png diff --git a/tests/auto/widgets/widgets/qframe/images/box_sunken_1_1.png b/tests/auto/widgets/widgets/qframe/images/box_sunken_1_1.png Binary files differindex 9d5440b3aa..8bf9170f89 100644 --- a/tests/auto/widgets/widgets/qframe/images/box_sunken_1_1.png +++ b/tests/auto/widgets/widgets/qframe/images/box_sunken_1_1.png diff --git a/tests/auto/widgets/widgets/qframe/images/box_sunken_1_2.png b/tests/auto/widgets/widgets/qframe/images/box_sunken_1_2.png Binary files differindex 17eb7f59c0..bb34a4db29 100644 --- a/tests/auto/widgets/widgets/qframe/images/box_sunken_1_2.png +++ b/tests/auto/widgets/widgets/qframe/images/box_sunken_1_2.png diff --git a/tests/auto/widgets/widgets/qframe/images/box_sunken_2_0.png b/tests/auto/widgets/widgets/qframe/images/box_sunken_2_0.png Binary files differindex a6ccd54a39..4aa344ad54 100644 --- a/tests/auto/widgets/widgets/qframe/images/box_sunken_2_0.png +++ b/tests/auto/widgets/widgets/qframe/images/box_sunken_2_0.png diff --git a/tests/auto/widgets/widgets/qframe/images/box_sunken_2_1.png b/tests/auto/widgets/widgets/qframe/images/box_sunken_2_1.png Binary files differindex 3736bf6c99..da5f2ba6b9 100644 --- a/tests/auto/widgets/widgets/qframe/images/box_sunken_2_1.png +++ b/tests/auto/widgets/widgets/qframe/images/box_sunken_2_1.png diff --git a/tests/auto/widgets/widgets/qframe/images/box_sunken_2_2.png b/tests/auto/widgets/widgets/qframe/images/box_sunken_2_2.png Binary files differindex 5750751c58..80ce6d846e 100644 --- a/tests/auto/widgets/widgets/qframe/images/box_sunken_2_2.png +++ b/tests/auto/widgets/widgets/qframe/images/box_sunken_2_2.png diff --git a/tests/auto/widgets/widgets/qframe/images/winpanel_noshadow_0_0.png b/tests/auto/widgets/widgets/qframe/images/winpanel_noshadow_0_0.png Binary files differindex 61f683df52..8c29cd9965 100644 --- a/tests/auto/widgets/widgets/qframe/images/winpanel_noshadow_0_0.png +++ b/tests/auto/widgets/widgets/qframe/images/winpanel_noshadow_0_0.png diff --git a/tests/auto/widgets/widgets/qframe/images/winpanel_noshadow_0_1.png b/tests/auto/widgets/widgets/qframe/images/winpanel_noshadow_0_1.png Binary files differindex 61f683df52..8c29cd9965 100644 --- a/tests/auto/widgets/widgets/qframe/images/winpanel_noshadow_0_1.png +++ b/tests/auto/widgets/widgets/qframe/images/winpanel_noshadow_0_1.png diff --git a/tests/auto/widgets/widgets/qframe/images/winpanel_noshadow_0_2.png b/tests/auto/widgets/widgets/qframe/images/winpanel_noshadow_0_2.png Binary files differindex 61f683df52..8c29cd9965 100644 --- a/tests/auto/widgets/widgets/qframe/images/winpanel_noshadow_0_2.png +++ b/tests/auto/widgets/widgets/qframe/images/winpanel_noshadow_0_2.png diff --git a/tests/auto/widgets/widgets/qframe/images/winpanel_noshadow_1_0.png b/tests/auto/widgets/widgets/qframe/images/winpanel_noshadow_1_0.png Binary files differindex 61f683df52..8c29cd9965 100644 --- a/tests/auto/widgets/widgets/qframe/images/winpanel_noshadow_1_0.png +++ b/tests/auto/widgets/widgets/qframe/images/winpanel_noshadow_1_0.png diff --git a/tests/auto/widgets/widgets/qframe/images/winpanel_noshadow_1_1.png b/tests/auto/widgets/widgets/qframe/images/winpanel_noshadow_1_1.png Binary files differindex 61f683df52..8c29cd9965 100644 --- a/tests/auto/widgets/widgets/qframe/images/winpanel_noshadow_1_1.png +++ b/tests/auto/widgets/widgets/qframe/images/winpanel_noshadow_1_1.png diff --git a/tests/auto/widgets/widgets/qframe/images/winpanel_noshadow_1_2.png b/tests/auto/widgets/widgets/qframe/images/winpanel_noshadow_1_2.png Binary files differindex 61f683df52..8c29cd9965 100644 --- a/tests/auto/widgets/widgets/qframe/images/winpanel_noshadow_1_2.png +++ b/tests/auto/widgets/widgets/qframe/images/winpanel_noshadow_1_2.png diff --git a/tests/auto/widgets/widgets/qframe/images/winpanel_noshadow_2_0.png b/tests/auto/widgets/widgets/qframe/images/winpanel_noshadow_2_0.png Binary files differindex 61f683df52..8c29cd9965 100644 --- a/tests/auto/widgets/widgets/qframe/images/winpanel_noshadow_2_0.png +++ b/tests/auto/widgets/widgets/qframe/images/winpanel_noshadow_2_0.png diff --git a/tests/auto/widgets/widgets/qframe/images/winpanel_noshadow_2_1.png b/tests/auto/widgets/widgets/qframe/images/winpanel_noshadow_2_1.png Binary files differindex 61f683df52..8c29cd9965 100644 --- a/tests/auto/widgets/widgets/qframe/images/winpanel_noshadow_2_1.png +++ b/tests/auto/widgets/widgets/qframe/images/winpanel_noshadow_2_1.png diff --git a/tests/auto/widgets/widgets/qframe/images/winpanel_noshadow_2_2.png b/tests/auto/widgets/widgets/qframe/images/winpanel_noshadow_2_2.png Binary files differindex 61f683df52..8c29cd9965 100644 --- a/tests/auto/widgets/widgets/qframe/images/winpanel_noshadow_2_2.png +++ b/tests/auto/widgets/widgets/qframe/images/winpanel_noshadow_2_2.png diff --git a/tests/auto/widgets/widgets/qframe/images/winpanel_plain_0_0.png b/tests/auto/widgets/widgets/qframe/images/winpanel_plain_0_0.png Binary files differindex 61f683df52..8c29cd9965 100644 --- a/tests/auto/widgets/widgets/qframe/images/winpanel_plain_0_0.png +++ b/tests/auto/widgets/widgets/qframe/images/winpanel_plain_0_0.png diff --git a/tests/auto/widgets/widgets/qframe/images/winpanel_plain_0_1.png b/tests/auto/widgets/widgets/qframe/images/winpanel_plain_0_1.png Binary files differindex 61f683df52..8c29cd9965 100644 --- a/tests/auto/widgets/widgets/qframe/images/winpanel_plain_0_1.png +++ b/tests/auto/widgets/widgets/qframe/images/winpanel_plain_0_1.png diff --git a/tests/auto/widgets/widgets/qframe/images/winpanel_plain_0_2.png b/tests/auto/widgets/widgets/qframe/images/winpanel_plain_0_2.png Binary files differindex 61f683df52..8c29cd9965 100644 --- a/tests/auto/widgets/widgets/qframe/images/winpanel_plain_0_2.png +++ b/tests/auto/widgets/widgets/qframe/images/winpanel_plain_0_2.png diff --git a/tests/auto/widgets/widgets/qframe/images/winpanel_plain_1_0.png b/tests/auto/widgets/widgets/qframe/images/winpanel_plain_1_0.png Binary files differindex 61f683df52..8c29cd9965 100644 --- a/tests/auto/widgets/widgets/qframe/images/winpanel_plain_1_0.png +++ b/tests/auto/widgets/widgets/qframe/images/winpanel_plain_1_0.png diff --git a/tests/auto/widgets/widgets/qframe/images/winpanel_plain_1_1.png b/tests/auto/widgets/widgets/qframe/images/winpanel_plain_1_1.png Binary files differindex 61f683df52..8c29cd9965 100644 --- a/tests/auto/widgets/widgets/qframe/images/winpanel_plain_1_1.png +++ b/tests/auto/widgets/widgets/qframe/images/winpanel_plain_1_1.png diff --git a/tests/auto/widgets/widgets/qframe/images/winpanel_plain_1_2.png b/tests/auto/widgets/widgets/qframe/images/winpanel_plain_1_2.png Binary files differindex 61f683df52..8c29cd9965 100644 --- a/tests/auto/widgets/widgets/qframe/images/winpanel_plain_1_2.png +++ b/tests/auto/widgets/widgets/qframe/images/winpanel_plain_1_2.png diff --git a/tests/auto/widgets/widgets/qframe/images/winpanel_plain_2_0.png b/tests/auto/widgets/widgets/qframe/images/winpanel_plain_2_0.png Binary files differindex 61f683df52..8c29cd9965 100644 --- a/tests/auto/widgets/widgets/qframe/images/winpanel_plain_2_0.png +++ b/tests/auto/widgets/widgets/qframe/images/winpanel_plain_2_0.png diff --git a/tests/auto/widgets/widgets/qframe/images/winpanel_plain_2_1.png b/tests/auto/widgets/widgets/qframe/images/winpanel_plain_2_1.png Binary files differindex 61f683df52..8c29cd9965 100644 --- a/tests/auto/widgets/widgets/qframe/images/winpanel_plain_2_1.png +++ b/tests/auto/widgets/widgets/qframe/images/winpanel_plain_2_1.png diff --git a/tests/auto/widgets/widgets/qframe/images/winpanel_plain_2_2.png b/tests/auto/widgets/widgets/qframe/images/winpanel_plain_2_2.png Binary files differindex 61f683df52..8c29cd9965 100644 --- a/tests/auto/widgets/widgets/qframe/images/winpanel_plain_2_2.png +++ b/tests/auto/widgets/widgets/qframe/images/winpanel_plain_2_2.png diff --git a/tests/auto/widgets/widgets/qframe/images/winpanel_raised_0_0.png b/tests/auto/widgets/widgets/qframe/images/winpanel_raised_0_0.png Binary files differindex 00447760ec..a28358ec55 100644 --- a/tests/auto/widgets/widgets/qframe/images/winpanel_raised_0_0.png +++ b/tests/auto/widgets/widgets/qframe/images/winpanel_raised_0_0.png diff --git a/tests/auto/widgets/widgets/qframe/images/winpanel_raised_0_1.png b/tests/auto/widgets/widgets/qframe/images/winpanel_raised_0_1.png Binary files differindex 00447760ec..a28358ec55 100644 --- a/tests/auto/widgets/widgets/qframe/images/winpanel_raised_0_1.png +++ b/tests/auto/widgets/widgets/qframe/images/winpanel_raised_0_1.png diff --git a/tests/auto/widgets/widgets/qframe/images/winpanel_raised_0_2.png b/tests/auto/widgets/widgets/qframe/images/winpanel_raised_0_2.png Binary files differindex 00447760ec..a28358ec55 100644 --- a/tests/auto/widgets/widgets/qframe/images/winpanel_raised_0_2.png +++ b/tests/auto/widgets/widgets/qframe/images/winpanel_raised_0_2.png diff --git a/tests/auto/widgets/widgets/qframe/images/winpanel_raised_1_0.png b/tests/auto/widgets/widgets/qframe/images/winpanel_raised_1_0.png Binary files differindex 00447760ec..a28358ec55 100644 --- a/tests/auto/widgets/widgets/qframe/images/winpanel_raised_1_0.png +++ b/tests/auto/widgets/widgets/qframe/images/winpanel_raised_1_0.png diff --git a/tests/auto/widgets/widgets/qframe/images/winpanel_raised_1_1.png b/tests/auto/widgets/widgets/qframe/images/winpanel_raised_1_1.png Binary files differindex 00447760ec..a28358ec55 100644 --- a/tests/auto/widgets/widgets/qframe/images/winpanel_raised_1_1.png +++ b/tests/auto/widgets/widgets/qframe/images/winpanel_raised_1_1.png diff --git a/tests/auto/widgets/widgets/qframe/images/winpanel_raised_1_2.png b/tests/auto/widgets/widgets/qframe/images/winpanel_raised_1_2.png Binary files differindex 00447760ec..a28358ec55 100644 --- a/tests/auto/widgets/widgets/qframe/images/winpanel_raised_1_2.png +++ b/tests/auto/widgets/widgets/qframe/images/winpanel_raised_1_2.png diff --git a/tests/auto/widgets/widgets/qframe/images/winpanel_raised_2_0.png b/tests/auto/widgets/widgets/qframe/images/winpanel_raised_2_0.png Binary files differindex 00447760ec..a28358ec55 100644 --- a/tests/auto/widgets/widgets/qframe/images/winpanel_raised_2_0.png +++ b/tests/auto/widgets/widgets/qframe/images/winpanel_raised_2_0.png diff --git a/tests/auto/widgets/widgets/qframe/images/winpanel_raised_2_1.png b/tests/auto/widgets/widgets/qframe/images/winpanel_raised_2_1.png Binary files differindex 00447760ec..a28358ec55 100644 --- a/tests/auto/widgets/widgets/qframe/images/winpanel_raised_2_1.png +++ b/tests/auto/widgets/widgets/qframe/images/winpanel_raised_2_1.png diff --git a/tests/auto/widgets/widgets/qframe/images/winpanel_raised_2_2.png b/tests/auto/widgets/widgets/qframe/images/winpanel_raised_2_2.png Binary files differindex 00447760ec..a28358ec55 100644 --- a/tests/auto/widgets/widgets/qframe/images/winpanel_raised_2_2.png +++ b/tests/auto/widgets/widgets/qframe/images/winpanel_raised_2_2.png diff --git a/tests/auto/widgets/widgets/qframe/images/winpanel_sunken_0_0.png b/tests/auto/widgets/widgets/qframe/images/winpanel_sunken_0_0.png Binary files differindex 4c809a2c80..b5ea56f422 100644 --- a/tests/auto/widgets/widgets/qframe/images/winpanel_sunken_0_0.png +++ b/tests/auto/widgets/widgets/qframe/images/winpanel_sunken_0_0.png diff --git a/tests/auto/widgets/widgets/qframe/images/winpanel_sunken_0_1.png b/tests/auto/widgets/widgets/qframe/images/winpanel_sunken_0_1.png Binary files differindex 4c809a2c80..b5ea56f422 100644 --- a/tests/auto/widgets/widgets/qframe/images/winpanel_sunken_0_1.png +++ b/tests/auto/widgets/widgets/qframe/images/winpanel_sunken_0_1.png diff --git a/tests/auto/widgets/widgets/qframe/images/winpanel_sunken_0_2.png b/tests/auto/widgets/widgets/qframe/images/winpanel_sunken_0_2.png Binary files differindex 4c809a2c80..b5ea56f422 100644 --- a/tests/auto/widgets/widgets/qframe/images/winpanel_sunken_0_2.png +++ b/tests/auto/widgets/widgets/qframe/images/winpanel_sunken_0_2.png diff --git a/tests/auto/widgets/widgets/qframe/images/winpanel_sunken_1_0.png b/tests/auto/widgets/widgets/qframe/images/winpanel_sunken_1_0.png Binary files differindex 4c809a2c80..b5ea56f422 100644 --- a/tests/auto/widgets/widgets/qframe/images/winpanel_sunken_1_0.png +++ b/tests/auto/widgets/widgets/qframe/images/winpanel_sunken_1_0.png diff --git a/tests/auto/widgets/widgets/qframe/images/winpanel_sunken_1_1.png b/tests/auto/widgets/widgets/qframe/images/winpanel_sunken_1_1.png Binary files differindex 4c809a2c80..b5ea56f422 100644 --- a/tests/auto/widgets/widgets/qframe/images/winpanel_sunken_1_1.png +++ b/tests/auto/widgets/widgets/qframe/images/winpanel_sunken_1_1.png diff --git a/tests/auto/widgets/widgets/qframe/images/winpanel_sunken_1_2.png b/tests/auto/widgets/widgets/qframe/images/winpanel_sunken_1_2.png Binary files differindex 4c809a2c80..b5ea56f422 100644 --- a/tests/auto/widgets/widgets/qframe/images/winpanel_sunken_1_2.png +++ b/tests/auto/widgets/widgets/qframe/images/winpanel_sunken_1_2.png diff --git a/tests/auto/widgets/widgets/qframe/images/winpanel_sunken_2_0.png b/tests/auto/widgets/widgets/qframe/images/winpanel_sunken_2_0.png Binary files differindex 4c809a2c80..b5ea56f422 100644 --- a/tests/auto/widgets/widgets/qframe/images/winpanel_sunken_2_0.png +++ b/tests/auto/widgets/widgets/qframe/images/winpanel_sunken_2_0.png diff --git a/tests/auto/widgets/widgets/qframe/images/winpanel_sunken_2_1.png b/tests/auto/widgets/widgets/qframe/images/winpanel_sunken_2_1.png Binary files differindex 4c809a2c80..b5ea56f422 100644 --- a/tests/auto/widgets/widgets/qframe/images/winpanel_sunken_2_1.png +++ b/tests/auto/widgets/widgets/qframe/images/winpanel_sunken_2_1.png diff --git a/tests/auto/widgets/widgets/qframe/images/winpanel_sunken_2_2.png b/tests/auto/widgets/widgets/qframe/images/winpanel_sunken_2_2.png Binary files differindex 4c809a2c80..b5ea56f422 100644 --- a/tests/auto/widgets/widgets/qframe/images/winpanel_sunken_2_2.png +++ b/tests/auto/widgets/widgets/qframe/images/winpanel_sunken_2_2.png diff --git a/tests/auto/widgets/widgets/qgroupbox/tst_qgroupbox.cpp b/tests/auto/widgets/widgets/qgroupbox/tst_qgroupbox.cpp index 62224217d6..420ef56106 100644 --- a/tests/auto/widgets/widgets/qgroupbox/tst_qgroupbox.cpp +++ b/tests/auto/widgets/widgets/qgroupbox/tst_qgroupbox.cpp @@ -67,7 +67,7 @@ private slots: void toggledVsClicked(); void childrenAreDisabled(); void propagateFocus(); - void task_QTBUG_19170_ignoreMouseReleseEvent(); + void task_QTBUG_19170_ignoreMouseReleaseEvent(); void task_QTBUG_15519_propagateMouseEvents(); private: @@ -477,7 +477,7 @@ void tst_QGroupBox::propagateFocus() QTRY_COMPARE(qApp->focusWidget(), static_cast<QWidget*>(&lineEdit)); } -void tst_QGroupBox::task_QTBUG_19170_ignoreMouseReleseEvent() +void tst_QGroupBox::task_QTBUG_19170_ignoreMouseReleaseEvent() { QGroupBox box; box.setCheckable(true); diff --git a/tests/auto/widgets/widgets/qlineedit/tst_qlineedit.cpp b/tests/auto/widgets/widgets/qlineedit/tst_qlineedit.cpp index 2c6599631e..21669e42cd 100644 --- a/tests/auto/widgets/widgets/qlineedit/tst_qlineedit.cpp +++ b/tests/auto/widgets/widgets/qlineedit/tst_qlineedit.cpp @@ -44,10 +44,6 @@ #include <private/qapplication_p.h> #include "qclipboard.h" -#ifdef Q_OS_MAC -#include <cstdlib> // For the random function. -#endif - #include <qlineedit.h> #include <private/qlineedit_p.h> #include <private/qwidgetlinecontrol_p.h> @@ -1922,7 +1918,7 @@ void tst_QLineEdit::noCursorBlinkWhenReadOnly() centerOnScreen(&le); le.show(); le.setFocus(); - QTest::qWaitForWindowActive(&le); + QVERIFY(QTest::qWaitForWindowActive(&le)); le.updates = 0; QTest::qWait(cursorFlashTime); QVERIFY(le.updates > 0); @@ -1941,17 +1937,7 @@ void tst_QLineEdit::noCursorBlinkWhenReadOnly() static void figureOutProperKey(Qt::Key &key, Qt::KeyboardModifiers &pressState) { #ifdef Q_OS_MAC - static bool tst_lineedit_randomized = false; - // Mac has 3 different ways of accomplishing this (same for moving to the back) - // So I guess we should just randomly do this for now. Which may get people mad, but if - // we fail at one point, it's just a matter of setting roll to the correct value - // instead of random. - - if (!tst_lineedit_randomized) { - tst_lineedit_randomized = true; - ::srandom(ulong(time(0))); - } - long roll = ::random() % 3; + long roll = QRandomGenerator::global()->bounded(3); switch (roll) { case 0: key = key == Qt::Key_Home ? Qt::Key_Up : Qt::Key_Down; @@ -1963,9 +1949,8 @@ static void figureOutProperKey(Qt::Key &key, Qt::KeyboardModifiers &pressState) break; } #else - // Naively kill the warning. - key = key; - pressState = pressState; + Q_UNUSED(key); + Q_UNUSED(pressState); #endif } @@ -3361,7 +3346,7 @@ void tst_QLineEdit::inlineCompletion() completer->setCaseSensitivity(Qt::CaseInsensitive); centerOnScreen(testWidget); testWidget->show(); - QTest::qWaitForWindowExposed(testWidget); + QVERIFY(QTest::qWaitForWindowExposed(testWidget)); testWidget->setFocus(); QTRY_COMPARE(qApp->activeWindow(), (QWidget*)testWidget); testWidget->setCompleter(completer); @@ -3689,7 +3674,7 @@ void tst_QLineEdit::task229938_dontEmitChangedWhenTextIsNotChanged() QLineEdit lineEdit; lineEdit.setMaxLength(5); lineEdit.show(); - QTest::qWaitForWindowExposed(&lineEdit); // to be safe and avoid failing setFocus with window managers + QVERIFY(QTest::qWaitForWindowExposed(&lineEdit)); // to be safe and avoid failing setFocus with window managers lineEdit.setFocus(); QSignalSpy changedSpy(&lineEdit, SIGNAL(textChanged(QString))); QTest::qWait(200); @@ -3979,6 +3964,8 @@ void tst_QLineEdit::QTBUG16850_setSelection() le.setText(" 1"); le.setSelection(3, 1); QCOMPARE(le.selectionStart(), 3); + QCOMPARE(le.selectionEnd(), 4); + QCOMPARE(le.selectionLength(), 1); QCOMPARE(le.selectedText(), QString("1")); } @@ -4173,11 +4160,16 @@ void tst_QLineEdit::inputMethodSelection() QCOMPARE(selectionSpy.count(), 0); QCOMPARE(testWidget->selectionStart(), -1); + QCOMPARE(testWidget->selectionEnd(), -1); + QCOMPARE(testWidget->selectionLength(), 0); testWidget->setSelection(0,5); QCOMPARE(selectionSpy.count(), 1); QCOMPARE(testWidget->selectionStart(), 0); + QCOMPARE(testWidget->selectionEnd(), 5); + QCOMPARE(testWidget->selectionLength(), 5); + // selection gained { @@ -4189,6 +4181,8 @@ void tst_QLineEdit::inputMethodSelection() QCOMPARE(selectionSpy.count(), 2); QCOMPARE(testWidget->selectionStart(), 12); + QCOMPARE(testWidget->selectionEnd(), 17); + QCOMPARE(testWidget->selectionLength(), 5); // selection removed { @@ -4199,6 +4193,10 @@ void tst_QLineEdit::inputMethodSelection() } QCOMPARE(selectionSpy.count(), 3); + QCOMPARE(testWidget->selectionStart(), -1); + QCOMPARE(testWidget->selectionEnd(), -1); + QCOMPARE(testWidget->selectionLength(), 0); + } Q_DECLARE_METATYPE(Qt::InputMethodHints) diff --git a/tests/auto/widgets/widgets/qmainwindow/tst_qmainwindow.cpp b/tests/auto/widgets/widgets/qmainwindow/tst_qmainwindow.cpp index 292080c55f..30dc1e6043 100644 --- a/tests/auto/widgets/widgets/qmainwindow/tst_qmainwindow.cpp +++ b/tests/auto/widgets/widgets/qmainwindow/tst_qmainwindow.cpp @@ -2013,7 +2013,7 @@ void tst_QMainWindow::resizeDocks() mw.setCentralWidget(new QTextEdit); mw.show(); - QTest::qWaitForWindowExposed(&mw); + QVERIFY(QTest::qWaitForWindowExposed(&mw)); QFETCH(Qt::Orientation, orientation); QFETCH(QStringList, docks); diff --git a/tests/auto/widgets/widgets/qmenu/BLACKLIST b/tests/auto/widgets/widgets/qmenu/BLACKLIST index cfd6bb1247..1c970c43b3 100644 --- a/tests/auto/widgets/widgets/qmenu/BLACKLIST +++ b/tests/auto/widgets/widgets/qmenu/BLACKLIST @@ -3,3 +3,10 @@ osx [submenuTearOffDontClose] osx-10.11 ci osx-10.12 ci +[layoutDirection] +# Fails when enabling synchronous expose events QTBUG-62092 +osx ci +[pushButtonPopulateOnAboutToShow] +osx +[tearOff] +osx diff --git a/tests/auto/widgets/widgets/qmenu/tst_qmenu.cpp b/tests/auto/widgets/widgets/qmenu/tst_qmenu.cpp index 99d29d487d..91c12e292d 100644 --- a/tests/auto/widgets/widgets/qmenu/tst_qmenu.cpp +++ b/tests/auto/widgets/widgets/qmenu/tst_qmenu.cpp @@ -118,6 +118,8 @@ private slots: #ifdef Q_OS_MAC void QTBUG_37933_ampersands_data(); void QTBUG_37933_ampersands(); +#else + void click_while_dismissing_submenu(); #endif void QTBUG_56917_wideMenuSize(); void QTBUG_56917_wideMenuScreenNumber(); @@ -1164,6 +1166,39 @@ void tst_QMenu::QTBUG20403_nested_popup_on_shortcut_trigger() QVERIFY(!subsub1.isVisible()); } +#ifndef Q_OS_MACOS +void tst_QMenu::click_while_dismissing_submenu() +{ + QMenu menu("Test Menu"); + QAction *action = menu.addAction("action"); + QMenu sub("&sub"); + sub.addAction("subaction"); + menu.addMenu(&sub); + centerOnScreen(&menu, QSize(120, 100)); + menu.show(); + QSignalSpy spy(action, SIGNAL(triggered())); + QSignalSpy menuShownSpy(&sub, SIGNAL(aboutToShow())); + QSignalSpy menuHiddenSpy(&sub, SIGNAL(aboutToHide())); + QVERIFY(QTest::qWaitForWindowExposed(&menu)); + //go over the submenu, press, move and release over the top level action + //this opens the submenu, move two times to emulate user interaction (d->motions > 0 in QMenu) + QTest::mouseMove(&menu, menu.rect().center() + QPoint(0,2)); + QTest::mouseMove(&menu, menu.rect().center() + QPoint(1,3), 60); + QVERIFY(menuShownSpy.wait()); + QVERIFY(sub.isVisible()); + QVERIFY(QTest::qWaitForWindowExposed(&sub)); + //press over the submenu entry + QTest::mousePress(&menu, Qt::LeftButton, 0, menu.rect().center() + QPoint(0,2), 300); + //move over the main action + QTest::mouseMove(&menu, menu.rect().center() - QPoint(0,2)); + QVERIFY(menuHiddenSpy.wait()); + //the submenu must have been hidden for the bug to be triggered + QVERIFY(!sub.isVisible()); + QTest::mouseRelease(&menu, Qt::LeftButton, 0, menu.rect().center() - QPoint(0,2), 300); + QCOMPARE(spy.count(), 1); +} +#endif + class MyWidget : public QWidget { public: diff --git a/tests/auto/widgets/widgets/qopenglwidget/tst_qopenglwidget.cpp b/tests/auto/widgets/widgets/qopenglwidget/tst_qopenglwidget.cpp index 2a05900adc..49291cf5f9 100644 --- a/tests/auto/widgets/widgets/qopenglwidget/tst_qopenglwidget.cpp +++ b/tests/auto/widgets/widgets/qopenglwidget/tst_qopenglwidget.cpp @@ -62,6 +62,8 @@ private slots: void showHide(); void nativeWindow(); void stackWidgetOpaqueChildIsVisible(); + void offscreen(); + void offscreenThenOnscreen(); }; void tst_QOpenGLWidget::initTestCase() @@ -75,15 +77,17 @@ void tst_QOpenGLWidget::create() { QScopedPointer<QOpenGLWidget> w(new QOpenGLWidget); QVERIFY(!w->isValid()); + QVERIFY(w->textureFormat() == 0); QSignalSpy frameSwappedSpy(w.data(), SIGNAL(frameSwapped())); w->show(); - QTest::qWaitForWindowExposed(w.data()); + QVERIFY(QTest::qWaitForWindowExposed(w.data())); QVERIFY(frameSwappedSpy.count() > 0); QVERIFY(w->isValid()); QVERIFY(w->context()); QCOMPARE(w->context()->format(), w->format()); QVERIFY(w->defaultFramebufferObject() != 0); + QVERIFY(w->textureFormat() != 0); } class ClearWidget : public QOpenGLWidget, protected QOpenGLFunctions @@ -127,7 +131,7 @@ void tst_QOpenGLWidget::clearAndGrab() QScopedPointer<ClearWidget> w(new ClearWidget(0, 800, 600)); w->resize(800, 600); w->show(); - QTest::qWaitForWindowExposed(w.data()); + QVERIFY(QTest::qWaitForWindowExposed(w.data())); QVERIFY(w->m_initCalled); QVERIFY(w->m_resizeCalled); QVERIFY(w->m_resizeOk); @@ -145,7 +149,7 @@ void tst_QOpenGLWidget::clearAndResizeAndGrab() QScopedPointer<QOpenGLWidget> w(new ClearWidget(0, 640, 480)); w->resize(640, 480); w->show(); - QTest::qWaitForWindowExposed(w.data()); + QVERIFY(QTest::qWaitForWindowExposed(w.data())); QImage image = w->grabFramebuffer(); QVERIFY(!image.isNull()); @@ -168,7 +172,7 @@ void tst_QOpenGLWidget::createNonTopLevel() QSignalSpy frameSwappedSpy(glw, SIGNAL(frameSwapped())); w.resize(400, 400); w.show(); - QTest::qWaitForWindowExposed(&w); + QVERIFY(QTest::qWaitForWindowExposed(&w)); QVERIFY(frameSwappedSpy.count() > 0); QVERIFY(glw->m_resizeCalled); @@ -224,7 +228,7 @@ void tst_QOpenGLWidget::painter() w.resize(640, 480); glw->resize(320, 200); w.show(); - QTest::qWaitForWindowExposed(&w); + QVERIFY(QTest::qWaitForWindowExposed(&w)); QImage image = glw->grabFramebuffer(); QCOMPARE(image.width(), glw->width()); @@ -245,11 +249,11 @@ void tst_QOpenGLWidget::reparentToAlreadyCreated() w1.resize(640, 480); glw->resize(320, 200); w1.show(); - QTest::qWaitForWindowExposed(&w1); + QVERIFY(QTest::qWaitForWindowExposed(&w1)); QWidget w2; w2.show(); - QTest::qWaitForWindowExposed(&w2); + QVERIFY(QTest::qWaitForWindowExposed(&w2)); glw->setParent(&w2); glw->show(); @@ -267,12 +271,12 @@ void tst_QOpenGLWidget::reparentToNotYetCreated() w1.resize(640, 480); glw->resize(320, 200); w1.show(); - QTest::qWaitForWindowExposed(&w1); + QVERIFY(QTest::qWaitForWindowExposed(&w1)); QWidget w2; glw->setParent(&w2); w2.show(); - QTest::qWaitForWindowExposed(&w2); + QVERIFY(QTest::qWaitForWindowExposed(&w2)); QImage image = glw->grabFramebuffer(); QCOMPARE(image.width(), 320); @@ -293,12 +297,12 @@ void tst_QOpenGLWidget::reparentHidden() glw->hide(); // Explicitly hidden - QTest::qWaitForWindowExposed(&topLevel1); + QVERIFY(QTest::qWaitForWindowExposed(&topLevel1)); QWidget topLevel2; topLevel2.resize(640, 480); topLevel2.show(); - QTest::qWaitForWindowExposed(&topLevel2); + QVERIFY(QTest::qWaitForWindowExposed(&topLevel2)); QOpenGLContext *originalContext = glw->context(); QVERIFY(originalContext); @@ -349,7 +353,7 @@ void tst_QOpenGLWidget::asViewport() layout->addWidget(btn); widget.setLayout(layout); widget.show(); - QTest::qWaitForWindowExposed(&widget); + QVERIFY(QTest::qWaitForWindowExposed(&widget)); QVERIFY(view->paintCount() > 0); view->resetPaintCount(); @@ -377,7 +381,7 @@ void tst_QOpenGLWidget::requestUpdate() PaintCountWidget w; w.resize(640, 480); w.show(); - QTest::qWaitForWindowExposed(&w); + QVERIFY(QTest::qWaitForWindowExposed(&w)); w.reset(); QCOMPARE(w.m_count, 0); @@ -401,7 +405,7 @@ void tst_QOpenGLWidget::fboRedirect() FboCheckWidget w; w.resize(640, 480); w.show(); - QTest::qWaitForWindowExposed(&w); + QVERIFY(QTest::qWaitForWindowExposed(&w)); // Unlike in paintGL(), the default fbo reported by the context is not affected by the widget, // so we get the real default fbo: either 0 or (on iOS) the fbo associated with the window. @@ -416,7 +420,7 @@ void tst_QOpenGLWidget::showHide() QScopedPointer<ClearWidget> w(new ClearWidget(0, 800, 600)); w->resize(800, 600); w->show(); - QTest::qWaitForWindowExposed(w.data()); + QVERIFY(QTest::qWaitForWindowExposed(w.data())); w->hide(); @@ -428,7 +432,7 @@ void tst_QOpenGLWidget::showHide() w->setClearColor(0, 0, 1); w->show(); - QTest::qWaitForWindowExposed(w.data()); + QVERIFY(QTest::qWaitForWindowExposed(w.data())); image = w->grabFramebuffer(); QVERIFY(!image.isNull()); @@ -443,7 +447,7 @@ void tst_QOpenGLWidget::nativeWindow() w->resize(800, 600); w->show(); w->winId(); - QTest::qWaitForWindowExposed(w.data()); + QVERIFY(QTest::qWaitForWindowExposed(w.data())); QImage image = w->grabFramebuffer(); QVERIFY(!image.isNull()); @@ -462,7 +466,7 @@ void tst_QOpenGLWidget::nativeWindow() child->resize(400, 400); child->move(23, 34); nativeParent.show(); - QTest::qWaitForWindowExposed(&nativeParent); + QVERIFY(QTest::qWaitForWindowExposed(&nativeParent)); QVERIFY(nativeParent.internalWinId()); QVERIFY(!child->internalWinId()); @@ -582,8 +586,8 @@ void tst_QOpenGLWidget::stackWidgetOpaqueChildIsVisible() stack.setCurrentIndex(0); stack.resize(dimensionSize, dimensionSize); stack.show(); - QTest::qWaitForWindowExposed(&stack); - QTest::qWaitForWindowActive(&stack); + QVERIFY(QTest::qWaitForWindowExposed(&stack)); + QVERIFY(QTest::qWaitForWindowActive(&stack)); // Switch to the QOpenGLWidget. stack.setCurrentIndex(1); @@ -603,6 +607,74 @@ void tst_QOpenGLWidget::stackWidgetOpaqueChildIsVisible() #undef VERIFY_COLOR } +void tst_QOpenGLWidget::offscreen() +{ + { + QScopedPointer<ClearWidget> w(new ClearWidget(0, 800, 600)); + w->resize(800, 600); + + w->setClearColor(0, 0, 1); + QImage image = w->grabFramebuffer(); + + QVERIFY(!image.isNull()); + QCOMPARE(image.width(), w->width()); + QCOMPARE(image.height(), w->height()); + QVERIFY(image.pixel(30, 40) == qRgb(0, 0, 255)); + } + + // QWidget::grab() should eventually end up in grabFramebuffer() as well + { + QScopedPointer<ClearWidget> w(new ClearWidget(0, 800, 600)); + w->resize(800, 600); + + w->setClearColor(0, 0, 1); + QPixmap pm = w->grab(); + QImage image = pm.toImage(); + + QVERIFY(!image.isNull()); + QCOMPARE(image.width(), w->width()); + QCOMPARE(image.height(), w->height()); + QVERIFY(image.pixel(30, 40) == qRgb(0, 0, 255)); + } + + // ditto for QWidget::render() + { + QScopedPointer<ClearWidget> w(new ClearWidget(0, 800, 600)); + w->resize(800, 600); + + w->setClearColor(0, 0, 1); + QImage image(800, 600, QImage::Format_ARGB32); + w->render(&image); + + QVERIFY(image.pixel(30, 40) == qRgb(0, 0, 255)); + } +} + +void tst_QOpenGLWidget::offscreenThenOnscreen() +{ + QScopedPointer<ClearWidget> w(new ClearWidget(0, 800, 600)); + w->resize(800, 600); + + w->setClearColor(0, 0, 1); + QImage image = w->grabFramebuffer(); + + QVERIFY(!image.isNull()); + QCOMPARE(image.width(), w->width()); + QCOMPARE(image.height(), w->height()); + QVERIFY(image.pixel(30, 40) == qRgb(0, 0, 255)); + + // now let's make things more challenging: show. Internally this needs + // recreating the context. + w->show(); + QVERIFY(QTest::qWaitForWindowExposed(w.data())); + + image = w->grabFramebuffer(); + QVERIFY(!image.isNull()); + QCOMPARE(image.width(), w->width()); + QCOMPARE(image.height(), w->height()); + QVERIFY(image.pixel(30, 40) == qRgb(0, 0, 255)); +} + QTEST_MAIN(tst_QOpenGLWidget) #include "tst_qopenglwidget.moc" diff --git a/tests/auto/widgets/widgets/qprogressbar/tst_qprogressbar.cpp b/tests/auto/widgets/widgets/qprogressbar/tst_qprogressbar.cpp index 205ef34958..9f64335930 100644 --- a/tests/auto/widgets/widgets/qprogressbar/tst_qprogressbar.cpp +++ b/tests/auto/widgets/widgets/qprogressbar/tst_qprogressbar.cpp @@ -45,6 +45,7 @@ private slots: void destroyIndeterminate(); void text(); void format(); + void setValueRepaint_data(); void setValueRepaint(); #ifndef Q_OS_MAC void setMinMaxRepaint(); @@ -191,21 +192,49 @@ void tst_QProgressBar::format() QCOMPARE(bar.text(), QString()); } +void tst_QProgressBar::setValueRepaint_data() +{ + QTest::addColumn<int>("min"); + QTest::addColumn<int>("max"); + QTest::addColumn<int>("increment"); + + auto add = [](int min, int max, int increment) { + QTest::addRow("%d-%d@%d", min, max, increment) << min << max << increment; + }; + + add(0, 10, 1); + + auto add_set = [=](int min, int max, int increment) { + // check corner cases, and adjacent values (to circumvent explicit checks for corner cases) + add(min, max, increment); + add(min + 1, max, increment); + add(min, max - 1, increment); + add(min + 1, max - 1, increment); + }; + + add_set(INT_MIN, INT_MAX, INT_MAX / 50 + 1); + add_set(0, INT_MAX, INT_MAX / 100 + 1); + add_set(INT_MIN, 0, INT_MAX / 100 + 1); +} + void tst_QProgressBar::setValueRepaint() { + QFETCH(int, min); + QFETCH(int, max); + QFETCH(int, increment); + ProgressBar pbar; - pbar.setMinimum(0); - pbar.setMaximum(10); + pbar.setMinimum(min); + pbar.setMaximum(max); pbar.setFormat("%v"); pbar.move(300, 300); pbar.show(); QVERIFY(QTest::qWaitForWindowExposed(&pbar)); QApplication::processEvents(); - for (int i = pbar.minimum(); i < pbar.maximum(); ++i) { + for (qint64 i = min; i < max; i += increment) { pbar.repainted = false; - pbar.setValue(i); - QTest::qWait(50); + pbar.setValue(int(i)); QTRY_VERIFY(pbar.repainted); } } diff --git a/tests/auto/widgets/widgets/qpushbutton/tst_qpushbutton.cpp b/tests/auto/widgets/widgets/qpushbutton/tst_qpushbutton.cpp index 7bbbc46b5a..2b54008de7 100644 --- a/tests/auto/widgets/widgets/qpushbutton/tst_qpushbutton.cpp +++ b/tests/auto/widgets/widgets/qpushbutton/tst_qpushbutton.cpp @@ -520,9 +520,6 @@ void tst_QPushButton::sizeHint_data() #if !defined(QT_NO_STYLE_FUSION) QTest::newRow("fusion") << QString::fromLatin1("fusion"); #endif -#if defined(Q_OS_WIN) && !defined(QT_NO_STYLE_WINDOWSXP) - QTest::newRow("windowsxp") << QString::fromLatin1("windowsxp"); -#endif #if defined(Q_OS_WIN) && !defined(QT_NO_STYLE_WINDOWSVISTA) QTest::newRow("windowsvista") << QString::fromLatin1("windowsvista"); #endif @@ -597,7 +594,7 @@ void tst_QPushButton::taskQTBUG_20191_shortcutWithKeypadModifer() QDialog dialog; dialog.setLayout(layout); dialog.show(); - QTest::qWaitForWindowExposed(&dialog); + QVERIFY(QTest::qWaitForWindowExposed(&dialog)); QApplication::setActiveWindow(&dialog); // add shortcut '5' to button1 and test with keyboard and keypad '5' keys @@ -642,7 +639,7 @@ void tst_QPushButton::emitReleasedAfterChange() QDialog dialog; dialog.setLayout(layout); dialog.show(); - QTest::qWaitForWindowExposed(&dialog); + QVERIFY(QTest::qWaitForWindowExposed(&dialog)); QApplication::setActiveWindow(&dialog); button1->setFocus(); diff --git a/tests/auto/widgets/widgets/qscrollbar/tst_qscrollbar.cpp b/tests/auto/widgets/widgets/qscrollbar/tst_qscrollbar.cpp index f9a3e51977..278f5cdd68 100644 --- a/tests/auto/widgets/widgets/qscrollbar/tst_qscrollbar.cpp +++ b/tests/auto/widgets/widgets/qscrollbar/tst_qscrollbar.cpp @@ -71,7 +71,7 @@ void tst_QScrollBar::scrollSingleStep() testWidget.resize(100, testWidget.height()); centerOnScreen(&testWidget); testWidget.show(); - QTest::qWaitForWindowExposed(&testWidget); + QVERIFY(QTest::qWaitForWindowExposed(&testWidget)); testWidget.setValue(testWidget.minimum()); QCOMPARE(testWidget.value(), testWidget.minimum()); @@ -110,7 +110,7 @@ void tst_QScrollBar::task_209492() verticalScrollBar->setRange(0, 1000); centerOnScreen(&scrollArea); scrollArea.show(); - QTest::qWaitForWindowExposed(&scrollArea); + QVERIFY(QTest::qWaitForWindowExposed(&scrollArea)); QSignalSpy spy(verticalScrollBar, SIGNAL(actionTriggered(int))); QCOMPARE(scrollArea.scrollCount, 0); @@ -147,7 +147,7 @@ void tst_QScrollBar::QTBUG_27308() testWidget.resize(100, testWidget.height()); centerOnScreen(&testWidget); testWidget.show(); - QTest::qWaitForWindowExposed(&testWidget); + QVERIFY(QTest::qWaitForWindowExposed(&testWidget)); testWidget.setValue(testWidget.minimum()); testWidget.setEnabled(false); @@ -176,7 +176,7 @@ void tst_QScrollBar::QTBUG_42871() scrollBarWidget.resize(100, scrollBarWidget.height()); centerOnScreen(&scrollBarWidget); scrollBarWidget.show(); - QTest::qWaitForWindowExposed(&scrollBarWidget); + QVERIFY(QTest::qWaitForWindowExposed(&scrollBarWidget)); QSignalSpy spy(&scrollBarWidget, SIGNAL(actionTriggered(int))); QVERIFY(spy.isValid()); QCOMPARE(myHandler.updatesCount, 0); diff --git a/tests/auto/widgets/widgets/qsplitter/tst_qsplitter.cpp b/tests/auto/widgets/widgets/qsplitter/tst_qsplitter.cpp index 72e6ffdeb5..aef4046afe 100644 --- a/tests/auto/widgets/widgets/qsplitter/tst_qsplitter.cpp +++ b/tests/auto/widgets/widgets/qsplitter/tst_qsplitter.cpp @@ -828,7 +828,7 @@ void tst_QSplitter::handleMinimumWidth() split.addWidget(new QLabel("Number Too")); split.show(); - QTest::qWaitForWindowExposed(&split); + QVERIFY(QTest::qWaitForWindowExposed(&split)); for (int i = 0; i < 10; i++) { split.setHandleWidth(i); QTest::qWait(100); // resizing diff --git a/tests/auto/widgets/widgets/qstackedwidget/tst_qstackedwidget.cpp b/tests/auto/widgets/widgets/qstackedwidget/tst_qstackedwidget.cpp index 2df5f01627..59a334fab9 100644 --- a/tests/auto/widgets/widgets/qstackedwidget/tst_qstackedwidget.cpp +++ b/tests/auto/widgets/widgets/qstackedwidget/tst_qstackedwidget.cpp @@ -180,7 +180,7 @@ void tst_QStackedWidget::dynamicPages() sw->resize(200, 200); sw->show(); qApp->setActiveWindow(sw); - QTest::qWaitForWindowActive(sw); + QVERIFY(QTest::qWaitForWindowActive(sw)); QTRY_COMPARE(QApplication::focusWidget(), le11); sw->setCurrentIndex(1); diff --git a/tests/auto/widgets/widgets/qtextedit/tst_qtextedit.cpp b/tests/auto/widgets/widgets/qtextedit/tst_qtextedit.cpp index 55ef44f4e0..f383d430d6 100644 --- a/tests/auto/widgets/widgets/qtextedit/tst_qtextedit.cpp +++ b/tests/auto/widgets/widgets/qtextedit/tst_qtextedit.cpp @@ -2507,7 +2507,7 @@ void tst_QTextEdit::highlightLongLine() }; NumHighlighter nh(edit.document()); edit.show(); - QTest::qWaitForWindowActive(edit.windowHandle()); + QVERIFY(QTest::qWaitForWindowActive(edit.windowHandle())); QCoreApplication::processEvents(); //If there is a quadratic behaviour, this would take forever. QVERIFY(true); @@ -2604,30 +2604,20 @@ namespace { class MyPaintEngine : public QPaintEngine { public: - bool begin(QPaintDevice *) - { - return true; - } + bool begin(QPaintDevice *) override { return true; } - bool end() - { - return true; - } + bool end() override { return true; } - void updateState(const QPaintEngineState &) - { - } + void updateState(const QPaintEngineState &) override { } - void drawPixmap(const QRectF &, const QPixmap &, const QRectF &) - { - } + void drawPixmap(const QRectF &, const QPixmap &, const QRectF &) override { } - void drawTextItem(const QPointF &, const QTextItem &textItem) Q_DECL_OVERRIDE + void drawTextItem(const QPointF &, const QTextItem &textItem) override { itemFonts.append(qMakePair(textItem.text(), textItem.font())); } - Type type() const { return User; } + Type type() const override { return User; } QList<QPair<QString, QFont> > itemFonts; |