diff options
author | Peter Varga <pvarga@inf.u-szeged.hu> | 2017-11-28 13:49:27 +0100 |
---|---|---|
committer | Peter Varga <pvarga@inf.u-szeged.hu> | 2019-05-08 10:59:19 +0000 |
commit | 27357fb962d97a12c20f6969f8cba6044fbfa9d0 (patch) | |
tree | 43f7f7e1f0d8629b20c76a73132aeb69e99e8364 /tests | |
parent | b14fb79c5762b7181ad844a08fe56409c6bd79ad (diff) |
Fix tst_QWebEngineHistory widget auto tests
- Reset loadFinishedSpy counter after initialization
- Do not expect loadFinished signal after "same document" navigation
Change-Id: If78304d8fa67ec96b28811c148b4a23f664987fb
Reviewed-by: Viktor Engelmann <viktor.engelmann@qt.io>
Reviewed-by: Allan Sandfeld Jensen <allan.jensen@qt.io>
(cherry picked from commit 3f4daf02723b16e83dfb9bcee654b5c803de1ae8)
Diffstat (limited to 'tests')
-rw-r--r-- | tests/auto/widgets/qwebenginehistory/tst_qwebenginehistory.cpp | 32 |
1 files changed, 18 insertions, 14 deletions
diff --git a/tests/auto/widgets/qwebenginehistory/tst_qwebenginehistory.cpp b/tests/auto/widgets/qwebenginehistory/tst_qwebenginehistory.cpp index d9bbce173..d1b6005eb 100644 --- a/tests/auto/widgets/qwebenginehistory/tst_qwebenginehistory.cpp +++ b/tests/auto/widgets/qwebenginehistory/tst_qwebenginehistory.cpp @@ -40,6 +40,7 @@ protected : loadFinishedSpy->clear(); page->load(QUrl("qrc:/resources/page" + QString::number(nr) + ".html")); QTRY_COMPARE(loadFinishedSpy->count(), 1); + loadFinishedSpy->clear(); } public Q_SLOTS: @@ -160,7 +161,7 @@ void tst_QWebEngineHistory::forward() while (hist->canGoBack()) { hist->back(); histBackCount++; - QTRY_COMPARE(loadFinishedSpy->count(), histBackCount+1); + QTRY_COMPARE(loadFinishedSpy->count(), histBackCount); } QSignalSpy titleChangedSpy(page, SIGNAL(titleChanged(const QString&))); @@ -197,15 +198,15 @@ void tst_QWebEngineHistory::goToItem() QWebEngineHistoryItem current = hist->currentItem(); hist->back(); - QTRY_COMPARE(loadFinishedSpy->count(), 2); + QTRY_COMPARE(loadFinishedSpy->count(), 1); hist->back(); - QTRY_COMPARE(loadFinishedSpy->count(), 3); + QTRY_COMPARE(loadFinishedSpy->count(), 2); QVERIFY(hist->currentItem().title() != current.title()); hist->goToItem(current); - QTRY_COMPARE(loadFinishedSpy->count(), 3); + QTRY_COMPARE(loadFinishedSpy->count(), 2); QTRY_COMPARE(hist->currentItem().title(), current.title()); } @@ -228,10 +229,10 @@ void tst_QWebEngineHistory::items() void tst_QWebEngineHistory::backForwardItems() { hist->back(); - QTRY_COMPARE(loadFinishedSpy->count(), 2); + QTRY_COMPARE(loadFinishedSpy->count(), 1); hist->back(); - QTRY_COMPARE(loadFinishedSpy->count(), 3); + QTRY_COMPARE(loadFinishedSpy->count(), 2); QTRY_COMPARE(hist->items().size(), 5); QTRY_COMPARE(hist->backItems(100).size(), 2); @@ -281,16 +282,17 @@ void tst_QWebEngineHistory::serialize_2() // Force a "same document" navigation. page->load(page->url().toString() + QLatin1String("#dummyAnchor")); - QTRY_COMPARE(loadFinishedSpy->count(), 1); + // "same document" navigation doesn't trigger loadFinished signal. + QTRY_COMPARE(evaluateJavaScriptSync(page, "location.hash").toString(), QStringLiteral("#dummyAnchor")); int initialCurrentIndex = hist->currentItemIndex(); hist->back(); - QTRY_COMPARE(loadFinishedSpy->count(), 2); + QTRY_VERIFY(evaluateJavaScriptSync(page, "location.hash").toString().isEmpty()); hist->back(); - QTRY_COMPARE(loadFinishedSpy->count(), 3); + QTRY_COMPARE(loadFinishedSpy->count(), 1); hist->back(); - QTRY_COMPARE(loadFinishedSpy->count(), 4); + QTRY_COMPARE(loadFinishedSpy->count(), 2); //check if current index was changed (make sure that it is not last item) QVERIFY(hist->currentItemIndex() != initialCurrentIndex); //save current index @@ -301,18 +303,20 @@ void tst_QWebEngineHistory::serialize_2() load >> *hist; QVERIFY(load.status() == QDataStream::Ok); // Restoring the history will trigger a load. - QTRY_COMPARE(loadFinishedSpy->count(), 5); + QTRY_COMPARE(loadFinishedSpy->count(), 3); //check current index QTRY_COMPARE(hist->currentItemIndex(), oldCurrentIndex); hist->forward(); - QTRY_COMPARE(loadFinishedSpy->count(), 6); + QTRY_COMPARE(loadFinishedSpy->count(), 4); hist->forward(); - QTRY_COMPARE(loadFinishedSpy->count(), 7); + QTRY_COMPARE(loadFinishedSpy->count(), 5); hist->forward(); - QTRY_COMPARE(loadFinishedSpy->count(), 8); + // "same document" navigation doesn't trigger loadFinished signal. + QTRY_COMPARE(evaluateJavaScriptSync(page, "location.hash").toString(), QStringLiteral("#dummyAnchor")); QTRY_COMPARE(hist->currentItemIndex(), initialCurrentIndex); + QCOMPARE(loadFinishedSpy->count(), 5); } /** |