summaryrefslogtreecommitdiffstats
path: root/tests/auto/widgets/qwebenginehistory
diff options
context:
space:
mode:
authorPeter Varga <pvarga@inf.u-szeged.hu>2017-11-28 13:49:27 +0100
committerAllan Sandfeld Jensen <allan.jensen@qt.io>2017-11-29 23:25:49 +0000
commit3f4daf02723b16e83dfb9bcee654b5c803de1ae8 (patch)
treecd7596fb74a45749229050e1d0abc6aa7a592e26 /tests/auto/widgets/qwebenginehistory
parentf9eb2b95fcdb4df82d3ba8c4aab44347a2bad452 (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>
Diffstat (limited to 'tests/auto/widgets/qwebenginehistory')
-rw-r--r--tests/auto/widgets/qwebenginehistory/tst_qwebenginehistory.cpp30
1 files changed, 16 insertions, 14 deletions
diff --git a/tests/auto/widgets/qwebenginehistory/tst_qwebenginehistory.cpp b/tests/auto/widgets/qwebenginehistory/tst_qwebenginehistory.cpp
index d9bbce173..9fceffd7e 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,17 +303,17 @@ 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);
+ QTRY_COMPARE(loadFinishedSpy->count(), 6);
QTRY_COMPARE(hist->currentItemIndex(), initialCurrentIndex);
}