From d86feb3afcaacd57e3d661b969db173dea075f96 Mon Sep 17 00:00:00 2001 From: Szabolcs David Date: Tue, 26 Jan 2016 06:29:48 -0800 Subject: Extend HttpCacheType with NoCache option Add option to disable cache with passing NULL as cache backend. It behaves the same way as using HttpCache::set_mode(DISABLE), but saves some memory without instantiating backend factory. Change-Id: I1565cc773eda21a6bc73eebe14ab8046252a7755 Reviewed-by: Allan Sandfeld Jensen --- .../qwebengineprofile/tst_qwebengineprofile.cpp | 33 ++++++++++++++++++++++ 1 file changed, 33 insertions(+) (limited to 'tests/auto/widgets') diff --git a/tests/auto/widgets/qwebengineprofile/tst_qwebengineprofile.cpp b/tests/auto/widgets/qwebengineprofile/tst_qwebengineprofile.cpp index d24a43b41..93e93cb92 100644 --- a/tests/auto/widgets/qwebengineprofile/tst_qwebengineprofile.cpp +++ b/tests/auto/widgets/qwebengineprofile/tst_qwebengineprofile.cpp @@ -47,6 +47,7 @@ private Q_SLOTS: void defaultProfile(); void profileConstructors(); void clearDataFromCache(); + void disableCache(); }; void tst_QWebEngineProfile::defaultProfile() @@ -112,5 +113,37 @@ void tst_QWebEngineProfile::clearDataFromCache() cacheDir.removeRecursively(); } +void tst_QWebEngineProfile::disableCache() +{ + QWebEnginePage page; + QDir cacheDir("./tst_QWebEngineProfile_cacheDir"); + if (cacheDir.exists()) + cacheDir.removeRecursively(); + cacheDir.mkpath(cacheDir.path()); + + QWebEngineProfile *profile = page.profile(); + profile->setCachePath(cacheDir.path()); + QVERIFY(!cacheDir.entryList().contains("Cache")); + + profile->setHttpCacheType(QWebEngineProfile::NoCache); + QSignalSpy loadFinishedSpy(&page, SIGNAL(loadFinished(bool))); + page.load(QUrl("http://qt-project.org")); + if (!loadFinishedSpy.wait(10000) || !loadFinishedSpy.at(0).at(0).toBool()) + QSKIP("Couldn't load page from network, skipping test."); + + cacheDir.refresh(); + QVERIFY(!cacheDir.entryList().contains("Cache")); + + profile->setHttpCacheType(QWebEngineProfile::DiskHttpCache); + page.load(QUrl("http://qt-project.org")); + if (!loadFinishedSpy.wait(10000) || !loadFinishedSpy.at(1).at(0).toBool()) + QSKIP("Couldn't load page from network, skipping test."); + + cacheDir.refresh(); + QVERIFY(cacheDir.entryList().contains("Cache")); + + cacheDir.removeRecursively(); +} + QTEST_MAIN(tst_QWebEngineProfile) #include "tst_qwebengineprofile.moc" -- cgit v1.2.3