From 8bcc6f111b1c8f0e5c9c9da18313a16559de63a5 Mon Sep 17 00:00:00 2001 From: Christian Ehrlicher Date: Thu, 14 Mar 2019 20:12:08 +0100 Subject: QComboBox: add QT_DEPRECATED_X() for deprecated functions QT_DEPRECATED_X() was not added with d6d33f0b80dd85043c71f71a3ed5485d6014e6c4 for the deprecated QComboBox functions - Add them now. Change-Id: I8d4ea08766ae6ff052dfccac6c3f35ecf34affb7 Reviewed-by: Richard Moe Gustavsen --- tests/auto/widgets/widgets/qcombobox/tst_qcombobox.cpp | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to 'tests/auto') diff --git a/tests/auto/widgets/widgets/qcombobox/tst_qcombobox.cpp b/tests/auto/widgets/widgets/qcombobox/tst_qcombobox.cpp index 5b4761ba87..a576770811 100644 --- a/tests/auto/widgets/widgets/qcombobox/tst_qcombobox.cpp +++ b/tests/auto/widgets/widgets/qcombobox/tst_qcombobox.cpp @@ -852,8 +852,8 @@ void tst_QComboBox::autoCompletionCaseSensitivity() // case insensitive testWidget->clearEditText(); QSignalSpy spyReturn(testWidget, SIGNAL(activated(int))); - testWidget->setAutoCompletionCaseSensitivity(Qt::CaseInsensitive); - QCOMPARE(testWidget->autoCompletionCaseSensitivity(), Qt::CaseInsensitive); + testWidget->completer()->setCaseSensitivity(Qt::CaseInsensitive); + QCOMPARE(testWidget->completer()->caseSensitivity(), Qt::CaseInsensitive); QTest::keyClick(testWidget->lineEdit(), Qt::Key_A); qApp->processEvents(); @@ -886,8 +886,8 @@ void tst_QComboBox::autoCompletionCaseSensitivity() // case sensitive testWidget->clearEditText(); - testWidget->setAutoCompletionCaseSensitivity(Qt::CaseSensitive); - QCOMPARE(testWidget->autoCompletionCaseSensitivity(), Qt::CaseSensitive); + testWidget->completer()->setCaseSensitivity(Qt::CaseSensitive); + QCOMPARE(testWidget->completer()->caseSensitivity(), Qt::CaseSensitive); QTest::keyClick(testWidget->lineEdit(), Qt::Key_A); qApp->processEvents(); QCOMPARE(testWidget->currentText(), QString("aww")); -- cgit v1.2.3 From cc4c0b43a54d9606f491c193df381a424ae696bf Mon Sep 17 00:00:00 2001 From: Ryan Chu Date: Fri, 3 May 2019 16:14:19 +0200 Subject: QDataStream: Fix inconsistent results of iostream with QPalette objects The value of NColorRoles got changed since 5.11. It introduced one more role called "PlaceholderText" in the ColorRole enumeration. When using QDataStream (5.12) to read QPalette objects from a file written by 5.9 (<5.11), the processing results are inconsistent. Fixes: QTBUG-74885 Change-Id: I14d57f9603a26e5890b4fd57c7e464c5b38eb3f2 Reviewed-by: Eirik Aavitsland --- .../serialization/qdatastream/tst_qdatastream.cpp | 54 +++++++++++++++++----- 1 file changed, 43 insertions(+), 11 deletions(-) (limited to 'tests/auto') diff --git a/tests/auto/corelib/serialization/qdatastream/tst_qdatastream.cpp b/tests/auto/corelib/serialization/qdatastream/tst_qdatastream.cpp index 011a0e1a85..041d9d7a09 100644 --- a/tests/auto/corelib/serialization/qdatastream/tst_qdatastream.cpp +++ b/tests/auto/corelib/serialization/qdatastream/tst_qdatastream.cpp @@ -174,6 +174,7 @@ private slots: void floatingPointPrecision(); + void compatibility_Qt5(); void compatibility_Qt3(); void compatibility_Qt2(); @@ -260,17 +261,17 @@ static int NColorRoles[] = { QPalette::HighlightedText + 1, // Qt_4_0, Qt_4_1 QPalette::HighlightedText + 1, // Qt_4_2 QPalette::AlternateBase + 1, // Qt_4_3 - QPalette::PlaceholderText + 1, // Qt_4_4 - QPalette::PlaceholderText + 1, // Qt_4_5 - QPalette::PlaceholderText + 1, // Qt_4_6 - QPalette::PlaceholderText + 1, // Qt_5_0 - QPalette::PlaceholderText + 1, // Qt_5_1 - QPalette::PlaceholderText + 1, // Qt_5_2 - QPalette::PlaceholderText + 1, // Qt_5_3 - QPalette::PlaceholderText + 1, // Qt_5_4 - QPalette::PlaceholderText + 1, // Qt_5_5 - QPalette::PlaceholderText + 1, // Qt_5_6 - 0 // add the correct value for Qt_5_7 here later + QPalette::ToolTipText + 1, // Qt_4_4 + QPalette::ToolTipText + 1, // Qt_4_5 + QPalette::ToolTipText + 1, // Qt_4_6, Qt_4_7, Qt_4_8, Qt_4_9 + QPalette::ToolTipText + 1, // Qt_5_0 + QPalette::ToolTipText + 1, // Qt_5_1 + QPalette::ToolTipText + 1, // Qt_5_2, Qt_5_3 + QPalette::ToolTipText + 1, // Qt_5_4, Qt_5_5 + QPalette::ToolTipText + 1, // Qt_5_6, Qt_5_7, Qt_5_8, Qt_5_9, Qt_5_10, Qt_5_11 + QPalette::PlaceholderText + 1, // Qt_5_12 + QPalette::PlaceholderText + 1, // Qt_5_13 + 0 // add the correct value for Qt_5_14 here later }; // Testing get/set functions @@ -3102,6 +3103,37 @@ void tst_QDataStream::streamRealDataTypes() } } +void tst_QDataStream::compatibility_Qt5() +{ + QLinearGradient gradient(QPointF(0,0), QPointF(1,1)); + gradient.setColorAt(0, Qt::red); + gradient.setColorAt(1, Qt::blue); + + QBrush brush(gradient); + QPalette palette; + palette.setBrush(QPalette::Button, brush); + palette.setColor(QPalette::Light, Qt::green); + + QByteArray stream; + { + QDataStream out(&stream, QIODevice::WriteOnly); + out.setVersion(QDataStream::Qt_5_7); + out << palette; + out << brush; + } + QBrush in_brush; + QPalette in_palette; + { + QDataStream in(stream); + in.setVersion(QDataStream::Qt_5_7); + in >> in_palette; + in >> in_brush; + } + QCOMPARE(in_brush.style(), Qt::LinearGradientPattern); + QCOMPARE(in_palette.brush(QPalette::Button).style(), Qt::LinearGradientPattern); + QCOMPARE(in_palette.color(QPalette::Light), QColor(Qt::green)); +} + void tst_QDataStream::compatibility_Qt3() { QByteArray ba("hello"); -- cgit v1.2.3 From b9f96cacc99c8a242f45f4581843a6b1c67501f4 Mon Sep 17 00:00:00 2001 From: Giuseppe D'Angelo Date: Mon, 27 May 2019 19:00:09 +0200 Subject: QRegExp: remove an out of bounds access into QString ... spotted with the brand-new checks for that in QCharRef. The rx[i] == ~~~ check is clearly wrong, as rx is the regexp we're building and `i` was not supposed to index into it. The intended meaning was wc[i] == ~~~, testing if we were seeing the closing bracket of a character set. We need to check for that immediately for dealing with the special syntax of []...] where the ] belongs to the character set (it can't be the closing one as character sets cannot be empty). Fix and add a regression test. Bonus: this code was almost unchanged since 2009. Change-Id: I958cd87fc25558e9d202d18b3dd4a35d0db16d8d Reviewed-by: Marc Mutz Reviewed-by: hjk --- tests/auto/corelib/tools/qregexp/tst_qregexp.cpp | 7 +++++++ 1 file changed, 7 insertions(+) (limited to 'tests/auto') diff --git a/tests/auto/corelib/tools/qregexp/tst_qregexp.cpp b/tests/auto/corelib/tools/qregexp/tst_qregexp.cpp index a98d37d733..a8111af6c1 100644 --- a/tests/auto/corelib/tools/qregexp/tst_qregexp.cpp +++ b/tests/auto/corelib/tools/qregexp/tst_qregexp.cpp @@ -834,6 +834,13 @@ void tst_QRegExp::testEscapingWildcard_data(){ QTest::newRow("a true '\\' in input") << "\\Qt;" << "\\Qt;" << true; QTest::newRow("two true '\\' in input") << "\\\\Qt;" << "\\\\Qt;" << true; QTest::newRow("a '\\' at the end") << "\\\\Qt;\\" << "\\\\Qt;\\" << true; + + QTest::newRow("[]\\] matches ]") << "[]\\]" << "]" << true; + QTest::newRow("[]\\] matches \\") << "[]\\]" << "\\" << true; + QTest::newRow("[]\\] does not match [") << "[]\\]" << "[" << false; + QTest::newRow("[]\\]a matches ]a") << "[]\\]a" << "]a" << true; + QTest::newRow("[]\\]a matches \\a") << "[]\\]a" << "\\a" << true; + QTest::newRow("[]\\]a does not match [a") << "[]\\]a" << "[a" << false; } void tst_QRegExp::testEscapingWildcard(){ -- cgit v1.2.3 From c3571d2922d41617e81fa9e8ae971d08fb9e94af Mon Sep 17 00:00:00 2001 From: Edward Welbourne Date: Thu, 23 May 2019 10:48:28 +0200 Subject: Correct qfloat16's 1/inf == 0 test It should have been qfloat16(1)/qfloat16(infinity) in any case. Sadly, that behaves no better than qfloat16(1.f/qfloat16(infinity)), which was promoting the infinity back to float. So retain the check for over-optimization (but make the comment more accurate). This is a follow-up to d441f6bba7b2aaf1e11b95c1ad4c785e6939f6ba. Change-Id: Iec4afe4b04081b0ebfbf98058da606dc3ade07f4 Reviewed-by: Qt CI Bot Reviewed-by: Friedemann Kleint Reviewed-by: Thiago Macieira --- tests/auto/corelib/global/qfloat16/tst_qfloat16.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'tests/auto') diff --git a/tests/auto/corelib/global/qfloat16/tst_qfloat16.cpp b/tests/auto/corelib/global/qfloat16/tst_qfloat16.cpp index aa6f0935e8..b73a297245 100644 --- a/tests/auto/corelib/global/qfloat16/tst_qfloat16.cpp +++ b/tests/auto/corelib/global/qfloat16/tst_qfloat16.cpp @@ -172,9 +172,9 @@ void tst_qfloat16::qNan() QVERIFY(qIsInf(-inf)); QVERIFY(qIsInf(2.f*inf)); QVERIFY(qIsInf(inf*2.f)); - // QTBUG-75812: QEMU's over-optimized arm64 flakily fails 1/inf == 0 :-( + // QTBUG-75812: QEMU/arm64 compiler over-optimizes, so flakily fails 1/inf == 0 :-( if (qfloat16(9.785e-4f) == qfloat16(9.794e-4f)) - QCOMPARE(qfloat16(1.f/inf), qfloat16(0.f)); + QCOMPARE(qfloat16(1.f) / inf, qfloat16(0.f)); #ifdef Q_CC_INTEL QEXPECT_FAIL("", "ICC optimizes zero * anything to zero", Continue); #endif -- cgit v1.2.3 From 67c569add0a3db5f730d81b6bcb3fed22d3a4ce6 Mon Sep 17 00:00:00 2001 From: Friedemann Kleint Date: Thu, 9 May 2019 13:44:12 +0200 Subject: Make tst_qwidget pass on High-DPI screens (Windows) - Move the fuzz check introduced by 63090627220a6209652d236cf991305fbeb188b8 to a shared header for reuse. Use it in in more places to account for rounding errors introduced by odd window frame sizes when scaling is active. - Use the test widget size to ensure windows do not violate the minimum decorated window size on Windows when scaling is inactive on large monitors. Task-number: QTBUG-46615 Change-Id: Icf803a4bc2c275eadb8f98e60b08e39b2ebebedd Reviewed-by: Oliver Wolff --- tests/auto/shared/highdpi.h | 109 ++++++++++++++++++++++ tests/auto/widgets/kernel/qwidget/tst_qwidget.cpp | 68 +++++++------- 2 files changed, 143 insertions(+), 34 deletions(-) create mode 100644 tests/auto/shared/highdpi.h (limited to 'tests/auto') diff --git a/tests/auto/shared/highdpi.h b/tests/auto/shared/highdpi.h new file mode 100644 index 0000000000..f0c34bea25 --- /dev/null +++ b/tests/auto/shared/highdpi.h @@ -0,0 +1,109 @@ +/**************************************************************************** +** +** 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. +** +** $QT_BEGIN_LICENSE:GPL-EXCEPT$ +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms +** and conditions see https://www.qt.io/terms-conditions. For further +** information use the contact form at https://www.qt.io/contact-us. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 3 as published by the Free Software +** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT +** included in the packaging of this file. Please review the following +** information to ensure the GNU General Public License requirements will +** be met: https://www.gnu.org/licenses/gpl-3.0.html. +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#ifndef HIGHDPI_H +#define HIGHDPI_H + +#include +#include +#include +#include + +// Helpers for comparing geometries a that may go through scaling in the +// platform plugin with fuzz (pass rounded-down device pixel ratios or +// scaling factors). Error message for use with QVERIFY2() are also provided. + +class HighDpi +{ +public: + HighDpi() = delete; + HighDpi(const HighDpi &) = delete; + HighDpi &operator=(const HighDpi &) = delete; + HighDpi(HighDpi &&) = delete; + HighDpi &operator=(HighDpi &&) = delete; + ~HighDpi() = delete; + + static int manhattanDelta(const QPoint &p1, const QPoint p2) + { + return (p1 - p2).manhattanLength(); + } + + static bool fuzzyCompare(const QPoint &p1, const QPoint p2, int fuzz) + { + return manhattanDelta(p1, p2) <= fuzz; + } + + static QByteArray msgPointMismatch(const QPoint &p1, const QPoint p2) + { + return QByteArray::number(p1.x()) + ',' + QByteArray::number(p1.y()) + + " != " + QByteArray::number(p2.x()) + ',' + QByteArray::number(p2.y()) + + ", manhattanLength=" + QByteArray::number(manhattanDelta(p1, p2)); + } + + // Compare a size that may go through scaling in the platform plugin with fuzz. + + static inline int manhattanDelta(const QSize &s1, const QSize &s2) + { + return qAbs(s1.width() - s2.width()) + qAbs(s1.height() - s2.height()); + } + + static inline bool fuzzyCompare(const QSize &s1, const QSize &s2, int fuzz) + { + return manhattanDelta(s1, s2) <= fuzz; + } + + static QByteArray msgSizeMismatch(const QSize &s1, const QSize &s2) + { + return QByteArray::number(s1.width()) + 'x' + QByteArray::number(s1.height()) + + " != " + QByteArray::number(s2.width()) + 'x' + QByteArray::number(s2.height()) + + ", manhattanLength=" + QByteArray::number(manhattanDelta(s1, s2)); + } + + // Compare a geometry that may go through scaling in the platform plugin with fuzz. + + static inline bool fuzzyCompare(const QRect &r1, const QRect &r2, int fuzz) + { + return manhattanDelta(r1.topLeft(), r2.topLeft()) <= fuzz + && manhattanDelta(r1.size(), r2.size()) <= fuzz; + } + + static QByteArray msgRectMismatch(const QRect &r1, const QRect &r2) + { + return formatRect(r1) + " != " + formatRect(r2); + } + +private: + static QByteArray formatRect(const QRect &r) + { + return QByteArray::number(r.width()) + 'x' + QByteArray::number(r.height()) + + (r.left() < 0 ? '-' : '+') + QByteArray::number(r.left()) + + (r.top() < 0 ? '-' : '+') + QByteArray::number(r.top()); + } +}; + +#endif // HIGHDPI_H diff --git a/tests/auto/widgets/kernel/qwidget/tst_qwidget.cpp b/tests/auto/widgets/kernel/qwidget/tst_qwidget.cpp index bbaed67a36..c0dfaf80a3 100644 --- a/tests/auto/widgets/kernel/qwidget/tst_qwidget.cpp +++ b/tests/auto/widgets/kernel/qwidget/tst_qwidget.cpp @@ -26,6 +26,7 @@ ** ****************************************************************************/ +#include "../../../shared/highdpi.h" #include #include @@ -140,19 +141,6 @@ static QByteArray msgComparisonFailed(T v1, const char *op, T v2) return s.toLocal8Bit(); } -// Compare a window position that may go through scaling in the platform plugin with fuzz. -static inline bool qFuzzyCompareWindowPosition(const QPoint &p1, const QPoint p2, int fuzz) -{ - return (p1 - p2).manhattanLength() <= fuzz; -} - -static QString msgPointMismatch(const QPoint &p1, const QPoint p2) -{ - QString result; - QDebug(&result) << p1 << "!=" << p2 << ", manhattanLength=" << (p1 - p2).manhattanLength(); - return result; -} - class tst_QWidget : public QObject { Q_OBJECT @@ -416,6 +404,7 @@ private: QPoint m_safeCursorPos; const bool m_windowsAnimationsEnabled; QTouchDevice *m_touchScreen; + const int m_fuzz; }; bool tst_QWidget::ensureScreenSize(int width, int height) @@ -574,6 +563,7 @@ tst_QWidget::tst_QWidget() , m_safeCursorPos(0, 0) , m_windowsAnimationsEnabled(windowsAnimationsEnabled()) , m_touchScreen(QTest::createTouchDevice()) + , m_fuzz(int(QGuiApplication::primaryScreen()->devicePixelRatio())) { if (m_windowsAnimationsEnabled) // Disable animations which can interfere with screen grabbing in moveChild(), showAndMoveChild() setWindowsAnimationsEnabled(false); @@ -2047,10 +2037,9 @@ void tst_QWidget::windowState() widget1.setWindowState(widget1.windowState() ^ Qt::WindowMaximized); QTest::qWait(100); - const int fuzz = int(QHighDpiScaling::factor(widget1.windowHandle())); QVERIFY(!(widget1.windowState() & Qt::WindowMaximized)); - QTRY_VERIFY2(qFuzzyCompareWindowPosition(widget1.pos(), pos, fuzz), - qPrintable(msgPointMismatch(widget1.pos(), pos))); + QTRY_VERIFY2(HighDpi::fuzzyCompare(widget1.pos(), pos, m_fuzz), + qPrintable(HighDpi::msgPointMismatch(widget1.pos(), pos))); QCOMPARE(widget1.windowHandle()->windowState(), Qt::WindowNoState); widget1.setWindowState(Qt::WindowMinimized); @@ -2071,8 +2060,8 @@ void tst_QWidget::windowState() widget1.setWindowState(widget1.windowState() ^ Qt::WindowMaximized); QTest::qWait(100); QVERIFY(!(widget1.windowState() & (Qt::WindowMinimized|Qt::WindowMaximized))); - QTRY_VERIFY2(qFuzzyCompareWindowPosition(widget1.pos(), pos, fuzz), - qPrintable(msgPointMismatch(widget1.pos(), pos))); + QTRY_VERIFY2(HighDpi::fuzzyCompare(widget1.pos(), pos, m_fuzz), + qPrintable(HighDpi::msgPointMismatch(widget1.pos(), pos))); QCOMPARE(widget1.windowHandle()->windowState(), Qt::WindowNoState); widget1.setWindowState(Qt::WindowFullScreen); @@ -2093,8 +2082,8 @@ void tst_QWidget::windowState() widget1.setWindowState(Qt::WindowNoState); QTest::qWait(100); VERIFY_STATE(Qt::WindowNoState); - QTRY_VERIFY2(qFuzzyCompareWindowPosition(widget1.pos(), pos, fuzz), - qPrintable(msgPointMismatch(widget1.pos(), pos))); + QTRY_VERIFY2(HighDpi::fuzzyCompare(widget1.pos(), pos, m_fuzz), + qPrintable(HighDpi::msgPointMismatch(widget1.pos(), pos))); QCOMPARE(widget1.windowHandle()->windowState(), Qt::WindowNoState); widget1.setWindowState(Qt::WindowFullScreen); @@ -2127,8 +2116,8 @@ void tst_QWidget::windowState() QVERIFY(!(widget1.windowState() & stateMask)); QCOMPARE(widget1.windowHandle()->windowState(), Qt::WindowNoState); - QTRY_VERIFY2(qFuzzyCompareWindowPosition(widget1.pos(), pos, fuzz), - qPrintable(msgPointMismatch(widget1.pos(), pos))); + QTRY_VERIFY2(HighDpi::fuzzyCompare(widget1.pos(), pos, m_fuzz), + qPrintable(HighDpi::msgPointMismatch(widget1.pos(), pos))); QTRY_COMPARE(widget1.size(), size); } @@ -2321,7 +2310,7 @@ void tst_QWidget::resizeEvent() { QWidget wParent; wParent.setWindowTitle(QLatin1String(QTest::currentTestFunction())); - wParent.resize(200, 200); + wParent.resize(m_testWidgetSize); ResizeWidget wChild(&wParent); wParent.show(); QVERIFY(QTest::qWaitForWindowExposed(&wParent)); @@ -2339,7 +2328,7 @@ void tst_QWidget::resizeEvent() { ResizeWidget wTopLevel; wTopLevel.setWindowTitle(QLatin1String(QTest::currentTestFunction())); - wTopLevel.resize(200, 200); + wTopLevel.resize(m_testWidgetSize); wTopLevel.show(); QVERIFY(QTest::qWaitForWindowExposed(&wTopLevel)); if (m_platform == QStringLiteral("winrt")) @@ -2377,17 +2366,20 @@ void tst_QWidget::showMinimized() #ifdef Q_OS_WINRT QEXPECT_FAIL("", "Winrt does not support move and resize", Abort); #endif - QCOMPARE(plain.pos(), pos); + QVERIFY2(HighDpi::fuzzyCompare(plain.pos(), pos, m_fuzz), + qPrintable(HighDpi::msgPointMismatch(plain.pos(), pos))); plain.showNormal(); QVERIFY(!plain.isMinimized()); QVERIFY(plain.isVisible()); - QCOMPARE(plain.pos(), pos); + QVERIFY2(HighDpi::fuzzyCompare(plain.pos(), pos, m_fuzz), + qPrintable(HighDpi::msgPointMismatch(plain.pos(), pos))); plain.showMinimized(); QVERIFY(plain.isMinimized()); QVERIFY(plain.isVisible()); - QCOMPARE(plain.pos(), pos); + QVERIFY2(HighDpi::fuzzyCompare(plain.pos(), pos, m_fuzz), + qPrintable(HighDpi::msgPointMismatch(plain.pos(), pos))); plain.hide(); QVERIFY(plain.isMinimized()); @@ -2779,7 +2771,9 @@ void tst_QWidget::setGeometry() tlw.setWindowTitle(QLatin1String(QTest::currentTestFunction())); QWidget child(&tlw); - QRect tr(100,100,200,200); + const QPoint topLeft = QGuiApplication::primaryScreen()->availableGeometry().topLeft(); + const QSize initialSize = 2 * m_testWidgetSize; + QRect tr(topLeft + QPoint(100,100), initialSize); QRect cr(50,50,50,50); tlw.setGeometry(tr); child.setGeometry(cr); @@ -2790,8 +2784,7 @@ void tst_QWidget::setGeometry() QCOMPARE(child.geometry(), cr); tlw.setParent(nullptr, Qt::Window|Qt::FramelessWindowHint); - tr = QRect(0,0,100,100); - tr.moveTopLeft(QGuiApplication::primaryScreen()->availableGeometry().topLeft()); + tr = QRect(topLeft, initialSize / 2); tlw.setGeometry(tr); QCOMPARE(tlw.geometry(), tr); tlw.showNormal(); @@ -3263,7 +3256,8 @@ void tst_QWidget::saveRestoreGeometry() if (m_platform == QStringLiteral("winrt")) QEXPECT_FAIL("", "WinRT does not support move/resize", Abort); - QTRY_COMPARE(widget.pos(), position); + QTRY_VERIFY2(HighDpi::fuzzyCompare(widget.pos(), position, m_fuzz), + qPrintable(HighDpi::msgPointMismatch(widget.pos(), position))); QCOMPARE(widget.size(), size); savedGeometry = widget.saveGeometry(); } @@ -3291,10 +3285,12 @@ void tst_QWidget::saveRestoreGeometry() QVERIFY(QTest::qWaitForWindowExposed(&widget)); QApplication::processEvents(); - QTRY_COMPARE(widget.pos(), position); + QVERIFY2(HighDpi::fuzzyCompare(widget.pos(), position, m_fuzz), + qPrintable(HighDpi::msgPointMismatch(widget.pos(), position))); QCOMPARE(widget.size(), size); widget.show(); - QCOMPARE(widget.pos(), position); + QVERIFY2(HighDpi::fuzzyCompare(widget.pos(), position, m_fuzz), + qPrintable(HighDpi::msgPointMismatch(widget.pos(), position))); QCOMPARE(widget.size(), size); } @@ -3408,6 +3404,9 @@ void tst_QWidget::restoreVersion1Geometry() QFETCH(QSize, expectedSize); QFETCH(QRect, expectedNormalGeometry); + if (m_platform == QLatin1String("windows") && QGuiApplication::primaryScreen()->geometry().width() > 2000) + QSKIP("Skipping due to minimum decorated window size on Windows"); + // WindowActive is uninteresting for this test const Qt::WindowStates WindowStateMask = Qt::WindowFullScreen | Qt::WindowMaximized | Qt::WindowMinimized; @@ -4988,7 +4987,8 @@ void tst_QWidget::windowMoveResize() widget.showNormal(); QTest::qWait(10); - QTRY_COMPARE(widget.pos(), rect.topLeft()); + QTRY_VERIFY2(HighDpi::fuzzyCompare(widget.pos(), rect.topLeft(), m_fuzz), + qPrintable(HighDpi::msgPointMismatch(widget.pos(), rect.topLeft()))); // Windows: Minimum size of decorated windows. const bool expectResizeFail = (!windowFlags && (rect.width() < 160 || rect.height() < 40)) && m_platform == QStringLiteral("windows"); -- cgit v1.2.3 From 7029ecade96876d08af7d576e0b81417502acbaa Mon Sep 17 00:00:00 2001 From: Liang Qi Date: Mon, 20 May 2019 11:37:27 +0200 Subject: cmake: correct version dependency for qt5_add_big_resources qt5_add_big_resources is only available if using CMake 3.9 and later. This amends cdccd0222bbed1954d5d7fe0da9d2308c202f3b1. Task-number: QTBUG-55680 Task-number: QTBUG-75806 Change-Id: Ibba7af6ee7edfb226368937d543b7ec5cc93eb16 Reviewed-by: Alexandru Croitor Reviewed-by: Kai Koehne --- tests/auto/cmake/CMakeLists.txt | 7 ++++++- tests/auto/cmake/test_add_big_resource/CMakeLists.txt | 2 +- 2 files changed, 7 insertions(+), 2 deletions(-) (limited to 'tests/auto') diff --git a/tests/auto/cmake/CMakeLists.txt b/tests/auto/cmake/CMakeLists.txt index 51d0d2879e..5b10a74d3f 100644 --- a/tests/auto/cmake/CMakeLists.txt +++ b/tests/auto/cmake/CMakeLists.txt @@ -146,7 +146,12 @@ endif() expect_pass(test_interface_link_libraries) expect_pass(test_moc_macro_target) -expect_pass(test_add_big_resource) + +if (NOT CMAKE_VERSION VERSION_LESS 3.9) + # The modification of TARGET_OBJECTS needs the following change in cmake + # https://gitlab.kitware.com/cmake/cmake/commit/93c89bc75ceee599ba7c08b8fe1ac5104942054f + expect_pass(test_add_big_resource) +endif() if (NOT CMAKE_VERSION VERSION_LESS 3.8) # With earlier CMake versions, this test would simply run moc multiple times and lead to: diff --git a/tests/auto/cmake/test_add_big_resource/CMakeLists.txt b/tests/auto/cmake/test_add_big_resource/CMakeLists.txt index f928b11278..45ed2c79d5 100644 --- a/tests/auto/cmake/test_add_big_resource/CMakeLists.txt +++ b/tests/auto/cmake/test_add_big_resource/CMakeLists.txt @@ -1,5 +1,5 @@ -cmake_minimum_required(VERSION 2.8) +cmake_minimum_required(VERSION 3.9) project(test_add_big_resource) -- cgit v1.2.3 From cf7d990a486b406d558e3291247d4323a9f48c73 Mon Sep 17 00:00:00 2001 From: Allan Sandfeld Jensen Date: Wed, 15 May 2019 11:02:50 +0200 Subject: Fix reference to a dead temporary NoDefaultConstructorRef1 was taking a reference of the input, which meant in the first test it would get a reference to the temporary created by the 1 literal. A temporary that would be out of scope by the time we check its value. Instead add a test with unique_ptr to test we can pass movable temporaries. Change-Id: I6b02377dfe30c82b6e71bfb3353a81ad81558ed3 Reviewed-by: Thiago Macieira --- .../tools/qsharedpointer/tst_qsharedpointer.cpp | 22 +++++++++++++++++----- 1 file changed, 17 insertions(+), 5 deletions(-) (limited to 'tests/auto') diff --git a/tests/auto/corelib/tools/qsharedpointer/tst_qsharedpointer.cpp b/tests/auto/corelib/tools/qsharedpointer/tst_qsharedpointer.cpp index ade9c5e754..e97848fb1c 100644 --- a/tests/auto/corelib/tools/qsharedpointer/tst_qsharedpointer.cpp +++ b/tests/auto/corelib/tools/qsharedpointer/tst_qsharedpointer.cpp @@ -40,6 +40,7 @@ #include "nontracked.h" #include "wrapper.h" +#include #include #include @@ -232,6 +233,12 @@ struct NoDefaultConstructorRRef1 int &i; NoDefaultConstructorRRef1(int &&i) : i(i) {} }; + +struct NoDefaultConstructorRRef2 +{ + std::unique_ptr i; + NoDefaultConstructorRRef2(std::unique_ptr &&i) : i(std::move(i)) {} +}; #endif void tst_QSharedPointer::basics_data() @@ -1820,14 +1827,19 @@ void tst_QSharedPointer::creatingVariadic() QCOMPARE(&ptr->i, &i); } { - NoDefaultConstructorRRef1(1); // control check - QSharedPointer ptr = QSharedPointer::create(1); - QCOMPARE(ptr->i, 1); - NoDefaultConstructorRRef1(std::move(i)); // control check - ptr = QSharedPointer::create(std::move(i)); + QSharedPointer ptr = QSharedPointer::create(std::move(i)); QCOMPARE(ptr->i, i); } + { + NoDefaultConstructorRRef2(std::unique_ptr(new int(1))); // control check + QSharedPointer ptr = QSharedPointer::create(std::unique_ptr(new int(1))); + QCOMPARE(*ptr->i, 1); + + std::unique_ptr p(new int(i)); + ptr = QSharedPointer::create(std::move(p)); + QCOMPARE(*ptr->i, i); + } { QString text("Hello, World"); NoDefaultConstructorRef2(text, 1); // control check -- cgit v1.2.3 From a978c4828467c9244ceb7bb1a678272aae456f7a Mon Sep 17 00:00:00 2001 From: Shawn Rutledge Date: Fri, 7 Jun 2019 08:26:49 +0200 Subject: Blacklist tst_QGraphicsView::cursor2 on Windows It's really failing only on Windows 10 it seems. Task-number: QTBUG-76259 Change-Id: Ieb541dc994a17e82478a5cc2643e0a89fd5aa97d Reviewed-by: Marc Mutz Reviewed-by: Liang Qi --- tests/auto/widgets/graphicsview/qgraphicsview/BLACKLIST | 1 + 1 file changed, 1 insertion(+) (limited to 'tests/auto') diff --git a/tests/auto/widgets/graphicsview/qgraphicsview/BLACKLIST b/tests/auto/widgets/graphicsview/qgraphicsview/BLACKLIST index e3d968b4f2..ee13a37212 100644 --- a/tests/auto/widgets/graphicsview/qgraphicsview/BLACKLIST +++ b/tests/auto/widgets/graphicsview/qgraphicsview/BLACKLIST @@ -4,6 +4,7 @@ xcb xcb [cursor2] xcb +windows [rubberBandExtendSelection] xcb [rotated_rubberBand] -- cgit v1.2.3 From 87ca7c96880c3da48fef894987333fdaf7caac8b Mon Sep 17 00:00:00 2001 From: Friedemann Kleint Date: Wed, 5 Jun 2019 13:56:21 +0200 Subject: tst_QGraphicsView::cursor2(): Prospective fix for flakyness on Windows Use QTRY_COMPARE to fix recent fails like FAIL! : tst_QGraphicsView::cursor2() Compared values are not the same Actual (view.viewport()->cursor().shape()): IBeamCursor Expected (Qt::SizeAllCursor) : SizeAllCursor Task-number: QTBUG-76259 Change-Id: Ie9d4bbe45a3be6064ec88ee237360beb92a61481 Reviewed-by: Shawn Rutledge --- .../qgraphicsview/tst_qgraphicsview.cpp | 38 +++++++++++----------- 1 file changed, 19 insertions(+), 19 deletions(-) (limited to 'tests/auto') diff --git a/tests/auto/widgets/graphicsview/qgraphicsview/tst_qgraphicsview.cpp b/tests/auto/widgets/graphicsview/qgraphicsview/tst_qgraphicsview.cpp index 28df3a3c38..a9c1404891 100644 --- a/tests/auto/widgets/graphicsview/qgraphicsview/tst_qgraphicsview.cpp +++ b/tests/auto/widgets/graphicsview/qgraphicsview/tst_qgraphicsview.cpp @@ -2280,53 +2280,53 @@ void tst_QGraphicsView::cursor2() QVERIFY(QTest::qWaitForWindowExposed(&view)); sendMouseMove(view.viewport(), view.mapFromScene(-30, -30)); - QCOMPARE(view.viewport()->cursor().shape(), Qt::PointingHandCursor); + QTRY_COMPARE(view.viewport()->cursor().shape(), Qt::PointingHandCursor); sendMouseMove(view.viewport(), view.mapFromScene(0, 0)); - QCOMPARE(view.viewport()->cursor().shape(), Qt::IBeamCursor); + QTRY_COMPARE(view.viewport()->cursor().shape(), Qt::IBeamCursor); sendMouseMove(view.viewport(), view.mapFromScene(-30, -30)); - QCOMPARE(view.viewport()->cursor().shape(), Qt::PointingHandCursor); + QTRY_COMPARE(view.viewport()->cursor().shape(), Qt::PointingHandCursor); sendMouseMove(view.viewport(), view.mapFromScene(0, 0)); - QCOMPARE(view.viewport()->cursor().shape(), Qt::IBeamCursor); + QTRY_COMPARE(view.viewport()->cursor().shape(), Qt::IBeamCursor); sendMouseMove(view.viewport(), view.mapFromScene(-15, 0)); - QCOMPARE(view.viewport()->cursor().shape(), Qt::PointingHandCursor); + QTRY_COMPARE(view.viewport()->cursor().shape(), Qt::PointingHandCursor); view.setDragMode(QGraphicsView::ScrollHandDrag); sendMouseMove(view.viewport(), view.mapFromScene(-30, -30)); - QCOMPARE(view.viewport()->cursor().shape(), Qt::OpenHandCursor); + QTRY_COMPARE(view.viewport()->cursor().shape(), Qt::OpenHandCursor); sendMouseMove(view.viewport(), view.mapFromScene(0, 0)); - QCOMPARE(view.viewport()->cursor().shape(), Qt::IBeamCursor); + QTRY_COMPARE(view.viewport()->cursor().shape(), Qt::IBeamCursor); sendMouseMove(view.viewport(), view.mapFromScene(-15, -15)); - QCOMPARE(view.viewport()->cursor().shape(), Qt::OpenHandCursor); + QTRY_COMPARE(view.viewport()->cursor().shape(), Qt::OpenHandCursor); view.setDragMode(QGraphicsView::NoDrag); - QCOMPARE(view.viewport()->cursor().shape(), Qt::ArrowCursor); + QTRY_COMPARE(view.viewport()->cursor().shape(), Qt::ArrowCursor); view.viewport()->setCursor(Qt::PointingHandCursor); - QCOMPARE(view.viewport()->cursor().shape(), Qt::PointingHandCursor); + QTRY_COMPARE(view.viewport()->cursor().shape(), Qt::PointingHandCursor); item2->setCursor(Qt::SizeAllCursor); sendMouseMove(view.viewport(), view.mapFromScene(-30, -30)); - QCOMPARE(view.viewport()->cursor().shape(), Qt::PointingHandCursor); + QTRY_COMPARE(view.viewport()->cursor().shape(), Qt::PointingHandCursor); sendMouseMove(view.viewport(), view.mapFromScene(-15, -15)); - QCOMPARE(view.viewport()->cursor().shape(), Qt::SizeAllCursor); + QTRY_COMPARE(view.viewport()->cursor().shape(), Qt::SizeAllCursor); sendMouseMove(view.viewport(), view.mapFromScene(0, 0)); - QCOMPARE(view.viewport()->cursor().shape(), Qt::IBeamCursor); + QTRY_COMPARE(view.viewport()->cursor().shape(), Qt::IBeamCursor); sendMouseMove(view.viewport(), view.mapFromScene(-15, -15)); - QCOMPARE(view.viewport()->cursor().shape(), Qt::SizeAllCursor); + QTRY_COMPARE(view.viewport()->cursor().shape(), Qt::SizeAllCursor); sendMouseMove(view.viewport(), view.mapFromScene(0, 0)); - QCOMPARE(view.viewport()->cursor().shape(), Qt::IBeamCursor); + QTRY_COMPARE(view.viewport()->cursor().shape(), Qt::IBeamCursor); sendMouseMove(view.viewport(), view.mapFromScene(-30, -30)); - QCOMPARE(view.viewport()->cursor().shape(), Qt::PointingHandCursor); + QTRY_COMPARE(view.viewport()->cursor().shape(), Qt::PointingHandCursor); view.setDragMode(QGraphicsView::ScrollHandDrag); sendMouseMove(view.viewport(), view.mapFromScene(-30, -30)); - QCOMPARE(view.viewport()->cursor().shape(), Qt::OpenHandCursor); + QTRY_COMPARE(view.viewport()->cursor().shape(), Qt::OpenHandCursor); sendMouseMove(view.viewport(), view.mapFromScene(0, 0)); - QCOMPARE(view.viewport()->cursor().shape(), Qt::IBeamCursor); + QTRY_COMPARE(view.viewport()->cursor().shape(), Qt::IBeamCursor); sendMouseMove(view.viewport(), view.mapFromScene(-15, -15)); - QCOMPARE(view.viewport()->cursor().shape(), Qt::SizeAllCursor); + QTRY_COMPARE(view.viewport()->cursor().shape(), Qt::SizeAllCursor); } #endif -- cgit v1.2.3 From 91ab70d17f892f3ff6b2019632fda3920d045dcb Mon Sep 17 00:00:00 2001 From: Timur Pocheptsov Date: Mon, 3 Jun 2019 16:16:14 +0200 Subject: tst_qnetworkreply - QSKIP/disable tests that deadlock on Windows We use global object to store errors found by q_X509Callback. Thus, we also use a lock/mutex. It would appear all tests involving in-process server and QNAM are prone to intermittent failures on our Windows VMs - it's always about timeouts due to the client socket (QNAM) locking and the server socket blocking main thread while trying to acquire the same lock. The real fix is to get rid of global variable/locking, we'll have it later (quite a change and requires a lot of accuracy). Task-number: QTBUG-76247 Change-Id: Iffc90d9e16783f17f62e836e01c35f22681bdd39 Reviewed-by: Timur Pocheptsov --- .../access/qnetworkreply/tst_qnetworkreply.cpp | 23 ++++++++++++++++++++++ 1 file changed, 23 insertions(+) (limited to 'tests/auto') diff --git a/tests/auto/network/access/qnetworkreply/tst_qnetworkreply.cpp b/tests/auto/network/access/qnetworkreply/tst_qnetworkreply.cpp index 8627a37e12..9a2c62b955 100644 --- a/tests/auto/network/access/qnetworkreply/tst_qnetworkreply.cpp +++ b/tests/auto/network/access/qnetworkreply/tst_qnetworkreply.cpp @@ -5031,6 +5031,9 @@ public: // very similar to ioPostToHttpUploadProgress but for SSL void tst_QNetworkReply::ioPostToHttpsUploadProgress() { +#ifdef Q_OS_WIN + QSKIP("QTBUG-76157: get rid of locking in TLS handshake (QSslSocket)"); +#endif //QFile sourceFile(testDataDir + "/bigfile"); //QVERIFY(sourceFile.open(QIODevice::ReadOnly)); qint64 wantedSize = 2*1024*1024; // 2 MB @@ -6412,6 +6415,10 @@ void tst_QNetworkReply::encrypted() void tst_QNetworkReply::abortOnEncrypted() { +#ifdef Q_OS_WIN + QSKIP("QTBUG-76157: get rid of locking in TLS handshake (QSslSocket)"); +#endif + SslServer server; server.listen(); if (!server.isListening()) @@ -8489,7 +8496,9 @@ void tst_QNetworkReply::ioHttpRedirectErrors_data() QTest::newRow("too-many-redirects") << "http://localhost" << tempRedirectReply << QNetworkReply::TooManyRedirectsError; #if QT_CONFIG(ssl) +#ifndef Q_OS_WIN // QTBUG-76157 QTest::newRow("insecure-redirect") << "https://localhost" << tempRedirectReply << QNetworkReply::InsecureRedirectError; +#endif // Q_OS_WIN #endif QTest::newRow("unknown-redirect") << "http://localhost"<< tempRedirectReply.replace("http", "bad_protocol") << QNetworkReply::ProtocolUnknownError; } @@ -8566,9 +8575,11 @@ void tst_QNetworkReply::ioHttpRedirectPolicy_data() QTest::newRow("nolesssafe-nossl") << QNetworkRequest::NoLessSafeRedirectPolicy << false << 1 << 200; QTest::newRow("same-origin-nossl") << QNetworkRequest::SameOriginRedirectPolicy << false << 1 << 200; #if QT_CONFIG(ssl) +#ifndef Q_OS_WIN // QTBUG-76157 QTest::newRow("manual-ssl") << QNetworkRequest::ManualRedirectPolicy << true << 0 << 307; QTest::newRow("nolesssafe-ssl") << QNetworkRequest::NoLessSafeRedirectPolicy << true << 1 << 200; QTest::newRow("same-origin-ssl") << QNetworkRequest::SameOriginRedirectPolicy << true << 1 << 200; +#endif // Q_OS_WIN #endif } @@ -8622,33 +8633,41 @@ void tst_QNetworkReply::ioHttpRedirectPolicyErrors_data() QTest::newRow("nolesssafe-nossl-nossl-too-many") << QNetworkRequest::NoLessSafeRedirectPolicy << false << QString("http://localhost:%1") << 0 << QNetworkReply::TooManyRedirectsError; #if QT_CONFIG(ssl) +#ifndef Q_OS_WIN // QTBUG-76157 QTest::newRow("nolesssafe-ssl-ssl-too-many") << QNetworkRequest::NoLessSafeRedirectPolicy << true << QString("https:/localhost:%1") << 0 << QNetworkReply::TooManyRedirectsError; QTest::newRow("nolesssafe-ssl-nossl-insecure-redirect") << QNetworkRequest::NoLessSafeRedirectPolicy << true << QString("http://localhost:%1") << 50 << QNetworkReply::InsecureRedirectError; +#endif // Q_OS_WIN #endif // 2. SameOriginRedirectsPolicy QTest::newRow("same-origin-nossl-nossl-too-many") << QNetworkRequest::SameOriginRedirectPolicy << false << QString("http://localhost:%1") << 0 << QNetworkReply::TooManyRedirectsError; #if QT_CONFIG(ssl) +#ifndef Q_OS_WIN // QTBUG-76157 QTest::newRow("same-origin-ssl-ssl-too-many") << QNetworkRequest::SameOriginRedirectPolicy << true << QString("https://localhost:%1") << 0 << QNetworkReply::TooManyRedirectsError; QTest::newRow("same-origin-https-http-wrong-protocol") << QNetworkRequest::SameOriginRedirectPolicy << true << QString("http://localhost:%1") << 50 << QNetworkReply::InsecureRedirectError; +#endif // Q_OS_WIN #endif QTest::newRow("same-origin-http-https-wrong-protocol") << QNetworkRequest::SameOriginRedirectPolicy << false << QString("https://localhost:%1") << 50 << QNetworkReply::InsecureRedirectError; QTest::newRow("same-origin-http-http-wrong-host") << QNetworkRequest::SameOriginRedirectPolicy << false << QString("http://not-so-localhost:%1") << 50 << QNetworkReply::InsecureRedirectError; #if QT_CONFIG(ssl) +#ifndef Q_OS_WIN // QTBUG-76157 QTest::newRow("same-origin-https-https-wrong-host") << QNetworkRequest::SameOriginRedirectPolicy << true << QString("https://not-so-localhost:%1") << 50 << QNetworkReply::InsecureRedirectError; +#endif // Q_OS_WIN #endif QTest::newRow("same-origin-http-http-wrong-port") << QNetworkRequest::SameOriginRedirectPolicy << false << QString("http://localhost/%1") << 50 << QNetworkReply::InsecureRedirectError; #if QT_CONFIG(ssl) +#ifndef Q_OS_WIN // QTBUG-76157 QTest::newRow("same-origin-https-https-wrong-port") << QNetworkRequest::SameOriginRedirectPolicy << true << QString("https://localhost/%1") << 50 << QNetworkReply::InsecureRedirectError; +#endif // Q_OS_WIN #endif } @@ -9123,6 +9142,10 @@ void tst_QNetworkReply::putWithServerClosingConnectionImmediately() for (int s = 0; s <= 1; s++) { withSsl = (s == 1); +#ifdef Q_OS_WIN + if (withSsl) + QSKIP("QTBUG-76157: get rid of locking in TLS handshake (QSslSocket)"); +#endif // Q_OS_WIN // Test also needs to run several times because of 9c2ecf89 for (int j = 0; j < 20; j++) { // emulate a minimal https server -- cgit v1.2.3 From 15d73a9f479e88af85944119e79d88ed26d4f346 Mon Sep 17 00:00:00 2001 From: Friedemann Kleint Date: Tue, 14 May 2019 14:20:08 +0200 Subject: Qt Widgets: Make tests pass on High DPI screens and scaling MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Use the comparison helpers to do fuzzy checking of geometries. Change-Id: I00f4403f3bca2e8a3996e938a85ba799e083058c Reviewed-by: Morten Johan Sørvig Reviewed-by: Richard Moe Gustavsen --- tests/auto/widgets/dialogs/qdialog/tst_qdialog.cpp | 5 ++++- tests/auto/widgets/dialogs/qwizard/tst_qwizard.cpp | 2 +- .../widgets/itemviews/qitemdelegate/tst_qitemdelegate.cpp | 11 ++++++++--- 3 files changed, 13 insertions(+), 5 deletions(-) (limited to 'tests/auto') diff --git a/tests/auto/widgets/dialogs/qdialog/tst_qdialog.cpp b/tests/auto/widgets/dialogs/qdialog/tst_qdialog.cpp index afe49368ae..c840dabc1a 100644 --- a/tests/auto/widgets/dialogs/qdialog/tst_qdialog.cpp +++ b/tests/auto/widgets/dialogs/qdialog/tst_qdialog.cpp @@ -26,6 +26,7 @@ ** ****************************************************************************/ +#include "../../../shared/highdpi.h" #include @@ -388,8 +389,10 @@ void tst_QDialog::toolDialogPosition() dialog.move(QPoint(100,100)); const QPoint beforeShowPosition = dialog.pos(); dialog.show(); + const int fuzz = int(dialog.devicePixelRatioF()); const QPoint afterShowPosition = dialog.pos(); - QCOMPARE(afterShowPosition, beforeShowPosition); + QVERIFY2(HighDpi::fuzzyCompare(afterShowPosition, beforeShowPosition, fuzz), + HighDpi::msgPointMismatch(afterShowPosition, beforeShowPosition).constData()); } class Dialog : public QDialog diff --git a/tests/auto/widgets/dialogs/qwizard/tst_qwizard.cpp b/tests/auto/widgets/dialogs/qwizard/tst_qwizard.cpp index a5b8646d40..63f6e67a3e 100644 --- a/tests/auto/widgets/dialogs/qwizard/tst_qwizard.cpp +++ b/tests/auto/widgets/dialogs/qwizard/tst_qwizard.cpp @@ -2551,7 +2551,7 @@ void tst_QWizard::task183550_stretchFactor() page2->enableVerticalExpansion(); wizard.next(); QCOMPARE(wizard.currentPage(), static_cast(page2)); - QVERIFY(page2->treeWidgetHeight() > page2->treeWidgetSizeHintHeight()); + QVERIFY(page2->treeWidgetHeight() >= page2->treeWidgetSizeHintHeight()); wizard.back(); QCOMPARE(wizard.currentPage(), static_cast(page1)); diff --git a/tests/auto/widgets/itemviews/qitemdelegate/tst_qitemdelegate.cpp b/tests/auto/widgets/itemviews/qitemdelegate/tst_qitemdelegate.cpp index aa11ed709f..961c8aa4ad 100644 --- a/tests/auto/widgets/itemviews/qitemdelegate/tst_qitemdelegate.cpp +++ b/tests/auto/widgets/itemviews/qitemdelegate/tst_qitemdelegate.cpp @@ -26,6 +26,7 @@ ** ****************************************************************************/ +#include "../../../shared/highdpi.h" #include @@ -51,6 +52,8 @@ #include #include +#include + #include Q_DECLARE_METATYPE(QAbstractItemDelegate::EndEditHint) @@ -223,8 +226,8 @@ private slots: void dateTextForRole_data(); void dateTextForRole(); -#ifdef QT_BUILD_INTERNAL private: +#ifdef QT_BUILD_INTERNAL struct RoleDelegate : public QItemDelegate { QString textForRole(Qt::ItemDataRole role, const QVariant &value, const QLocale &locale) @@ -234,6 +237,8 @@ private: } }; #endif + + const int m_fuzz = int(QGuiApplication::primaryScreen()->devicePixelRatio()); }; @@ -286,8 +291,8 @@ void tst_QItemDelegate::textRectangle() QFont font; TestItemDelegate delegate; QRect result = delegate.textRectangle(0, rect, font, text); - - QCOMPARE(result, expected); + QVERIFY2(HighDpi::fuzzyCompare(result, expected, m_fuzz), + HighDpi::msgRectMismatch(result, expected).constData()); } void tst_QItemDelegate::sizeHint_data() -- cgit v1.2.3 From 8c7589d992a5615fa3a98f67d098d5a2fca579cb Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jan=20Arve=20S=C3=A6ther?= Date: Wed, 29 May 2019 18:02:19 +0200 Subject: Do not strip off the fragment and query in the qfileselector This is needed for cases where we use e.g. "file:///test.html?query#Fragment". The fragment and query were already preserved for the qrc scheme. This fixes it for the file scheme. Change-Id: I5713e4a25372fdd55ac255b1c6228b4dea419244 Reviewed-by: Shawn Rutledge --- tests/auto/corelib/io/qfileselector/tst_qfileselector.cpp | 8 ++++++++ 1 file changed, 8 insertions(+) (limited to 'tests/auto') diff --git a/tests/auto/corelib/io/qfileselector/tst_qfileselector.cpp b/tests/auto/corelib/io/qfileselector/tst_qfileselector.cpp index c9f1e3d9f6..11b1fdaeeb 100644 --- a/tests/auto/corelib/io/qfileselector/tst_qfileselector.cpp +++ b/tests/auto/corelib/io/qfileselector/tst_qfileselector.cpp @@ -205,15 +205,23 @@ void tst_QFileSelector::urlConvenience_data() QString test("/test");// '/' is here so dir string can also be selector string QString custom1("custom1"); + QString testWithQueryAndFragment("/test?query#Fragment"); QTest::newRow("qrc") << QUrl("qrc:///extras/test") << (QStringList() << custom1) << QUrl(QString("qrc:///extras/") + QLatin1Char(selectorIndicator) + custom1 + test); + QTest::newRow("qrc with query and fragment") << QUrl(QString::fromLatin1("qrc:///extras%1").arg(testWithQueryAndFragment)) << (QStringList() << custom1) + << QUrl(QString("qrc:///extras/") + QLatin1Char(selectorIndicator) + custom1 + testWithQueryAndFragment); QString fileBasePath = QFINDTESTDATA("extras/test"); QString fileSelectedPath = QFINDTESTDATA(QString("extras/") + QLatin1Char(selectorIndicator) + custom1 + QString("/test")); QTest::newRow("file") << QUrl::fromLocalFile(fileBasePath) << (QStringList() << custom1) << QUrl::fromLocalFile(fileSelectedPath); + // do not strip off the query and fragment + QString strUrlWithFragment = QString("file://") + testWithQueryAndFragment; + QTest::newRow("file with query and fragment") << QUrl(strUrlWithFragment) << (QStringList()) << QUrl(strUrlWithFragment); + strUrlWithFragment = QString("file:") + testWithQueryAndFragment; + QTest::newRow("file with query and fragment too") << QUrl(strUrlWithFragment) << (QStringList()) << QUrl(strUrlWithFragment); // http://qt-project.org/images/qtdn/sprites-combined-latest.png is chosen as a representative real world URL // But note that this test is checking that http urls are NOT selected so it shouldn't be checked -- cgit v1.2.3 From 464b5278fa67e3867e4aed10bb3a698068449065 Mon Sep 17 00:00:00 2001 From: Friedemann Kleint Date: Fri, 17 May 2019 11:31:00 +0200 Subject: Brush up tst_QCompleter - Use nullptr - Fix warning about inconsistent parameter naming in CsvCompleter::pathFromIndex() - Fix C-style casts - Use range-based for - Use correct static invocation - Set a title on shown windows to make it possible to identify slow tests - Use initializer lists - Fix the class declarations, use override, member initializations - Remove goto, streamline code - Use auto to avoid repeating the type - Introduce std::unique_ptr Task-number: QTBUG-38014 Change-Id: Ia8ecd799064d630648b385b606848d7474c51363 Reviewed-by: Marc Mutz --- .../widgets/util/qcompleter/tst_qcompleter.cpp | 255 +++++++++++---------- 1 file changed, 129 insertions(+), 126 deletions(-) (limited to 'tests/auto') diff --git a/tests/auto/widgets/util/qcompleter/tst_qcompleter.cpp b/tests/auto/widgets/util/qcompleter/tst_qcompleter.cpp index ad64f1aef7..22f29a5e29 100644 --- a/tests/auto/widgets/util/qcompleter/tst_qcompleter.cpp +++ b/tests/auto/widgets/util/qcompleter/tst_qcompleter.cpp @@ -38,47 +38,50 @@ #include "../../../../shared/filesystem.h" +#include + +Q_DECLARE_METATYPE(QCompleter::CompletionMode) + using namespace QTestPrivate; class CsvCompleter : public QCompleter { Q_OBJECT public: - CsvCompleter(QObject *parent = 0) : QCompleter(parent), csv(true) { } + using QCompleter::QCompleter; - QString pathFromIndex(const QModelIndex& sourceIndex) const; + QString pathFromIndex(const QModelIndex& sourceIndex) const override; void setCsvCompletion(bool set) { csv = set; } protected: - QStringList splitPath(const QString &path) const { + QStringList splitPath(const QString &path) const override + { return csv ? path.split(QLatin1Char(',')) : QCompleter::splitPath(path); } private: - bool csv; + bool csv = true; }; -QString CsvCompleter::pathFromIndex(const QModelIndex& si) const +QString CsvCompleter::pathFromIndex(const QModelIndex &sourceIndex) const { if (!csv) - return QCompleter::pathFromIndex(si); + return QCompleter::pathFromIndex(sourceIndex); - if (!si.isValid()) + if (!sourceIndex.isValid()) return QString(); - QModelIndex idx = si; + QModelIndex idx = sourceIndex; QStringList list; do { QString t = model()->data(idx, completionRole()).toString(); list.prepend(t); QModelIndex parent = idx.parent(); - idx = parent.sibling(parent.row(), si.column()); + idx = parent.sibling(parent.row(), sourceIndex.column()); } while (idx.isValid()); - if (list.count() == 1) - return list[0]; - return list.join(','); + return list.count() == 1 ? list.constFirst() : list.join(QLatin1Char(',')); } class tst_QCompleter : public QObject @@ -154,15 +157,14 @@ private: }; void setSourceModel(ModelType); - CsvCompleter *completer; + CsvCompleter *completer = nullptr; QTreeWidget *treeWidget; - const int completionColumn; - const int columnCount; + const int completionColumn = 0; + const int columnCount = 3; }; -tst_QCompleter::tst_QCompleter() : completer(0), completionColumn(0), columnCount(3) +tst_QCompleter::tst_QCompleter() : treeWidget(new QTreeWidget) { - treeWidget = new QTreeWidget; treeWidget->move(100, 100); treeWidget->setColumnCount(columnCount); } @@ -184,11 +186,11 @@ void tst_QCompleter::setSourceModel(ModelType type) for (int i = 0; i < 2; i++) { for (int j = 0; j < 5; j++) { parent = new QTreeWidgetItem(treeWidget); - const QString text = QString::asprintf("%c%i", i == 0 ? 'P' : 'p', j); + const QString text = QLatin1Char(i == 0 ? 'P' : 'p') + QString::number(j); parent->setText(completionColumn, text); for (int k = 0; k < 5; k++) { child = new QTreeWidgetItem(parent); - QString t = QString::asprintf("c%i", k) + text; + QString t = QLatin1Char('c') + QString::number(k) + text; child->setText(completionColumn, t); } } @@ -203,11 +205,11 @@ void tst_QCompleter::setSourceModel(ModelType type) for (int i = 0; i < 5; i++) { for (int j = 0; j < 2; j++) { parent = new QTreeWidgetItem(treeWidget); - const QString text = QString::asprintf("%c%i", j == 0 ? 'P' : 'p', i); + const QString text = QLatin1Char(j == 0 ? 'P' : 'p') + QString::number(i); parent->setText(completionColumn, text); for (int k = 0; k < 5; k++) { child = new QTreeWidgetItem(parent); - QString t = QString::asprintf("c%i", k) + text; + QString t = QLatin1Char('c') + QString::number(k) + text; child->setText(completionColumn, t); } } @@ -229,7 +231,7 @@ void tst_QCompleter::setSourceModel(ModelType type) case FILESYSTEM_MODEL: completer->setCsvCompletion(false); { - QFileSystemModel *m = new QFileSystemModel(completer); + auto m = new QFileSystemModel(completer); m->setRootPath("/"); completer->setModel(m); } @@ -237,13 +239,14 @@ void tst_QCompleter::setSourceModel(ModelType type) break; default: qDebug() << "Invalid type"; + break; } } void tst_QCompleter::filter(bool assync) { QFETCH(QString, filterText); - QFETCH(QString, step); + QFETCH(const QString, step); QFETCH(QString, completion); QFETCH(QString, completionText); @@ -252,33 +255,43 @@ void tst_QCompleter::filter(bool assync) return; } - int times = 0; -retry: - - completer->setCompletionPrefix(filterText); - - for (int i = 0; i < step.length(); i++) { - int row = completer->currentRow(); - switch (step[i].toUpper().toLatin1()) { - case 'P': --row; break; - case 'N': ++row; break; - case 'L': row = completer->completionCount() - 1; break; - case 'F': row = 0; break; - default: - QFAIL(qPrintable(QString( - "Problem with 'step' value in test data: %1 (only P, N, L and F are allowed)." - ).arg(step[i]))); + int result = -1; + const int attempts = assync ? 10 : 1; + for (int times = 0; times < attempts; ++times) { + completer->setCompletionPrefix(filterText); + + for (QChar s : step) { + int row = completer->currentRow(); + switch (s.toUpper().toLatin1()) { + case 'P': + --row; + break; + case 'N': + ++row; + break; + case 'L': + row = completer->completionCount() - 1; + break; + case 'F': + row = 0; + break; + default: + QFAIL(qPrintable(QString( + "Problem with 'step' value in test data: %1 (only P, N, L and F are allowed)." + ).arg(s))); + } + completer->setCurrentRow(row); } - completer->setCurrentRow(row); - } - int r = QString::compare(completer->currentCompletion(), completionText, completer->caseSensitivity()); - if (assync && r && times < 10) { - times++; - QTest::qWait(50*times); - goto retry; + result = QString::compare(completer->currentCompletion(), completionText, + completer->caseSensitivity()); + if (result == 0) + break; + if (assync) + QTest::qWait(50 * times); } - QVERIFY(!r); + + QCOMPARE(result, 0); } // Testing get/set functions @@ -844,8 +857,7 @@ void tst_QCompleter::sortedEngineMapFromSource() QModelIndex si1, si2, pi; QAbstractItemModel *sourceModel = completer->model(); - const QAbstractProxyModel *completionModel = - qobject_cast(completer->completionModel()); + auto completionModel = qobject_cast(completer->completionModel()); // Fitering ON // empty @@ -915,8 +927,7 @@ void tst_QCompleter::unsortedEngineMapFromSource() QModelIndex si, si2, si3, pi; QAbstractItemModel *sourceModel = completer->model(); - const QAbstractProxyModel *completionModel = - qobject_cast(completer->completionModel()); + auto completionModel = qobject_cast(completer->completionModel()); si = sourceModel->index(6, completionColumn); // "P3" QCOMPARE(si.data().toString(), QLatin1String("P3")); @@ -997,8 +1008,7 @@ void tst_QCompleter::historySearch() completer->setCaseSensitivity(Qt::CaseSensitive); setSourceModel(HISTORY_MODEL); - const QAbstractProxyModel *completionModel = - qobject_cast(completer->completionModel()); + auto completionModel = qobject_cast(completer->completionModel()); // "p3,c3p3" and "p2,c4p2" are added in the tree root @@ -1046,7 +1056,7 @@ void tst_QCompleter::setters() { delete completer; completer = new CsvCompleter; - QVERIFY(completer->popup() != 0); + QVERIFY(completer->popup() != nullptr); QPointer dirModel = new QDirModel(completer); QAbstractItemModel *oldModel = completer->model(); completer->setModel(dirModel); @@ -1055,28 +1065,28 @@ void tst_QCompleter::setters() completer->setPopup(new QListView); QCOMPARE(completer->popup()->model(), completer->completionModel()); completer->setModel(new QStringListModel(completer)); - QVERIFY(dirModel == 0); // must have been deleted + QVERIFY(dirModel == nullptr); // must have been deleted - completer->setModel(0); - completer->setWidget(0); + completer->setModel(nullptr); + completer->setWidget(nullptr); } void tst_QCompleter::modelDeletion() { delete completer; completer = new CsvCompleter; - QStringList list; - list << "item1" << "item2" << "item3"; - QStringListModel *listModel = new QStringListModel(list); + const QStringList list = {"item1", "item2", "item3"}; + std::unique_ptr listModel(new QStringListModel(list)); completer->setCompletionPrefix("i"); - completer->setModel(listModel); + completer->setModel(listModel.get()); QCOMPARE(completer->completionCount(), 3); - QScopedPointer view(new QListView); + std::unique_ptr view(new QListView); + view->setWindowTitle(QLatin1String(QTest::currentTestFunction())); view->setModel(completer->completionModel()); - delete listModel; + listModel.reset(); view->move(200, 200); view->show(); - qApp->processEvents(); + QCoreApplication::processEvents(); view.reset(); QCOMPARE(completer->completionCount(), 0); QCOMPARE(completer->currentRow(), -1); @@ -1090,6 +1100,7 @@ void tst_QCompleter::multipleWidgets() completer.setCompletionMode(QCompleter::InlineCompletion); QWidget window; + window.setWindowTitle(QLatin1String(QTest::currentTestFunction())); window.move(200, 200); window.show(); QApplication::setActiveWindow(&window); @@ -1098,7 +1109,7 @@ void tst_QCompleter::multipleWidgets() QFocusEvent focusIn(QEvent::FocusIn); QFocusEvent focusOut(QEvent::FocusOut); - QComboBox *comboBox = new QComboBox(&window); + auto comboBox = new QComboBox(&window); comboBox->setEditable(true); comboBox->setCompleter(&completer); comboBox->setFocus(); @@ -1114,7 +1125,7 @@ void tst_QCompleter::multipleWidgets() comboBox->clearEditText(); QCOMPARE(comboBox->currentText(), QString("")); // combo box text must not change! - QLineEdit *lineEdit = new QLineEdit(&window); + auto lineEdit = new QLineEdit(&window); lineEdit->setCompleter(&completer); lineEdit->show(); lineEdit->setFocus(); @@ -1129,29 +1140,28 @@ void tst_QCompleter::multipleWidgets() void tst_QCompleter::focusIn() { - QStringList list; - list << "item1" << "item2" << "item2"; - QCompleter completer(list); + QCompleter completer({"item1", "item2", "item2"}); QWidget window; + window.setWindowTitle(QLatin1String(QTest::currentTestFunction())); window.move(200, 200); window.show(); window.activateWindow(); QApplication::setActiveWindow(&window); QVERIFY(QTest::qWaitForWindowActive(&window)); - QComboBox *comboBox = new QComboBox(&window); + auto comboBox = new QComboBox(&window); comboBox->setEditable(true); comboBox->setCompleter(&completer); comboBox->show(); comboBox->lineEdit()->setText("it"); - QLineEdit *lineEdit = new QLineEdit(&window); + auto lineEdit = new QLineEdit(&window); lineEdit->setCompleter(&completer); lineEdit->setText("it"); lineEdit->show(); - QLineEdit *lineEdit2 = new QLineEdit(&window); // has no completer! + auto lineEdit2 = new QLineEdit(&window); // has no completer! lineEdit2->show(); comboBox->setFocus(); @@ -1190,12 +1200,13 @@ void tst_QCompleter::dynamicSortOrder() void tst_QCompleter::disabledItems() { QLineEdit lineEdit; - QStandardItemModel *model = new QStandardItemModel(&lineEdit); + lineEdit.setWindowTitle(QLatin1String(QTest::currentTestFunction())); + auto model = new QStandardItemModel(&lineEdit); QStandardItem *suggestions = new QStandardItem("suggestions"); suggestions->setEnabled(false); model->appendRow(suggestions); model->appendRow(new QStandardItem("suggestions Enabled")); - QCompleter *completer = new QCompleter(model, &lineEdit); + auto completer = new QCompleter(model, &lineEdit); QSignalSpy spy(completer, QOverload::of(&QCompleter::activated)); lineEdit.setCompleter(completer); lineEdit.move(200, 200); @@ -1206,42 +1217,40 @@ void tst_QCompleter::disabledItems() QTest::keyPress(&lineEdit, Qt::Key_U); QAbstractItemView *view = lineEdit.completer()->popup(); QVERIFY(view->isVisible()); - QTest::mouseClick(view->viewport(), Qt::LeftButton, 0, view->visualRect(view->model()->index(0, 0)).center()); + QTest::mouseClick(view->viewport(), Qt::LeftButton, {}, view->visualRect(view->model()->index(0, 0)).center()); QCOMPARE(spy.count(), 0); QVERIFY(view->isVisible()); - QTest::mouseClick(view->viewport(), Qt::LeftButton, 0, view->visualRect(view->model()->index(1, 0)).center()); + QTest::mouseClick(view->viewport(), Qt::LeftButton, {}, view->visualRect(view->model()->index(1, 0)).center()); QCOMPARE(spy.count(), 1); QVERIFY(!view->isVisible()); } void tst_QCompleter::task178797_activatedOnReturn() { - QStringList words; - words << "foobar1" << "foobar2"; QLineEdit ledit; setFrameless(&ledit); - QCompleter *completer = new QCompleter(words, &ledit); + auto completer = new QCompleter({"foobar1", "foobar2"}, &ledit); ledit.setCompleter(completer); QSignalSpy spy(completer, QOverload::of(&QCompleter::activated)); QCOMPARE(spy.count(), 0); ledit.move(200, 200); ledit.show(); - qApp->setActiveWindow(&ledit); + QApplication::setActiveWindow(&ledit); QVERIFY(QTest::qWaitForWindowActive(&ledit)); QTest::keyClick(&ledit, Qt::Key_F); - qApp->processEvents(); - QTRY_VERIFY(qApp->activePopupWidget()); - QTest::keyClick(qApp->activePopupWidget(), Qt::Key_Down); - qApp->processEvents(); - QTest::keyClick(qApp->activePopupWidget(), Qt::Key_Return); - qApp->processEvents(); + QCoreApplication::processEvents(); + QTRY_VERIFY(QApplication::activePopupWidget()); + QTest::keyClick(QApplication::activePopupWidget(), Qt::Key_Down); + QCoreApplication::processEvents(); + QTest::keyClick(QApplication::activePopupWidget(), Qt::Key_Return); + QCoreApplication::processEvents(); QCOMPARE(spy.count(), 1); } class task189564_StringListModel : public QStringListModel { const QString omitString; - Qt::ItemFlags flags(const QModelIndex &index) const + Qt::ItemFlags flags(const QModelIndex &index) const override { Qt::ItemFlags flags = Qt::ItemIsEnabled; if (data(index, Qt::DisplayRole).toString() != omitString) @@ -1249,7 +1258,7 @@ class task189564_StringListModel : public QStringListModel return flags; } public: - task189564_StringListModel(const QString &omitString, QObject *parent = 0) + explicit task189564_StringListModel(const QString &omitString, QObject *parent = nullptr) : QStringListModel(parent) , omitString(omitString) { @@ -1315,8 +1324,7 @@ void tst_QCompleter::task246056_setCompletionPrefix() QTest::keyPress(comboBox.completer()->popup(), Qt::Key_Down); QTest::keyPress(comboBox.completer()->popup(), Qt::Key_Enter); // don't crash! QCOMPARE(spy.count(), 1); - QList arguments = spy.at(0); - QModelIndex index = arguments.at(0).value(); + const auto index = spy.at(0).constFirst().toModelIndex(); QVERIFY(!index.isValid()); } @@ -1331,7 +1339,7 @@ public: completer->setWidget(this); } - void keyPressEvent (QKeyEvent *e) + void keyPressEvent (QKeyEvent *e) override { completer->popup(); QTextEdit::keyPressEvent(e); @@ -1344,11 +1352,11 @@ class task250064_Widget : public QWidget public: task250064_Widget() : m_textEdit(new task250064_TextEdit) { - QTabWidget *tabWidget = new QTabWidget; + auto tabWidget = new QTabWidget; tabWidget->setFocusPolicy(Qt::ClickFocus); tabWidget->addTab(m_textEdit, "untitled"); - QVBoxLayout *layout = new QVBoxLayout(this); + auto layout = new QVBoxLayout(this); layout->addWidget(tabWidget); m_textEdit->setPlainText("bla bla bla"); @@ -1357,7 +1365,7 @@ public: void setCompletionModel() { - m_textEdit->completer->setModel(0); + m_textEdit->completer->setModel(nullptr); } QTextEdit *textEdit() const { return m_textEdit; } @@ -1369,6 +1377,7 @@ private: void tst_QCompleter::task250064_lostFocus() { task250064_Widget widget; + widget.setWindowTitle(QLatin1String(QTest::currentTestFunction())); widget.show(); QApplication::setActiveWindow(&widget); QVERIFY(QTest::qWaitForWindowActive(&widget)); @@ -1382,33 +1391,33 @@ void tst_QCompleter::task250064_lostFocus() void tst_QCompleter::task253125_lineEditCompletion_data() { QTest::addColumn("list"); - QTest::addColumn("completionMode"); + QTest::addColumn("completionMode"); - QStringList list = QStringList() - << "alpha" << "beta" << "gamma" << "delta" << "epsilon" << "zeta" - << "eta" << "theta" << "iota" << "kappa" << "lambda" << "mu" - << "nu" << "xi" << "omicron" << "pi" << "rho" << "sigma" - << "tau" << "upsilon" << "phi" << "chi" << "psi" << "omega"; + QStringList list = {"alpha", "beta", "gamma", "delta", "epsilon", "zeta", + "eta", "theta", "iota", "kappa", "lambda", "mu", + "nu", "xi", "omicron", "pi", "rho", "sigma", + "tau", "upsilon", "phi", "chi", "psi", "omega"}; - QTest::newRow("Inline") << list << (int)QCompleter::InlineCompletion; - QTest::newRow("Filtered") << list << (int)QCompleter::PopupCompletion; - QTest::newRow("Unfiltered") << list << (int)QCompleter::UnfilteredPopupCompletion; + QTest::newRow("Inline") << list << QCompleter::InlineCompletion; + QTest::newRow("Filtered") << list << QCompleter::PopupCompletion; + QTest::newRow("Unfiltered") << list << QCompleter::UnfilteredPopupCompletion; } void tst_QCompleter::task253125_lineEditCompletion() { QFETCH(QStringList, list); - QFETCH(int, completionMode); + QFETCH(QCompleter::CompletionMode, completionMode); - QStringListModel *model = new QStringListModel; - model->setStringList(list); + std::unique_ptr model(new QStringListModel(list)); - QCompleter *completer = new QCompleter(list); - completer->setModel(model); - completer->setCompletionMode((QCompleter::CompletionMode)completionMode); + std::unique_ptr completer(new QCompleter(list)); + completer->setModel(model.get()); + completer->setCompletionMode(completionMode); QLineEdit edit; - edit.setCompleter(completer); + edit.setWindowTitle(QLatin1String(QTest::currentTestFunction()) + QLatin1String("::") + + QLatin1String(QTest::currentDataTag())); + edit.setCompleter(completer.get()); edit.move(200, 200); edit.show(); edit.setFocus(); @@ -1550,9 +1559,6 @@ void tst_QCompleter::task253125_lineEditCompletion() QTest::keyClick(edit.completer()->popup(), Qt::Key_Enter); QCOMPARE(edit.text(), QString("zz")); - - delete completer; - delete model; } void tst_QCompleter::task247560_keyboardNavigation() @@ -1570,6 +1576,7 @@ void tst_QCompleter::task247560_keyboardNavigation() completer.setCompletionColumn(1); QLineEdit edit; + edit.setWindowTitle(QLatin1String(QTest::currentTestFunction())); edit.setCompleter(&completer); edit.move(200, 200); edit.show(); @@ -1688,6 +1695,7 @@ void tst_QCompleter::QTBUG_14292_filesystem() QVERIFY(fs.createDirectory(QLatin1String(testDir2))); QLineEdit edit; + edit.setWindowTitle(QLatin1String(QTest::currentTestFunction())); QCompleter comp; comp.setModel(&model); edit.setCompleter(&comp); @@ -1750,16 +1758,14 @@ void tst_QCompleter::QTBUG_14292_filesystem() void tst_QCompleter::QTBUG_52028_tabAutoCompletes() { - QStringList words; - words << "foobar1" << "foobar2" << "hux"; - QWidget w; + w.setWindowTitle(QLatin1String(QTest::currentTestFunction())); w.setLayout(new QVBoxLayout); QComboBox cbox; cbox.setEditable(true); cbox.setInsertPolicy(QComboBox::NoInsert); - cbox.addItems(words); + cbox.addItems({"foobar1", "foobar2", "hux"}); cbox.completer()->setCaseSensitivity(Qt::CaseInsensitive); cbox.completer()->setCompletionMode(QCompleter::PopupCompletion); @@ -1767,8 +1773,8 @@ void tst_QCompleter::QTBUG_52028_tabAutoCompletes() w.layout()->addWidget(&cbox); // Adding a line edit is a good reason for tab to do something unrelated - QLineEdit le; - w.layout()->addWidget(&le); + auto le = new QLineEdit; + w.layout()->addWidget(le); const auto pos = QApplication::desktop()->availableGeometry(&w).topLeft() + QPoint(200,200); w.move(pos); @@ -1789,30 +1795,27 @@ void tst_QCompleter::QTBUG_52028_tabAutoCompletes() QEXPECT_FAIL("", "QTBUG-52028 will not be fixed today.", Abort); QCOMPARE(cbox.currentText(), QLatin1String("hux")); QCOMPARE(activatedSpy.count(), 0); - QVERIFY(!le.hasFocus()); + QVERIFY(!le->hasFocus()); } void tst_QCompleter::QTBUG_51889_activatedSentTwice() { - QStringList words; - words << "foobar1" << "foobar2" << "bar" <<"hux"; - QWidget w; + w.setWindowTitle(QLatin1String(QTest::currentTestFunction())); w.setLayout(new QVBoxLayout); QComboBox cbox; setFrameless(&cbox); cbox.setEditable(true); cbox.setInsertPolicy(QComboBox::NoInsert); - cbox.addItems(words); + cbox.addItems({"foobar1", "foobar2", "bar", "hux"}); cbox.completer()->setCaseSensitivity(Qt::CaseInsensitive); cbox.completer()->setCompletionMode(QCompleter::PopupCompletion); w.layout()->addWidget(&cbox); - QLineEdit le; - w.layout()->addWidget(&le); + w.layout()->addWidget(new QLineEdit); const auto pos = QApplication::desktop()->availableGeometry(&w).topLeft() + QPoint(200,200); w.move(pos); -- cgit v1.2.3 From a4f79313f065815451610dabdbbb33b8a35f0a86 Mon Sep 17 00:00:00 2001 From: Eirik Aavitsland Date: Mon, 3 Jun 2019 14:45:07 +0200 Subject: Fix: QTextDocument::find backward search crossing paragraphs If the start position of a backward string search was the at the start of a paragraph, the code would start searching at an illegal position (at the eol character) in the preceding paragraph. That caused that whole paragraph to be skipped, so any matches there would not be found. Fix by making sure the search starts at legal position. Fixes: QTBUG-48035 Change-Id: Id6c0159b6613ec75ec617a0a57096ceef2b4cbd0 Reviewed-by: Konstantin Ritt --- tests/auto/gui/text/qtextdocument/tst_qtextdocument.cpp | 9 +++++++++ 1 file changed, 9 insertions(+) (limited to 'tests/auto') diff --git a/tests/auto/gui/text/qtextdocument/tst_qtextdocument.cpp b/tests/auto/gui/text/qtextdocument/tst_qtextdocument.cpp index 3f602f5aae..32131352c3 100644 --- a/tests/auto/gui/text/qtextdocument/tst_qtextdocument.cpp +++ b/tests/auto/gui/text/qtextdocument/tst_qtextdocument.cpp @@ -319,6 +319,15 @@ void tst_QTextDocument::find_data() QTest::newRow("nbsp") << "Hello" + QString(QChar(QChar::Nbsp)) +"World" << " " << int(QTextDocument::FindCaseSensitively) << 0 << 5 << 6; QTest::newRow("from-the-end") << "Hello World" << "Hello World" << int(QTextDocument::FindCaseSensitively| QTextDocument::FindBackward) << 11 << 0 << 11; + + QTest::newRow("bw-cross-paras-1") << "a1\na2\nb1" << "a" << int(QTextDocument::FindBackward) << 7 << 3 << 4; + QTest::newRow("bw-cross-paras-2") << "a1\na2\nb1" << "a" << int(QTextDocument::FindBackward) << 6 << 3 << 4; + QTest::newRow("bw-cross-paras-3") << "a1\na2\nb1" << "a" << int(QTextDocument::FindBackward) << 5 << 3 << 4; + QTest::newRow("bw-cross-paras-4") << "a1\na2\nb1" << "a" << int(QTextDocument::FindBackward) << 3 << 0 << 1; + QTest::newRow("bw-cross-paras-5") << "xa\n\nb1" << "a" << int(QTextDocument::FindBackward) << 5 << 1 << 2; + QTest::newRow("bw-cross-paras-6") << "xa\n\nb1" << "a" << int(QTextDocument::FindBackward) << 4 << 1 << 2; + QTest::newRow("bw-cross-paras-7") << "xa\n\nb1" << "a" << int(QTextDocument::FindBackward) << 3 << 1 << 2; + QTest::newRow("bw-cross-paras-8") << "xa\n\nb1" << "a" << int(QTextDocument::FindBackward) << 2 << 1 << 2; } void tst_QTextDocument::find() -- cgit v1.2.3 From c6763ec1491e62b9d45179906cf4c05cdf794a85 Mon Sep 17 00:00:00 2001 From: Timur Pocheptsov Date: Mon, 3 Jun 2019 16:16:14 +0200 Subject: tst_qnetworkreply - QSKIP/disable tests that deadlock on Windows MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit We use global object to store errors found by q_X509Callback. Thus, we also use a lock/mutex. It would appear all tests involving in-process server and QNAM are prone to intermittent failures on our Windows VMs - it's always about timeouts due to the client socket (QNAM) locking and the server socket blocking main thread while trying to acquire the same lock. The real fix is to re-write our verification callback so that it does not need locking/does not block the main and 'http' threads as a result. But such change is too dangerous for 5.13.0 so we instead have a somewhat handicapped/reduced test on Windows. The fixed QSSlSocket will go into 5.13. Task-number: QTBUG-76157 Change-Id: Ia54701bcb3f6f079a69e52c8904ac3efcee4a787 Reviewed-by: Mårten Nordheim --- .../access/qnetworkreply/tst_qnetworkreply.cpp | 23 ++++++++++++++++++++++ 1 file changed, 23 insertions(+) (limited to 'tests/auto') diff --git a/tests/auto/network/access/qnetworkreply/tst_qnetworkreply.cpp b/tests/auto/network/access/qnetworkreply/tst_qnetworkreply.cpp index 8627a37e12..9a2c62b955 100644 --- a/tests/auto/network/access/qnetworkreply/tst_qnetworkreply.cpp +++ b/tests/auto/network/access/qnetworkreply/tst_qnetworkreply.cpp @@ -5031,6 +5031,9 @@ public: // very similar to ioPostToHttpUploadProgress but for SSL void tst_QNetworkReply::ioPostToHttpsUploadProgress() { +#ifdef Q_OS_WIN + QSKIP("QTBUG-76157: get rid of locking in TLS handshake (QSslSocket)"); +#endif //QFile sourceFile(testDataDir + "/bigfile"); //QVERIFY(sourceFile.open(QIODevice::ReadOnly)); qint64 wantedSize = 2*1024*1024; // 2 MB @@ -6412,6 +6415,10 @@ void tst_QNetworkReply::encrypted() void tst_QNetworkReply::abortOnEncrypted() { +#ifdef Q_OS_WIN + QSKIP("QTBUG-76157: get rid of locking in TLS handshake (QSslSocket)"); +#endif + SslServer server; server.listen(); if (!server.isListening()) @@ -8489,7 +8496,9 @@ void tst_QNetworkReply::ioHttpRedirectErrors_data() QTest::newRow("too-many-redirects") << "http://localhost" << tempRedirectReply << QNetworkReply::TooManyRedirectsError; #if QT_CONFIG(ssl) +#ifndef Q_OS_WIN // QTBUG-76157 QTest::newRow("insecure-redirect") << "https://localhost" << tempRedirectReply << QNetworkReply::InsecureRedirectError; +#endif // Q_OS_WIN #endif QTest::newRow("unknown-redirect") << "http://localhost"<< tempRedirectReply.replace("http", "bad_protocol") << QNetworkReply::ProtocolUnknownError; } @@ -8566,9 +8575,11 @@ void tst_QNetworkReply::ioHttpRedirectPolicy_data() QTest::newRow("nolesssafe-nossl") << QNetworkRequest::NoLessSafeRedirectPolicy << false << 1 << 200; QTest::newRow("same-origin-nossl") << QNetworkRequest::SameOriginRedirectPolicy << false << 1 << 200; #if QT_CONFIG(ssl) +#ifndef Q_OS_WIN // QTBUG-76157 QTest::newRow("manual-ssl") << QNetworkRequest::ManualRedirectPolicy << true << 0 << 307; QTest::newRow("nolesssafe-ssl") << QNetworkRequest::NoLessSafeRedirectPolicy << true << 1 << 200; QTest::newRow("same-origin-ssl") << QNetworkRequest::SameOriginRedirectPolicy << true << 1 << 200; +#endif // Q_OS_WIN #endif } @@ -8622,33 +8633,41 @@ void tst_QNetworkReply::ioHttpRedirectPolicyErrors_data() QTest::newRow("nolesssafe-nossl-nossl-too-many") << QNetworkRequest::NoLessSafeRedirectPolicy << false << QString("http://localhost:%1") << 0 << QNetworkReply::TooManyRedirectsError; #if QT_CONFIG(ssl) +#ifndef Q_OS_WIN // QTBUG-76157 QTest::newRow("nolesssafe-ssl-ssl-too-many") << QNetworkRequest::NoLessSafeRedirectPolicy << true << QString("https:/localhost:%1") << 0 << QNetworkReply::TooManyRedirectsError; QTest::newRow("nolesssafe-ssl-nossl-insecure-redirect") << QNetworkRequest::NoLessSafeRedirectPolicy << true << QString("http://localhost:%1") << 50 << QNetworkReply::InsecureRedirectError; +#endif // Q_OS_WIN #endif // 2. SameOriginRedirectsPolicy QTest::newRow("same-origin-nossl-nossl-too-many") << QNetworkRequest::SameOriginRedirectPolicy << false << QString("http://localhost:%1") << 0 << QNetworkReply::TooManyRedirectsError; #if QT_CONFIG(ssl) +#ifndef Q_OS_WIN // QTBUG-76157 QTest::newRow("same-origin-ssl-ssl-too-many") << QNetworkRequest::SameOriginRedirectPolicy << true << QString("https://localhost:%1") << 0 << QNetworkReply::TooManyRedirectsError; QTest::newRow("same-origin-https-http-wrong-protocol") << QNetworkRequest::SameOriginRedirectPolicy << true << QString("http://localhost:%1") << 50 << QNetworkReply::InsecureRedirectError; +#endif // Q_OS_WIN #endif QTest::newRow("same-origin-http-https-wrong-protocol") << QNetworkRequest::SameOriginRedirectPolicy << false << QString("https://localhost:%1") << 50 << QNetworkReply::InsecureRedirectError; QTest::newRow("same-origin-http-http-wrong-host") << QNetworkRequest::SameOriginRedirectPolicy << false << QString("http://not-so-localhost:%1") << 50 << QNetworkReply::InsecureRedirectError; #if QT_CONFIG(ssl) +#ifndef Q_OS_WIN // QTBUG-76157 QTest::newRow("same-origin-https-https-wrong-host") << QNetworkRequest::SameOriginRedirectPolicy << true << QString("https://not-so-localhost:%1") << 50 << QNetworkReply::InsecureRedirectError; +#endif // Q_OS_WIN #endif QTest::newRow("same-origin-http-http-wrong-port") << QNetworkRequest::SameOriginRedirectPolicy << false << QString("http://localhost/%1") << 50 << QNetworkReply::InsecureRedirectError; #if QT_CONFIG(ssl) +#ifndef Q_OS_WIN // QTBUG-76157 QTest::newRow("same-origin-https-https-wrong-port") << QNetworkRequest::SameOriginRedirectPolicy << true << QString("https://localhost/%1") << 50 << QNetworkReply::InsecureRedirectError; +#endif // Q_OS_WIN #endif } @@ -9123,6 +9142,10 @@ void tst_QNetworkReply::putWithServerClosingConnectionImmediately() for (int s = 0; s <= 1; s++) { withSsl = (s == 1); +#ifdef Q_OS_WIN + if (withSsl) + QSKIP("QTBUG-76157: get rid of locking in TLS handshake (QSslSocket)"); +#endif // Q_OS_WIN // Test also needs to run several times because of 9c2ecf89 for (int j = 0; j < 20; j++) { // emulate a minimal https server -- cgit v1.2.3