summaryrefslogtreecommitdiffstats
path: root/tests
diff options
context:
space:
mode:
authorKirill Burtsev <kirill.burtsev@qt.io>2022-01-20 18:36:02 +0100
committerKirill Burtsev <kirill.burtsev@qt.io>2022-02-17 19:06:12 +0100
commit6de032c11537c9d89a52cece5912ac46f3a40f0d (patch)
treea94e4e9ebfc4658ed2ca5e4fde2a54786e6bafae /tests
parent82357352b49fdcba80727feec441053f676b5af2 (diff)
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 <allan.jensen@qt.io>
Diffstat (limited to 'tests')
-rw-r--r--tests/auto/widgets/qwebengineprofile/tst_qwebengineprofile.cpp41
1 files changed, 17 insertions, 24 deletions
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<bool>("userCreated");
+ QTest::addRow("global") << false;
+ QTest::addRow("user") << true;
}
void tst_QWebEngineProfile::defaultProfile()
{
- QWebEngineProfile *profile = QWebEngineProfile::defaultProfile();
+ QFETCH(bool, userCreated);
+ QScopedPointer<QWebEngineProfile> 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