From 58dcd497ad8a0138a77a58001bc8adb3fd62fd73 Mon Sep 17 00:00:00 2001 From: Michal Klocek Date: Mon, 29 Jan 2018 13:37:12 +0100 Subject: Correct documentation for storage paths MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Udpdate docs and profile unit test for storage paths. Change-Id: I646a33571ad8458af4efcddf310489cdde3a4606 Reviewed-by: Leena Miettinen Reviewed-by: Michael BrĂ¼ning --- .../qwebengineprofile/tst_qwebengineprofile.cpp | 54 ++++++++++++++++++---- 1 file changed, 44 insertions(+), 10 deletions(-) (limited to 'tests/auto') diff --git a/tests/auto/widgets/qwebengineprofile/tst_qwebengineprofile.cpp b/tests/auto/widgets/qwebengineprofile/tst_qwebengineprofile.cpp index c443ee114..123cb7b32 100644 --- a/tests/auto/widgets/qwebengineprofile/tst_qwebengineprofile.cpp +++ b/tests/auto/widgets/qwebengineprofile/tst_qwebengineprofile.cpp @@ -42,8 +42,10 @@ class tst_QWebEngineProfile : public QObject Q_OBJECT private Q_SLOTS: - void defaultProfile(); - void profileConstructors(); + void init(); + void cleanup(); + void privateProfile(); + void testProfile(); void clearDataFromCache(); void disableCache(); void urlSchemeHandlers(); @@ -56,28 +58,60 @@ private Q_SLOTS: void changePersistentPath(); }; -void tst_QWebEngineProfile::defaultProfile() +void tst_QWebEngineProfile::init() { + //make sure defualt global profile is 'default' across all the tests QWebEngineProfile *profile = QWebEngineProfile::defaultProfile(); QVERIFY(profile); QVERIFY(!profile->isOffTheRecord()); QCOMPARE(profile->storageName(), QStringLiteral("Default")); QCOMPARE(profile->httpCacheType(), QWebEngineProfile::DiskHttpCache); QCOMPARE(profile->persistentCookiesPolicy(), QWebEngineProfile::AllowPersistentCookies); + QCOMPARE(profile->cachePath(), QStandardPaths::writableLocation(QStandardPaths::CacheLocation) + + QStringLiteral("/QtWebEngine/Default")); + QCOMPARE(profile->persistentStoragePath(), QStandardPaths::writableLocation(QStandardPaths::DataLocation) + + QStringLiteral("/QtWebEngine/Default")); } -void tst_QWebEngineProfile::profileConstructors() +void tst_QWebEngineProfile::cleanup() { - QWebEngineProfile otrProfile; - QWebEngineProfile diskProfile(QStringLiteral("Test")); + QWebEngineProfile *profile = QWebEngineProfile::defaultProfile(); + profile->setCachePath(QString()); + profile->setPersistentStoragePath(QString()); + profile->setHttpCacheType(QWebEngineProfile::DiskHttpCache); +} +void tst_QWebEngineProfile::privateProfile() +{ + QWebEngineProfile otrProfile; QVERIFY(otrProfile.isOffTheRecord()); - QVERIFY(!diskProfile.isOffTheRecord()); - QCOMPARE(diskProfile.storageName(), QStringLiteral("Test")); QCOMPARE(otrProfile.httpCacheType(), QWebEngineProfile::MemoryHttpCache); - QCOMPARE(diskProfile.httpCacheType(), QWebEngineProfile::DiskHttpCache); QCOMPARE(otrProfile.persistentCookiesPolicy(), QWebEngineProfile::NoPersistentCookies); - QCOMPARE(diskProfile.persistentCookiesPolicy(), QWebEngineProfile::AllowPersistentCookies); + QCOMPARE(otrProfile.cachePath(), QString()); + QCOMPARE(otrProfile.persistentStoragePath(), QString()); + // TBD: setters do not really work + otrProfile.setCachePath(QStringLiteral("/home/foo/bar")); + QCOMPARE(otrProfile.cachePath(), QString()); + otrProfile.setPersistentStoragePath(QStringLiteral("/home/foo/bar")); + QCOMPARE(otrProfile.persistentStoragePath(), QString()); + otrProfile.setHttpCacheType(QWebEngineProfile::DiskHttpCache); + QCOMPARE(otrProfile.httpCacheType(), QWebEngineProfile::MemoryHttpCache); + otrProfile.setPersistentCookiesPolicy(QWebEngineProfile::ForcePersistentCookies); + QCOMPARE(otrProfile.persistentCookiesPolicy(), QWebEngineProfile::NoPersistentCookies); +} + + +void tst_QWebEngineProfile::testProfile() +{ + QWebEngineProfile profile(QStringLiteral("Test")); + QVERIFY(!profile.isOffTheRecord()); + QCOMPARE(profile.storageName(), QStringLiteral("Test")); + QCOMPARE(profile.httpCacheType(), QWebEngineProfile::DiskHttpCache); + QCOMPARE(profile.persistentCookiesPolicy(), QWebEngineProfile::AllowPersistentCookies); + QCOMPARE(profile.cachePath(), QStandardPaths::writableLocation(QStandardPaths::CacheLocation) + + QStringLiteral("/QtWebEngine/Test")); + QCOMPARE(profile.persistentStoragePath(), QStandardPaths::writableLocation(QStandardPaths::DataLocation) + + QStringLiteral("/QtWebEngine/Test")); } void tst_QWebEngineProfile::clearDataFromCache() -- cgit v1.2.3