diff options
Diffstat (limited to 'tests/auto/widgets/widgets')
31 files changed, 259 insertions, 119 deletions
diff --git a/tests/auto/widgets/widgets/qabstractscrollarea/tst_qabstractscrollarea.cpp b/tests/auto/widgets/widgets/qabstractscrollarea/tst_qabstractscrollarea.cpp index 007825d39c..a17a9f6c33 100644 --- a/tests/auto/widgets/widgets/qabstractscrollarea/tst_qabstractscrollarea.cpp +++ b/tests/auto/widgets/widgets/qabstractscrollarea/tst_qabstractscrollarea.cpp @@ -124,13 +124,19 @@ void tst_QAbstractScrollArea::scrollBarWidgets() QCOMPARE(area.scrollBarWidgets(Qt::AlignTop), QWidgetList()); QCOMPARE(area.scrollBarWidgets(Qt::AlignBottom), w2List); + auto sort = [](const QWidgetList l) { + QWidgetList list = l; + std::sort(list.begin(), list.end()); + return list; + }; + // two widgets at Bottom. area.addScrollBarWidget(w3, Qt::AlignBottom); - QCOMPARE(area.scrollBarWidgets(all).toSet(), allList.toSet()); + QCOMPARE(sort(area.scrollBarWidgets(all)), sort(allList)); QCOMPARE(area.scrollBarWidgets(Qt::AlignLeft), w1List); QCOMPARE(area.scrollBarWidgets(Qt::AlignRight), QWidgetList()); QCOMPARE(area.scrollBarWidgets(Qt::AlignTop), QWidgetList()); - QCOMPARE(area.scrollBarWidgets(Qt::AlignBottom).toSet(), (w2List + w3List).toSet()); + QCOMPARE(sort(area.scrollBarWidgets(Qt::AlignBottom)), sort(w2List + w3List)); //delete delete w1; diff --git a/tests/auto/widgets/widgets/qabstractslider/tst_qabstractslider.cpp b/tests/auto/widgets/widgets/qabstractslider/tst_qabstractslider.cpp index 1a0d7a9289..f77efe036a 100644 --- a/tests/auto/widgets/widgets/qabstractslider/tst_qabstractslider.cpp +++ b/tests/auto/widgets/widgets/qabstractslider/tst_qabstractslider.cpp @@ -33,7 +33,7 @@ #include <QSlider> #include <QStyle> #include <QStyleOption> -#include <QTime> +#include <QElapsedTimer> #include <QDebug> #include <QtTest/private/qtesthelpers_p.h> @@ -91,7 +91,7 @@ private slots: void connectedSliders(); private: - void waitUntilTimeElapsed(const QTime& t, int ms); + void waitUntilTimeElapsed(const QElapsedTimer &t, int ms); QWidget *topLevel; Slider *slider; @@ -1662,8 +1662,12 @@ void tst_QAbstractSlider::wheelEvent() slider->setOrientation(sliderOrientation); Qt::KeyboardModifier k = withModifiers ? Qt::ControlModifier : Qt::NoModifier; - QWheelEvent event(slider->rect().bottomRight() + distanceFromBottomRight, WHEEL_DELTA * deltaMultiple, - Qt::NoButton, k, wheelOrientation); + + const QPoint wheelPoint = slider->rect().bottomRight() + distanceFromBottomRight; + const QPoint angleDelta(wheelOrientation == Qt::Horizontal ? WHEEL_DELTA * deltaMultiple : 0, + wheelOrientation == Qt::Vertical ? WHEEL_DELTA * deltaMultiple : 0); + QWheelEvent event(wheelPoint, slider->mapToGlobal(wheelPoint), QPoint(), angleDelta, + Qt::NoButton, k, Qt::NoScrollPhase, false); QVERIFY(applicationInstance->sendEvent(slider,&event)); #ifdef Q_OS_MAC QEXPECT_FAIL("Normal data page", "QTBUG-23679", Continue); @@ -1674,8 +1678,8 @@ void tst_QAbstractSlider::wheelEvent() slider->setSliderPosition(initialSliderPosition); k = withModifiers ? Qt::ShiftModifier : Qt::NoModifier; - event = QWheelEvent(slider->rect().bottomRight() + distanceFromBottomRight, WHEEL_DELTA * deltaMultiple, - Qt::NoButton, k, wheelOrientation); + event = QWheelEvent(wheelPoint, slider->mapToGlobal(wheelPoint), QPoint(), angleDelta, + Qt::NoButton, k, Qt::NoScrollPhase, false); QSignalSpy spy1(slider, SIGNAL(actionTriggered(int))); QSignalSpy spy2(slider, SIGNAL(valueChanged(int))); QVERIFY(applicationInstance->sendEvent(slider,&event)); @@ -1715,16 +1719,16 @@ void tst_QAbstractSlider::fineGrainedWheelEvent() slider->setSliderPosition(0); const int singleStepDelta = invertedControls ? (-WHEEL_DELTA / 3) : (WHEEL_DELTA / 3); - - QWheelEvent eventDown(slider->rect().bottomRight(), singleStepDelta / 2, - Qt::NoButton, Qt::NoModifier, Qt::Vertical); + const QPoint wheelPoint = slider->rect().bottomRight(); + QWheelEvent eventDown(wheelPoint, slider->mapToGlobal(wheelPoint), QPoint(), QPoint(0, singleStepDelta / 2), + Qt::NoButton, Qt::NoModifier, Qt::NoScrollPhase, false); QVERIFY(applicationInstance->sendEvent(slider,&eventDown)); QCOMPARE(slider->sliderPosition(), 0); QVERIFY(applicationInstance->sendEvent(slider,&eventDown)); QCOMPARE(slider->sliderPosition(), 1); - QWheelEvent eventUp(slider->rect().bottomRight(), -singleStepDelta / 2, - Qt::NoButton, Qt::NoModifier, Qt::Vertical); + QWheelEvent eventUp(wheelPoint, slider->mapToGlobal(wheelPoint), QPoint(), QPoint(0, -singleStepDelta / 2), + Qt::NoButton, Qt::NoModifier, Qt::NoScrollPhase, false); QVERIFY(applicationInstance->sendEvent(slider,&eventUp)); QCOMPARE(slider->sliderPosition(), 1); QVERIFY(applicationInstance->sendEvent(slider,&eventUp)); @@ -2053,11 +2057,11 @@ void tst_QAbstractSlider::setValue() QVERIFY(sliderMovedTimeStamp < valueChangedTimeStamp); } -void tst_QAbstractSlider::waitUntilTimeElapsed(const QTime& t, int ms) +void tst_QAbstractSlider::waitUntilTimeElapsed(const QElapsedTimer &t, int ms) { const int eps = 80; while (t.elapsed() < ms + eps) - QTest::qWait(qMax(ms - t.elapsed() + eps, 25)); + QTest::qWait(qMax(int(ms - t.elapsed() + eps), 25)); } void tst_QAbstractSlider::setRepeatAction() @@ -2073,7 +2077,7 @@ void tst_QAbstractSlider::setRepeatAction() QCOMPARE(spy.count(), 0); QCOMPARE(slider->value(), 55); - QTime t; + QElapsedTimer t; t.start(); QTest::qWait(300); QCOMPARE(spy.count(), 0); diff --git a/tests/auto/widgets/widgets/qcombobox/tst_qcombobox.cpp b/tests/auto/widgets/widgets/qcombobox/tst_qcombobox.cpp index a576770811..8a46211714 100644 --- a/tests/auto/widgets/widgets/qcombobox/tst_qcombobox.cpp +++ b/tests/auto/widgets/widgets/qcombobox/tst_qcombobox.cpp @@ -2102,7 +2102,9 @@ void tst_QComboBox::mouseWheel() box.setEditable(i==0?false:true); box.setCurrentIndex(startIndex); - QWheelEvent event = QWheelEvent(box.rect().bottomRight() , WHEEL_DELTA * wheelDirection, Qt::NoButton, Qt::NoModifier); + const QPoint wheelPoint = box.rect().bottomRight(); + QWheelEvent event(wheelPoint, box.mapToGlobal(wheelPoint), QPoint(), QPoint(0, WHEEL_DELTA * wheelDirection), + Qt::NoButton, Qt::NoModifier, Qt::NoScrollPhase, false); QVERIFY(applicationInstance->sendEvent(&box,&event)); QCOMPARE(box.currentIndex(), expectedIndex); @@ -2131,7 +2133,9 @@ void tst_QComboBox::popupWheelHandling() comboBox->showPopup(); QTRY_VERIFY(comboBox->view() && comboBox->view()->isVisible()); const QPoint popupPos = comboBox->view()->pos(); - QWheelEvent event(QPointF(10, 10), WHEEL_DELTA, Qt::NoButton, Qt::NoModifier); + const QPoint wheelPoint(10, 10); + QWheelEvent event(wheelPoint, scrollArea.mapToGlobal(wheelPoint), QPoint(), QPoint(0, WHEEL_DELTA), + Qt::NoButton, Qt::NoModifier, Qt::NoScrollPhase, false); QVERIFY(QCoreApplication::sendEvent(scrollArea.windowHandle(), &event)); QCoreApplication::processEvents(); QVERIFY(comboBox->view()->isVisible()); diff --git a/tests/auto/widgets/widgets/qdatetimeedit/tst_qdatetimeedit.cpp b/tests/auto/widgets/widgets/qdatetimeedit/tst_qdatetimeedit.cpp index b5ef454b14..810f081b73 100644 --- a/tests/auto/widgets/widgets/qdatetimeedit/tst_qdatetimeedit.cpp +++ b/tests/auto/widgets/widgets/qdatetimeedit/tst_qdatetimeedit.cpp @@ -307,19 +307,19 @@ static QLatin1String modifierToName(Qt::KeyboardModifier modifier) { switch (modifier) { case Qt::NoModifier: - return QLatin1Literal("No"); + return QLatin1String("No"); break; case Qt::ControlModifier: - return QLatin1Literal("Ctrl"); + return QLatin1String("Ctrl"); break; case Qt::ShiftModifier: - return QLatin1Literal("Shift"); + return QLatin1String("Shift"); break; case Qt::AltModifier: - return QLatin1Literal("Alt"); + return QLatin1String("Alt"); break; case Qt::MetaModifier: - return QLatin1Literal("Meta"); + return QLatin1String("Meta"); break; default: qFatal("Unexpected keyboard modifier"); @@ -331,17 +331,17 @@ static QLatin1String sectionToName(const QDateTimeEdit::Section section) { switch (section) { case QDateTimeEdit::SecondSection: - return QLatin1Literal("Second"); + return QLatin1String("Second"); case QDateTimeEdit::MinuteSection: - return QLatin1Literal("Minute"); + return QLatin1String("Minute"); case QDateTimeEdit::HourSection: - return QLatin1Literal("Hours"); + return QLatin1String("Hours"); case QDateTimeEdit::DaySection: - return QLatin1Literal("Day"); + return QLatin1String("Day"); case QDateTimeEdit::MonthSection: - return QLatin1Literal("Month"); + return QLatin1String("Month"); case QDateTimeEdit::YearSection: - return QLatin1Literal("Year"); + return QLatin1String("Year"); default: qFatal("Unexpected section"); return QLatin1String(); @@ -3141,7 +3141,6 @@ void tst_QDateTimeEdit::wheelEvent_data() { #if QT_CONFIG(wheelevent) QTest::addColumn<QPoint>("angleDelta"); - QTest::addColumn<int>("qt4Delta"); QTest::addColumn<int>("stepModifier"); QTest::addColumn<Qt::KeyboardModifiers>("modifiers"); QTest::addColumn<Qt::MouseEventSource>("source"); @@ -3217,16 +3216,16 @@ void tst_QDateTimeEdit::wheelEvent_data() QLatin1String sourceName; switch (source) { case Qt::MouseEventNotSynthesized: - sourceName = QLatin1Literal("NotSynthesized"); + sourceName = QLatin1String("NotSynthesized"); break; case Qt::MouseEventSynthesizedBySystem: - sourceName = QLatin1Literal("SynthesizedBySystem"); + sourceName = QLatin1String("SynthesizedBySystem"); break; case Qt::MouseEventSynthesizedByQt: - sourceName = QLatin1Literal("SynthesizedByQt"); + sourceName = QLatin1String("SynthesizedByQt"); break; case Qt::MouseEventSynthesizedByApplication: - sourceName = QLatin1Literal("SynthesizedByApplication"); + sourceName = QLatin1String("SynthesizedByApplication"); break; default: qFatal("Unexpected wheel event source"); @@ -3255,7 +3254,6 @@ void tst_QDateTimeEdit::wheelEvent_data() modifierName.latin1(), sourceName.latin1()) << angleDelta - << units << static_cast<int>(stepModifier) << modifiers << source @@ -3277,7 +3275,6 @@ void tst_QDateTimeEdit::wheelEvent() { #if QT_CONFIG(wheelevent) QFETCH(QPoint, angleDelta); - QFETCH(int, qt4Delta); QFETCH(int, stepModifier); QFETCH(Qt::KeyboardModifiers, modifiers); QFETCH(Qt::MouseEventSource, source); @@ -3294,9 +3291,8 @@ void tst_QDateTimeEdit::wheelEvent() style->stepModifier = static_cast<Qt::KeyboardModifier>(stepModifier); edit.setStyle(style.data()); - QWheelEvent event(QPointF(), QPointF(), QPoint(), angleDelta, qt4Delta, - Qt::Vertical, Qt::NoButton, modifiers, Qt::NoScrollPhase, - source); + QWheelEvent event(QPointF(), QPointF(), QPoint(), angleDelta, + Qt::NoButton, modifiers, Qt::NoScrollPhase, false, source); QCOMPARE(edit.date(), startDate); for (QDate expected : expectedDates) { @@ -3454,7 +3450,7 @@ void tst_QDateTimeEdit::timeSpec() } QVERIFY(edit.minimumTime() != min.time()); QVERIFY(edit.minimumDateTime().timeSpec() != min.timeSpec()); - QCOMPARE(edit.minimumDateTime().toTime_t(), min.toTime_t()); + QCOMPARE(edit.minimumDateTime().toSecsSinceEpoch(), min.toSecsSinceEpoch()); } else { QSKIP("Not tested in the GMT timezone"); } diff --git a/tests/auto/widgets/widgets/qdockwidget/tst_qdockwidget.cpp b/tests/auto/widgets/widgets/qdockwidget/tst_qdockwidget.cpp index f8ce6a2c0a..625116654d 100644 --- a/tests/auto/widgets/widgets/qdockwidget/tst_qdockwidget.cpp +++ b/tests/auto/widgets/widgets/qdockwidget/tst_qdockwidget.cpp @@ -670,7 +670,11 @@ void tst_QDockWidget::dockLocationChanged() spy.clear(); dw.setFloating(true); - QTest::qWait(100); + QTRY_COMPARE(spy.count(), 1); + QCOMPARE(qvariant_cast<Qt::DockWidgetArea>(spy.at(0).at(0)), + Qt::NoDockWidgetArea); + spy.clear(); + dw.setFloating(false); QTRY_COMPARE(spy.count(), 1); QCOMPARE(qvariant_cast<Qt::DockWidgetArea>(spy.at(0).at(0)), diff --git a/tests/auto/widgets/widgets/qdoublespinbox/BLACKLIST b/tests/auto/widgets/widgets/qdoublespinbox/BLACKLIST index c1b6c9693e..8f5648d0f9 100644 --- a/tests/auto/widgets/widgets/qdoublespinbox/BLACKLIST +++ b/tests/auto/widgets/widgets/qdoublespinbox/BLACKLIST @@ -1,2 +1,4 @@ [editingFinished] -* +osx-10.12 +osx-10.14 +osx-10.13 diff --git a/tests/auto/widgets/widgets/qdoublespinbox/tst_qdoublespinbox.cpp b/tests/auto/widgets/widgets/qdoublespinbox/tst_qdoublespinbox.cpp index 954ee6471d..c760d9cc99 100644 --- a/tests/auto/widgets/widgets/qdoublespinbox/tst_qdoublespinbox.cpp +++ b/tests/auto/widgets/widgets/qdoublespinbox/tst_qdoublespinbox.cpp @@ -221,19 +221,19 @@ static QLatin1String modifierToName(Qt::KeyboardModifier modifier) { switch (modifier) { case Qt::NoModifier: - return QLatin1Literal("No"); + return QLatin1String("No"); break; case Qt::ControlModifier: - return QLatin1Literal("Ctrl"); + return QLatin1String("Ctrl"); break; case Qt::ShiftModifier: - return QLatin1Literal("Shift"); + return QLatin1String("Shift"); break; case Qt::AltModifier: - return QLatin1Literal("Alt"); + return QLatin1String("Alt"); break; case Qt::MetaModifier: - return QLatin1Literal("Meta"); + return QLatin1String("Meta"); break; default: qFatal("Unexpected keyboard modifier"); @@ -1377,7 +1377,6 @@ void tst_QDoubleSpinBox::wheelEvents_data() { #if QT_CONFIG(wheelevent) QTest::addColumn<QPoint>("angleDelta"); - QTest::addColumn<int>("qt4Delta"); QTest::addColumn<int>("stepModifier"); QTest::addColumn<Qt::KeyboardModifiers>("modifier"); QTest::addColumn<Qt::MouseEventSource>("source"); @@ -1448,16 +1447,16 @@ void tst_QDoubleSpinBox::wheelEvents_data() QLatin1String sourceName; switch (source) { case Qt::MouseEventNotSynthesized: - sourceName = QLatin1Literal("NotSynthesized"); + sourceName = QLatin1String("NotSynthesized"); break; case Qt::MouseEventSynthesizedBySystem: - sourceName = QLatin1Literal("SynthesizedBySystem"); + sourceName = QLatin1String("SynthesizedBySystem"); break; case Qt::MouseEventSynthesizedByQt: - sourceName = QLatin1Literal("SynthesizedByQt"); + sourceName = QLatin1String("SynthesizedByQt"); break; case Qt::MouseEventSynthesizedByApplication: - sourceName = QLatin1Literal("SynthesizedByApplication"); + sourceName = QLatin1String("SynthesizedByApplication"); break; default: qFatal("Unexpected wheel event source"); @@ -1476,7 +1475,6 @@ void tst_QDoubleSpinBox::wheelEvents_data() modifierName.latin1(), sourceName.latin1()) << angleDelta - << units << static_cast<int>(stepModifier) << modifiers << source @@ -1496,7 +1494,6 @@ void tst_QDoubleSpinBox::wheelEvents() { #if QT_CONFIG(wheelevent) QFETCH(QPoint, angleDelta); - QFETCH(int, qt4Delta); QFETCH(int, stepModifier); QFETCH(Qt::KeyboardModifiers, modifier); QFETCH(Qt::MouseEventSource, source); @@ -1512,9 +1509,8 @@ void tst_QDoubleSpinBox::wheelEvents() style->stepModifier = static_cast<Qt::KeyboardModifier>(stepModifier); spinBox.setStyle(style.data()); - QWheelEvent event(QPointF(), QPointF(), QPoint(), angleDelta, qt4Delta, - Qt::Vertical, Qt::NoButton, modifier, Qt::NoScrollPhase, - source); + QWheelEvent event(QPointF(), QPointF(), QPoint(), angleDelta, + Qt::NoButton, modifier, Qt::NoScrollPhase, false, source); for (int expected : expectedValues) { qApp->sendEvent(&spinBox, &event); QCOMPARE(spinBox.value(), expected); diff --git a/tests/auto/widgets/widgets/qfontcombobox/tst_qfontcombobox.cpp b/tests/auto/widgets/widgets/qfontcombobox/tst_qfontcombobox.cpp index 1813e5ad5f..5392d36ae0 100644 --- a/tests/auto/widgets/widgets/qfontcombobox/tst_qfontcombobox.cpp +++ b/tests/auto/widgets/widgets/qfontcombobox/tst_qfontcombobox.cpp @@ -108,7 +108,7 @@ void tst_QFontComboBox::currentFont() QFont oldCurrentFont = box.currentFont(); box.setCurrentFont(currentFont); - QRegExp foundry(" \\[.*\\]"); + QRegularExpression foundry(" \\[.*\\]"); if (!box.currentFont().family().contains(foundry)) { QCOMPARE(box.currentFont(), currentFont); } diff --git a/tests/auto/widgets/widgets/qlineedit/tst_qlineedit.cpp b/tests/auto/widgets/widgets/qlineedit/tst_qlineedit.cpp index 95799905de..f1bc3e8dd4 100644 --- a/tests/auto/widgets/widgets/qlineedit/tst_qlineedit.cpp +++ b/tests/auto/widgets/widgets/qlineedit/tst_qlineedit.cpp @@ -3615,6 +3615,14 @@ void tst_QLineEdit::task174640_editingFinished() le2->setFocus(); QTRY_VERIFY(le2->hasFocus()); + // editingFinished will not be emitted anew because no editing happened + QCOMPARE(editingFinishedSpy.count(), 0); + + le1->setFocus(); + QTRY_VERIFY(le1->hasFocus()); + QTest::keyPress(le1, Qt::Key_Plus); + le2->setFocus(); + QTRY_VERIFY(le2->hasFocus()); QCOMPARE(editingFinishedSpy.count(), 1); editingFinishedSpy.clear(); @@ -3632,6 +3640,8 @@ void tst_QLineEdit::task174640_editingFinished() delete testMenu1; QCOMPARE(editingFinishedSpy.count(), 0); QTRY_VERIFY(le1->hasFocus()); + // Ensure le1 has been edited + QTest::keyPress(le1, Qt::Key_Plus); QMenu *testMenu2 = new QMenu(le2); testMenu2->addAction("foo2"); @@ -3986,7 +3996,7 @@ void tst_QLineEdit::QTBUG7174_inputMaskCursorBlink() edit.setFocus(); edit.setText(QLatin1String("AAAA")); edit.show(); - QRect cursorRect = edit.inputMethodQuery(Qt::ImMicroFocus).toRect(); + QRect cursorRect = edit.inputMethodQuery(Qt::ImCursorRectangle).toRect(); QVERIFY(QTest::qWaitForWindowExposed(&edit)); edit.updateRegion = QRegion(); QTest::qWait(QApplication::cursorFlashTime()); diff --git a/tests/auto/widgets/widgets/qmdiarea/BLACKLIST b/tests/auto/widgets/widgets/qmdiarea/BLACKLIST index b1c8d7dfde..1dd876ea97 100644 --- a/tests/auto/widgets/widgets/qmdiarea/BLACKLIST +++ b/tests/auto/widgets/widgets/qmdiarea/BLACKLIST @@ -1,7 +1,16 @@ -[updateScrollBars] -osx [tileSubWindows] -osx -xcb +ubuntu-16.04 +rhel-7.6 +opensuse-leap +osx-10.11 +osx-10.13 +ubuntu-18.04 +osx-10.14 +rhel-7.4 +osx-10.12 +opensuse-42.3 [resizeTimer] -osx +osx-10.12 +osx-10.14 +osx-10.13 + diff --git a/tests/auto/widgets/widgets/qmdiarea/tst_qmdiarea.cpp b/tests/auto/widgets/widgets/qmdiarea/tst_qmdiarea.cpp index 67b79e3faf..046899ce05 100644 --- a/tests/auto/widgets/widgets/qmdiarea/tst_qmdiarea.cpp +++ b/tests/auto/widgets/widgets/qmdiarea/tst_qmdiarea.cpp @@ -333,6 +333,7 @@ void tst_QMdiArea::subWindowActivated() for ( i = 0; i < count; ++i ) { QWidget *widget = new QWidget(workspace, 0); widget->setAttribute(Qt::WA_DeleteOnClose); + widget->setFocus(); workspace->addSubWindow(widget)->show(); widget->show(); qApp->processEvents(); diff --git a/tests/auto/widgets/widgets/qmdisubwindow/BLACKLIST b/tests/auto/widgets/widgets/qmdisubwindow/BLACKLIST deleted file mode 100644 index 26d1776b0d..0000000000 --- a/tests/auto/widgets/widgets/qmdisubwindow/BLACKLIST +++ /dev/null @@ -1,2 +0,0 @@ -[setOpaqueResizeAndMove] -osx-10.12 diff --git a/tests/auto/widgets/widgets/qmenu/BLACKLIST b/tests/auto/widgets/widgets/qmenu/BLACKLIST index bac14ea225..ad6d2f340c 100644 --- a/tests/auto/widgets/widgets/qmenu/BLACKLIST +++ b/tests/auto/widgets/widgets/qmenu/BLACKLIST @@ -1,13 +1,13 @@ [task258920_mouseBorder] -osx -[submenuTearOffDontClose] -osx-10.12 ci +osx-10.14 +osx-10.13 [layoutDirection] +osx-10.12 +osx-10.13 # Fails when enabling synchronous expose events QTBUG-62092 -osx ci [pushButtonPopulateOnAboutToShow] -osx +osx-10.13 [tearOff] -osx +osx-10.14 [activeSubMenuPosition] winrt diff --git a/tests/auto/widgets/widgets/qmenubar/BLACKLIST b/tests/auto/widgets/widgets/qmenubar/BLACKLIST index f897797f00..c9e15e531c 100644 --- a/tests/auto/widgets/widgets/qmenubar/BLACKLIST +++ b/tests/auto/widgets/widgets/qmenubar/BLACKLIST @@ -3,6 +3,6 @@ ubuntu-16.04 #QTBUG-66255 ubuntu-18.04 [activatedCount] -* +opensuse-42.3 [QTBUG_65488_hiddenActionTriggered] winrt diff --git a/tests/auto/widgets/widgets/qmenubar/tst_qmenubar.cpp b/tests/auto/widgets/widgets/qmenubar/tst_qmenubar.cpp index cb829c81a6..d6ba85d61f 100644 --- a/tests/auto/widgets/widgets/qmenubar/tst_qmenubar.cpp +++ b/tests/auto/widgets/widgets/qmenubar/tst_qmenubar.cpp @@ -113,10 +113,7 @@ private slots: void check_escKey(); #endif -#ifndef Q_OS_WINCE void allowActiveAndDisabled(); -#endif - void taskQTBUG56860_focus(); void check_endKey(); void check_homeKey(); diff --git a/tests/auto/widgets/widgets/qopenglwidget/BLACKLIST b/tests/auto/widgets/widgets/qopenglwidget/BLACKLIST index b67c8354e8..b281eca3bf 100644 --- a/tests/auto/widgets/widgets/qopenglwidget/BLACKLIST +++ b/tests/auto/widgets/widgets/qopenglwidget/BLACKLIST @@ -1,5 +1,3 @@ -[clearAndGrab] -ubuntu - [stackWidgetOpaqueChildIsVisible] -windows +windows-10 msvc-2017 + diff --git a/tests/auto/widgets/widgets/qprogressbar/tst_qprogressbar.cpp b/tests/auto/widgets/widgets/qprogressbar/tst_qprogressbar.cpp index df5ff9d448..3408fc0946 100644 --- a/tests/auto/widgets/widgets/qprogressbar/tst_qprogressbar.cpp +++ b/tests/auto/widgets/widgets/qprogressbar/tst_qprogressbar.cpp @@ -174,7 +174,7 @@ void tst_QProgressBar::format() #ifndef Q_OS_MAC // Animated scroll bars get paint events all the time #ifdef Q_OS_WIN - if (QSysInfo::WindowsVersion < QSysInfo::WV_VISTA) + if (QOperatingSystemVersion::current() < QOperatingSystemVersion::WindowsVista) #endif QVERIFY(!bar.repainted); #endif diff --git a/tests/auto/widgets/widgets/qscrollarea/tst_qscrollarea.cpp b/tests/auto/widgets/widgets/qscrollarea/tst_qscrollarea.cpp index d1923e4bb0..9f08bd337b 100644 --- a/tests/auto/widgets/widgets/qscrollarea/tst_qscrollarea.cpp +++ b/tests/auto/widgets/widgets/qscrollarea/tst_qscrollarea.cpp @@ -87,7 +87,7 @@ public: protected: QVariant inputMethodQuery(Qt::InputMethodQuery query) const { - if (query == Qt::ImMicroFocus) + if (query == Qt::ImCursorRectangle) return QRect(width() / 2, height() / 2, 5, 5); return QWidget::inputMethodQuery(query); } @@ -110,7 +110,7 @@ void tst_QScrollArea::ensureMicroFocusVisible_Task_167838() parent->resize(300, 300); scrollArea.setWidget(parent); scrollArea.ensureWidgetVisible(child, 10, 10); - QRect microFocus = child->inputMethodQuery(Qt::ImMicroFocus).toRect(); + QRect microFocus = child->inputMethodQuery(Qt::ImCursorRectangle).toRect(); QPoint p = child->mapTo(scrollArea.viewport(), microFocus.topLeft()); microFocus.translate(p - microFocus.topLeft()); QVERIFY(scrollArea.viewport()->rect().contains(microFocus)); diff --git a/tests/auto/widgets/widgets/qscrollbar/BLACKLIST b/tests/auto/widgets/widgets/qscrollbar/BLACKLIST deleted file mode 100644 index 277ae4d260..0000000000 --- a/tests/auto/widgets/widgets/qscrollbar/BLACKLIST +++ /dev/null @@ -1,3 +0,0 @@ -#QTBUG-66321 -[QTBUG_42871] -macos diff --git a/tests/auto/widgets/widgets/qscrollbar/tst_qscrollbar.cpp b/tests/auto/widgets/widgets/qscrollbar/tst_qscrollbar.cpp index 278f5cdd68..339ff293f4 100644 --- a/tests/auto/widgets/widgets/qscrollbar/tst_qscrollbar.cpp +++ b/tests/auto/widgets/widgets/qscrollbar/tst_qscrollbar.cpp @@ -151,8 +151,11 @@ void tst_QScrollBar::QTBUG_27308() testWidget.setValue(testWidget.minimum()); testWidget.setEnabled(false); - QWheelEvent event(testWidget.rect().center(), - -WHEEL_DELTA, Qt::NoButton, Qt::NoModifier, testWidget.orientation()); + const QPoint wheelPoint = testWidget.rect().center(); + const QPoint angleDelta(testWidget.orientation() == Qt::Horizontal ? -WHEEL_DELTA : 0, + testWidget.orientation() == Qt::Vertical ? -WHEEL_DELTA : 0); + QWheelEvent event(wheelPoint, testWidget.mapToGlobal(wheelPoint), QPoint(), angleDelta, + Qt::NoButton, Qt::NoModifier, Qt::NoScrollPhase, false); qApp->sendEvent(&testWidget, &event); QCOMPARE(testWidget.value(), testWidget.minimum()); } diff --git a/tests/auto/widgets/widgets/qspinbox/BLACKLIST b/tests/auto/widgets/widgets/qspinbox/BLACKLIST index a38511bfb4..96a7732165 100644 --- a/tests/auto/widgets/widgets/qspinbox/BLACKLIST +++ b/tests/auto/widgets/widgets/qspinbox/BLACKLIST @@ -1,3 +1,2 @@ [stepModifierPressAndHold] -opensuse ci # QTBUG-69492 -opensuse-leap ci +opensuse-42.3 diff --git a/tests/auto/widgets/widgets/qspinbox/tst_qspinbox.cpp b/tests/auto/widgets/widgets/qspinbox/tst_qspinbox.cpp index 52d7dad7cf..d75e701d1c 100644 --- a/tests/auto/widgets/widgets/qspinbox/tst_qspinbox.cpp +++ b/tests/auto/widgets/widgets/qspinbox/tst_qspinbox.cpp @@ -206,7 +206,7 @@ private slots: void stepModifierPressAndHold_data(); void stepModifierPressAndHold(); public slots: - void valueChangedHelper(const QString &); + void textChangedHelper(const QString &); void valueChangedHelper(int); private: QStringList actualTexts; @@ -222,19 +222,19 @@ static QLatin1String modifierToName(Qt::KeyboardModifier modifier) { switch (modifier) { case Qt::NoModifier: - return QLatin1Literal("No"); + return QLatin1String("No"); break; case Qt::ControlModifier: - return QLatin1Literal("Ctrl"); + return QLatin1String("Ctrl"); break; case Qt::ShiftModifier: - return QLatin1Literal("Shift"); + return QLatin1String("Shift"); break; case Qt::AltModifier: - return QLatin1Literal("Alt"); + return QLatin1String("Alt"); break; case Qt::MetaModifier: - return QLatin1Literal("Meta"); + return QLatin1String("Meta"); break; default: qFatal("Unexpected keyboard modifier"); @@ -490,7 +490,7 @@ void tst_QSpinBox::setPrefixSuffix() } } -void tst_QSpinBox::valueChangedHelper(const QString &text) +void tst_QSpinBox::textChangedHelper(const QString &text) { actualTexts << text; } @@ -568,7 +568,7 @@ void tst_QSpinBox::setTracking() QSpinBox spin(0); spin.setKeyboardTracking(tracking); spin.show(); - connect(&spin, SIGNAL(valueChanged(QString)), this, SLOT(valueChangedHelper(QString))); + connect(&spin, &QSpinBox::textChanged, this, &tst_QSpinBox::textChangedHelper); keys.simulate(&spin); QCOMPARE(actualTexts, texts); @@ -1331,7 +1331,6 @@ void tst_QSpinBox::wheelEvents_data() { #if QT_CONFIG(wheelevent) QTest::addColumn<QPoint>("angleDelta"); - QTest::addColumn<int>("qt4Delta"); QTest::addColumn<int>("stepModifier"); QTest::addColumn<Qt::KeyboardModifiers>("modifier"); QTest::addColumn<Qt::MouseEventSource>("source"); @@ -1402,16 +1401,16 @@ void tst_QSpinBox::wheelEvents_data() QLatin1String sourceName; switch (source) { case Qt::MouseEventNotSynthesized: - sourceName = QLatin1Literal("NotSynthesized"); + sourceName = QLatin1String("NotSynthesized"); break; case Qt::MouseEventSynthesizedBySystem: - sourceName = QLatin1Literal("SynthesizedBySystem"); + sourceName = QLatin1String("SynthesizedBySystem"); break; case Qt::MouseEventSynthesizedByQt: - sourceName = QLatin1Literal("SynthesizedByQt"); + sourceName = QLatin1String("SynthesizedByQt"); break; case Qt::MouseEventSynthesizedByApplication: - sourceName = QLatin1Literal("SynthesizedByApplication"); + sourceName = QLatin1String("SynthesizedByApplication"); break; default: qFatal("Unexpected wheel event source"); @@ -1430,7 +1429,6 @@ void tst_QSpinBox::wheelEvents_data() modifierName.latin1(), sourceName.latin1()) << angleDelta - << units << static_cast<int>(stepModifier) << modifiers << source @@ -1450,7 +1448,6 @@ void tst_QSpinBox::wheelEvents() { #if QT_CONFIG(wheelevent) QFETCH(QPoint, angleDelta); - QFETCH(int, qt4Delta); QFETCH(int, stepModifier); QFETCH(Qt::KeyboardModifiers, modifier); QFETCH(Qt::MouseEventSource, source); @@ -1466,9 +1463,8 @@ void tst_QSpinBox::wheelEvents() style->stepModifier = static_cast<Qt::KeyboardModifier>(stepModifier); spinBox.setStyle(style.data()); - QWheelEvent event(QPointF(), QPointF(), QPoint(), angleDelta, qt4Delta, - Qt::Vertical, Qt::NoButton, modifier, Qt::NoScrollPhase, - source); + QWheelEvent event(QPointF(), QPointF(), QPoint(), angleDelta, + Qt::NoButton, modifier, Qt::NoScrollPhase, false, source); for (int expected : expectedValues) { qApp->sendEvent(&spinBox, &event); QCOMPARE(spinBox.value(), expected); diff --git a/tests/auto/widgets/widgets/qtabwidget/qtabwidget.pro b/tests/auto/widgets/widgets/qtabwidget/qtabwidget.pro index 6523209c32..b61cc8fa13 100644 --- a/tests/auto/widgets/widgets/qtabwidget/qtabwidget.pro +++ b/tests/auto/widgets/widgets/qtabwidget/qtabwidget.pro @@ -8,4 +8,4 @@ INCLUDEPATH += ../ HEADERS += SOURCES += tst_qtabwidget.cpp -win32:!winrt: LIBS += -luser32 +win32:!winrt: QMAKE_USE += user32 diff --git a/tests/auto/widgets/widgets/qtextbrowser/heading.html b/tests/auto/widgets/widgets/qtextbrowser/heading.html new file mode 100644 index 0000000000..8b23807f65 --- /dev/null +++ b/tests/auto/widgets/widgets/qtextbrowser/heading.html @@ -0,0 +1,2 @@ +<h3>this is a heading</h3> +<p>this is a paragraph</p> diff --git a/tests/auto/widgets/widgets/qtextbrowser/markdown.md b/tests/auto/widgets/widgets/qtextbrowser/markdown.md new file mode 100644 index 0000000000..be56aef234 --- /dev/null +++ b/tests/auto/widgets/widgets/qtextbrowser/markdown.md @@ -0,0 +1,2 @@ +### this is a heading +this is a paragraph diff --git a/tests/auto/widgets/widgets/qtextbrowser/markdown.really b/tests/auto/widgets/widgets/qtextbrowser/markdown.really new file mode 100644 index 0000000000..be56aef234 --- /dev/null +++ b/tests/auto/widgets/widgets/qtextbrowser/markdown.really @@ -0,0 +1,2 @@ +### this is a heading +this is a paragraph diff --git a/tests/auto/widgets/widgets/qtextbrowser/qtextbrowser.pro b/tests/auto/widgets/widgets/qtextbrowser/qtextbrowser.pro index 9680ffd871..dfdcf26497 100644 --- a/tests/auto/widgets/widgets/qtextbrowser/qtextbrowser.pro +++ b/tests/auto/widgets/widgets/qtextbrowser/qtextbrowser.pro @@ -4,6 +4,6 @@ SOURCES += tst_qtextbrowser.cpp QT += widgets testlib -TESTDATA += *.html subdir/* +TESTDATA += *.html *.md markdown.really subdir/* builtin_testdata: DEFINES += BUILTIN_TESTDATA diff --git a/tests/auto/widgets/widgets/qtextbrowser/quotesAndFractions.md b/tests/auto/widgets/widgets/qtextbrowser/quotesAndFractions.md new file mode 100644 index 0000000000..6bad9cb95b --- /dev/null +++ b/tests/auto/widgets/widgets/qtextbrowser/quotesAndFractions.md @@ -0,0 +1 @@ +you’ll hope to see ❝quotes❞ ﹠1½ ⅔ ¼ ⅗ ⅚ ⅝ some “vulgar” fractions (pardon my «French») diff --git a/tests/auto/widgets/widgets/qtextbrowser/tst_qtextbrowser.cpp b/tests/auto/widgets/widgets/qtextbrowser/tst_qtextbrowser.cpp index 8a1b228c71..27bf0ce7be 100644 --- a/tests/auto/widgets/widgets/qtextbrowser/tst_qtextbrowser.cpp +++ b/tests/auto/widgets/widgets/qtextbrowser/tst_qtextbrowser.cpp @@ -1,6 +1,6 @@ /**************************************************************************** ** -** Copyright (C) 2016 The Qt Company Ltd. +** Copyright (C) 2019 The Qt Company Ltd. ** Contact: https://www.qt.io/licensing/ ** ** This file is part of the test suite of the Qt Toolkit. @@ -38,7 +38,7 @@ class TestBrowser : public QTextBrowser { public: - inline TestBrowser() : htmlLoadAttempts(0) { + inline TestBrowser() { show(); QApplication::setActiveWindow(this); activateWindow(); @@ -47,11 +47,12 @@ public: QVERIFY(hasFocus()); } - virtual QVariant loadResource(int type, const QUrl &name); + QVariant loadResource(int type, const QUrl &name) override; - int htmlLoadAttempts; + int htmlLoadAttempts = 0; QUrl lastResource; QUrl sourceInsideLoadResource; + QUrl baseInsideLoadResource; }; QVariant TestBrowser::loadResource(int type, const QUrl &name) @@ -60,6 +61,7 @@ QVariant TestBrowser::loadResource(int type, const QUrl &name) htmlLoadAttempts++; lastResource = name; sourceInsideLoadResource = source(); + baseInsideLoadResource = document()->baseUrl(); return QTextBrowser::loadResource(type, name); } @@ -90,6 +92,10 @@ private slots: void focusIndicator(); void focusHistory(); void urlEncoding(); + void sourceType_data(); + void sourceType(); + void unicode_data(); + void unicode(); private: TestBrowser *browser; @@ -108,7 +114,7 @@ void tst_QTextBrowser::init() void tst_QTextBrowser::cleanup() { delete browser; - browser = 0; + browser = nullptr; } void tst_QTextBrowser::noReloadOnAnchorJump() @@ -428,11 +434,18 @@ void tst_QTextBrowser::sourceInsideLoadResource() #ifdef Q_OS_WINRT QSKIP("Paths cannot be compared if applications are sandboxed."); #endif - QUrl url = QUrl::fromLocalFile("pagewithimage.html"); + QUrl url = QUrl::fromLocalFile("pagewithimage.html"); // "file://pagewithimage.html" browser->setSource(url); QCOMPARE(browser->lastResource, QUrl::fromLocalFile(QDir::current().filePath("foobar.png"))); + // baseUrl was not set because the source URL was a relative one + QCOMPARE(browser->baseInsideLoadResource, QUrl()); QEXPECT_FAIL("", "This is currently not supported", Continue); QCOMPARE(browser->sourceInsideLoadResource.toString(), url.toString()); + url = QUrl::fromLocalFile(QDir::current().filePath("pagewithimage.html")); // "file:///home/user/path/to/pagewithimage.html" + browser->setSource(url); + QCOMPARE(browser->lastResource, QUrl::fromLocalFile(QDir::current().filePath("foobar.png"))); + // baseUrl has the full path, and that's where relative-path resources come from + QCOMPARE(browser->baseInsideLoadResource, QUrl::fromLocalFile(QDir::currentPath() + QLatin1Char('/'))); } void tst_QTextBrowser::textInteractionFlags_vs_readOnly() @@ -669,5 +682,72 @@ void tst_QTextBrowser::urlEncoding() delete browser; } +void tst_QTextBrowser::sourceType_data() +{ + QTest::addColumn<QString>("sourceFile"); + QTest::addColumn<QTextDocument::ResourceType>("sourceType"); + QTest::addColumn<int>("expectedMaxHeadingLevel"); + QTest::addColumn<QTextDocument::ResourceType>("expectedSourceType"); + +#if QT_CONFIG(textmarkdownreader) + const int maxMdHeadingLevel = 3; + const QTextDocument::ResourceType mdExpectedType = QTextDocument::MarkdownResource; +#else + // If Qt doesn't support markdown, and we read a MD document anyway, it won't have any H3's. + const int maxMdHeadingLevel = 0; + const QTextDocument::ResourceType mdExpectedType = QTextDocument::HtmlResource; +#endif + QTest::newRow("markdown detected") << "markdown.md" << QTextDocument::UnknownResource << maxMdHeadingLevel << mdExpectedType; + QTest::newRow("markdown specified") << "markdown.really" << QTextDocument::MarkdownResource << maxMdHeadingLevel << mdExpectedType; + QTest::newRow("markdown not identified") << "markdown.really" << QTextDocument::UnknownResource << 0 << QTextDocument::HtmlResource; + QTest::newRow("html detected") << "heading.html" << QTextDocument::UnknownResource << 3 << QTextDocument::HtmlResource; + QTest::newRow("html specified") << "heading.html" << QTextDocument::HtmlResource << 3 << QTextDocument::HtmlResource; +} + +void tst_QTextBrowser::sourceType() +{ + QFETCH(QString, sourceFile); + QFETCH(QTextDocument::ResourceType, sourceType); + QFETCH(int, expectedMaxHeadingLevel); + QFETCH(QTextDocument::ResourceType, expectedSourceType); + if (sourceType == QTextDocument::UnknownResource) + // verify that the property setter works, with its default parameter for sourceType + browser->setProperty("source", QUrl::fromLocalFile(QFINDTESTDATA(sourceFile))); + else + browser->setSource(QUrl::fromLocalFile(QFINDTESTDATA(sourceFile)), sourceType); + QCOMPARE(browser->sourceType(), expectedSourceType); + QTextFrame::iterator iterator = browser->document()->rootFrame()->begin(); + int maxHeadingLevel = -1; + while (!iterator.atEnd()) + maxHeadingLevel = qMax(iterator++.currentBlock().blockFormat().intProperty(QTextFormat::HeadingLevel), maxHeadingLevel); + QCOMPARE(maxHeadingLevel, expectedMaxHeadingLevel); +} + +void tst_QTextBrowser::unicode_data() +{ + QTest::addColumn<QString>("sourceFile"); + QTest::addColumn<QTextDocument::ResourceType>("sourceType"); + QTest::addColumn<QString>("expectedText"); + +#if QT_CONFIG(textmarkdownreader) + QTest::newRow("markdown with quotes and fractions") << "quotesAndFractions.md" << QTextDocument::MarkdownResource << + "you\u2019ll hope to see \u275Dquotes\u275E \uFE601\u00BD \u2154 \u00BC \u2157 \u215A \u215D some \u201Cvulgar\u201D fractions (pardon my \u00ABFrench\u00BB)"; +#endif +} + +void tst_QTextBrowser::unicode() +{ + QFETCH(QString, sourceFile); + QFETCH(QTextDocument::ResourceType, sourceType); + QFETCH(QString, expectedText); + browser->setSource(QUrl::fromLocalFile(QFINDTESTDATA(sourceFile)), sourceType); + QTextFrame::iterator iterator = browser->document()->rootFrame()->begin(); + while (!iterator.atEnd()) { + QString blockText = iterator++.currentBlock().text(); + if (!blockText.isEmpty()) + QCOMPARE(blockText, expectedText); + } +} + QTEST_MAIN(tst_QTextBrowser) #include "tst_qtextbrowser.moc" diff --git a/tests/auto/widgets/widgets/qtextedit/tst_qtextedit.cpp b/tests/auto/widgets/widgets/qtextedit/tst_qtextedit.cpp index 3669935823..c2cf31bfa4 100644 --- a/tests/auto/widgets/widgets/qtextedit/tst_qtextedit.cpp +++ b/tests/auto/widgets/widgets/qtextedit/tst_qtextedit.cpp @@ -160,6 +160,7 @@ private slots: void selectionChanged(); #ifndef QT_NO_CLIPBOARD void copyPasteBackgroundImage(); + void copyPasteForegroundImage(); #endif void setText(); void cursorRect(); @@ -1904,6 +1905,36 @@ void tst_QTextEdit::copyPasteBackgroundImage() ba.texture().cacheKey() == bb.texture().cacheKey()); QFile::remove(QLatin1String("foo.png")); } + +void tst_QTextEdit::copyPasteForegroundImage() +{ + ed->clear(); + + QPixmap pix(20, 20); + pix.fill(Qt::blue); + + QTextCharFormat fmt; + { + QBrush textureBrush; + { + textureBrush.setTexture(pix); + } + textureBrush.setStyle(Qt::TexturePattern); + fmt.setForeground(textureBrush); + } + ed->textCursor().insertText("Foobar", fmt); + + ed->moveCursor(QTextCursor::Start); + ed->moveCursor(QTextCursor::End, QTextCursor::KeepAnchor); + + ed->copy(); + ed->clear(); + ed->paste(); + + QBrush brush = ed->textCursor().charFormat().foreground(); + QCOMPARE(brush.style(), Qt::TexturePattern); + QCOMPARE(brush.texture().cacheKey(), pix.cacheKey()); +} #endif void tst_QTextEdit::setText() @@ -2638,12 +2669,14 @@ void tst_QTextEdit::wheelEvent() ed.setReadOnly(true); float defaultFontSize = ed.font().pointSizeF(); - QWheelEvent wheelUp(QPointF(), QPointF(), QPoint(), QPoint(0, 120), 120, Qt::Vertical, Qt::NoButton, Qt::ControlModifier); + QWheelEvent wheelUp(QPointF(), QPointF(), QPoint(), QPoint(0, 120), + Qt::NoButton, Qt::ControlModifier, Qt::NoScrollPhase, Qt::MouseEventNotSynthesized); ed.wheelEvent(&wheelUp); QCOMPARE(defaultFontSize + 1, ed.font().pointSizeF()); - QWheelEvent wheelHalfDown(QPointF(), QPointF(), QPoint(), QPoint(0, -60), -60, Qt::Vertical, Qt::NoButton, Qt::ControlModifier); + QWheelEvent wheelHalfDown(QPointF(), QPointF(), QPoint(), QPoint(0, -60), + Qt::NoButton, Qt::ControlModifier, Qt::NoScrollPhase, Qt::MouseEventNotSynthesized); ed.wheelEvent(&wheelHalfDown); QCOMPARE(defaultFontSize + 0.5, ed.font().pointSizeF()); diff --git a/tests/auto/widgets/widgets/qtoolbutton/BLACKLIST b/tests/auto/widgets/widgets/qtoolbutton/BLACKLIST index df4fda196f..52ba36562f 100644 --- a/tests/auto/widgets/widgets/qtoolbutton/BLACKLIST +++ b/tests/auto/widgets/widgets/qtoolbutton/BLACKLIST @@ -1,2 +1,2 @@ [task176137_autoRepeatOfAction] -osx ci +osx-10.13 |