diff options
author | Qt Forward Merge Bot <qt_forward_merge_bot@qt-project.org> | 2018-05-02 13:15:15 +0200 |
---|---|---|
committer | Qt Forward Merge Bot <qt_forward_merge_bot@qt-project.org> | 2018-05-02 13:15:15 +0200 |
commit | 7de400052f7df52095103f56f1cb753854be1af1 (patch) | |
tree | 823c01302efd5d2181a3b3a55eb2937e52c849b1 /tests | |
parent | 8b098e6544221a96bc6a41a6bfcc0dfa7cf805e6 (diff) | |
parent | 364bd6ca74b059ffe8ae367e1562645a3ed0855e (diff) |
Merge remote-tracking branch 'origin/5.11' into dev
Change-Id: Ia082e20e2eb4b76afd4c1a1584ff4e5514655d7a
Diffstat (limited to 'tests')
10 files changed, 214 insertions, 68 deletions
diff --git a/tests/auto/corelib/itemmodels/qitemselectionmodel/tst_qitemselectionmodel.cpp b/tests/auto/corelib/itemmodels/qitemselectionmodel/tst_qitemselectionmodel.cpp index b05e3968ea..6fbaa28d69 100644 --- a/tests/auto/corelib/itemmodels/qitemselectionmodel/tst_qitemselectionmodel.cpp +++ b/tests/auto/corelib/itemmodels/qitemselectionmodel/tst_qitemselectionmodel.cpp @@ -95,6 +95,9 @@ private slots: void QTBUG58851_data(); void QTBUG58851(); + void QTBUG18001_data(); + void QTBUG18001(); + private: QAbstractItemModel *model; QItemSelectionModel *selection; @@ -2922,5 +2925,98 @@ void tst_QItemSelectionModel::QTBUG58851() } } +void tst_QItemSelectionModel::QTBUG18001_data() +{ + using IntPair = std::pair<int, int>; + using IntPairList = QList<IntPair>; + using IntList = QList<int>; + using BoolList = QList<bool>; + + QTest::addColumn<IntPairList>("indexesToSelect"); + QTest::addColumn<IntList>("selectionCommands"); + QTest::addColumn<BoolList>("expectedSelectedRows"); + QTest::addColumn<BoolList>("expectedSelectedColums"); + + int colSelect = QItemSelectionModel::Select | QItemSelectionModel::Columns; + int rowSelect = QItemSelectionModel::Select | QItemSelectionModel::Rows; + + QTest::newRow("Select column 1") + << IntPairList { {0, 1} } + << IntList{ colSelect } + << BoolList{ false, false, false, false, false } + << BoolList{ false, true, false, false, false }; + + QTest::newRow("Select row 1") + << IntPairList { {1, 0} } + << IntList{ rowSelect } + << BoolList{ false, true, false, false, false } + << BoolList{ false, false, false, false, false }; + + QTest::newRow("Select column 1+2, row 1+2") + << IntPairList { {0, 1}, {0, 2}, {1, 0}, {2, 0} } + << IntList{ colSelect, colSelect, rowSelect, rowSelect } + << BoolList{ false, true, true, false, false } + << BoolList{ false, true, true, false, false }; + + QTest::newRow("Select row 1+2, col 1+2") + << IntPairList { {1, 0}, {2, 0}, {0, 1}, {0, 2} } + << IntList{ rowSelect, rowSelect, colSelect, colSelect } + << BoolList{ false, true, true, false, false } + << BoolList{ false, true, true, false, false }; +} + +void tst_QItemSelectionModel::QTBUG18001() +{ + using IntPair = std::pair<int, int>; + using IntPairList = QList<IntPair>; + using IntList = QList<int>; + using BoolList = QList<bool>; + + QFETCH(IntPairList, indexesToSelect); + QFETCH(IntList, selectionCommands); + QFETCH(BoolList, expectedSelectedRows); + QFETCH(BoolList, expectedSelectedColums); + + QStandardItemModel model(5, 5); + for (int row = 0; row < model.rowCount(); ++row) { + for (int column = 0; column < model.columnCount(); ++column) { + QStandardItem *item = new QStandardItem(QString("%0x%1").arg(row).arg(column)); + model.setItem(row, column, item); + + const bool oddRow = row % 2; + const bool oddCol = column % 2; + + if (oddRow == oddCol) + item->setSelectable(false); + } + } + + QItemSelectionModel selectionModel(&model); + + for (int i = 0; i < indexesToSelect.count(); ++i) { + QModelIndex idx = model.index( indexesToSelect.at(i).first, indexesToSelect.at(i).second ); + selectionModel.select(idx, QItemSelectionModel::SelectionFlag(selectionCommands.at(i))); + } + + for (int i = 0; i < expectedSelectedRows.count(); ++i) { + const bool expected = expectedSelectedRows.at(i); + const bool actual = selectionModel.isRowSelected(i, QModelIndex()); + QByteArray description = QByteArray("Row ") + QByteArray::number(i) + + " Expected " + QByteArray::number(expected) + + " Actual " + QByteArray::number(actual); + QVERIFY2(expected == actual, description.data()); + } + + for (int i = 0; i < expectedSelectedColums.count(); ++i) { + const bool expected = expectedSelectedColums.at(i); + const bool actual = selectionModel.isColumnSelected(i, QModelIndex()); + QByteArray description = QByteArray("Col ") + QByteArray::number(i) + + " Expected " + QByteArray::number(expected) + + " Actual " + QByteArray::number(actual); + QVERIFY2(expected == actual, description.data()); + } + +} + QTEST_MAIN(tst_QItemSelectionModel) #include "tst_qitemselectionmodel.moc" diff --git a/tests/auto/corelib/tools/qstring/tst_qstring.cpp b/tests/auto/corelib/tools/qstring/tst_qstring.cpp index 6aa3c498aa..fefb533616 100644 --- a/tests/auto/corelib/tools/qstring/tst_qstring.cpp +++ b/tests/auto/corelib/tools/qstring/tst_qstring.cpp @@ -324,10 +324,8 @@ public: public slots: void cleanup(); private slots: -#ifndef Q_CC_HPACC void fromStdString(); void toStdString(); -#endif void check_QTextIOStream(); void check_QTextStream(); void check_QDataStream(); @@ -4098,8 +4096,6 @@ void tst_QString::setRawData() QVERIFY(cstr.data_ptr() != csd); } -#ifndef Q_CC_HPACC -// This test crashes on HP-UX with aCC (not supported) void tst_QString::fromStdString() { std::string stroustrup = "foo"; @@ -4110,10 +4106,7 @@ void tst_QString::fromStdString() QString qtnull = QString::fromStdString( stdnull ); QCOMPARE( qtnull.size(), int(stdnull.size()) ); } -#endif -#ifndef Q_CC_HPACC -// This test crashes on HP-UX with aCC (not supported) void tst_QString::toStdString() { QString nord = "foo"; @@ -4130,7 +4123,6 @@ void tst_QString::toStdString() std::string stdnull = qtnull.toStdString(); QCOMPARE( int(stdnull.size()), qtnull.size() ); } -#endif void tst_QString::utf8() { diff --git a/tests/auto/network/access/qnetworkcookiejar/tst_qnetworkcookiejar.cpp b/tests/auto/network/access/qnetworkcookiejar/tst_qnetworkcookiejar.cpp index ed5d0c69a0..8b49679042 100644 --- a/tests/auto/network/access/qnetworkcookiejar/tst_qnetworkcookiejar.cpp +++ b/tests/auto/network/access/qnetworkcookiejar/tst_qnetworkcookiejar.cpp @@ -164,7 +164,9 @@ void tst_QNetworkCookieJar::setCookiesFromUrl_data() result.clear(); preset.clear(); cookie.setDomain(".foo.ck"); - QTest::newRow("effective-tld2-denied") << preset << cookie << "http://foo.ck" << result << false; + result += cookie; + QTest::newRow("effective-tld2-accepted2") << preset << cookie << "http://foo.ck" << result << true; + result.clear(); QTest::newRow("effective-tld2-denied2") << preset << cookie << "http://www.foo.ck" << result << false; QTest::newRow("effective-tld2-denied3") << preset << cookie << "http://www.anything.foo.ck" << result << false; cookie.setDomain(".www.ck"); @@ -208,6 +210,22 @@ void tst_QNetworkCookieJar::setCookiesFromUrl_data() preset.clear(); cookie.setDomain(".com."); QTest::newRow("rfc2109-4.3.2-ex3-2") << preset << cookie << "http://x.foo.com" << result << false; + + // When using a TLD as a hostname the hostname should still get cookies (QTBUG-52040) + // ... and nothing else should get the cookies. + result.clear(); + preset.clear(); + cookie.setPath("/"); + cookie.setDomain(".support"); + result += cookie; + QTest::newRow("TLD-as-domain-accepted") << preset << cookie << "http://support" << result << true; + result.clear(); + QTest::newRow("TLD-as-domain-rejected") << preset << cookie << "http://a.support" << result << false; + // Now test with no domain in the cookie, use the domain from the url (matching TLD) + cookie.setDomain("support"); + result += cookie; + cookie.setDomain(""); + QTest::newRow("TLD-as-domain-accepted2") << preset << cookie << "http://support" << result << true; } void tst_QNetworkCookieJar::setCookiesFromUrl() @@ -351,6 +369,19 @@ void tst_QNetworkCookieJar::cookiesForUrl_data() result.clear(); result += rootCookie; QTest::newRow("root-path-match") << allCookies << "http://qt-project.org" << result; + + // Domain in cookie happens to match a TLD + allCookies.clear(); + QNetworkCookie tldCookie; + tldCookie.setDomain(".support"); + tldCookie.setName("a"); + tldCookie.setValue("b"); + allCookies += tldCookie; + result.clear(); + result += tldCookie; + QTest::newRow("tld-cookie-match") << allCookies << "http://support/" << result; + result.clear(); + QTest::newRow("tld-cookie-no-match") << allCookies << "http://a.support/" << result; } void tst_QNetworkCookieJar::cookiesForUrl() diff --git a/tests/auto/other/gestures/tst_gestures.cpp b/tests/auto/other/gestures/tst_gestures.cpp index d153146574..0767efb817 100644 --- a/tests/auto/other/gestures/tst_gestures.cpp +++ b/tests/auto/other/gestures/tst_gestures.cpp @@ -43,24 +43,6 @@ #include <qdebug.h> -static bool waitForWindowExposed(QWindow *window) -{ - if (!window) - return false; -#ifdef Q_OS_OSX - QTest::qWait(100); - return window->isExposed(); -#endif - return QTest::qWaitForWindowExposed(window); -} - -static bool waitForWindowExposed(QWidget *widget) -{ - if (!widget) - return false; - return waitForWindowExposed(widget->windowHandle()); -} - static QPointF mapToGlobal(const QPointF &pt, QGraphicsItem *item, QGraphicsView *view) { return view->viewport()->mapToGlobal(view->mapFromScene(item->mapToScene(pt))); @@ -376,7 +358,7 @@ void tst_Gestures::customGesture() GestureWidget widget; widget.grabGesture(CustomGesture::GestureType, Qt::DontStartGestureOnChildren); widget.show(); - QVERIFY(waitForWindowExposed(&widget)); + QVERIFY(QTest::qWaitForWindowExposed(&widget)); CustomEvent event; event.hotSpot = widget.mapToGlobal(QPoint(5,5)); @@ -845,7 +827,7 @@ void tst_Gestures::graphicsItemGesture() item->setPos(100, 100); view.show(); - QVERIFY(waitForWindowExposed(&view)); + QVERIFY(QTest::qWaitForWindowExposed(&view)); view.ensureVisible(scene.sceneRect()); item->grabGesture(CustomGesture::GestureType); @@ -907,7 +889,7 @@ void tst_Gestures::graphicsView() item->setPos(100, 100); view.show(); - QVERIFY(waitForWindowExposed(&view)); + QVERIFY(QTest::qWaitForWindowExposed(&view)); view.ensureVisible(scene.sceneRect()); item->grabGesture(CustomGesture::GestureType); @@ -983,7 +965,7 @@ void tst_Gestures::graphicsItemTreeGesture() item1_child2->setParentItem(item1); view.show(); - QVERIFY(waitForWindowExposed(&view)); + QVERIFY(QTest::qWaitForWindowExposed(&view)); view.ensureVisible(scene.sceneRect()); item1->grabGesture(CustomGesture::GestureType); @@ -1040,7 +1022,7 @@ void tst_Gestures::explicitGraphicsObjectTarget() item2_child1->setPos(10, 10); view.show(); - QVERIFY(waitForWindowExposed(&view)); + QVERIFY(QTest::qWaitForWindowExposed(&view)); view.ensureVisible(scene.sceneRect()); item1->grabGesture(CustomGesture::GestureType, Qt::DontStartGestureOnChildren); @@ -1099,7 +1081,7 @@ void tst_Gestures::gestureOverChildGraphicsItem() item2_child1->setPos(0, 0); view.show(); - QVERIFY(waitForWindowExposed(&view)); + QVERIFY(QTest::qWaitForWindowExposed(&view)); view.ensureVisible(scene.sceneRect()); item1->grabGesture(CustomGesture::GestureType); @@ -1397,7 +1379,7 @@ void tst_Gestures::testMapToScene() item0->setPos(14, 16); view.show(); // need to show to give it a global coordinate - QVERIFY(waitForWindowExposed(&view)); + QVERIFY(QTest::qWaitForWindowExposed(&view)); view.ensureVisible(scene.sceneRect()); QPoint origin = view.mapToGlobal(QPoint()); @@ -1523,7 +1505,7 @@ void tst_Gestures::autoCancelGestures() parent.grabGesture(CustomGesture::GestureType); child->grabGesture(secondGesture); parent.show(); - QVERIFY(waitForWindowExposed(&parent)); + QVERIFY(QTest::qWaitForWindowExposed(&parent)); /* An event is sent to both the child and the parent, when the child gets it a gesture is triggered @@ -1582,7 +1564,7 @@ void tst_Gestures::autoCancelGestures2() child->grabGesture(secondGesture); view.show(); - QVERIFY(waitForWindowExposed(&view)); + QVERIFY(QTest::qWaitForWindowExposed(&view)); view.ensureVisible(scene.sceneRect()); CustomEvent event; @@ -1628,7 +1610,7 @@ void tst_Gestures::graphicsViewParentPropagation() item1_c1_c1->setPos(0, 0); view.show(); - QVERIFY(waitForWindowExposed(&view)); + QVERIFY(QTest::qWaitForWindowExposed(&view)); view.ensureVisible(scene.sceneRect()); item0->grabGesture(CustomGesture::GestureType, Qt::ReceivePartialGestures | Qt::IgnoredGesturesPropagateToParent); @@ -1698,7 +1680,7 @@ void tst_Gestures::panelPropagation() item1_child1_child1->setZValue(10); view.show(); - QVERIFY(waitForWindowExposed(&view)); + QVERIFY(QTest::qWaitForWindowExposed(&view)); view.ensureVisible(scene.sceneRect()); static const int TotalGestureEventsCount = CustomGesture::SerialFinishedThreshold - CustomGesture::SerialStartedThreshold + 1; @@ -1809,7 +1791,7 @@ void tst_Gestures::panelStacksBehindParent() panel->setZValue(5); view.show(); - QVERIFY(waitForWindowExposed(&view)); + QVERIFY(QTest::qWaitForWindowExposed(&view)); view.ensureVisible(scene.sceneRect()); static const int TotalGestureEventsCount = CustomGesture::SerialFinishedThreshold - CustomGesture::SerialStartedThreshold + 1; @@ -1893,7 +1875,7 @@ void tst_Gestures::deleteGestureTargetItem() items.insert(item2->objectName(), item2); view.show(); - QVERIFY(waitForWindowExposed(&view)); + QVERIFY(QTest::qWaitForWindowExposed(&view)); view.ensureVisible(scene.sceneRect()); if (propagateUpdateGesture) @@ -1938,7 +1920,7 @@ void tst_Gestures::viewportCoordinates() scene.addItem(item1); view.show(); - QVERIFY(waitForWindowExposed(&view)); + QVERIFY(QTest::qWaitForWindowExposed(&view)); view.ensureVisible(scene.sceneRect()); CustomEvent event; @@ -1975,7 +1957,7 @@ void tst_Gestures::partialGesturePropagation() scene.addItem(item4); view.show(); - QVERIFY(waitForWindowExposed(&view)); + QVERIFY(QTest::qWaitForWindowExposed(&view)); view.ensureVisible(scene.sceneRect()); item1->ignoredUpdatedGestures << CustomGesture::GestureType; @@ -2063,7 +2045,7 @@ void tst_Gestures::testQGestureRecognizerCleanup() //QGestureRecognizer::registerRecognizer(new PanRecognizer(PanRecognizer::Custom)); w->show(); - QVERIFY(waitForWindowExposed(w)); + QVERIFY(QTest::qWaitForWindowExposed(w)); delete w; } @@ -2184,7 +2166,7 @@ void tst_Gestures::testReuseCanceledGestures() gv->viewport()->grabGesture(tapGestureTypeId); mw.show(); - QVERIFY(waitForWindowExposed(&mw)); + QVERIFY(QTest::qWaitForWindowExposed(&mw)); QPoint targetPos(gv->mapFromScene(target->mapToScene(target->rect().center()))); targetPos = gv->viewport()->mapFromParent(targetPos); @@ -2250,7 +2232,7 @@ void tst_Gestures::conflictingGesturesInGraphicsView() scene.addItem(item2); view.show(); - QVERIFY(waitForWindowExposed(&view)); + QVERIFY(QTest::qWaitForWindowExposed(&view)); view.ensureVisible(scene.sceneRect()); static const int TotalGestureEventsCount = CustomGesture::SerialFinishedThreshold - CustomGesture::SerialStartedThreshold + 1; @@ -2315,7 +2297,7 @@ void tst_Gestures::bug_13501_gesture_not_accepted() NoConsumeWidgetBug13501 w; w.grabGesture(Qt::TapGesture); w.show(); - QVERIFY(waitForWindowExposed(&w)); + QVERIFY(QTest::qWaitForWindowExposed(&w)); //QTest::mousePress(&ignoreEvent, Qt::LeftButton); QTouchDevice *device = QTest::createTouchDevice(); QTest::touchEvent(&w, device).press(0, QPoint(10, 10), &w); diff --git a/tests/auto/other/qfocusevent/tst_qfocusevent.cpp b/tests/auto/other/qfocusevent/tst_qfocusevent.cpp index 37521a64aa..e82327bbb1 100644 --- a/tests/auto/other/qfocusevent/tst_qfocusevent.cpp +++ b/tests/auto/other/qfocusevent/tst_qfocusevent.cpp @@ -304,6 +304,7 @@ void tst_QFocusEvent::checkReason_focusWidget() frame1.setLayout(&leftLayout); frame2.setLayout(&rightLayout); window1.show(); + QVERIFY(QTest::qWaitForWindowActive(&window1)); edit1.setFocus(); QTRY_VERIFY(edit1.hasFocus()); diff --git a/tests/auto/widgets/kernel/qwidget/tst_qwidget.cpp b/tests/auto/widgets/kernel/qwidget/tst_qwidget.cpp index e1c4019fba..ff2d8fd191 100644 --- a/tests/auto/widgets/kernel/qwidget/tst_qwidget.cpp +++ b/tests/auto/widgets/kernel/qwidget/tst_qwidget.cpp @@ -401,6 +401,8 @@ private slots: void tabletTracking(); + void closeEvent(); + private: bool ensureScreenSize(int width, int height); @@ -10808,5 +10810,31 @@ void tst_QWidget::tabletTracking() QTRY_COMPARE(widget.moveEventCount, 3); } +class CloseCountingWidget : public QWidget +{ +public: + int closeCount = 0; + void closeEvent(QCloseEvent *ev) override; +}; + +void CloseCountingWidget::closeEvent(QCloseEvent *ev) +{ + ++closeCount; + ev->accept(); +} + +void tst_QWidget::closeEvent() +{ + CloseCountingWidget widget; + widget.show(); + QVERIFY(QTest::qWaitForWindowExposed(&widget)); + // Yes we call the close() function twice. This mimics the behavior of QTBUG-43344 where + // QApplication first closes all windows and then QCocoaApplication flushes window system + // events, triggering more close events. + widget.windowHandle()->close(); + widget.windowHandle()->close(); + QCOMPARE(widget.closeCount, 1); +} + QTEST_MAIN(tst_QWidget) #include "tst_qwidget.moc" diff --git a/tests/auto/widgets/widgets/qlineedit/tst_qlineedit.cpp b/tests/auto/widgets/widgets/qlineedit/tst_qlineedit.cpp index 9da33d9525..7eb739611a 100644 --- a/tests/auto/widgets/widgets/qlineedit/tst_qlineedit.cpp +++ b/tests/auto/widgets/widgets/qlineedit/tst_qlineedit.cpp @@ -319,6 +319,7 @@ private: void psKeyClick(QWidget *target, Qt::Key key, Qt::KeyboardModifiers pressState = 0); void psKeyClick(QTestEventList &keys, Qt::Key key, Qt::KeyboardModifiers pressState = 0); bool unselectingWithLeftOrRightChangesCursorPosition(); + void addKeySequenceStandardKey(QTestEventList &keys, QKeySequence::StandardKey); QLineEdit *ensureTestWidget(); bool validInput; @@ -724,7 +725,7 @@ void tst_QLineEdit::keypress_inputMask_data() { QTestEventList keys; // inserting 'A1.2B' - keys.addKeyClick(Qt::Key_Home); + addKeySequenceStandardKey(keys, QKeySequence::MoveToStartOfLine); keys.addKeyClick(Qt::Key_A); keys.addKeyClick(Qt::Key_1); keys.addKeyClick(Qt::Key_Period); @@ -735,7 +736,7 @@ void tst_QLineEdit::keypress_inputMask_data() { QTestEventList keys; // inserting 'A1.2B' - keys.addKeyClick(Qt::Key_Home); + addKeySequenceStandardKey(keys, QKeySequence::MoveToStartOfLine); keys.addKeyClick(Qt::Key_0); keys.addKeyClick(Qt::Key_Exclam); keys.addKeyClick('P'); @@ -745,22 +746,24 @@ void tst_QLineEdit::keypress_inputMask_data() { QTestEventList keys; // pressing delete - keys.addKeyClick(Qt::Key_Home); + addKeySequenceStandardKey(keys, QKeySequence::MoveToStartOfLine); keys.addKeyClick(Qt::Key_Delete); QTest::newRow("delete") << QString("000.000;_") << keys << QString(".") << QString("___.___"); } { QTestEventList keys; // selecting all and delete - keys.addKeyClick(Qt::Key_Home); - keys.addKeyClick(Qt::Key_End, Qt::ShiftModifier); + keys.addKeyClick(Qt::Key_1); + keys.addKeyClick(Qt::Key_2); + addKeySequenceStandardKey(keys, QKeySequence::MoveToStartOfLine); + addKeySequenceStandardKey(keys, QKeySequence::SelectEndOfLine); keys.addKeyClick(Qt::Key_Delete); QTest::newRow("deleting all") << QString("000.000;_") << keys << QString(".") << QString("___.___"); } { QTestEventList keys; // inserting '12.12' then two backspaces - keys.addKeyClick(Qt::Key_Home); + addKeySequenceStandardKey(keys, QKeySequence::MoveToStartOfLine); keys.addKeyClick(Qt::Key_1); keys.addKeyClick(Qt::Key_2); keys.addKeyClick(Qt::Key_Period); @@ -773,7 +776,7 @@ void tst_QLineEdit::keypress_inputMask_data() { QTestEventList keys; // inserting '12ab' - keys.addKeyClick(Qt::Key_Home); + addKeySequenceStandardKey(keys, QKeySequence::MoveToStartOfLine); keys.addKeyClick(Qt::Key_1); keys.addKeyClick(Qt::Key_2); keys.addKeyClick(Qt::Key_A); @@ -1971,6 +1974,13 @@ void tst_QLineEdit::psKeyClick(QTestEventList &keys, Qt::Key key, Qt::KeyboardMo keys.addKeyClick(key, pressState); } +void tst_QLineEdit::addKeySequenceStandardKey(QTestEventList &keys, QKeySequence::StandardKey key) +{ + QKeySequence keyseq = QKeySequence(key); + for (int i = 0; i < keyseq.count(); ++i) + keys.addKeyClick( Qt::Key( keyseq[i] & ~Qt::KeyboardModifierMask), Qt::KeyboardModifier(keyseq[i] & Qt::KeyboardModifierMask) ); +} + void tst_QLineEdit::cursorPosition() { QLineEdit *testWidget = ensureTestWidget(); diff --git a/tests/auto/widgets/widgets/qtabwidget/tst_qtabwidget.cpp b/tests/auto/widgets/widgets/qtabwidget/tst_qtabwidget.cpp index cd7fe3710d..cbf5196bb9 100644 --- a/tests/auto/widgets/widgets/qtabwidget/tst_qtabwidget.cpp +++ b/tests/auto/widgets/widgets/qtabwidget/tst_qtabwidget.cpp @@ -549,7 +549,9 @@ void tst_QTabWidget::paintEventCount() QCOMPARE(tw->currentIndex(), 0); tw->show(); - QVERIFY(QTest::qWaitForWindowActive(tw)); + QVERIFY(QTest::qWaitForWindowExposed(tw)); + // Wait for extra paint events that happen at least on macOS + QTest::qWait(1000); // Mac, Windows and Windows CE get multiple repaints on the first show, so use those as a starting point. static const int MaxInitialPaintCount = diff --git a/tests/manual/touch/main.cpp b/tests/manual/touch/main.cpp index d3c6079c7d..9f2dcb3842 100644 --- a/tests/manual/touch/main.cpp +++ b/tests/manual/touch/main.cpp @@ -47,8 +47,8 @@ #include <QDebug> #include <QTextStream> -bool optIgnoreTouch = false; -QVector<Qt::GestureType> optGestures; +static bool optIgnoreTouch = false; +static QVector<Qt::GestureType> optGestures; static inline void drawEllipse(const QPointF ¢er, qreal hDiameter, qreal vDiameter, const QColor &color, QPainter &painter) { @@ -275,10 +275,10 @@ class TouchTestWidget : public QWidget { Q_OBJECT Q_PROPERTY(bool drawPoints READ drawPoints WRITE setDrawPoints) public: - explicit TouchTestWidget(QWidget *parent = 0) : QWidget(parent), m_drawPoints(true) + explicit TouchTestWidget(QWidget *parent = nullptr) : QWidget(parent), m_drawPoints(true) { setAttribute(Qt::WA_AcceptTouchEvents); - foreach (Qt::GestureType t, optGestures) + for (Qt::GestureType t : optGestures) grabGesture(t); } @@ -337,10 +337,11 @@ bool TouchTestWidget::event(QEvent *event) case QEvent::TouchBegin: case QEvent::TouchUpdate: if (m_drawPoints) { - foreach (const QTouchEvent::TouchPoint &p, static_cast<const QTouchEvent *>(event)->touchPoints()) + for (const QTouchEvent::TouchPoint &p : static_cast<const QTouchEvent *>(event)->touchPoints()) m_points.append(Point(p.pos(), TouchPoint, Qt::MouseEventNotSynthesized, p.ellipseDiameters())); update(); } + Q_FALLTHROUGH(); case QEvent::TouchEnd: if (optIgnoreTouch) event->ignore(); @@ -358,7 +359,8 @@ bool TouchTestWidget::event(QEvent *event) void TouchTestWidget::handleGestureEvent(QGestureEvent *gestureEvent) { - foreach (QGesture *gesture, gestureEvent->gestures()) { + const auto gestures = gestureEvent->gestures(); + for (QGesture *gesture : gestures) { if (optGestures.contains(gesture->gestureType())) { switch (gesture->state()) { case Qt::NoGesture: @@ -389,7 +391,7 @@ void TouchTestWidget::paintEvent(QPaintEvent *) const QRectF geom = QRectF(QPointF(0, 0), QSizeF(size())); painter.fillRect(geom, Qt::white); painter.drawRect(QRectF(geom.topLeft(), geom.bottomRight() - QPointF(1, 1))); - foreach (const Point &point, m_points) { + for (const Point &point : qAsConst(m_points)) { if (geom.contains(point.pos)) { if (point.type == MouseRelease) drawEllipse(point.pos, point.horizontalDiameter, point.verticalDiameter, point.color(), painter); @@ -397,7 +399,7 @@ void TouchTestWidget::paintEvent(QPaintEvent *) fillEllipse(point.pos, point.horizontalDiameter, point.verticalDiameter, point.color(), painter); } } - foreach (const GesturePtr &gp, m_gestures) + for (const GesturePtr &gp : qAsConst(m_gestures)) gp->draw(geom, painter); } @@ -429,24 +431,24 @@ MainWindow::MainWindow() QMenu *fileMenu = menuBar()->addMenu("File"); QAction *dumpDeviceAction = fileMenu->addAction(QStringLiteral("Dump devices")); dumpDeviceAction->setShortcut(QKeySequence(Qt::CTRL + Qt::Key_D)); - connect(dumpDeviceAction, SIGNAL(triggered()), this, SLOT(dumpTouchDevices())); + connect(dumpDeviceAction, &QAction::triggered, this, &MainWindow::dumpTouchDevices); toolBar->addAction(dumpDeviceAction); QAction *clearLogAction = fileMenu->addAction(QStringLiteral("Clear Log")); clearLogAction->setShortcut(QKeySequence(Qt::CTRL + Qt::Key_L)); - connect(clearLogAction, SIGNAL(triggered()), m_logTextEdit, SLOT(clear())); + connect(clearLogAction, &QAction::triggered, m_logTextEdit, &QPlainTextEdit::clear); toolBar->addAction(clearLogAction); QAction *toggleDrawPointAction = fileMenu->addAction(QStringLiteral("Draw Points")); toggleDrawPointAction->setCheckable(true); toggleDrawPointAction->setChecked(m_touchWidget->drawPoints()); - connect(toggleDrawPointAction, SIGNAL(toggled(bool)), m_touchWidget, SLOT(setDrawPoints(bool))); + connect(toggleDrawPointAction, &QAction::toggled, m_touchWidget, &TouchTestWidget::setDrawPoints); toolBar->addAction(toggleDrawPointAction); QAction *clearPointAction = fileMenu->addAction(QStringLiteral("Clear Points")); clearPointAction->setShortcut(QKeySequence(Qt::CTRL + Qt::Key_P)); - connect(clearPointAction, SIGNAL(triggered()), m_touchWidget, SLOT(clearPoints())); + connect(clearPointAction, &QAction::triggered, m_touchWidget, &TouchTestWidget::clearPoints); toolBar->addAction(clearPointAction); QAction *quitAction = fileMenu->addAction(QStringLiteral("Quit")); quitAction->setShortcut(QKeySequence(Qt::CTRL + Qt::Key_Q)); - connect(quitAction, SIGNAL(triggered()), this, SLOT(close())); + connect(quitAction, &QAction::triggered, qApp, &QCoreApplication::quit); toolBar->addAction(quitAction); QSplitter *mainSplitter = new QSplitter(Qt::Vertical, this); @@ -541,7 +543,7 @@ int main(int argc, char *argv[]) : static_cast<QObject *>(w.touchWidget()); EventFilter *filter = new EventFilter(eventTypes, filterTarget); filterTarget->installEventFilter(filter); - QObject::connect(filter, SIGNAL(eventReceived(QString)), &w, SLOT(appendToLog(QString))); + QObject::connect(filter, &EventFilter::eventReceived, &w, &MainWindow::appendToLog); return a.exec(); } diff --git a/tests/shared/emulationdetector.h b/tests/shared/emulationdetector.h index cca11be695..2b04a1061e 100644 --- a/tests/shared/emulationdetector.h +++ b/tests/shared/emulationdetector.h @@ -29,6 +29,8 @@ #ifndef EMULATIONDETECTOR_H #define EMULATIONDETECTOR_H +#include <QtCore/qglobal.h> + #if defined(Q_OS_LINUX) && defined(Q_PROCESSOR_ARM) #define SHOULD_CHECK_ARM_ON_X86 |