From 6de032c11537c9d89a52cece5912ac46f3a40f0d Mon Sep 17 00:00:00 2001 From: Kirill Burtsev Date: Thu, 20 Jan 2022 18:36:02 +0100 Subject: Add testing of default constructed profile back Amends d0ff107c00. Re-add test of default user created profile without storage name. Also remove duplicated test for profile with storage name. Pick-to: 6.2 6.3 Change-Id: I5d404e06a8ea9a349d5122c7bf138cde768e8391 Reviewed-by: Allan Sandfeld Jensen --- .../qwebengineprofile/tst_qwebengineprofile.cpp | 41 +++++++++------------- 1 file changed, 17 insertions(+), 24 deletions(-) (limited to 'tests') diff --git a/tests/auto/widgets/qwebengineprofile/tst_qwebengineprofile.cpp b/tests/auto/widgets/qwebengineprofile/tst_qwebengineprofile.cpp index 38f3b04e7..c09f3b51a 100644 --- a/tests/auto/widgets/qwebengineprofile/tst_qwebengineprofile.cpp +++ b/tests/auto/widgets/qwebengineprofile/tst_qwebengineprofile.cpp @@ -57,9 +57,9 @@ class tst_QWebEngineProfile : public QObject private Q_SLOTS: void initTestCase(); - void userDefaultProfile(); + void defaultProfile_data(); void defaultProfile(); - void testProfile(); + void userDefinedProfile(); void clearDataFromCache(); void disableCache(); void urlSchemeHandlers(); @@ -103,32 +103,28 @@ void tst_QWebEngineProfile::initTestCase() QWebEngineUrlScheme::registerScheme(myscheme); } -void tst_QWebEngineProfile::userDefaultProfile() +static QString StandardCacheLocation() { static auto p = QStandardPaths::writableLocation(QStandardPaths::CacheLocation); return p; } +static QString StandardAppDataLocation() { static auto p = QStandardPaths::writableLocation(QStandardPaths::AppDataLocation); return p; } + +void tst_QWebEngineProfile::defaultProfile_data() { - QWebEngineProfile profile("Default"); - 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::AppDataLocation) - + QStringLiteral("/QtWebEngine/Default")); + QTest::addColumn("userCreated"); + QTest::addRow("global") << false; + QTest::addRow("user") << true; } void tst_QWebEngineProfile::defaultProfile() { - QWebEngineProfile *profile = QWebEngineProfile::defaultProfile(); + QFETCH(bool, userCreated); + QScopedPointer p(userCreated ? new QWebEngineProfile : nullptr); + QWebEngineProfile *profile = userCreated ? p.get() : QWebEngineProfile::defaultProfile(); QVERIFY(profile); QVERIFY(profile->isOffTheRecord()); + QCOMPARE(profile->storageName(), QString()); QCOMPARE(profile->httpCacheType(), QWebEngineProfile::MemoryHttpCache); QCOMPARE(profile->persistentCookiesPolicy(), QWebEngineProfile::NoPersistentCookies); QCOMPARE(profile->cachePath(), QString()); - QCOMPARE(profile->persistentStoragePath(), - QStandardPaths::writableLocation(QStandardPaths::AppDataLocation) - + QStringLiteral("/QtWebEngine/OffTheRecord")); + QCOMPARE(profile->persistentStoragePath(), StandardAppDataLocation() + QStringLiteral("/QtWebEngine/OffTheRecord")); // TBD: setters do not really work profile->setCachePath(QStringLiteral("/home/foo/bar")); QCOMPARE(profile->cachePath(), QString()); @@ -140,18 +136,15 @@ void tst_QWebEngineProfile::defaultProfile() QCOMPARE(profile->persistentCookiesPolicy(), QWebEngineProfile::NoPersistentCookies); } - -void tst_QWebEngineProfile::testProfile() +void tst_QWebEngineProfile::userDefinedProfile() { 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::AppDataLocation) - + QStringLiteral("/QtWebEngine/Test")); + QCOMPARE(profile.cachePath(), StandardCacheLocation() + QStringLiteral("/QtWebEngine/Test")); + QCOMPARE(profile.persistentStoragePath(), StandardAppDataLocation() + QStringLiteral("/QtWebEngine/Test")); } class AutoDir : public QDir -- cgit v1.2.3