diff options
Diffstat (limited to 'tests')
-rw-r--r-- | tests/auto/corelib/tools/qline/tst_qline.cpp | 3 | ||||
-rw-r--r-- | tests/auto/gui/kernel/qwindow/BLACKLIST | 2 | ||||
-rw-r--r-- | tests/auto/network/socket/qudpsocket/tst_qudpsocket.cpp | 6 | ||||
-rw-r--r-- | tests/auto/other/gestures/tst_gestures.cpp | 28 | ||||
-rw-r--r-- | tests/auto/printsupport/kernel/qprinter/tst_qprinter.cpp | 45 | ||||
-rw-r--r-- | tests/auto/widgets/itemviews/qheaderview/tst_qheaderview.cpp | 4 | ||||
-rw-r--r-- | tests/manual/touch/main.cpp | 98 |
7 files changed, 159 insertions, 27 deletions
diff --git a/tests/auto/corelib/tools/qline/tst_qline.cpp b/tests/auto/corelib/tools/qline/tst_qline.cpp index 6e020ac35b..ae65d8f697 100644 --- a/tests/auto/corelib/tools/qline/tst_qline.cpp +++ b/tests/auto/corelib/tools/qline/tst_qline.cpp @@ -166,9 +166,6 @@ void tst_QLine::testIntersection_data() << 100.1599256468622 << 50.0; - QLineF baseA(0, -50, 0, 50); - QLineF baseB(-50, 0, 50, 0); - for (int i = 0; i < 1000; ++i) { QLineF a = QLineF::fromPolar(50, i); a.setP1(-a.p2()); diff --git a/tests/auto/gui/kernel/qwindow/BLACKLIST b/tests/auto/gui/kernel/qwindow/BLACKLIST index cd1cb99c3c..70091121bc 100644 --- a/tests/auto/gui/kernel/qwindow/BLACKLIST +++ b/tests/auto/gui/kernel/qwindow/BLACKLIST @@ -3,8 +3,6 @@ linux osx-10.12 ci [positioning:fake] osx-10.12 ci -[modalWindowPosition] -ubuntu-16.04 [modalWithChildWindow] ubuntu-16.04 # QTBUG-66851 diff --git a/tests/auto/network/socket/qudpsocket/tst_qudpsocket.cpp b/tests/auto/network/socket/qudpsocket/tst_qudpsocket.cpp index 8165ccbc58..8ebb27e58c 100644 --- a/tests/auto/network/socket/qudpsocket/tst_qudpsocket.cpp +++ b/tests/auto/network/socket/qudpsocket/tst_qudpsocket.cpp @@ -962,8 +962,10 @@ void tst_QUdpSocket::bindMode() // Depending on the user's privileges, this or will succeed or // fail. Admins are allowed to reuse the address, but nobody else. - if (!socket2.bind(socket.localPort(), QUdpSocket::ReuseAddressHint), socket2.errorString().toLatin1().constData()) - qWarning("Failed to bind with QUdpSocket::ReuseAddressHint, user isn't an administrator?"); + if (!socket2.bind(socket.localPort(), QUdpSocket::ReuseAddressHint)) { + qWarning("Failed to bind with QUdpSocket::ReuseAddressHint(%s), user isn't an administrator?", + qPrintable(socket2.errorString())); + } socket.close(); QVERIFY2(socket.bind(0, QUdpSocket::ShareAddress), socket.errorString().toLatin1().constData()); QVERIFY(!socket2.bind(socket.localPort())); diff --git a/tests/auto/other/gestures/tst_gestures.cpp b/tests/auto/other/gestures/tst_gestures.cpp index 0767efb817..9abe9a77c0 100644 --- a/tests/auto/other/gestures/tst_gestures.cpp +++ b/tests/auto/other/gestures/tst_gestures.cpp @@ -331,6 +331,9 @@ private slots: void graphicsViewParentPropagation(); void panelPropagation(); void panelStacksBehindParent(); +#ifdef Q_OS_MACOS + void deleteMacPanGestureRecognizerTargetWidget(); +#endif void deleteGestureTargetWidget(); void deleteGestureTargetItem_data(); void deleteGestureTargetItem(); @@ -1807,6 +1810,31 @@ void tst_Gestures::panelStacksBehindParent() QCOMPARE(panel->gestureOverrideEventsReceived, 0); } +#ifdef Q_OS_MACOS +void tst_Gestures::deleteMacPanGestureRecognizerTargetWidget() +{ + QWidget window; + window.resize(400,400); + QGraphicsScene scene; + QGraphicsView *view = new QGraphicsView(&scene, &window); + view->resize(400, 400); + window.show(); + + QVERIFY(QTest::qWaitForWindowExposed(&window)); + QTouchDevice *device = QTest::createTouchDevice(); + // QMacOSPenGestureRecognizer will start a timer on a touch press event + QTest::touchEvent(&window, device).press(1, QPoint(100, 100), &window); + delete view; + + // wait until after that the QMacOSPenGestureRecognizer timer (300ms) is triggered. + // This is needed so that the whole test does not finish before the timer triggers + // and to make sure it crashes while executing *this* function. (otherwise it might give the + // impression that some of the subsequent test function caused the crash...) + + QTest::qWait(400); // DO NOT CRASH while waiting +} +#endif + void tst_Gestures::deleteGestureTargetWidget() { } diff --git a/tests/auto/printsupport/kernel/qprinter/tst_qprinter.cpp b/tests/auto/printsupport/kernel/qprinter/tst_qprinter.cpp index a612f0749b..a65dd0bf8f 100644 --- a/tests/auto/printsupport/kernel/qprinter/tst_qprinter.cpp +++ b/tests/auto/printsupport/kernel/qprinter/tst_qprinter.cpp @@ -122,6 +122,7 @@ private slots: void testPageMetrics_data(); void testPageMetrics(); + void reusePageMetrics(); #endif private: QString testFileName(const QString &prefix, const QString &suffix); @@ -1955,6 +1956,50 @@ QString tst_QPrinter::testFileName(const QString &prefix, const QString &suffix) return result; } +void tst_QPrinter::reusePageMetrics() +{ + QList<QPrinterInfo> availablePrinters = QPrinterInfo::availablePrinters(); + if (availablePrinters.size() < 2) + QSKIP("Not enough printers to do this test with, need at least 2 setup"); + QPrinter defaultP; + QPrinterInfo info(defaultP); + QString otherPrinterName; + for (QPrinterInfo i : qAsConst(availablePrinters)) { + if (i.printerName() != defaultP.printerName()) { + otherPrinterName = i.printerName(); + break; + } + } + QPrinter otherP(QPrinterInfo::printerInfo(otherPrinterName)); + QList<QPageSize> defaultPageSizes = info.supportedPageSizes(); + QList<QPageSize> otherPageSizes = QPrinterInfo(otherP).supportedPageSizes(); + QPageSize unavailableSizeToSet; + for (QPageSize s : qAsConst(defaultPageSizes)) { + bool found = false; + for (QPageSize os : qAsConst(otherPageSizes)) { + if (os.isEquivalentTo(s)) { + found = true; + break; + } + } + const QPageSize tmpSize(s.size(QPageSize::Point), QPageSize::Point); + if (!tmpSize.name().startsWith("Custom")) + found = true; + if (!found) { + unavailableSizeToSet = s; + break; + } + } + if (!unavailableSizeToSet.isValid()) + QSKIP("Could not find a size that was not available on the non default printer. The test " + "requires this"); + defaultP.setPageSize(unavailableSizeToSet); + defaultP.setPrinterName(otherP.printerName()); + QVERIFY(defaultP.pageLayout().pageSize().isEquivalentTo(unavailableSizeToSet)); + QVERIFY(defaultP.pageLayout().pageSize().name() != unavailableSizeToSet.name()); + QCOMPARE(defaultP.pageLayout().pageSize().sizePoints(), unavailableSizeToSet.sizePoints()); +} + #endif // QT_CONFIG(printer) QTEST_MAIN(tst_QPrinter) diff --git a/tests/auto/widgets/itemviews/qheaderview/tst_qheaderview.cpp b/tests/auto/widgets/itemviews/qheaderview/tst_qheaderview.cpp index 74a2f7f2b6..08597d5eb1 100644 --- a/tests/auto/widgets/itemviews/qheaderview/tst_qheaderview.cpp +++ b/tests/auto/widgets/itemviews/qheaderview/tst_qheaderview.cpp @@ -3326,7 +3326,7 @@ void tst_QHeaderView::testMinMaxSectionSize(bool stretchLastSection) header.resizeSection(0, sectionSizeMax); QCOMPARE(header.sectionSize(0), sectionSizeMax); header.setMaximumSectionSize(defaultSectionSize); - waitFor([this, &header, defaultSectionSize]() { return header.sectionSize(0) == defaultSectionSize; }); + waitFor([&header, defaultSectionSize]() { return header.sectionSize(0) == defaultSectionSize; }); QCOMPARE(header.sectionSize(0), defaultSectionSize); // change section size on min change @@ -3335,7 +3335,7 @@ void tst_QHeaderView::testMinMaxSectionSize(bool stretchLastSection) header.resizeSection(0, sectionSizeMin); QCOMPARE(header.sectionSize(0), sectionSizeMin); header.setMinimumSectionSize(defaultSectionSize); - waitFor([this, &header, defaultSectionSize]() { return header.sectionSize(0) == defaultSectionSize; }); + waitFor([&header, defaultSectionSize]() { return header.sectionSize(0) == defaultSectionSize; }); QCOMPARE(header.sectionSize(0), defaultSectionSize); } diff --git a/tests/manual/touch/main.cpp b/tests/manual/touch/main.cpp index 9f2dcb3842..a244230a22 100644 --- a/tests/manual/touch/main.cpp +++ b/tests/manual/touch/main.cpp @@ -34,6 +34,7 @@ #include <QAction> #include <QMainWindow> #include <QSplitter> +#include <QStatusBar> #include <QToolBar> #include <QVector> #include <QCommandLineOption> @@ -43,6 +44,7 @@ #include <QPainterPath> #include <QPaintEvent> #include <QScreen> +#include <QWindow> #include <QSharedPointer> #include <QDebug> #include <QTextStream> @@ -50,6 +52,8 @@ static bool optIgnoreTouch = false; static QVector<Qt::GestureType> optGestures; +static QWidgetList mainWindows; + static inline void drawEllipse(const QPointF ¢er, qreal hDiameter, qreal vDiameter, const QColor &color, QPainter &painter) { const QPen oldPen = painter.pen(); @@ -191,6 +195,7 @@ typedef QSharedPointer<Gesture> GesturePtr; typedef QVector<GesturePtr> GesturePtrs; typedef QVector<QEvent::Type> EventTypeVector; +static EventTypeVector eventTypes; class EventFilter : public QObject { Q_OBJECT @@ -206,6 +211,8 @@ private: const EventTypeVector m_types; }; +static EventFilter *globalEventFilter = nullptr; + bool EventFilter::eventFilter(QObject *o, QEvent *e) { static int n = 0; @@ -406,29 +413,67 @@ void TouchTestWidget::paintEvent(QPaintEvent *) class MainWindow : public QMainWindow { Q_OBJECT -public: MainWindow(); +public: + static MainWindow *createMainWindow(); + QWidget *touchWidget() const { return m_touchWidget; } + void setVisible(bool visible) override; + public slots: void appendToLog(const QString &text) { m_logTextEdit->appendPlainText(text); } void dumpTouchDevices(); private: + void updateScreenLabel(); + void newWindow() { MainWindow::createMainWindow(); } + TouchTestWidget *m_touchWidget; QPlainTextEdit *m_logTextEdit; + QLabel *m_screenLabel; }; +MainWindow *MainWindow::createMainWindow() +{ + MainWindow *result = new MainWindow; + const QSize screenSize = QGuiApplication::primaryScreen()->availableGeometry().size(); + result->resize(screenSize / 2); + const QSize sizeDiff = screenSize - result->size(); + const QPoint pos = QPoint(sizeDiff.width() / 2, sizeDiff.height() / 2) + + mainWindows.size() * QPoint(30, 10); + result->move(pos); + result->show(); + + EventFilter *eventFilter = globalEventFilter; + if (!eventFilter) { + eventFilter = new EventFilter(eventTypes, result->touchWidget()); + result->touchWidget()->installEventFilter(eventFilter); + } + QObject::connect(eventFilter, &EventFilter::eventReceived, result, &MainWindow::appendToLog); + + mainWindows.append(result); + return result; +} + MainWindow::MainWindow() : m_touchWidget(new TouchTestWidget) , m_logTextEdit(new QPlainTextEdit) + , m_screenLabel(new QLabel) { - setWindowTitle(QStringLiteral("Touch Event Tester ") + QT_VERSION_STR); + QString title; + QTextStream(&title) << "Touch Event Tester " << QT_VERSION_STR << ' ' + << qApp->platformName() << " #" << (mainWindows.size() + 1); + setWindowTitle(title); setObjectName("MainWin"); QToolBar *toolBar = new QToolBar(this); addToolBar(Qt::TopToolBarArea, toolBar); QMenu *fileMenu = menuBar()->addMenu("File"); + QAction *newWindowAction = fileMenu->addAction(QStringLiteral("New Window"), this, &MainWindow::newWindow); + newWindowAction->setShortcut(QKeySequence(Qt::CTRL + Qt::Key_N)); + toolBar->addAction(newWindowAction); + fileMenu->addSeparator(); QAction *dumpDeviceAction = fileMenu->addAction(QStringLiteral("Dump devices")); dumpDeviceAction->setShortcut(QKeySequence(Qt::CTRL + Qt::Key_D)); connect(dumpDeviceAction, &QAction::triggered, this, &MainWindow::dumpTouchDevices); @@ -461,9 +506,32 @@ MainWindow::MainWindow() mainSplitter->addWidget(m_logTextEdit); setCentralWidget(mainSplitter); + statusBar()->addPermanentWidget(m_screenLabel); + dumpTouchDevices(); } +void MainWindow::setVisible(bool visible) +{ + QMainWindow::setVisible(visible); + connect(windowHandle(), &QWindow::screenChanged, this, &MainWindow::updateScreenLabel); + updateScreenLabel(); +} + +void MainWindow::updateScreenLabel() +{ + QString text; + QTextStream str(&text); + const QScreen *screen = windowHandle()->screen(); + const QRect geometry = screen->geometry(); + const qreal dpr = screen->devicePixelRatio(); + str << '"' << screen->name() << "\" " << geometry.width() << 'x' << geometry.height() + << forcesign << geometry.x() << geometry.y() << noforcesign; + if (!qFuzzyCompare(dpr, qreal(1))) + str << ", dpr=" << dpr; + m_screenLabel->setText(text); +} + void MainWindow::dumpTouchDevices() { QString message; @@ -522,14 +590,6 @@ int main(int argc, char *argv[]) if (parser.isSet(swipeGestureOption)) optGestures.append(Qt::SwipeGesture); - MainWindow w; - const QSize screenSize = QGuiApplication::primaryScreen()->availableGeometry().size(); - w.resize(screenSize / 2); - const QSize sizeDiff = screenSize - w.size(); - w.move(sizeDiff.width() / 2, sizeDiff.height() / 2); - w.show(); - - EventTypeVector eventTypes; if (!parser.isSet(noMouseLogOption)) eventTypes << QEvent::MouseButtonPress << QEvent::MouseButtonRelease << QEvent::MouseButtonDblClick; if (parser.isSet(mouseMoveOption)) @@ -538,14 +598,16 @@ int main(int argc, char *argv[]) eventTypes << QEvent::TouchBegin << QEvent::TouchUpdate << QEvent::TouchEnd; if (!optGestures.isEmpty()) eventTypes << QEvent::Gesture << QEvent::GestureOverride; - QObject *filterTarget = parser.isSet(globalFilterOption) - ? static_cast<QObject *>(&a) - : static_cast<QObject *>(w.touchWidget()); - EventFilter *filter = new EventFilter(eventTypes, filterTarget); - filterTarget->installEventFilter(filter); - QObject::connect(filter, &EventFilter::eventReceived, &w, &MainWindow::appendToLog); - - return a.exec(); + if (parser.isSet(globalFilterOption)) { + globalEventFilter = new EventFilter(eventTypes, &a); + a.installEventFilter(globalEventFilter); + } + + MainWindow::createMainWindow(); + + const int exitCode = a.exec(); + qDeleteAll(mainWindows); + return exitCode; } #include "main.moc" |