diff options
Diffstat (limited to 'tests/auto')
52 files changed, 632 insertions, 174 deletions
diff --git a/tests/auto/corelib/global/qrandomgenerator/tst_qrandomgenerator.cpp b/tests/auto/corelib/global/qrandomgenerator/tst_qrandomgenerator.cpp index bf43f6d710..2195bf8ec8 100644 --- a/tests/auto/corelib/global/qrandomgenerator/tst_qrandomgenerator.cpp +++ b/tests/auto/corelib/global/qrandomgenerator/tst_qrandomgenerator.cpp @@ -34,11 +34,9 @@ #include <private/qrandom_p.h> #include <algorithm> -#if QT_CONFIG(cxx11_random) -# include <random> -#endif +#include <random> -#if !QT_CONFIG(getentropy) && (QT_CONFIG(cxx11_random) || defined(Q_OS_BSD4) || defined(Q_OS_WIN)) +#if !QT_CONFIG(getentropy) && (defined(Q_OS_BSD4) || defined(Q_OS_WIN)) # define HAVE_FALLBACK_ENGINE #endif @@ -468,9 +466,6 @@ template <typename Engine> void seedStdRandomEngine() void tst_QRandomGenerator::seedStdRandomEngines() { -#if !QT_CONFIG(cxx11_random) - QSKIP("<random> not found"); -#else seedStdRandomEngine<std::default_random_engine>(); seedStdRandomEngine<std::minstd_rand0>(); seedStdRandomEngine<std::minstd_rand>(); @@ -480,7 +475,6 @@ void tst_QRandomGenerator::seedStdRandomEngines() seedStdRandomEngine<std::ranlux48_base>(); seedStdRandomEngine<std::ranlux24>(); seedStdRandomEngine<std::ranlux48>(); -#endif } void tst_QRandomGenerator::stdUniformIntDistribution_data() @@ -511,9 +505,6 @@ void tst_QRandomGenerator::stdUniformIntDistribution_data() void tst_QRandomGenerator::stdUniformIntDistribution() { -#if !QT_CONFIG(cxx11_random) - QSKIP("<random> not found"); -#else QFETCH(uint, control); QFETCH(quint32, max); setRNGControl(control & (SkipHWRNG|SkipSystemRNG|SkipMemfill)); @@ -575,14 +566,11 @@ void tst_QRandomGenerator::stdUniformIntDistribution() QVERIFY(value <= dist.max()); } } -#endif } void tst_QRandomGenerator::stdGenerateCanonical() { -#if !QT_CONFIG(cxx11_random) - QSKIP("<random> not found"); -#elif defined(Q_CC_MSVC) && Q_CC_MSVC < 1900 +#if defined(Q_CC_MSVC) && Q_CC_MSVC < 1900 // see https://connect.microsoft.com/VisualStudio/feedback/details/811611 QSKIP("MSVC 2013's std::generate_canonical is broken"); #else @@ -634,9 +622,6 @@ void tst_QRandomGenerator::stdUniformRealDistribution_data() void tst_QRandomGenerator::stdUniformRealDistribution() { -#if !QT_CONFIG(cxx11_random) - QSKIP("<random> not found"); -#else QFETCH(uint, control); QFETCH(double, min); QFETCH(double, sup); @@ -663,14 +648,10 @@ void tst_QRandomGenerator::stdUniformRealDistribution() QVERIFY(value < dist.max()); } } -#endif } void tst_QRandomGenerator::stdRandomDistributions() { -#if !QT_CONFIG(cxx11_random) - QSKIP("<random> not found"); -#else // just a compile check for some of the distributions, besides // std::uniform_int_distribution and std::uniform_real_distribution (tested // above) @@ -695,7 +676,6 @@ void tst_QRandomGenerator::stdRandomDistributions() QVERIFY(discrete(rd) != 0); QVERIFY_3TIMES(discrete(rd) == 3); } -#endif } QTEST_APPLESS_MAIN(tst_QRandomGenerator) diff --git a/tests/auto/corelib/io/qlockfile/qlockfiletesthelper/qlockfile_test_helper.cpp b/tests/auto/corelib/io/qlockfile/qlockfiletesthelper/qlockfile_test_helper.cpp index f10c2a7c98..e086bf1904 100644 --- a/tests/auto/corelib/io/qlockfile/qlockfiletesthelper/qlockfile_test_helper.cpp +++ b/tests/auto/corelib/io/qlockfile/qlockfiletesthelper/qlockfile_test_helper.cpp @@ -31,6 +31,12 @@ #include <QLockFile> #include <QThread> +#ifdef Q_OS_UNIX +# include <unistd.h> +#else +# include <stdlib.h> +#endif + int main(int argc, char *argv[]) { QCoreApplication app(argc, argv); @@ -44,11 +50,11 @@ int main(int argc, char *argv[]) if (argc > 2) option = QString::fromLocal8Bit(argv[2]); - if (option == "-crash") { + if (option == "-uncleanexit") { QLockFile lockFile(lockName); lockFile.lock(); // exit on purpose, so that the lock remains! - exit(0); + _exit(0); } else if (option == "-busy") { QLockFile lockFile(lockName); lockFile.lock(); diff --git a/tests/auto/corelib/io/qlockfile/tst_qlockfile.cpp b/tests/auto/corelib/io/qlockfile/tst_qlockfile.cpp index d2f345feb5..835c4a2778 100644 --- a/tests/auto/corelib/io/qlockfile/tst_qlockfile.cpp +++ b/tests/auto/corelib/io/qlockfile/tst_qlockfile.cpp @@ -262,7 +262,7 @@ void tst_QLockFile::staleLockFromCrashedProcess() QFETCH(int, staleLockTime); const QString fileName = dir.path() + "/staleLockFromCrashedProcess"; - int ret = QProcess::execute(m_helperApp, QStringList() << fileName << "-crash"); + int ret = QProcess::execute(m_helperApp, QStringList() << fileName << "-uncleanexit"); QCOMPARE(ret, int(QLockFile::NoError)); QTRY_VERIFY(QFile::exists(fileName)); @@ -288,7 +288,7 @@ void tst_QLockFile::staleLockFromCrashedProcessReusedPid() #else const QString fileName = dir.path() + "/staleLockFromCrashedProcessReusedPid"; - int ret = QProcess::execute(m_helperApp, QStringList() << fileName << "-crash"); + int ret = QProcess::execute(m_helperApp, QStringList() << fileName << "-uncleanexit"); QCOMPARE(ret, int(QLockFile::NoError)); QVERIFY(QFile::exists(fileName)); QVERIFY(overwritePidInLockFile(fileName, QCoreApplication::applicationPid())); @@ -397,7 +397,7 @@ void tst_QLockFile::staleLockRace() // Only one thread should delete it, otherwise a race will ensue const QString fileName = dir.path() + "/sharedFile"; const QString lockName = fileName + ".lock"; - int ret = QProcess::execute(m_helperApp, QStringList() << lockName << "-crash"); + int ret = QProcess::execute(m_helperApp, QStringList() << lockName << "-uncleanexit"); QCOMPARE(ret, int(QLockFile::NoError)); QTRY_VERIFY(QFile::exists(lockName)); diff --git a/tests/auto/corelib/itemmodels/qsortfilterproxymodel/tst_qsortfilterproxymodel.cpp b/tests/auto/corelib/itemmodels/qsortfilterproxymodel/tst_qsortfilterproxymodel.cpp index 74e9e4e47d..b0dd7f18f1 100644 --- a/tests/auto/corelib/itemmodels/qsortfilterproxymodel/tst_qsortfilterproxymodel.cpp +++ b/tests/auto/corelib/itemmodels/qsortfilterproxymodel/tst_qsortfilterproxymodel.cpp @@ -3893,7 +3893,7 @@ void tst_QSortFilterProxyModel::hierarchyFilterInvalidation() view.setCurrentIndex(proxy.index(2, 0).child(0, 0)); view.show(); - QTest::qWaitForWindowExposed(&view); + QVERIFY(QTest::qWaitForWindowExposed(&view)); proxy.setMode(true); } @@ -3950,7 +3950,7 @@ void tst_QSortFilterProxyModel::simpleFilterInvalidation() view.setModel(&proxy); view.show(); - QTest::qWaitForWindowExposed(&view); + QVERIFY(QTest::qWaitForWindowExposed(&view)); proxy.setMode(true); model.insertRow(0, new QStandardItem("extra")); diff --git a/tests/auto/corelib/kernel/qcoreapplication/qcoreapplication.pro b/tests/auto/corelib/kernel/qcoreapplication/qcoreapplication.pro index e37542be65..1a76085c1b 100644 --- a/tests/auto/corelib/kernel/qcoreapplication/qcoreapplication.pro +++ b/tests/auto/corelib/kernel/qcoreapplication/qcoreapplication.pro @@ -5,5 +5,5 @@ SOURCES = tst_qcoreapplication.cpp HEADERS = tst_qcoreapplication.h win32: VERSION = 1.2.3.4 else: VERSION = 1.2.3 -darwin: QMAKE_LFLAGS += -Wl,-sectcreate,__TEXT,__info_plist,$$shell_quote($$PWD/Info.plist) +QMAKE_INFO_PLIST = $$PWD/Info.plist requires(qtConfig(private_tests)) diff --git a/tests/auto/corelib/kernel/qtimer/qtimer.pro b/tests/auto/corelib/kernel/qtimer/qtimer.pro index b27d862bc5..710dfea682 100644 --- a/tests/auto/corelib/kernel/qtimer/qtimer.pro +++ b/tests/auto/corelib/kernel/qtimer/qtimer.pro @@ -1,6 +1,6 @@ CONFIG += testcase TARGET = tst_qtimer -QT = core testlib +QT = core core-private testlib SOURCES = tst_qtimer.cpp # Force C++17 if available diff --git a/tests/auto/corelib/kernel/qtimer/tst_qtimer.cpp b/tests/auto/corelib/kernel/qtimer/tst_qtimer.cpp index 343a9384bc..2c6d9ea7c0 100644 --- a/tests/auto/corelib/kernel/qtimer/tst_qtimer.cpp +++ b/tests/auto/corelib/kernel/qtimer/tst_qtimer.cpp @@ -33,11 +33,11 @@ # include <QtCore/QCoreApplication> #endif +#include <QtCore/private/qglobal_p.h> #include <QtTest/QtTest> #include <qtimer.h> #include <qthread.h> -#include <qoperatingsystemversion.h> #if defined Q_OS_UNIX #include <unistd.h> @@ -500,7 +500,7 @@ void tst_QTimer::moveToThread() #if defined(Q_OS_WIN32) QSKIP("Does not work reliably on Windows :("); #elif defined(Q_OS_MACOS) - if (QOperatingSystemVersion::current() >= QOperatingSystemVersion::MacOSSierra) + if (__builtin_available(macOS 10.12, *)) QSKIP("Does not work reliably on macOS 10.12 (QTBUG-59679)"); #endif QTimer ti1; diff --git a/tests/auto/corelib/kernel/qwineventnotifier/tst_qwineventnotifier.cpp b/tests/auto/corelib/kernel/qwineventnotifier/tst_qwineventnotifier.cpp index 304f6121a5..15a39b62c0 100644 --- a/tests/auto/corelib/kernel/qwineventnotifier/tst_qwineventnotifier.cpp +++ b/tests/auto/corelib/kernel/qwineventnotifier/tst_qwineventnotifier.cpp @@ -41,6 +41,7 @@ protected slots: void simple_activated(); void simple_timerSet(); private slots: + void simple_data(); void simple(); void manyNotifiers(); @@ -61,9 +62,17 @@ void tst_QWinEventNotifier::simple_timerSet() SetEvent((HANDLE)simpleHEvent); } +void tst_QWinEventNotifier::simple_data() +{ + QTest::addColumn<bool>("resetManually"); + QTest::newRow("manual_reset") << true; + QTest::newRow("auto_reset") << false; +} + void tst_QWinEventNotifier::simple() { - simpleHEvent = CreateEvent(0, true, false, 0); + QFETCH(bool, resetManually); + simpleHEvent = CreateEvent(0, resetManually, false, 0); QVERIFY(simpleHEvent); QWinEventNotifier n(simpleHEvent); diff --git a/tests/auto/corelib/thread/qthread/tst_qthread.cpp b/tests/auto/corelib/thread/qthread/tst_qthread.cpp index 27a617ec85..0405896ca7 100644 --- a/tests/auto/corelib/thread/qthread/tst_qthread.cpp +++ b/tests/auto/corelib/thread/qthread/tst_qthread.cpp @@ -1338,7 +1338,7 @@ void tst_QThread::quitLock() void tst_QThread::create() { -#ifndef QTHREAD_HAS_CREATE +#if !QT_CONFIG(cxx11_future) QSKIP("This test requires QThread::create"); #else { @@ -1586,7 +1586,7 @@ void tst_QThread::create() } #endif // QT_NO_EXCEPTIONS #endif // QTHREAD_HAS_VARIADIC_CREATE -#endif // QTHREAD_HAS_CREATE +#endif // QT_CONFIG(cxx11_future) } class StopableJob : public QObject diff --git a/tests/auto/corelib/tools/qstringview/tst_qstringview.cpp b/tests/auto/corelib/tools/qstringview/tst_qstringview.cpp index 48ea5a794c..4174b85f4c 100644 --- a/tests/auto/corelib/tools/qstringview/tst_qstringview.cpp +++ b/tests/auto/corelib/tools/qstringview/tst_qstringview.cpp @@ -364,14 +364,21 @@ void tst_QStringView::basics() const void tst_QStringView::literals() const { #if !defined(Q_OS_WIN) || defined(Q_COMPILER_UNICODE_STRINGS) - // the + ensures it's a pointer, not an array - QCOMPARE(QStringView(+u"Hello").size(), 5); - QStringView sv = u"Hello"; + const char16_t hello[] = u"Hello"; + const char16_t longhello[] = + u"Hello World. This is a much longer message, to exercise qustrlen."; + const char16_t withnull[] = u"a\0zzz"; #else // storage_type is wchar_t - // the + ensures it's a pointer, not an array - QCOMPARE(QStringView(+L"Hello").size(), 5); - QStringView sv = L"Hello"; + const wchar_t hello[] = L"Hello"; + const wchar_t longhello[] = + L"Hello World. This is a much longer message, to exercise qustrlen."; + const wchar_t withnull[] = L"a\0zzz"; #endif + Q_STATIC_ASSERT(sizeof(longhello) >= 16); + + QCOMPARE(QStringView(hello).size(), 5); + QCOMPARE(QStringView(hello + 0).size(), 5); // forces decay to pointer + QStringView sv = hello; QCOMPARE(sv.size(), 5); QVERIFY(!sv.empty()); QVERIFY(!sv.isEmpty()); @@ -390,6 +397,24 @@ void tst_QStringView::literals() const QVERIFY(!sv2.isNull()); QVERIFY(!sv2.empty()); QCOMPARE(sv2.size(), 5); + + QStringView sv3(longhello); + QCOMPARE(size_t(sv3.size()), sizeof(longhello)/sizeof(longhello[0]) - 1); + QCOMPARE(sv3.last(), QLatin1Char('.')); + sv3 = longhello; + QCOMPARE(size_t(sv3.size()), sizeof(longhello)/sizeof(longhello[0]) - 1); + + for (int i = 0; i < sv3.size(); ++i) { + QStringView sv4(longhello + i); + QCOMPARE(size_t(sv4.size()), sizeof(longhello)/sizeof(longhello[0]) - 1 - i); + QCOMPARE(sv4.last(), QLatin1Char('.')); + sv4 = longhello + i; + QCOMPARE(size_t(sv4.size()), sizeof(longhello)/sizeof(longhello[0]) - 1 - i); + } + + // these are different results + QCOMPARE(size_t(QStringView(withnull).size()), sizeof(withnull)/sizeof(withnull[0]) - 1); + QCOMPARE(QStringView(withnull + 0).size(), 1); } void tst_QStringView::at() const diff --git a/tests/auto/gui/kernel/qguiapplication/tst_qguiapplication.cpp b/tests/auto/gui/kernel/qguiapplication/tst_qguiapplication.cpp index a935258fb8..6ba488aaa7 100644 --- a/tests/auto/gui/kernel/qguiapplication/tst_qguiapplication.cpp +++ b/tests/auto/gui/kernel/qguiapplication/tst_qguiapplication.cpp @@ -227,7 +227,7 @@ void tst_QGuiApplication::focusObject() QOpenGLContext context; context.create(); context.makeCurrent(&window1); - QTest::qWaitForWindowExposed(&window1); // Buffer swap only succeeds with exposed window + QVERIFY(QTest::qWaitForWindowExposed(&window1)); // Buffer swap only succeeds with exposed window context.swapBuffers(&window1); #endif @@ -392,7 +392,7 @@ void tst_QGuiApplication::changeFocusWindow() QOpenGLContext context; context.create(); context.makeCurrent(&window1); - QTest::qWaitForWindowExposed(&window1); // Buffer swap only succeeds with exposed window + QVERIFY(QTest::qWaitForWindowExposed(&window1)); // Buffer swap only succeeds with exposed window context.swapBuffers(&window1); #endif FocusChangeWindow window2; @@ -406,7 +406,7 @@ void tst_QGuiApplication::changeFocusWindow() #if defined(Q_OS_QNX) // We either need to create a eglSurface or a create a backing store // and then post the window in order for screen to show the window context.makeCurrent(&window2); - QTest::qWaitForWindowExposed(&window2); // Buffer swap only succeeds with exposed window + QVERIFY(QTest::qWaitForWindowExposed(&window2)); // Buffer swap only succeeds with exposed window context.swapBuffers(&window2); #endif QVERIFY(QTest::qWaitForWindowExposed(&window1)); diff --git a/tests/auto/gui/kernel/qguitimer/qguitimer.pro b/tests/auto/gui/kernel/qguitimer/qguitimer.pro index 8a71e48007..9c58f0e22c 100644 --- a/tests/auto/gui/kernel/qguitimer/qguitimer.pro +++ b/tests/auto/gui/kernel/qguitimer/qguitimer.pro @@ -1,4 +1,4 @@ CONFIG += testcase TARGET = tst_qguitimer -QT = core gui testlib +QT = core core-private gui testlib SOURCES += ../../../corelib/kernel/qtimer/tst_qtimer.cpp diff --git a/tests/auto/gui/kernel/qopenglwindow/tst_qopenglwindow.cpp b/tests/auto/gui/kernel/qopenglwindow/tst_qopenglwindow.cpp index 7200d1cc8a..f74ae00bff 100644 --- a/tests/auto/gui/kernel/qopenglwindow/tst_qopenglwindow.cpp +++ b/tests/auto/gui/kernel/qopenglwindow/tst_qopenglwindow.cpp @@ -62,7 +62,7 @@ void tst_QOpenGLWindow::create() w.resize(640, 480); w.show(); - QTest::qWaitForWindowExposed(&w); + QVERIFY(QTest::qWaitForWindowExposed(&w)); QVERIFY(w.isValid()); } @@ -111,7 +111,7 @@ void tst_QOpenGLWindow::basic() w.reset(); w.resize(640, 480); w.show(); - QTest::qWaitForWindowExposed(&w); + QVERIFY(QTest::qWaitForWindowExposed(&w)); // Check that the virtuals are invoked. QCOMPARE(w.initCount, 1); @@ -170,7 +170,7 @@ void tst_QOpenGLWindow::painter() PainterWindow w; w.resize(400, 400); w.show(); - QTest::qWaitForWindowExposed(&w); + QVERIFY(QTest::qWaitForWindowExposed(&w)); QCOMPARE(w.img.size(), w.size() * w.devicePixelRatio()); QVERIFY(w.img.pixel(QPoint(5, 5) * w.devicePixelRatio()) == qRgb(0, 0, 255)); @@ -212,7 +212,7 @@ void tst_QOpenGLWindow::partial() PartialPainterWindow w(u); w.resize(800, 400); w.show(); - QTest::qWaitForWindowExposed(&w); + QVERIFY(QTest::qWaitForWindowExposed(&w)); // Add a couple of small blue rects. for (int i = 0; i < 10; ++i) { @@ -285,7 +285,7 @@ void tst_QOpenGLWindow::underOver() PaintUnderOverWindow w; w.resize(400, 400); w.show(); - QTest::qWaitForWindowExposed(&w); + QVERIFY(QTest::qWaitForWindowExposed(&w)); // under -> paint -> over -> under -> paint -> ... is the only acceptable sequence QCOMPARE(w.m_state, PaintUnderOverWindow::PaintOver); diff --git a/tests/auto/gui/kernel/qrasterwindow/tst_qrasterwindow.cpp b/tests/auto/gui/kernel/qrasterwindow/tst_qrasterwindow.cpp index 7fb79b28ae..ffc440ac2d 100644 --- a/tests/auto/gui/kernel/qrasterwindow/tst_qrasterwindow.cpp +++ b/tests/auto/gui/kernel/qrasterwindow/tst_qrasterwindow.cpp @@ -46,7 +46,7 @@ void tst_QRasterWindow::create() w.resize(640, 480); w.show(); - QTest::qWaitForWindowExposed(&w); + QVERIFY(QTest::qWaitForWindowExposed(&w)); } class PainterWindow : public QRasterWindow @@ -70,7 +70,7 @@ void tst_QRasterWindow::basic() w.reset(); w.resize(400, 400); w.show(); - QTest::qWaitForWindowExposed(&w); + QVERIFY(QTest::qWaitForWindowExposed(&w));; QVERIFY(w.paintCount >= 1); diff --git a/tests/auto/gui/kernel/qwindow/BLACKLIST b/tests/auto/gui/kernel/qwindow/BLACKLIST index 9ffcf73d64..3e03d9e236 100644 --- a/tests/auto/gui/kernel/qwindow/BLACKLIST +++ b/tests/auto/gui/kernel/qwindow/BLACKLIST @@ -23,3 +23,5 @@ osx osx-10.11 ci osx-10.12 ci +[testInputEvents] +rhel-7.4 diff --git a/tests/auto/gui/kernel/qwindow/tst_qwindow.cpp b/tests/auto/gui/kernel/qwindow/tst_qwindow.cpp index 24f61e4584..a365d21d36 100644 --- a/tests/auto/gui/kernel/qwindow/tst_qwindow.cpp +++ b/tests/auto/gui/kernel/qwindow/tst_qwindow.cpp @@ -409,13 +409,17 @@ void tst_QWindow::exposeEventOnShrink_QTBUG54040() QVERIFY(QTest::qWaitForWindowExposed(&window)); - const int initialExposeCount = window.received(QEvent::Expose); + int exposeCount = window.received(QEvent::Expose); window.resize(window.width(), window.height() - 5); - QTRY_COMPARE(window.received(QEvent::Expose), initialExposeCount + 1); + QTRY_VERIFY(window.received(QEvent::Expose) > exposeCount); + + exposeCount = window.received(QEvent::Expose); window.resize(window.width() - 5, window.height()); - QTRY_COMPARE(window.received(QEvent::Expose), initialExposeCount + 2); + QTRY_VERIFY(window.received(QEvent::Expose) > exposeCount); + + exposeCount = window.received(QEvent::Expose); window.resize(window.width() - 5, window.height() - 5); - QTRY_COMPARE(window.received(QEvent::Expose), initialExposeCount + 3); + QTRY_VERIFY(window.received(QEvent::Expose) > exposeCount); } void tst_QWindow::positioning_data() @@ -486,7 +490,7 @@ void tst_QWindow::positioning() window.showNormal(); QCoreApplication::processEvents(); - QTest::qWaitForWindowExposed(&window); + QVERIFY(QTest::qWaitForWindowExposed(&window)); QMargins originalMargins = window.frameMargins(); @@ -1479,7 +1483,7 @@ void tst_QWindow::activateAndClose() window.showNormal(); #if defined(Q_OS_QNX) // We either need to create a eglSurface or a create a backing store // and then post the window in order for screen to show the window - QTest::qWaitForWindowExposed(&window); + QVERIFY(QTest::qWaitForWindowExposed(&window)); QOpenGLContext context; context.create(); context.makeCurrent(&window); diff --git a/tests/auto/gui/qopengl/tst_qopengl.cpp b/tests/auto/gui/qopengl/tst_qopengl.cpp index f23eb70a36..5b1af9b6c9 100644 --- a/tests/auto/gui/qopengl/tst_qopengl.cpp +++ b/tests/auto/gui/qopengl/tst_qopengl.cpp @@ -1413,7 +1413,7 @@ void tst_QOpenGL::glxContextWrap() window->setSurfaceType(QWindow::OpenGLSurface); window->setGeometry(0, 0, 10, 10); window->show(); - QTest::qWaitForWindowExposed(window); + QVERIFY(QTest::qWaitForWindowExposed(window)); QPlatformNativeInterface *nativeIf = QGuiApplicationPrivate::instance()->platformIntegration()->nativeInterface(); QVERIFY(nativeIf); @@ -1457,7 +1457,7 @@ void tst_QOpenGL::wglContextWrap() window->setSurfaceType(QWindow::OpenGLSurface); window->setGeometry(0, 0, 256, 256); window->show(); - QTest::qWaitForWindowExposed(window.data()); + QVERIFY(QTest::qWaitForWindowExposed(window.data())); QVariant v = ctx->nativeHandle(); QVERIFY(!v.isNull()); diff --git a/tests/auto/gui/qvulkan/tst_qvulkan.cpp b/tests/auto/gui/qvulkan/tst_qvulkan.cpp index 716d49a2f1..c80c3fed97 100644 --- a/tests/auto/gui/qvulkan/tst_qvulkan.cpp +++ b/tests/auto/gui/qvulkan/tst_qvulkan.cpp @@ -116,7 +116,7 @@ void tst_QVulkan::vulkanPlainWindow() w.setVulkanInstance(&inst); w.resize(1024, 768); w.show(); - QTest::qWaitForWindowExposed(&w); + QVERIFY(QTest::qWaitForWindowExposed(&w)); QCOMPARE(w.vulkanInstance(), &inst); @@ -182,7 +182,7 @@ void tst_QVulkan::vulkanWindow() QVERIFY(!w.isValid()); w.resize(1024, 768); w.show(); - QTest::qWaitForWindowExposed(&w); + QVERIFY(QTest::qWaitForWindowExposed(&w)); QVERIFY(!w.isValid()); // Now set it. A simple hide - show should be enough to correct, this, no @@ -194,7 +194,7 @@ void tst_QVulkan::vulkanWindow() if (pdevs.isEmpty()) QSKIP("No Vulkan physical devices; skip"); w.show(); - QTest::qWaitForWindowExposed(&w); + QVERIFY(QTest::qWaitForWindowExposed(&w)); QVERIFY(w.isValid()); QCOMPARE(w.vulkanInstance(), &inst); QVulkanInfoVector<QVulkanExtension> exts = w.supportedDeviceExtensions(); @@ -208,7 +208,7 @@ void tst_QVulkan::vulkanWindow() // supported lists can be queried before expose too QVERIFY(w.supportedDeviceExtensions() == exts); w.show(); - QTest::qWaitForWindowExposed(&w); + QVERIFY(QTest::qWaitForWindowExposed(&w)); QVERIFY(w.isValid()); QVERIFY(w.flags().testFlag(QVulkanWindow::PersistentResources)); @@ -355,7 +355,7 @@ void tst_QVulkan::vulkanWindowRenderer() w.setVulkanInstance(&inst); w.resize(1024, 768); w.show(); - QTest::qWaitForWindowExposed(&w); + QVERIFY(QTest::qWaitForWindowExposed(&w)); if (w.availablePhysicalDevices().isEmpty()) QSKIP("No Vulkan physical devices; skip"); @@ -389,7 +389,7 @@ void tst_QVulkan::vulkanWindowGrab() w.setVulkanInstance(&inst); w.resize(1024, 768); w.show(); - QTest::qWaitForWindowExposed(&w); + QVERIFY(QTest::qWaitForWindowExposed(&w)); if (w.availablePhysicalDevices().isEmpty()) QSKIP("No Vulkan physical devices; skip"); diff --git a/tests/auto/network/access/http2/tst_http2.cpp b/tests/auto/network/access/http2/tst_http2.cpp index e433293a2c..9befb7276e 100644 --- a/tests/auto/network/access/http2/tst_http2.cpp +++ b/tests/auto/network/access/http2/tst_http2.cpp @@ -124,6 +124,7 @@ private: const Http2Settings tst_Http2::defaultServerSettings{{Http2::Settings::MAX_CONCURRENT_STREAMS_ID, 100}}; const Http2Settings tst_Http2::defaultClientSettings{{Http2::Settings::MAX_FRAME_SIZE_ID, quint32(Http2::maxFrameSize)}, + {Http2::Settings::INITIAL_WINDOW_SIZE_ID, quint32(Http2::initialStreamReceiveWindowSize)}, {Http2::Settings::ENABLE_PUSH_ID, quint32(0)}}; namespace { @@ -274,7 +275,7 @@ void tst_Http2::flowControlClientSide() ServerPtr srv(newServer(serverSettings)); - const QByteArray respond(int(Http2::defaultSessionWindowSize * 50), 'x'); + const QByteArray respond(int(Http2::initialStreamReceiveWindowSize * 5), 'x'); srv->setResponseBody(respond); QMetaObject::invokeMethod(srv.data(), "startServer", Qt::QueuedConnection); @@ -342,6 +343,7 @@ void tst_Http2::pushPromise() const EnvVarGuard env("QT_HTTP2_ENABLE_PUSH_PROMISE", "1"); const Http2Settings clientSettings{{Settings::MAX_FRAME_SIZE_ID, quint32(Http2::maxFrameSize)}, + {Http2::Settings::INITIAL_WINDOW_SIZE_ID, quint32(Http2::initialStreamReceiveWindowSize)}, {Settings::ENABLE_PUSH_ID, quint32(1)}}; ServerPtr srv(newServer(defaultServerSettings, clientSettings)); diff --git a/tests/auto/network/access/qnetworkreply/tst_qnetworkreply.cpp b/tests/auto/network/access/qnetworkreply/tst_qnetworkreply.cpp index 40e909113e..49abbede35 100644 --- a/tests/auto/network/access/qnetworkreply/tst_qnetworkreply.cpp +++ b/tests/auto/network/access/qnetworkreply/tst_qnetworkreply.cpp @@ -488,6 +488,7 @@ private Q_SLOTS: void ioHttpRedirectPolicyErrors(); void ioHttpUserVerifiedRedirect_data(); void ioHttpUserVerifiedRedirect(); + void ioHttpCookiesDuringRedirect(); #ifndef QT_NO_SSL void putWithServerClosingConnectionImmediately(); #endif @@ -8456,6 +8457,33 @@ void tst_QNetworkReply::ioHttpUserVerifiedRedirect() QCOMPARE(reply->attribute(QNetworkRequest::HttpStatusCodeAttribute).toInt(), statusCode); } +void tst_QNetworkReply::ioHttpCookiesDuringRedirect() +{ + MiniHttpServer target(httpEmpty200Response, false); + + const QString cookieHeader = QStringLiteral("Set-Cookie: hello=world; Path=/;\r\n"); + QString redirect = tempRedirectReplyStr(); + // Insert 'cookieHeader' before the final \r\n + redirect.insert(redirect.length() - 2, cookieHeader); + + QUrl url("http://localhost/"); + url.setPort(target.serverPort()); + redirect = redirect.arg(url.toString()); + MiniHttpServer redirectServer(redirect.toLatin1(), false); + + url = QUrl("http://localhost/"); + url.setPort(redirectServer.serverPort()); + QNetworkRequest request(url); + auto oldRedirectPolicy = manager.redirectPolicy(); + manager.setRedirectPolicy(QNetworkRequest::RedirectPolicy::NoLessSafeRedirectPolicy); + QNetworkReplyPtr reply(manager.get(request)); + // Set policy back to whatever it was + manager.setRedirectPolicy(oldRedirectPolicy); + + QVERIFY(waitForFinish(reply) == Success); + QVERIFY(target.receivedData.contains("\r\nCookie: hello=world\r\n")); +} + #ifndef QT_NO_SSL class PutWithServerClosingConnectionImmediatelyHandler: public QObject diff --git a/tests/auto/network/kernel/qnetworkinterface/tst_qnetworkinterface.cpp b/tests/auto/network/kernel/qnetworkinterface/tst_qnetworkinterface.cpp index 94c355aadc..36dcec0a82 100644 --- a/tests/auto/network/kernel/qnetworkinterface/tst_qnetworkinterface.cpp +++ b/tests/auto/network/kernel/qnetworkinterface/tst_qnetworkinterface.cpp @@ -195,7 +195,7 @@ void tst_QNetworkInterface::localAddress() QHostAddress local = socket.localAddress(); - // test that we can find the address that QTcpSocket reported + // test that we can find the address that QUdpSocket reported QList<QHostAddress> all = QNetworkInterface::allAddresses(); QVERIFY(all.contains(local)); } diff --git a/tests/auto/network/kernel/qnetworkproxyfactory/tst_qnetworkproxyfactory.cpp b/tests/auto/network/kernel/qnetworkproxyfactory/tst_qnetworkproxyfactory.cpp index f3a1ac84ff..90da0b64e2 100644 --- a/tests/auto/network/kernel/qnetworkproxyfactory/tst_qnetworkproxyfactory.cpp +++ b/tests/auto/network/kernel/qnetworkproxyfactory/tst_qnetworkproxyfactory.cpp @@ -256,8 +256,8 @@ void tst_QNetworkProxyFactory::genericSystemProxy() QFETCH(QString, hostName); QFETCH(int, port); -// The generic system proxy is only available on the following platforms -#if (!defined Q_OS_WIN) && (!defined Q_OS_OSX) && !QT_CONFIG(libproxy) +// We can only use the generic system proxy where available: +#if !defined(Q_OS_WIN) && !defined(Q_OS_MACOS) && !QT_CONFIG(libproxy) qputenv(envVar, url); const QList<QNetworkProxy> systemProxy = QNetworkProxyFactory::systemProxyForQuery(); QCOMPARE(systemProxy.size(), 1); diff --git a/tests/auto/network/ssl/qsslsocket_onDemandCertificates_member/tst_qsslsocket_onDemandCertificates_member.cpp b/tests/auto/network/ssl/qsslsocket_onDemandCertificates_member/tst_qsslsocket_onDemandCertificates_member.cpp index b5bfde3cab..25c2701f69 100644 --- a/tests/auto/network/ssl/qsslsocket_onDemandCertificates_member/tst_qsslsocket_onDemandCertificates_member.cpp +++ b/tests/auto/network/ssl/qsslsocket_onDemandCertificates_member/tst_qsslsocket_onDemandCertificates_member.cpp @@ -168,29 +168,59 @@ void tst_QSslSocket_onDemandCertificates_member::proxyAuthenticationRequired(con #ifndef QT_NO_OPENSSL +static bool waitForEncrypted(QSslSocket *socket) +{ + Q_ASSERT(socket); + + QEventLoop eventLoop; + + QTimer connectionTimeoutWatcher; + connectionTimeoutWatcher.setSingleShot(true); + connectionTimeoutWatcher.connect(&connectionTimeoutWatcher, &QTimer::timeout, + [&eventLoop]() { + eventLoop.exit(); + }); + + bool encrypted = false; + socket->connect(socket, &QSslSocket::encrypted, [&eventLoop, &encrypted](){ + eventLoop.exit(); + encrypted = true; + }); + + socket->connect(socket, QOverload<const QList<QSslError>&>::of(&QSslSocket::sslErrors), + [&eventLoop](){ + eventLoop.exit(); + }); + + // Wait for 30 s. maximum - the default timeout in our QSslSocket::waitForEncrypted ... + connectionTimeoutWatcher.start(30000); + eventLoop.exec(); + return encrypted; +} + void tst_QSslSocket_onDemandCertificates_member::onDemandRootCertLoadingMemberMethods() { - QString host("www.qt.io"); + const QString host("www.qt.io"); // not using any root certs -> should not work QSslSocketPtr socket2 = newSocket(); this->socket = socket2.data(); socket2->setCaCertificates(QList<QSslCertificate>()); socket2->connectToHostEncrypted(host, 443); - QVERIFY(!socket2->waitForEncrypted()); + QVERIFY(!waitForEncrypted(socket2.data())); // default: using on demand loading -> should work QSslSocketPtr socket = newSocket(); this->socket = socket.data(); socket->connectToHostEncrypted(host, 443); - QVERIFY2(socket->waitForEncrypted(), qPrintable(socket->errorString())); + QVERIFY2(waitForEncrypted(socket.data()), qPrintable(socket->errorString())); // not using any root certs again -> should not work QSslSocketPtr socket3 = newSocket(); this->socket = socket3.data(); socket3->setCaCertificates(QList<QSslCertificate>()); socket3->connectToHostEncrypted(host, 443); - QVERIFY(!socket3->waitForEncrypted()); + QVERIFY(!waitForEncrypted(socket3.data())); // setting empty SSL configuration explicitly -> depends on on-demand loading QSslSocketPtr socket4 = newSocket(); @@ -199,24 +229,16 @@ void tst_QSslSocket_onDemandCertificates_member::onDemandRootCertLoadingMemberMe socket4->setSslConfiguration(conf); socket4->connectToHostEncrypted(host, 443); #ifdef QT_BUILD_INTERNAL - bool rootCertLoadingAllowed = QSslSocketPrivate::rootCertOnDemandLoadingSupported(); -#if defined(Q_OS_LINUX) - QCOMPARE(rootCertLoadingAllowed, true); + const bool works = QSslSocketPrivate::rootCertOnDemandLoadingSupported(); +#if defined(Q_OS_LINUX) || defined(Q_OS_WIN) + QCOMPARE(works, true); #elif defined(Q_OS_MAC) - QCOMPARE(rootCertLoadingAllowed, false); -#endif // other platforms: undecided (Windows: depends on the version) - // when we allow on demand loading, it is enabled by default, - // so on Unix it will work without setting any certificates. Otherwise, - // the configuration contains an empty set of certificates - // and will fail. - bool works; -#if defined (Q_OS_WIN) - works = false; // on Windows, this won't work even though we use on demand loading - Q_UNUSED(rootCertLoadingAllowed) -#else - works = rootCertLoadingAllowed; -#endif - QCOMPARE(socket4->waitForEncrypted(), works); + QCOMPARE(works, false); +#endif // other platforms: undecided. + // When we *allow* on-demand loading, we enable it by default; so, on Unix, + // it will work without setting any certificates. Otherwise, the configuration + // contains an empty set of certificates, so on-demand loading shall fail. + QCOMPARE(waitForEncrypted(socket4.data()), works); #endif // QT_BUILD_INTERNAL } diff --git a/tests/auto/opengl/qgl/tst_qgl.cpp b/tests/auto/opengl/qgl/tst_qgl.cpp index f110b9cb0d..46e2345c6a 100644 --- a/tests/auto/opengl/qgl/tst_qgl.cpp +++ b/tests/auto/opengl/qgl/tst_qgl.cpp @@ -2142,7 +2142,7 @@ void tst_QGL::textureCleanup() QGLWidget w; w.resize(200,200); w.show(); - QTest::qWaitForWindowExposed(&w); + QVERIFY(QTest::qWaitForWindowExposed(&w)); w.makeCurrent(); // Test pixmaps which have been loaded via QPixmapCache are removed from the texture cache diff --git a/tests/auto/opengl/qglthreads/tst_qglthreads.cpp b/tests/auto/opengl/qglthreads/tst_qglthreads.cpp index ce895f734a..1a7ccba9be 100644 --- a/tests/auto/opengl/qglthreads/tst_qglthreads.cpp +++ b/tests/auto/opengl/qglthreads/tst_qglthreads.cpp @@ -523,7 +523,7 @@ public: GLWidgetWrapper() { widget.resize(150, 150); widget.show(); - QTest::qWaitForWindowExposed(&widget); + QVERIFY(QTest::qWaitForWindowExposed(&widget)); widget.doneCurrent(); } QPaintDevice *realPaintDevice() { return &widget; } diff --git a/tests/auto/other/qaccessibility/tst_qaccessibility.cpp b/tests/auto/other/qaccessibility/tst_qaccessibility.cpp index 4ffdc4c762..e73af60e74 100644 --- a/tests/auto/other/qaccessibility/tst_qaccessibility.cpp +++ b/tests/auto/other/qaccessibility/tst_qaccessibility.cpp @@ -356,7 +356,7 @@ void tst_QAccessibility::customWidget() { QtTestAccessibleWidget* widget = new QtTestAccessibleWidget(0, "Heinz"); widget->show(); - QTest::qWaitForWindowExposed(widget); + QVERIFY(QTest::qWaitForWindowExposed(widget)); // By default we create QAccessibleWidget QAccessibleInterface *iface = QAccessible::queryAccessibleInterface(widget); QVERIFY(iface != 0); @@ -372,7 +372,7 @@ void tst_QAccessibility::customWidget() QAccessible::installFactory(QtTestAccessibleWidgetIface::ifaceFactory); QtTestAccessibleWidget* widget = new QtTestAccessibleWidget(0, "Heinz"); widget->show(); - QTest::qWaitForWindowExposed(widget); + QVERIFY(QTest::qWaitForWindowExposed(widget)); QAccessibleInterface *iface = QAccessible::queryAccessibleInterface(widget); QVERIFY(iface != 0); QVERIFY(iface->isValid()); @@ -1753,7 +1753,7 @@ void tst_QAccessibility::textEditTest() } edit.show(); - QTest::qWaitForWindowExposed(&edit); + QVERIFY(QTest::qWaitForWindowExposed(&edit)); QAccessibleInterface *iface = QAccessible::queryAccessibleInterface(&edit); QCOMPARE(iface->text(QAccessible::Value), edit.toPlainText()); QVERIFY(iface->state().focusable); @@ -2165,7 +2165,7 @@ void tst_QAccessibility::lineEditTest() QLineEdit le(QStringLiteral("My characters have geometries."), toplevel); // characterRect() le.show(); - QTest::qWaitForWindowExposed(&le); + QVERIFY(QTest::qWaitForWindowExposed(&le)); QAccessibleInterface *iface(QAccessible::queryAccessibleInterface(&le)); QAccessibleTextInterface* textIface = iface->textInterface(); QVERIFY(textIface); @@ -3075,7 +3075,7 @@ void tst_QAccessibility::tableTest() tableView->resize(600,600); tableView->show(); - QTest::qWaitForWindowExposed(tableView); + QVERIFY(QTest::qWaitForWindowExposed(tableView)); QAccessibleInterface *iface = QAccessible::queryAccessibleInterface(tableView); QCOMPARE(verifyHierarchy(iface), 0); @@ -3449,7 +3449,7 @@ void tst_QAccessibility::dockWidgetTest() mw->resize(600,400); mw->show(); - QTest::qWaitForWindowExposed(mw); + QVERIFY(QTest::qWaitForWindowExposed(mw)); QAccessibleInterface *accMainWindow = QAccessible::queryAccessibleInterface(mw); // 4 children: menu bar, dock1, dock2, and central widget @@ -3632,7 +3632,7 @@ void tst_QAccessibility::labelTest() window->resize(320, 200); window->show(); - QTest::qWaitForWindowExposed(window); + QVERIFY(QTest::qWaitForWindowExposed(window)); #if defined(Q_OS_UNIX) QCoreApplication::processEvents(); #endif diff --git a/tests/auto/other/qaccessibilitylinux/tst_qaccessibilitylinux.cpp b/tests/auto/other/qaccessibilitylinux/tst_qaccessibilitylinux.cpp index d40f9130ba..2575f22309 100644 --- a/tests/auto/other/qaccessibilitylinux/tst_qaccessibilitylinux.cpp +++ b/tests/auto/other/qaccessibilitylinux/tst_qaccessibilitylinux.cpp @@ -63,7 +63,7 @@ public: { layout()->addWidget(widget); widget->show(); - QTest::qWaitForWindowExposed(widget); + QVERIFY(QTest::qWaitForWindowExposed(widget)); } void clearChildren() @@ -182,7 +182,7 @@ void tst_QAccessibilityLinux::initTestCase() m_window = new AccessibleTestWindow(); m_window->show(); - QTest::qWaitForWindowExposed(m_window); + QVERIFY(QTest::qWaitForWindowExposed(m_window)); registerDbus(); } diff --git a/tests/auto/other/qaccessibilitymac/tst_qaccessibilitymac.cpp b/tests/auto/other/qaccessibilitymac/tst_qaccessibilitymac.cpp index 13c933aa14..ba0562f049 100644 --- a/tests/auto/other/qaccessibilitymac/tst_qaccessibilitymac.cpp +++ b/tests/auto/other/qaccessibilitymac/tst_qaccessibilitymac.cpp @@ -49,7 +49,7 @@ public: { layout()->addWidget(widget); widget->show(); - QTest::qWaitForWindowExposed(widget); + QVERIFY(QTest::qWaitForWindowExposed(widget)); } void clearChildren() @@ -84,7 +84,7 @@ void tst_QAccessibilityMac::init() m_window->show(); m_window->resize(400, 400); - QTest::qWaitForWindowExposed(m_window); + QVERIFY(QTest::qWaitForWindowExposed(m_window)); } void tst_QAccessibilityMac::cleanup() diff --git a/tests/auto/widgets/dialogs/qfiledialog2/tst_qfiledialog2.cpp b/tests/auto/widgets/dialogs/qfiledialog2/tst_qfiledialog2.cpp index d48ee03a22..79dfaee6f2 100644 --- a/tests/auto/widgets/dialogs/qfiledialog2/tst_qfiledialog2.cpp +++ b/tests/auto/widgets/dialogs/qfiledialog2/tst_qfiledialog2.cpp @@ -367,7 +367,7 @@ void tst_QFileDialog2::task143519_deleteAndRenameActionBehavior() fd.selectFile(ctx.file.fileName()); fd.show(); - QTest::qWaitForWindowActive(&fd); + QVERIFY(QTest::qWaitForWindowActive(&fd)); // grab some internals: QAction *rm = fd.findChild<QAction*>("qt_delete_action"); diff --git a/tests/auto/widgets/dialogs/qmessagebox/tst_qmessagebox.cpp b/tests/auto/widgets/dialogs/qmessagebox/tst_qmessagebox.cpp index 50f87b2c70..a5058f4b6c 100644 --- a/tests/auto/widgets/dialogs/qmessagebox/tst_qmessagebox.cpp +++ b/tests/auto/widgets/dialogs/qmessagebox/tst_qmessagebox.cpp @@ -594,7 +594,7 @@ void tst_QMessageBox::detailsText() box.setDetailedText(text); QCOMPARE(box.detailedText(), text); box.show(); - QTest::qWaitForWindowExposed(&box); + QVERIFY(QTest::qWaitForWindowExposed(&box)); // QTBUG-39334, the box should now have the default "Ok" button as well as // the "Show Details.." button. QCOMPARE(box.findChildren<QAbstractButton *>().size(), 2); @@ -647,7 +647,7 @@ void tst_QMessageBox::expandDetails_QTBUG_32473() // that the window manager is also done manipulating the first QMessageBox. QWidget fleece; fleece.show(); - QTest::qWaitForWindowExposed(&fleece); + QVERIFY(QTest::qWaitForWindowExposed(&fleece)); if (geom.topLeft() == box.geometry().topLeft()) QTest::qWait(500); QCOMPARE(geom.topLeft(), box.geometry().topLeft()); diff --git a/tests/auto/widgets/graphicsview/qgraphicsitem/tst_qgraphicsitem.cpp b/tests/auto/widgets/graphicsview/qgraphicsitem/tst_qgraphicsitem.cpp index 63fe2e6cb4..2599718651 100644 --- a/tests/auto/widgets/graphicsview/qgraphicsitem/tst_qgraphicsitem.cpp +++ b/tests/auto/widgets/graphicsview/qgraphicsitem/tst_qgraphicsitem.cpp @@ -11419,7 +11419,7 @@ void tst_QGraphicsItem::doNotMarkFullUpdateIfNotInScene() item2->setParentItem(item); scene.addItem(item); view.show(); - QTest::qWaitForWindowActive(view.windowHandle()); + QVERIFY(QTest::qWaitForWindowActive(view.windowHandle())); view.activateWindow(); QTRY_VERIFY(view.isActiveWindow()); QTRY_VERIFY(view.repaints >= 1); diff --git a/tests/auto/widgets/graphicsview/qgraphicsproxywidget/tst_qgraphicsproxywidget.cpp b/tests/auto/widgets/graphicsview/qgraphicsproxywidget/tst_qgraphicsproxywidget.cpp index e49cd87941..07d195b3e8 100644 --- a/tests/auto/widgets/graphicsview/qgraphicsproxywidget/tst_qgraphicsproxywidget.cpp +++ b/tests/auto/widgets/graphicsview/qgraphicsproxywidget/tst_qgraphicsproxywidget.cpp @@ -824,7 +824,7 @@ void tst_QGraphicsProxyWidget::focusOutEvent() QApplication::setActiveWindow(&view); view.activateWindow(); view.setFocus(); - QTest::qWaitForWindowActive(&view); + QVERIFY(QTest::qWaitForWindowActive(&view)); QTRY_VERIFY(view.isVisible()); QTRY_COMPARE(QApplication::activeWindow(), (QWidget*)&view); diff --git a/tests/auto/widgets/graphicsview/qgraphicsview/tst_qgraphicsview.cpp b/tests/auto/widgets/graphicsview/qgraphicsview/tst_qgraphicsview.cpp index 3d87836698..ac38819385 100644 --- a/tests/auto/widgets/graphicsview/qgraphicsview/tst_qgraphicsview.cpp +++ b/tests/auto/widgets/graphicsview/qgraphicsview/tst_qgraphicsview.cpp @@ -688,7 +688,7 @@ void tst_QGraphicsView::openGLViewport() view.setViewport(glw); view.show(); - QTest::qWaitForWindowExposed(&view); + QVERIFY(QTest::qWaitForWindowExposed(&view)); QTRY_VERIFY(spy1.count() > 0); QTRY_VERIFY(spy2.count() >= spy1.count()); spy1.clear(); diff --git a/tests/auto/widgets/itemviews/qabstractitemview/tst_qabstractitemview.cpp b/tests/auto/widgets/itemviews/qabstractitemview/tst_qabstractitemview.cpp index 0fbb909646..7811c13ee1 100644 --- a/tests/auto/widgets/itemviews/qabstractitemview/tst_qabstractitemview.cpp +++ b/tests/auto/widgets/itemviews/qabstractitemview/tst_qabstractitemview.cpp @@ -55,6 +55,8 @@ #include <qproxystyle.h> #include <qdialog.h> +Q_DECLARE_METATYPE(Qt::ItemFlags); + static inline void setFrameless(QWidget *w) { Qt::WindowFlags flags = w->windowFlags(); @@ -154,6 +156,8 @@ private slots: void testDialogAsEditor(); void QTBUG46785_mouseout_hover_state(); void testClearModelInClickedSignal(); + void inputMethodEnabled_data(); + void inputMethodEnabled(); }; class MyAbstractItemDelegate : public QAbstractItemDelegate @@ -1811,7 +1815,7 @@ void tst_QAbstractItemView::shiftSelectionAfterChangingModelContents() view.setModel(&proxyModel); view.setSelectionMode(QAbstractItemView::ExtendedSelection); view.show(); - QTest::qWaitForWindowExposed(&view); + QVERIFY(QTest::qWaitForWindowExposed(&view)); // Click "C" QTest::mouseClick(view.viewport(), Qt::LeftButton, Qt::NoModifier, view.visualRect(indexC).center()); @@ -1925,7 +1929,7 @@ void tst_QAbstractItemView::QTBUG48968_reentrant_updateEditorGeometries() tree.setRootIsDecorated(false); QObject::connect(&tree, SIGNAL(doubleClicked(QModelIndex)), &tree, SLOT(setRootIndex(QModelIndex))); tree.show(); - QTest::qWaitForWindowActive(&tree); + QVERIFY(QTest::qWaitForWindowActive(&tree)); // Trigger editing idx QModelIndex idx = m->index(1, 0); @@ -2167,7 +2171,7 @@ void tst_QAbstractItemView::testClickToSelect() SetSelectionTestView view; view.setModel(&model); view.show(); - QTest::qWaitForWindowExposed(&view); + QVERIFY(QTest::qWaitForWindowExposed(&view)); QSignalSpy spy(&view, &SetSelectionTestView::setSelectionCalled); @@ -2295,5 +2299,107 @@ void tst_QAbstractItemView::testClearModelInClickedSignal() QCOMPARE(view.model(), nullptr); } +void tst_QAbstractItemView::inputMethodEnabled_data() +{ + QTest::addColumn<QByteArray>("viewType"); + QTest::addColumn<Qt::ItemFlags>("itemFlags"); + QTest::addColumn<bool>("result"); + + QList<QByteArray> widgets; + widgets << "QListView" << "QTreeView" << "QTableView"; + + for (const QByteArray &widget : qAsConst(widgets)) { + QTest::newRow(widget + ": no flags") << widget << Qt::ItemFlags(Qt::NoItemFlags) << false; + QTest::newRow(widget + ": checkable") << widget << Qt::ItemFlags(Qt::ItemIsUserCheckable) << false; + QTest::newRow(widget + ": selectable") << widget << Qt::ItemFlags(Qt::ItemIsSelectable) << false; + QTest::newRow(widget + ": enabled") << widget << Qt::ItemFlags(Qt::ItemIsEnabled) << false; + QTest::newRow(widget + ": selectable|enabled") + << widget << Qt::ItemFlags(Qt::ItemIsSelectable | Qt::ItemIsEnabled) << false; + QTest::newRow(widget + ": editable|enabled") + << widget << Qt::ItemFlags(Qt::ItemIsEditable | Qt::ItemIsEnabled) << true; + QTest::newRow(widget + ": editable|enabled|selectable") + << widget << Qt::ItemFlags(Qt::ItemIsEditable | Qt::ItemIsEnabled | Qt::ItemIsSelectable) << true; + } +} + +void tst_QAbstractItemView::inputMethodEnabled() +{ + QFETCH(QByteArray, viewType); + QFETCH(Qt::ItemFlags, itemFlags); + QFETCH(bool, result); + + QScopedPointer<QAbstractItemView> view; + if (viewType == "QListView") + view.reset(new QListView()); + else if (viewType == "QTableView") + view.reset(new QTableView()); + else if (viewType == "QTreeView") + view.reset(new QTreeView()); + else + QVERIFY(0); + + centerOnScreen(view.data()); + view->show(); + QVERIFY(QTest::qWaitForWindowExposed(view.data())); + + QStandardItemModel *model = new QStandardItemModel(view.data()); + QStandardItem *item = new QStandardItem("first item"); + item->setFlags(Qt::ItemIsSelectable | Qt::ItemIsEnabled); + model->appendRow(item); + + QStandardItem *secondItem = new QStandardItem("test item"); + secondItem->setFlags(Qt::ItemFlags(itemFlags)); + model->appendRow(secondItem); + + view->setModel(model); + + // Check current changed + view->setCurrentIndex(model->index(0, 0)); + QVERIFY(!view->testAttribute(Qt::WA_InputMethodEnabled)); + view->setCurrentIndex(model->index(1, 0)); + QCOMPARE(view->testAttribute(Qt::WA_InputMethodEnabled), result); + view->setCurrentIndex(model->index(0, 0)); + QVERIFY(!view->testAttribute(Qt::WA_InputMethodEnabled)); + + // Check focus by switching the activation of the window to force a focus in + view->setCurrentIndex(model->index(1, 0)); + QApplication::setActiveWindow(0); + QApplication::setActiveWindow(view.data()); + QVERIFY(QTest::qWaitForWindowActive(view.data())); + QCOMPARE(view->testAttribute(Qt::WA_InputMethodEnabled), result); + + view->setCurrentIndex(QModelIndex()); + QVERIFY(!view->testAttribute(Qt::WA_InputMethodEnabled)); + QApplication::setActiveWindow(0); + QApplication::setActiveWindow(view.data()); + QVERIFY(QTest::qWaitForWindowActive(view.data())); + QModelIndex index = model->index(1, 0); + QPoint p = view->visualRect(index).center(); + QTest::mouseClick(view->viewport(), Qt::LeftButton, Qt::NoModifier, p); + if (itemFlags & Qt::ItemIsEnabled) + QCOMPARE(view->currentIndex(), index); + QCOMPARE(view->testAttribute(Qt::WA_InputMethodEnabled), result); + + index = model->index(0, 0); + QApplication::setActiveWindow(0); + QApplication::setActiveWindow(view.data()); + QVERIFY(QTest::qWaitForWindowActive(view.data())); + p = view->visualRect(index).center(); + QTest::mouseClick(view->viewport(), Qt::LeftButton, Qt::NoModifier, p); + QCOMPARE(view->currentIndex(), index); + QVERIFY(!view->testAttribute(Qt::WA_InputMethodEnabled)); + + // There is a case when it goes to the first visible item so we + // make the flags of the first item match the ones we are testing + // to check the attribute correctly + QApplication::setActiveWindow(0); + view->setCurrentIndex(QModelIndex()); + view->reset(); + item->setFlags(Qt::ItemFlags(itemFlags)); + QApplication::setActiveWindow(view.data()); + QVERIFY(QTest::qWaitForWindowActive(view.data())); + QCOMPARE(view->testAttribute(Qt::WA_InputMethodEnabled), result); +} + QTEST_MAIN(tst_QAbstractItemView) #include "tst_qabstractitemview.moc" diff --git a/tests/auto/widgets/itemviews/qitemdelegate/BLACKLIST b/tests/auto/widgets/itemviews/qitemdelegate/BLACKLIST index a16fd19b99..fea108f3fd 100644 --- a/tests/auto/widgets/itemviews/qitemdelegate/BLACKLIST +++ b/tests/auto/widgets/itemviews/qitemdelegate/BLACKLIST @@ -1,2 +1,4 @@ [enterKey] -opensuse-42.3 +opensuse-42.3 ci +[testLineEditValidation] +opensuse-42.3 ci diff --git a/tests/auto/widgets/itemviews/qlistview/tst_qlistview.cpp b/tests/auto/widgets/itemviews/qlistview/tst_qlistview.cpp index 11bd118e4b..59895e4e7d 100644 --- a/tests/auto/widgets/itemviews/qlistview/tst_qlistview.cpp +++ b/tests/auto/widgets/itemviews/qlistview/tst_qlistview.cpp @@ -2163,7 +2163,7 @@ void tst_QListView::draggablePaintPairs() view.setModel(&model); view.show(); - QTest::qWaitForWindowExposed(&view); + QVERIFY(QTest::qWaitForWindowExposed(&view)); QModelIndex expectedIndex = model.index(row, 0); QListViewPrivate *privateClass = static_cast<QListViewPrivate *>(QListViewPrivate::get(&view)); @@ -2207,7 +2207,7 @@ void tst_QListView::taskQTBUG_21804_hiddenItemsAndScrollingWithKeys() lv.setSpacing(spacing); lv.setModel(&model); lv.show(); - QTest::qWaitForWindowExposed(&lv); + QVERIFY(QTest::qWaitForWindowExposed(&lv)); // hide every odd number row for (int i = 1; i < model.rowCount(); i+=2) @@ -2279,7 +2279,7 @@ void tst_QListView::spacing() lv.setModel(&model); lv.setSpacing(spacing); lv.show(); - QTest::qWaitForWindowExposed(&lv); + QVERIFY(QTest::qWaitForWindowExposed(&lv)); // check size and position of first two items QRect item1 = lv.visualRect(lv.model()->index(0, 0)); @@ -2310,7 +2310,7 @@ void tst_QListView::testScrollToWithHidden() lv.setSpacing(5); lv.showNormal(); - QTest::qWaitForWindowExposed(&lv); + QVERIFY(QTest::qWaitForWindowExposed(&lv)); QCOMPARE(lv.verticalScrollBar()->value(), 0); @@ -2455,7 +2455,7 @@ void tst_QListView::horizontalScrollingByVerticalWheelEvents() lv.resize(300, 300); lv.show(); - QTest::qWaitForWindowExposed(&lv); + QVERIFY(QTest::qWaitForWindowExposed(&lv)); QPoint globalPos = lv.geometry().center(); QPoint pos = lv.viewport()->geometry().center(); diff --git a/tests/auto/widgets/itemviews/qtreeview/tst_qtreeview.cpp b/tests/auto/widgets/itemviews/qtreeview/tst_qtreeview.cpp index e761ce2833..e9a29d444a 100644 --- a/tests/auto/widgets/itemviews/qtreeview/tst_qtreeview.cpp +++ b/tests/auto/widgets/itemviews/qtreeview/tst_qtreeview.cpp @@ -4239,7 +4239,7 @@ void tst_QTreeView::testInitialFocus() treeWidget.header()->hideSection(0); // make sure we skip hidden section(s) treeWidget.header()->swapSections(1, 2); // make sure that we look for first visual index (and not first logical) treeWidget.show(); - QTest::qWaitForWindowExposed(&treeWidget); + QVERIFY(QTest::qWaitForWindowExposed(&treeWidget)); QApplication::processEvents(); QCOMPARE(treeWidget.currentIndex().column(), 2); } @@ -4262,7 +4262,7 @@ void tst_QTreeView::quickExpandCollapse() QVERIFY(rootIndex.isValid()); tree.show(); - QTest::qWaitForWindowExposed(&tree); + QVERIFY(QTest::qWaitForWindowExposed(&tree)); const QAbstractItemView::State initialState = tree.state(); @@ -4456,7 +4456,7 @@ void tst_QTreeView::statusTip() QSize(500, 500))); mw.show(); qApp->setActiveWindow(&mw); - QTest::qWaitForWindowActive(&mw); + QVERIFY(QTest::qWaitForWindowActive(&mw)); // Ensure it is moved away first and then moved to the relevant section QTest::mouseMove(mw.windowHandle(), view->mapTo(&mw, view->rect().bottomLeft() + QPoint(20, 20))); QPoint centerPoint = view->viewport()->mapTo(&mw, view->visualRect(model.index(0, 0)).center()); diff --git a/tests/auto/widgets/kernel/qboxlayout/tst_qboxlayout.cpp b/tests/auto/widgets/kernel/qboxlayout/tst_qboxlayout.cpp index c39c770316..570caf851d 100644 --- a/tests/auto/widgets/kernel/qboxlayout/tst_qboxlayout.cpp +++ b/tests/auto/widgets/kernel/qboxlayout/tst_qboxlayout.cpp @@ -160,7 +160,7 @@ void tst_QBoxLayout::sizeHint() lay1->addLayout(lay2); window.setLayout(lay1); window.show(); - QTest::qWaitForWindowExposed(&window); + QVERIFY(QTest::qWaitForWindowExposed(&window)); label->setText("foooooooo baaaaaaar"); QSize sh = lay1->sizeHint(); QApplication::processEvents(); @@ -181,7 +181,7 @@ void tst_QBoxLayout::sizeConstraints() lay->setSizeConstraint(QLayout::SetFixedSize); window.setLayout(lay); window.show(); - QTest::qWaitForWindowExposed(&window); + QVERIFY(QTest::qWaitForWindowExposed(&window)); QSize sh = window.sizeHint(); delete lay->takeAt(1); QVERIFY(sh.width() >= window.sizeHint().width() && @@ -228,7 +228,7 @@ void tst_QBoxLayout::setStyleShouldChangeSpacing() style1->hspacing = 6; window.setStyle(style1.data()); window.show(); - QTest::qWaitForWindowExposed(&window); + QVERIFY(QTest::qWaitForWindowExposed(&window)); int spacing = pb2->geometry().left() - pb1->geometry().right() - 1; QCOMPARE(spacing, 6); diff --git a/tests/auto/widgets/kernel/qwidget/tst_qwidget.cpp b/tests/auto/widgets/kernel/qwidget/tst_qwidget.cpp index 81fb332a62..df6eab7a45 100644 --- a/tests/auto/widgets/kernel/qwidget/tst_qwidget.cpp +++ b/tests/auto/widgets/kernel/qwidget/tst_qwidget.cpp @@ -199,6 +199,7 @@ private slots: void defaultTabOrder(); void reverseTabOrder(); void tabOrderWithProxy(); + void tabOrderWithCompoundWidgets(); #ifdef Q_OS_WIN void activation(); #endif @@ -1665,22 +1666,26 @@ public: class Composite : public QFrame { public: - Composite(QWidget* parent = 0, const char* name = 0) + Composite(QWidget* parent = 0, const QString &name = 0) : QFrame(parent) { setObjectName(name); lineEdit1 = new QLineEdit; lineEdit2 = new QLineEdit; + lineEdit3 = new QLineEdit; + lineEdit3->setEnabled(false); QHBoxLayout* hbox = new QHBoxLayout(this); hbox->addWidget(lineEdit1); hbox->addWidget(lineEdit2); + hbox->addWidget(lineEdit3); } public: QLineEdit *lineEdit1; QLineEdit *lineEdit2; + QLineEdit *lineEdit3; }; void tst_QWidget::defaultTabOrder() @@ -1851,6 +1856,93 @@ void tst_QWidget::tabOrderWithProxy() QVERIFY(firstEdit->hasFocus()); } +void tst_QWidget::tabOrderWithCompoundWidgets() +{ + const int compositeCount = 4; + Container container; + Composite *composite[compositeCount]; + + QLineEdit *firstEdit = new QLineEdit(); + container.box->addWidget(firstEdit); + + for (int i = 0; i < compositeCount; i++) { + composite[i] = new Composite(0, QStringLiteral("Composite: ") + QString::number(i)); + container.box->addWidget(composite[i]); + + // Let the composite handle focus, and set a child as focus proxy (use the second child, just + // to ensure that we don't just tab to the first child by coinsidence). This will make the + // composite "compound". Also enable the last line edit to have a bit more data to check when + // tabbing forwards. + composite[i]->setFocusPolicy(Qt::StrongFocus); + composite[i]->setFocusProxy(composite[i]->lineEdit2); + composite[i]->lineEdit3->setEnabled(true); + } + + QLineEdit *lastEdit = new QLineEdit(); + container.box->addWidget(lastEdit); + + // Reverse tab order between each composite + // (but not inside them), including first and last line edit. + // The result should not affect local tab order inside each + // composite, only between them. + QWidget::setTabOrder(lastEdit, composite[compositeCount - 1]); + for (int i = compositeCount - 1; i >= 1; --i) + QWidget::setTabOrder(composite[i], composite[i-1]); + QWidget::setTabOrder(composite[0], firstEdit); + + container.show(); + container.activateWindow(); + qApp->setActiveWindow(&container); + QVERIFY(QTest::qWaitForWindowActive(&container)); + + lastEdit->setFocus(); + QTRY_VERIFY(lastEdit->hasFocus()); + + // Check that focus moves between the line edits in the normal + // order when tabbing inside each compound, but in the reverse + // order when tabbing between them. Since the composites have + // lineEdit2 as focus proxy, lineEdit2 will be the first with focus + // when the compound gets focus, and lineEdit1 will therefore be skipped. + for (int i = compositeCount - 1; i >= 0; --i) { + container.tab(); + Composite *c = composite[i]; + QVERIFY(!c->lineEdit1->hasFocus()); + QVERIFY(c->lineEdit2->hasFocus()); + QVERIFY(!c->lineEdit3->hasFocus()); + container.tab(); + QVERIFY(!c->lineEdit1->hasFocus()); + QVERIFY(!c->lineEdit2->hasFocus()); + QVERIFY(c->lineEdit3->hasFocus()); + } + + container.tab(); + QVERIFY(firstEdit->hasFocus()); + + // Check that focus moves in reverse order when backTab inside the composites, but + // in the 'correct' order when backTab between them (since the composites are in reverse tab + // order from before, which cancels it out). Note that when we backtab into a compound, we start + // at lineEdit3 rather than the focus proxy, since that is the reverse of what happens when we tab + // forward. And this time we will also backtab to lineEdit1, since there is no focus proxy that interferes. + for (int i = 0; i < compositeCount; ++i) { + container.backTab(); + Composite *c = composite[i]; + QVERIFY(!c->lineEdit1->hasFocus()); + QVERIFY(!c->lineEdit2->hasFocus()); + QVERIFY(c->lineEdit3->hasFocus()); + container.backTab(); + QVERIFY(!c->lineEdit1->hasFocus()); + QVERIFY(c->lineEdit2->hasFocus()); + QVERIFY(!c->lineEdit3->hasFocus()); + container.backTab(); + QVERIFY(c->lineEdit1->hasFocus()); + QVERIFY(!c->lineEdit2->hasFocus()); + QVERIFY(!c->lineEdit3->hasFocus()); + } + + container.backTab(); + QVERIFY(lastEdit->hasFocus()); +} + #ifdef Q_OS_WIN void tst_QWidget::activation() { @@ -2207,7 +2299,7 @@ void tst_QWidget::resizeEvent() wParent.resize(200, 200); ResizeWidget wChild(&wParent); wParent.show(); - QTest::qWaitForWindowExposed(&wParent); + QVERIFY(QTest::qWaitForWindowExposed(&wParent)); QCOMPARE (wChild.m_resizeEventCount, 1); // initial resize event before paint wParent.hide(); QSize safeSize(640,480); @@ -2223,7 +2315,7 @@ void tst_QWidget::resizeEvent() ResizeWidget wTopLevel; wTopLevel.resize(200, 200); wTopLevel.show(); - QTest::qWaitForWindowExposed(&wTopLevel); + QVERIFY(QTest::qWaitForWindowExposed(&wTopLevel)); QCOMPARE (wTopLevel.m_resizeEventCount, 1); // initial resize event before paint for toplevels wTopLevel.hide(); QSize safeSize(640,480); @@ -2232,7 +2324,7 @@ void tst_QWidget::resizeEvent() wTopLevel.resize(safeSize); QCOMPARE (wTopLevel.m_resizeEventCount, 1); wTopLevel.show(); - QTest::qWaitForWindowExposed(&wTopLevel); + QVERIFY(QTest::qWaitForWindowExposed(&wTopLevel)); QCOMPARE (wTopLevel.m_resizeEventCount, 2); } } diff --git a/tests/auto/widgets/kernel/qwidget_window/tst_qwidget_window.cpp b/tests/auto/widgets/kernel/qwidget_window/tst_qwidget_window.cpp index a158b6cbc9..71faf99790 100644 --- a/tests/auto/widgets/kernel/qwidget_window/tst_qwidget_window.cpp +++ b/tests/auto/widgets/kernel/qwidget_window/tst_qwidget_window.cpp @@ -851,7 +851,7 @@ void tst_QWidget_window::QTBUG_50561_QCocoaBackingStore_paintDevice_crash() QMainWindow w; w.addToolBar(new QToolBar(&w)); w.show(); - QTest::qWaitForWindowExposed(&w); + QVERIFY(QTest::qWaitForWindowExposed(&w)); // Simulate window system close QCloseEvent *e = new QCloseEvent; @@ -907,7 +907,8 @@ void tst_QWidget_window::setWindowState() w.show(); QCOMPARE(w.windowState(), state); QCOMPARE(w.windowHandle()->windowStates(), state); - QTest::qWaitForWindowExposed(&w); + if (!(state & Qt::WindowMinimized)) + QVERIFY(QTest::qWaitForWindowExposed(&w)); QTRY_COMPARE(w.windowState(), state); QCOMPARE(w.windowHandle()->windowStates(), state); @@ -925,7 +926,7 @@ void tst_QWidget_window::nativeShow() QWidget w; w.winId(); w.windowHandle()->setVisible(true); - QTest::qWaitForWindowExposed(&w); + QVERIFY(QTest::qWaitForWindowExposed(&w)); QVERIFY(w.isVisible()); // ... and that we can hide it diff --git a/tests/auto/widgets/kernel/qwindowcontainer/tst_qwindowcontainer.cpp b/tests/auto/widgets/kernel/qwindowcontainer/tst_qwindowcontainer.cpp index 6ec1b754d0..a3e549aa50 100644 --- a/tests/auto/widgets/kernel/qwindowcontainer/tst_qwindowcontainer.cpp +++ b/tests/auto/widgets/kernel/qwindowcontainer/tst_qwindowcontainer.cpp @@ -74,6 +74,7 @@ private slots: void testOwnership(); void testBehindTheScenesDeletion(); void testUnparenting(); + void testUnparentReparent(); void testActivation(); void testAncestorChange(); void testDockWidget(); @@ -241,6 +242,31 @@ void tst_QWindowContainer::testUnparenting() QVERIFY(!window->isVisible()); } +void tst_QWindowContainer::testUnparentReparent() +{ + QWidget root; + + QWindow *window = new QWindow(); + QScopedPointer<QWidget> container(QWidget::createWindowContainer(window, &root)); + container->setWindowTitle(QTest::currentTestFunction()); + container->setGeometry(m_availableGeometry.x() + 100, m_availableGeometry.y() + 100, 200, 100); + + root.show(); + + QVERIFY(QTest::qWaitForWindowExposed(&root)); + + QTRY_VERIFY(window->isVisible()); + + container->setParent(nullptr); + QTRY_VERIFY(!window->isVisible()); + + container->show(); + QVERIFY(QTest::qWaitForWindowExposed(window)); + QTRY_VERIFY(window->isVisible()); + + container->setParent(&root); // This should not crash (QTBUG-63168) +} + void tst_QWindowContainer::testAncestorChange() { QWidget root; diff --git a/tests/auto/widgets/util/qcompleter/tst_qcompleter.cpp b/tests/auto/widgets/util/qcompleter/tst_qcompleter.cpp index f8095badb8..3818b83584 100644 --- a/tests/auto/widgets/util/qcompleter/tst_qcompleter.cpp +++ b/tests/auto/widgets/util/qcompleter/tst_qcompleter.cpp @@ -143,6 +143,8 @@ private slots: void task253125_lineEditCompletion(); void task247560_keyboardNavigation(); void QTBUG_14292_filesystem(); + void QTBUG_52028_tabAutoCompletes(); + void QTBUG_51889_activatedSentTwice(); private: void filter(bool assync = false); @@ -1742,5 +1744,108 @@ void tst_QCompleter::QTBUG_14292_filesystem() QVERIFY(!comp.popup()->isVisible()); } +void tst_QCompleter::QTBUG_52028_tabAutoCompletes() +{ + QStringList words; + words << "foobar1" << "foobar2" << "hux"; + + QWidget w; + w.setLayout(new QVBoxLayout); + + QComboBox cbox; + cbox.setEditable(true); + cbox.setInsertPolicy(QComboBox::NoInsert); + cbox.addItems(words); + + cbox.completer()->setCaseSensitivity(Qt::CaseInsensitive); + cbox.completer()->setCompletionMode(QCompleter::PopupCompletion); + + w.layout()->addWidget(&cbox); + + // Adding a line edit is a good reason for tab to do something unrelated + QLineEdit le; + w.layout()->addWidget(&le); + + const auto pos = QApplication::desktop()->availableGeometry(&w).topLeft() + QPoint(200,200); + w.move(pos); + w.show(); + QApplication::setActiveWindow(&w); + QVERIFY(QTest::qWaitForWindowActive(&w)); + + QSignalSpy activatedSpy(&cbox, QOverload<int>::of(&QComboBox::activated)); + + // Tab key will complete but not activate + cbox.lineEdit()->clear(); + QTest::keyClick(&cbox, Qt::Key_H); + QVERIFY(cbox.completer()->popup()); + QTRY_VERIFY(cbox.completer()->popup()->isVisible()); + QTest::keyClick(cbox.completer()->popup(), Qt::Key_Tab); + QCOMPARE(cbox.completer()->currentCompletion(), QLatin1String("hux")); + QCOMPARE(activatedSpy.count(), 0); + QEXPECT_FAIL("", "QTBUG-52028 will not be fixed today.", Abort); + QCOMPARE(cbox.currentText(), QLatin1String("hux")); + QCOMPARE(activatedSpy.count(), 0); + QVERIFY(!le.hasFocus()); +} + +void tst_QCompleter::QTBUG_51889_activatedSentTwice() +{ + QStringList words; + words << "foobar1" << "foobar2" << "bar" <<"hux"; + + QWidget w; + w.setLayout(new QVBoxLayout); + + QComboBox cbox; + setFrameless(&cbox); + cbox.setEditable(true); + cbox.setInsertPolicy(QComboBox::NoInsert); + cbox.addItems(words); + + cbox.completer()->setCaseSensitivity(Qt::CaseInsensitive); + cbox.completer()->setCompletionMode(QCompleter::PopupCompletion); + + w.layout()->addWidget(&cbox); + + QLineEdit le; + w.layout()->addWidget(&le); + + const auto pos = QApplication::desktop()->availableGeometry(&w).topLeft() + QPoint(200,200); + w.move(pos); + w.show(); + QApplication::setActiveWindow(&w); + QVERIFY(QTest::qWaitForWindowActive(&w)); + + QSignalSpy activatedSpy(&cbox, QOverload<int>::of(&QComboBox::activated)); + + // Navigate + enter activates only once (first item) + cbox.lineEdit()->clear(); + QTest::keyClick(&cbox, Qt::Key_F); + QVERIFY(cbox.completer()->popup()); + QTRY_VERIFY(cbox.completer()->popup()->isVisible()); + QTest::keyClick(cbox.completer()->popup(), Qt::Key_Down); + QTest::keyClick(cbox.completer()->popup(), Qt::Key_Return); + QTRY_COMPARE(activatedSpy.count(), 1); + + // Navigate + enter activates only once (non-first item) + cbox.lineEdit()->clear(); + activatedSpy.clear(); + QTest::keyClick(&cbox, Qt::Key_H); + QVERIFY(cbox.completer()->popup()); + QTRY_VERIFY(cbox.completer()->popup()->isVisible()); + QTest::keyClick(cbox.completer()->popup(), Qt::Key_Down); + QTest::keyClick(cbox.completer()->popup(), Qt::Key_Return); + QTRY_COMPARE(activatedSpy.count(), 1); + + // Full text + enter activates only once + cbox.lineEdit()->clear(); + activatedSpy.clear(); + QTest::keyClicks(&cbox, "foobar1"); + QVERIFY(cbox.completer()->popup()); + QTRY_VERIFY(cbox.completer()->popup()->isVisible()); + QTest::keyClick(&cbox, Qt::Key_Return); + QTRY_COMPARE(activatedSpy.count(), 1); +} + QTEST_MAIN(tst_QCompleter) #include "tst_qcompleter.moc" diff --git a/tests/auto/widgets/widgets/qcombobox/tst_qcombobox.cpp b/tests/auto/widgets/widgets/qcombobox/tst_qcombobox.cpp index 3415d06bc6..e33171a7cf 100644 --- a/tests/auto/widgets/widgets/qcombobox/tst_qcombobox.cpp +++ b/tests/auto/widgets/widgets/qcombobox/tst_qcombobox.cpp @@ -2261,7 +2261,7 @@ void tst_QComboBox::task190351_layout() listCombo.setCurrentIndex(70); listCombo.showPopup(); QTRY_VERIFY(listCombo.view()); - QTest::qWaitForWindowExposed(listCombo.view()); + QVERIFY(QTest::qWaitForWindowExposed(listCombo.view())); QTRY_VERIFY(listCombo.view()->isVisible()); QApplication::processEvents(); @@ -2408,7 +2408,7 @@ void tst_QComboBox::task248169_popupWithMinimalSize() QTRY_VERIFY(comboBox.isVisible()); comboBox.showPopup(); QTRY_VERIFY(comboBox.view()); - QTest::qWaitForWindowExposed(comboBox.view()); + QVERIFY(QTest::qWaitForWindowExposed(comboBox.view())); QTRY_VERIFY(comboBox.view()->isVisible()); #if defined QT_BUILD_INTERNAL @@ -3254,12 +3254,12 @@ void tst_QComboBox::task_QTBUG_49831_scrollerNotActivated() box.setModel(&model); box.setCurrentIndex(500); box.show(); - QTest::qWaitForWindowExposed(&box); + QVERIFY(QTest::qWaitForWindowExposed(&box)); QTest::mouseMove(&box, QPoint(5, 5), 100); box.showPopup(); QFrame *container = box.findChild<QComboBoxPrivateContainer *>(); QVERIFY(container); - QTest::qWaitForWindowExposed(container); + QVERIFY(QTest::qWaitForWindowExposed(container)); QList<QComboBoxPrivateScroller *> scrollers = container->findChildren<QComboBoxPrivateScroller *>(); // Not all styles support scrollers. We rely only on those platforms that do to catch any regression. @@ -3335,11 +3335,11 @@ void tst_QComboBox::task_QTBUG_56693_itemFontFromModel() box.addItem(QLatin1String("Item ") + QString::number(i)); box.show(); - QTest::qWaitForWindowExposed(&box); + QVERIFY(QTest::qWaitForWindowExposed(&box)); box.showPopup(); QFrame *container = box.findChild<QComboBoxPrivateContainer *>(); QVERIFY(container); - QTest::qWaitForWindowExposed(container); + QVERIFY(QTest::qWaitForWindowExposed(container)); QCOMPARE(proxyStyle->italicItemsNo, 5); diff --git a/tests/auto/widgets/widgets/qlineedit/tst_qlineedit.cpp b/tests/auto/widgets/widgets/qlineedit/tst_qlineedit.cpp index a396063c1c..255ea04771 100644 --- a/tests/auto/widgets/widgets/qlineedit/tst_qlineedit.cpp +++ b/tests/auto/widgets/widgets/qlineedit/tst_qlineedit.cpp @@ -1930,7 +1930,7 @@ void tst_QLineEdit::noCursorBlinkWhenReadOnly() centerOnScreen(&le); le.show(); le.setFocus(); - QTest::qWaitForWindowActive(&le); + QVERIFY(QTest::qWaitForWindowActive(&le)); le.updates = 0; QTest::qWait(cursorFlashTime); QVERIFY(le.updates > 0); @@ -3368,7 +3368,7 @@ void tst_QLineEdit::inlineCompletion() completer->setCaseSensitivity(Qt::CaseInsensitive); centerOnScreen(testWidget); testWidget->show(); - QTest::qWaitForWindowExposed(testWidget); + QVERIFY(QTest::qWaitForWindowExposed(testWidget)); testWidget->setFocus(); QTRY_COMPARE(qApp->activeWindow(), (QWidget*)testWidget); testWidget->setCompleter(completer); @@ -3696,7 +3696,7 @@ void tst_QLineEdit::task229938_dontEmitChangedWhenTextIsNotChanged() QLineEdit lineEdit; lineEdit.setMaxLength(5); lineEdit.show(); - QTest::qWaitForWindowExposed(&lineEdit); // to be safe and avoid failing setFocus with window managers + QVERIFY(QTest::qWaitForWindowExposed(&lineEdit)); // to be safe and avoid failing setFocus with window managers lineEdit.setFocus(); QSignalSpy changedSpy(&lineEdit, SIGNAL(textChanged(QString))); QTest::qWait(200); diff --git a/tests/auto/widgets/widgets/qmainwindow/tst_qmainwindow.cpp b/tests/auto/widgets/widgets/qmainwindow/tst_qmainwindow.cpp index 292080c55f..30dc1e6043 100644 --- a/tests/auto/widgets/widgets/qmainwindow/tst_qmainwindow.cpp +++ b/tests/auto/widgets/widgets/qmainwindow/tst_qmainwindow.cpp @@ -2013,7 +2013,7 @@ void tst_QMainWindow::resizeDocks() mw.setCentralWidget(new QTextEdit); mw.show(); - QTest::qWaitForWindowExposed(&mw); + QVERIFY(QTest::qWaitForWindowExposed(&mw)); QFETCH(Qt::Orientation, orientation); QFETCH(QStringList, docks); diff --git a/tests/auto/widgets/widgets/qmenubar/tst_qmenubar.cpp b/tests/auto/widgets/widgets/qmenubar/tst_qmenubar.cpp index 789ea57dfc..fd1248bd53 100644 --- a/tests/auto/widgets/widgets/qmenubar/tst_qmenubar.cpp +++ b/tests/auto/widgets/widgets/qmenubar/tst_qmenubar.cpp @@ -39,6 +39,7 @@ #include <qstyleoption.h> #include <QVBoxLayout> #include <QLabel> +#include <QPlainTextEdit> #include <qscreen.h> #include <qobject.h> @@ -106,6 +107,7 @@ private slots: void allowActiveAndDisabled(); #endif + void taskQTBUG56860_focus(); void check_endKey(); void check_homeKey(); @@ -710,6 +712,52 @@ void tst_QMenuBar::check_cursorKeys3() } #endif +void tst_QMenuBar::taskQTBUG56860_focus() +{ +#if defined(Q_OS_DARWIN) + QSKIP("Native key events are needed to test menu action activation on macOS."); +#endif + QMainWindow w; + QMenuBar *mb = w.menuBar(); + + if (mb->platformMenuBar()) + QSKIP("This test requires the Qt menubar."); + + QMenu *em = mb->addMenu("&Edit"); + em->setObjectName("EditMenu"); + em->addAction("&Cut"); + em->addAction("C&opy"); + QPlainTextEdit *e = new QPlainTextEdit; + e->setObjectName("edit"); + + w.setCentralWidget(e); + w.show(); + QApplication::setActiveWindow(&w); + QVERIFY(QTest::qWaitForWindowActive(&w)); + + QTRY_COMPARE(QApplication::focusWidget(), e); + + // Open menu + QTest::keyClick(static_cast<QWidget *>(0), Qt::Key_E, Qt::AltModifier ); + QTRY_COMPARE(QApplication::activePopupWidget(), em); + // key down to trigger focus + QTest::keyClick(static_cast<QWidget *>(0), Qt::Key_Down ); + // and press ENTER to close + QTest::keyClick(static_cast<QWidget *>(0), Qt::Key_Enter ); + QTRY_COMPARE(QApplication::activePopupWidget(), nullptr); + // focus should have returned to the editor by now + QTRY_COMPARE(QApplication::focusWidget(), e); + + // Now do it all over again... + QTest::keyClick(static_cast<QWidget *>(0), Qt::Key_E, Qt::AltModifier ); + QTRY_COMPARE(QApplication::activePopupWidget(), em); + QTest::keyClick(static_cast<QWidget *>(0), Qt::Key_Down ); + QTest::keyClick(static_cast<QWidget *>(0), Qt::Key_Enter ); + QTRY_COMPARE(QApplication::activePopupWidget(), nullptr); + QTRY_COMPARE(QApplication::focusWidget(), e); + +} + /*! If a popupmenu is active you can use home to go quickly to the first item in the menu. */ diff --git a/tests/auto/widgets/widgets/qopenglwidget/tst_qopenglwidget.cpp b/tests/auto/widgets/widgets/qopenglwidget/tst_qopenglwidget.cpp index 7bb0de7e17..db125f6644 100644 --- a/tests/auto/widgets/widgets/qopenglwidget/tst_qopenglwidget.cpp +++ b/tests/auto/widgets/widgets/qopenglwidget/tst_qopenglwidget.cpp @@ -80,7 +80,7 @@ void tst_QOpenGLWidget::create() QVERIFY(w->textureFormat() == 0); QSignalSpy frameSwappedSpy(w.data(), SIGNAL(frameSwapped())); w->show(); - QTest::qWaitForWindowExposed(w.data()); + QVERIFY(QTest::qWaitForWindowExposed(w.data())); QVERIFY(frameSwappedSpy.count() > 0); QVERIFY(w->isValid()); @@ -131,7 +131,7 @@ void tst_QOpenGLWidget::clearAndGrab() QScopedPointer<ClearWidget> w(new ClearWidget(0, 800, 600)); w->resize(800, 600); w->show(); - QTest::qWaitForWindowExposed(w.data()); + QVERIFY(QTest::qWaitForWindowExposed(w.data())); QVERIFY(w->m_initCalled); QVERIFY(w->m_resizeCalled); QVERIFY(w->m_resizeOk); @@ -149,7 +149,7 @@ void tst_QOpenGLWidget::clearAndResizeAndGrab() QScopedPointer<QOpenGLWidget> w(new ClearWidget(0, 640, 480)); w->resize(640, 480); w->show(); - QTest::qWaitForWindowExposed(w.data()); + QVERIFY(QTest::qWaitForWindowExposed(w.data())); QImage image = w->grabFramebuffer(); QVERIFY(!image.isNull()); @@ -172,7 +172,7 @@ void tst_QOpenGLWidget::createNonTopLevel() QSignalSpy frameSwappedSpy(glw, SIGNAL(frameSwapped())); w.resize(400, 400); w.show(); - QTest::qWaitForWindowExposed(&w); + QVERIFY(QTest::qWaitForWindowExposed(&w)); QVERIFY(frameSwappedSpy.count() > 0); QVERIFY(glw->m_resizeCalled); @@ -228,7 +228,7 @@ void tst_QOpenGLWidget::painter() w.resize(640, 480); glw->resize(320, 200); w.show(); - QTest::qWaitForWindowExposed(&w); + QVERIFY(QTest::qWaitForWindowExposed(&w)); QImage image = glw->grabFramebuffer(); QCOMPARE(image.width(), glw->width()); @@ -249,11 +249,11 @@ void tst_QOpenGLWidget::reparentToAlreadyCreated() w1.resize(640, 480); glw->resize(320, 200); w1.show(); - QTest::qWaitForWindowExposed(&w1); + QVERIFY(QTest::qWaitForWindowExposed(&w1)); QWidget w2; w2.show(); - QTest::qWaitForWindowExposed(&w2); + QVERIFY(QTest::qWaitForWindowExposed(&w2)); glw->setParent(&w2); glw->show(); @@ -271,12 +271,12 @@ void tst_QOpenGLWidget::reparentToNotYetCreated() w1.resize(640, 480); glw->resize(320, 200); w1.show(); - QTest::qWaitForWindowExposed(&w1); + QVERIFY(QTest::qWaitForWindowExposed(&w1)); QWidget w2; glw->setParent(&w2); w2.show(); - QTest::qWaitForWindowExposed(&w2); + QVERIFY(QTest::qWaitForWindowExposed(&w2)); QImage image = glw->grabFramebuffer(); QCOMPARE(image.width(), 320); @@ -297,12 +297,12 @@ void tst_QOpenGLWidget::reparentHidden() glw->hide(); // Explicitly hidden - QTest::qWaitForWindowExposed(&topLevel1); + QVERIFY(QTest::qWaitForWindowExposed(&topLevel1)); QWidget topLevel2; topLevel2.resize(640, 480); topLevel2.show(); - QTest::qWaitForWindowExposed(&topLevel2); + QVERIFY(QTest::qWaitForWindowExposed(&topLevel2)); QOpenGLContext *originalContext = glw->context(); QVERIFY(originalContext); @@ -353,7 +353,7 @@ void tst_QOpenGLWidget::asViewport() layout->addWidget(btn); widget.setLayout(layout); widget.show(); - QTest::qWaitForWindowExposed(&widget); + QVERIFY(QTest::qWaitForWindowExposed(&widget)); QVERIFY(view->paintCount() > 0); view->resetPaintCount(); @@ -381,7 +381,7 @@ void tst_QOpenGLWidget::requestUpdate() PaintCountWidget w; w.resize(640, 480); w.show(); - QTest::qWaitForWindowExposed(&w); + QVERIFY(QTest::qWaitForWindowExposed(&w)); w.reset(); QCOMPARE(w.m_count, 0); @@ -405,7 +405,7 @@ void tst_QOpenGLWidget::fboRedirect() FboCheckWidget w; w.resize(640, 480); w.show(); - QTest::qWaitForWindowExposed(&w); + QVERIFY(QTest::qWaitForWindowExposed(&w)); // Unlike in paintGL(), the default fbo reported by the context is not affected by the widget, // so we get the real default fbo: either 0 or (on iOS) the fbo associated with the window. @@ -420,7 +420,7 @@ void tst_QOpenGLWidget::showHide() QScopedPointer<ClearWidget> w(new ClearWidget(0, 800, 600)); w->resize(800, 600); w->show(); - QTest::qWaitForWindowExposed(w.data()); + QVERIFY(QTest::qWaitForWindowExposed(w.data())); w->hide(); @@ -432,7 +432,7 @@ void tst_QOpenGLWidget::showHide() w->setClearColor(0, 0, 1); w->show(); - QTest::qWaitForWindowExposed(w.data()); + QVERIFY(QTest::qWaitForWindowExposed(w.data())); image = w->grabFramebuffer(); QVERIFY(!image.isNull()); @@ -447,7 +447,7 @@ void tst_QOpenGLWidget::nativeWindow() w->resize(800, 600); w->show(); w->winId(); - QTest::qWaitForWindowExposed(w.data()); + QVERIFY(QTest::qWaitForWindowExposed(w.data())); QImage image = w->grabFramebuffer(); QVERIFY(!image.isNull()); @@ -466,7 +466,7 @@ void tst_QOpenGLWidget::nativeWindow() child->resize(400, 400); child->move(23, 34); nativeParent.show(); - QTest::qWaitForWindowExposed(&nativeParent); + QVERIFY(QTest::qWaitForWindowExposed(&nativeParent)); QVERIFY(nativeParent.internalWinId()); QVERIFY(!child->internalWinId()); @@ -586,8 +586,8 @@ void tst_QOpenGLWidget::stackWidgetOpaqueChildIsVisible() stack.setCurrentIndex(0); stack.resize(dimensionSize, dimensionSize); stack.show(); - QTest::qWaitForWindowExposed(&stack); - QTest::qWaitForWindowActive(&stack); + QVERIFY(QTest::qWaitForWindowExposed(&stack)); + QVERIFY(QTest::qWaitForWindowActive(&stack)); // Switch to the QOpenGLWidget. stack.setCurrentIndex(1); @@ -666,7 +666,7 @@ void tst_QOpenGLWidget::offscreenThenOnscreen() // now let's make things more challenging: show. Internally this needs // recreating the context. w->show(); - QTest::qWaitForWindowExposed(w.data()); + QVERIFY(QTest::qWaitForWindowExposed(w.data())); image = w->grabFramebuffer(); QVERIFY(!image.isNull()); diff --git a/tests/auto/widgets/widgets/qpushbutton/tst_qpushbutton.cpp b/tests/auto/widgets/widgets/qpushbutton/tst_qpushbutton.cpp index bacab78601..2b54008de7 100644 --- a/tests/auto/widgets/widgets/qpushbutton/tst_qpushbutton.cpp +++ b/tests/auto/widgets/widgets/qpushbutton/tst_qpushbutton.cpp @@ -594,7 +594,7 @@ void tst_QPushButton::taskQTBUG_20191_shortcutWithKeypadModifer() QDialog dialog; dialog.setLayout(layout); dialog.show(); - QTest::qWaitForWindowExposed(&dialog); + QVERIFY(QTest::qWaitForWindowExposed(&dialog)); QApplication::setActiveWindow(&dialog); // add shortcut '5' to button1 and test with keyboard and keypad '5' keys @@ -639,7 +639,7 @@ void tst_QPushButton::emitReleasedAfterChange() QDialog dialog; dialog.setLayout(layout); dialog.show(); - QTest::qWaitForWindowExposed(&dialog); + QVERIFY(QTest::qWaitForWindowExposed(&dialog)); QApplication::setActiveWindow(&dialog); button1->setFocus(); diff --git a/tests/auto/widgets/widgets/qscrollbar/tst_qscrollbar.cpp b/tests/auto/widgets/widgets/qscrollbar/tst_qscrollbar.cpp index 5238eea592..5ef2c7bc50 100644 --- a/tests/auto/widgets/widgets/qscrollbar/tst_qscrollbar.cpp +++ b/tests/auto/widgets/widgets/qscrollbar/tst_qscrollbar.cpp @@ -78,7 +78,7 @@ void tst_QScrollBar::scrollSingleStep() testWidget.resize(100, testWidget.height()); centerOnScreen(&testWidget); testWidget.show(); - QTest::qWaitForWindowExposed(&testWidget); + QVERIFY(QTest::qWaitForWindowExposed(&testWidget)); testWidget.setValue(testWidget.minimum()); QCOMPARE(testWidget.value(), testWidget.minimum()); @@ -117,7 +117,7 @@ void tst_QScrollBar::task_209492() verticalScrollBar->setRange(0, 1000); centerOnScreen(&scrollArea); scrollArea.show(); - QTest::qWaitForWindowExposed(&scrollArea); + QVERIFY(QTest::qWaitForWindowExposed(&scrollArea)); QSignalSpy spy(verticalScrollBar, SIGNAL(actionTriggered(int))); QCOMPARE(scrollArea.scrollCount, 0); @@ -154,7 +154,7 @@ void tst_QScrollBar::QTBUG_27308() testWidget.resize(100, testWidget.height()); centerOnScreen(&testWidget); testWidget.show(); - QTest::qWaitForWindowExposed(&testWidget); + QVERIFY(QTest::qWaitForWindowExposed(&testWidget)); testWidget.setValue(testWidget.minimum()); testWidget.setEnabled(false); @@ -183,7 +183,7 @@ void tst_QScrollBar::QTBUG_42871() scrollBarWidget.resize(100, scrollBarWidget.height()); centerOnScreen(&scrollBarWidget); scrollBarWidget.show(); - QTest::qWaitForWindowExposed(&scrollBarWidget); + QVERIFY(QTest::qWaitForWindowExposed(&scrollBarWidget)); QSignalSpy spy(&scrollBarWidget, SIGNAL(actionTriggered(int))); QVERIFY(spy.isValid()); QCOMPARE(myHandler.updatesCount, 0); diff --git a/tests/auto/widgets/widgets/qsplitter/tst_qsplitter.cpp b/tests/auto/widgets/widgets/qsplitter/tst_qsplitter.cpp index 9050ad4486..80c12c0bd2 100644 --- a/tests/auto/widgets/widgets/qsplitter/tst_qsplitter.cpp +++ b/tests/auto/widgets/widgets/qsplitter/tst_qsplitter.cpp @@ -828,7 +828,7 @@ void tst_QSplitter::handleMinimumWidth() split.addWidget(new QLabel("Number Too")); split.show(); - QTest::qWaitForWindowExposed(&split); + QVERIFY(QTest::qWaitForWindowExposed(&split)); for (int i = 0; i < 10; i++) { split.setHandleWidth(i); QTest::qWait(100); // resizing diff --git a/tests/auto/widgets/widgets/qstackedwidget/tst_qstackedwidget.cpp b/tests/auto/widgets/widgets/qstackedwidget/tst_qstackedwidget.cpp index 2df5f01627..59a334fab9 100644 --- a/tests/auto/widgets/widgets/qstackedwidget/tst_qstackedwidget.cpp +++ b/tests/auto/widgets/widgets/qstackedwidget/tst_qstackedwidget.cpp @@ -180,7 +180,7 @@ void tst_QStackedWidget::dynamicPages() sw->resize(200, 200); sw->show(); qApp->setActiveWindow(sw); - QTest::qWaitForWindowActive(sw); + QVERIFY(QTest::qWaitForWindowActive(sw)); QTRY_COMPARE(QApplication::focusWidget(), le11); sw->setCurrentIndex(1); diff --git a/tests/auto/widgets/widgets/qtextedit/tst_qtextedit.cpp b/tests/auto/widgets/widgets/qtextedit/tst_qtextedit.cpp index 4e1d93dbbb..53511ed7e2 100644 --- a/tests/auto/widgets/widgets/qtextedit/tst_qtextedit.cpp +++ b/tests/auto/widgets/widgets/qtextedit/tst_qtextedit.cpp @@ -2507,7 +2507,7 @@ void tst_QTextEdit::highlightLongLine() }; NumHighlighter nh(edit.document()); edit.show(); - QTest::qWaitForWindowActive(edit.windowHandle()); + QVERIFY(QTest::qWaitForWindowActive(edit.windowHandle())); QCoreApplication::processEvents(); //If there is a quadratic behaviour, this would take forever. QVERIFY(true); |