From f9858ee2f51095e84602156a29d9d9a57a607045 Mon Sep 17 00:00:00 2001
From: Allan Sandfeld Jensen <allan.jensen@qt.io>
Date: Wed, 7 Feb 2018 16:38:31 +0100
Subject: [PATCH] Fix race condition in
 tst_QWebEngineDownloads::downloadTwoLinks()
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

Accept the two requests might come out of order

Change-Id: I313506d975ebf007fce3cd857baa742866b8f38b
Reviewed-by: Michael Brüning <michael.bruning@qt.io>
---
 .../qwebenginedownloads/tst_qwebenginedownloads.cpp        | 7 ++++++-
 1 file changed, 6 insertions(+), 1 deletion(-)

diff --git a/tests/auto/widgets/qwebenginedownloads/tst_qwebenginedownloads.cpp b/tests/auto/widgets/qwebenginedownloads/tst_qwebenginedownloads.cpp
index 606fe5b12..79a5aa2dc 100644
--- a/tests/auto/widgets/qwebenginedownloads/tst_qwebenginedownloads.cpp
+++ b/tests/auto/widgets/qwebenginedownloads/tst_qwebenginedownloads.cpp
@@ -472,11 +472,16 @@ void tst_QWebEngineDownloads::downloadTwoLinks()
     std::unique_ptr<HttpReqRep> file1RR(results.takeFirst());
     QVERIFY(file1RR);
     QCOMPARE(file1RR->requestMethod(), QByteArrayLiteral("GET"));
-    QCOMPARE(file1RR->requestPath(), QByteArrayLiteral("/file1"));
     QTRY_COMPARE(requestSpy.count(), 4);
     std::unique_ptr<HttpReqRep> file2RR(results.takeFirst());
     QVERIFY(file2RR);
     QCOMPARE(file2RR->requestMethod(), QByteArrayLiteral("GET"));
+
+    // Handle one request overtaking the other
+    if (file1RR->requestPath() == QByteArrayLiteral("/file2"))
+        std::swap(file1RR, file2RR);
+
+    QCOMPARE(file1RR->requestPath(), QByteArrayLiteral("/file1"));
     QCOMPARE(file2RR->requestPath(), QByteArrayLiteral("/file2"));
 
     file1RR->setResponseHeader(QByteArrayLiteral("content-type"), QByteArrayLiteral("text/plain"));
-- 
GitLab