From d25075fb681fa92fad1f9bdcb262a3e361e7659e Mon Sep 17 00:00:00 2001 From: Kirill Burtsev Date: Fri, 31 Jul 2020 16:02:36 +0200 Subject: Don't send duplicate load progress values MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Suppress duplicated progress values coming from chromium. Verify this behavior reliably (and not only 0 and 100 value) by loading html with subresources with minor delay through test http server. Change-Id: Id034dda9012212d54d12fc95d5939ba301577c1c Reviewed-by: Jüri Valdmann --- tests/auto/widgets/loadsignals/tst_loadsignals.cpp | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) (limited to 'tests/auto/widgets/loadsignals/tst_loadsignals.cpp') diff --git a/tests/auto/widgets/loadsignals/tst_loadsignals.cpp b/tests/auto/widgets/loadsignals/tst_loadsignals.cpp index 20e5fbf0d..8eeadeeb8 100644 --- a/tests/auto/widgets/loadsignals/tst_loadsignals.cpp +++ b/tests/auto/widgets/loadsignals/tst_loadsignals.cpp @@ -28,6 +28,7 @@ #include +#include "httpserver.h" #include "../util.h" #include "qdebug.h" #include "qwebenginepage.h" @@ -133,18 +134,25 @@ void tst_LoadSignals::loadStartedAndFinishedCount() */ void tst_LoadSignals::monotonicity() { - view->load(QUrl("qrc:///resources/page1.html")); + HttpServer server; + server.setResourceDirs({ TESTS_SHARED_DATA_DIR }); + connect(&server, &HttpServer::newRequest, [] (HttpReqRep *) { + QTest::qWait(250); // just add delay to trigger some progress for every sub resource + }); + QVERIFY(server.start()); + + view->load(server.url("/loadprogress/main.html")); QTRY_COMPARE(loadFinishedSpy->size(), 1); bool loadSucceeded = (*loadFinishedSpy)[0][0].toBool(); QVERIFY(loadSucceeded); // first loadProgress should have 0% progress - QCOMPARE(loadProgressSpy->first()[0].toInt(), 0); + QCOMPARE(loadProgressSpy->takeFirst()[0].toInt(), 0); - // every loadProgress should have at least as much progress as the one before + // every loadProgress should have more progress than the one before int progress = 0; for (auto item : *loadProgressSpy) { - QVERIFY(item[0].toInt() >= progress); + QVERIFY(progress < item[0].toInt()); progress = item[0].toInt(); } -- cgit v1.2.3