summaryrefslogtreecommitdiffstats
path: root/tests/auto/widgets/qwebenginehistory/tst_qwebenginehistory.cpp
diff options
context:
space:
mode:
authorSzabolcs David <davidsz@inf.u-szeged.hu>2016-11-22 05:42:20 -0800
committerSzabolcs David <davidsz@inf.u-szeged.hu>2016-12-06 11:40:45 +0000
commitbb85301877aa4599af75f3993af484fa8b957948 (patch)
tree07e8a1677650f21d492f164dc80d3c88850c12a2 /tests/auto/widgets/qwebenginehistory/tst_qwebenginehistory.cpp
parent60ab7cb732433a495faad7f8d85f3210ad132c2c (diff)
Ensure the deletion of testing pages
If a test fails it may trigger an assert in debug mode because the delete wasn't performed. Move QWebEngine* objects to the stack or use QScopedPointers to avoid these assertion fails. Change-Id: Ic44c3fddc7cd9cf57a0e2d1c57e0a6fd99033e02 Reviewed-by: Peter Varga <pvarga@inf.u-szeged.hu>
Diffstat (limited to 'tests/auto/widgets/qwebenginehistory/tst_qwebenginehistory.cpp')
-rw-r--r--tests/auto/widgets/qwebenginehistory/tst_qwebenginehistory.cpp21
1 files changed, 9 insertions, 12 deletions
diff --git a/tests/auto/widgets/qwebenginehistory/tst_qwebenginehistory.cpp b/tests/auto/widgets/qwebenginehistory/tst_qwebenginehistory.cpp
index a329b7307..dffd995c9 100644
--- a/tests/auto/widgets/qwebenginehistory/tst_qwebenginehistory.cpp
+++ b/tests/auto/widgets/qwebenginehistory/tst_qwebenginehistory.cpp
@@ -370,22 +370,21 @@ void tst_QWebEngineHistory::saveAndRestore_crash_2()
{
QByteArray buffer;
saveHistory(hist, &buffer);
- QWebEnginePage* page2 = new QWebEnginePage(this);
- QWebEngineHistory* hist2 = page2->history();
+ QWebEnginePage page2(this);
+ QWebEngineHistory* hist2 = page2.history();
for (unsigned i = 0; i < 5; i++) {
restoreHistory(hist2, &buffer);
saveHistory(hist2, &buffer);
}
- delete page2;
}
void tst_QWebEngineHistory::saveAndRestore_crash_3()
{
QByteArray buffer;
saveHistory(hist, &buffer);
- QWebEnginePage* page2 = new QWebEnginePage(this);
+ QWebEnginePage page2(this);
QWebEngineHistory* hist1 = hist;
- QWebEngineHistory* hist2 = page2->history();
+ QWebEngineHistory* hist2 = page2.history();
for (unsigned i = 0; i < 5; i++) {
restoreHistory(hist1, &buffer);
restoreHistory(hist2, &buffer);
@@ -395,7 +394,6 @@ void tst_QWebEngineHistory::saveAndRestore_crash_3()
saveHistory(hist2, &buffer);
hist2->clear();
}
- delete page2;
}
void tst_QWebEngineHistory::saveAndRestore_crash_4()
@@ -406,18 +404,18 @@ void tst_QWebEngineHistory::saveAndRestore_crash_4()
QByteArray buffer;
saveHistory(hist, &buffer);
- QWebEnginePage* page2 = new QWebEnginePage(this);
+ QScopedPointer<QWebEnginePage> page2(new QWebEnginePage(this));
// The initial crash was in PageCache.
page2->settings()->setMaximumPagesInCache(3);
// Load the history in a new page, waiting for the load to finish.
QEventLoop waitForLoadFinished;
- QObject::connect(page2, SIGNAL(loadFinished(bool)), &waitForLoadFinished, SLOT(quit()), Qt::QueuedConnection);
+ QObject::connect(page2.data(), SIGNAL(loadFinished(bool)), &waitForLoadFinished, SLOT(quit()), Qt::QueuedConnection);
QDataStream load(&buffer, QIODevice::ReadOnly);
load >> *page2->history();
waitForLoadFinished.exec();
- delete page2;
+ page2.reset();
// Give some time for the PageCache cleanup 0-timer to fire.
QTest::qWait(50);
#endif
@@ -456,12 +454,11 @@ void tst_QWebEngineHistory::clear()
QVERIFY(hist->count() == 1); // Leave current item.
QVERIFY(!actionBack->isEnabled());
- QWebEnginePage* page2 = new QWebEnginePage(this);
- QWebEngineHistory* hist2 = page2->history();
+ QWebEnginePage page2(this);
+ QWebEngineHistory* hist2 = page2.history();
QVERIFY(hist2->count() == 0);
hist2->clear();
QVERIFY(hist2->count() == 0); // Do not change anything.
- delete page2;
}
void tst_QWebEngineHistory::historyItemFromDeletedPage()