From f34292d147bfde094d8ec4a58f7b0e5f77a1fd0b Mon Sep 17 00:00:00 2001 From: Kirill Burtsev Date: Thu, 20 Jan 2022 19:14:02 +0100 Subject: Add QML test for basic profiles and fix the docs accordingly Amends d0ff107c00. Ensure default values for profile settings match the docs. Also fix doc's issues after off-the-record toggle to off by default. Pick-to: 6.2 6.3 Change-Id: I558a77dbec82d7f2b335b1a2ceca74ab66a1a6e9 Reviewed-by: Michal Klocek --- tests/auto/quick/qmltests/CMakeLists.txt | 1 + .../auto/quick/qmltests/data/tst_basicProfiles.qml | 115 +++++++++++++++++++++ 2 files changed, 116 insertions(+) create mode 100644 tests/auto/quick/qmltests/data/tst_basicProfiles.qml (limited to 'tests/auto/quick') diff --git a/tests/auto/quick/qmltests/CMakeLists.txt b/tests/auto/quick/qmltests/CMakeLists.txt index 455c4c746..2500ed6df 100644 --- a/tests/auto/quick/qmltests/CMakeLists.txt +++ b/tests/auto/quick/qmltests/CMakeLists.txt @@ -18,6 +18,7 @@ set(testList tst_activeFocusOnPress.qml tst_audioMuted.qml tst_contextMenu.qml + tst_basicProfiles.qml tst_desktopBehaviorLoadHtml.qml tst_download.qml tst_favicon.qml diff --git a/tests/auto/quick/qmltests/data/tst_basicProfiles.qml b/tests/auto/quick/qmltests/data/tst_basicProfiles.qml new file mode 100644 index 000000000..a84e4e997 --- /dev/null +++ b/tests/auto/quick/qmltests/data/tst_basicProfiles.qml @@ -0,0 +1,115 @@ +/**************************************************************************** +** +** Copyright (C) 2022 The Qt Company Ltd. +** Contact: https://www.qt.io/licensing/ +** +** This file is part of the QtWebEngine module of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:GPL-EXCEPT$ +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms +** and conditions see https://www.qt.io/terms-conditions. For further +** information use the contact form at https://www.qt.io/contact-us. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 3 as published by the Free Software +** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT +** included in the packaging of this file. Please review the following +** information to ensure the GNU General Public License requirements will +** be met: https://www.gnu.org/licenses/gpl-3.0.html. +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +import QtQuick +import QtTest +import QtWebEngine +import Qt.labs.platform + +Item { + WebEngineProfile { id: otrProfile; /* MEMO implicit offTheRecord: true */ } + WebEngineProfile { id: nonOtrProfile; offTheRecord: false } + + function getPath(path, offset = 1) { return path.substr(path.indexOf(':') + offset, path.length) } + property string appDataLocation: getPath(getPath(StandardPaths.writableLocation(StandardPaths.AppDataLocation).toString(), 3)) + property string cacheLocation: getPath(getPath(StandardPaths.writableLocation(StandardPaths.CacheLocation).toString(), 3)) + property string downloadLocation: getPath(getPath(StandardPaths.writableLocation(StandardPaths.DownloadLocation).toString(), 3)) + + TestCase { + name: "BasicProfiles" + + function test_defaultProfile() { + let p = WebEngine.defaultProfile + verify(p.offTheRecord) + + compare(p.storageName, '') + compare(p.cachePath, '') + compare(getPath(p.persistentStoragePath), appDataLocation + '/QtWebEngine/OffTheRecord') + compare(p.httpCacheType, WebEngineProfile.MemoryHttpCache) + compare(p.httpCacheMaximumSize, 0) + compare(p.persistentCookiesPolicy, WebEngineProfile.NoPersistentCookies) + + compare(getPath(p.downloadPath), downloadLocation) + compare(p.httpAcceptLanguage, '') + verify(p.httpUserAgent !== '') + compare(p.spellCheckEnabled, false) + compare(p.spellCheckLanguages, []) + + compare(p.userScripts.collection, []) + } + + function test_otrProfile() { + let p = otrProfile + verify(p.offTheRecord) + + compare(p.storageName, '') + compare(p.cachePath, '') + compare(getPath(p.persistentStoragePath), appDataLocation + '/QtWebEngine/OffTheRecord') + compare(p.httpCacheType, WebEngineProfile.MemoryHttpCache) + compare(p.httpCacheMaximumSize, 0) + compare(p.persistentCookiesPolicy, WebEngineProfile.NoPersistentCookies) + + compare(getPath(p.downloadPath), downloadLocation) + compare(p.httpAcceptLanguage, '') + verify(p.httpUserAgent !== '') + compare(p.spellCheckEnabled, false) + compare(p.spellCheckLanguages, []) + + compare(p.userScripts.collection, []) + } + + function test_nonOtrProfile() { + let p = nonOtrProfile + verify(!p.offTheRecord) + + compare(p.storageName, '') + compare(p.cachePath, '') + compare(getPath(p.persistentStoragePath), appDataLocation + '/QtWebEngine/UnknownProfile') + compare(p.httpCacheType, WebEngineProfile.MemoryHttpCache) + compare(p.httpCacheMaximumSize, 0) + compare(p.persistentCookiesPolicy, WebEngineProfile.NoPersistentCookies) + + compare(getPath(p.downloadPath), downloadLocation) + compare(p.httpAcceptLanguage, '') + verify(p.httpUserAgent !== '') + compare(p.spellCheckEnabled, false) + compare(p.spellCheckLanguages, []) + + compare(p.userScripts.collection, []) + + p.storageName = 'Test' + compare(p.storageName, 'Test') + compare(getPath(p.cachePath), cacheLocation + '/QtWebEngine/' + p.storageName) + compare(getPath(p.persistentStoragePath), appDataLocation + '/QtWebEngine/' + p.storageName) + + compare(p.httpCacheType, WebEngineProfile.DiskHttpCache) + compare(p.httpCacheMaximumSize, 0) + compare(p.persistentCookiesPolicy, WebEngineProfile.AllowPersistentCookies) + } + } +} -- cgit v1.2.3