summaryrefslogtreecommitdiffstats
path: root/tests
diff options
context:
space:
mode:
authorAllan Sandfeld Jensen <allan.jensen@qt.io>2017-10-24 10:37:17 +0200
committerLiang Qi <liang.qi@qt.io>2017-10-24 13:40:55 +0200
commitfa9d12f4a20d618caedc77880459fa1af75fd50d (patch)
tree11bd3cb4541afb924b3ee17f867133e71eb0e090 /tests
parent895cb4681ee78caaf9b99c88390a74ff1d79ae61 (diff)
parentf174d31667dca184439f520b9624a1471d9556a6 (diff)
Merge remote-tracking branch 'origin/5.10' into dev
Conflicts: src/plugins/platforms/windows/qwindowsmousehandler.cpp src/plugins/platforms/xcb/qxcbimage.cpp tests/auto/network/access/qnetworkreply/tst_qnetworkreply.cpp tests/manual/qtabletevent/regular_widgets/main.cpp Done-with: Friedemann Kleint<Friedemann.Kleint@qt.io> Done-with: MÃ¥rten Nordheim<marten.nordheim@qt.io> Change-Id: I5b2499513a92c590ed0756f7d2e93c35a64b7f30
Diffstat (limited to 'tests')
-rw-r--r--tests/auto/auto.pro5
-rw-r--r--tests/auto/corelib/global/qlogging/BLACKLIST3
-rw-r--r--tests/auto/corelib/global/qrandomgenerator/tst_qrandomgenerator.cpp50
-rw-r--r--tests/auto/corelib/io/qfileinfo/tst_qfileinfo.cpp54
-rw-r--r--tests/auto/corelib/io/qurl/tst_qurl.cpp17
-rw-r--r--tests/auto/corelib/thread/qthreadpool/tst_qthreadpool.cpp64
-rw-r--r--tests/auto/gui/qopengl/BLACKLIST2
-rw-r--r--tests/auto/network/access/qnetworkcookiejar/tst_qnetworkcookiejar.cpp11
-rw-r--r--tests/auto/network/access/qnetworkreply/tst_qnetworkreply.cpp305
-rw-r--r--tests/auto/network/kernel/qhostinfo/BLACKLIST6
-rw-r--r--tests/auto/network/kernel/qhostinfo/qhostinfo.pro3
-rw-r--r--tests/auto/network/kernel/qhostinfo/tst_qhostinfo.cpp15
-rw-r--r--tests/auto/other/gestures/BLACKLIST2
-rw-r--r--tests/auto/widgets/dialogs/qfiledialog2/tst_qfiledialog2.cpp2
-rw-r--r--tests/auto/widgets/kernel/qwidget/BLACKLIST2
-rw-r--r--tests/auto/widgets/widgets/qmenu/tst_qmenu.cpp28
-rw-r--r--tests/auto/widgets/widgets/qmenubar/BLACKLIST4
-rw-r--r--tests/auto/widgets/widgets/qmenubar/tst_qmenubar.cpp1
-rw-r--r--tests/auto/xml/sax/qxmlsimplereader/tst_qxmlsimplereader.cpp2
-rw-r--r--tests/manual/network_remote_stresstest/tst_network_remote_stresstest.cpp2
-rw-r--r--tests/manual/network_stresstest/tst_network_stresstest.cpp2
-rw-r--r--tests/manual/qtabletevent/regular_widgets/main.cpp67
-rw-r--r--tests/manual/widgets/itemviews/qtreewidget/main.cpp13
23 files changed, 512 insertions, 148 deletions
diff --git a/tests/auto/auto.pro b/tests/auto/auto.pro
index 0f8129cb74..3caa6a3b65 100644
--- a/tests/auto/auto.pro
+++ b/tests/auto/auto.pro
@@ -43,3 +43,8 @@ else:!qtConfig(process): SUBDIRS -= tools
SUBDIRS -= dbus
}
}
+
+# QTBUG-63915
+boot2qt: {
+ contains(QT_ARCH, arm64): SUBDIRS -= dbus
+}
diff --git a/tests/auto/corelib/global/qlogging/BLACKLIST b/tests/auto/corelib/global/qlogging/BLACKLIST
new file mode 100644
index 0000000000..1dcee92361
--- /dev/null
+++ b/tests/auto/corelib/global/qlogging/BLACKLIST
@@ -0,0 +1,3 @@
+[qMessagePattern:backtrace depth,separator]
+# QTBUG-63915
+b2qt 64bit
diff --git a/tests/auto/corelib/global/qrandomgenerator/tst_qrandomgenerator.cpp b/tests/auto/corelib/global/qrandomgenerator/tst_qrandomgenerator.cpp
index 2195bf8ec8..d1c0c8e965 100644
--- a/tests/auto/corelib/global/qrandomgenerator/tst_qrandomgenerator.cpp
+++ b/tests/auto/corelib/global/qrandomgenerator/tst_qrandomgenerator.cpp
@@ -97,6 +97,8 @@ private slots:
void generateReal_data() { generate32_data(); }
void generateReal();
+ void qualityReal_data() { generate32_data(); }
+ void qualityReal();
void seedStdRandomEngines();
void stdUniformIntDistribution_data();
@@ -445,7 +447,7 @@ void tst_QRandomGenerator::generateReal()
for (int i = 0; i < 4; ++i) {
QVERIFY_3TIMES([] {
qreal value = QRandomGenerator::generateDouble();
- return value > 0 && value < 1 && value != RandomValueFP;
+ return value >= 0 && value < 1 && value != RandomValueFP;
}());
}
@@ -454,6 +456,52 @@ void tst_QRandomGenerator::generateReal()
QVERIFY_3TIMES(QRandomGenerator::generateDouble() != QRandomGenerator::generateDouble());
}
+void tst_QRandomGenerator::qualityReal()
+{
+ QFETCH(uint, control);
+ setRNGControl(control);
+
+ enum {
+ SampleSize = 160,
+
+ // Expected value: sample size times proportion of the range:
+ PerfectOctile = SampleSize / 8,
+ PerfectHalf = SampleSize / 2,
+
+ // Variance is (1 - proportion of range) * expected; sqrt() for standard deviations.
+ // Should usually be within twice that and almost never outside four times:
+ RangeHalf = 25, // floor(4 * sqrt((1 - 0.5) * PerfectHalf))
+ RangeOctile = 16 // floor(4 * sqrt((1 - 0.125) * PerfectOctile))
+ };
+
+ double data[SampleSize];
+ std::generate(std::begin(data), std::end(data), &QRandomGenerator::generateDouble);
+
+ int aboveHalf = 0;
+ int belowOneEighth = 0;
+ int aboveSevenEighths = 0;
+ for (double x : data) {
+ aboveHalf += x >= 0.5;
+ belowOneEighth += x < 0.125;
+ aboveSevenEighths += x >= 0.875;
+
+ // these are strict requirements
+ QVERIFY(x >= 0);
+ QVERIFY(x < 1);
+ }
+
+ qInfo("Halfway distribution: %.1f - %.1f", 100. * aboveHalf / SampleSize, 100 - 100. * aboveHalf / SampleSize);
+ qInfo("%.1f below 1/8 (expected 12.5%% ideally)", 100. * belowOneEighth / SampleSize);
+ qInfo("%.1f above 7/8 (expected 12.5%% ideally)", 100. * aboveSevenEighths / SampleSize);
+
+ QVERIFY(aboveHalf < PerfectHalf + RangeHalf);
+ QVERIFY(aboveHalf > PerfectHalf - RangeHalf);
+ QVERIFY(aboveSevenEighths < PerfectOctile + RangeOctile);
+ QVERIFY(aboveSevenEighths > PerfectOctile - RangeOctile);
+ QVERIFY(belowOneEighth < PerfectOctile + RangeOctile);
+ QVERIFY(belowOneEighth > PerfectOctile - RangeOctile);
+}
+
template <typename Engine> void seedStdRandomEngine()
{
QRandomGenerator rd;
diff --git a/tests/auto/corelib/io/qfileinfo/tst_qfileinfo.cpp b/tests/auto/corelib/io/qfileinfo/tst_qfileinfo.cpp
index 8945daff4a..44e79985d4 100644
--- a/tests/auto/corelib/io/qfileinfo/tst_qfileinfo.cpp
+++ b/tests/auto/corelib/io/qfileinfo/tst_qfileinfo.cpp
@@ -48,7 +48,6 @@
#endif
#ifdef Q_OS_WIN
#include <qt_windows.h>
-#include <qlibrary.h>
#if !defined(Q_OS_WINRT)
#include <lm.h>
#endif
@@ -684,18 +683,12 @@ void tst_QFileInfo::canonicalFilePath()
#endif
#if defined(Q_OS_WIN) && !defined(Q_OS_WINRT)
- typedef BOOL (WINAPI *PtrCreateSymbolicLink)(LPTSTR, LPTSTR, DWORD);
- PtrCreateSymbolicLink ptrCreateSymbolicLink =
- (PtrCreateSymbolicLink)QLibrary::resolve(QLatin1String("kernel32"), "CreateSymbolicLinkW");
-
- if (!ptrCreateSymbolicLink) {
- QSKIP("Symbolic links aren't supported by FS");
- } else {
+ {
// CreateSymbolicLink can return TRUE & still fail to create the link,
// the error code in that case is ERROR_PRIVILEGE_NOT_HELD (1314)
SetLastError(0);
const QString linkTarget = QStringLiteral("res");
- BOOL ret = ptrCreateSymbolicLink((wchar_t*)linkTarget.utf16(), (wchar_t*)m_resourcesDir.utf16(), 1);
+ BOOL ret = CreateSymbolicLink((wchar_t*)linkTarget.utf16(), (wchar_t*)m_resourcesDir.utf16(), 1);
DWORD dwErr = GetLastError();
if (!ret)
QSKIP("Symbolic links aren't supported by FS");
@@ -1443,16 +1436,6 @@ void tst_QFileInfo::ntfsJunctionPointsAndSymlinks_data()
QDir pwd;
pwd.mkdir("target");
- QLibrary kernel32("kernel32");
- typedef BOOLEAN (WINAPI *PtrCreateSymbolicLink)(LPCWSTR, LPCWSTR, DWORD);
- PtrCreateSymbolicLink createSymbolicLinkW = 0;
- createSymbolicLinkW = (PtrCreateSymbolicLink) kernel32.resolve("CreateSymbolicLinkW");
- if (!createSymbolicLinkW) {
- //we need at least one data set for the test not to fail when skipping _data function
- QDir target("target");
- QTest::newRow("dummy") << target.path() << false << "" << target.canonicalPath();
- QSKIP("symbolic links not supported by operating system");
- }
{
//Directory symlinks
QDir target("target");
@@ -1472,10 +1455,10 @@ void tst_QFileInfo::ntfsJunctionPointsAndSymlinks_data()
DWORD err = ERROR_SUCCESS ;
if (!pwd.exists("abs_symlink"))
- if (!createSymbolicLinkW((wchar_t*)absSymlink.utf16(),(wchar_t*)absTarget.utf16(),0x1))
+ if (!CreateSymbolicLink((wchar_t*)absSymlink.utf16(),(wchar_t*)absTarget.utf16(),0x1))
err = GetLastError();
if (err == ERROR_SUCCESS && !pwd.exists(relSymlink))
- if (!createSymbolicLinkW((wchar_t*)relSymlink.utf16(),(wchar_t*)relTarget.utf16(),0x1))
+ if (!CreateSymbolicLink((wchar_t*)relSymlink.utf16(),(wchar_t*)relTarget.utf16(),0x1))
err = GetLastError();
if (err != ERROR_SUCCESS) {
wchar_t errstr[0x100];
@@ -1505,10 +1488,9 @@ void tst_QFileInfo::ntfsJunctionPointsAndSymlinks_data()
QString relSymlink = "rel_symlink.cpp";
QString relToRelTarget = QDir::toNativeSeparators(relativeDir.relativeFilePath(target.absoluteFilePath()));
QString relToRelSymlink = "relative/rel_symlink";
- QVERIFY(pwd.exists("abs_symlink.cpp") || createSymbolicLinkW((wchar_t*)absSymlink.utf16(),(wchar_t*)absTarget.utf16(),0x0));
- QVERIFY(pwd.exists(relSymlink) || createSymbolicLinkW((wchar_t*)relSymlink.utf16(),(wchar_t*)relTarget.utf16(),0x0));
- QVERIFY(pwd.exists(relToRelSymlink)
- || createSymbolicLinkW((wchar_t*)relToRelSymlink.utf16(), (wchar_t*)relToRelTarget.utf16(),0x0));
+ QVERIFY(pwd.exists("abs_symlink.cpp") || CreateSymbolicLink((wchar_t*)absSymlink.utf16(),(wchar_t*)absTarget.utf16(),0x0));
+ QVERIFY(pwd.exists(relSymlink) || CreateSymbolicLink((wchar_t*)relSymlink.utf16(),(wchar_t*)relTarget.utf16(),0x0));
+ QVERIFY(pwd.exists(relToRelSymlink) || CreateSymbolicLink((wchar_t*)relToRelSymlink.utf16(), (wchar_t*)relToRelTarget.utf16(),0x0));
QTest::newRow("absolute file symlink") << absSymlink << true << QDir::fromNativeSeparators(absTarget) << target.canonicalFilePath();
QTest::newRow("relative file symlink") << relSymlink << true << QDir::fromNativeSeparators(absTarget) << target.canonicalFilePath();
QTest::newRow("relative to relative file symlink") << relToRelSymlink << true << QDir::fromNativeSeparators(absTarget) << target.canonicalFilePath();
@@ -1535,20 +1517,14 @@ void tst_QFileInfo::ntfsJunctionPointsAndSymlinks_data()
QTest::newRow("junction_root") << junction << false << QString() << QString();
//Mountpoint
- typedef BOOLEAN (WINAPI *PtrGetVolumeNameForVolumeMountPointW)(LPCWSTR, LPWSTR, DWORD);
- PtrGetVolumeNameForVolumeMountPointW getVolumeNameForVolumeMountPointW = 0;
- getVolumeNameForVolumeMountPointW = (PtrGetVolumeNameForVolumeMountPointW) kernel32.resolve("GetVolumeNameForVolumeMountPointW");
- if(getVolumeNameForVolumeMountPointW)
- {
- wchar_t buffer[MAX_PATH];
- QString rootPath = QDir::toNativeSeparators(QDir::rootPath());
- QVERIFY(getVolumeNameForVolumeMountPointW((wchar_t*)rootPath.utf16(), buffer, MAX_PATH));
- QString rootVolume = QString::fromWCharArray(buffer);
- junction = "mountpoint";
- rootVolume.replace("\\\\?\\","\\??\\");
- FileSystem::createNtfsJunction(rootVolume, junction);
- QTest::newRow("mountpoint") << junction << false << QString() << QString();
- }
+ wchar_t buffer[MAX_PATH];
+ QString rootPath = QDir::toNativeSeparators(QDir::rootPath());
+ QVERIFY(GetVolumeNameForVolumeMountPoint((wchar_t*)rootPath.utf16(), buffer, MAX_PATH));
+ QString rootVolume = QString::fromWCharArray(buffer);
+ junction = "mountpoint";
+ rootVolume.replace("\\\\?\\","\\??\\");
+ FileSystem::createNtfsJunction(rootVolume, junction);
+ QTest::newRow("mountpoint") << junction << false << QString() << QString();
}
void tst_QFileInfo::ntfsJunctionPointsAndSymlinks()
diff --git a/tests/auto/corelib/io/qurl/tst_qurl.cpp b/tests/auto/corelib/io/qurl/tst_qurl.cpp
index 7eeaea564f..400a89c03f 100644
--- a/tests/auto/corelib/io/qurl/tst_qurl.cpp
+++ b/tests/auto/corelib/io/qurl/tst_qurl.cpp
@@ -2058,6 +2058,14 @@ void tst_QUrl::isValid()
}
{
+ QUrl url("http:");
+ url.setPath("//example.com");
+ QVERIFY(!url.isValid());
+ QVERIFY(url.toString().isEmpty());
+ QVERIFY(url.errorString().contains("Path component starts with '//' and authority is absent"));
+ }
+
+ {
QUrl url;
url.setPath("http://example.com");
QVERIFY(!url.isValid());
@@ -3632,12 +3640,12 @@ void tst_QUrl::setComponents_data()
QTest::newRow("path-%3A-before-slash") << QUrl()
<< int(Path) << "c%3A/" << Tolerant << true
<< PrettyDecoded << "c%3A/" << "c%3A/";
- QTest::newRow("path-doubleslash") << QUrl("trash:/")
+ QTest::newRow("path-doubleslash") << QUrl("http://example.com")
<< int(Path) << "//path" << Tolerant << true
- << PrettyDecoded << "/path" << "trash:/path";
+ << PrettyDecoded << "//path" << "http://example.com//path";
QTest::newRow("path-withdotdot") << QUrl("file:///tmp")
<< int(Path) << "//tmp/..///root/." << Tolerant << true
- << PrettyDecoded << "/tmp/..///root/." << "file:///tmp/..///root/.";
+ << PrettyDecoded << "//tmp/..///root/." << "file:////tmp/..///root/.";
// the other fields can be present and be empty
// that is, their delimiters would be present, but there would be nothing to one side
@@ -3760,6 +3768,9 @@ void tst_QUrl::setComponents_data()
QTest::newRow("invalid-path-2") << QUrl("http://example.com")
<< int(Path) << "relative" << Strict << false
<< PrettyDecoded << "relative" << "";
+ QTest::newRow("invalid-path-3") << QUrl("trash:/")
+ << int(Path) << "//path" << Tolerant << false
+ << PrettyDecoded << "//path" << "";
// -- test bad percent encoding --
// unnecessary to test the scheme, since percent-decoding is not performed in it;
diff --git a/tests/auto/corelib/thread/qthreadpool/tst_qthreadpool.cpp b/tests/auto/corelib/thread/qthreadpool/tst_qthreadpool.cpp
index 782eed03e8..094c6ed0a5 100644
--- a/tests/auto/corelib/thread/qthreadpool/tst_qthreadpool.cpp
+++ b/tests/auto/corelib/thread/qthreadpool/tst_qthreadpool.cpp
@@ -94,6 +94,7 @@ private slots:
void destroyingWaitsForTasksToFinish();
void stackSize();
void stressTest();
+ void takeAllAndIncreaseMaxThreadCount();
private:
QMutex m_functionTestMutex;
@@ -1203,5 +1204,68 @@ void tst_QThreadPool::stressTest()
}
}
+void tst_QThreadPool::takeAllAndIncreaseMaxThreadCount() {
+ class Task : public QRunnable
+ {
+ public:
+ Task(QSemaphore *mainBarrier, QSemaphore *threadBarrier)
+ : m_mainBarrier(mainBarrier)
+ , m_threadBarrier(threadBarrier)
+ {
+ setAutoDelete(false);
+ }
+
+ void run() {
+ m_mainBarrier->release();
+ m_threadBarrier->acquire();
+ }
+ private:
+ QSemaphore *m_mainBarrier;
+ QSemaphore *m_threadBarrier;
+ };
+
+ QSemaphore mainBarrier;
+ QSemaphore taskBarrier;
+
+ QThreadPool threadPool;
+ threadPool.setMaxThreadCount(1);
+
+ Task *task1 = new Task(&mainBarrier, &taskBarrier);
+ Task *task2 = new Task(&mainBarrier, &taskBarrier);
+ Task *task3 = new Task(&mainBarrier, &taskBarrier);
+
+ threadPool.start(task1);
+ threadPool.start(task2);
+ threadPool.start(task3);
+
+ mainBarrier.acquire(1);
+
+ QCOMPARE(threadPool.activeThreadCount(), 1);
+
+ QVERIFY(!threadPool.tryTake(task1));
+ QVERIFY(threadPool.tryTake(task2));
+ QVERIFY(threadPool.tryTake(task3));
+
+ // A bad queue implementation can segfault here because two consecutive items in the queue
+ // have been taken
+ threadPool.setMaxThreadCount(4);
+
+ // Even though we increase the max thread count, there should only be one job to run
+ QCOMPARE(threadPool.activeThreadCount(), 1);
+
+ // Make sure jobs 2 and 3 never started
+ QCOMPARE(mainBarrier.available(), 0);
+
+ taskBarrier.release(1);
+
+ threadPool.waitForDone();
+
+ QCOMPARE(threadPool.activeThreadCount(), 0);
+
+ delete task1;
+ delete task2;
+ delete task3;
+}
+
QTEST_MAIN(tst_QThreadPool);
#include "tst_qthreadpool.moc"
diff --git a/tests/auto/gui/qopengl/BLACKLIST b/tests/auto/gui/qopengl/BLACKLIST
index a16327d411..a036106c57 100644
--- a/tests/auto/gui/qopengl/BLACKLIST
+++ b/tests/auto/gui/qopengl/BLACKLIST
@@ -7,4 +7,4 @@ windows
[openGLPaintDevice]
windows
[wglContextWrap]
-windows-7
+windows
diff --git a/tests/auto/network/access/qnetworkcookiejar/tst_qnetworkcookiejar.cpp b/tests/auto/network/access/qnetworkcookiejar/tst_qnetworkcookiejar.cpp
index a0459021be..ed5d0c69a0 100644
--- a/tests/auto/network/access/qnetworkcookiejar/tst_qnetworkcookiejar.cpp
+++ b/tests/auto/network/access/qnetworkcookiejar/tst_qnetworkcookiejar.cpp
@@ -340,6 +340,17 @@ void tst_QNetworkCookieJar::cookiesForUrl_data()
QTest::newRow("no-match-domain-dot") << allCookies << "http://example.com" << result;
result += cookieDot;
QTest::newRow("match-domain-dot") << allCookies << "http://example.com." << result;
+
+ // Root path in cookie, empty url path
+ allCookies.clear();
+ QNetworkCookie rootCookie;
+ rootCookie.setName("a");
+ rootCookie.setPath("/");
+ rootCookie.setDomain("qt-project.org");
+ allCookies += rootCookie;
+ result.clear();
+ result += rootCookie;
+ QTest::newRow("root-path-match") << allCookies << "http://qt-project.org" << result;
}
void tst_QNetworkCookieJar::cookiesForUrl()
diff --git a/tests/auto/network/access/qnetworkreply/tst_qnetworkreply.cpp b/tests/auto/network/access/qnetworkreply/tst_qnetworkreply.cpp
index 49abbede35..f6e3962454 100644
--- a/tests/auto/network/access/qnetworkreply/tst_qnetworkreply.cpp
+++ b/tests/auto/network/access/qnetworkreply/tst_qnetworkreply.cpp
@@ -30,7 +30,6 @@
#include <QtTest/QtTest>
#include <QtCore/QCryptographicHash>
#include <QtCore/QDataStream>
-#include <QtCore/QTextStream>
#include <QtCore/QUrl>
#include <QtCore/QEventLoop>
#include <QtCore/QFile>
@@ -489,6 +488,13 @@ private Q_SLOTS:
void ioHttpUserVerifiedRedirect_data();
void ioHttpUserVerifiedRedirect();
void ioHttpCookiesDuringRedirect();
+ void ioHttpRedirect_data();
+ void ioHttpRedirect();
+ void ioHttpRedirectFromLocalToRemote();
+ void ioHttpRedirectPost_data();
+ void ioHttpRedirectPost();
+ void ioHttpRedirectMultipartPost_data();
+ void ioHttpRedirectMultipartPost();
#ifndef QT_NO_SSL
void putWithServerClosingConnectionImmediately();
#endif
@@ -515,6 +521,17 @@ bool tst_QNetworkReply::seedCreated = false;
QFAIL(qPrintable(errorMsg)); \
} while (0)
+static bool validateRedirectedResponseHeaders(QNetworkReplyPtr reply)
+{
+ // QTBUG-61300: previously we were mixing 'raw' headers from all responses
+ // along the redirect chain. The simplest test is to check/verify we have
+ // no 'location' header anymore.
+ Q_ASSERT(reply.data());
+
+ return !reply->hasRawHeader("location")
+ && !reply->header(QNetworkRequest::LocationHeader).isValid();
+}
+
#ifndef QT_NO_SSL
static void setupSslServer(QSslSocket* serverSocket)
{
@@ -545,7 +562,10 @@ public:
bool ipv6;
bool multiple;
int totalConnections;
- bool parseHeaders = false;
+
+ bool hasContent = false;
+ int contentRead = 0;
+ int contentLength = 0;
MiniHttpServer(const QByteArray &data, bool ssl = false, QThread *thread = 0, bool useipv6 = false)
: dataToTransmit(data), doClose(true), doSsl(ssl), ipv6(useipv6),
@@ -573,7 +593,7 @@ public:
void clearHeaderParserState()
{
- expectPayload = false;
+ contentLength = 0;
receivedData.clear();
}
@@ -629,6 +649,18 @@ private:
this, SLOT(slotError(QAbstractSocket::SocketError)));
}
+ void parseContentLength()
+ {
+ int index = receivedData.indexOf("Content-Length:");
+ index += sizeof("Content-Length:") - 1;
+ const auto end = std::find(receivedData.cbegin() + index, receivedData.cend(), '\r');
+ auto num = receivedData.mid(index, std::distance(receivedData.cbegin() + index, end));
+ bool ok;
+ contentLength = num.toInt(&ok);
+ if (!ok)
+ contentLength = -1;
+ }
+
private slots:
#ifndef QT_NO_SSL
void slotSslErrors(const QList<QSslError>& errors)
@@ -650,28 +682,22 @@ public slots:
void readyReadSlot()
{
Q_ASSERT(!client.isNull());
- if (expectPayload) {
- // NOTE: this works only for the test using POST/PUT requests to this
- // local HTTP server, fortunately we know that data is very small
- // (7 bytes) and we can safely read/discard it here:
- client->readAll();
- return reply();
- }
receivedData += client->readAll();
- int doubleEndlPos = receivedData.indexOf("\r\n\r\n");
+ const int doubleEndlPos = receivedData.indexOf("\r\n\r\n");
if (doubleEndlPos != -1) {
- if (parseHeaders) {
- parseRequest();
- if (expectPayload && doubleEndlPos + 4 == receivedData.size()) {
- // Wait for more incoming (POST/PUT) data.
- return;
- }
- }
+ const int endOfHeader = doubleEndlPos + 4;
+ hasContent = receivedData.startsWith("POST") || receivedData.startsWith("PUT");
+ if (hasContent && contentLength == 0)
+ parseContentLength();
+ contentRead = receivedData.length() - endOfHeader;
+ if (hasContent && contentRead < contentLength)
+ return;
+
// multiple requests incoming. remove the bytes of the current one
if (multiple)
- receivedData.remove(0, doubleEndlPos+4);
+ receivedData.remove(0, endOfHeader);
reply();
}
@@ -691,18 +717,6 @@ public slots:
{
ready.release();
}
-
-private:
- void parseRequest()
- {
- Q_ASSERT(parseHeaders);
- QTextStream parser(receivedData, QIODevice::ReadOnly);
- const QString line(parser.readLine());
- expectPayload = line.startsWith(QLatin1Literal("POST"))
- || line.startsWith(QLatin1Literal("PUT"));
- }
-
- bool expectPayload = false;
};
class MyCookieJar: public QNetworkCookieJar
@@ -7267,7 +7281,6 @@ void tst_QNetworkReply::qtbug28035browserDoesNotLoadQtProjectOrgCorrectly() {
manager.setCache(diskCache);
MiniHttpServer server(getReply);
- server.parseHeaders = true;
QNetworkRequest request(QUrl("http://localhost:" + QString::number(server.serverPort())));
QNetworkReplyPtr reply(manager.get(request));
@@ -8150,6 +8163,7 @@ void tst_QNetworkReply::ioHttpSingleRedirect()
// Reply url is set to the redirect url
QCOMPARE(reply->url(), redirectUrl);
QCOMPARE(reply->error(), QNetworkReply::NoError);
+ QVERIFY(validateRedirectedResponseHeaders(reply));
}
void tst_QNetworkReply::ioHttpChangeMaxRedirects()
@@ -8198,6 +8212,7 @@ void tst_QNetworkReply::ioHttpChangeMaxRedirects()
QCOMPARE(redSpy2.count(), 2);
QCOMPARE(reply2->url(), server3Url);
QCOMPARE(reply2->error(), QNetworkReply::NoError);
+ QVERIFY(validateRedirectedResponseHeaders(reply2));
}
void tst_QNetworkReply::ioHttpRedirectErrors_data()
@@ -8211,7 +8226,9 @@ void tst_QNetworkReply::ioHttpRedirectErrors_data()
"location: http://localhost:%1\r\n\r\n");
QTest::newRow("too-many-redirects") << "http://localhost" << tempRedirectReply << QNetworkReply::TooManyRedirectsError;
+#if QT_CONFIG(ssl)
QTest::newRow("insecure-redirect") << "https://localhost" << tempRedirectReply << QNetworkReply::InsecureRedirectError;
+#endif
QTest::newRow("unknown-redirect") << "http://localhost"<< tempRedirectReply.replace("http", "bad_protocol") << QNetworkReply::ProtocolUnknownError;
}
@@ -8222,7 +8239,7 @@ void tst_QNetworkReply::ioHttpRedirectErrors()
QFETCH(QNetworkReply::NetworkError, error);
QUrl localhost(url);
- MiniHttpServer server("", localhost.scheme() == "https");
+ MiniHttpServer server("", localhost.scheme() == QLatin1String("https"));
localhost.setPort(server.serverPort());
@@ -8272,11 +8289,13 @@ void tst_QNetworkReply::ioHttpRedirectPolicy_data()
QTest::addColumn<int>("statusCode");
QTest::newRow("manual-nossl") << QNetworkRequest::ManualRedirectPolicy << false << 0 << 307;
- QTest::newRow("manual-ssl") << QNetworkRequest::ManualRedirectPolicy << true << 0 << 307;
QTest::newRow("nolesssafe-nossl") << QNetworkRequest::NoLessSafeRedirectPolicy << false << 1 << 200;
- QTest::newRow("nolesssafe-ssl") << QNetworkRequest::NoLessSafeRedirectPolicy << true << 1 << 200;
QTest::newRow("same-origin-nossl") << QNetworkRequest::SameOriginRedirectPolicy << false << 1 << 200;
+#if QT_CONFIG(ssl)
+ 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
}
void tst_QNetworkReply::ioHttpRedirectPolicy()
@@ -8284,10 +8303,6 @@ void tst_QNetworkReply::ioHttpRedirectPolicy()
QFETCH(const QNetworkRequest::RedirectPolicy, policy);
QFETCH(const bool, ssl);
-#ifdef QT_NO_SSL
- if (ssl)
- QSKIP("SSL is not supported");
-#endif
QFETCH(const int, redirectCount);
QFETCH(const int, statusCode);
@@ -8295,11 +8310,7 @@ void tst_QNetworkReply::ioHttpRedirectPolicy()
// Setup HTTP server.
SameOriginRedirector redirectServer("", ssl);
- QUrl url(QLatin1String(
-#ifndef QT_NO_SSL
- ssl ? "https://localhost" :
-#endif
- "http://localhost"));
+ QUrl url(QLatin1String(ssl ? "https://localhost" : "http://localhost"));
url.setPort(redirectServer.serverPort());
redirectServer.responses.push_back(httpEmpty200Response);
@@ -8322,6 +8333,7 @@ void tst_QNetworkReply::ioHttpRedirectPolicy()
QCOMPARE(finishedSpy.count(), 1);
QCOMPARE(redirectSpy.count(), redirectCount);
QCOMPARE(reply->attribute(QNetworkRequest::HttpStatusCodeAttribute).toInt(), statusCode);
+ QVERIFY(validateRedirectedResponseHeaders(reply) || statusCode != 200);
}
void tst_QNetworkReply::ioHttpRedirectPolicyErrors_data()
@@ -8335,27 +8347,35 @@ void tst_QNetworkReply::ioHttpRedirectPolicyErrors_data()
// 1. NoLessSafeRedirectsPolicy
QTest::newRow("nolesssafe-nossl-nossl-too-many") << QNetworkRequest::NoLessSafeRedirectPolicy
<< false << QString("http://localhost:%1") << 0 << QNetworkReply::TooManyRedirectsError;
+#if QT_CONFIG(ssl)
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
// 2. SameOriginRedirectsPolicy
QTest::newRow("same-origin-nossl-nossl-too-many") << QNetworkRequest::SameOriginRedirectPolicy
<< false << QString("http://localhost:%1") << 0 << QNetworkReply::TooManyRedirectsError;
+#if QT_CONFIG(ssl)
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
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)
QTest::newRow("same-origin-https-https-wrong-host") << QNetworkRequest::SameOriginRedirectPolicy
<< true << QString("https://not-so-localhost:%1") << 50 << QNetworkReply::InsecureRedirectError;
+#endif
QTest::newRow("same-origin-http-http-wrong-port") << QNetworkRequest::SameOriginRedirectPolicy
<< false << QString("http://localhost/%1") << 50 << QNetworkReply::InsecureRedirectError;
+#if QT_CONFIG(ssl)
QTest::newRow("same-origin-https-https-wrong-port") << QNetworkRequest::SameOriginRedirectPolicy
<< true << QString("https://localhost/%1") << 50 << QNetworkReply::InsecureRedirectError;
+#endif
}
void tst_QNetworkReply::ioHttpRedirectPolicyErrors()
@@ -8369,20 +8389,11 @@ void tst_QNetworkReply::ioHttpRedirectPolicyErrors()
QFETCH(const int, maxRedirects);
QFETCH(const QNetworkReply::NetworkError, expectedError);
-#ifdef QT_NO_SSL
- if (ssl || location.contains("https"))
- QSKIP("SSL required to run this test");
-#endif
-
// Setup the server.
MiniHttpServer server("", ssl);
server.setDataToTransmit(tempRedirectReplyStr().arg(location.arg(server.serverPort())).toLatin1());
- QUrl url(QLatin1String(
-#ifndef QT_NO_SSL
- ssl ? "https://localhost" :
-#endif
- "http://localhost"));
+ QUrl url(QLatin1String(ssl ? "https://localhost" : "http://localhost"));
url.setPort(server.serverPort());
QNetworkRequest request(url);
@@ -8455,6 +8466,7 @@ void tst_QNetworkReply::ioHttpUserVerifiedRedirect()
waitForFinish(reply);
QCOMPARE(finishedSpy.count(), 1);
QCOMPARE(reply->attribute(QNetworkRequest::HttpStatusCodeAttribute).toInt(), statusCode);
+ QVERIFY(validateRedirectedResponseHeaders(reply) || statusCode != 200);
}
void tst_QNetworkReply::ioHttpCookiesDuringRedirect()
@@ -8482,6 +8494,191 @@ void tst_QNetworkReply::ioHttpCookiesDuringRedirect()
QVERIFY(waitForFinish(reply) == Success);
QVERIFY(target.receivedData.contains("\r\nCookie: hello=world\r\n"));
+ QVERIFY(validateRedirectedResponseHeaders(reply));
+}
+
+void tst_QNetworkReply::ioHttpRedirect_data()
+{
+ QTest::addColumn<QString>("status");
+
+ QTest::addRow("301") << "301 Moved Permanently";
+ QTest::addRow("302") << "302 Found";
+ QTest::addRow("303") << "303 See Other";
+ QTest::addRow("305") << "305 Use Proxy";
+ QTest::addRow("307") << "307 Temporary Redirect";
+ QTest::addRow("308") << "308 Permanent Redirect";
+}
+
+void tst_QNetworkReply::ioHttpRedirect()
+{
+ QFETCH(QString, status);
+
+ MiniHttpServer target(httpEmpty200Response, false);
+ QUrl targetUrl("http://localhost/");
+ targetUrl.setPort(target.serverPort());
+
+ QString redirectReply = QStringLiteral("HTTP/1.1 %1\r\n"
+ "Content-Type: text/plain\r\n"
+ "location: %2\r\n"
+ "\r\n").arg(status, targetUrl.toString());
+ MiniHttpServer redirectServer(redirectReply.toLatin1(), false);
+ QUrl url("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 what it was
+ manager.setRedirectPolicy(oldRedirectPolicy);
+
+ QCOMPARE(waitForFinish(reply), int(Success));
+ QCOMPARE(reply->attribute(QNetworkRequest::HttpStatusCodeAttribute).toInt(), 200);
+ QVERIFY(validateRedirectedResponseHeaders(reply));
+}
+
+void tst_QNetworkReply::ioHttpRedirectFromLocalToRemote()
+{
+ QUrl targetUrl("http://" + QtNetworkSettings::serverName() + "/qtest/rfc3252.txt");
+
+ QString redirectReply = tempRedirectReplyStr().arg(targetUrl.toString());
+ MiniHttpServer redirectServer(redirectReply.toLatin1(), false);
+ QUrl url("http://localhost/");
+ url.setPort(redirectServer.serverPort());
+
+ QFile reference(testDataDir + "/rfc3252.txt");
+ QVERIFY(reference.open(QIODevice::ReadOnly));
+ QNetworkRequest request(url);
+
+ auto oldRedirectPolicy = manager.redirectPolicy();
+ manager.setRedirectPolicy(QNetworkRequest::RedirectPolicy::NoLessSafeRedirectPolicy);
+ QNetworkReplyPtr reply(manager.get(request));
+ // Restore previous policy
+ manager.setRedirectPolicy(oldRedirectPolicy);
+
+ QCOMPARE(waitForFinish(reply), int(Success));
+
+ QCOMPARE(reply->url(), targetUrl);
+ QCOMPARE(reply->error(), QNetworkReply::NoError);
+ QCOMPARE(reply->header(QNetworkRequest::ContentLengthHeader).toLongLong(), reference.size());
+ QCOMPARE(reply->readAll(), reference.readAll());
+}
+
+void tst_QNetworkReply::ioHttpRedirectPost_data()
+{
+ QTest::addColumn<QString>("status");
+ QTest::addColumn<QByteArray>("data");
+ QTest::addColumn<QString>("contentType");
+
+ QByteArray data;
+ data = "hello world";
+ QTest::addRow("307") << "307 Temporary Redirect" << data << "text/plain";
+ QString permanentRedirect = "308 Permanent Redirect";
+ QTest::addRow("308") << permanentRedirect << data << "text/plain";
+
+ // Some data from ::putToFile_data
+ data = "";
+ QTest::newRow("empty") << permanentRedirect << data << "application/octet-stream";
+
+ data = QByteArray("abcd\0\1\2\abcd",12);
+ QTest::newRow("with-nul") << permanentRedirect << data << "application/octet-stream";
+
+ data = QByteArray(4097, '\4');
+ QTest::newRow("4k+1") << permanentRedirect << data << "application/octet-stream";
+
+ data = QByteArray(128*1024+1, '\177');
+ QTest::newRow("128k+1") << permanentRedirect << data << "application/octet-stream";
+
+ data = QByteArray(2*1024*1024+1, '\177');
+ QTest::newRow("2MB+1") << permanentRedirect << data << "application/octet-stream";
+}
+
+void tst_QNetworkReply::ioHttpRedirectPost()
+{
+ QFETCH(QString, status);
+ QFETCH(QByteArray, data);
+ QFETCH(QString, contentType);
+
+ QUrl targetUrl("http://" + QtNetworkSettings::serverName() + "/qtest/cgi-bin/md5sum.cgi");
+
+ QString redirectReply = QStringLiteral("HTTP/1.1 %1\r\n"
+ "Content-Type: text/plain\r\n"
+ "location: %2\r\n"
+ "\r\n").arg(status, targetUrl.toString());
+ MiniHttpServer redirectServer(redirectReply.toLatin1());
+ QUrl url("http://localhost/");
+ url.setPort(redirectServer.serverPort());
+ QNetworkRequest request(url);
+ request.setHeader(QNetworkRequest::KnownHeaders::ContentTypeHeader, contentType);
+ auto oldRedirectPolicy = manager.redirectPolicy();
+ manager.setRedirectPolicy(QNetworkRequest::RedirectPolicy::NoLessSafeRedirectPolicy);
+
+ QNetworkReplyPtr reply(manager.post(request, data));
+ // Restore previous policy:
+ manager.setRedirectPolicy(oldRedirectPolicy);
+
+ QCOMPARE(waitForFinish(reply), int(Success));
+ QCOMPARE(reply->readAll().trimmed(), md5sum(data).toHex());
+}
+
+void tst_QNetworkReply::ioHttpRedirectMultipartPost_data()
+{
+ postToHttpMultipart_data();
+}
+
+void tst_QNetworkReply::ioHttpRedirectMultipartPost()
+{
+ // Note: This code is heavily based on postToHttpMultipart
+ QFETCH(QUrl, url);
+
+ static QSet<QByteArray> boundaries;
+
+ QNetworkReplyPtr reply;
+
+ QFETCH(QHttpMultiPart *, multiPart);
+ QFETCH(QByteArray, expectedReplyData);
+ QFETCH(QByteArray, contentType);
+
+ QString redirectReply = tempRedirectReplyStr().arg(url.toString());
+ MiniHttpServer redirectServer(redirectReply.toLatin1());
+ QUrl redirectUrl("http://localhost/");
+ redirectUrl.setPort(redirectServer.serverPort());
+ QNetworkRequest request(redirectUrl);
+
+ // Restore policy when we leave this scope:
+ struct PolicyRestorer
+ {
+ QNetworkAccessManager &qnam;
+ QNetworkRequest::RedirectPolicy policy;
+ PolicyRestorer(QNetworkAccessManager &qnam)
+ : qnam(qnam), policy(qnam.redirectPolicy())
+ { qnam.setRedirectPolicy(QNetworkRequest::RedirectPolicy::NoLessSafeRedirectPolicy); }
+ ~PolicyRestorer() { qnam.setRedirectPolicy(policy); }
+ } policyRestorer(manager);
+
+ // hack for testing the setting of the content-type header by hand:
+ if (contentType == "custom") {
+ QByteArray contentType("multipart/custom; boundary=\"" + multiPart->boundary() + "\"");
+ request.setHeader(QNetworkRequest::ContentTypeHeader, contentType);
+ }
+
+ QVERIFY2(! boundaries.contains(multiPart->boundary()), "boundary '" + multiPart->boundary() + "' has been created twice");
+ boundaries.insert(multiPart->boundary());
+
+ RUN_REQUEST(runMultipartRequest(request, reply, multiPart, "POST"));
+ multiPart->deleteLater();
+
+ QCOMPARE(reply->url(), url);
+ QCOMPARE(reply->error(), QNetworkReply::NoError);
+
+ QCOMPARE(reply->attribute(QNetworkRequest::HttpStatusCodeAttribute).toInt(), 200); // 200 OK
+
+ QVERIFY(multiPart->boundary().count() > 20); // check that there is randomness after the "boundary_.oOo._" string
+ QVERIFY(multiPart->boundary().count() < 70);
+ QByteArray replyData = reply->readAll();
+
+ expectedReplyData.prepend("content type: multipart/" + contentType + "; boundary=\"" + multiPart->boundary() + "\"\n");
+// QEXPECT_FAIL("nested", "the server does not understand nested multipart messages", Continue); // see above
+ QCOMPARE(replyData, expectedReplyData);
}
#ifndef QT_NO_SSL
diff --git a/tests/auto/network/kernel/qhostinfo/BLACKLIST b/tests/auto/network/kernel/qhostinfo/BLACKLIST
new file mode 100644
index 0000000000..87c5fe991f
--- /dev/null
+++ b/tests/auto/network/kernel/qhostinfo/BLACKLIST
@@ -0,0 +1,6 @@
+# These tests fail due to a DNS server issue
+# (this is not a Qt bug)
+[lookupIPv6:a-plus-aaaa]
+windows ci
+[blockingLookup:a-plus-aaaa]
+windows ci
diff --git a/tests/auto/network/kernel/qhostinfo/qhostinfo.pro b/tests/auto/network/kernel/qhostinfo/qhostinfo.pro
index 67a37faeb5..3d8457dd46 100644
--- a/tests/auto/network/kernel/qhostinfo/qhostinfo.pro
+++ b/tests/auto/network/kernel/qhostinfo/qhostinfo.pro
@@ -8,7 +8,4 @@ QT = core-private network-private testlib
win32:LIBS += -lws2_32
-# needed for getaddrinfo with official MinGW
-mingw:DEFINES += _WIN32_WINNT=0x0501
-
winrt: WINRT_MANIFEST.capabilities += internetClientServer
diff --git a/tests/auto/network/kernel/qhostinfo/tst_qhostinfo.cpp b/tests/auto/network/kernel/qhostinfo/tst_qhostinfo.cpp
index cb7e66bad4..caf8145c19 100644
--- a/tests/auto/network/kernel/qhostinfo/tst_qhostinfo.cpp
+++ b/tests/auto/network/kernel/qhostinfo/tst_qhostinfo.cpp
@@ -64,14 +64,10 @@
#include <qhostinfo.h>
#include "private/qhostinfo_p.h"
-#if !defined(QT_NO_GETADDRINFO)
-# include <sys/types.h>
-# if defined(Q_OS_UNIX)
+#include <sys/types.h>
+#if defined(Q_OS_UNIX)
# include <sys/socket.h>
-# endif
-# if !defined(Q_OS_WIN)
# include <netdb.h>
-# endif
#endif
#include "../../../network-settings.h"
@@ -204,15 +200,13 @@ void tst_QHostInfo::initTestCase()
ipv6Available = true;
}
-// HP-UX 11i does not support IPv6 reverse lookups.
-#if !defined(QT_NO_GETADDRINFO) && !(defined(Q_OS_HPUX) && defined(__ia64))
// check if the system getaddrinfo can do IPv6 lookups
struct addrinfo hint, *result = 0;
memset(&hint, 0, sizeof hint);
hint.ai_family = AF_UNSPEC;
-# ifdef AI_ADDRCONFIG
+#ifdef AI_ADDRCONFIG
hint.ai_flags = AI_ADDRCONFIG;
-# endif
+#endif
int res = getaddrinfo("::1", "80", &hint, &result);
if (res == 0) {
@@ -224,7 +218,6 @@ void tst_QHostInfo::initTestCase()
ipv6LookupsAvailable = true;
}
}
-#endif
// run each testcase with and without test enabled
QTest::addColumn<bool>("cache");
diff --git a/tests/auto/other/gestures/BLACKLIST b/tests/auto/other/gestures/BLACKLIST
index e33d36e201..bd43b99d39 100644
--- a/tests/auto/other/gestures/BLACKLIST
+++ b/tests/auto/other/gestures/BLACKLIST
@@ -1,5 +1,7 @@
[]
rhel-7.1
rhel-7.2
+rhel-7.3
+rhel-7.4
[customGesture]
opensuse-13.1
diff --git a/tests/auto/widgets/dialogs/qfiledialog2/tst_qfiledialog2.cpp b/tests/auto/widgets/dialogs/qfiledialog2/tst_qfiledialog2.cpp
index 79dfaee6f2..09e070ac20 100644
--- a/tests/auto/widgets/dialogs/qfiledialog2/tst_qfiledialog2.cpp
+++ b/tests/auto/widgets/dialogs/qfiledialog2/tst_qfiledialog2.cpp
@@ -689,7 +689,7 @@ void tst_QFileDialog2::completionOnLevelAfterRoot()
}
}
if (testDir.isEmpty())
- QSKIP("This test requires to have an unique directory of at least six ascii characters under c:/");
+ QSKIP("This test requires to have a unique directory of at least six ascii characters under c:/");
#else
fd.setFilter(QDir::Hidden | QDir::AllDirs | QDir::Files | QDir::System);
fd.setDirectory("/");
diff --git a/tests/auto/widgets/kernel/qwidget/BLACKLIST b/tests/auto/widgets/kernel/qwidget/BLACKLIST
index 8e8602840e..0b1d7b4437 100644
--- a/tests/auto/widgets/kernel/qwidget/BLACKLIST
+++ b/tests/auto/widgets/kernel/qwidget/BLACKLIST
@@ -14,6 +14,8 @@ ubuntu-14.04
ubuntu-16.04
rhel-7.1
rhel-7.2
+rhel-7.3
+rhel-7.4
osx
[focusProxyAndInputMethods]
linux
diff --git a/tests/auto/widgets/widgets/qmenu/tst_qmenu.cpp b/tests/auto/widgets/widgets/qmenu/tst_qmenu.cpp
index 4408533c85..7689669d9b 100644
--- a/tests/auto/widgets/widgets/qmenu/tst_qmenu.cpp
+++ b/tests/auto/widgets/widgets/qmenu/tst_qmenu.cpp
@@ -135,6 +135,7 @@ private slots:
void menuSize_Scrolling_data();
void menuSize_Scrolling();
void tearOffMenuNotDisplayed();
+ void QTBUG_61039_menu_shortcuts();
protected slots:
void onActivated(QAction*);
@@ -1644,5 +1645,32 @@ void tst_QMenu::tearOffMenuNotDisplayed()
QVERIFY(!torn->isVisible());
}
+void tst_QMenu::QTBUG_61039_menu_shortcuts()
+{
+ QAction *actionKamen = new QAction("Action Kamen");
+ actionKamen->setShortcut(QKeySequence(QLatin1String("K")));
+
+ QAction *actionJoe = new QAction("Action Joe");
+ actionJoe->setShortcut(QKeySequence(QLatin1String("Ctrl+J")));
+
+ QMenu menu;
+ menu.addAction(actionKamen);
+ menu.addAction(actionJoe);
+ QVERIFY(!menu.platformMenu());
+
+ QWidget widget;
+ widget.addAction(menu.menuAction());
+ widget.show();
+ QVERIFY(QTest::qWaitForWindowActive(&widget));
+
+ QSignalSpy actionKamenSpy(actionKamen, &QAction::triggered);
+ QTest::keyClick(&widget, Qt::Key_K);
+ QTRY_COMPARE(actionKamenSpy.count(), 1);
+
+ QSignalSpy actionJoeSpy(actionJoe, &QAction::triggered);
+ QTest::keyClick(&widget, Qt::Key_J, Qt::ControlModifier);
+ QTRY_COMPARE(actionJoeSpy.count(), 1);
+}
+
QTEST_MAIN(tst_QMenu)
#include "tst_qmenu.moc"
diff --git a/tests/auto/widgets/widgets/qmenubar/BLACKLIST b/tests/auto/widgets/widgets/qmenubar/BLACKLIST
index 06776d961d..ee08086e83 100644
--- a/tests/auto/widgets/widgets/qmenubar/BLACKLIST
+++ b/tests/auto/widgets/widgets/qmenubar/BLACKLIST
@@ -1,9 +1,5 @@
[check_menuPosition]
ubuntu-14.04
ubuntu-16.04
-[taskQTBUG4965_escapeEaten]
-ubuntu-14.04
-ubuntu-16.04
-redhatenterpriselinuxworkstation-6.6
[task256322_highlight]
osx
diff --git a/tests/auto/widgets/widgets/qmenubar/tst_qmenubar.cpp b/tests/auto/widgets/widgets/qmenubar/tst_qmenubar.cpp
index fd1248bd53..2ccd87d1cc 100644
--- a/tests/auto/widgets/widgets/qmenubar/tst_qmenubar.cpp
+++ b/tests/auto/widgets/widgets/qmenubar/tst_qmenubar.cpp
@@ -1374,6 +1374,7 @@ void tst_QMenuBar::menubarSizeHint()
void tst_QMenuBar::taskQTBUG4965_escapeEaten()
{
QMenuBar menubar;
+ menubar.setNativeMenuBar(false);
QMenu menu("menu1");
QAction *first = menubar.addMenu(&menu);
menu.addAction("quit", &menubar, SLOT(close()), QKeySequence("ESC"));
diff --git a/tests/auto/xml/sax/qxmlsimplereader/tst_qxmlsimplereader.cpp b/tests/auto/xml/sax/qxmlsimplereader/tst_qxmlsimplereader.cpp
index 8a5c8ec1df..f77fd2ebab 100644
--- a/tests/auto/xml/sax/qxmlsimplereader/tst_qxmlsimplereader.cpp
+++ b/tests/auto/xml/sax/qxmlsimplereader/tst_qxmlsimplereader.cpp
@@ -562,7 +562,7 @@ void tst_QXmlSimpleReader::inputFromSocket()
QSKIP("WinRT does not support connecting to localhost");
#endif
- QTRY_VERIFY(server->listening);
+ QTRY_VERIFY_WITH_TIMEOUT(server->listening, 15000);
QTcpSocket sock;
sock.connectToHost(QHostAddress::LocalHost, TEST_PORT);
diff --git a/tests/manual/network_remote_stresstest/tst_network_remote_stresstest.cpp b/tests/manual/network_remote_stresstest/tst_network_remote_stresstest.cpp
index 99e3d148df..f5c3bfde34 100644
--- a/tests/manual/network_remote_stresstest/tst_network_remote_stresstest.cpp
+++ b/tests/manual/network_remote_stresstest/tst_network_remote_stresstest.cpp
@@ -156,7 +156,7 @@ void tst_NetworkRemoteStressTest::clearManager()
bool nativeLookup(const char *hostname, int port, QByteArray &buf)
{
-#if !defined(QT_NO_GETADDRINFO) && 0
+#if 0
addrinfo *res = 0;
struct addrinfo hints;
memset(&hints, 0, sizeof(hints));
diff --git a/tests/manual/network_stresstest/tst_network_stresstest.cpp b/tests/manual/network_stresstest/tst_network_stresstest.cpp
index d46703c671..03df1633d5 100644
--- a/tests/manual/network_stresstest/tst_network_stresstest.cpp
+++ b/tests/manual/network_stresstest/tst_network_stresstest.cpp
@@ -147,7 +147,7 @@ void tst_NetworkStressTest::clearManager()
bool nativeLookup(const char *hostname, int port, QByteArray &buf)
{
-#if !defined(QT_NO_GETADDRINFO) && 0
+#if 0
addrinfo *res = 0;
struct addrinfo hints;
memset(&hints, 0, sizeof(hints));
diff --git a/tests/manual/qtabletevent/regular_widgets/main.cpp b/tests/manual/qtabletevent/regular_widgets/main.cpp
index 891d7bcab6..caf8c70c6f 100644
--- a/tests/manual/qtabletevent/regular_widgets/main.cpp
+++ b/tests/manual/qtabletevent/regular_widgets/main.cpp
@@ -59,6 +59,25 @@ struct TabletPoint
qreal angle;
};
+class ProximityEventFilter : public QObject
+{
+public:
+ explicit ProximityEventFilter(QObject *parent) : QObject(parent) { }
+
+ bool eventFilter(QObject *, QEvent *event) override
+ {
+ switch (event->type()) {
+ case QEvent::TabletEnterProximity:
+ case QEvent::TabletLeaveProximity:
+ qDebug() << event;
+ break;
+ default:
+ break;
+ }
+ return false;
+ }
+};
+
class EventReportWidget : public QWidget
{
Q_OBJECT
@@ -69,39 +88,34 @@ public slots:
void clearPoints() { m_points.clear(); update(); }
signals:
- void stats(QString s);
+ void stats(QString s, int timeOut = 0);
protected:
- void mouseDoubleClickEvent(QMouseEvent *event) { outputMouseEvent(event); }
- void mouseMoveEvent(QMouseEvent *event) { outputMouseEvent(event); }
- void mousePressEvent(QMouseEvent *event) { outputMouseEvent(event); }
- void mouseReleaseEvent(QMouseEvent *event) { outputMouseEvent(event); }
+ void mouseDoubleClickEvent(QMouseEvent *event) override { outputMouseEvent(event); }
+ void mouseMoveEvent(QMouseEvent *event) override { outputMouseEvent(event); }
+ void mousePressEvent(QMouseEvent *event) override { outputMouseEvent(event); }
+ void mouseReleaseEvent(QMouseEvent *event) override { outputMouseEvent(event); }
- void tabletEvent(QTabletEvent *);
+ void tabletEvent(QTabletEvent *) override;
- bool event(QEvent *event);
+ bool event(QEvent *event) override;
- void paintEvent(QPaintEvent *);
- void timerEvent(QTimerEvent *);
+ void paintEvent(QPaintEvent *) override;
+ void timerEvent(QTimerEvent *) override;
private:
void outputMouseEvent(QMouseEvent *event);
- bool m_lastIsMouseMove;
- bool m_lastIsTabletMove;
- Qt::MouseButton m_lastButton;
+ bool m_lastIsMouseMove = false;
+ bool m_lastIsTabletMove = false;
+ Qt::MouseButton m_lastButton = Qt::NoButton;
QVector<TabletPoint> m_points;
QVector<QPointF> m_touchPoints;
- int m_tabletMoveCount;
- int m_paintEventCount;
+ int m_tabletMoveCount = 0;
+ int m_paintEventCount = 0;
};
EventReportWidget::EventReportWidget()
- : m_lastIsMouseMove(false)
- , m_lastIsTabletMove(false)
- , m_lastButton(Qt::NoButton)
- , m_tabletMoveCount(0)
- , m_paintEventCount(0)
{
setAttribute(Qt::WA_AcceptTouchEvents);
startTimer(1000);
@@ -118,7 +132,7 @@ void EventReportWidget::paintEvent(QPaintEvent *)
p.setPen(Qt::white);
QPainterPath ellipse;
ellipse.addEllipse(0, 0, halfLineSpacing * 5, halfLineSpacing);
- foreach (const TabletPoint &t, m_points) {
+ for (const TabletPoint &t : qAsConst(m_points)) {
if (geom.contains(t.pos)) {
QPainterPath pp;
pp.addEllipse(t.pos, halfLineSpacing, halfLineSpacing);
@@ -168,10 +182,6 @@ void EventReportWidget::tabletEvent(QTabletEvent *event)
QWidget::tabletEvent(event);
bool isMove = false;
switch (event->type()) {
- case QEvent::TabletEnterProximity:
- case QEvent::TabletLeaveProximity:
- qDebug() << "proximity" << event;
- break;
case QEvent::TabletMove:
m_points.push_back(TabletPoint(event->pos(), TabletMove, m_lastButton, event->pointerType(), event->pressure(), event->rotation()));
update();
@@ -243,15 +253,16 @@ void EventReportWidget::timerEvent(QTimerEvent *)
int main(int argc, char *argv[])
{
QApplication app(argc, argv);
+ app.installEventFilter(new ProximityEventFilter(&app));
QMainWindow mainWindow;
mainWindow.setWindowTitle(QString::fromLatin1("Tablet Test %1").arg(QT_VERSION_STR));
EventReportWidget *widget = new EventReportWidget;
widget->setMinimumSize(640, 480);
QMenu *fileMenu = mainWindow.menuBar()->addMenu("File");
- QObject::connect(fileMenu->addAction("Clear"), SIGNAL(triggered()), widget, SLOT(clearPoints()));
- QObject::connect(widget, SIGNAL(stats(QString)), mainWindow.statusBar(), SLOT(showMessage(QString)));
- QAction *quitAction = fileMenu->addAction("Quit");
- QObject::connect(quitAction, SIGNAL(triggered()), qApp, SLOT(quit()));
+ fileMenu->addAction("Clear", widget, &EventReportWidget::clearPoints);
+ QObject::connect(widget, &EventReportWidget::stats,
+ mainWindow.statusBar(), &QStatusBar::showMessage);
+ QAction *quitAction = fileMenu->addAction("Quit", qApp, &QCoreApplication::quit);
quitAction->setShortcut(Qt::CTRL + Qt::Key_Q);
mainWindow.setCentralWidget(widget);
mainWindow.show();
diff --git a/tests/manual/widgets/itemviews/qtreewidget/main.cpp b/tests/manual/widgets/itemviews/qtreewidget/main.cpp
index 5d129101fd..fb72c404a5 100644
--- a/tests/manual/widgets/itemviews/qtreewidget/main.cpp
+++ b/tests/manual/widgets/itemviews/qtreewidget/main.cpp
@@ -95,6 +95,18 @@ public:
item5sl.append("Approver");
/* QTreeWidgetItem *item4 =*/ new QTreeWidgetItem(item4, item5sl);
+ treeWidget->setDragEnabled(true);
+ treeWidget->viewport()->setAcceptDrops(true);
+ treeWidget->setDragDropMode(QAbstractItemView::InternalMove);
+
+ for (int u = 0; u < 12; ++u) {
+ const QString username = QString("Anonymous User %1").arg(u + 1);
+ QStringList info;
+ info << username << username << QString::number(u + 1) << QStringLiteral("Test user");
+ new QTreeWidgetItem(item4, info);
+ }
+
+ treeWidget->expandAll();
treeWidget->setColumnCount(item2sl.size());
QStringList itemInfo("First Name");
itemInfo.append("Last Name");
@@ -133,6 +145,7 @@ int main(int argc, char *argv[])
{
QApplication app(argc, argv);
ExampleDlg d;
+ d.resize(d.sizeHint() * 3);
d.show();
app.exec();
}